# This script is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

#-----------------------------------------------------------------------------
# This fvwm-themes "module" is all original code by Olivier Chapuis
# Copyright 2000, Olivier Chapuis
#-----------------------------------------------------------------------------

# For text with 70 characters per line

WindowTitle {FVWM Themes Documentation}
WindowSize 480 500
Font		-adobe-helvetica-bold-r-*-*-12-*

Init
Begin
    Set $Message = {}
    Set $Title = {}
    Set $InLineDoc = {}
    Set $Lang = {}
    Set $font = {-*-fixed-medium-r-semicondensed-*-13-*}

    # Arguments
    Set $i = 1
    Set $arg = (GetScriptArgument $i)
    While $arg <> {} Do
    Begin
	Set $j = (Add $i 1)
	If $arg == {--lang} Then
	    Set $Lang = (GetScriptArgument $j)
	If $arg == {--message} Then
	    Set $Message = (GetScriptArgument $j)
  	If $arg == {--title} Then
	    Set $Title = (GetScriptArgument $j)
	If $arg == {--text-colorset} Then
	    Set $TextColorset = (GetScriptArgument $j)
	If $arg == {--in-line-doc} Then
	    Set $InLineDoc = (GetScriptArgument $j)
	If $arg == {--text-font} Then
	    Set $TextFont = (GetScriptArgument $j)
	Set $i = (Add $i 2)
	Set $arg = (GetScriptArgument $i)
    End

    If $TextColorset <> {} Then
	ChangeColorset 2 $TextColorset
    If $Message <> {} Then
	ChangeTitle 2 $Message
    If $Title <> {} Then
	ChangeTitle 1 $Title
    If $InLineDoc <> {} Then
    Begin
	Set $cmd = {fvwm-themes-script --in-line-doc }$InLineDoc{ --line-length 70}
	# if the --lang is not used, ft-script computes it itself
	If $Lang <> {} Then
	    Set $cmd = $cmd { --lang }$Lang
 	Set $Doc = (GetOutput $cmd 1 -1)

	# first "line" is the font, evaluate it
	Set $font = {}
	Set $index = 1
	Set $done = 0
	While $done <> 1 Do
	Begin
	    Set $tmp = (StrCopy $Doc $index $index)
	    If $tmp == {|} Then
		Set $done = 1
	    Else
		Set $font = $font $tmp
	    Set $index = (Add $index 1)
	    If $index == 300 Then
	    Begin
		Set $font = "-*-fixed-medium-r-semicondensed-*-13-*"
		Set $done = 1
	    End
	End

	Set $Doc = (StrCopy $Doc $index 32000)
 	ChangeTitle 2 $Doc
    End

    If $TextFont <> {} Then
	Set $font = $TextFont
    ChangeFont 2 $font

End

# Title
Widget 1
Property
    Position 10 5
    Size 455 20
    Type ItemDraw
    Flags NoReliefString
    Title {}
Main
 Case message of
 SingleClic :
 Begin
 End
End

# the documentation
Widget 2
Property
    Position 10 30
    Size 460 430
    Type List
    Font -*-fixed-medium-r-semicondensed-*-13-*
    Title {}
    Flags NoReliefString
Main
 Case message of
 SingleClic :
 Begin
    ChangeValue 2 0
 End
End

Widget 3
Property
    Position 400 465
    Type PushButton
    Flags NoReliefString
    Title {Quit}
Main
 Case message of
 SingleClic :
 Begin
    Quit
 End
End
