### Copyright (C) 1995, 1996, 1997 Jeppe Buk (buk@imada.ou.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 style {} {
  # Styles of Windows

  Desc "This page contains all the 'per window' configurations of Fvwm2."\
      "This includes the colors, icon boxes, decorations and many more."
  ShortDesc "Styles of individual windows"

  ######################################################################
  # The name of the window
  #
  Entry windowName -text "Window name"

  Help windowName \
      "Enter the name of the window you wish to configure. The normal" \
      "wildcards (*,?) are allowed."
  #
  ######################################################################

  ######################################################################
  # Use Style
  #
  Entry useStyle -text "Base on the style named:" -packEntry:side right

  set useStyleHelp [concat \
      "FVWM gives you the possibility to inherit style settings from" \
      "another style name. If you enter another style name all the" \
      "settings from that style will be used in the current style as" \
      "well. You can of course overload and add options in the current" \
      "style." ]

  Help useStyle $useStyleHelp
  #
  ######################################################################

  ######################################################################
  # Use Decor
  #
  Entry useDecor -text "Use decoration named:" -packEntry:side right

  set useDecorHelp [concat \
      "Enter the name of a decoration to apply to this window. This" \
      "decoration must be defined on the 'Decorations' page." ]

  Help useDecor $useDecorHelp
  #
  ######################################################################

  ######################################################################
  # Mini Icon
  #
  Entry miniIcon -text "Associated mini icon:" \
      -packEntry:side right

  set miniIconHelp [concat \
      "Enter the name of a mini icon to associate to this window. This" \
      "style flag does nothing itself to the appearance of the window," \
      "but when specifying button pixmaps (in decorations) you can" \
      "select the associated mini icon. Also it may be used by various" \
      "Fvwm modules." ]

  Help miniIcon $miniIconHelp
  #
  ######################################################################

  ######################################################################
  # Colors
  #
  CheckBox colBox -text Change
  global colorList
  Command foreColor \
      -text "Foreground color" \
      -default [list "#FFFFFF" 0] \
      -setvalue {if {[lindex $foreColor 0] == ""} {
	set foreColor [list "#FFFFFF" 0]} 
	$widget configure -bg [lindex $foreColor 0] -text "      "} \
      -invoke {ColorWidget $colorList [lindex $foreColor 0] \
		   [lindex $foreColor 1]} \
      -disable {$widget configure -relief flat } \
      -enable {$widget configure -relief raised }
  
  Command backColor \
      -text "Background color" \
      -default [list "#000000" 0] \
      -setvalue {if {[lindex $backColor 0] == ""} {
	set backColor [list "#000000" 0]} 
	$widget configure -bg [lindex $backColor 0] -text "      "} \
      -invoke {ColorWidget $colorList [lindex $backColor 0] \
		   [lindex $backColor 1]} \
      -disable {$widget configure -relief flat } \
      -enable {$widget configure -relief raised }
  
  Frame colorFrame -entries { colBox foreColor backColor }
  
  Change {
    if {$changeElm == "colBox"} {
      if {$colBox==1} {
	Enable foreColor
	Enable backColor
      } else {
	Disable foreColor
	Disable backColor
      }
    }
  }
  
  Help colBox \
      "To change the colors of the window you have to check this" \
      "option (see help for \"Color Configuration\")."
  
  Help foreColor \
      "By pressing this button you can change the foreground color of" \
      "the window decorations when the window is inactive. This also" \
      "affects the icon foreground for monochrome icons (bitmaps) and" \
      "the icon title foreground."
  
  Help backColor \
      "By pressing this button you can change the background color of" \
      "the window decorations when the window is inactive. This also" \
      "affects the icon background for monochrome icons (bitmaps) and" \
      "the icon title background. Unless you use pixmaps for the title" \
      "bar buttons, this also affects those buttons."
  #
  ######################################################################
  
  ######################################################################
  # Borders / Handles
  #
  CheckBox noHandles -text "Prevent handles"
  CheckBox useHandles -text "Force handles"
  CheckBox borBox -text "Change the width of borders without handles to"
  Int borderWidth -textafter "pixels"
  CheckBox hanBox -text "Change the width of borders with handles to"
  Int handleWidth -textafter "pixels"
  Frame hanU -entries { noHandles useHandles }
  Frame hanW -entries { hanBox handleWidth }
  Frame borW -entries { borBox borderWidth }
  Frame borderFrame -entries { hanU hanW borW } -orient top
  
  Change {
    if {$changeElm == "noHandles"} {
      if {$noHandles == 1} {
	set useHandles 0
	set hanBox 0
	Disable hanBox
	Disable handleWidth
	Enable borBox
	if {$borBox == 1} {Enable borderWidth}
      } else {
	Enable hanBox
	if {$hanBox == 1} {Enable handleWidth}
      }
    }
    if {$changeElm == "hanBox"} {
      if {$hanBox==1} {Enable handleWidth} else {Disable handleWidth}
    }
    if {$changeElm == "useHandles"} {
      if {$useHandles == 1} {
	set noHandles 0
	set borBox 0
	Disable borBox
	Disable borderWidth
	Enable hanBox
	if {$hanBox==1} {Enable handleWidth}
      } else {
	Enable borBox
	if {$borBox == 1} {Enable borderWidth}
      }
    }
    if {$changeElm == "borBox"} {
      if {$borBox==1} {Enable borderWidth} else {Disable borderWidth}
    }
  }

  Help noHandles \
      "This option gives you the opportunity to suppres the display of" \
      "handles on the window border. Handles are the cut-outs at the" \
      "corners of the window. FVWM then sets the width of the border" \
      "to <BorderWidth> instead of <HandleWidth>."

  Help useHandles \
      "This option restores the handles on the window border. Handles" \
      "are the cut-outs at the corners of the window. FVWM then sets" \
      "the width of the border to <HandleWidth> instead of" \
      "<BorderWidth>. Since handles are the default for FVWM this" \
      "option only makes sense if another more general style has set" \
      "the prevent handles option."

  set borWidthHelp [concat \
      "Here you can change the width of borders without handles. This" \
      "is borders of windows having the prevent handles option set." ]
      
  Help borBox $borWidthHelp
  Help borderWidth $borWidthHelp

  set hanWidthHelp [concat \
      "Here you can change the width of borders with handles. This" \
      "is borders of windows without the prevent handles option set" \
      "(and windows with the force handles option set)." ]
      
  Help hanBox $hanWidthHelp
  Help handleWidth $hanWidthHelp
  #
  ######################################################################

  ######################################################################
  # Title
  #
  CheckBox noTitle -text "Prevent title"
  CheckBox useTitle -text "Force title"
  Frame titleFrame -entries { noTitle useTitle }

  Change {
    if {$changeElm == "noTitle"} {
      if {$noTitle==1} {set useTitle 0}
    }
    if {$changeElm == "useTitle"} {
      if {$useTitle==1} {set noTitle 0}
    }
  }
  
  Help noTitle \
      "When this option is checked no title bar will be displayed."
  
  Help useTitle \
      "When this option is checked the title bar will be displayed."
  #
  ######################################################################

  ######################################################################
  # Decorate Transients
  #
  CheckBox noTrans -text "Prevent decoration of transients"
  CheckBox forceTrans -text "Force decoration of transients"
  Frame transientFrame -entries { noTrans forceTrans }

  Change {
    if {$changeElm == "noTrans"} {
      if {$noTrans==1} {set forceTrans 0}
    }
    if {$changeElm == "forceTrans"} {
      if {$forceTrans==1} {set noTrans 0}
    }
  }
  
  Help noTrans "If you check this option transient windows will not get"\
      "any decoration. Transient windows are windows that are supposed"\
      "to be displayed for a short while only (e.g. dialog"\
      "boxes). Since this is the default behavior this option only"\
      "makes sense if another more general style sets the 'force"\
      "decoration of transients' option."
  
  Help forceTrans "If you check this option transient windows will be"\
      "decorated. Transient windows are windows that are supposed to be"\
      "displayed for a short while only (e.g. dialog boxes)."
  #
  ######################################################################

  ######################################################################
  # Buttons
  #
  Header butH -text "Buttons to include/exclude:" \
      -frame:relief flat -label:justify left -label:anchor nw
  for {set i 0} {$i <= 9} {incr i} {
    Label lab$i -text " $i"
    CheckBox ibut$i
    CheckBox ebut$i
    Frame fram$i -entries " lab$i ibut$i ebut$i " -orient top
  }
  Label butNo -text "No"
  Label incl -text "Include"
  Label excl -text "Exclude"
  Label space -text "  "
  Frame framL -entries { butNo incl excl } -orient top
  Frame butC -entries { framL
    fram1 fram3 fram5 fram7 fram9 space
    fram0 fram8 fram6 fram4 fram2 }
  Frame buttonFrame -entries { butH butC } -orient top
  
  Change {
    if {[regexp "ibut(\[0-9\])" $changeElm all no] && $changeElm == $all} {
      if {[set ibut$no] == 1} {set ebut$no 0}
    }
    if {[regexp "ebut(\[0-9\])" $changeElm all no] && $changeElm == $all} {
      if {[set ebut$no] == 1} {set ibut$no 0}
    }
  }
  
  set butHelp1 [concat \
      "To include/exclude specific buttons from the title bar of the" \
      "current window, check the corresponding checkbuttons. FVWM will" \
      "allways left-justify the odd buttons and right-justify the even" \
      "buttons, so the position of the button on the window may not" \
      "match that of the checkbutton."]
  
  set butHelp2 [concat \
      "Further more FVWM only displays valid buttons (buttons with" \
      "a valid binding), so it is possible that some of the included" \
      "buttons will not be displayed."]

  # concat eats newlines...
  set butHelp "$butHelp1\n\n$butHelp2"

  for {set i 0} {$i <= 9} {incr i} {
    Help lab$i $butHelp
    Help ibut$i $butHelp
    Help ebut$i $butHelp
  }
  foreach widget { butH butNo incl excl } {
    Help $widget $butHelp
  }
  #
  ######################################################################

  ######################################################################
  # Start of windows
  #
  CheckBox startIconic -text "Start as an icon"
  CheckBox startNormal -text "Start as a normal window"
  CheckBox startsOnDesk -text "Specify desk to start on:"
  Int startsOnDeskNo
  Frame startsOnDeskF -entries { startsOnDesk startsOnDeskNo }
  CheckBox startsAnywhere -text "Start on any desk"
  CheckBox smartPlacement -checkbutton:justify left \
      -text "Try to place windows without\ncovering others"
  CheckBox dumbPlacement -checkbutton:justify left \
      -text "Place windows without regard\nto other windows"
  CheckBox randomPlacement -text "Place windows automatically"
  CheckBox activePlacement -text "Place windows interactively"
  CheckBox skipMapping -checkbutton:justify left \
      -text "Don't switch to the desk\nwhere the window is started"
  CheckBox showMapping -checkbutton:justify left \
      -text "Switch to the desk where\nthe window is started"
  CheckBox noPPosition -text "Ignore the PPosition field"
  CheckBox usePPosition -text "Use the PPosition field"

  Frame startLeft -orient top -packFrame:expand no -entries {
    startIconic startsOnDeskF smartPlacement randomPlacement skipMapping
    noPPosition
  }
  Frame startRight -orient top -entries {
    startNormal startsAnywhere dumbPlacement activePlacement showMapping
    usePPosition
  }
  Frame startFrame -entries { startLeft startRight }

  Change {
    if {$changeElm == "startIconic"} {
      if {$startIconic == 1} {set startNormal 0}
    }
    if {$changeElm == "startNormal"} {
      if {$startNormal == 1} {set startIconic 0}
    }
    if {$changeElm == "startsOnDesk"} {
      if {$startsOnDesk == 1} {
	set startsAnywhere 0
	Enable startsOnDeskNo
      } else {
	Disable startsOnDeskNo
      }
    }
    if {$changeElm == "startsAnywhere"} {
      if {$startsAnywhere == 1} {
	set startsOnDesk 0
	Disable startsOnDeskNo
      }
    }
    if {$changeElm == "smartPlacement"} {
      if {$smartPlacement == 1} {set dumbPlacement 0}
    }
    if {$changeElm == "dumbPlacement"} {
      if {$dumbPlacement == 1} {set smartPlacement 0}
    }
    if {$changeElm == "randomPlacement"} {
      if {$randomPlacement == 1} {set activePlacement 0}
    }
    if {$changeElm == "activePlacement"} {
      if {$activePlacement == 1} {set randomPlacement 0}
    }
    if {$changeElm == "skipMapping"} {
      if {$skipMapping == 1} {set showMapping 0}
    }
    if {$changeElm == "showMapping"} {
      if {$showMapping == 1} {set skipMapping 0}
    }
    if {$changeElm == "noPPosition"} {
      if {$noPPosition == 1} {set usePPosition 0}
    }
    if {$changeElm == "usePPosition"} {
      if {$usePPosition == 1} {set noPPosition 0}
    }
  }

  Help startIconic "Check this option if you want the window to be"\
      "iconified when it is initially started."
  Help startNormal "Check this option if you want the window to start"\
      "as a normal window (i.e. not iconified). Since this is the"\
      "default this option only makes sense if a more general style"\
      "sets the 'start iconic' option."
  Help startsOnDesk "Using this option you can specify a virtual"\
      "desktop on which this window should always start. You cannot"\
      "specify on which page on the desk it should start, though."
  Help startsAnywhere "Check this option if you'll let this window"\
      "start on any virtual desktop. Since this is the default this"\
      "option only makes sense if a more general style sets the 'start"\
      "on specific desk' option."
  Help smartPlacement "If you check this option FVWM will try not to"\
      "cover existing windows when drawing this window initially. If"\
      "there isn't enough room for that, FVWM defaults to random"\
      "locations (or interactive placement)."
  Help dumbPlacement "Check this option to prevent FVWM from trying to"\
      "place this window without covering existing windows. Since this"\
      "is the default this option only makes sense if a more general"\
      "style sets the 'try not to cover other windows' option."
  Help randomPlacement "Check this option if you want FVWM to place the"\
      "window for you when it is initially drawn. This way you wont"\
      "have to place the window with the mouse."
  Help activePlacement "Check this option if you want to place this"\
      "window yourself (using the mouse) when the window is initially"\
      "drawn. Since this is the default this option only makes sense if"\
      "a more general style sets the 'place window automatically'"\
      "option."
  Help skipMapping "Check this option if you want FVWM to stay on the"\
      "current desk even if this window starts on another desk."
  Help showMapping "Check this option if you want FVWM to change the"\
      "view to the desk on which this window will be drawn"\
      "initially. Since this is the default this option only makes"\
      "sense if a more general style sets the 'do not switch to the"\
      "desk where this window is started' option."
  Help noPPosition "If you check this option FVWM will ignore the"\
      "PPosition field when this window is initially drawn. The"\
      "PPosition field is a way for the application to tell FVWM where"\
      "it wants to start."
  Help usePPosition "If you check this option FVWM will use the"\
      "PPosition field if the application sets it. The PPosition field"\
      "is a way for the application to tell FVWM where it wants to"\
      "start. Since this is the default this option only makes sense if"\
      "a more general style sets the 'ignore the PPosition field'"\
      "option."
  #
  ######################################################################

  ######################################################################
  # Running Windows
  #
  CheckBox windowListSkip -text "Exclude this window from the window list"
  CheckBox windowListHit -text "Include this window in the window list"
  CheckBox circulateSkip -text "Skip this window when circulating"
  CheckBox circulateHit -text "Stop at this window when circulating"
  CheckBox staysOnTop -text "Always stay on top"
  CheckBox staysPut -text "Always stay put"
  CheckBox sticky -text "This window sticks to the screen"
  CheckBox slippery -text "This window sticks to the desk"

  CheckBox clickToFocus -text "Click to focus" -packFrame:expand yes
  CheckBox sloppyFocus -text "Sloppy focus" -packFrame:expand yes
  CheckBox mouseFocus -text "Focus follows mouse" -packFrame:expand yes
  Frame focusFrame -entries {
    clickToFocus sloppyFocus mouseFocus
  }

  Frame runWinLeft -orient top -packFrame:expand no -entries {
    windowListSkip circulateSkip staysOnTop sticky
  }
  Frame runWinRight -orient top -entries {
    windowListHit circulateHit staysPut slippery
  }
  Frame runningFrameC -entries { runWinLeft runWinRight }
  Line runningL
  Frame runningFrame -orient top -entries {
    runningL runningFrameC focusFrame
  }

  Change {
    if {$changeElm == "windowListSkip"} {
      if {$windowListSkip == 1} {set windowListHit 0}
    }
    if {$changeElm == "windowListHit"} {
      if {$windowListHit == 1} {set windowListSkip 0}
    }
    if {$changeElm == "circulateSkip"} {
      if {$circulateSkip == 1} {set circulateHit 0}
    }
    if {$changeElm == "circulateHit"} {
      if {$circulateHit == 1} {set circulateSkip 0}
    }
    if {$changeElm == "staysOnTop"} {
      if {$staysOnTop == 1} {set staysPut 0}
    }
    if {$changeElm == "staysPut"} {
      if {$staysPut == 1} {set staysOnTop 0}
    }
    if {$changeElm == "sticky"} {
      if {$sticky == 1} {set slippery 0}
    }
    if {$changeElm == "slippery"} {
      if {$slippery == 1} {set sticky 0}
    }
    if {$changeElm == "clickToFocus"} {
      if {$clickToFocus == 1} {
	set sloppyFocus 0
	set mouseFocus 0
      }
    }
    if {$changeElm == "sloppyFocus"} {
      if {$sloppyFocus == 1} {
	set clickToFocus 0
	set mouseFocus 0
      }
    }
    if {$changeElm == "mouseFocus"} {
      if {$mouseFocus == 1} {
	set clickToFocus 0
	set sloppyFocus 0
      }
    }
  }

  Help windowListSkip "If you check this option this window will not be"\
      "shown in the window list. This is useful for clocks, xbiff, etc."
  Help windowListHit "If you check this option this window will be"\
      "shown in the window list even if a more general style sets the"\
      "'exclude this window from the window list."
  Help circulateSkip "If you check this option the window will be"\
      "skipped when you circulate windows using the Next command."
  Help circulateHit "If you check this option the window will not be"\
      "skipped when circulating, even if a more general style sets the"\
      "'skip this window when circulating' option."
  Help staysOnTop "This option will make the window stay on top of all"\
      "other windows no matter if they're raised. This is useful for"\
      "toolbars (e.g. FvwmButtons)."
  Help staysPut "This option will make the window stay below all other"\
      "windows no matter if they're lowered. This is useful if you use"\
      "a graphic viewer to put images around your desktop."
  Help sticky "If you make the window stick to the screen it will"\
      "follow you around virtual desks and pages. The title bar will"\
      "get horizontal lines to distinguish sticky windows from normal"\
      "ones. This is useful for clocks, xbiff, etc."
  Help slippery "If the window sticks to the desk it will stay on the"\
      "virtual desk or page when you change the viewport. Since this is"\
      "the default behavior of FVWM this option only makes sense if"\
      "another more general style sets the 'stick to screen' option."
  Help clickToFocus "'Click to focus' means that you have to click in"\
      "the window before it receives the keyboard focus. This is useful"\
      "for clocks, xbiff, etc. if you use 'Sloppy focus' for other"\
      "windows."
  Help sloppyFocus "'Sloppy focus' means that the keyboard focus will"\
      "follow the mouse (as with 'mouse focus'), but a window doesn't"\
      "loose the focus until the mouse enters another window using"\
      "'sloppy focus' or 'mouse focus'. This is useful, because you can"\
      "move the mouse out of windows without loosing the input focus."
  Help mouseFocus "'Mouse focus' means that the keyboard focus will"\
      "follow the mouse. The window containing the mouse cursor will"\
      "also receive the input focus. If you like this focus policy"\
      "maybe 'sloppy focus' will please you even more."
  #
  ######################################################################

  ######################################################################
  # Technical
  #
  CheckBox olDecor -text "Respect OpenLook(tm) hints"
  CheckBox noOlDecor -text "Ignore OpenLook(tm) hints"
  CheckBox lenience -checkbutton:justify left \
      -text "Ignore the ICCCM input field\nconvention (wm_hints.input)"
  CheckBox noLenience -checkbutton:justify left \
      -text "Respect the ICCCM input field\nconvention"

  Frame technicalLeft -orient top -packFrame:expand no -entries {
    olDecor lenience
  }
  Frame technicalRight -orient top -entries {
    noOlDecor noLenience
  }
  Frame technicalFrameC -entries { technicalLeft technicalRight }
  Line technicalL
  Frame technicalFrame -orient top -entries { technicalL technicalFrameC }

  Change {
    if {$changeElm == "olDecor"} {
      if {$olDecor == 1} {set noOlDecor 0}
    }
    if {$changeElm == "noOlDecor"} {
      if {$noOlDecor == 1} {set olDecor 0}
    }
    if {$changeElm == "lenience"} {
      if {$lenience == 1} {set noLenience 0}
    }
    if {$changeElm == "noLenience"} {
      if {$noLenience == 1} {set lenience 0}
    }
  }

  Help olDecor "If you check this option FVWM will attempt to recognize"\
      "and respect the decoration hints that many OpenLook(tm)"\
      "applications use (e.g. should there be a close button or not)."
  Help noOlDecor "If you check this option FVWM will ignore the"\
      "decoration hints that many OpenLook(tm) applications use. Since"\
      "this is the default this option only makes sense if another more"\
      "general style sets the 'respect OpenLook(tm) hints' option."
  Help lenience "This instructs FVWM to ignore the convention in the"\
      "ICCCM which states that if an application sets the input field"\
      "of the wm_hints structure to False, then it never wants the"\
      "window manager to give it the input focus."
  Help noLenience "This instructs FVWM to respect the convention in the"\
      "ICCCM which states that if an application sets the input field"\
      "of the wm_hints structure to False, then it never wants the"\
      "window manager to give it the input focus. Since this is the"\
      "default behavior this option only makes sense if a more general"\
      "style sets the 'ignore the ICCCM input field convention' option."
  #
  ######################################################################

  ######################################################################
  # Icon
  #
  CheckBox noIcon -text "Prevent icon"
  CheckBox useIcon -text "Force icon"
  Frame icoU -entries { noIcon useIcon }
  CheckBox icoBox -text "Specify icon name:"
  Entry icon
  Frame icoC -entries { icoBox icon }
  Frame iconFrame -entries { icoU icoC } -orient top
  
  Change {
    if {$changeElm == "useIcon"} {
      if {$useIcon==1} {
	set noIcon 0
	Enable icoBox
	if {$icoBox == 1} {Enable icon}
	Enable noIct
	Enable useIct
      } else {
	set icoBox 0
	Disable icoBox
	Disable icon
	set noIct 0
	set useIct 0
	Disable noIct
	Disable useIct
      }
    }
    if {$changeElm == "noIcon"} {
      if {$noIcon==1} {
	set useIcon 0
	set icoBox 0
	Disable icoBox
	Disable icon
	set noIct 0
	set useIct 0
	Disable noIct
	Disable useIct
      }
    }
    if {$changeElm == "icoBox"} {
      if {$icoBox == 1} {Enable icon} else {Disable icon}
    }
  }
  
  Help noIcon \
      "If you check 'Prevent icon' no icon will be displayed when this" \
      "window is iconified."
  
  Help useIcon \
      "If you check 'Force icon' the default icon for the window will" \
      "be displayed when the window is iconified. Optionally you can" \
      "specify a name of an icon file to display."

  set iconHelp [concat \
      "If you specify a name of an icon in this field, this icon will" \
      "be displayed when the window is iconified." ]

  Help icoBox $iconHelp
  Help icon $iconHelp
  #
  ######################################################################

  ######################################################################
  # Icon Title
  #
  CheckBox noIct -text "Prevent icon title"
  CheckBox useIct -text "Force icon title"
  Frame iconTitleFrame -entries { noIct useIct }

  Change {
    if {$changeElm == "noIct"} {
      if {$noIct==1} {set useIct 0}
    }
    if {$changeElm == "useIct"} {
      if {$useIct==1} {set noIct 0}
    }
  }
  
  Help noIct \
      "If you check 'Prevent icon title' no icon title will be" \
      "displayed when this window is iconified." \
      "\n\nNote: This only works when an icon is displayed. If you select" \
      "'Prevent icon' above no icon title will be displayed redardless of" \
      "this setting."

  Help useIct \
      "If you check 'Force icon title' the icon of this window will get" \
      "an icon title." \
      "\n\nNote: This only works when an icon is displayed. If you select" \
      "'Prevent icon' above no icon title will be displayed redardless of" \
      "this setting."
  #
  ######################################################################

  ######################################################################
  # IconBox + Sticky/Slippery
  #
  CheckBox icbC -text "Set the icon area:"
  Int icbLeft -text left
  Int icbTop -text top
  Int icbRight -text right
  Int icbBottom -text bottom
  Frame icbF -entries { icbC icbLeft icbTop icbRight icbBottom }
  CheckBox stickyIcon -text "Force sticky icon"
  CheckBox slipperyIcon -text "Prevent sticky icon"
  Frame stickF -entries { stickyIcon slipperyIcon }
  Frame iconBoxFrame -entries { icbF stickF } -orient top

  Change {
    if { $changeElm == "icbC" } {
      if { $icbC == 1 } { Enable icbLeft icbTop icbRight icbBottom
      } else { Disable icbLeft icbTop icbRight icbBottom }
    }
    if { $changeElm == "stickyIcon" } {
      if { $stickyIcon == 1 } { set slipperyIcon 0 }
    }
    if { $changeElm == "slipperyIcon" } {
      if { $slipperyIcon == 1 } { set stickyIcon 0 }
    }
  }

  Help icbC "The icon box determines where FVWM will put the iconified"\
      "window. You must enter four coordinates, the left, top, right,"\
      "and bottom values. Negative values are relative to the"\
      "right/bottom of the screen."
  Help icbLeft "Here you enter the x-coordinate of the left side of the"\
      "icon box."
  Help icbTop "Here you enter the y-coordinate of the top side of the"\
      "icon box."
  Help icbRight "Here you enter the x-coordinate of the right side of"\
      "the icon box."
  Help icbBottom "Here you enter the y-coordinate of the bottom side of"\
      "the icon box."

  Help stickyIcon "If you check the 'sticky icon' option the icon will"\
      "stick to the physical screen. This means that it follows you"\
      "around virtual desks and pages."
  Help slipperyIcon "If you check the 'prevent sticky icon' option the"\
      "icon will stay on the virtual desk and page where it was"\
      "iconified, when you change the viewport. Since this is the"\
      "default behavior this option only makes sense if another more"\
      "general style has set the 'sticky icon' option."
  #
  ######################################################################

  ######################################################################
  # MWM Stuff
  #
  CheckBox mwmBut  -text "Force MWM Buttons"
  CheckBox fvwmBut -text "Force FVWM Buttons"
  CheckBox mwmBor  -text "Force MWM Border"
  CheckBox fvwmBor -text "Force FVWM Border"
  CheckBox mwmDec  -text "Recognize MWM Decor hints"
  CheckBox noDec   -text "Ignore MWM Decor hints"
  CheckBox mwmFunc -text "Recognize MWM Function hints"
  CheckBox noFunc  -text "Ignore MWM Function hints"
  CheckBox mwmHint -text "Override MWM Function hints"
  CheckBox noHint  -text "Respect MWM Function hints"
  
  Frame mwmLeft  -entries { mwmBut mwmBor mwmDec mwmFunc mwmHint } \
      -orient top
  Frame mwmRight -entries { fvwmBut fvwmBor noDec noFunc noHint } \
      -orient top
  Frame mwmFrame -entries { mwmLeft mwmRight }
  
  Change {
    if {$changeElm == "mwmBut"} {if {$mwmBut == 1} {set fvwmBut 0}}
    if {$changeElm == "fvwmBut"} {if {$fvwmBut == 1} {set mwmBut 0}}
    if {$changeElm == "mwmBor"} {if {$mwmBor == 1} {set fvwmBor 0}}
    if {$changeElm == "fvwmBor"} {if {$fvwmBor == 1} {set mwmBor 0}}
    if {$changeElm == "mwmDec"} {if {$mwmDec == 1} {set noDec 0}}
    if {$changeElm == "noDec"} {if {$noDec == 1} {set mwmDec 0}}
    if {$changeElm == "mwmFunc"} {
      if {$mwmFunc == 1} {
	set noFunc 0
	Enable mwmHint
	Enable noHint
      } else {
	set mwmHint 0
	set noHint 0
	Disable mwmHint
	Disable noHint
      }
    }
    if {$changeElm == "noFunc"} {
      if {$noFunc == 1} {
	set mwmFunc 0
	set mwmHint 0
	set noHint 0
	Disable mwmHint
	Disable noHint
      }
    }
    if {$changeElm == "mwmHint"} {if {$mwmHint == 1} {set noHint 0}}
    if {$changeElm == "noHint"} {if {$noHint == 1} {set mwmHint 0}}
  }
  
  Help mwmBut \
      "The MWM buttons option gives the title bar buttons a look and" \
      "feel like the Motif(tm) Window Manager. This is less 'deep'" \
      "than the default FVWM buttons"
  
  Help fvwmBut \
      "The FVWM buttons option restores the default FVWM look and feel" \
      "for the title bar buttons. This style has more 'depth' than the" \
      "Motif(tm) equivalent. Since FVWM buttons is the default, this" \
      "option only makes sense if a more general style sets the MWM" \
      "buttons option."
  
  Help mwmBor \
      "The MWM borders option gives the borders and handles of the window" \
      "a look and feel like the Motif(tm) Window Manager. This is less" \
      "'deep' than the default FVWM borders."

  Help fvwmBor \
      "The FVWM borders option restores the default FVWM look and feel" \
      "for the borders and handles of the window. This style has more" \
      "'depth' than the Motif(tm) equivalent. Since FVWM borders is the" \
      "default, this option only makes sense if a more general style" \
      "sets the MWM borders option."

  Help mwmDec \
      "If you check this option FVWM will try to recognize and respect" \
      "the Motif(tm) Window Manager decoration hints that applications" \
      "occasionally use. (Probably hints about borders, titles, etc.)"

  Help noDec \
      "If you check this option FVWM will ignore the Motif(tm) Window" \
      "Manager decoration hints that applications occasionally use." \
      "Since this is the default, this option only makes sense if a more" \
      "general style sets the 'Recognize MWM Decor hints' option."

  Help mwmFunc \
      "If you check this option FVWM will try to recognize and respect" \
      "the Motif(tm) Window Manager prohibited operations hints that" \
      "applications occasionally use. These prohibited operations will" \
      "then be disabled (shaded out) in menus."

  Help noFunc \
      "If you check this option FVWM will ignore the Motif(tm) Window" \
      "Manager prohibited operations hints that applications" \
      "occasionally use. Since this is the default, this option only" \
      "makes sense if a more general style sets the 'Recognize MWM" \
      "Function hints' option."

  Help mwmHint \
      "If you check this option FVWM will override the Motif(tm) Window" \
      "Manager prohibited operations hints that applications" \
      "occasionally use. This means that the operations will still be" \
      "shaded out in menus, but the operation can be performed."

  Help noHint \
      "If you check this option FVWM will not let you perform the" \
      "Motif(tm) Window Manager prohibited operations. Since this is" \
      "the default, this option only makes sense if a more general" \
      "style sets the 'Override MWM Function hints' option."
  #
  ######################################################################

  ######################################################################
  # Windows
  #

  # Window Appearance
  Header windowAppearanceH -text "Window Appearance" -frame:relief flat
  Line winAppL
  Window windowAppearance -text "Window Appearance" -entries {
    windowAppearanceH winAppL colorFrame borderFrame titleFrame
    transientFrame buttonFrame
  } -pageEnd {
    if {$borBox==1 && $borderWidth==""} {
      error [concat \
		 "In style of $windowName: " \
		 "Invalid width entered for borders without handles." \
		 "Either uncheck the \"Change border width...\" check box" \
		 "or enter a valid width."]
    }
    if {$hanBox==1 && $handleWidth==""} {
      error [concat \
		 "In style of $windowName: " \
		 "Invalid width entered for borders with handles." \
		 "Either uncheck the \"Change border width...\" check box" \
		 "or enter a valid width."]
    }
  }

  set winAppHelp [concat \
    "On this page you can configure the decorations of windows. This" \
    "includes colors, buttons, borders, etc." ]

  Help windowAppearanceH $winAppHelp
  Help windowAppearance  $winAppHelp

  # Window Behavior
  Header windowBehaviorH -text "Window Behavior" -frame:relief flat
  Line winBehL
  Window windowBehavior -text "Window Behavior" -entries {
    windowBehaviorH winBehL startFrame runningFrame technicalFrame
  } -pageEnd {
    if {$startsOnDesk == 1} {
      if {$startsOnDeskNo == "" || $startsOnDeskNo < 0} {
	error "In style of $windowName: Invalid desk number in Window Behavior"
      }
    }
  }

  set winBehHelp [concat "On this page you can configure different"\
		      "aspects with respect to the window"\
		      "behavior. This includes how the window is"\
		      "initially drawn on screen and how it behaves"\
		      "while the application is running." ]
  Help windowBehaviorH $winBehHelp
  Help windowBehavior  $winBehHelp

  # Icon Appearance
  Header iconAppearanceH -text "Icon Appearance" -frame:relief flat
  Line icoAppL
  Window iconAppearance -text "Icon Appearance" -entries {
    iconAppearanceH icoAppL iconFrame iconTitleFrame iconBoxFrame
  } -pageEnd {
    if {$icoBox == 1 && $icon == ""} {error "Empty string in \"Icon\""}
    if {$icbC == 1} {
      if {$icbLeft == "" || $icbTop == "" ||
	  $icbRight == "" || $icbBottom == "" } {
	error "Invalid icon box coordinates for style $windowName"
      }
    }
  }

  set icoAppHelp [concat \
    "On this page you can configure the appearance of the minimized" \
    "window" ]

  Help iconAppearanceH $icoAppHelp
  Help iconAppearance  $icoAppHelp
  
  # MWM
  Header mwmH -text "Motif(tm) Window Manager Options" -frame:relief flat
  Line mwmL
  Window mwm -text "Motif(tm) WM Options" \
      -entries { mwmH mwmL mwmFrame }
  
  Help mwm \
      "This page configures options to make Fvwm (not) behave more like" \
      "the Motif(tm) Window Manager"
  Help mwmH \
      "This page configures options to make Fvwm (not) behave more like" \
      "the Motif(tm) Window Manager"
  #
  ######################################################################

  Line styleL
  ExtEntry style \
    -entries { windowName
               styleL
	       useStyle
	       useDecor
	       miniIcon
	       windowAppearance
               windowBehavior
               iconAppearance
               mwm
	     } \
    -index windowName -orient top -count 1
  #
  ######################################################################
  
  ######################################################################
  # Save
  #
  Save {
    forevery style {
      if {$windowName == {}} {
	tk_dialog .savedialog Warning \
	    "Warning:\nYou had a 'style' entry with no window name. This \
style will not be generated" info 0 OK
      } else {
	set result "Style\t\"$windowName\"\t"
	if {$useStyle != ""} {append result "UseStyle $useStyle,"}
	if {$useDecor != ""} {append result "UseDecor \"$useDecor\","}
	if {$miniIcon != ""} {append result "MiniIcon $miniIcon,"}
	if {$colBox == 1} {
	  append result "ForeColor [hash2rgb [lindex $foreColor 0]],"
	  append result "BackColor [hash2rgb [lindex $backColor 0]],"
	}
	if {$noHandles  == 1} {append result "NoHandles,"}
	if {$useHandles == 1} {append result "Handles,"}
	if {$borBox     == 1} {append result "BorderWidth $borderWidth,"}
	if {$hanBox     == 1} {append result "HandleWidth $handleWidth,"}
	if {$noTitle    == 1} {append result "NoTitle,"}
	if {$useTitle   == 1} {append result "Title,"}
	if {$noTrans      == 1} {append result "NakedTransient,"}
	if {$forceTrans   == 1} {append result "DecorateTransient,"}
	if {$startIconic  == 1} {append result "StartIconic,"}
	if {$startNormal  == 1} {append result "StartNormal,"}
	if {$startsOnDesk == 1} {append result "StartsOnDesk $startsOnDeskNo,"}
	if {$startsAnywhere  == 1} {append result "StartsAnywhere,"}
	if {$smartPlacement  == 1} {append result "SmartPlacement,"}
	if {$dumbPlacement   == 1} {append result "DumbPlacement,"}
	if {$randomPlacement == 1} {append result "RandomPlacement,"}
	if {$activePlacement == 1} {append result "ActivePlacement,"}
	if {$skipMapping     == 1} {append result "SkipMapping,"}
	if {$showMapping     == 1} {append result "ShowMaping,"}
	if {$noPPosition     == 1} {append result "NoPPosition,"}
	if {$usePPosition    == 1} {append result "UsePPosition,"}
	if {$windowListSkip  == 1} {append result "WindowListSkip,"}
	if {$windowListHit   == 1} {append result "WindowListHit,"}
	if {$circulateSkip   == 1} {append result "CirculateSkip,"}
	if {$circulateHit    == 1} {append result "CirculateHit,"}
	if {$staysOnTop      == 1} {append result "StaysOnTop,"}
	if {$staysPut        == 1} {append result "StaysPut,"}
	if {$sticky          == 1} {append result "Sticky,"}
	if {$slippery        == 1} {append result "Slippery,"}
	if {$clickToFocus    == 1} {append result "ClickToFocus,"}
	if {$sloppyFocus     == 1} {append result "SloppyFocus,"}
	if {$mouseFocus      == 1} {append result "MouseFocus,"}
	if {$olDecor         == 1} {append result "OLDecor,"}
	if {$noOlDecor       == 1} {append result "NoOLDecor,"}
	if {$lenience        == 1} {append result "Lenience,"}
	if {$noLenience      == 1} {append result "NoLenience,"}
	if {$useIcon == 1} {
	  append result "Icon"
	  if {$icoBox == 1} {append result " $icon"}
	  append result ","
	}
	if {$noIcon == 1} {append result "NoIcon,"}
	if {$useIct == 1} {append result "IconTitle,"}
	if {$noIct  == 1} {append result "NoIconTitle,"}
	if {$icbC   == 1} {
	  append result "IconBox $icbLeft $icbTop $icbRight $icbBottom,"
	}
	if {$stickyIcon   == 1} {append result "StickyIcon,"}
	if {$slipperyIcon == 1} {append result "SlipperyIcon,"}
	if {$mwmBut  == 1} {append result "MWMButtons,"}
	if {$fvwmBut == 1} {append result "FvwmButtons,"}
	if {$mwmBor  == 1} {append result "MWMBorder,"}
	if {$fvwmBor == 1} {append result "FvwmBorder,"}
	if {$mwmDec  == 1} {append result "MWMDecor,"}
	if {$noDec   == 1} {append result "NoDecorHint,"}
	if {$mwmFunc == 1} {append result "MWMFunctions,"}
	if {$noFunc  == 1} {append result "NoFuncHint,"}
	if {$mwmHint == 1} {append result "HintOverride,"}
	if {$noHint  == 1} {append result "NoOverride,"}
	
	for {set i 0} {$i <= 9} {incr i} {
	  if {[set ibut$i] == 1} {append result "Button $i,"}
	  if {[set ebut$i] == 1} {append result "NoButton $i,"}
	}
	
	# Strip last comma
	if {[string index $result [expr [string length $result] - 1]] == ","} {
          set result \
	      [string range $result 0 [expr [string length $result] - 2]]
          print $result
        } else {
	  error "No options given for window \"$windowName\""
	}
      }
    }
  }
  #
  ######################################################################
}

