### Copyright (C) 1995 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 buttonsAndCursors {} {
  # Operating modes / Buttons and cursors
  Desc "Change the style of buttons and mouse cursors"
  ShortDesc "Buttons and cursors"

  # Button styles
  Menu buttonNo -text "Button no" -entries {0 1 2 3 4 5 6 7 8 9} \
      -help "Choose which button to change"
  Int buttonWidth -text "Width %" \
      -help "The width of the button.\nThis entry is used when defining" \
      "rectangular buttons"
  Int buttonHeight -text "Height %" \
      -help "The height of the button.\nThis entry is used when defining" \
      "rectangular buttons"

  ExtEntry buttonStyle -text "Buttons" -entries {
    buttonNo buttonWidth buttonHeight} \
      -help "Define rectangular shapes of your buttons"
  Line line1

  Menu buttonNo2 -text "Button no" -entries {0 1 2 3 4 5 6 7 8 9} \
      -help "Choose which button to change"
  Entry userStyle -text "User style" \
      -help "This entry is used to define more complex button shapes.\n" \
      "Check out the man page for fvwm to see the syntax."
  ExtEntry buttonStyle2 -text "Or use complex definitions" -entries {
    buttonNo2 userStyle} -help "Define complex shapes of your buttons"
  Line line2
  
  # Cursors
  Menu cursorNo -text "Cursor" -entries {
    Position "Title bar" Default System Move Wait Menu Select Destroy Top \
	Right Bottom Left "Top left" "Top right" "Bottom left" "Bottom right"} \
      -help "Use this menu to select which cursor you want to change"
  ListBox cursorType -text "Type" -entries {
    "Default (no change)" X_cursor arrow based_arrow_down based_arrow_up boat \
	bogosity bottom_left_corner bottom_right_corner bottom_side bottom_tee \
	box_spiral center_ptr circle clock coffee_mug cross cross_reverse \
	crosshair diamond_cross dot dotbox double_arrow draft_large \
	draft_small draped_box exchange fleur gobbler gumby hand1 hand2 heart \
	icon iron_cross left_ptr left_side left_tee leftbutton ll_angle \
	lr_angle man middlebutton mouse pencil pirate plus question_arrow \
	right_ptr right_side right_tee rightbutton rtl_logo sailboat \
	sb_down_arrow sb_h_double_arrow sb_left_arrow sb_right_arrow \
	sb_up_arrow sb_v_double_arrow shuttle sizing spider spraycan star \
	target tcross top_left_arrow top_left_corner top_right_corner \
	top_side top_tee trek ul_angle umbrella ur_angle watch xterm } \
      -selectmode single \
      -help "Use this menu to define the shape of the cursor"

  ExtEntry cursor -text "Cursors" -lines 1 -entries {cursorNo cursorType} \
      -help "Here you can change the appearance of your cursor. Select which" \
      "cursor to change in the menu and select the shape of the cursor in the" \
      "listbox."
  
  Save {
    forevery buttonStyle {
      if {$buttonWidth != {} && $buttonHeight != {}} {
	if {$buttonWidth < 0 || $buttonWidth > 100} {
	  error "Invalid button width"
	}
	if {$buttonHeight < 0 || $buttonHeight > 100} {
	  error "Invalid button height"
	}
	print "ButtonStyle\t$buttonNo(name) ${buttonWidth}x$buttonHeight"
      }
    }
    forevery buttonStyle2 {
      if {$userStyle != {}} {
	print "ButtonStyle : $buttonNo2(name) $userStyle"
      }
    }
    forevery cursor {
      if {$cursorType(index) != 0 && $cursorType(index) != {}} {
	print "Cursor\t$cursorNo(index) [expr ($cursorType(index)-1)*2]"
      }
    }
  }
}

