# interface generated by SpecTcl version 1.0 from pref_general.ui
#   root     is the parent window for this user interface

proc pref_general_ui {root args} {        
    global ChangeVarInfo
    # this treats "." as a special case
    
    if {$root == "."} {
	set base ""
    } else {
	set base $root
    }
    
    frame $base.fr1 -bd 2 -relief ridge
    frame $base.fr2 -bd 2 -relief ridge
    frame $base.fr3 -bd 2 -relief ridge
    frame $base.fr4 -bd 2 -relief ridge
    
    
    frame $base.frame#1
    frame $base.frame#2
    frame $base.frame#3
    frame $base.frame#4
    
    checkbutton $base.checkbutton#1 \
	    -disabledforeground grey60 \
	    -text [_ "Dialog browser"] \
	    -variable ChangeVarInfo(Dialogbrowser)
    GidHelp $base.checkbutton#1 [_ "If set, file names are required from the\
	    user with a browser window. If not, file names are required in\
	    the command line"]
    
    
    checkbutton $base.checkbutton#2 \
	    -disabledforeground grey60 \
	    -text [_ "Splash window"] \
	    -variable ChangeVarInfo(SplashWindow)
    GidHelp $base.checkbutton#2 [_ "If this option is set, the welcome image is\
	    displayed when opening the program"]
    
    checkbutton $base.checkbutton#22 \
	    -disabledforeground grey60 \
	    -text [_ "View menu"] \
	    -variable ChangeVarInfo(ViewMenu)
    GidHelp $base.checkbutton#22 [_ "If this option is set, a 'view' menu entry will\
	    appear on the top menu bar view several view options."]
    
    label $base.label#4 \
	    -text [_ "Create new point"]:
    
    tk_optionMenuRAM $base.menubutton#1 ChangeVarInfo(Createnewpoint) \
	    [list [_ "Always"] [_ "Ask"] [_ "Never"]] \
	    {Always Ask Never}
    
    GidHelp  "$base.label#4 $base.menubutton#1" [_ "It alters the way how the\
	    points are entered. Options are:\
	    \nAlways: If trying to create a new point in the vicinity of\
	    an existing one, the new point is always created.\
	    \nAsk: If trying to create a new point in the vicinity of an\
	    existing one, the program asks the user whether to make use of the\
	    existing point or create a new one.\
	    \nNever: Only allows to select existing points. It can be changed\
	    interactively  when in creation point mode by setting 'No join'\
	    until all points are entered."]
    
    
    checkbutton $base.checkbutton#3 \
	    -disabledforeground grey60 \
	    -text [_ "Display coordinates"] \
	    -variable ChangeVarInfo(Displaycoordinates)
    
    GidHelp $base.checkbutton#3 [_ "If set, coordinates are shown in the\
	    graphical window. "]
    
    #checkbutton $base.checkbutton#4 \
	    #        -disabledforeground grey60 \
	    #        -text {Automatic redraw} \
	    #        -variable ChangeVarInfo(Automaticredraw)
    
    #GidHelp $base.checkbutton#4 "If this option is not set, redraws caused " \
	    #        "by window expositions, or by internal functions are not " \
	    #        "performed. This avoids spending a lot of time for large models."
    
    label $base.label#8 \
	    -text [_ "Automatic redraw:"]
 
    tk_optionMenuRAM $base.menubutton#3 ChangeVarInfo(Automaticredraw) \
	    [list [_ "All windows"] [_ "Current window"] [_ "None"]] \
	    {"All windows" "Current window" "None"}
   
    
    GidHelp "$base.label#8 $base.menubutton#3" [_ "The option 'All' redraw all the windows,\
	    'Current' only redraw the window with the focus, and\
	    'None' avoid the redraws (must be util to work with large models)."]
    
    
    label $base.label#7 \
	    -text [_ "Use more windows:"]
    
    tk_optionMenuRAM $base.menubutton#2 ChangeVarInfo(Usemorewindows) \
	    [list [_ "Yes"] [_ "No"] [_ "Beginner"]] \
	    {yes no beginner}
    
    GidHelp "$base.label#7 $base.menubutton#2" [_ "Depending on the selected\
	    field, 'yes', 'no' or 'beginner', some options are asked to\
	    the user inside a new window or with a message in the regular\
	    messages window."]

    checkbutton $base.checkSound -text [_ "Play sound"] -variable ChangeVarInfo(Sound)   
    GidHelp "$base.checkSound" [_ "If this option is set, a sound is played to indicate a task has finished."]

    checkbutton $base.checkSmallWinSelecting -text [_ "Shrink windows when selecting"] -variable ChangeVarInfo(SmallWinSelecting)   
    GidHelp "$base.checkSmallWinSelecting" [_ "If this option is set, when selecting some windows are resized in order to facilitate the selection."]

    checkbutton $base.checkbutton#7 \
	    -text [_ "Backup time (min):"] \
	    -disabledforeground grey60 \
	    -variable ChangeVarInfo(BackupCheck)
    
    entry $base.entry#12 \
	    -borderwidth 1 \
	    -insertborderwidth 1 \
	    -textvariable ChangeVarInfo(BackupTime) \
	    -width 14
   
    GidHelp "$base.frame#2 \
	$base.checkbutton#7 $base.entry#12" \
	[_ "If this option is set, the model is saved automatically \
	    with the frequency given by the number of minutes\
	    \n'Note:' Mesh is not saved into the backup to save time."]
    
    checkbutton $base.checkbutton#5 \
	    -text [_ "Write batch file:"] \
	    -disabledforeground grey60 \
	    -variable ChangeVarInfo(WriteBatchCheck)
    
    entry $base.entry#10 \
	    -borderwidth 1 \
	    -insertborderwidth 1 \
	    -textvariable ChangeVarInfo(WriteBatchFile) \
	    -width 14
    
    button $base.button#1 \
	    -command "OpenBrowserForBatch $base" \
	    -disabledforeground grey60 \
	    -text F
    
    checkbutton $base.checkbutton#6 \
	    -disabledforeground grey60 \
	    -text [_ "Write rot in batch"] \
	    -variable ChangeVarInfo(WriteRotationsInBatch)
    
    GidHelp "$base.frame#1 $base.checkbutton#5 $base.entry#10 $base.button#1 \
	    $base.checkbutton#6" [_ "If this option is set, and a filename is\
	    given, all commands used during the current session are saved\
	    into this file. It can be executed later by means of a script\
	    file with the predefined commands to be run in the program\
	    (see 'Batch file').\
	    \nWith option 'Write rotations in batch' all dynamic rotations\
	    and movements are stored in the batch file. This permits to see\
	    these movements when reading this batch file with\
	    'Read batch window'."]
    
    label $base.label#10 \
	    -text [_ "Language"]:
    
    set ChangeVarInfo(Language) [::GidUtils::GetCurrentLanguage]
    set langs [::GidUtils::GetAllLanguages]
    set langlabels ""
    foreach i $langs {
      lappend langlabels [_ "%s" [::GIDi18n::language $i]]
    }
    tk_optionMenuRAM $base.menubutton#4 ChangeVarInfo(Language) \
	    $langlabels $langs
    
    GidHelp "$base.frame#4 $base.label#10 $base.menubutton#4" \
	    [_ "It set the program language. The new settings will be active after restarting."]
    
    # Geometry management
    
    
    grid $base.fr1 -in $root -sticky ewns -row 1 -column 1 -padx 2 -pady 2
    grid $base.fr2 -in $root -sticky ewns -row 2 -column 1 -padx 2 -pady 2
    grid $base.fr3 -in $root -sticky ewns -row 3 -column 1 -padx 2 -pady 2
    grid $base.fr4 -in $root -sticky ewns -row 4 -column 1 -padx 2 -pady 2
    
    grid rowconfigure $root 1 -weight 1 -minsize 30
    grid rowconfigure $root 2 -weight 1 -minsize 30
    grid rowconfigure $root 3 -weight 1 -minsize 30
    grid rowconfigure $root 4 -weight 1 -minsize 30
    grid columnconfigure $root 1 -weight 1
    
    #grid $base.checkbutton#1 -in $base.fr1 -row 1 -column 1 -sticky w -columnspan 2 
    grid $base.checkbutton#2 -in $base.fr1 -row 2 -column 1 -sticky w -columnspan 2 
    #grid $base.checkbutton#22 -in $base.fr1 -row 3 -column 1  -sticky w -columnspan 2 
    grid $base.label#4 -in $base.fr1 -row 4 -column 1  -sticky w
    grid $base.menubutton#1 -in $base.fr1 -row 4 -column 2  -sticky w
    grid $base.checkbutton#3 -in $base.fr1 -row 5 -column 1  -sticky w -columnspan 2 
    grid $base.label#8 -in $base.fr1 -row 6 -column 1  -sticky e
    grid $base.menubutton#3 -in $base.fr1 -row 6 -column 2 -sticky w
    grid $base.label#7 -in $base.fr1 -row 7 -column 1  -sticky e
    grid $base.menubutton#2 -in $base.fr1 -row 7 -column 2  -sticky w
    grid $base.checkSound -in $base.fr1 -row 8 -column 1  -sticky w -columnspan 2
    grid $base.checkSmallWinSelecting -in $base.fr1 -row 9 -column 1  -sticky w -columnspan 2

    grid columnconfigure $base.fr1 1 -weight 0 -minsize 30
    grid columnconfigure $base.fr1 2 -weight 1 -minsize 30
    
    
    grid $base.frame#2 -in $base.fr2 -columnspan 2 -row 1 -column 1  \
	    -sticky ew
    grid $base.checkbutton#7 -in $base.fr2        -row 2 -column 1  \
	    -sticky e
    grid $base.entry#12 -in $base.fr2        -row 2 -column 2  \
	    -sticky ew -padx 3
    
    grid columnconfigure $base.fr2 1 -weight 0 -minsize 30
    grid columnconfigure $base.fr2 2 -weight 1 -minsize 30
    
    
    grid $base.frame#1 -in $base.fr3 -columnspan 2 -row 1 -column 1  \
	    -sticky ew
    grid $base.checkbutton#6  -in $base.fr3     -row 2 -column 1 \
	    -sticky e
    
    grid columnconfigure $base.fr3 1 -weight 0 -minsize 30
    grid columnconfigure $base.fr3 2 -weight 1 -minsize 30


    if { $::MSGCAT_GID } {
	grid $base.label#10     -in $base.fr4 -row 1 -column 1  \
		-sticky e
	grid $base.menubutton#4 -in $base.fr4 -row 1 -column 2  \
		-sticky w
    }
    
    grid columnconfigure $base.fr4 1 -weight 0 -minsize 2
    grid columnconfigure $base.fr4 2 -weight 1 -minsize 30
    
    grid $base.checkbutton#5 -in $base.frame#1        -row 1 -column 1 
    grid $base.entry#10 -in $base.frame#1        -row 1 -column 2 -sticky ew  -padx 3
    grid $base.button#1 -in $base.frame#1        -row 1 -column 3 -padx 2
    
    grid rowconfigure $base.frame#1 1 -weight 0 -minsize 30
    grid columnconfigure $base.frame#1 1 -weight 0 -minsize 2
    grid columnconfigure $base.frame#1 2 -weight 1 -minsize 30
    grid columnconfigure $base.frame#1 3 -weight 0 -minsize 30
    
    grid rowconfigure $base.frame#2 1 -weight 0 -minsize 30
    grid columnconfigure $base.frame#2 1 -weight 0 -minsize 2
    grid columnconfigure $base.frame#2 2 -weight 1 -minsize 30
    grid columnconfigure $base.frame#2 3 -weight 0 -minsize 30
    
    
    # additional interface code
    
    trace variable ChangeVarInfo(WriteBatchCheck) w BatchFileCheck
    set ChangeVarInfo(basew) $base
    
    proc BatchFileCheck { name1 name2 op } {
	global ChangeVarInfo
	
	if { $ChangeVarInfo(WriteBatchCheck) == 1 } {
	    $ChangeVarInfo(basew).entry#10 conf -state normal
	    $ChangeVarInfo(basew).button#1 conf -state normal
	    $ChangeVarInfo(basew).entry#10 conf -fg black
	    if { [string length $ChangeVarInfo(WriteBatchFile)] == 0 } {
		set ChangeVarInfo(WriteBatchFile) batch
	    }
	} else {
	    if { [string length $ChangeVarInfo(WriteBatchFile)] == 0 } {
		set ChangeVarInfo(WriteBatchFile) batch
	    }
	    $ChangeVarInfo(basew).entry#10 conf -state disabled
	    $ChangeVarInfo(basew).button#1 conf -state disabled
	    $ChangeVarInfo(basew).entry#10 conf -fg grey60
	}
    }
    
    trace variable ChangeVarInfo(BackupCheck) w BackupFileCheck
    
    proc BackupFileCheck { name1 name2 op } {
	global ChangeVarInfo
	
	if { $ChangeVarInfo(BackupCheck) == 1 } {            
	    $ChangeVarInfo(basew).entry#12 conf -state normal
	    $ChangeVarInfo(basew).entry#12 conf -fg black
	    
	    if { [catch {
		if { $ChangeVarInfo(BackupTime) <= 0 } {
		    set ChangeVarInfo(BackupTime) 20
		} elseif { $ChangeVarInfo(BackupTime) > 70000 } {
		    set ChangeVarInfo(BackupTime) 70000
		}
	    } ] } { set ChangeVarInfo(BackupTime) 20 }
	    
	} else {            
	    set ChangeVarInfo(BackupTime) 0
	    $ChangeVarInfo(basew).entry#12 conf -state disabled
	    $ChangeVarInfo(basew).entry#12 conf -fg grey60
	}
    }
    
    proc OpenBrowserForBatch { w } {
	global ChangeVarInfo
	set ChangeVarInfo(WriteBatchFile) [Browser-ramR file write $w [_ "write batch file"]]
    } 
     
    global GIDDEFAULT tkPriv
    
    
    set tkPriv(OpenFolderImage) [image create bitmap -data {
	#define folder_open_width 20
	#define folder_open_height 16
	static unsigned char folder_open_bits[] = {
	    0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x04, 0x00,
	    0xf8, 0x83, 0x00, 0xf8, 0xff, 0x00, 0xf8, 0xff, 0x00, 0x38, 0x00, 0x08,
	    0x38, 0x00, 0x04, 0x18, 0x00, 0x04, 0x18, 0x00, 0x02, 0x08, 0x00, 0x02,
	    0x08, 0x00, 0x01, 0x00, 0x00, 0x01, 0xf8, 0xff, 0x00, 0x00, 0x00, 0x00}; \
		} -maskdata {
	    #define folder_open_msk_width 20
	    #define folder_open_msk_height 16
	    static unsigned char folder_open_msk_bits[] = {
		0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0xf8, 0x03, 0x00, 0xfc, 0x07, 0x00,
		0x04, 0xbc, 0x00, 0x04, 0x80, 0x00, 0x04, 0x80, 0x00, 0xc4, 0xff, 0x0f,
		0xc4, 0xff, 0x07, 0x64, 0x77, 0x07, 0xe4, 0xdd, 0x03, 0x74, 0x77, 0x03,
		0xd4, 0xdd, 0x01, 0x7c, 0x77, 0x01, 0xfc, 0xff, 0x00, 0x00, 0x00, 0x00}; \
		    } -background yellow -foreground black]
		
	$base.button#1 conf -image $tkPriv(OpenFolderImage) -width 24 -height 18                     
	
	# end additional interface code
	
    }
    
    
    # Allow interface to be run "stand-alone" for testing
    
    catch {
	if {$argv0 == [info script]} {
	    wm title . [_ "Testing pref_general"]
	    pref_general_ui .
	}
    }
