#!/usr/local/bin/wish8.5

###############################################################################
# QuIRC Style editor for version .9.80
# Written by Axe (DawnRazor)
#
# This software is freely available at: www.crown.net/~axe/quedit
# (QuEdit uses the same license agreement as QuIRC - GPL)
# Check here for updates and other notes.
#
# QuIRC is freely available at: http://www.quirc.org
#
# If you come across ANY problems, or have ANY suggestions, please email me at
# axe@crown.net or axe@killinghand.org.  I will answer most all email the
# same day.
#
# Legal stuff! (I scammed this straight from the GPL :)
#    Copyright (C) 2000
#    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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#    (You can find the license at http://www.crown.net/~axe/quedit/license)
#
# BUILD 200101210
###############################################################################


#####################################
###### Save and load functions ######
#####################################

#### Procedure for saving the quedit.tcl file ####
proc proc_save { } {
    if { [ file exists $::env(HOME)/.quirc/themes/quedit.tcl ] } { file copy -force "$::env(HOME)/.quirc/themes/quedit.tcl" "$::env(HOME)/.quirc/themes/quedit.tcl.old" }
    set sty [open $::env(HOME)/.quirc/themes/quedit.tcl "w"]
    foreach var [info vars ::dynamic::t*] {
        if { ![array exists $var] } {
            puts $sty "set $var [string range [list "\x7d[set $var]"] 2 end]"
        } else {
            puts $sty "array set $var {[array get $var]}"
        }
    }
    puts $sty "set whoislocation \[flocation $::whoislocation]"

    foreach var [info vars ::fset::*] {
        set brem [ string length $var ]
        set remo [ string length [list [set $var]]]
        incr remo -2
        set tvar [ string range [list [set $var]] 1 $remo ]
        puts $sty "fset $tvar"
    }
    foreach var [info vars array*] {
        puts $sty $var
    }
   
    close $sty
   
    if { [ file exists $::env(HOME)/.quirc/themes/quedit.tcl.old ] } {
        tk_messageBox -title "Settings saved to quedit.tcl" -message "To load your new theme, load QuIRC, click on Menu, Themes, Choose A Theme, then double-click on quedit.tcl.  Origional settings backed up to quedit.tcl.old"
    } else {
        tk_messageBox -title "Settings saved to quedit.tcl" -message "To load your new theme, load QuIRC, click on Menu, Themes, then Choose A Theme."
    }
}

#### Procedure for saving into a file name of choice ####
proc proc_saveas { } {
	set ::filename ""
	toplevel .saveas
 	wm title .saveas "Save As..."

	label .saveas.text -text "Enter the filename to save as.."
	entry .saveas.name -textvariable ::filename
	button .saveas.butt -text "Save" -command {

		destroy .saveas
		set sty [open $::env(HOME)/.quirc/themes/$::filename "w"]
		foreach var [info vars ::dynamic::t*] {
        	if { ![array exists $var] } {
            		puts $sty "set $var [string range [list "\x7d[set $var]"] 2 end]"
        	} else {
            		puts $sty "array set $var {[array get $var]}"
        		}
    		}
	        puts $sty "set whoislocation \[flocation $::whoislocation]"


    		foreach var [info vars ::fset::*] {
        		set brem [ string length $var ]
		        set remo [ string length [list [set $var]]]
		        incr remo -2
		        set tvar [ string range [list [set $var]] 1 $remo ]
		        puts $sty "fset $tvar"
    		}
		foreach var [info vars array*] {
        		puts $sty $var
    		}

	        close $sty
   		tk_messageBox -title "Settings saved." -message "Settings saved to $::filename - To load your new theme, load QuIRC, click on Menu, Themes, then Choose A Theme."
		}
	pack .saveas.text .saveas.name .saveas.butt
}

#### Load from specified file - NO ERROR-CONTROL ####
proc proc_loadfr { } {

	namespace eval ::temp { }
        set ::filename ""
        toplevel .loadfr
        wm title .loadfr "Load From..."
	namespace delete ::fset
	set ::num 0
	namespace eval ::fset { }

        label .loadfr.text -text "Enter full path and name of file to be Loaded from.."
        entry .loadfr.name -textvariable ::filename
        button .loadfr.butt -text "Load" -command {
                destroy .loadfr

    set fh [open $filename]
	while { ![eof $fh] } {
       	 gets $fh theline
          if { [string match "set ::dynamic::t*" $theline]  } {
            uplevel #0 $theline
          } elseif { [string match "fset*" $theline]  } {
            lappend ::temp::entire_fset "$theline"
            set $::num [ incr ::num ]
          } elseif { [string match "set ::default*" $theline]  } {
            uplevel #0 $theline
            set theline "set ::dynamic[string range $theline 4 end]"
            uplevel #0 $theline
          } elseif { [string match "array set*" $theline] } {
            uplevel #0 $theline
          } elseif { [string match "set whoislocation*" $theline] } {
            set endlen [ string length $theline]
	    incr endlen -2
	    set ::whoislocation [string range $theline 29 $endlen]
	  }
        }
      close $fh
      fset_switch
      tk_messageBox -title "Loaded" -message "Loaded settings from $::filename"
    }
    pack .loadfr.text .loadfr.name .loadfr.butt
}

#### Reload out of the default.tcl file ####
proc proc_reload { } {
    set ::num 0
    namespace eval ::temp { }
    namespace eval ::fset { }
    namespace eval ::dynamic { proc_convert }
    tk_messageBox -title "Done" -message "default.tcl reloaded"
}


#### Pull the settings out of the default QuIRC file.  ####
proc proc_convert { } {

    namespace eval ::temp { }
    set fh [open $::env(HOME)/.quirc/themes/default.tcl]
    while { ![eof $fh] } {
	gets $fh theline
	if { [string match "set ::dynamic::t*" $theline]  } {
	    uplevel #0 $theline
	} elseif { [string match "fset*" $theline]  } {
            lappend ::temp::entire_fset "$theline"
            set $::num [ incr ::num ]
	} elseif { [string match "set ::default*" $theline]  } {
	    uplevel #0 $theline
	    set theline "set ::dynamic[string range $theline 4 end]"
	    uplevel #0 $theline
        } elseif { [string match "set whoislocation*" $theline] } {
            set endlen [ string length $theline]
            incr endlen -2
            set ::whoislocation [string range $theline 29 $endlen]
	}
    }
    close $fh
    fset_switch
}


#### Pull the settings out of our previously stored file. ####
proc proc_source { } {
    set ::num 0
    set fh [open $::env(HOME)/.quirc/themes/quedit.tcl]
    while { ![eof $fh] } {
	gets $fh theline
	if { [string match "set ::dynamic::t*" $theline]  } {
	    uplevel #0 $theline
	} elseif { [string match "fset*" $theline]  } {
	    lappend ::temp::entire_fset "$theline"
	    set $::num [ incr ::num ]
	} elseif { [string match "set ::default*" $theline]  } {
	    uplevel #0 $theline
	    set theline "set ::dynamic[string range $theline 4 end]"
	    uplevel #0 $theline
	} elseif { [string match "array set*" $theline] } {
	    uplevel #0 $theline
        } elseif { [string match "set whoislocation*" $theline] } {
            set endlen [ string length $theline]
            incr endlen -2
            set ::whoislocation [string range $theline 29 $endlen]
        }

    }
    close $fh
    fset_switch
}


#### Load quedit.tcl.old file (Part 1) ####
proc proc_relold { } {
    set fileset [ file exists $::env(HOME)/.quirc/themes/quedit.tcl.old ]
    if { $fileset == 0 } {
        tk_messageBox -title "Oops" -message "The quedit.tcl.old file could not be found."
    }

    if { $fileset == 1 } {
        namespace delete ::fset
	set ::num 0
	namespace eval ::temp { }
	namespace eval ::fset { }
        namespace eval ::dynamic { proc_sourceold }
    }
}


#### Load quedit.tcl.old file (Part 2) ####
proc proc_sourceold { } {
    set fh [ open $::env(HOME)/.quirc/themes/quedit.tcl.old ]
    while { ![eof $fh] } {
	gets $fh theline
	if { [string match "set ::dynamic::t*" $theline]  } {
	    uplevel #0 $theline
	} elseif { [string match "fset*" $theline]  } {
            lappend ::temp::entire_fset "$theline"
            set $::num [ incr ::num ]
	} elseif { [string match "set ::default*" $theline]  } {
	    uplevel #0 $theline
	    set theline "set ::dynamic[string range $theline 4 end]"
	    uplevel #0 $theline
	} elseif { [string match "array set*" $theline] } {
	    uplevel #0 $theline
        } elseif { [string match "set whoislocation*" $theline] } {
            set endlen [ string length  $theline]
            incr endlen -2
            set ::whoislocation [string range $theline 29 $endlen]
	}

    }
    close $fh
    fset_switch
    tk_messageBox -title "Loaded" -message "Settings loaded from quedit.tcl.old"
}


#### Load new default.tcl then load quedit.tcl ontop. ####
proc proc_newstyle { } {
    proc_convert
    namespace delete ::fset
    set ::num 0
    namespace eval ::temp { }
    namespace eval ::fset { }
    proc_source
    tk_messageBox -title "Sourced" -message "New default.tcl variables loaded, and quedit.tcl variables sourced on top."
}

#### Reload FSETs from default.tcl ####
proc proc_origfset { } {
	namespace delete ::fset
	set ::num 0
	namespace eval ::temp { }
	namespace eval ::fset { }
	set fh [open $::env(HOME)/.quirc/themes/default.tcl]
	while { ![eof $fh] } {
		gets $fh theline 
		if { [string match "fset*" $theline]  } {
	            lappend ::temp::entire_fset "$theline"
       		    set $::num [ incr ::num ]
		} else { }
	}
	close $fh
	fset_switch 
	tk_messageBox -title "Reloaded" -message "Default FSET's loaded."
}



#### This is a conversion so we can use certain QuIRC variables in setting colors on the frames. ####
proc proc_cov { command vari } {
    eval "$command $::dynamic::theme_color($vari)"
}


#############################
##### Window Procedures #####
#############################

##### Main window procedures - #####