proc fvwmmodes {} {
  # Operating modes / General look-and-feel
  Desc "The general 'look-and-feel' of the window manager"
  ShortDesc "The look and feel"

  CheckBox boundary -text "Change the width of decorated borders" \
      -help "This changes the width of window borders"
  Int boundaryWidth -textafter "pixels" \
      -help "The width of window borders in pixels"
  CheckBox clickTime -text "Change delay for double clicks" \
      -help "Use this to change the click time for double clicks. This is" \
      "very useful if you're having trouble double clicking."
  Int clickDelay -default 150 -text "\tMaximum time between clicks" \
      -textafter "milli seconds" \
      -help "The maximum delay between two mouse clicks to make it a double" \
      "click"
  CheckBox clickFocus -text "You have to click" \
      "the mouse on a window to give it the focus" \
      -help "If this option is selected you have to click the mouse in a" \
      "window to give it the focus"
  CheckBox desktopScale -text "Change the virtual desktop scale" \
      -help "Use this option if you don't like the size of the internal pager"
  Int desktopScaleVal -default 25 -text "\tReduce by a factor of" \
      -help "The reduction factor for the internal pager.\nThe size of each" \
      "desktop in the pager will be your screen resolution divided by the" \
      "reduction factor"
  CheckBox desktopSize -text "Define the number of virtual desktops" \
      -help "This defines the number of virtual desktops you want (horizontal" \
      "x vertical)"
  Int desktopSizeX -default 2 -text "\tIn the horizontal direction" \
      -help "Number of desktops in the horizontal direction"
  Int desktopSizeY -default 2 -text "\tIn the vertical direction" \
      -help "Number of desktops in the vertical direction"
  CheckBox edgeRes -text "Change how hard it should be to change desktop by" \
      -help "If you find yourself accidentally flipping pages with the mouse" \
      "use this option to make it harder to change desktop.\nThe resistance" \
      "is given by to values:\n1) The delay in milli seconds to wait before" \
      "flipping, and\n2) The number of pixels a window must be off screen" \
      "before actually flipping"
  Int edgeRes1 -default 150 -text "\tmoving the mouse over the edge" \
      -textafter "milli seconds\t"\
      -help "If you find yourself accidentally flipping pages with the mouse" \
      "use this option to make it harder to change desktop.\nThe resistance" \
      "is given by to values:\n1) The delay in milli seconds to wait before" \
      "flipping, and\n2) The number of pixels a window must be off screen" \
      "before actually flipping"
  Int edgeRes2 -default 50 -textafter "pixels\t\t"\
      -help "If you find yourself accidentally flipping pages with the mouse" \
      "use this option to make it harder to change desktop.\nThe resistance" \
      "is given by to values:\n1) The delay in milli seconds to wait before" \
      "flipping, and\n2) The number of pixels a window must be off screen" \
      "before actually flipping"
  CheckBox edgeScroll -text "Change the percentage of a desktop to flip when" \
      "the mouse goes over the edge" \
      -help "This changes the percentage of a desktop to flip when using the" \
      "mouse to change pages"
  Int xScroll -default 100 -textafter "% in the x direction" \
      -help "This changes the percentage of a desktop to flip when using the" \
      "mouse to change pages"
  Int yScroll -default 100 -textafter "% in the y direction" \
      -help "This changes the percentage of a desktop to flip when using the" \
      "mouse to change pages"
  CheckBox pager -text "Location of the internal pager" \
      -help "To move the internal pager to a specified location at startup" \
      "use this option"
  Int xPager -default 0 -text "\tX location" \
      -help "Where to put the internal pager at startup (X)"
  Int yPager -default 0 -text "\tY location" \
      -help "Where to put the internal pager at startup (Y)"
  CheckBox pagingDefault -text "Start with the internal pager enabled" \
      -help "Enable this option to start with the internal pager enabled"
  CheckBox sloppyFocus -text "Windows keep the focus until the mouse enters" \
      "another window (not the root)" \
      -help "With this option enabled you can move the mouse out of a window" \
      "without removing the focus from the window. The focus is not moved" \
      "until the mouse enters another window - that is, not the desktop (root)."
  CheckBox noBoundary -text "Change the width of undecorated borders" \
      -help "Use this option to change the border width of undecorated windows"
  Int noBoundaryWidth -textafter "pixels" \
      -help "The width (in pixels) of the borders of undecorated windows"
  
  Change {
    if {$clickTime == 1} {
      Enable clickDelay
    } else {
      Disable clickDelay
    }
    if {$desktopScale == 1} {
      Enable desktopScaleVal
    } else {
      Disable desktopScaleVal
    }
    if {$desktopSize == 1} {
      Enable desktopSizeX
      Enable desktopSizeY
    } else {
      Disable desktopSizeX
      Disable desktopSizeY
    }
    if {$edgeRes == 1} {
      Enable edgeRes1
      Enable edgeRes2
    } else {
      Disable edgeRes1
      Disable edgeRes2
    }
    if {$edgeScroll == 1} {
      Enable xScroll
      Enable yScroll
    } else {
      Disable xScroll
      Disable yScroll
    }
    if {$pager == 1} {
      Enable xPager
      Enable yPager
    } else {
      Disable xPager
      Disable yPager
    }  
    if {$boundary == 1} {
      Enable boundaryWidth
    } else {
      Disable boundaryWidth
    }
    if {$noBoundary == 1} {
      Enable noBoundaryWidth
    } else {
      Disable noBoundaryWidth
    }
  }
  
  Save {
    if {$boundary == 1} {
      if {$boundaryWidth == {}} {error "invalid boundary width"}
      print "BoundaryWidth\t$boundaryWidth"
    }
    if {$clickTime == 1} {
      if {$clickDelay == {}} {error "No value given for click delay"}
      print "ClickTime\t$clickDelay"
    }
    if {$clickFocus == 1} {print "ClickToFocus"}
    if {$desktopScale == 1} {
      if {$desktopScaleVal == {}} {error "No value given for reduce factor"}
      print "DesktopScale\t$desktopScaleVal"
    }
    if {$desktopSize == 1} {
      if {$desktopSizeX == {}} {error "No value given for virtual desktops" \
				    " in the horisontal direction" }
      if {$desktopSizeY == {}} {error "No value given for virtual desktops" \
				    " in the vertical direction" }
      print "DesktopSize\t${desktopSizeX}x${desktopSizeY}"
    }
    if {$edgeRes == 1} {
      if {$edgeRes1 == {}} {error "edge resistance values wrong"}
      if {$edgeRes2 == {}} {error "edge resistance values wrong"}
      print "EdgeResistance\t$edgeRes1 $edgeRes2"
    }
    if {$edgeScroll == 1} {
      if {$xScroll == {}} {error "edge scroll values wrong"}
      if {$yScroll == {}} {error "edge scroll values wrong"}
      print "EdgeScroll\t$xScroll $yScroll"
    }
    if {$pager == 1} {
      if {$xPager == {}} {error "Invalid X location for pager"}
      if {$yPager == {}} {error "Invalid Y location for pager"}
      print "Pager\t$xPager $yPager"
    }
    # I'm not completely sure about this one...
    if {$pagingDefault == 1} {print "PagingDefault\t1"}
    if {$sloppyFocus == 1} {print "SloppyFocus"}
    if {$noBoundary == 1} {
      if {$noBoundaryWidth == {}} {error "invalid noboundary width"}
      print "NoBoundaryWidth\t$noBoundaryWidth"
    }
  }
}

