# # Copyright 2003 (c) Pointwise, Inc. # All rights reserved. # # This sample Gridgen script is not supported by Pointwise, Inc. # It is provided freely for demonstration purposes only. # SEE THE WARRANTY DISCLAIMER AT THE BOTTOM OF THIS FILE. # gg::tkLoad catch { set scriptDir [file dirname [info script]] source [file join $scriptDir pwiLogo.glf] } ###################################################################### # PROC: CreateLabelFrame # Creates a fancy label frame widget # Returns the new frame # proc CreateLabelFrame {w args} { frame $w -bd 0 label $w.l frame $w.f -bd 2 -relief groove frame $w.f.spc -height 2 pack $w.f.spc frame $w.f.f pack $w.f.f set text {} set font {} set padx 3 set pady 7 set ipadx 2 set ipady 3 foreach {tag value} $args { switch -- $tag { -font {set font $value} -text {set text $value} -padx {set padx $value} -pady {set pady $value} -ipadx {set ipadx $value} -ipady {set ipady $value} -bd {$w.f config -bd $value} -relief {$w.f config -relief $value} } } if {"$font"!=""} { $w.l config -font $font } $w.l config -text $text pack $w.f -padx $padx -pady $pady -fill both -expand 1 place $w.l -x [expr $padx+10] -y $pady -anchor w pack $w.f.f -padx $ipadx -pady $ipady -fill both -expand 1 raise $w.l return $w.f.f } set gridgenDefaults {{230 60 135} {0 95 0} {255 69 0} {0 0 175} {255 215 0} {125 0 0} {145 0 255}} set iniBGColor [gg::dispBGColor] set bgcolor $iniBGColor set tred 0 set tgreen 0 set tblue 0 scan [gg::dispColor 0] #%02x%02x%02x tred tgreen tblue set allDefaults "{$tred $tgreen $tblue}" for {set i 1} { $i < 7 } { incr i } { scan [lindex [gg::dispColor $i] 0] #%02x%02x%02x tred tgreen tblue set allDefaults "$allDefaults {$tred $tgreen $tblue}" } proc restoreDefaults { var } { global $var foreach i {0 1 2 3 4 5 6} { gg::dispColor $i [lindex [set $var] $i] set tcolor [format #%02x%02x%02x [lindex [lindex [set $var] $i] 0] [lindex [lindex [set $var] $i] 1] [lindex [lindex [set $var] $i] 2]] set tcolor [string toupper $tcolor] .colorSample$i configure -background $tcolor } if { $var == "allDefaults" } { global iniBGColor gg::dispBGColor $iniBGColor } else { gg::dispBGColor BLACK } global bgcolor set bgcolor [gg::dispBGColor] } proc colorClick { index } { set tcolor [tk_chooseColor -title "Select Color - [expr $index+1]" -initialcolor [gg::dispColor $index]] if { $tcolor != "" } { gg::dispColor $index $tcolor .colorSample$index configure -background $tcolor } } proc makeWindow {} { label .title -text "Gridgen Color Palette" set font [.title cget -font] .title configure -font [font create -family [font actual $font -family] -weight bold] pack .title -expand 1 -side top pack [frame .hr1 -bd 1 -height 2 -relief sunken] -fill x -pady 2 set parent . pack [frame .content] -side top -fill x pack [frame .left] -in .content -side left -fill both pack [frame .right] -in .content -side right -fill both foreach i {0 1 2 3 4 5 6} { frame .colorChoice$i -borderwidth 1 -relief solid pack [label .colorNumber$i -text "[expr $i+1]:"] -in .colorChoice$i -side left pack [button .colorSample$i -width 20 -command "colorClick $i"] -in .colorChoice$i -padx 2 -pady 2 -fill both -side right .colorSample$i configure -background [gg::dispColor $i] if { $i > 3 } { pack .colorChoice$i -in .right -side top -ipadx 3 -padx 5 -pady 2 -fill x } else { pack .colorChoice$i -in .left -side top -ipadx 3 -padx 5 -pady 2 -fill x } # bind .colorSample$i "colorClick $i" } set frm [CreateLabelFrame .lblfrm -text "Background Color" -relief solid -bd 1] pack .lblfrm -side top -in .right # pack [frame .bgSelection -borderwidth 1 -relief solid] -fill x -padx 25 -pady 3 # pack [label .lbl1 -text "Background Color"] -in .bgSelection -side left pack [radiobutton .bgWhite -text "White" -command {gg::dispBGColor WHITE} -variable bgcolor -value WHITE] -in $frm -side right -pady 1 pack [radiobutton .bgBlack -text "Black" -command {gg::dispBGColor BLACK} -variable bgcolor -value BLACK] -in $frm -side right -pady 1 pack [frame .hr2 -bd 1 -height 2 -relief sunken] -fill x -pady 2 frame .buttons pack [button .buttons.restoredef -text "Defaults" -command { restoreDefaults gridgenDefaults }] -side right -padx 3 pack [button .buttons.cancel -text "Cancel" -command { restoreDefaults allDefaults; exit; }] -side right -padx 3 pack [button .buttons.ok -text "OK" -command { exit }] -side right -padx 3 if {![catch {pwiLogoCreate .buttons.logo 1} b]} { $b configure -bd 0 -relief flat pack $b -side left -padx 5 -fill y } pack .buttons -fill x -side bottom -padx 2 -pady 1 } makeWindow ::tk::PlaceWindow . widget gg::tkLoop # # DISCLAIMER: # TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, POINTWISE DISCLAIMS # ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED # TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE, WITH REGARD TO THIS SCRIPT. TO THE MAXIMUM EXTENT PERMITTED # BY APPLICABLE LAW, IN NO EVENT SHALL POINTWISE BE LIABLE TO ANY PARTY # FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES # WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF # BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE # USE OF OR INABILITY TO USE THIS SCRIPT EVEN IF POINTWISE HAS BEEN # ADVISED OF THE POSSIBILITY OF SUCH DAMAGES AND REGARDLESS OF THE # FAULT OR NEGLIGENCE OF POINTWISE. #