proc proc_main_status { } {
    proc_create
    wm title . "QuIRC Style Editor - Main Status Window"  
    

    #### Create the basic frames ####
    frame .m.ft -relief sunken -bg $::dynamic::theme_buttonbar_background -border 1
    frame .m.fc -relief sunken -bg [ proc_cov { set ::backg } $::dynamic::theme_main_background ]  -border 1
    frame .m.fb -relief sunken -bg $::dynamic::theme_main_entry_background -border 1
    frame .m.fl -relief sunken -bg $::dynamic::theme_windowlist_background  -border 1
    frame .update -relief sunken -bg black

    #### Minor Frames ####
    frame .m.fc.t	-bg [ proc_cov { set ::backg } $dynamic::theme_main_background ]
    frame .m.fl.t  	-bg $::dynamic::theme_windowlist_background
    
    #### Add some buttons and labels ####
    
    button .m.ft.close -text "Close" -fg $::dynamic::theme_button_close_foreground -bg $::dynamic::theme_button_close_background -activeforeground $::dynamic::theme_button_close_activeforeground -activebackground $::dynamic::theme_button_close_activebackground -command { proc_univ_button_close } -highlightcolor black
    button .m.ft.condis -text "Start A New Server" -fg $::dynamic::theme_button_condis_foreground -bg $::dynamic::theme_button_condis_background -activeforeground $::dynamic::theme_button_condis_activeforeground -activebackground $::dynamic::theme_button_condis_activebackground -command { proc_univ_button_condis } 
    button .m.ft.menu -text "Menu" -fg $::dynamic::theme_button_menu_foreground -bg $::dynamic::theme_button_menu_background -activeforeground $::dynamic::theme_button_menu_activeforeground -activebackground $::dynamic::theme_button_menu_activebackground -command { proc_univ_button_menu }
    button .m.ft.lag -text "Server lag:  0.17" -fg $::dynamic::theme_lag_foreground -bg $::dynamic::theme_lag_background -relief flat -command { proc_univ_lag } -activebackground $::dynamic::theme_lag_background -activeforeground white

    label .m.fl.t.1 -text "Main Status" -bg $::dynamic::theme_windowlist_selectbackground -fg $::dynamic::theme_windowlist_selectforeground -font $::dynamic::theme_windowlist_font 
    label .m.fl.t.2 -text "hebron.dal.net" -bg $::dynamic::theme_windowlist_background -fg $::dynamic::theme_windowlist_foreground -font $::dynamic::theme_windowlist_font 
    label .m.fl.t.3 -text "#Active_Chan" -bg $::dynamic::theme_windowlist_activebackground -fg $::dynamic::theme_windowlist_activeforeground -font $::dynamic::theme_windowlist_font
    label .m.fl.t.4 -text "#Normal_Chan" -bg $::dynamic::theme_windowlist_background -fg $::dynamic::theme_windowlist_foreground -font $::dynamic::theme_windowlist_font
    button .m.fl.chan -text "Change" -bg $::dynamic::theme_windowlist_background -fg $::dynamic::theme_windowlist_foreground -command { proc_univ_winlist } -relief flat -width 3
    
    label .m.fc.t.text -text "Oi! I've been disconnected!" -fg [ proc_cov { set ::foreg } $::dynamic::theme_main_foreground ] -bg [ proc_cov { set ::backg } $::dynamic::theme_main_background ] -font $::dynamic::theme_main_font_normal
    button .m.fc.t.btext -text "Change" -command { proc_main_fc } -width 3 -relief flat -bg [ proc_cov { set ::backg } $::dynamic::theme_main_background ] -fg [ proc_cov { set ::foreg } $::dynamic::theme_main_foreground ]
   
    entry .m.fb.entry -fg $::dynamic::theme_main_entry_foreground -bg $::dynamic::theme_main_entry_background -font $::dynamic::theme_main_entry_font -insertbackground $::dynamic::theme_main_entry_insertbackground -relief flat -width 60
    button .m.fb.bentry -text "Change" -command { proc_main_fb } -relief flat -bg $::dynamic::theme_main_entry_background  -fg $::dynamic::theme_main_entry_foreground -width 3
    
    button .update.up -text "Update settings for preview" -command { proc_main_update }
    
    #### Pack everything ####
    
    pack .m.ft -side top -fill x
    pack .m.ft.close .m.ft.condis .m.ft.menu -side left
    pack .m.ft.lag -side right
    
    pack .m.fl -side left -fill y
    pack .m.fl.t  -side top
    grid .m.fl.t.1 -column 1 -row 1 
    grid .m.fl.t.2 -column 1 -row 2 
    grid .m.fl.t.3 -column 1 -row 3
    grid .m.fl.t.4 -column 1 -row 4
    pack .m.fl.chan -side bottom
    
    pack .m.fc -anchor center  -fill both -expand 1
    pack .m.fc.t -side bottom -fill both
    pack .m.fc.t.text -side left
    pack .m.fc.t.btext -side right
    
    pack .m.fb -fill x
    pack .m.fb.entry -side left -fill x
    pack .m.fb.bentry -side right

    pack .m -fill both -expand 1
    
    pack .update.up 
    pack .update -fill x

    
    #### Mini-procedures ####
    
    proc proc_main_fc { } {
	
	toplevel .bc
	wm title .bc "Main status window"
	label .bc.0 -text "Background color:"
	tk_optionMenu .bc.1 ::dynamic::theme_main_background 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
	button .bc.2 -text "Choose" -command { color_chooser { set ::dynamic::theme_main_background } }
       	label .bc.3 -text "Foreground color:"
	tk_optionMenu .bc.4 ::dynamic::theme_main_foreground 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
	button .bc.5 -text "Choose" -command { color_chooser { set ::dynamic::theme_main_foreground } }
       	label .bc.6 -text "Selected Background color:"
	button .bc.7 -textvariable ::dynamic::theme_main_selectbackground -command { color_chooser { proc_ccov ::dynamic::theme_main_selectbackground } }
	button .bc.8 -text "Choose" -command { chooseColor_check ::dynamic::theme_main_selectbackground }
       	label .bc.9 -text "Selected Foreground color:"
	button .bc.10 -textvariable ::dynamic::theme_main_selectforeground -command { color_chooser { proc_ccov ::dynamic::theme_main_selectforeground } }
	button .bc.11 -text "Choose" -command { chooseColor_check ::dynamic::theme_main_selectforeground }
       	label .bc.12 -text "Selected Borderwidth:"
	entry .bc.13 -width 5 -textvariable ::dynamic::theme_main_selectborderwidth
	label .bc.14 -text ""
        label .bc.15 -text "Font (Normal):"
        entry .bc.16 -width 30 -textvariable ::dynamic::theme_main_font_normal
        button .bc.17 -text "Choose" -command { proc_fontchoose ::dynamic::theme_main_font_normal $::dynamic::theme_main_font_normal }
        label .bc.18 -text "Font (Bold):"
        entry .bc.19 -width 30 -textvariable ::dynamic::theme_main_font_bold
        button .bc.20 -text "Choose" -command { proc_fontchoose ::dynamic::theme_main_font_bold $::dynamic::theme_main_font_bold }
	button .bc.c -text "Close this window" -command { destroy .bc }

    for { set n 0 } { $n < 21 } { incr n } {
        grid .bc.$n -column [expr $n%3+1] -row [expr $n/3+1]
        }
	grid .bc.c -column 1 -row 8

    }
    proc proc_main_fb { } {
	
	toplevel .bc
	wm title .bc "Main status entry window"
       	label .bc.0 -text "Entrybox background color:"
	button .bc.1 -textvariable ::dynamic::theme_main_entry_background -command { color_chooser { proc_ccov ::dynamic::theme_main_entry_background } }
	button .bc.2 -text "Choose" -command { chooseColor_check ::dynamic::theme_main_entry_background }
       	label .bc.3 -text "Entrybox foreground color:"
	button .bc.4 -textvariable ::dynamic::theme_main_entry_foreground -command { color_chooser { proc_ccov ::dynamic::theme_main_entry_foreground } }
	button .bc.5 -text "Choose" -command { chooseColor_check ::dynamic::theme_main_entry_foreground }
       	label .bc.6 -text "Entry insert background:"
	button .bc.7 -textvariable ::dynamic::theme_main_entry_insertbackground -command { color_chooser { proc_ccov ::dynamic::theme_main_entry_insertbackground } }
	button .bc.8 -text "Choose" -command { chooseColor_check ::dynamic::theme_main_entry_insertbackground }
        label .bc.9 -text "Font:"
        entry .bc.10 -width 30 -textvariable ::dynamic::theme_main_entry_font
        button .bc.11 -text "Choose" -command { proc_fontchoose ::dynamic::theme_main_entry_font $::dynamic::theme_main_entry_font }
	button .bc.c -text "Close this window" -command { destroy .bc }

    for { set n 0 } { $n < 12 } { incr n } {
        grid .bc.$n -column [expr $n%3+1] -row [expr $n/3+1]
        }
	grid .bc.c -column 1 -row 5

    }
    
    proc proc_main_update { } { proc_main_status }
}

proc proc_server { } {
    proc_create
    wm title . "QuIRC Style Editor - Server Window"
    
    #### Create the basic frames ####

    frame .m.ft -relief sunken -bg $::dynamic::theme_buttonbar_background  -border 1
    frame .m.fl -relief sunken -bg $::dynamic::theme_windowlist_background -border 1
    frame .m.fc -relief sunken -bg [ proc_cov { set ::backg } $::dynamic::theme_status_background ] -border 1
    frame .m.fb -relief sunken -bg $::dynamic::theme_status_entry_background -border 1
    frame .update -relief sunken -bg black
    
    #### Minor Frames ####

    frame .m.fc.t 	-bg [ proc_cov { set ::backg } $dynamic::theme_status_background ]
    frame .m.fl.t	-bg $::dynamic::theme_windowlist_background 

    #### Add some buttons and labels ####

    proc_close_disconnect_menu

    label .m.fl.t.1 -text "Main Status" -bg $::dynamic::theme_windowlist_background -fg $::dynamic::theme_windowlist_foreground -font $::dynamic::theme_windowlist_font
    label .m.fl.t.2 -text "hebron.dal.net" -bg $::dynamic::theme_windowlist_selectbackground -fg $::dynamic::theme_windowlist_selectforeground -font $::dynamic::theme_windowlist_font
    label .m.fl.t.3 -text "#Active_Chan" -bg $::dynamic::theme_windowlist_activebackground -fg $::dynamic::theme_windowlist_activeforeground -font $::dynamic::theme_windowlist_font
    label .m.fl.t.4 -text "#Normal_Chan" -bg $::dynamic::theme_windowlist_background -fg $::dynamic::theme_windowlist_foreground -font $::dynamic::theme_windowlist_font
    button .m.fl.chan -text "Change" -command { proc_univ_winlist } -relief flat -bg $::dynamic::theme_windowlist_background -fg $::dynamic::theme_windowlist_foreground -width 3
    
    label .m.fc.t.text -text "STATUS connected" -fg [ proc_cov { set ::foreg } $::dynamic::theme_status_foreground ] -bg [ proc_cov { set ::backg } $::dynamic::theme_status_background ] -font $::dynamic::theme_status_font_normal
    button .m.fc.t.btext -text "Change" -command { proc_status_fc } -relief flat -bg [ proc_cov { set ::backg } $::dynamic::theme_status_background ] -fg [ proc_cov { set ::foreg } $::dynamic::theme_status_foreground ] -width 3
    
    entry .m.fb.entry -fg $::dynamic::theme_status_entry_foreground -bg $::dynamic::theme_status_entry_background -font $::dynamic::theme_status_entry_font -insertbackground $::dynamic::theme_status_entry_insertbackground  -width 60 -relief flat
    button .m.fb.bentry -text "Change" -command { proc_status_fb } -relief flat -bg $::dynamic::theme_status_entry_background  -fg $::dynamic::theme_status_entry_foreground -width 3

    
    
    button .update.up -text "Update settings for preview" -command { proc_server_update }
    
    #### Pack everything ####
    
    pack .m.ft -side top -fill x
    pack .m.ft.close .m.ft.condis .m.ft.menu -side left
    pack .m.ft.lag -side right
    
    pack .m.fl -side left -fill y
    pack .m.fl.t -side top	
    grid .m.fl.t.1 -column 1 -row 1 
    grid .m.fl.t.2 -column 1 -row 2
    grid .m.fl.t.3 -column 1 -row 3
    grid .m.fl.t.4 -column 1 -row 4
    pack .m.fl.chan -side bottom
    
    pack .m.fc -anchor center -fill both -expand 1
    pack .m.fc.t -side bottom -fill x
    pack .m.fc.t.text -side left
    pack .m.fc.t.btext -side right
    
    pack .m.fb -side bottom -fill x
    pack .m.fb.entry -side left
    pack .m.fb.bentry -side right
    
    pack .m -fill both -expand 1
    
    pack .update.up
    pack .update -fill x
    
    #### Mini procedures ####
    
    proc proc_status_fc { } {
        toplevel .bc
        wm title .bc "Server status window"
	
	label .bc.0 -text "Background color:"
	tk_optionMenu .bc.1 ::dynamic::theme_status_background 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
	button .bc.2 -text "Choose" -command { color_chooser {  set ::dynamic::theme_status_background } }
        label .bc.3 -text "Foreground color:"
	tk_optionMenu .bc.4 ::dynamic::theme_status_foreground 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
	button .bc.5 -text "Choose" -command { color_chooser {  set ::dynamic::theme_status_foreground } }
        label .bc.6 -text "Select Background:"
	button .bc.7 -textvariable ::dynamic::theme_status_selectbackground -command { color_chooser { proc_ccov ::dynamic::theme_status_selectbackground } }
	button .bc.8 -text "Choose" -command { chooseColor_check ::dynamic::theme_status_selectbackground }
        label .bc.9 -text "Select Foreground:"
	button .bc.10 -textvariable ::dynamic::theme_status_selectforeground -command { color_chooser { proc_ccov ::dynamic::theme_status_selectforeground } }
	button .bc.11 -text "Choose" -command { chooseColor_check ::dynamic::theme_status_selectforeground }
        label .bc.12 -text "Selected Borderwidth:"
	entry .bc.13 -width 5 -textvariable ::dynamic::theme_status_selectborderwidth
	label .bc.14 -text ""
        label .bc.15 -text "Font (Normal):"
        entry .bc.16 -width 30 -textvariable ::dynamic::theme_status_font_normal
        button .bc.17 -text "Choose" -command { proc_fontchoose ::dynamic::theme_status_font_normal $::dynamic::theme_status_font_normal }
        label .bc.18 -text "Font (Bold):"
        entry .bc.19 -width 30 -textvariable ::dynamic::theme_status_font_bold
        button .bc.20 -text "Choose" -command { proc_fontchoose ::dynamic::theme_status_font_bold $::dynamic::theme_status_font_bold }
        button .bc.c -text "Close this window" -command { destroy .bc }

    for { set n 0 } { $n < 21 } { incr n } {
        grid .bc.$n -column [expr $n%3+1] -row [expr $n/3+1]
        }
        grid .bc.c -column 1 -row 10
	
    }
    
    proc proc_status_fb { } {
        toplevel .bc
        wm title .bc "Server status entry window"
        label .bc.0 -text "Entrybox Background:"
	button .bc.1 -textvariable ::dynamic::theme_status_entry_background -command { color_chooser { proc_ccov ::dynamic::theme_status_entry_background } }
	button .bc.2 -text "Choose" -command { chooseColor_check ::dynamic::theme_status_entry_background }
        label .bc.3 -text "Entrybox Foreground:"
	button .bc.4 -textvariable ::dynamic::theme_status_entry_foreground -command { color_chooser { proc_ccov ::dynamic::theme_status_entry_foreground } }
	button .bc.5 -text "Choose" -command { chooseColor_check ::dynamic::theme_status_entry_foreground }
        label .bc.6 -text "Entry Insert Background:"
	button .bc.7 -textvariable ::dynamic::theme_status_entry_insertbackground -command { color_chooser { proc_ccov ::dynamic::theme_status_entry_insertbackground } }
	button .bc.8 -text "Choose" -command { chooseColor_check ::dynamic::theme_status_entry_insertbackground }
        label .bc.9 -text "Font:"
        entry .bc.10 -width 30 -textvariable ::dynamic::theme_status_entry_font
        button .bc.11 -text "Choose" -command { proc_fontchoose ::dynamic::theme_status_entry_font $::dynamic::theme_status_entry_font }
	button .bc.c -text "Close this window" -command { destroy .bc } 

    for { set n 0 } { $n < 12 } { incr n } {
        grid .bc.$n -column [expr $n%3+1] -row [expr $n/3+1]
        }
        grid .bc.c -column 1 -row 7
    }
    
    proc proc_server_update { } { proc_server }
    
}