proc FVWMwindows {} {
  # Operating modes / Behavior of windows 

  Desc "Options that affect the behavior of windows"
  ShortDesc "The behavior of windows"

  CheckBox dontMove -text "Prevent windows from being moved entirely off" \
      "the screen" \
      -help "Windows that are placed entirely off screen will be moved 16" \
      "pixels back onto the screen, so you can reach the border."
  CheckBox autoRaise -text "Autoraise windows" \
      -help "If you want windows to be raised automatically after a certain" \
      "period of time enable this option"
  Int autoRaiseDelay -default 750 -text "\tAutoraise after" \
      -textafter "milli seconds" \
      -help "How many milli seconds before raising windows"
  CheckBox centerOnCirculate -text "Center windows when circulating" \
      -help "With this option enabled, windows will be centered on screen" \
      "when circulating or warping to them."
  CheckBox circulateSkipIcons -text "Skip iconified windows when circulating" \
      "and warping" \
      -help "With this option enabled iconified windows will not be" \
      "considered when circulating and warping"
  CheckBox decorateTransients -text "Give transient windows decorations" \
      -help "Enable this to decorate transient windows"
  CheckBox opaqueMove -text "Move windows with their contents (requires" \
      "a fast server)" \
      -help "Enable this to draw the entire window when moving (no wireframe)"
  Int opaqueSize -default 20 -text "\tMaximum window size in percent of" \
      "the screen" -textafter "%" \
      -help "This determines the maximum window size for opaque move"
  CheckBox opaqueResize -text "Resize windows with their contents (requires" \
      "an even faster server ;-)" \
      -help "With this option enabled the entire window will be drawn while" \
      "resizing (no wireframe)"
  CheckBox randomPlacement -text "Prevent user interaction when creating new" \
      "windows" \
      -help "This makes new windows popup at random locations in stead of" \
      "having the user (you) placing every new window with the mouse"
  CheckBox smartPlacement -text "New windows will be placed without covering" \
      "other windows when possible" \
      -help "This works pretty much like random placement, but if possible" \
      "new windows will be placed without covering other windows."
  CheckBox stickyIcons -text "Let the icons follow you when changing desktop" \
      -help "The icons sticks to the screen rather than the desktop. This" \
      "means that you can allways see all your icons, no matter which desktop" \
      "is currently visible"
  CheckBox stubIcons -text "Minimize windows to their original desktop" \
      -help "When this option is enabled windows will allways minimize to" \
      "their original desktop"
  CheckBox stubIconPlace -text "Do not place icons under windows" \
      -help "This will try to prevent placing icons underneath windows"
  CheckBox stubbornPlacement -text "Do not place new windows on top of icons" \
      -help "This will try to prevent placing new windows on top of icons"
  CheckBox supIcons -text "Do not use icons at all" \
      -help "This suppresses the use of icons entirely"

  Line beforeIconBox
  Int iconBoxLeft -text "Left" -help the left edge of the icon box"
  Int iconBoxTop -text "Top" -help the top edge of the icon box"
  Int iconBoxRight -text "Right" -help the right edge of the icon box"
  Int iconBoxBottom -text "Bottom" -help the bottom edge of the icon box"
  ExtEntry iconBox -text "Icon boxes" -entries {
    iconBoxLeft iconBoxTop iconBoxRight iconBoxBottom} \
      -help "Defines region(s) of the desktop to use for icons"

  Change {
    if {$autoRaise == 1} {
      Enable autoRaiseDelay
    } else {
      Disable autoRaiseDelay
    }
    if {$opaqueMove == 1} {
      Enable opaqueSize
    } else {
      Disable opaqueSize
    }

  }
  
  Save {
    if {$dontMove == 1} {print "DontMoveOff"}
    if {$autoRaise == 1} {
      if {$autoRaiseDelay == {}} {error "No value given for autoraise delay"}
      print "AutoRaise\t$autoRaiseDelay"
    }
    if {$centerOnCirculate == 1} {print "CenterOnCirculate"}
    if {$circulateSkipIcons == 1} {print "CirculateSkipIcons"}
    if {$decorateTransients == 1} {print "DecorateTransients"}
    if {$opaqueMove == 1} {
      if {$opaqueSize == {}} {error "No value given for opaque size"}
      print "OpaqueMove\t$opaqueSize"
    }
    if {$opaqueResize == 1} {print "OpaqueResize"}
    if {$randomPlacement == 1} {print "RandomPlacement"}
    if {$smartPlacement == 1} {print "SmartPlacement"}
    if {$stickyIcons == 1} {print "StickyIcons"}
    if {$stubIcons == 1} {print "StubbornIcons"}
    if {$stubIconPlace == 1} {print "StubbornIconPlacement"}
    if {$stubbornPlacement == 1} {print "StubbornPlacement"}
    if {$supIcons == 1} {print "SuppressIcons"}
    forevery iconBox {
      if {$iconBoxLeft!={} && $iconBoxTop!={} && $iconBoxRight!={} &&
	  $iconBoxBottom!={}} {
	print "IconBox\t$iconBoxLeft $iconBoxTop $iconBoxRight $iconBoxBottom"
      }
    }
  }
}

