iwidgets::toolbar − Create and manipulate a tool bar iwid‐

gets::toolbar pathName ?options? itk::Widget <‐ iwidgets::Tool‐

3bar

activeBackground activeForeground background borderWidth

cursor disabledForeground font foreground

highlightBackground highlightColor highlightThickness

insertBackground insertForeground orient selectBackground

selectBorderWidth selectForeground state troughColor

9See  the  "options"  manual entry for details on the standard op‐
10tions. For widgets added to the toolbar, these  options  will  be
11propogated  if  the  widget supports the option. For example, all
12widgets that support a font option will be  changed  if  the  the
13toolbar’s font option is configured.
14Name:           balloonBackground
15Class:          BalloonBackground
16Command‐Line Switch:           ‐ballooonbackground
17Specifies  the  background color of the balloon help displayed at
18the bottom center of a widget on the toolbar that has a non empty
19string for its balloonStr option. The default color is yellow.
20Name:           balloonDelay1
21Class:          BalloonDelay1
22Command‐Line Switch:           ‐balloondelay1
23Specifies  the  length  of  time (in milliseconds) to wait before
24initially posting a balloon help hint window. This  delay  is  in
25effect  whenever 1) the mouse leaves the toolbar, or 2) a toolbar
26item is selected with the mouse button.
27Name:           balloonDelay2
28Class:          BalloonDelay2
29Command‐Line Switch:           ‐balloondelay2
30Specifies the length of time (in  milliseconds)  to  wait  before
31continuing  to  post  balloon help hint windows. This delay is in
32effect after the first time a balloon hint window  is  activated.
33It remains in effect until 1) the mouse leaves the toolbar, or 2)
34a toolbar item is selected with the mouse button.
35Name:           balloonFont
36Class:          BalloonFont
37Command‐Line Switch:           ‐balloonfont
38Specifies the font of the balloon help text displayed at the bot‐
39tom center of a widget on the toolbar that has a non empty string
40for its balloonStr option. The default font is 6x10.
41Name:           balloonForeground
42Class:          BalloonForeground
43Command‐Line Switch:           ‐ballooonforeground
44Specifies the foreground color of the balloon help  displayed  at
45the bottom center of a widget on the toolbar that has a non empty
46string for its balloonStr option. The default color is black.
47Name:           helpVariable
48Class:          HelpVariable
49Command‐Line Switch:           ‐helpvariable
50Specifies the global variable to update whenever the mouse is  in
51motion  over  a  toolbar  widget. This global variable is updated
52with the current value of the active widget’s helpStr. Other wid‐
53gets  can  "watch" this variable with the trace command, or as is
54the case  with  entry  or  label  widgets,  they  can  set  their
55textVariable  to the same global variable. This allows for a sim‐
56ple implementation of a  help  status  bar.  Whenever  the  mouse
57leaves  a menu entry, the helpVariable is set to the empty string
58{}.
59Name:           orient
60Class:          Orient
61Command‐Line Switch:           ‐orient
62Specifies the orientation of the toolbar. Must be either horizon‐
63tal  or  vertical.   The  iwidgets::toolbar command creates a new
64window (given by the pathName argument) and makes it into a tool‐

bar widget. Additional options, described above may be specified

66on the command line or in the option database  to  configure  as‐
67pects  of  the toolbar such as its colors, font, and orientation.
68The iwidgets::toolbar command returns its pathName  argument.  At
69the  time  this command is invoked, there must not exist a window
70named pathName, but pathName’s parent must exist.  A toolbar is a
71widget that displays a collection of widgets arranged either in a
72row or a column (depending on the value of the  ‐orient  option).
73This  collection  of  widgets  is usually for user convenience to
74give access to a set of commands or settings. Any widget  may  be
75placed  on a toolbar.  However, command or value‐oriented widgets
76(such as button, radiobutton, etc.) are usually the  most  useful
77kind of widgets to appear on a toolbar.  In addition, the toolbar
78adds two new options to all widgets that are added to  it.  These
79are  the  helpStr  and balloonStr options. See the discussion for
80the widget command add below.
81
82The iwidgets::toolbar command creates a  new  Tcl  command  whose
83name  is pathName. This command may be used to invoke various op‐
84erations on the widget. It has the following general form:  path‐

Name option ?arg arg ...? Option and args determine the exact

86behavior of the command.  Many of the widget commands for a tool‐
87bar take as one argument an indicator of which widget item of the
88toolbar to operate on. The indicator is called an index  and  may
89be  specified in any of the following forms: number Specifies the
90widget numerically, where 0 corresponds to the  first  widget  in
91the  notebook,  1 to the second, and so on. (For horizontal, 0 is
92the leftmost; for vertical, 0 is the topmost).  end Specifes  the
93last  widget in the toolbar’s index. If the toolbar is empty this
94will return ‐1.  last Same as end.  pattern If the index  doesn’t
95satisfy  any  of the above forms, then this form is used. Pattern
96is pattern‐matched against the widgetName of each widget  in  the
97toolbar,  in  order  from  the  first to the last widget, until a
98matching entry is found. An exact match must occur.  The  follow‐
99ing  commands are possible for toolbar widgets: pathName add wid‐

getCommand widgetName ?option value? Adds a widget with the com‐

101mand  widgetCommand  whose  name is widgetName to the toolbar. If
102widgetCommand is  radiobutton  or  checkbutton,  its  packing  is
103slightly padded to match the geometry of button widgets. In addi‐
104tion, the indicatorOn option is false by default and the  select‐
105Color  is  that of the toolbar background by default. This allows
106Radiobutton and Checkbutton widgets to be added as icons by  sim‐
107ply  setting  their  bitmap or image options. If additional argu‐
108ments are present, they are the set of available options that the
109widget  type of widgetCommand supports. In addition they may also
110be one of the following options: ‐helpstr value Specifes the help
111string  to  associate  with the widget. When the mouse moves over
112the widget, the variable denoted by helpVariable is set to  help‐