proc proc_channel { } {
    proc_create
    wm title . "QuIRC Style Editor - Channel Window"
    
    #### Create the basic frames ####
    frame .m.ft -relief sunken -bg $::dynamic::theme_buttonbar_background -border 1
    frame .m.fl -relief sunken -bg $::dynamic::theme_windowlist_background -border 1
    frame .m.fc -relief sunken -bg [ proc_cov { set ::backg } $::dynamic::theme_channel_background ] -border 1
    frame .m.fr -relief sunken -bg $::dynamic::theme_nicklist_background -border 1
    frame .m.fb -relief sunken -bg $::dynamic::theme_channel_entry_background -border 1
    frame .update -relief sunken -bg black
    
    #### Minor Frames ####
    frame .m.fc.t   -bg [ proc_cov { set ::backg } $dynamic::theme_channel_background ]
    frame .m.fl.t   -bg $::dynamic::theme_windowlist_background
    frame .m.fr.t   -bg $::dynamic::theme_nicklist_background
    
    #### Add some buttons and labels ####
    
    proc_close_disconnect_menu
    
    label .m.fl.t.1 -text "Main Status" -bg $::dynamic::theme_windowlist_background -fg $::dynamic::theme_windowlist_foreground -font $::dynamic::theme_windowlist_font
    label .m.fl.t.2 -text "hebron.dal.net" -bg $::dynamic::theme_windowlist_background -fg $::dynamic::theme_windowlist_foreground -font $::dynamic::theme_windowlist_font
    label .m.fl.t.3 -text "#Active_Chan" -bg $::dynamic::theme_windowlist_activebackground -fg $::dynamic::theme_windowlist_activeforeground -font $::dynamic::theme_windowlist_font
    label .m.fl.t.4 -text "#Normal_Chan" -bg $::dynamic::theme_windowlist_selectbackground -fg $::dynamic::theme_windowlist_selectforeground -font $::dynamic::theme_windowlist_font
    button .m.fl.chan -text "Change" -command { proc_univ_winlist } -relief flat -bg $::dynamic::theme_windowlist_background -fg $::dynamic::theme_windowlist_foreground -width 3
    
    label .m.fr.t.1 -text "Alfred" -bg $::dynamic::theme_nicklist_background -fg $::dynamic::theme_nicklist_foreground -font $::dynamic::theme_nicklist_font
    label .m.fr.t.2 -text "Bob" -bg $::dynamic::theme_nicklist_background -fg $::dynamic::theme_nicklist_foreground -font $::dynamic::theme_nicklist_font
    label .m.fr.t.3 -text "George" -bg $::dynamic::theme_nicklist_background -fg $::dynamic::theme_nicklist_foreground -font $::dynamic::theme_nicklist_font
    button .m.fr.t.4 -text "Change" -command { proc_univ_nicklist } -relief flat -bg $::dynamic::theme_nicklist_background -fg $::dynamic::theme_nicklist_foreground -width 3
    
    
    label .m.fc.t.text -text "<George> " -fg [ proc_cov { set ::backg } $::dynamic::theme_default_foreground2 ] -bg [ proc_cov { set ::backg } $::dynamic::theme_channel_background ] -font $::dynamic::theme_channel_font_normal
    label .m.fc.t.text1 -text "So Bob, like I was saying." -fg [ proc_cov { set ::foreg } $::dynamic::theme_channel_foreground ] -bg [ proc_cov { set ::backg } $::dynamic::theme_channel_background ] -font $::dynamic::theme_channel_font_normal
    button .m.fc.t.btext -text "Change" -command { proc_channel_fc } -relief flat -bg [ proc_cov { set ::backg } $::dynamic::theme_channel_background ] -fg [ proc_cov { set ::foreg } $::dynamic::theme_channel_foreground ] -width 3
    
    entry .m.fb.entry -fg $::dynamic::theme_channel_entry_foreground -bg $::dynamic::theme_channel_entry_background -font $::dynamic::theme_channel_entry_font -insertbackground $::dynamic::theme_channel_entry_insertbackground  -width 53 -relief flat
    button .m.fb.bentry -text "Change" -command { proc_channel_fb } -relief flat -bg $::dynamic::theme_channel_entry_background  -fg $::dynamic::theme_channel_entry_foreground -width 3

    button .update.up -text "Update settings for preview" -command { proc_channel_update }
    
    #### Pack everything ####	
    pack .m.ft -side top -fill x
    pack .m.ft.close .m.ft.condis .m.ft.menu -side left
    pack .m.ft.lag -side right
    
    pack .m.fl -side left -fill y
    pack .m.fl.t -side top
    grid .m.fl.t.1 -column 1 -row 1
    grid .m.fl.t.2 -column 1 -row 2
    grid .m.fl.t.3 -column 1 -row 3
    grid .m.fl.t.4 -column 1 -row 4
    pack .m.fl.chan -side bottom
    
    pack .m.fr -side right -fill y
    pack .m.fr.t -side top
    grid .m.fr.t.1 -column 1 -row 1
    grid .m.fr.t.2 -column 1 -row 2
    grid .m.fr.t.3 -column 1 -row 3
    grid .m.fr.t.4 -column 1 -row 4
    
    pack .m.fc -anchor center -fill both -expand 1
    pack .m.fc.t -side bottom -fill x
    pack .m.fc.t.text .m.fc.t.text1 -side left
    pack .m.fc.t.btext -side right
    
    pack .m.fb -side bottom -fill x
    pack .m.fb.entry -side left
    pack .m.fb.bentry -side right
    
    pack .m -fill both -expand 1
    
    pack .update.up
    pack .update -fill x
    
    #### Mini procedures ####
    
    proc proc_channel_fc { } {
        toplevel .bc
        wm title .bc "Channel window"
	
       	label .bc.0 -text "Background color:"
	tk_optionMenu .bc.1 ::dynamic::theme_channel_background 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
	button .bc.2 -text "Choose" -command { color_chooser { set ::dynamic::theme_channel_background } }
       	label .bc.3 -text "Foreground color:"
	tk_optionMenu .bc.4 ::dynamic::theme_channel_foreground 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
	button .bc.5 -text "Choose" -command { color_chooser { set ::dynamic::theme_channel_foreground } }
       	label .bc.6 -text "Selected Background color:"
	button .bc.7 -textvariable ::dynamic::theme_channel_selectbackground -command { color_chooser { proc_ccov ::dynamic::theme_channel_selectbackground } }
	button .bc.8 -text "Choose" -command { chooseColor_check ::dynamic::theme_channel_selectbackground }
       	label .bc.9 -text "Selected Foreground color:"
	button .bc.10 -textvariable ::dynamic::theme_channel_selectforeground -command { color_chooser { proc_ccov ::dynamic::theme_channel_selectforeground } }
	button .bc.11 -text "Choose" -command { chooseColor_check ::dynamic::theme_channel_selectforeground }
       	label .bc.12 -text "Selected Borderwidth:"
	entry .bc.13 -width 5 -textvariable ::dynamic::theme_channel_selectborderwidth
	label .bc.14 -text ""
        label .bc.15 -text "Font (Normal):"
        entry .bc.16 -width 30 -textvariable ::dynamic::theme_channel_font_normal
        button .bc.17 -text "Choose" -command { proc_fontchoose ::dynamic::theme_channel_font_normal $::dynamic::theme_channel_font_normal }
        label .bc.18 -text "Font (Bold):"
        entry .bc.19 -width 30 -textvariable ::dynamic::theme_channel_font_bold
        button .bc.20 -text "Choose" -command { proc_fontchoose ::dynamic::theme_channel_font_bold $::dynamic::theme_channel_font_bold }
        button .bc.c -text "Close this window" -command { destroy .bc }

    for { set n 0 } { $n < 21 } { incr n } {
        grid .bc.$n -column [expr $n%3+1] -row [expr $n/3+1]
        }
        grid .bc.c -column 1 -row 8
    }
    
    proc proc_channel_fb { } {
        toplevel .bc
        wm title .bc "Channel entry window"
	
	label .bc.0 -text "Entrybox background color:"
	button .bc.1 -textvariable ::dynamic::theme_channel_entry_background -command { color_chooser { proc_ccov ::dynamic::theme_channel_entry_background } }
	button .bc.2 -text "Choose" -command { chooseColor_check ::dynamic::theme_channel_entry_background }
       	label .bc.3 -text "Entrybox foreground color:"
	button .bc.4 -textvariable ::dynamic::theme_channel_entry_foreground -command { color_chooser { proc_ccov ::dynamic::theme_channel_entry_foreground } }
	button .bc.5 -text "Choose" -command { chooseColor_check ::dynamic::theme_channel_entry_foreground }
       	label .bc.6 -text "Entry insert background:"
	button .bc.7 -textvariable ::dynamic::theme_channel_entry_insertbackground -command { color_chooser { proc_ccov ::dynamic::theme_channel_entry_insertbackground } }
	button .bc.8 -text "Choose" -command { chooseColor_check ::dynamic::theme_channel_entry_insertbackground }
        label .bc.9 -text "Font:"
        entry .bc.10 -width 30 -textvariable ::dynamic::theme_channel_entry_font
        button .bc.11 -text "Choose" -command { proc_fontchoose ::dynamic::theme_channel_entry_font $::dynamic::theme_channel_entry_font }
        button .bc.c -text "Close this window" -command { destroy .bc }

    for { set n 0 } { $n < 12 } { incr n } {
        grid .bc.$n -column [expr $n%3+1] -row [expr $n/3+1]
        }
        grid .bc.c -column 1 -row 7
	
	
    }
    
    proc proc_channel_update { } { proc_channel }
}

proc proc_query { } {
    proc_create
    wm title . "QuIRC Style Editor - Query Window"
    
    #### Create the basic frames ####
    frame .m.ft -relief sunken -bg $::dynamic::theme_buttonbar_background -border 1
    frame .m.fl -relief sunken -bg $::dynamic::theme_windowlist_background -border 1
    frame .m.fc -relief sunken -bg [ proc_cov { set ::backg } $::dynamic::theme_query_background ] -border 1
    frame .m.fb -relief sunken -bg $::dynamic::theme_query_entry_background -border 1
    frame .update -relief sunken -bg black
    
    #### Minor Frames ####
    frame .m.fc.t   -bg [ proc_cov { set ::backg } $dynamic::theme_query_background ]
    frame .m.fl.t   -bg $::dynamic::theme_windowlist_background
    
    #### Add some buttons and labels ####
    
    proc_close_disconnect_menu
    
    label .m.fl.t.1 -text "Main Status" -bg $::dynamic::theme_windowlist_background -fg $::dynamic::theme_windowlist_foreground -font $::dynamic::theme_windowlist_font
    label .m.fl.t.2 -text "hebron.dal.net" -bg $::dynamic::theme_windowlist_background -fg $::dynamic::theme_windowlist_foreground -font $::dynamic::theme_windowlist_font
    label .m.fl.t.3 -text "#Active_Chan" -bg $::dynamic::theme_windowlist_activebackground -fg $::dynamic::theme_windowlist_activeforeground -font $::dynamic::theme_windowlist_font
    label .m.fl.t.4 -text "#Normal_Chan" -bg $::dynamic::theme_windowlist_background -fg $::dynamic::theme_windowlist_foreground -font $::dynamic::theme_windowlist_font
    label .m.fl.t.5 -text "Alfred" -bg $::dynamic::theme_windowlist_selectbackground -fg $::dynamic::theme_windowlist_selectforeground -font $::dynamic::theme_windowlist_font
    button .m.fl.chan -text "Change" -command { proc_univ_winlist } -relief flat -bg $::dynamic::theme_windowlist_background -fg $::dynamic::theme_windowlist_foreground -width 3
    
    label .m.fc.t.text -text "<Alfred> " -fg [ proc_cov { set ::backg } $::dynamic::theme_default_foreground2 ] -bg [ proc_cov { set ::backg } $::dynamic::theme_query_background ] -font $::dynamic::theme_query_font_normal
    label .m.fc.t.text1 -text "Is George buggin the crap outa you, too?" -fg [ proc_cov { set ::foreg } $::dynamic::theme_query_foreground ] -bg [ proc_cov { set ::backg } $::dynamic::theme_query_background ] -font $::dynamic::theme_query_font_normal
    button .m.fc.t.btext -text "Change" -command { proc_query_fc } -relief flat -bg [ proc_cov { set ::backg } $::dynamic::theme_query_background ] -fg [ proc_cov { set ::foreg } $::dynamic::theme_query_foreground ] -width 3
    
    entry .m.fb.entry -fg $::dynamic::theme_query_entry_foreground -bg $::dynamic::theme_query_entry_background -font $::dynamic::theme_query_entry_font -insertbackground $::dynamic::theme_query_entry_insertbackground  -width 60  -relief flat
    button .m.fb.bentry -text "Change" -command { proc_query_fb } -width 3 -relief flat -bg $::dynamic::theme_query_entry_background  -fg $::dynamic::theme_query_entry_foreground -width 3

    
    button .update.up -text "Update settings for preview" -command { proc_query_update }
    
    #### Pack everything ####
    
    pack .m.ft -side top -fill x
    pack .m.ft.close .m.ft.condis .m.ft.menu -side left
    pack .m.ft.lag -side right
    
    pack .m.fl -side left -fill y
    pack .m.fl.t -side top
    grid .m.fl.t.1 -column 1 -row 1
    grid .m.fl.t.2 -column 1 -row 2
    grid .m.fl.t.3 -column 1 -row 3
    grid .m.fl.t.4 -column 1 -row 4
    grid .m.fl.t.5 -column 1 -row 5
    pack .m.fl.chan -side bottom
    
    pack .m.fc -anchor center -fill both -expand 1
    pack .m.fc.t -side bottom -fill x
    pack .m.fc.t.text .m.fc.t.text1 -side left
    pack .m.fc.t.btext -side right
    
    pack .m.fb -side bottom -fill x
    pack .m.fb.entry -side left
    pack .m.fb.bentry -side right
    
    pack .m -fill both -expand 1
    
    pack .update.up
    pack .update -fill x
    
    #### Mini procedures ####
    
    proc proc_query_fc { } {
	toplevel .bc
        wm title .bc "Query window"
	
	label .bc.0 -text "Background color:"
	tk_optionMenu .bc.1 ::dynamic::theme_query_background 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
	button .bc.2 -text "Choose" -command { color_chooser { set ::dynamic::theme_query_background } }
        label .bc.3 -text "Foreground color:"
	tk_optionMenu .bc.4 ::dynamic::theme_query_foreground 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
	button .bc.5 -text "Choose" -command { color_chooser { set ::dynamic::theme_query_foreground } }
        label .bc.6 -text "Selected Background color:"
	button .bc.7 -textvariable ::dynamic::theme_query_selectbackground -command { color_chooser { proc_ccov ::dynamic::theme_query_selectbackground } }
	button .bc.8 -text "Choose" -command { chooseColor_check ::dynamic::theme_query_selectbackground }
        label .bc.9 -text "Selected Foreground color:"
	button .bc.10 -textvariable ::dynamic::theme_query_selectforeground -command { color_chooser { proc_ccov ::dynamic::theme_query_selectforeground } }
	button .bc.11 -text "Choose" -command { chooseColor_check ::dynamic::theme_query_selectforeground }
        label .bc.12 -text "Selected Borderwidth:"
	entry .bc.13 -width 5 -textvariable ::dynamic::theme_query_selectborderwidth
	label .bc.14 -text ""
        label .bc.15 -text "Font (Normal):"
        entry .bc.16 -width 30 -textvariable ::dynamic::theme_query_font_normal
        button .bc.17 -text "Choose" -command { proc_fontchoose ::dynamic::theme_query_font_normal $::dynamic::theme_query_font_normal }
        label .bc.18 -text "Font (Bold):"
        entry .bc.19 -width 30 -textvariable ::dynamic::theme_query_font_bold
        button .bc.20 -text "Choose" -command { proc_fontchoose ::dynamic::theme_query_font_bold $::dynamic::theme_query_font_bold }
        button .bc.c -text "Close this window" -command { destroy .bc }

    for { set n 0 } { $n < 21 } { incr n } {
        grid .bc.$n -column [expr $n%3+1] -row [expr $n/3+1]
        }
        grid .bc.c -column 1 -row 8
    }
    
    proc proc_query_fb { } {
        toplevel .bc
        wm title .bc "Query window"
	
        label .bc.0 -text "Entrybox background color:"
	button .bc.1 -textvariable ::dynamic::theme_query_entry_background -command { color_chooser { proc_ccov ::dynamic::theme_query_entry_background } }
	button .bc.2 -text "Choose" -command { chooseColor_check ::dynamic::theme_query_entry_background }
        label .bc.3 -text "Entrybox foreground color:"
	button .bc.4 -textvariable ::dynamic::theme_query_entry_foreground -command { color_chooser { proc_ccov ::dynamic::theme_query_entry_foreground } }
	button .bc.5 -text "Choose" -command { chooseColor_check ::dynamic::theme_query_entry_foreground }
        label .bc.6 -text "Entry insert background:"
	button .bc.7 -textvariable ::dynamic::theme_query_entry_insertbackground -command { color_chooser { proc_ccov ::dynamic::theme_query_entry_insertbackground } }
	button .bc.8 -text "Choose" -command { chooseColor_check ::dynamic::theme_query_entry_insertbackground }
        label .bc.9 -text "Font:"
        entry .bc.10 -width 30 -textvariable ::dynamic::theme_query_entry_font
        button .bc.11 -text "Choose" -command { proc_fontchoose ::dynamic::theme_query_entry_font $::dynamic::theme_query_entry_font }
        button .bc.c -text "Close this window" -command { destroy .bc }

    for { set n 0 } { $n < 12 } { incr n } {
        grid .bc.$n -column [expr $n%3+1] -row [expr $n/3+1]
        }
        grid .bc.c -column 1 -row 5
    }
    
    proc proc_query_update { } { proc_query }
    
}