proc MWMmodes {} {
  # Operating modes / Motif(tm) options

  Desc "Motif Window Manager options"
  ShortDesc "MWM options"

  CheckBox mwmFunc -text "MWM function hints" \
      -help "Some programs rely on this (see man page)"
  CheckBox mwmOver -text "MWM hint override" \
      -help "Some programs rely on this (see man page)"
  CheckBox mwmDecor -text "MWM decor hints" \
      -help "Some programs rely on this (see man page)"
  CheckBox mwmMenus -text "Motif style menus" \
      -help "This makes menus drop down Motif-like. That is, sub menus drop" \
      "down right away, and entirely off the parent menu."
  CheckBox mwmBorders -text "Motif style borders (less deep)" \
      -help "This makes the borders of windows less deep (a la Motif)"
  CheckBox mwmButtons -text "Motif style buttons" \
      -help "Maximize button does MWM-inversion thingy (?)"

  Save {
    if {$mwmFunc == 1} {print "MWMFunctionHints"}
    if {$mwmOver == 1} {print "MWMHintOverride"}
    if {$mwmDecor == 1} {print "MWMDecorHints"}
    if {$mwmMenus == 1} {print "MWMMenus"}
    if {$mwmBorders == 1} {print "MWMBorders"}
    if {$mwmButtons == 1} {print "MWMButtons"}
  }
}

