### 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 colorsfonts {} {
  # Look-and-Feel / Colors and Fonts

  Desc "Configuration of colors and fonts of menus and windows"
  ShortDesc "Colors and fonts"

  Header colfontH -text "Colors and Fonts" -frame:relief flat
  Help colfontH \
      "On this page you configure the colors and fonts to use for" \
      "menus and window title bars."

  ####################################################################
  # Menus
  #
  Line menusL
  Header menusH -text "Menu Appearance" -frame:relief flat

  CheckBox menuB -text "Change the menu appearance"
  Command foreColor \
      -text "    Color of the text" \
      -default [list "#000000" 0] \
      -setvalue {
	$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 } \
      -packFrame:expand no
  Command backColor \
      -text "background" \
      -default [list "#AAAAAA" 0] \
      -setvalue {
	$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 } \
      -packFrame:expand no
  Command shadeColor \
      -text "shade" \
      -default [list "#CCCCCC" 0] \
      -setvalue {
	$widget configure -bg [lindex $shadeColor 0] -text "      "} \
      -invoke {ColorWidget $colorList [lindex $shadeColor 0] \
		   [lindex $shadeColor 1]} \
      -disable {$widget configure -relief flat } \
      -enable {$widget configure -relief raised } \
      -packFrame:expand no
  Frame colF -entries { foreColor backColor shadeColor }

  Command menuFont \
      -text "    Font" \
      -default "--adobe-helvetica-*-*-*-*-*-*-*-*-*-*-*-*" \
      -setvalue {buttonSetText $widget $menuFont} \
      -invoke {FontWidget $menuFont 0} \
      -disable {$widget configure -text "Not set"
	$widget configure -font fixed} \
      -enable {buttonSetText $widget $menuFont}

  Label menuStyleL -text "    Menu style:" -packFrame:expand no
  Radio menuStyle -entries { FVWM MWM }
  Frame menuStyleF -entries { menuStyleL menuStyle }

  Help menusH \
      "Here you configure the appearance of the menus in FVWM. You can" \
      "configure the colors, fonts, and choose whether to emulate the" \
      "Motif(tm) Window Manager."

  Help menuB \
      "Select this checkbox if you want to configure the appearance of" \
      "the menus."

  Help foreColor \
      "Here you configure the color of the text on menus."

  Help backColor \
      "Here you configure the background color of menus."

  Help shadeColor \
      "Here you configure the color of disabled menu entries."

  Help menuFont \
      "Here you select the font to use for the menus."

  set styleHelp [concat \
      "Here you select the menu style. FVWM means use the default menu" \
      "appearance for FVWM. MWM means that menus should resemble the menus" \
      "of the Motif(tm) Window Manager. This affects the titles and" \
      "the drop-down behavior." ]

  Help menuStyleL $styleHelp
  Help menuStyle  $styleHelp

  Change {
    if {$changeElm == "menuB"} {
      if {$menuB == 1} {
	Enable foreColor backColor shadeColor menuFont menuStyle
      } else {
	Disable foreColor backColor shadeColor menuFont menuStyle
      }
    }
  }

  Save {
    if {$menuB == 1} {
      set result "MenuStyle\t"
      append result "[hash2rgb [lindex $foreColor 0]] "
      append result "[hash2rgb [lindex $backColor 0]] "
      append result "[hash2rgb [lindex $shadeColor 0]] $menuFont "
      if {$menuStyle(name) == "FVWM"} {
	append result fvwm
      } else {
	append result mwm
      }
      print $result
    }
  }
  #
  ####################################################################

  ####################################################################
  # Windows
  #
  Line windowsL
  Header windowsH -text "Window Appearance" -frame:relief flat

  CheckBox wColB -text "Set the highlight color of" -packFrame:expand no
  Command wForeColor \
      -text "text" \
      -default [list "#FFFFFF" 0] \
      -setvalue {
	$widget configure -bg [lindex $wForeColor 0] -text "      "} \
      -invoke {ColorWidget $colorList [lindex $wForeColor 0] \
		   [lindex $wForeColor 1]} \
      -disable {$widget configure -relief flat } \
      -enable {$widget configure -relief raised } \
      -packFrame:expand no
  Command wBackColor \
      -text "background" \
      -default [list "#0000AA" 0] \
      -setvalue {
	$widget configure -bg [lindex $wBackColor 0] -text "      "} \
      -invoke {ColorWidget $colorList [lindex $wBackColor 0] \
		   [lindex $wBackColor 1]} \
      -disable {$widget configure -relief flat } \
      -enable {$widget configure -relief raised } \
      -packFrame:expand no
  Frame wColF -entries { wColB wForeColor wBackColor } -packFrame:expand no

  Help windowsH \
      "Here you configure the colors and font to use for the active" \
      "window."
  Help wColB \
      "Check this button if you want to change the colors used for the" \
      "active window."
  Help wForeColor \
      "By pressing this button you can specify the foreground color to" \
      "use for the active window."
  Help wBackColor \
      "By pressing this button you can specify the background color to" \
      "use for the active window."
  
  CheckBox wFonB -text "Change the title font"
  Command winFont \
      -default "--adobe-helvetica-*-*-*-*-*-*-*-*-*-*-*-*" \
      -setvalue {buttonSetText $widget $winFont} \
      -invoke {FontWidget $winFont 0} \
      -disable {$widget configure -text "Not set"
	$widget configure -font fixed} \
      -enable {buttonSetText $widget $winFont}
  Frame wFonF -entries { wFonB winFont }

  Help wFonB \
      "Check this button if you want to change the font used for the active" \
      "window."
  Help winFont \
      "By pressing this button you can specify the font to use for the" \
      "active title bar."

  CheckBox tStyleB -text "Change the title style"
  Label tStyleAlignL -text "    Justification" -packFrame:expand no
  Radio tStyleAlign -entries  { left centered right } -default centered
  Frame tStyleAlignF -entries { tStyleAlignL tStyleAlign }
  Label tStyleReliefL -text "    Appearance" -packFrame:expand no
  Radio tStyleRelief -entries { raised flat sunken } -default raised
  Frame tStyleReliefF -entries { tStyleReliefL tStyleRelief }

  Help tStyleB \
      "Check this button if you want to change the font used for the title" \
      "bar text."
  set tStyleAlignHelp "Here you control the alignment of the title bar text."
  Help tStyleAlignL $tStyleAlignHelp
  Help tStyleAlign $tStyleAlignHelp
  set tStyleReliefHelp "Here you control the appearance of the title bar border."
  Help tStyleReliefL $tStyleReliefHelp
  Help tStyleRelief $tStyleReliefHelp

  CheckBox iFonB -text "Change the icon font"
  Command icoFont \
      -default "fixed" \
      -setvalue {buttonSetText $widget $icoFont} \
      -invoke {FontWidget $icoFont 0} \
      -disable {$widget configure -text "Not set"
	$widget configure -font fixed} \
      -enable {buttonSetText $widget $icoFont}
  Frame iFonF -entries { iFonB icoFont }

  Help iFonB \
      "Check this button if you want to change the font used for iconified" \
      "windows."
  Help icoFont \
      "By pressing this button you can specify the font to use for the" \
      "iconified windows."

  Change {
    if {$changeElm == "wColB"} {
      if {$wColB == 1} { Enable wForeColor wBackColor
      } else { Disable wForeColor wBackColor }
    }
    if {$changeElm == "wFonB"} {
      if {$wFonB == 1} { Enable winFont
      } else { Disable winFont }
    }
    if {$changeElm == "tStyleB"} {
      if {$tStyleB == 1} { Enable tStyleAlign tStyleRelief
      } else { Disable tStyleAlign tStyleRelief }
    }
    if {$changeElm == "iFonB"} {
      if {$iFonB == 1} { Enable icoFont
      } else { Disable icoFont }
    }
  }

  Save {
    if {$wColB == 1} {
      print "HilightColor\t[hash2rgb [lindex $wForeColor 0]]\
 [hash2rgb [lindex $wBackColor 0]]"
    }
    if {$wFonB == 1} {print "WindowFont\t$winFont"}
    if {$tStyleB == 1} {
      set justification {LeftJustified Centered RightJustified}
      set appearance {Raised Flat Sunk}
      set result "TitleStyle\t"
      append result "[lindex $justification $tStyleAlign(index)] "
      print $result
      set result "TitleStyle\t-- "
      append result "[lindex $appearance $tStyleRelief(index)]"
    }
    if {$iFonB == 1} {print "IconFont\t$icoFont"}
  }
  #
  ####################################################################
}