proc proc_file { } {
    proc_create
    wm title . "QuIRC Style Editor - DCC File Window"
    
    #### Create the basic frames ####
    frame .m.ft -relief sunken -bg $::dynamic::theme_buttonbar_background -border 1
    frame .m.fl -relief sunken -bg $::dynamic::theme_windowlist_background -border 1
    frame .m.fc -relief sunken -bg [ proc_cov { set ::backg } $::dynamic::theme_files_background ] -border 1
    frame .m.fb -relief sunken -bg $::dynamic::theme_files_entry_background -border 1
    frame .update -relief sunken -bg black
    
    #### Minor Frames ####
    frame .m.fc.t   -bg [ proc_cov { set ::backg } $::dynamic::theme_files_background ]
    frame .m.fc.b   -bg $::dynamic::theme_filelist_background 
    frame .m.fc.b.t -bg $::dynamic::theme_filelist_background 
    frame .m.fl.t   -bg $::dynamic::theme_windowlist_background
    
    #### Add some buttons and labels ####
    
    proc_close_disconnect_menu

    label .m.fl.t.1 -text "Main Status" -bg $::dynamic::theme_windowlist_background -fg $::dynamic::theme_windowlist_foreground -font $::dynamic::theme_windowlist_font
    label .m.fl.t.2 -text "hebron.dal.net" -bg $::dynamic::theme_windowlist_background -fg $::dynamic::theme_windowlist_foreground -font $::dynamic::theme_windowlist_font
    label .m.fl.t.3 -text "DCC Files" -bg $::dynamic::theme_windowlist_selectbackground -fg $::dynamic::theme_windowlist_selectforeground -font $::dynamic::theme_windowlist_font
    label .m.fl.t.4 -text "#Active_Chan" -bg $::dynamic::theme_windowlist_activebackground -fg $::dynamic::theme_windowlist_activeforeground -font $::dynamic::theme_windowlist_font
    label .m.fl.t.5 -text "#Normal_Chan" -bg $::dynamic::theme_windowlist_background -fg $::dynamic::theme_windowlist_foreground -font $::dynamic::theme_windowlist_font
    button .m.fl.chan -text "Change" -command { proc_univ_winlist } -relief flat -bg $::dynamic::theme_windowlist_background -fg $::dynamic::theme_windowlist_foreground -width 3
    
    label .m.fc.b.t.text -text "\[0] /root/quedit 10% (1650)" -bg  $::dynamic::theme_filelist_background -fg $::dynamic::theme_filelist_foreground -font $::dynamic::theme_files_font_normal
    label .m.fc.b.t.text1 -text " " -bg  $::dynamic::theme_filelist_background -fg $::dynamic::theme_filelist_foreground
    label .m.fc.b.t.text2 -text " " -bg  $::dynamic::theme_filelist_background -fg $::dynamic::theme_filelist_foreground
    button .m.fc.b.t.btest -text "Change" -command { proc_filelist } -relief flat -bg $::dynamic::theme_filelist_background -fg $::dynamic::theme_filelist_foreground -width 3
    
    label .m.fc.t.text -text "DCC connection to Alfred established" -fg [ proc_cov { set ::foreg } $::dynamic::theme_files_foreground ] -bg [ proc_cov { set ::backg } $::dynamic::theme_files_background ] -font $::dynamic::theme_files_font_normal
    button .m.fc.t.btext -text "Change" -command { proc_files_fc } -relief flat -bg [ proc_cov { set ::backg } $::dynamic::theme_files_background ] -fg [ proc_cov { set ::foreg } $::dynamic::theme_files_foreground ] -width 3
    
    entry .m.fb.entry -fg $::dynamic::theme_files_entry_foreground -bg $::dynamic::theme_files_entry_background -font $::dynamic::theme_files_entry_font -insertbackground $::dynamic::theme_files_entry_insertbackground  -width 60  -relief flat
    button .m.fb.bentry -text "Change" -command { proc_files_fb } -width 3 -relief flat -bg $::dynamic::theme_files_entry_background  -fg $::dynamic::theme_files_entry_foreground -width 3

    button .update.up -text "Update settings for preview" -command { proc_files_update }
    
    #### Pack everything ####
    
    pack .m.ft -side top -fill x
    pack .m.ft.close .m.ft.condis .m.ft.menu -side left
    pack .m.ft.lag -side right
    
    pack .m.fl -side left -fill y
    pack .m.fl.t -side top 	
    grid .m.fl.t.1 -column 1 -row 1
    grid .m.fl.t.2 -column 1 -row 2
    grid .m.fl.t.3 -column 1 -row 3
    grid .m.fl.t.4 -column 1 -row 4
    grid .m.fl.t.5 -column 1 -row 5
    pack .m.fl.chan -side bottom
    
    pack .m.fc -anchor center -fill both -expand 1
    pack .m.fc.b -side top -fill x
    pack .m.fc.b.t -side top -fill x 
    pack .m.fc.b.t.text -side left
    pack .m.fc.b.t.btest -side right
    pack .m.fc.b.t.text1 
    pack .m.fc.b.t.text2 
    
    pack .m.fc.t -side bottom -fill x
    pack .m.fc.t.text -side left
    pack .m.fc.t.btext -side right
    
    pack .m.fb -side bottom -fill x
    pack .m.fb.entry -side left
    pack .m.fb.bentry -side right
    
    pack .m -fill both -expand 1
    
    pack .update.up
    pack .update -fill x
    
    #### Mini procedures ####
    
    proc proc_filelist { } {
	
	toplevel .bc
	wm title .bc "Filelist frame" 
	
        label .bc.0 -text "File DCC background color:"
	button .bc.1 -textvariable ::dynamic::theme_filelist_background -command { color_chooser { proc_ccov ::dynamic::theme_filelist_background } }
	button .bc.2 -text "Choose" -command { chooseColor_check ::dynamic::theme_filelist_background }
        label .bc.3 -text "File DCC foreground color:"
	button .bc.4 -textvariable ::dynamic::theme_filelist_foreground  -command { color_chooser { proc_ccov ::dynamic::theme_filelist_foreground } }
	button .bc.5 -text "Choose" -command { chooseColor_check ::dynamic::theme_filelist_foreground }
        label .bc.6 -text "Font:"
        entry .bc.7 -width 30 -textvariable ::dynamic::theme_filelist_font
        button .bc.8 -text "Choose" -command { proc_fontchoose ::dynamic::theme_filelist_font $::dynamic::theme_filelist_font }
        button .bc.c -text "Close this window" -command { destroy .bc }

    for { set n 0 } { $n < 9 } { incr n } {
        grid .bc.$n -column [expr $n%3+1] -row [expr $n/3+1]
        }
        grid .bc.c -column 1 -row 4

    }
    
    proc proc_files_fc { } {
	
	toplevel .bc
	wm title .bc "Files window"
	
        label .bc.0 -text "Background color:"
	tk_optionMenu .bc.1 ::dynamic::theme_files_background 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
	button .bc.2 -text "Choose" -command { color_chooser {  set ::dynamic::theme_files_background } }
        label .bc.3 -text "Foreground color:"
	tk_optionMenu .bc.4 ::dynamic::theme_files_foreground 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
	button .bc.5 -text "Choose" -command { color_chooser {  set ::dynamic::theme_files_foreground } }
        label .bc.6 -text "Selected Background color:"
	button .bc.7 -textvariable ::dynamic::theme_files_selectbackground -command { color_chooser { proc_ccov ::dynamic::theme_files_selectbackground } }
	button .bc.8 -text "Choose" -command { chooseColor_check ::dynamic::theme_files_selectbackground }
        label .bc.9 -text "Selected Foreground color:"
	button .bc.10 -textvariable ::dynamic::theme_files_selectforeground -command { color_chooser { proc_ccov ::dynamic::theme_files_selectforeground } }
	button .bc.11 -text "Choose" -command { chooseColor_check ::dynamic::theme_files_selectforeground }
        label .bc.12 -text "Selected Borderwidth:"
	entry .bc.13 -width 5 -textvariable ::dynamic::theme_files_selectborderwidth
	label .bc.14 -text ""
        label .bc.15 -text "Font (Normal):"
        entry .bc.16 -width 30 -textvariable ::dynamic::theme_files_font_normal
        button .bc.17 -text "Choose" -command { proc_fontchoose ::dynamic::theme_files_font_normal $::dynamic::theme_files_font_normal }
        label .bc.18 -text "Font (Bold):"
        entry .bc.19 -width 30 -textvariable ::dynamic::theme_files_font_bold
        button .bc.20 -text "Choose" -command { proc_fontchoose ::dynamic::theme_files_font_bold $::dynamic::theme_files_font_bold }
        button .bc.c -text "Close this window" -command { destroy .bc }

    for { set n 0 } { $n < 21 } { incr n } {
        grid .bc.$n -column [expr $n%3+1] -row [expr $n/3+1]
        }
        grid .bc.c -column 1 -row 8
	
    }
    
    proc proc_files_fb { } {
	
	toplevel .bc
	wm title .bc "Files entry window"
	
        label .bc.0 -text "Entrybox background color:"
	button .bc.1 -textvariable ::dynamic::theme_files_entry_background -command { color_chooser { proc_ccov ::dynamic::theme_files_entry_background } }
	button .bc.2 -text "Choose" -command { chooseColor_check ::dynamic::theme_files_entry_background }
        label .bc.3 -text "Entrybox foreground color:"
	button .bc.4 -textvariable ::dynamic::theme_files_entry_foreground -command { color_chooser { proc_ccov ::dynamic::theme_files_entry_foreground } }
	button .bc.5 -text "Choose" -command { chooseColor_check ::dynamic::theme_files_entry_foreground }
        label .bc.6 -text "Entry insert background:"
	button .bc.7 -textvariable ::dynamic::theme_files_entry_insertbackground -command { color_chooser { proc_ccov ::dynamic::theme_files_entry_insertbackground } }
	button .bc.8 -text "Choose" -command { chooseColor_check ::dynamic::theme_files_entry_insertbackground }
        label .bc.9 -text "Font:"
        entry .bc.10 -width 30 -textvariable ::dynamic::theme_files_entry_font
        button .bc.11 -text "Choose" -command { proc_fontchoose ::dynamic::theme_files_entry_font $::dynamic::theme_files_entry_font }
        button .bc.c -text "Close this window" -command { destroy .bc }

    for { set n 0 } { $n < 12 } { incr n } {
        grid .bc.$n -column [expr $n%3+1] -row [expr $n/3+1]
        }
        grid .bc.c -column 1 -row 5
    }
    
    proc proc_files_update { } { proc_file }
    
}