proc TechnicalStuff {} {
  # Operating modes / Technical stuff

  Desc "Options that affect speed and/or use of memory etc."
  ShortDesc "Technical stuff"

  CheckBox appsBacking -text "Make application windows request backing store" \
      -help "This is a bit too technical for me ;-|"
  CheckBox backingStore -text "Make fvwm decorations request backing store" \
      -help "This is a bit too technical for me ;-|"
  CheckBox noPPosition -text "Ignore the PPosition field when adding new" \
      "windows" \
      -help "This is a bit too technical for me ;-|"
  CheckBox saveUnders -text "Make fvwm decorations request save-unders" \
      -help "This is a bit too technical for me ;-|"
  CheckBox XORvalue -text "Change the value with which bits are XOR'ed when" \
      "doing rubber band moving or resizing" \
      -help "This makes the wire frame appear in another color. Setting this" \
      "is a trial-and-error procedure"
  Int XOR -default 0 -text "\tXOR value" \
      -help "This makes the wire frame appear in another color. Setting this" \
      "is a trial-and-error procedure"
  
  Change {
    if {$XORvalue == 1} {
      Enable XOR
    } else {
      Disable XOR
    }
  }
  
  Save {
    if {$appsBacking == 1} {print "AppsBackingStore"}
    if {$backingStore == 1} {print "BackingStore"}
    if {$noPPosition == 1} {print "NoPPosition"}
    if {$saveUnders == 1} {print "SaveUnders"}
    if {$XORvalue == 1} {
      if {$XOR == {}} {
	error "Illegal XOR value"
      } else {
	print "XORvalue\t$XOR"
      }
    }
      
  }
}