Str. Another widget can bind to the helpVariable and thus track

114status help.  ‐balloonstr value Specifes the string to display in
115a  balloon  window  for  this widget. A balloon window is a small
116popup window centered at the bottom of the  widget.  Usually  the

balloonStr value is the name of the item on the toolbar. It is

118sometimes known as a hint window.  When the mouse moves  into  an
119item  on  the  toolbar, a timer is set based on the value of bal‐

loonDelay1. If the mouse stays inside the item for balloonDelay1,

121the  balloon  window will pop up displaying the balloonStr value.
122Once the balloon window is posted, a new timer based on  balloon‐

Delay2 is set. This is typically a shorter timer. If the mouse is

124moved to another item, the window is unposted and  a  new  window
125will  be posted over the item if the shorter delay time is satis‐
126fied.  While the balloon window is posted, it can also be unpost‐
127ed  if  the  item is selected. In this case the timer is reset to

balloonDelay1. Whenever the mouse leaves the toolbar, the timer

129is  also  reset  to balloonDelay1.  This window posting/unposting
130model is the same model used in the Windows95 environment.  path‐

Name cget option Returns the current value of the configuration

132option given by option.  pathName configure ?option value?  Query
133or  modify  the configuration options of the widget. If no option
134is specified, returns a list describing all of the available  op‐
135tions  for  pathName (see Tk_ConfigureInfo for information on the
136format of this list). If option is specified with no value,  then
137the  command returns a list describing the one named option (this
138list will be identical to the corresponding sublist of the  value
139returned  if no option is specified). If one or more option‐value
140pairs are specified, then the command modifies the  given  widget
141option(s)  to  have  the given value(s); in this case the command
142returns an empty string.  pathName delete  index  ?index2?   This
143command  deletes all items between index and index2 inclusive. If

index2 is omitted then it defaults to index. Returns an empty

145string.   pathName index index Returns the widget’s numerical in‐
146dex for the entry corresponding to index. If index is not  found,
147‐1  is  returned.  pathName insert beforeIndex widgetCommand wid‐

getName ?option value? Insert a new item named widgetName with

149the  command widgetCommand before the item specified by beforeIn‐

dex. If widgetCommand is radiobutton or checkbutton, its packing

151is  slightly  padded  to match the geometry of button widgets. In
152addition, the indicatorOn option is false by default and the  se‐

lectColor is that of the toolbar background by default. This al‐

154lows Radiobutton and Checkbutton widgets to be added as icons  by
155simply  setting  their bitmap or image options. The set of avail‐
156able options is the same as specified in the ad  command.   path‐

Name itemcget index option Returns the current value of the con‐

158figuration option given by option for index. The item type of in‐

dex determines the valid available options. pathName itemconfig‐

ure index ?option value? Query or modify the configuration op‐

161tions  of the widget of the toolbar specified by index. If no op‐
162tion is specified, returns a list describing all of the available
163options  for  index  (see Tk_ConfigureInfo for information on the
164format of this list). If option is specified with no value,  then
165the  command returns a list describing the one named option (this
166list will be identical to the corresponding sublist of the  value
167returned  if no option is specified). If one or more option‐value
168pairs are specified, then the command modifies the  given  widget
169option(s)  to  have  the given value(s); in this case the command
170returns an empty string. The item type of  index  determines  the
171valid available options. The set of available options is the same
172as specified in the ad command.
173 package require Iwidgets 4.0
174 iwidgets::toolbar .tb ‐helpvariable statusVar
175
176 .tb add button item1 \
177    ‐helpstr "Save It" ‐bitmap @./icons/Tool_32_box.xbm \
178    ‐balloonstr "Save" ‐command {puts 1}
179 .tb add button item2 \
180    ‐helpstr "Save It" ‐bitmap @./icons/Tool_32_brush.xbm \
181    ‐balloonstr "Save" ‐command {puts 1}
182 .tb add button item3 \
183    ‐helpstr "Save It" ‐bitmap @./icons/Tool_32_cut.xbm \
184    ‐balloonstr "Save" ‐command {puts 1}
185 .tb add button item4 \
186    ‐helpstr "Save It" ‐bitmap @./icons/Tool_32_draw.xbm \
187    ‐balloonstr "Save" ‐command {puts 1}
188 .tb add button item5 \
189    ‐bitmap @./icons/Tool_32_erase.xbm ‐helpstr "Play It" \
190    ‐command {puts 2}
191 .tb add frame filler \
192    ‐borderwidth 1 ‐width 10 ‐height 10
193 .tb add radiobutton item6 \
194    ‐bitmap @./icons/Tool_32_oval.xbm ‐command {puts 4} \
195    ‐variable result ‐value OPEN ‐helpstr "Radio Button # 1" \
196    ‐balloonstr "Radio"
197 .tb add radiobutton item7 \
198    ‐bitmap @./icons/Tool_32_line.xbm ‐command {puts 5} \
199    ‐variable result ‐value CLOSED
200 .tb add checkbutton item8 \
201    ‐bitmap @./icons/Tool_32_text.xbm ‐command {puts 6} \
202    ‐variable checkit ‐onvalue yes ‐offvalue no
203 .tb add checkbutton check2 \
204    ‐bitmap @./icons/Tool_32_points.xbm ‐command {puts 7} \
205     ‐variable checkit2 ‐onvalue yes ‐offvalue no
206
207 pack .tb ‐side top ‐anchor nw Bill Scott  toolbar,  button,  ra‐
208diobutton, checkbutton, iwidgets, widget
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
Impressum