proc proc_chat { } {
    proc_create
    wm title . "QuIRC Style Editor - DCC Chat Window"
    
    #### Create the basic frames ####
    frame .m.ft -relief sunken -bg $::dynamic::theme_buttonbar_background -border 1
    frame .m.fl -relief sunken -bg $::dynamic::theme_windowlist_background -border 1
    frame .m.fc -relief sunken -bg [ proc_cov { set ::backg } $::dynamic::theme_query_background ] -border 1
    frame .m.fb -relief sunken -bg $::dynamic::theme_chat_entry_background -border 1
    frame .update -relief sunken -bg black
    
    #### Minor Frames ####
    frame .m.fc.t   -bg [ proc_cov { set ::backg } $dynamic::theme_chat_background ]
    frame .m.fl.t   -bg $::dynamic::theme_windowlist_background
    
    #### Add some buttons and labels ####
    
    proc_close_disconnect_menu
    
    label .m.fl.t.1 -text "Main Status" -bg $::dynamic::theme_windowlist_background -fg $::dynamic::theme_windowlist_foreground -font $::dynamic::theme_windowlist_font
    label .m.fl.t.2 -text "hebron.dal.net" -bg $::dynamic::theme_windowlist_background -fg $::dynamic::theme_windowlist_foreground -font $::dynamic::theme_windowlist_font
    label .m.fl.t.3 -text "#Active_Chan" -bg $::dynamic::theme_windowlist_activebackground -fg $::dynamic::theme_windowlist_activeforeground -font $::dynamic::theme_windowlist_font
    label .m.fl.t.4 -text "#Normal_Chan" -bg $::dynamic::theme_windowlist_background -fg $::dynamic::theme_windowlist_foreground -font $::dynamic::theme_windowlist_font
    label .m.fl.t.5 -text "=Alfred" -bg $::dynamic::theme_windowlist_selectbackground -fg $::dynamic::theme_windowlist_selectforeground -font $::dynamic::theme_windowlist_font
    button .m.fl.chan -text "Change" -command { proc_univ_winlist } -relief flat -bg $::dynamic::theme_windowlist_background -fg $::dynamic::theme_windowlist_foreground -width 3
    
    label .m.fc.t.text -text "<Alfred> " -fg [ proc_cov { set ::backg } $::dynamic::theme_default_foreground2 ] -bg [ proc_cov { set ::backg } $::dynamic::theme_chat_background ] -font $::dynamic::theme_chat_font_normal
    label .m.fc.t.text1 -text "Is George buggin the crap outa you, too?" -fg [ proc_cov { set ::foreg } $::dynamic::theme_chat_foreground ] -bg [ proc_cov { set ::backg } $::dynamic::theme_chat_background ] -font $::dynamic::theme_chat_font_normal
    button .m.fc.t.btext -text "Change" -command { proc_chat_fc } -relief flat -bg [ proc_cov { set ::backg } $::dynamic::theme_chat_background ] -fg [ proc_cov { set ::foreg } $::dynamic::theme_chat_foreground ] -width 3
    
    entry .m.fb.entry -fg $::dynamic::theme_chat_entry_foreground -bg $::dynamic::theme_chat_entry_background -font $::dynamic::theme_chat_entry_font -insertbackground $::dynamic::theme_chat_entry_insertbackground  -width 60  -relief flat
    button .m.fb.bentry -text "Change" -command { proc_chat_fb } -relief flat -bg $::dynamic::theme_chat_entry_background  -fg $::dynamic::theme_chat_entry_foreground -width 3 

    button .update.up -text "Update settings for preview" -command { proc_chat_update }
    
    #### Pack everything ####
    
    pack .m.ft -side top -fill x
    pack .m.ft.close .m.ft.condis .m.ft.menu -side left
    pack .m.ft.lag -side right
    
    pack .m.fl -side left -fill y
    pack .m.fl.t -side top
    grid .m.fl.t.1 -column 1 -row 1
    grid .m.fl.t.2 -column 1 -row 2
    grid .m.fl.t.3 -column 1 -row 3
    grid .m.fl.t.4 -column 1 -row 4
    grid .m.fl.t.5 -column 1 -row 5
    pack .m.fl.chan -side bottom
    
    pack .m.fc -anchor center -fill both -expand 1
    pack .m.fc.t -side bottom -fill x
    pack .m.fc.t.text .m.fc.t.text1 -side left
    pack .m.fc.t.btext -side right
    
    pack .m.fb -side bottom -fill x
    pack .m.fb.entry -side left
    pack .m.fb.bentry -side right
    
    pack .m -fill both -expand 1
    
    pack .update.up
    pack .update -fill x
    
    #### Mini procedures ####
    
    proc proc_chat_fc { } {
	toplevel .bc
	wm title .bc "DCC Chat window"
	
        label .bc.0 -text "Background color:"
	tk_optionMenu .bc.1 ::dynamic::theme_chat_background 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
	button .bc.2 -text "Choose" -command { color_chooser {  set ::dynamic::theme_chat_background } }
        label .bc.3 -text "Foreground color:"
	tk_optionMenu .bc.4 ::dynamic::theme_chat_foreground 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
	button .bc.5 -text "Choose" -command { color_chooser {  set ::dynamic::theme_chat_foreground } }
        label .bc.6 -text "Selected Background color:"
	button .bc.7 -textvariable ::dynamic::theme_chat_selectbackground -command { color_chooser { proc_ccov ::dynamic::theme_chat_selectbackground } }
	button .bc.8 -text "Choose" -command { chooseColor_check ::dynamic::theme_chat_selectbackground }
        label .bc.9 -text "Selected Foreground color:"
	button .bc.10 -textvariable ::dynamic::theme_chat_selectforeground -command { color_chooser { proc_ccov ::dynamic::theme_chat_selectforeground } }
	button .bc.11 -text "Choose" -command { chooseColor_check ::dynamic::theme_chat_selectforeground }
        label .bc.12 -text "Selected Borderwidth:"
	entry .bc.13 -width 5 -textvariable ::dynamic::theme_chat_selectborderwidth
	label .bc.14 -text ""
        label .bc.15 -text "Font (Normal):"
        entry .bc.16 -width 30 -textvariable ::dynamic::theme_chat_font_normal
        button .bc.17 -text "Choose" -command { proc_fontchoose ::dynamic::theme_chat_font_normal $::dynamic::theme_chat_font_normal }
        label .bc.18 -text "Font (Bold):"
        entry .bc.19 -width 30 -textvariable ::dynamic::theme_chat_font_bold
        button .bc.20 -text "Choose" -command { proc_fontchoose ::dynamic::theme_chat_font_bold $::dynamic::theme_chat_font_bold }
        button .bc.c -text "Close this window" -command { destroy .bc }

    for { set n 0 } { $n < 21 } { incr n } {
        grid .bc.$n -column [expr $n%3+1] -row [expr $n/3+1]
        }
        grid .bc.c -column 1 -row 8
    }
    
    proc proc_chat_fb { } {
        toplevel .bc
        wm title .bc "DCC Chat entry window"
	
        label .bc.0 -text "Entrybox background color:"
	button .bc.1 -textvariable ::dynamic::theme_chat_entry_background -command { color_chooser { proc_ccov ::dynamic::theme_chat_entry_background } }
	button .bc.2 -text "Choose" -command { chooseColor_check ::dynamic::theme_chat_entry_background }
        label .bc.3 -text "Entrybox foreground color:"
	button .bc.4 -textvariable ::dynamic::theme_chat_entry_foreground -command { color_chooser { proc_ccov ::dynamic::theme_chat_entry_foreground } }
	button .bc.5 -text "Choose" -command { chooseColor_check ::dynamic::theme_chat_entry_foreground }
        label .bc.6 -text "Entry insert background:"
	button .bc.7 -textvariable ::dynamic::theme_chat_entry_insertbackground -command { color_chooser { proc_ccov ::dynamic::theme_chat_entry_insertbackground } }
	button .bc.8 -text "Choose" -command { chooseColor_check ::dynamic::theme_chat_entry_insertbackground }
        label .bc.9 -text "Font:"
        entry .bc.10 -width 30 -textvariable ::dynamic::theme_chat_entry_font
        button .bc.11 -text "Choose" -command { proc_fontchoose ::dynamic::theme_chat_entry_font $::dynamic::theme_chat_entry_font }
        button .bc.c -text "Close this window" -command { destroy .bc }

    for { set n 0 } { $n < 12 } { incr n } {
        grid .bc.$n -column [expr $n%3+1] -row [expr $n/3+1]
        }
        grid .bc.c -column 1 -row 5
    }
    
    proc proc_chat_update { } { proc_chat }
}

#### Global Quickies section ####

proc proc_global { } {

	#### Set some variables so the display looks a little nicer ####
	set ::default_temp "0"
	set ::default_font_normal $::dynamic::theme_channel_font_normal
	set ::default_font_bold $::dynamic::theme_channel_font_bold
	set ::default_font_entry $::dynamic::theme_channel_entry_font
	set ::default_background $::dynamic::theme_channel_background 
	set ::default_foreground $::dynamic::theme_channel_foreground
	set ::default_selectbackground $::dynamic::theme_channel_selectbackground
	set ::default_selectforeground $::dynamic::theme_channel_selectforeground
	set ::default_selectborderwidth $::dynamic::theme_channel_selectborderwidth
	set ::default_entry_background $::dynamic::theme_channel_entry_background
	set ::default_entry_foreground $::dynamic::theme_channel_entry_foreground
	set ::default_entry_insertbackground $::dynamic::theme_channel_entry_insertbackground

    #### And now let's create the display ####
    proc_create
    wm title . "QuIRC Style Editor - Global Quickies"
    
    label .m.0 -text "Default background color:"
    tk_optionMenu .m.1 ::default_background 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
    button .m.2 -text "Choose" -command { color_chooser { set ::default_background } }
    button .m.3 -text "Set global" -command { set ::default_temp "0" ; proc_set_default 0 }
    label .m.4 -text "Default foreground color:"
    tk_optionMenu .m.5 ::default_foreground 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
    button .m.6 -text "Choose" -command { color_chooser { set ::default_foreground } }
    button .m.7 -text "Set global" -command { set ::default_temp "0" ; proc_set_default 1 }
    label .m.8 -text "Default selected background color:"
    button .m.9 -textvariable ::default_selectbackground -command { color_chooser { proc_ccov ::default_selectbackground } }
    button .m.10 -text "Choose" -command { chooseColor_check ::default_selectbackground }
    button .m.11 -text "Set global" -command { set ::default_temp "0" ; proc_set_default 2 }
    label .m.12 -text "Default selected foreground color:"
    button .m.13 -textvariable ::default_selectforeground -command { color_chooser { proc_ccov ::default_selectforeground } }
    button .m.14 -text "Choose" -command { chooseColor_check ::default_selectforeground }
    button .m.15 -text "Set global" -command { set ::default_temp "0" ; proc_set_default 3 }
    label .m.16 -text "Default border width:"
    entry .m.17 -width 5 -textvariable ::default_selectborderwidth
    label .m.18 -text ""
    button .m.19 -text "Set global" -command { set ::default_temp "0" ; proc_set_default 6 }
    label .m.20 -text "Default entry background color:"
    button .m.21 -textvariable ::default_entry_background -command { color_chooser { proc_ccov ::default_entry_background } }
    button .m.22 -text "Choose" -command { chooseColor_check ::default_entry_background }
    button .m.23 -text "Set global" -command { set ::default_temp "0" ; proc_set_default 4 }
    label .m.24 -text "Default entry foreground color:"
    button .m.25 -textvariable ::default_entry_foreground -command { color_chooser { proc_ccov ::default_entry_foreground } }
    button .m.26 -text "Choose" -command { chooseColor_check ::default_entry_foreground }
    button .m.27 -text "Set global" -command { set ::default_temp "0" ; proc_set_default 5 }
    label .m.28 -text "Default insert background color:"
    button .m.29 -textvariable ::default_entry_insertbackground -command { color_chooser { proc_ccov ::default_entry_insertbackground } }
    button .m.30 -text "Choose" -command { chooseColor_check ::default_entry_insertbackground }
    button .m.31 -text "Set global" -command { set ::default_temp "0" ; proc_set_default 7 }
    label .m.32 -text "Default Normal font:"
    entry .m.33 -width 15 -textvariable ::default_font_normal
    button .m.34 -text "Choose" -command { proc_fontchoose ::default_font_normal $::default_font_normal }
    button .m.35 -text "Set global" -command { set ::default_temp "0" ; proc_set_font_default 1 }
    label .m.36 -text "Default Bold font:"
    entry .m.37 -width 15 -textvariable ::default_font_bold 
    button .m.38 -text "Choose" -command { proc_fontchoose ::default_font_bold $::default_font_bold }
    button .m.39 -text "Set global" -command { set ::default_temp "0" ; proc_set_font_default 0 }
    label .m.40 -text "Default entry font:"
    entry .m.41 -width 15 -textvariable ::default_font_entry 
    button .m.42 -text "Choose" -command { proc_fontchoose ::default_font_entry $::default_font_entry }
    button .m.43 -text "Set global" -command { proc_set_font_default 2 }
    button .m.44 -text "Set ALL global" -command { set ::default_temp "1" ; proc_set_default 0 ; proc_set_default 1 ; proc_set_default 2 ; proc_set_default 3 ; proc_set_default 4 ; proc_set_default 5 ; proc_set_default 6 ; proc_set_default 7 ; proc_set_font_default 0 ; proc_set_font_default 1 ; proc_set_font_default 2 ; tk_messageBox -title "Done" -message "All values have been set global."} -width 9

    for { set n 0 } { $n < 44 } { incr n } {
	grid .m.$n -column [expr $n%4+1] -row [expr $n/4+1]
    }
    grid .m.44 -column 4 -row 12
    pack .m
}