proc styles {} {
  # Operating modes / Styles of windows
  Desc "The styles of specified windows"
  ShortDesc "Styles"

  # Find the names of all the defined colors
  set colorNames [getColors]
  if {$colorNames != {}} {
    # The colors have been found
    ListBox foreColorBox -selectmode single -entries $colorNames \
	-help "This is the list of colors available for foreground color"
    ListBox backColorBox -selectmode single -entries $colorNames \
	-help "This is the list of colors available for background color"
  } else {
    error "No color definition file could be found"
  }
  
  Entry styleName -text "Name of window" \
      -help "This is the name of the window you would like to change the" \
      "appearance of"
  
  CheckBox borderWidth -text "Change the border width to" \
      -help "The borderwidth of the specified window"
  Int borderWidthValue -textafter "pixels" \
      -help "The borderwidth of the specified window"
  Frame borderWidthFrame -entries {borderWidth borderWidthValue}

  CheckBox handleWidth -text "Change the handle width to" \
      -help "The handlewidth of the specified window"
  Int handleWidthValue -textafter "pixels" \
      -help "The handlewidth of the specified window"
  Frame handleWidthFrame -entries {handleWidth handleWidthValue}

  CheckBox noIcon -text "Prevent icon" \
      -help "Prevent use of an icon for the specified window"
  CheckBox icon -text "Specify icon name" \
      -help "Specify which icon to use for this window"
  Entry iconName -help "Type the name of the icon to use here (relatively" \
      "to an entry in the icon/pixmap path"
  Frame iconFrame -entries {noIcon icon iconName}

  CheckBox noTitle -text "Prevent window title" \
      -help "When this option is checked, this window will get no title bar"
  CheckBox title -text "Specify window title" \
      -help "Here you can specify what title will appear in the windows title" \
      "bar"
  Entry titleName -help "Enter the title of this window here"
  Frame titleFrame -entries {noTitle title titleName}

  CheckBox noHandles -text "Prevent handles" \
      -help "When this option is checked, the window will get no handles" \
      "(corners)."
  CheckBox handles -text "Force handles" \
      -help "When this option is checked, the window will get handles" \
      "(corners)."
  Frame handlesFrame -entries {noHandles handles}

  CheckBox windowListSkip -text "Remove from window list" \
      -help "Use this option to exclude this window from the window list"
  CheckBox windowListHit -text "Include in window list" \
      -help "Use this option to include this window in the window list"
  Frame windowListSkipFrame -entries {windowListSkip windowListHit}

  CheckBox circulateSkip -text "Skip when circulating" \
      -help "Use this option to skip this window when circulating"
  CheckBox circulateHit -text "Include when circulating" \
      -help "Use this option to include this window when circulating"
  Frame circulateSkipFrame -entries {circulateSkip circulateHit}

  CheckBox staysOnTop -text "Window stays on top" \
      -help "With this option you make the window stay on top (never covered" \
      "by other windows)"
  CheckBox staysPut -text "Window stays put" \
      -help "With this option you make the window stay 'glued' to the desktop" \
      "so it never covers other windows"
  Frame staysOnTopFrame -entries {staysOnTop staysPut}

  CheckBox sticky -text "Sticky window" \
      -help "This option makes the window stick to the screen, so it follows" \
      "you along the desktops"
  CheckBox slippery -text "Slippery window" \
      -help "This option prevents the window from sticking to the screen, so" \
      "it stays on the current desktop"
  Frame stickyFrame -entries {sticky slippery}

  CheckBox startIconic -text "Start iconified" \
      -help "This option forces the window to start iconified"
  CheckBox startNormal -text "Start as normal window" \
      -help "This option prevents the window from starting iconified"
  Frame startIconicFrame -entries {startIconic startNormal}

  CheckBox foreColor -text "Change the foreground color" \
      -help "Use this to change the foreground color of the window"
  CheckBox backColor -text "Change the background color" \
      -help "Use this to change the background color of the window"
  Frame foreColorFrame -entries {foreColor foreColorBox} -orient top
  Frame backColorFrame -entries {backColor backColorBox} -orient top
  Frame colorFrame -entries {foreColorFrame backColorFrame}

  CheckBox startsAnyWhere -text "Allow to start on any desk" \
      -help "When this option is checked the window may start anywhere (i.e." \
      "it starts on the current desktop"
  CheckBox startsOnDesk -text "Force to start on desk no" \
      -help "With this option you can specify at which desktop this window" \
      "should be opened"
  Int startsOnDeskValue -help "Enter the desktop number here"
  Frame startsOnDeskFrame -entries {
    startsAnyWhere startsOnDesk startsOnDeskValue}

  CheckBox noIconTitle -text "Prevent icon title" \
      -help "This option enabled means that the window gets no title when" \
      "iconified"
  CheckBox iconTitle -text "Specify icon title" \
      -help "This option enables you to specify the icon title of the window"
  Entry iconTitleName
  Frame iconTitleFrame -entries {noIconTitle iconTitle iconTitleName}

  ExtEntry style -entries {
    styleName borderWidthFrame handleWidthFrame iconFrame titleFrame \
	handlesFrame windowListSkipFrame circulateSkipFrame staysOnTopFrame \
	stickyFrame startIconicFrame colorFrame startsOnDeskFrame \
	iconTitleFrame} -orient top -count 1 \
      -help "When changing the style of windows keep in mind that later style" \
      "definitions overload former.\nThis means that when using wildcards," \
      "a window will get the styles of all matching definitions, but when two" \
      "style definitions conflict the latter of the two is used."

  Change {
    if {$changeElm=="borderWidth"} {
      if {$borderWidth==1} {Enable borderWidthValue
      } else {Disable borderWidthValue}
    }
      
    if {$changeElm=="handleWidth"} {
      if {$handleWidth==1} {Enable handleWidthValue
      } else {Disable handleWidthValue}
    }
    
    if {$changeElm=="icon"} {if {$icon==1} {set noIcon 0}}
    if {$changeElm=="noIcon"} {if {$noIcon==1} {set icon 0}}
    if {$changeElm=="icon"} {
      if {$icon==1} {Enable iconName} else {Disable iconName}
    }

    if {$changeElm=="title"} {if {$title==1} {set noTitle 0}}
    if {$changeElm=="noTitle"} {if {$noTitle==1} {set title 0}}
    if {$changeElm=="title"} {
      if {$title==1} {Enable titleName} else {Disable titleName}
    }
      
    if {$changeElm=="handles"} {if {$handles==1} {set noHandles 0}}
    if {$changeElm=="noHandles"} {if {$noHandles==1} {set handles 0}}
    
    if {$changeElm=="windowListHit"} {if {$windowListHit==1} {
      set windowListSkip 0}}
    if {$changeElm=="windowListSkip"} {if {$windowListSkip==1} {
      set windowListHit 0}}
    
    if {$changeElm=="circulateHit"} {if {$circulateHit==1} {
      set circulateSkip 0}}
    if {$changeElm=="circulateSkip"} {if {$circulateSkip==1} {
      set circulateHit 0}}
    
    if {$changeElm=="staysPut"} {if {$staysPut==1} {set staysOnTop 0}}
    if {$changeElm=="staysOnTop"} {if {$staysOnTop==1} {set staysPut 0}}
    
    if {$changeElm=="slippery"} {if {$slippery==1} {set sticky 0}}
    if {$changeElm=="sticky"} {if {$sticky==1} {set slippery 0}}
      
    if {$changeElm=="startNormal"} {if {$startNormal==1} {set startIconic 0}}
    if {$changeElm=="startIconic"} {if {$startIconic==1} {set startNormal 0}}
    
    if {$changeElm=="foreColor"} {
      if {$foreColor==1} {Enable foreColorBox} else {Disable foreColorBox}
    }
    if {$changeElm=="backColor"} {
      if {$backColor==1} {Enable backColorBox} else {Disable backColorBox}
    }
    
    if {$changeElm=="startsOnDesk"} {if {$startsOnDesk==1} {
      set startsAnyWhere 0}}
    if {$changeElm=="startsAnyWhere"} {if {$startsAnyWhere==1} {
      set startsOnDesk 0}}
    if {$changeElm=="startsOnDesk"} {
      if {$startsOnDesk==1} {Enable startsOnDeskValue} else {
	Disable startsOnDeskValue}
    }
    
    if {$changeElm=="iconTitle"} {if {$iconTitle==1} {set noIconTitle 0}}
    if {$changeElm=="noIconTitle"} {if {$noIconTitle==1} {set iconTitle 0}}
    if {$changeElm=="iconTitle"} {
      if {$iconTitle==1} {Enable iconTitleName} else {Disable iconTitleName}
    }
  }

  Save {
    forevery style {
      if {$styleName != {}} {
	set result "Style\t\"$styleName\"\t"
	if {$borderWidth==1} {
	  if {$borderWidthValue=={}} {error "Invalid border width"}
	  append result "BorderWidth $borderWidthValue,"
	}
	if {$handleWidth==1} {
	  if {$handleWidthValue=={}} {error "Invalid handle width"}
	  append result "HandleWidth $handleWidthValue,"
	}
	if {$icon==1} {
	  if {$iconName=={}} {error "Invalid icon name"}
	  append result "Icon $iconName,"
	} else {
	  if {$noIcon==1} {append result "NoIcon,"}
	}
	if {$title==1} {
	  if {$titleName=={}} {error "Invalid title"}
	  append result "Title $titleName,"
	} else {
	  if {$noTitle==1} {append result "NoTitle,"}
	}
	if {$handles==1} {
	  append result "Handles,"
	} else {
	  if {$noHandles==1} {append result "NoHandles,"}
	}
	if {$windowListSkip==1} {
	  append result "WindowListSkip,"
	} else {
	  if {$windowListHit==1} {append result "WindowListHit,"}
	}
	if {$circulateSkip==1} {
	  append result "CirculateSkip,"
	} else {
	  if {$circulateHit==1} {append result "CirculateHit,"}
	}
	if {$staysOnTop==1} {
	  append result "StaysOnTop,"
	} else {
	  if {$staysPut==1} {append result "StaysPut,"}
	}
	if {$sticky==1} {
	  append result "Sticky,"
	} else {
	  if {$slippery==1} {append result "Slippery,"}
	}
	if {$startIconic==1} {
	  append result "StartIconic,"
	} else {
	  if {$startNormal==1} {append result "StartNormal,"}
	}
	if {$foreColor==1} {append result "ForeColor $foreColorBox(name),"}
	if {$backColor==1} {append result "BackColor $backColorBox(name),"}
	if {$startsOnDesk==1} {
	  if {$startsOnDeskValue=={}} {error "Invalid desk no"}
	  append result "StartsOnDesk $startsOnDeskValue,"
	} else {
	  if {$startsAnyWhere==1} {append result "StartsAnyWhere,"}
	}
	if {$iconTitle==1} {
	  if {$iconTitleName=={}} {error "Invalid icon title"}
	  append result "IconTitle $iconTitleName,"
	} else {
	  if {$noIconTitle==1} {append result "NoIconTitle,"}
	}
	if {[string index $result [expr [string length $result] - 1]] == ","} {
	  set result [string range $result 0 [expr [string length $result] - 2]]
	}
	print $result
      }
    }
  }
}
