4 # --------------------------------------------------------------------------
5 # Starting with Tcl 8.x, the BLT commands are stored in their own
6 # namespace called "blt". The idea is to prevent name clashes with
7 # Tcl commands and variables from other packages, such as a "table"
8 # command in two different packages.
10 # You can access the BLT commands in a couple of ways. You can prefix
11 # all the BLT commands with the namespace qualifier "blt::"
14 # blt::table . .g -fill both
16 # or you can import all the command into the global namespace.
18 # namespace import blt::*
20 # table . .g -fill both
22 # --------------------------------------------------------------------------
24 if { $tcl_version >= 8.0 } {
25 namespace import blt::*
26 # namespace import -force blt::tile::*
28 #source scripts/demo.tcl
31 # Script to test the "busy" command.
35 # General widget class resource attributes
37 option add *Button.padX 10
38 option add *Button.padY 2
39 option add *Scale.relief sunken
40 #option add *Scale.orient horizontal
41 option add *Entry.relief sunken
42 option add *Frame.borderWidth 2
44 set visual [winfo screenvisual .]
45 if { $visual == "staticgray" || $visual == "grayscale" } {
50 option add *f1.background white
53 set normalBg springgreen
56 option add *Button.background khaki2
57 option add *Button.activeBackground khaki1
58 option add *Frame.background khaki2
59 option add *f2.tile textureBg
60 # option add *Button.tile textureBg
62 option add *releaseButton.background limegreen
63 option add *releaseButton.activeBackground springgreen
64 option add *releaseButton.foreground black
66 option add *holdButton.background red
67 option add *holdButton.activeBackground pink
68 option add *holdButton.foreground black
69 option add *f1.background springgreen
73 # Instance specific widget options
75 option add *f1.relief sunken
76 option add *f1.background $normalBg
77 option add *testButton.text "Test"
78 option add *quitButton.text "Quit"
79 option add *newButton.text "New button"
80 option add *holdButton.text "Hold"
81 option add *releaseButton.text "Release"
82 option add *buttonLabel.text "Buttons"
83 option add *entryLabel.text "Entries"
84 option add *scaleLabel.text "Scales"
85 option add *textLabel.text "Text"
90 proc KeepRaised { w } {
91 bindtags $w keepRaised
94 bind keepRaised <Visibility> { raise %W }
96 set file ./images/chalk.gif
97 image create photo textureBg -file $file
100 # This never gets used; it's reset by the Animate proc. It's
101 # here to just demonstrate how to set busy window options via
102 # the host window path name
104 #option add *f1.busyCursor bogosity
108 # Counter for new buttons created by the "New button" button
113 .menu add command -label "First"
114 .menu add command -label "Second"
115 .menu add command -label "Third"
116 .menu add command -label "Fourth"
117 . configure -menu .menu
120 # Create two frames. The top frame will be the host window for the
121 # busy window. It'll contain widgets to test the effectiveness of
122 # the busy window. The bottom frame will contain buttons to
123 # control the testing.
129 # Create some widgets to test the busy window and its cursor
132 button .testButton -command {
133 puts stdout "Not busy."
135 button .quitButton -command { exit }
138 text .text -width 20 -height 4
141 # The following buttons sit in the lower frame to control the demo
143 button .newButton -command {
146 set name button#${numWin}
147 button .f1.$name -text "$name" \
148 -command [list .f1 configure -bg blue]
150 .f1.$name $numWin+3,0 -padx 10 -pady 10
153 button .holdButton -command {
154 if { [busy isbusy .f1] == "" } {
156 .f1 configure -bg $activeBg
162 button .releaseButton -command {
163 if { [busy isbusy .f1] == ".f1" } {
168 .f1 configure -bg $normalBg
172 # Notice that the widgets packed in .f1 and .f2 are not their children
178 .text 1,1 -fill both \
186 table configure .f1 .testButton .scale .entry .quitButton -padx 10 -pady 10 -fill both
187 table configure .f2 .newButton .holdButton .releaseButton -padx 10 -pady 10
188 table configure .f2 c0 -resize none
190 # Finally, realize and map the top level window
196 table configure . .f1 .f2 -fill both
197 # Initialize a list of bitmap file names which make up the animated
198 # fish cursor. The bitmap mask files have a "m" appended to them.
200 table configure . r1 -resize none
202 set bitmapList { left left1 mid right1 right }
205 # Simple cursor animation routine: Uses the "after" command to
206 # circulate through a list of cursors every 0.075 seconds. The
207 # first pass through the cursor list may appear sluggish because
208 # the bitmaps have to be read from the disk. Tk's cursor cache
209 # takes care of it afterwards.
211 proc StartAnimation { widget count } {
213 set prefix "bitmaps/fish/[lindex $bitmapList $count]"
214 set cursor [list @${prefix}.xbm ${prefix}m.xbm black white ]
215 busy configure $widget -cursor $cursor
218 set limit [llength $bitmapList]
219 if { $count >= $limit } {
223 set afterId($widget) [after 125 StartAnimation $widget $count]
226 proc StopAnimation { widget } {
228 after cancel $afterId($widget)
231 proc TranslateBusy { window } {
232 #set widget [string trimright $window "_Busy"]
233 set widget [string trimright $window "Busy"]
234 set widget [string trimright $widget "_"]
235 # if { [winfo toplevel $widget] != $widget } {
236 # set widget [string trimright $widget "."]
241 if { [info exists tcl_platform] && $tcl_platform(platform) == "unix" } {
243 StartAnimation [TranslateBusy %W] 0
246 StopAnimation [TranslateBusy %W]
251 # For testing, allow the top level window to be resized
256 # Force the demo to stay raised