##### Banlist Section #####
proc proc_banlist { } {
    toplevel .bc
    wm title .bc "QuIRC Style Editor - Banlist"
    
    frame .bc.1
    frame .bc.1.t -bg $::dynamic::theme_banlist_title_background -relief sunken -border 1
    frame .bc.1.m -bg $::dynamic::theme_banlist_background  -relief sunken -border 1
    frame .bc.1.b -bg $::dynamic::theme_banlist_entry_background -relief sunken -border 1
    frame .bc.update -bg $::dynamic::theme_banlist_background -relief sunken
    
    label  .bc.1.t.1 -text "Num   Ban	  Nick	                           Time" -bg $::dynamic::theme_banlist_title_background -fg $::dynamic::theme_banlist_title_foreground 
    button .bc.1.t.2 -text "Change" -bg $::dynamic::theme_banlist_title_background -fg $::dynamic::theme_banlist_title_foreground -command { proc_btop } -relief flat -width 3
    
    label .bc.1.m.1 -text "1        *!*@*            Axe!axe@killinghand.org    Fri Nov 21 15:50:31 CST 2000" -bg $::dynamic::theme_banlist_background -fg $::dynamic::theme_banlist_foreground
    button .bc.1.m.2 -text "Change" -bg $::dynamic::theme_banlist_background -fg $::dynamic::theme_banlist_foreground -command { proc_bmid } -relief flat -width 3
    label .bc.1.m.s1 -text "" -bg $::dynamic::theme_banlist_background -fg $::dynamic::theme_banlist_foreground
    label .bc.1.m.s2 -text "" -bg $::dynamic::theme_banlist_background -fg $::dynamic::theme_banlist_foreground
    label .bc.1.m.s3 -text "" -bg $::dynamic::theme_banlist_background -fg $::dynamic::theme_banlist_foreground
    label .bc.1.m.s4 -text "" -bg $::dynamic::theme_banlist_background -fg $::dynamic::theme_banlist_foreground
    
    entry .bc.1.b.entry -fg $::dynamic::theme_banlist_entry_foreground -bg $::dynamic::theme_banlist_entry_background -insertbackground $::dynamic::theme_banlist_entry_insertbackground  -width 64  -relief flat
    button .bc.1.b.bentry -text "Change" -bg $::dynamic::theme_banlist_entry_background -fg $::dynamic::theme_banlist_entry_foreground -command { proc_bbot } -relief flat -width 3
    
    button .bc.update.up -text "Update settings for preview" -command { proc_banlist_update }
    button .bc.update.c -text "Close this window" -command { destroy .bc } 
    
    pack .bc.1.t -fill both -side top
    pack .bc.1.t.1 -side left
    pack .bc.1.t.2 -side right
    
    pack .bc.1.m -fill both -side top 
    grid .bc.1.m.1 -column 1 -row 1 
    grid .bc.1.m.2 -column 2 -row 1
    grid .bc.1.m.s1 -column 1 -row 2
    grid .bc.1.m.s2 -column 1 -row 3
    grid .bc.1.m.s3 -column 1 -row 4
    grid .bc.1.m.s4 -column 1 -row 5
    
    pack .bc.1.b -fill both -side bottom
    pack .bc.1.b.entry -side left
    pack .bc.1.b.bentry -side right
    
    pack .bc.1 -fill both
    
    pack .bc.update -fill both 
    pack .bc.update.up -side left
    pack .bc.update.c  -side right
    
    #### Mini Procedures ####

    proc proc_btop { } {
	toplevel .bc1
	wm title .bc1 "Banlist-top"

	label .bc1.0 -text "Title background:"
	button .bc1.1 -textvariable ::dynamic::theme_banlist_title_background -command { color_chooser { proc_ccov ::dynamic::theme_banlist_title_background } }
	button .bc1.2 -text "Choose" -command { chooseColor_check ::dynamic::theme_banlist_title_background }
	label .bc1.3 -text "Title foreground:"
	button .bc1.4 -textvariable ::dynamic::theme_banlist_title_foreground -command { color_chooser { proc_ccov ::dynamic::theme_banlist_title_foreground } }
	button .bc1.5 -text "Choose" -command { chooseColor_check ::dynamic::theme_banlist_title_foreground }
	button .bc1.c -text "Close this window" -command { destroy .bc1 }

    for { set n 0 } { $n < 6 } { incr n } {
        grid .bc1.$n -column [expr $n%3+1] -row [expr $n/3+1]
        }
	grid .bc1.c -column 1 -row 3
    }
    
    proc proc_bmid { } {
	toplevel .bc1
	wm title .bc1 "Banlist-middle"

	label .bc1.0 -text "Background color:"
	button .bc1.1 -textvariable ::dynamic::theme_banlist_background -command { color_chooser { proc_ccov ::dynamic::theme_banlist_background } }
	button .bc1.2 -text "Choose" -command { chooseColor_check ::dynamic::theme_banlist_background }
	label .bc1.3 -text "Foreground color:"
	button .bc1.4 -textvariable ::dynamic::theme_banlist_foreground -command { color_chooser { proc_ccov ::dynamic::theme_banlist_foreground } }
	button .bc1.5 -text "Choose" -command { chooseColor_check ::dynamic::theme_banlist_foreground }
        label .bc1.6 -text "Font:"
        entry .bc1.7 -width 30 -textvariable ::dynamic::theme_banlist_font
        button .bc1.8 -text "Choose" -command { proc_fontchoose ::dynamic::theme_banlist_font $::dynamic::theme_banlist_font }
	button .bc1.c -text "Close this window" -command { destroy .bc1 }



    for { set n 0 } { $n < 9 } { incr n } {
        grid .bc1.$n -column [expr $n%3+1] -row [expr $n/3+1]
        }
	grid .bc1.c -column 1 -row 4
    }
    
    proc proc_bbot { } {
	toplevel .bc1
	wm title .bc1 "Banlist-bottom"

	label .bc1.0 -text "Entry background:"
	button .bc1.1 -textvariable ::dynamic::theme_banlist_entry_background -command { color_chooser { proc_ccov ::dynamic::theme_banlist_entry_background } }
	button .bc1.2 -text "Choose" -command { chooseColor_check ::dynamic::theme_banlist_entry_background }
	label .bc1.3 -text "Entry foreground:"
	button .bc1.4 -textvariable ::dynamic::theme_banlist_entry_foreground -command { color_chooser { proc_ccov ::dynamic::theme_banlist_entry_foreground } }
	button .bc1.5 -text "Choose" -command { chooseColor_check ::dynamic::theme_banlist_entry_foreground }
	label .bc1.6 -text "Entry insert background:"
	button .bc1.7 -textvariable ::dynamic::theme_banlist_entry_insertbackground -command { color_chooser { proc_ccov ::dynamic::theme_banlist_entry_insertbackground } }
	button .bc1.8 -text "Choose" -command { chooseColor_check ::dynamic::theme_banlist_entry_insertbackground }
	button .bc1.c -text "Close this window" -command { destroy .bc1 }

    for { set n 0 } { $n < 9 } { incr n } {
        grid .bc1.$n -column [expr $n%3+1] -row [expr $n/3+1]
        }

        grid .bc1.c -column 1 -row 4

    }
    
    proc proc_banlist_update { } {
	destroy .bc 
	proc_banlist 
    }
    
}

##### Foreground colors section #####

proc proc_foreg { } {
    toplevel .bc
    wm title .bc "QuIRC Style Editor - Foreground colors"
    
    label .bc.0 -text "Foreground color #2:"
    label .bc.1 -textvariable "   " -bg [ proc_cov { set ::backg } $::dynamic::theme_default_foreground2 ]
    tk_optionMenu .bc.2 ::dynamic::theme_default_foreground2 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
    button .bc.3 -text "Choose" -command { color_chooser { set ::dynamic::theme_default_foreground2 } }
    label .bc.4 -text "Foreground color #3:"
    label .bc.5 -textvariable "   " -bg [ proc_cov { set ::backg } $::dynamic::theme_default_foreground3 ]
    tk_optionMenu .bc.6 ::dynamic::theme_default_foreground3 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
    button .bc.7 -text "Choose" -command { color_chooser { set ::dynamic::theme_default_foreground3 } }
    label .bc.8 -text "Foreground color #4:"
    label .bc.9 -textvariable "   " -bg [ proc_cov { set ::backg } $::dynamic::theme_default_foreground4 ]
    tk_optionMenu .bc.10 ::dynamic::theme_default_foreground4 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
    button .bc.11 -text "Choose" -command { color_chooser { set ::dynamic::theme_default_foreground4 } }
    label .bc.12 -text "Foreground color #5:"
    label .bc.13 -textvariable "   " -bg [ proc_cov { set ::backg } $::dynamic::theme_default_foreground5 ]
    tk_optionMenu .bc.14 ::dynamic::theme_default_foreground5 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
    button .bc.15 -text "Choose" -command { color_chooser { set ::dynamic::theme_default_foreground5 } }
    button .bc.c -text "Close this window" -command { destroy .bc }
    button .bc.up -text "Update" -command { proc_foreg_update }
   
    for { set n 0 } { $n < 16 } { incr n } {
        grid .bc.$n -column [expr $n%4+1] -row [expr $n/4+1]
    }
    grid .bc.c -column 1 -row 8
    grid .bc.up -column 3 -row 8
   
 
    proc proc_foreg_update { } {
	destroy .bc
	proc_foreg
    }
}

##### Gloval color value section #####

proc proc_color { } {
    toplevel .bc
    wm title .bc "QuIRC Style Editor - Color settings"
    
    label .bc.0 -text "Color 0:"
    label .bc.1 -textvariable "   " -bg $::dynamic::theme_color(0)
    button .bc.2 -textvariable "::dynamic::theme_color(0)"  -command { chooseColor_check ::dynamic::theme_color(0) }
    label .bc.3 -text "Color 1:"
    label .bc.4 -textvariable "   " -bg $::dynamic::theme_color(1)
    button .bc.5 -textvariable "::dynamic::theme_color(1)" -command { chooseColor_check ::dynamic::theme_color(1) }
    label .bc.6 -text "Color 2:"
    label .bc.7 -textvariable "   " -bg $::dynamic::theme_color(2)
    button .bc.8 -textvariable "::dynamic::theme_color(2)" -command { chooseColor_check ::dynamic::theme_color(2) }
    label .bc.9 -text "Color 3:"
    label .bc.10 -textvariable "   " -bg $::dynamic::theme_color(3)
    button .bc.11 -textvariable "::dynamic::theme_color(3)" -command { chooseColor_check ::dynamic::theme_color(3) }
    label .bc.12 -text "Color 4:"
    label .bc.13 -textvariable "   " -bg $::dynamic::theme_color(4)
    button .bc.14 -textvariable "::dynamic::theme_color(4)" -command { chooseColor_check ::dynamic::theme_color(4) }
    label .bc.15 -text "Color 5:"
    label .bc.16 -textvariable "   " -bg $::dynamic::theme_color(5)
    button .bc.17 -textvariable "::dynamic::theme_color(5)" -command { chooseColor_check ::dynamic::theme_color(5) }
    label .bc.18 -text "Color 6:"
    label .bc.19 -textvariable "   " -bg $::dynamic::theme_color(6)
    button .bc.20 -textvariable "::dynamic::theme_color(6)" -command { chooseColor_check ::dynamic::theme_color(6) }
    label .bc.21 -text "Color 7:"
    label .bc.22 -textvariable "   " -bg $::dynamic::theme_color(7)
    button .bc.23 -textvariable "::dynamic::theme_color(7)" -command { chooseColor_check ::dynamic::theme_color(7) }
    label .bc.24 -text "Color 8:"
    label .bc.25 -textvariable "   " -bg $::dynamic::theme_color(8)
    button .bc.26 -textvariable "::dynamic::theme_color(8)" -command { chooseColor_check ::dynamic::theme_color(8) }
    label .bc.27 -text "Color 9:"
    label .bc.28 -textvariable "   " -bg $::dynamic::theme_color(9)
    button .bc.29 -textvariable "::dynamic::theme_color(9)" -command { chooseColor_check ::dynamic::theme_color(9) }
    label .bc.30 -text "Color 10:"
    label .bc.31 -textvariable "   " -bg $::dynamic::theme_color(10)
    button .bc.32 -textvariable "::dynamic::theme_color(10)" -command { chooseColor_check ::dynamic::theme_color(10) }
    label .bc.33 -text "Color 11:"
    label .bc.34 -textvariable "   " -bg $::dynamic::theme_color(11)
    button .bc.35 -textvariable "::dynamic::theme_color(11)" -command { chooseColor_check ::dynamic::theme_color(11) }
    label .bc.36 -text "Color 12:"
    label .bc.37 -textvariable "   " -bg $::dynamic::theme_color(12)
    button .bc.38 -textvariable "::dynamic::theme_color(12)" -command { chooseColor_check ::dynamic::theme_color(12) }
    label .bc.39 -text "Color 13:"
    label .bc.40 -textvariable "   " -bg $::dynamic::theme_color(13)
    button .bc.41 -textvariable "::dynamic::theme_color(13)" -command { chooseColor_check ::dynamic::theme_color(13) }
    label .bc.42 -text "Color 14:"
    label .bc.43 -textvariable "   " -bg $::dynamic::theme_color(14)
    button .bc.44 -textvariable "::dynamic::theme_color(14)" -command { chooseColor_check ::dynamic::theme_color(14) }
    label .bc.45 -text "Color 15:"
    label .bc.46 -textvariable "   " -bg $::dynamic::theme_color(15)
    button .bc.47 -textvariable "::dynamic::theme_color(15)" -command { chooseColor_check ::dynamic::theme_color(15) }
    button .bc.set -text "Set Defaults" -command { proc_default_color }
    button .bc.c -text "Close this window" -command { destroy .bc }
    
    for { set n 0 } { $n < 48 } { incr n } {
	grid .bc.$n -column [expr $n%6+1] -row [expr $n/6+1]
    }
    grid .bc.set -column 1 -row 9
    grid .bc.c -column 4 -row 9
}

