### Copyright (C) 1995, 1996, 1997 Jeppe Buk (buk@imada.sdu.dk)
### This program 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., 675 Mass Ave, Cambridge, MA 02139, USA.

proc FvwmWinList {} {
  # Modules / FvwmWinList
  Desc "Configuration of the FvwmWinList module"
  ShortDesc "FvwmWinList"

  Header h -text "FvwmWinList" -frame:relief flat \
      -help "On this page you configure the FvwmWinList module. This"\
      "module is used for managing windows."
  Line l
  CheckBox spawn -text "Spawn this module when Fvwm2 starts" \
      -help "If you check this option the module will be spawned from"\
      "the two functions 'InitFunction' and 'RestartFunction'. You will"\
      "not have to insert them yourself then."

  Line colL

  # Geometry
  Label geomL -text "Specify location:" -help "Here you can specify the"\
      "location of the FvwmWinList window."
  Int geomX -text "X-pos"
  Int geomY -text "Y-pos"
  Frame geomF -entries { geomL geomX geomY }
  PageEnd {
    if {$geomX != "" || $geomY != ""} {
      if {$geomX == "" || $geomY == ""} {
	error "You must specify both X and Y location for FvwmWinList."
      }
    }
  }
  Save {
    if {$geomX != ""} {
      print "*FvwmWinListGeometry\t[signed $geomX][signed $geomY]"
    }
  }

  CheckBox skipList -text "Don't show windows Fvwm2 skips" \
      -help "If this option is checked windows having the style flag"\
      'WindowListSkip' set will not be included in the list."
  Save {if {$skipList == 1} {print "*FvwmWinListUseSkipList"}}

  CheckBox noAnchor -text "Don't anchor the window" \
      -help "By default, FvwmWinList will anchor the gravity corner"\
      "so the window will grow in the opposite direction. This undoes"\
      "that behavior."
  Save {if {$noAnchor == 1} {print "*FvwmWinListNoAnchor"}}

  CheckBox useIcons -text "Display icon names instead of window names"\
      -help "Normally FvwmWinList will use the window title as text on"\
      "the buttons. If you check this option icon names will be used"\
      "instead (usually a shorter name)."
  Save {if {$useIcons == 1} {print "*FvwmWinListUseIconNames"}}

  CheckBox leftJust -text "Left justify text on buttons" \
      -help "By default FvwmWinList centers the text on the buttons."\
      "Bu checking this option you can make the text flush left instead."
  Save {if {$leftJust == 1} {print "*FvwmWinListLeftJustify"}}

  Int minWidth -text "Specify minimum width" \
      -help "Normally FvwmWinList will size itself to fit the longest"\
      "name. If you wish you may specify a minimum width here to make"\
      "the buttons never shrink below this limit."
  Int maxWidth -text "Specify maximum width" \
      -help "Normally FvwmWinList will size itself to fit the longest"\
      "name. If you wish you may specify a maximum width here to make"\
      "the buttons never grow beyond this limit."
  Change {
    if {$changeElm == "minWidth" && $minWidth == "-"} {set minWidth ""}
    if {$changeElm == "maxWidth" && $maxWidth == "-"} {set maxWidth ""}
    if {$changeElm == "maxWidth"} {
      if {$maxWidth == ""} {Disable truncLeft} else {Enable truncLeft}
    }
  }
  PageEnd {
    if {$minWidth != "" && $maxWidth != "" && $minWidth > $maxWidth} {
      error "Minimum width of FvwmWinList must be <= maximum width."
    }
  }
  Save {
    if {$minWidth != ""} {print "*FvwmWinListMinWidth\t$minWidth"}
    if {$maxWidth != ""} {print "*FvwmWinListMaxWidth\t$maxWidth"}
  }

  CheckBox truncLeft -text "Truncate text to the left instead of right" \
      -help "If names get truncated because of the setting of"\
      "FvwmWinListMaxWidth, they will normally get truncated on the"\
      "right, so only the start of the names are visible. Setting this"\
      "option will cause them to get truncated on the left, so that the"\
      "end of names are visible. This is useful when the window title"\
      "contains a directory and file name, for example."
  Save {
    if {$maxWidth != "" && $truncLeft == 1} {
      print "*FvwmWinListTruncateLeft"
    }
  }

  # Colors and Fonts
  CheckBox winColB -text "Specify button" -help "Check this"\
      "button if you want to specify default colors of buttons."
  Command winFore \
      -text "foreground" \
      -default [list "white" 0] \
      -setvalue {
	$widget configure -bg [lindex $winFore 0] -text "      "} \
      -invoke {ColorWidget $colorList [lindex $winFore 0] \
		   [lindex $winFore 1]} \
      -disable {$widget configure -relief flat } \
      -enable {$widget configure -relief raised } \
      -help "In this widget you can set the foreground color of the"\
      "FvwmWinList buttons."
  Command winBack \
      -text "background" \
      -default [list "black" 0] \
      -setvalue {
	$widget configure -bg [lindex $winBack 0] -text "      "} \
      -invoke {ColorWidget $colorList [lindex $winBack 0] \
		   [lindex $winBack 1]} \
      -disable {$widget configure -relief flat } \
      -enable {$widget configure -relief raised } \
      -help "In this widget you can set the default background color of the"\
      "FvwmWinList buttons."
  Frame winColF -entries { winColB winFore winBack }
  Change {
    if {$changeElm == "winColB"} {
      if {$winColB == 1} {Enable winFore winBack
      } else {Disable winFore winBack}
    }
  }
  Save {
    if {$winColB == 1} {
      print "*FvwmWinListFore\t[hash2rgb [lindex $winFore 0]]"
      print "*FvwmWinListBack\t[hash2rgb [lindex $winBack 0]]"
    }
  }

  CheckBox icoColB -text "Specify iconified" -help "Check this"\
      "button if you want to specify the colors of buttons representing"\
      "iconified windows."
  Command icoFore \
      -text "foreground" \
      -default [list "white" 0] \
      -setvalue {
	$widget configure -bg [lindex $icoFore 0] -text "      "} \
      -invoke {ColorWidget $colorList [lindex $icoFore 0] \
		   [lindex $icoFore 1]} \
      -disable {$widget configure -relief flat } \
      -enable {$widget configure -relief raised } \
      -help "In this widget you can set the foreground color of the buttons"\
      "representing iconified windows."
  Command icoBack \
      -text "background" \
      -default [list "black" 0] \
      -setvalue {
	$widget configure -bg [lindex $icoBack 0] -text "      "} \
      -invoke {ColorWidget $colorList [lindex $icoBack 0] \
		   [lindex $icoBack 1]} \
      -disable {$widget configure -relief flat } \
      -enable {$widget configure -relief raised } \
      -help "In this widget you can set the background color of the buttons"\
      "representing iconified windows."
  Frame icoColF -entries { icoColB icoFore icoBack }
  Change {
    if {$changeElm == "icoColB"} {
      if {$icoColB == 1} {Enable icoFore icoBack
      } else {Disable icoFore icoBack}
    }
  }
  Save {
    if {$icoColB == 1} {
      print "*FvwmWinListIconFore\t[hash2rgb [lindex $icoFore 0]]"
      print "*FvwmWinListIconBack\t[hash2rgb [lindex $icoBack 0]]"
    }
  }

  CheckBox hiColB -text "Specify focused" -help "Check this"\
      "button if you want to specify the colors of the button representing"\
      "the focused window."
  Command hiFore \
      -text "foreground" \
      -default [list "white" 0] \
      -setvalue {
	$widget configure -bg [lindex $hiFore 0] -text "      "} \
      -invoke {ColorWidget $colorList [lindex $hiFore 0] \
		   [lindex $hiFore 1]} \
      -disable {$widget configure -relief flat } \
      -enable {$widget configure -relief raised } \
      -help "In this widget you can set the foreground color of the button"\
      "representing the focused window."
  Command hiBack \
      -text "background" \
      -default [list "black" 0] \
      -setvalue {
	$widget configure -bg [lindex $hiBack 0] -text "      "} \
      -invoke {ColorWidget $colorList [lindex $hiBack 0] \
		   [lindex $hiBack 1]} \
      -disable {$widget configure -relief flat } \
      -enable {$widget configure -relief raised } \
      -help "In this widget you can set the background color of the button"\
      "representing the focused window."
  Frame hiColF -entries { hiColB hiFore hiBack }
  Change {
    if {$changeElm == "hiColB"} {
      if {$hiColB == 1} {Enable hiFore hiBack
      } else {Disable hiFore hiBack}
    }
  }
  Save {
    if {$icoColB == 1} {
      print "*FvwmWinListFocusFore\t[hash2rgb [lindex $hiFore 0]]"
      print "*FvwmWinListFocusBack\t[hash2rgb [lindex $hiBack 0]]"
    }
  }

  CheckBox fontB -text "Specify font" -help "Check this button if you"\
      "want to set the font used for button text."
  Command font \
      -default "fixed" \
      -setvalue {buttonSetText $widget $font} \
      -invoke {FontWidget $font 0} \
      -disable {$widget configure -text "Not set"
	$widget configure -font fixed} \
      -enable {buttonSetText $widget $font} \
      -help "In this widget you can set the font to use for button text."
  Frame fontF -entries { fontB font }
  Change {
    if {$changeElm == "fontB"} {
      if {$fontB == 1} {Enable font} else {Disable font}
    }
  }
  Save {
    if {$fontB == 1} {print "*FvwmWinListFont\t$font"}
  }

  Window colFont -text "Configuration of Colors and Fonts" -entries {
    winColF icoColF hiColF fontF
  } -help "In this window you configure the colors and font to use."

  # Bindings  
  Label mouseIdx -text "Description:" -label:relief groove
  Menu mouseBut -entries { 1 2 3 } -text "Button to press"
  Label funcLabel -text "Function to call" \
      -help "This is a list of the built-in functions you can bind to."
  global Builtins
  ComboBox builtinCall -noedit 1 -default Beep -entryhelp $Builtins \
      -help "Select a built-in function to call from this menu"
  Label argLabel -text "Arguments" \
      -help "Any additional arguments are entered here (the syntax is your" \
      "responsibility) - see help for the individual commands."
  Entry mouseArgs \
      -help "Any additional arguments are entered here (the syntax is your" \
      "responsibility) - see help for the individual commands."
  Frame mouseFuncF -entries {funcLabel builtinCall} -orient top
  Frame mouseArgsF -entries {argLabel mouseArgs} -orient top
  ExtEntry responses -entries { mouseFuncF mouseArgsF }
  Frame mouseBindF -entries {mouseBut responses} -orient top

  ExtEntry mice -text "Mouse Bindings" -entries {
    mouseIdx mouseBindF
  } -index mouseIdx -orient top -count 1 -packFrame:expand yes \
      -packFrame:fill x \
      -help "Here you configure the mouse bindings. Select a mouse"\
      "button and an action to bind, and then specify which command(s)"\
      "to execute on that event."
  Change {
    if {$changeElm == "mouseBut"} {
      set mouseIdx "Button $mouseBut(name)"
    }
  }
  Save {
    forevery mice {
      set resp ""
      forevery responses {
	append resp ",$builtinCall"
	if {$mouseArgs != ""} {append resp " $mouseArgs"}
      }
      if {$resp != ""} {
	print "*FvwmWinListAction\tClick$mouseBut(name) [string \
               range $resp 1 end]"
      } else {
	tk_dialog .mouseDialog Warning "You had a mouse binding for\
 FvwmWinList without any functions to call. This binding will be ignored." \
	    info 0 OK
      }
    }
  }

  Window bindingW -text "Configuration of Mouse Bindings" -entries {
    mice
  } -help "In this window you configure the mouse bindings to use in"\
      "FvwmWinList."

  Save {
    if {$spawn == 1} {
      print "AddToFunc InitFunction \"I\" Module FvwmWinList"
      print "AddToFunc RestartFunction \"I\" Module FvwmWinList"
    }
  }
}