##### The ugly FSET's section #####

proc proc_fset { } {
    proc_create
    wm geometry . 630x365
    wm title . "QuIRC Style Editor - FSET Menu"
   
    set ::packer 0
    set ::hei 10
 
    #### Create some frames ####
    frame .m.mid
	canvas .m.mid.canvas -width 600 -height 300 -yscrollcommand ".m.mid.scroll set" 
	scrollbar .m.mid.scroll -command ".m.mid.canvas yview"
    frame .update
    
    #### Now, the entries ####
    while { $::packer < $::num } {
	entry .m.mid.canvas.$::packer -textvariable ::fset::fset$::packer -width 90
	.m.mid.canvas create window 320 $::hei  -window .m.mid.canvas.$::packer
	set ::hei [incr ::hei 20 ] 
        set ::packer [ incr ::packer 1 ]
    }
	.m.mid.canvas configure -scrollregion "0 0 500 $::hei"

    button .update.h -text "Open Help Window" -command { proc_fset_help_main }
   

 
    #### Pack everything under the sun ####
    
    pack .m.mid.scroll -side right -fill y
    pack .m.mid.canvas -side right -expand 1
    pack .m.mid
    
    pack .update.h 
    pack .update -side bottom
    
    pack .m
    
    proc proc_fset_help_main { } {
    tk_messageBox -title "FSET Help" -message "These are maybe the most dangerous QuIRC commands to mess up.  Use caution, because 
the only way to fix them is to reload the origionals from default.tcl or not save. I might even suggest leaving them alone until a better editor is created. 
But, for the brave, they are all listed here for your editing pleasure.  You'll notice there is a common
theme to the FSET's.  Name first, the color, the command, and then the location.  That's the general layout for most of them, the
rest might just lack the location."
    }
}

proc proc_extra { } {

	proc_create
	wm title . "QuIRC Style Editor - Extra Menu"
	
	label .m.whois -text "Whois Location:"
	tk_optionMenu .m.whoisc ::whoislocation current all none currentorstatus status serverall files


	grid .m.whois -row 1 -column 1
	grid .m.whoisc -row 1 -column 2
	pack .m

}
##################################
###### Help Menu Procedures ######
##################################

proc proc_version { } {
    global ver
    tk_messageBox -title Version -message "QuIRC Style Editor version $ver " 
}


proc proc_about { } {
    tk_messageBox -title About -message "A simple theme/style editor for the *nix IRC client, QuIRC" 
}


proc proc_file_about { } {
	tk_messageBox -title "About File" -message \
"Save - Self explainitory.
Save As - Self explainitory. 
Load From - Use with caution, there is no error checking. (Will flip out if you open a binary file, etc)
Reload Default.tcl - Kills your current settings, and loads the default ones that came with QuIRC.
Reload Old QuEdit Settings - Will load the settings from quedit.tcl.old (Settings from 2 saves previous)
Load New default.tcl - Sources a new default.tcl then loads your custom quedit settings on top."
}


proc proc_gq_about { } {
	tk_messageBox -title "About Global Quickies" -message \
"These are here for quick changing of common settings.  For example
if you want the background a uniform color on every window, just change it here." 
}


###############################
###### Lesser procedures ######
###############################

proc proc_create { } {
    destroy .update
    destroy .m
    frame .m 
}

proc color_chooser { command } {
    #### Command will pass a number between 0 and 15 - Donated by Patrick Earl ####
    toplevel .colorchooser
    wm geometry .colorchooser 140x110
    for { set n 0 } {$n < 16 } {incr n} {
	label .colorchooser.label$n -text "   " -bg [ set ::dynamic::theme_color($n) ] -relief raised
	bind .colorchooser.label$n <Button-1> "destroy .colorchooser; $command $n"
    }
    for { set y 0 } { $y < 4 } { incr y } {
	for { set x 0 } { $x < 4 } { incr x } {
	    grid .colorchooser.label[expr $y*4+$x] -column [expr $x+1] -row [expr $y+1]
	}
    }
}

proc chooseColor_check { colorvariable } {
	#### Routine to check if tk_chooseColor is going to pass a color or ####
	#### a blank variable back to us ####
	set newcolorvariable [ tk_chooseColor -initialcolor [ set $colorvariable ] ]
	if { $newcolorvariable != "" } { set $colorvariable $newcolorvariable }
}

proc proc_ccov { variab n } {
	set n $::dynamic::theme_color($n) 
	set $variab $n
}

proc proc_fontchoose { varib font } {
	set newfont [ exec $::env(HOME)/.quirc/fontsel $font ]
        if { $newfont != "" } { set $varib $newfont }
}

proc fset_switch { } {
	set ::temp::entire_fset [lsort -dictionary $::temp::entire_fset]
	set fsnum 0
        while { $fsnum < $::num } {
            set thevar "set ::fset::fset$fsnum {[string range [lindex $::temp::entire_fset $fsnum] 5 end]}"
            uplevel #0 $thevar
            set $fsnum [ incr fsnum ]
	}
	namespace delete ::temp
}

#################################
##### Universal procedures ######
#################################

#### Universal Buttonbar procedures (First proc draws most of them, and the second/third/forth is used to customize them) ####

proc proc_close_disconnect_menu { } {

    button .m.ft.close -text "Close" -fg $::dynamic::theme_button_close_foreground -bg $::dynamic::theme_button_close_background -activeforeground $::dynamic::theme_button_close_activeforeground -activebackground $::dynamic::theme_button_close_activebackground -command { proc_univ_button_close }
    button .m.ft.condis -text "Disconnect" -fg $::dynamic::theme_button_condis_foreground -bg $::dynamic::theme_button_condis_background -activeforeground $::dynamic::theme_button_condis_activeforeground -activebackground $::dynamic::theme_button_condis_activebackground -command { proc_univ_button_condis }
    button .m.ft.menu -text "Menu" -fg $::dynamic::theme_button_menu_foreground -bg $::dynamic::theme_button_menu_background -activeforeground $::dynamic::theme_button_menu_activeforeground -activebackground $::dynamic::theme_button_menu_activebackground -command { proc_univ_button_menu }
    button .m.ft.lag -text "Server lag:  0.17" -fg $::dynamic::theme_lag_foreground -bg $::dynamic::theme_lag_background -relief flat -command { proc_univ_lag } -activebackground $::dynamic::theme_lag_background -activeforeground white
}

proc proc_univ_button_condis { } {
    
    toplevel .bc
    wm title .bc "Connect/Disconnect and Start A New Server Button"
    
    label .bc.0 -text "ButtonBar background color:"
    button .bc.1 -textvariable ::dynamic::theme_buttonbar_background -command { color_chooser { proc_ccov ::dynamic::theme_buttonbar_background } }
    button .bc.2 -text "Choose" -command { chooseColor_check ::dynamic::theme_buttonbar_background }
    label .bc.3 -text "Background of connect/disconnect/start button:"
    button .bc.4 -textvariable ::dynamic::theme_button_condis_background  -command { color_chooser { proc_ccov ::dynamic::theme_button_condis_background } }
    button .bc.5 -text "Choose" -command { chooseColor_check ::dynamic::theme_button_condis_background }
    label .bc.6 -text "Foreground of connect/disconnect/start button:"
    button .bc.7 -textvariable ::dynamic::theme_button_condis_foreground -command { color_chooser { proc_ccov ::dynamic::theme_button_condis_foreground } }
    button .bc.8 -text "Choose" -command { chooseColor_check ::dynamic::theme_button_condis_foreground }
    label .bc.9 -text "Background of active connect/disconnect/start button:"
    button .bc.10 -textvariable ::dynamic::theme_button_condis_activebackground -command { color_chooser { proc_ccov ::dynamic::theme_button_condis_activebackground } }
    button .bc.11 -text "Choose" -command { chooseColor_check ::dynamic::theme_button_condis_activebackground }
    label .bc.12 -text "Foreground of active connect/disconnect/start button:"
    button .bc.13 -textvariable ::dynamic::theme_button_condis_activeforeground  -command { color_chooser {proc_ccov ::dynamic::theme_button_condis_activeforeground } }
    button .bc.14 -text "Choose" -command { chooseColor_check ::dynamic::theme_button_condis_activeforeground }
    button .bc.c -text "Close this window" -command { destroy .bc }
   
    for { set n 0 } { $n < 15 } { incr n } {
        grid .bc.$n -column [expr $n%3+1] -row [expr $n/3+1]
        }
    grid .bc.c -column 1 -row 6
}

proc proc_univ_button_close { } {
    
    toplevel .bc
    wm title .bc "Close Button"
    
    label .bc.0 -text "ButtonBar background color:"
    button .bc.1 -textvariable ::dynamic::theme_buttonbar_background -command { color_chooser { proc_ccov ::dynamic::theme_buttonbar_background } }
    button .bc.2 -text "Choose" -command { chooseColor_check ::dynamic::theme_buttonbar_background }
    label .bc.3 -text "Background of close button"
    button .bc.4 -textvariable ::dynamic::theme_button_close_background -command { color_chooser {proc_ccov ::dynamic::theme_button_close_background } }
    button .bc.5 -text "Choose" -command { chooseColor_check ::dynamic::theme_button_close_background }
    label .bc.6 -text "Foreground of close button"
    button .bc.7 -textvariable ::dynamic::theme_button_close_foreground  -command { color_chooser { proc_ccov ::dynamic::theme_button_close_foreground } }
    button .bc.8 -text "Choose" -command { chooseColor_check ::dynamic::theme_button_close_foreground }
    label .bc.9 -text "Background of active close button"
    button .bc.10 -textvariable ::dynamic::theme_button_close_activebackground  -command { color_chooser { proc_ccov ::dynamic::theme_button_close_activebackground } }
    button .bc.11 -text "Choose" -command { chooseColor_check ::dynamic::theme_button_close_activebackground }
    label .bc.12 -text "Foreground of active close button"
    button .bc.13 -textvariable ::dynamic::theme_button_close_activeforeground  -command { color_chooser { proc_ccov ::dynamic::theme_button_close_activeforeground } }
    button .bc.14 -text "Choose" -command { chooseColor_check ::dynamic::theme_button_close_activeforeground }
    button .bc.c -text "Close this window" -command { destroy .bc }
   
    for { set n 0 } { $n < 15 } { incr n } {
        grid .bc.$n -column [expr $n%3+1] -row [expr $n/3+1]
        }
    grid .bc.c -column 1 -row 6
}

proc proc_univ_button_menu { } {
   
    toplevel .bc
    wm title .bc "Menu Button"
   
    label .bc.0 -text "ButtonBar background color:"
    button .bc.1 -textvariable ::dynamic::theme_buttonbar_background -command { color_chooser { proc_ccov ::dynamic::theme_buttonbar_background } }
    button .bc.2 -text "Choose" -command { chooseColor_check ::dynamic::theme_buttonbar_background }
    label .bc.3 -text "Background of menu button"
    button .bc.4 -textvariable ::dynamic::theme_button_menu_background -command { color_chooser {proc_ccov ::dynamic::theme_button_menu_background } }
    button .bc.5 -text "Choose" -command { chooseColor_check ::dynamic::theme_button_menu_background }
    label .bc.6 -text "Foreground of menu button"
    button .bc.7 -textvariable ::dynamic::theme_button_menu_foreground  -command { color_chooser { proc_ccov ::dynamic::theme_button_menu_foreground } }
    button .bc.8 -text "Choose" -command { chooseColor_check ::dynamic::theme_button_menu_foreground }
    label .bc.9 -text "Background of active menu button"
    button .bc.10 -textvariable ::dynamic::theme_button_menu_activebackground  -command { color_chooser { proc_ccov ::dynamic::theme_button_menu_activebackground } }
    button .bc.11 -text "Choose" -command { chooseColor_check ::dynamic::theme_button_menu_activebackground }
    label .bc.12 -text "Foreground of active menu button"
    button .bc.13 -textvariable ::dynamic::theme_button_menu_activeforeground  -command { color_chooser { proc_ccov ::dynamic::theme_button_menu_activeforeground } }
    button .bc.14 -text "Choose" -command { chooseColor_check ::dynamic::theme_button_menu_activeforeground }
    button .bc.c -text "Close this window" -command { destroy .bc }

    for { set n 0 } { $n < 15 } { incr n } {
        grid .bc.$n -column [expr $n%3+1] -row [expr $n/3+1]
        }
    grid .bc.c -column 1 -row 6
}

proc proc_univ_lag { } {
    
    toplevel .bc
    wm title .bc "Lag Checker"
    
    label .bc.0 -text "ButtonBar background color:"
    button .bc.1 -textvariable ::dynamic::theme_buttonbar_background -command { color_chooser { proc_ccov ::dynamic::theme_buttonbar_background } }
    button .bc.2 -text "Choose" -command { chooseColor_check ::dynamic::theme_buttonbar_background }
    label .bc.3 -text "Background color:"
    button .bc.4 -textvariable ::dynamic::theme_lag_background -command { color_chooser { proc_ccov ::dynamic::theme_lag_background } }
    button .bc.5 -text "Choose" -command { chooseColor_check ::dynamic::theme_lag_background }
    label .bc.6 -text "Foreground color:"
    button .bc.7 -textvariable ::dynamic::theme_lag_foreground -command { color_chooser { proc_ccov ::dynamic::theme_lag_foreground } }
    button .bc.8 -text "Choose" -command { chooseColor_check ::dynamic::theme_lag_foreground }
    button .bc.c -text "Close this window" -command { destroy .bc }
   
    for { set n 0 } { $n < 9 } { incr n } {
        grid .bc.$n -column [expr $n%3+1] -row [expr $n/3+1]
        }
    grid .bc.c -column 1 -row 4
    
}

#### Universal window list procedure ####

proc proc_univ_winlist { } {
    
    toplevel .bc
    wm title .bc "Window List"
    
    label .bc.0 -text "Background color:"
    button .bc.1 -textvariable ::dynamic::theme_windowlist_background -command { color_chooser { proc_ccov ::dynamic::theme_windowlist_background }  }
    button .bc.2 -text "Choose" -command { chooseColor_check ::dynamic::theme_windowlist_background }
    label .bc.3 -text "Foreground color:"
    button .bc.4 -textvariable ::dynamic::theme_windowlist_foreground -command { color_chooser { proc_ccov ::dynamic::theme_windowlist_foreground } }
    button .bc.5 -text "Choose" -command { chooseColor_check ::dynamic::theme_windowlist_foreground }
    label .bc.6 -text "Active Background color:"
    button .bc.7 -textvariable ::dynamic::theme_windowlist_activebackground -command { color_chooser { proc_ccov ::dynamic::theme_windowlist_activebackground } }
    button .bc.8 -text "Choose" -command { chooseColor_check ::dynamic::theme_windowlist_activebackground }
    label .bc.9 -text "Active Foreground color:"
    button .bc.10 -textvariable ::dynamic::theme_windowlist_activeforeground -command { color_chooser { proc_ccov ::dynamic::theme_windowlist_activeforeground } }
    button .bc.11 -text "Choose" -command { chooseColor_check ::dynamic::theme_windowlist_activeforeground }
    label .bc.12 -text "Selected Background color:"
    button .bc.13 -textvariable ::dynamic::theme_windowlist_selectbackground -command { color_chooser { proc_ccov ::dynamic::theme_windowlist_selectbackground } }
    button .bc.14 -text "Choose" -command { chooseColor_check ::dynamic::theme_windowlist_selectbackground }
    label .bc.15 -text "Selected Foreground color:"
    button .bc.16 -textvariable ::dynamic::theme_windowlist_selectforeground -command { color_chooser { proc_ccov ::dynamic::theme_windowlist_selectforeground } }
    button .bc.17 -text "Choose" -command { chooseColor_check ::dynamic::theme_windowlist_selectforeground }
    label .bc.18 -text "Width of the Windowlist:"
    entry .bc.19 -width 5 -textvariable ::dynamic::theme_windowlist_width
    label .bc.20 -text ""
    label .bc.21 -text "Font:"
    entry .bc.22 -width 30 -textvariable ::dynamic::theme_windowlist_font
    button .bc.23 -text "Choose" -command { proc_fontchoose ::dynamic::theme_windowlist_font $::dynamic::theme_windowlist_font }
    button .bc.c -text "Close this window" -command { destroy .bc }

    for { set n 0 } { $n < 24 } { incr n } {
        grid .bc.$n -column [expr $n%3+1] -row [expr $n/3+1]
    }
    grid .bc.c -column 1 -row 9
    
}

#### Universal nicklist procedure ####

proc proc_univ_nicklist { } {
    toplevel .bc
    wm title .bc "Nick list"
    
    label .bc.0 -text "Nicklist background color:"
    button .bc.1 -textvariable ::dynamic::theme_nicklist_background  -command { color_chooser { proc_ccov ::dynamic::theme_nicklist_background } }
    button .bc.2 -text "Choose" -command { chooseColor_check ::dynamic::theme_nicklist_background }
    label .bc.3 -text "Nicklist foreground color:"
    button .bc.4 -textvariable ::dynamic::theme_nicklist_foreground -command { color_chooser { proc_ccov ::dynamic::theme_nicklist_foreground } }
    button .bc.5 -text "Choose" -command { chooseColor_check ::dynamic::theme_nicklist_foreground }
    label .bc.6 -text "Nicklist Width:"
    entry .bc.7 -width 5 -textvariable ::dynamic::theme_nicklist_width
    label .bc.8 -text ""
    label .bc.9 -text "Font:"
    entry .bc.10 -width 20 -textvariable ::dynamic::theme_nicklist_font
    button .bc.11 -text "Choose" -command { proc_fontchoose ::dynamic::theme_nicklist_font $::dynamic::theme_nicklist_font }
    button .bc.c -text "Close this window" -command { destroy .bc }

    for { set n 0 } { $n < 12 } { incr n } {
        grid .bc.$n -column [expr $n%3+1] -row [expr $n/3+1]
    }
    grid .bc.c -column 1 -row 6
    
}

####################################
##### Some Defaults procedures #####
####################################

#### Procedure to set some defaults (Global Quickies) ####

proc proc_set_default { vari } {
    set message ""
    switch $vari {
	0 { set type background }
	1 { set type foreground }
	2 { set type selectbackground; set message "select background" }
	3 { set type selectforeground; set message "select foreground" }
	4 { set type entry_background; set message "entry background" }
	5 { set type entry_foreground; set message "entry foreground" }
	6 { set type selectborderwidth; set message "borderwidth" }
	7 { set type entry_insertbackground; set message "insert background" }
    }
    if { $message=="" } { set message $type }
    
    set ::dynamic::theme_status_$type [set ::default_$type]
    set ::dynamic::theme_chat_$type [set ::default_$type]
    set ::dynamic::theme_files_$type [set ::default_$type]
    set ::dynamic::theme_main_$type [set ::default_$type]
    set ::dynamic::theme_channel_$type [set ::default_$type]
    set ::dynamic::theme_query_$type [set ::default_$type]
    if { $::default_temp == "0" } { tk_messageBox  -title "Done." -message "Default $message has been set." }
}

proc proc_set_font_default { vari } {
	set message ""
	switch $vari {
		0 { set type bold }
		1 { set type normal }
		2 { set type entry }
	}
	set message $type
	if { $vari != "2" } {
		set ::dynamic::theme_status_font_$type [ set ::default_font_$type ]
		set ::dynamic::theme_query_font_$type [ set ::default_font_$type ]
		set ::dynamic::theme_chat_font_$type [ set ::default_font_$type ]
		set ::dynamic::theme_files_font_$type [ set ::default_font_$type ]
		set ::dynamic::theme_channel_font_$type [ set ::default_font_$type ]
		set ::dynamic::theme_main_font_$type [ set ::default_font_$type ]
	}
	if { $vari == "1" } {
		set ::dynamic::theme_nicklist_font [ set ::default_font_$type ]
		set ::dynamic::theme_banlist_font [ set ::default_font_$type ]
		set ::dynamic::theme_filelist_font [ set ::default_font_$type ]
		set ::dynamic::theme_windowlist_font [ set ::default_font_$type ]
	}
	if { $vari == "2" } {
		set ::dynamic::theme_status_entry_font [ set ::default_font_$type ]
		set ::dynamic::theme_query_entry_font [ set ::default_font_$type ]
		set ::dynamic::theme_chat_entry_font [ set ::default_font_$type ]
		set ::dynamic::theme_files_entry_font [ set ::default_font_$type ]
		set ::dynamic::theme_channel_entry_font [ set ::default_font_$type ]
		set ::dynamic::theme_main_entry_font [ set ::default_font_$type ]
	}
	if { $::default_temp == "0" } { tk_messageBox -title "Done!" -message "Default $message font has been set" }
}

#### Procedure to set the color values back to default ####

proc proc_default_color { } {
    set ::dynamic::theme_color(0) "#FFFFFF"
    set ::dynamic::theme_color(2) "#00007F"
    set ::dynamic::theme_color(3) "#007F00"
    set ::dynamic::theme_color(4) "#FF0000"
    set ::dynamic::theme_color(5) "#7F0000"
    set ::dynamic::theme_color(6) "#7F007F"
    set ::dynamic::theme_color(7) "#FF7F00"
    set ::dynamic::theme_color(8) "#FFFF00"
    set ::dynamic::theme_color(9) "#00FF00"
    set ::dynamic::theme_color(10) "#007F7F"
    set ::dynamic::theme_color(11) "#00FFFF"
    set ::dynamic::theme_color(12) "#0000FF"
    set ::dynamic::theme_color(13) "#FF00FF"
    set ::dynamic::theme_color(14) "#7F7F7F"
    set ::dynamic::theme_color(15) "#CFCFCF"
}

############################
###### Main Init Code ######
############################

wm title . "QuIRC Style Editor"

#### Some default variables we use around the house ####
set ver 2.01
set ::color(X) "Y"
set ::num 0

# Let's finally get the settings out of QuIRC's default.tcl or our own quedit.tcl
	namespace eval ::temp { }
	namespace eval ::fset { }
	if { [ file exists $::env(HOME)/.quirc/themes/quedit.tcl ] } {
		namespace eval ::dynamic { proc_source }
	} else {
		namespace eval ::dynamic { proc_convert }
	}


#### Setting the menu frame and main window frames ####

frame .menubar -relief raised -borderwidth 1

menubutton .menubar.file -text "File" -menu .menubar.file.menu
pack .menubar.file -side left
	menu .menubar.file.menu -tearoff 0
		.menubar.file.menu add cascade -label "Save" -menu .menubar.file.menu.save
		   menu .menubar.file.menu.save -tearoff 0
			.menubar.file.menu.save add command  -label "Save" -command { proc_save }
			.menubar.file.menu.save add command -label "Save as..." -command { proc_saveas }
		.menubar.file.menu add cascade -label "Load" -menu .menubar.file.menu.load
		   menu .menubar.file.menu.load -tearoff 0
			.menubar.file.menu.load add command -label "Load from..." -command { proc_loadfr }
	                .menubar.file.menu.load add command -label "Reload default.tcl" -command { proc_reload }
			.menubar.file.menu.load add command -label "Reload old QuEdit settings" -command { proc_relold }
			.menubar.file.menu.load add command -label "Load new default.tcl settings" -command { proc_newstyle }
			.menubar.file.menu.load add command -label "Load origional FSET's" -command { proc_origfset }
		.menubar.file.menu add command -label "Exit"  -command { exit }
menubutton .menubar.edit -text "Edit" -menu .menubar.edit.menu
pack .menubar.edit -side left
	menu .menubar.edit.menu -tearoff 0
		.menubar.edit.menu add command -label "Show main status window" -command { proc_main_status }
		.menubar.edit.menu add command -label "Show server window" -command { proc_server }
		.menubar.edit.menu add command -label "Show channel window" -command { proc_channel }
		.menubar.edit.menu add command -label "Show query window" -command { proc_query }
		.menubar.edit.menu add command -label "Show DCC file window" -command { proc_file }
		.menubar.edit.menu add command -label "Show DCC chat window" -command { proc_chat }
		.menubar.edit.menu add separator
		.menubar.edit.menu add command -label "Show banlist window" -command { proc_banlist }
		.menubar.edit.menu add command -label "Show foreground colors" -command { proc_foreg }		
		.menubar.edit.menu add command -label "Show color settings" -command { proc_color }
		.menubar.edit.menu add command -label "Show FSET's menu" -command { proc_fset }
		.menubar.edit.menu add command -label "Show extras menu" -command { proc_extra }
		.menubar.edit.menu add separator
		.menubar.edit.menu add command -label "Global Quickies" -command { proc_global }
menubutton .menubar.help -text "Help" -menu .menubar.help.menu
pack .menubar.help -side right
	menu .menubar.help.menu -tearoff 0
		.menubar.help.menu add command -label "Version" -command { proc_version }
		.menubar.help.menu add command -label "About QuIRC Style Edit" -command { proc_about }
		.menubar.help.menu add command -label "About the File menu" -command { proc_file_about }
		.menubar.help.menu add command -label "About Global Quickies" -command { proc_gq_about }
pack .menubar -side top -fill x -anchor n

wm geometry . 595x395
proc_global

# EOF
