Bwidget Source Code
Check-in [02459eb6f9]
Not logged in
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Theming support for Button widget
Timelines: family | ancestors | descendants | both | bwidget
Files: files | file ages | folders
SHA1: 02459eb6f9d61faef49879463c659ce2cabacd5e
User & Date: oehhar 2010-11-21 17:25:54
Context
2010-11-21
19:35
Add theming support for label widget check-in: 927ec26cfe user: oehhar tags: bwidget
17:25
Theming support for Button widget check-in: 02459eb6f9 user: oehhar tags: bwidget
2010-11-10
07:56
tree.tcl (Tree::itemconfigure): Fix intermingling of node names and flag values which can cause an lsearch to fail, by mistaking a flag value as the node searched for, and then treating a node name as flags. As the upd,nodes value is a dictionary it should not be search as a list. Now using a temporary array for quicker check and append/replace [Bug 3106208]. (report and fix by Andreas Kupries) check-in: 5018ffa91f user: oehhar tags: bwidget
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to BWman/Button.html.

7
8
9
10
11
12
13

14
15
16
17
18
19
20
..
55
56
57
58
59
60
61





















62
63
64
65
66
67
68
...
157
158
159
160
161
162
163
164

165
166
167
168
169
170
171
...
193
194
195
196
197
198
199
200


201
202
203
204
205
206
207
...
265
266
267
268
269
270
271

272








273
</DD></DL>
<DL>
<DT><I>CREATION</I></DT>
<DD><A HREF="#descr"><B>Button</B></A> <I>pathName</I> ?<I>option value...</I>?</DD>
</DL>
<DL>
<DT><I>STANDARD OPTIONS</I></DT>

<DD><TABLE CELLSPACING=0 CELLSPACING=0 BORDER=0>
<TR>
<TD>&nbsp;&nbsp;<A HREF="options.htm#M-activebackground">-activebackground</A></TD>
<TD>&nbsp;&nbsp;<A HREF="options.htm#M-activeforeground">-activeforeground</A></TD>
</TR>
<TR>
<TD>&nbsp;&nbsp;<A HREF="options.htm#M-anchor">-anchor</A></TD>
................................................................................
<TR>
<TD>&nbsp;&nbsp;<A HREF="options.htm#M-text">-text</A></TD>
<TD>&nbsp;&nbsp;<A HREF="options.htm#M-textvariable">-textvariable</A></TD>
</TR>
<TR>
<TD>&nbsp;&nbsp;<A HREF="options.htm#M-wraplength">-wraplength</A></TD>
</TABLE></DD>





















</DL>
<DL>
<DT><I><A HREF="#wso">WIDGET-SPECIFIC OPTIONS</A></I></DT>
<DD><TABLE CELLSPACING=0 CELLSPACING=0 BORDER=0>
<TR>
<TD>&nbsp;&nbsp;<A HREF="#-armcommand">-armcommand</A></TD>
<TD>&nbsp;&nbsp;<A HREF="#-command">-command</A></TD>
................................................................................
<DD>

Specifies a desired height for the Button.
If an image or bitmap is being displayed in the Button then the value is in
screen units;
for text it is in lines of text.
If this option isn't specified, the Button's desired height is computed
from the size of the image or bitmap or text being displayed in it.

</DD>
</DL>
<DL><DT><A NAME="-helptext"><B>-helptext</B></A></DT>
<DD>

Text for dynamic help. If empty, no help is available for this widget.
See also <A HREF="DynamicHelp.html">DynamicHelp</A>.
................................................................................
</DD>
</DL>
<DL><DT><A NAME="-relief"><B>-relief</B></A></DT>
<DD>

Specifies the 3-D effect desired for the widget. Acceptable values are standard values for
button relief (<B>raised</B>, <B>sunken</B>, <B>flat</B>, <B>ridge</B>, <B>solid</B>, and <B>groove</B>) and <B>link</B>, which specifies that button relief is <B>flat</B> when pointer
is outside the button and <B>raised</B> when pointer is inside.


</DD>
</DL>
<DL><DT><A NAME="-state"><B>-state</B></A></DT>
<DD>

Specifies one of three states for the Button:  <B>normal</B>, <B>active</B>,
or <B>disabled</B>.  In normal state the Button is displayed using the
................................................................................

If Button <B>state</B> is not disabled, this invoke the commands of the Button.
Button is redisplayed with active color and sunken relief, and
<B>armcommand</B> is called. Then Button is redisplayed with
normal color and its defined relief, and <B>disarmcommand</B> then <B>command</B>
are called.
<P><B>invoke</B> is called when Button has input focus and user press the space bar.

</DD></DL>








</BODY></HTML>






>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|
>







 







|
>
>







 







>

>
>
>
>
>
>
>
>

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
...
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
...
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
...
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
</DD></DL>
<DL>
<DT><I>CREATION</I></DT>
<DD><A HREF="#descr"><B>Button</B></A> <I>pathName</I> ?<I>option value...</I>?</DD>
</DL>
<DL>
<DT><I>STANDARD OPTIONS</I></DT>
<DT><I>Not themed</I></DT>
<DD><TABLE CELLSPACING=0 CELLSPACING=0 BORDER=0>
<TR>
<TD>&nbsp;&nbsp;<A HREF="options.htm#M-activebackground">-activebackground</A></TD>
<TD>&nbsp;&nbsp;<A HREF="options.htm#M-activeforeground">-activeforeground</A></TD>
</TR>
<TR>
<TD>&nbsp;&nbsp;<A HREF="options.htm#M-anchor">-anchor</A></TD>
................................................................................
<TR>
<TD>&nbsp;&nbsp;<A HREF="options.htm#M-text">-text</A></TD>
<TD>&nbsp;&nbsp;<A HREF="options.htm#M-textvariable">-textvariable</A></TD>
</TR>
<TR>
<TD>&nbsp;&nbsp;<A HREF="options.htm#M-wraplength">-wraplength</A></TD>
</TABLE></DD>
<DT><I>Themed</I></DT>
<DD><TABLE CELLSPACING=0 CELLSPACING=0 BORDER=0>
<TR>
<TD>&nbsp;&nbsp;<A HREF="options.htm#M-compound">-compound</A></TD>
<TD>&nbsp;&nbsp;<A HREF="options.htm#M-cursor">-cursor</A></TD>
</TR>
<TR>
<TD>&nbsp;&nbsp;<A HREF="options.htm#M-image">-image</A></TD>
<TD>&nbsp;&nbsp;<A HREF="options.htm#M-style">-style</A></TD>
</TR>
<TR>
<TD>&nbsp;&nbsp;<A HREF="options.htm#M-repeatdelay">-repeatdelay</A></TD>
<TD>&nbsp;&nbsp;<A HREF="options.htm#M-repeatinterval">-repeatinterval</A></TD>
</TR>
<TR>
<TD>&nbsp;&nbsp;<A HREF="options.htm#M-takefocus">-takefocus</A></TD>
<TD>&nbsp;&nbsp;<A HREF="options.htm#M-text">-text</A></TD>
</TR>
<TR>
<TD>&nbsp;&nbsp;<A HREF="options.htm#M-textvariable">-textvariable</A></TD>
</TABLE></DD>
</DL>
<DL>
<DT><I><A HREF="#wso">WIDGET-SPECIFIC OPTIONS</A></I></DT>
<DD><TABLE CELLSPACING=0 CELLSPACING=0 BORDER=0>
<TR>
<TD>&nbsp;&nbsp;<A HREF="#-armcommand">-armcommand</A></TD>
<TD>&nbsp;&nbsp;<A HREF="#-command">-command</A></TD>
................................................................................
<DD>

Specifies a desired height for the Button.
If an image or bitmap is being displayed in the Button then the value is in
screen units;
for text it is in lines of text.
If this option isn't specified, the Button's desired height is computed
from the size of the image or bitmap or text being displayed in it.<BR>
Option not available when widget is <I>themed</I>.
</DD>
</DL>
<DL><DT><A NAME="-helptext"><B>-helptext</B></A></DT>
<DD>

Text for dynamic help. If empty, no help is available for this widget.
See also <A HREF="DynamicHelp.html">DynamicHelp</A>.
................................................................................
</DD>
</DL>
<DL><DT><A NAME="-relief"><B>-relief</B></A></DT>
<DD>

Specifies the 3-D effect desired for the widget. Acceptable values are standard values for
button relief (<B>raised</B>, <B>sunken</B>, <B>flat</B>, <B>ridge</B>, <B>solid</B>, and <B>groove</B>) and <B>link</B>, which specifies that button relief is <B>flat</B> when pointer
is outside the button and <B>raised</B> when pointer is inside.<BR>
This option has only the following effect if the widget is <I>themed</I>:
The value <B>link</B> used a style <B>Toolbutton</B> while any other value uses the standard effect.
</DD>
</DL>
<DL><DT><A NAME="-state"><B>-state</B></A></DT>
<DD>

Specifies one of three states for the Button:  <B>normal</B>, <B>active</B>,
or <B>disabled</B>.  In normal state the Button is displayed using the
................................................................................

If Button <B>state</B> is not disabled, this invoke the commands of the Button.
Button is redisplayed with active color and sunken relief, and
<B>armcommand</B> is called. Then Button is redisplayed with
normal color and its defined relief, and <B>disarmcommand</B> then <B>command</B>
are called.
<P><B>invoke</B> is called when Button has input focus and user press the space bar.

</DD></DL>
<HR WIDTH="50%"><BR>
<B><A NAME="wc">BINDINGS</A></B><BR>
<DL><DT><A NAME="Invoke"><I>&lt;&lt;Invoke&gt;&gt;</I></A>
</DT><DD>

Invoke the <B>invoke</B> widget command.
</DD></DL>
<HR WIDTH="50%"><BR>
</BODY></HTML>

Changes to BWman/ButtonBox.html.

99
100
101
102
103
104
105
106

107
108
109
110
111
112
113
...
135
136
137
138
139
140
141
142
143

144
145
146
147
148
149

150
151
152
153
154
155
156
</P>
<BR><HR WIDTH="50%"><BR>
<B><A NAME="wso">WIDGET-SPECIFIC OPTIONS</A></B><BR>
<DL><DT><A NAME="-background"><B>-background</B></A></DT>
<DD>

Specifies a default background color for all added buttons and for the frame.


</DD>
</DL>
<DL><DT><A NAME="-default"><B>-default</B></A></DT>
<DD>

Specifies the default button of the button box. The value is an integer
................................................................................
If this option is <B>vertical</B>, buttons are added from left to right.

</DD>
</DL>
<DL><DT><A NAME="-padx"><B>-padx</B></A></DT>
<DD>

Specifies a default value for the -padx option of all added buttons.


</DD>
</DL>
<DL><DT><A NAME="-pady"><B>-pady</B></A></DT>
<DD>

Specifies a default value for the -pady option of all added buttons.


</DD>
</DL>
<DL><DT><A NAME="-spacing"><B>-spacing</B></A></DT>
<DD>

Specifies the default spacing between buttons. This value can be changed before each






|
>







 







|
<
>





|
>







99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
...
136
137
138
139
140
141
142
143

144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
</P>
<BR><HR WIDTH="50%"><BR>
<B><A NAME="wso">WIDGET-SPECIFIC OPTIONS</A></B><BR>
<DL><DT><A NAME="-background"><B>-background</B></A></DT>
<DD>

Specifies a default background color for all added buttons and for the frame.<BR>
For <I>themed</I> wigets, the button color is not set.

</DD>
</DL>
<DL><DT><A NAME="-default"><B>-default</B></A></DT>
<DD>

Specifies the default button of the button box. The value is an integer
................................................................................
If this option is <B>vertical</B>, buttons are added from left to right.

</DD>
</DL>
<DL><DT><A NAME="-padx"><B>-padx</B></A></DT>
<DD>

Specifies a default value for the -padx option of all added buttons.<BR>

Option has no effect for <I>themed</I> wigets.
</DD>
</DL>
<DL><DT><A NAME="-pady"><B>-pady</B></A></DT>
<DD>

Specifies a default value for the -pady option of all added buttons.<BR>
Option has no effect for <I>themed</I> wigets.

</DD>
</DL>
<DL><DT><A NAME="-spacing"><B>-spacing</B></A></DT>
<DD>

Specifies the default spacing between buttons. This value can be changed before each

Changes to BWman/Dialog.html.

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
...
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<DD><TABLE CELLSPACING=0 CELLSPACING=0 BORDER=0>
<TR>
<TD>&nbsp;&nbsp;<A HREF="#-anchor">-anchor</A></TR>
<TD>&nbsp;&nbsp;<A HREF="#-bitmap">-bitmap</A></TR>
</TR>
<TR>

<TD>&nbsp;&nbsp;<A HREF="#-buttonwidth">-buttonwidth</A></TR>
<TD>&nbsp;&nbsp;<A HREF="#-cancel">-cancel</A></TR>
</TR>
<TR>
<TD>&nbsp;&nbsp;<A HREF="#-default">-default</A></TR>
<TD>&nbsp;&nbsp;<A HREF="#-geometry">-geometry</A></TR>
</TR>
<TR>
<TD>&nbsp;&nbsp;<A HREF="#-image">-image</A></TR>
................................................................................
</DL>
<DL><DT><A NAME="-bitmap"><B>-bitmap (read-only)</B></A></DT>
<DD>

Specifies a bitmap to display at the left of the user frame.
<B>image</B> option override <B>bitmap</B>.
</DD>
</DL>
<DL><DT><A NAME="-buttonwidth"><B>-buttonwidth (read-only)</B></A></DT>
<DD>

Specifies the width of the buttons as specified for the option <B>width</B>
of the <B>button</b> widget.
</DD>
</DL>
<DL><DT><A NAME="-cancel"><B>-cancel</B></A></DT>
<DD>

Specifies the number of the cancel button of the Dialog. When user presses Esc or the windows close button,
this button is invoked.<BR>
If set to <B>-1</B>, Esc does not invoke anything.






<
|







 







<
<
<
<
<
<
<







29
30
31
32
33
34
35

36
37
38
39
40
41
42
43
...
133
134
135
136
137
138
139







140
141
142
143
144
145
146
<DD><TABLE CELLSPACING=0 CELLSPACING=0 BORDER=0>
<TR>
<TD>&nbsp;&nbsp;<A HREF="#-anchor">-anchor</A></TR>
<TD>&nbsp;&nbsp;<A HREF="#-bitmap">-bitmap</A></TR>
</TR>
<TR>


<TD>&nbsp;&nbsp;<A HREF="#-cancel">-cancel</A></TD>
</TR>
<TR>
<TD>&nbsp;&nbsp;<A HREF="#-default">-default</A></TR>
<TD>&nbsp;&nbsp;<A HREF="#-geometry">-geometry</A></TR>
</TR>
<TR>
<TD>&nbsp;&nbsp;<A HREF="#-image">-image</A></TR>
................................................................................
</DL>
<DL><DT><A NAME="-bitmap"><B>-bitmap (read-only)</B></A></DT>
<DD>

Specifies a bitmap to display at the left of the user frame.
<B>image</B> option override <B>bitmap</B>.
</DD>







</DL>
<DL><DT><A NAME="-cancel"><B>-cancel</B></A></DT>
<DD>

Specifies the number of the cancel button of the Dialog. When user presses Esc or the windows close button,
this button is invoked.<BR>
If set to <B>-1</B>, Esc does not invoke anything.

Changes to ChangeLog.











1
2
3
4
5
6
7









2010-11-09  Andreas Kupries  <[email protected]>

	* tree.tcl (Tree::itemconfigure): Fix intermingling of node names
	and flag values which can cause an lsearch to fail, by mistaking a
	flag value as the node searched for, and then treating a node name
	as flags. As the upd,nodes value is a dictionary it should not be
	search as a list. Now using a temporary array for quicker check
>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2010-11-16 Harald Oehlmann <[email protected]>

	* button.tcl Add theming support for Button widget.
	Option "-relief link" is mapped to "Toolbutton style.
	Option -height is not available when themed.
	Thanks to Kevin Walzer for the test on MacOS.
	* buttonbox.tcl When themed, only set themed button options.
	The widget itself is not jet themed.
	* Dialog.html Removed documentation of unavailable option -buttonwidth.

2010-11-09  Andreas Kupries  <[email protected]>

	* tree.tcl (Tree::itemconfigure): Fix intermingling of node names
	and flag values which can cause an lsearch to fail, by mistaking a
	flag value as the node searched for, and then treating a node name
	as flags. As the upd,nodes value is a dictionary it should not be
	search as a list. Now using a temporary array for quicker check

Changes to button.tcl.

49
50
51
52
53
54
55

56
57
58
59
60
61
62
63
64
65



66

67
68
69
70
71
72
73
74
75
76
77
78
79
80
..
86
87
88
89
90
91
92
93
94












95
96
97
98
99
100
101
...
119
120
121
122
123
124
125
126
127
128
129

130






131
132
133
134
135
136
137
138

139

140
141
142
143
144
145
146
147
148
149
150
...
173
174
175
176
177
178
179
























180
181
182
183
184
185




186

187
188
189
190
191
192




193
194
195
196
197
198
199

200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221



222
223
224
225

226
227
228
229
230
231
232
...
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
265
266
267
268
269
270
...
280
281
282
283
284
285
286
287
288




289
290
291
292

293
294
295
296
297
298
299
    bind BwButton <Enter>           {Button::_enter %W}
    bind BwButton <Leave>           {Button::_leave %W}
    bind BwButton <ButtonPress-1>   {Button::_press %W}
    bind BwButton <ButtonRelease-1> {Button::_release %W}
    bind BwButton <Key-space>       {Button::invoke %W; break}
    bind BwButton <Return>          {Button::invoke %W; break}

    bind BwButton <Destroy>         {Widget::destroy %W}
}


# ----------------------------------------------------------------------------
#  Command Button::create
# ----------------------------------------------------------------------------
proc Button::create { path args } {
    array set maps [list Button {} :cmd {}]
    array set maps [Widget::parseArgs Button $args]



    eval [concat [list button $path] $maps(:cmd)]

    Widget::initFromODB Button $path $maps(Button)

    # Do some extra configuration on the button
    set relief [Widget::getMegawidgetOption $path -relief]
    if { [string equal $relief "link"] } {
        set relief "flat"
    }
    set var [Widget::getMegawidgetOption $path -textvariable]
    set st [Widget::getMegawidgetOption $path -state]
    if {  ![string length $var] } {
        set desc [BWidget::getname [Widget::getMegawidgetOption $path -name]]
        if { [llength $desc] } {
            set text  [lindex $desc 0]
            set under [lindex $desc 1]
................................................................................
        }
    } else {
        set under -1
        set text  ""
        Widget::configure $path [list -underline $under]
    }

    $path configure -relief $relief -text $text -underline $under \
	    -textvariable $var -state $st












    bindtags $path [list $path BwButton [winfo toplevel $path] all]

    set accel1 [string tolower [string index $text $under]]
    set accel2 [string toupper $accel1]
    if { $accel1 != "" } {
        bind [winfo toplevel $path] <Alt-$accel1> [list Button::invoke $path]
        bind [winfo toplevel $path] <Alt-$accel2> [list Button::invoke $path]
................................................................................
        set oldaccel1 ""
        set oldaccel2 ""
    }
    set res [Widget::configure $path $args]

    # Extract all the modified bits we're interested in
    foreach {cr cs cv cn ct cu} [Widget::hasChangedX $path \
	    -relief -state -textvariable -name -text -underline] break
    if { $cr || $cs } {
	set relief [Widget::cget $path -relief]
	set state  [Widget::cget $path -state]

        if { [string equal $relief "link"] } {






            if { [string equal $state "active"] } {
                set relief "raised"
            } else {
                set relief "flat"
            }
        }
        $path:cmd configure -relief $relief -state $state
    }



    if { $cv || $cn || $ct || $cu } {
	set var		[Widget::cget $path -textvariable]
	set text	[Widget::cget $path -text]
	set under	[Widget::cget $path -underline]
        if {  ![string length $var] } {
            set desc [BWidget::getname [Widget::cget $path -name]]
            if { [llength $desc] } {
                set text  [lindex $desc 0]
                set under [lindex $desc 1]
            }
        } else {
................................................................................
# ----------------------------------------------------------------------------
#  Command Button::cget
# ----------------------------------------------------------------------------
proc Button::cget { path option } {
    Widget::cget $path $option
}


























# ----------------------------------------------------------------------------
#  Command Button::invoke
# ----------------------------------------------------------------------------
proc Button::invoke { path } {
    if { ![string equal [$path:cmd cget -state] "disabled"] } {




	$path:cmd configure -state active -relief sunken

	update idletasks
	set cmd [Widget::getMegawidgetOption $path -armcommand]
        if { $cmd != "" } {
            uplevel \#0 $cmd
        }
	after 100




        set relief [Widget::getMegawidgetOption $path -relief]
        if { [string equal $relief "link"] } {
            set relief flat
        }
	$path:cmd configure \
            -state  [Widget::getMegawidgetOption $path -state] \
            -relief $relief

	set cmd [Widget::getMegawidgetOption $path -disarmcommand]
        if { $cmd != "" } {
            uplevel \#0 $cmd
        }
	set cmd [Widget::getMegawidgetOption $path -command]
        if { $cmd != "" } {
            uplevel \#0 $cmd
        }
    }
}


# ----------------------------------------------------------------------------
#  Command Button::_enter
# ----------------------------------------------------------------------------
proc Button::_enter { path } {
    variable _current
    variable _pressed

    set _current $path
    if { ![string equal [$path:cmd cget -state] "disabled"] } {
        $path:cmd configure -state active



        if { $_pressed == $path } {
            $path:cmd configure -relief sunken
        } elseif { [string equal [Widget::cget $path -relief] "link"] } {
            $path:cmd configure -relief raised

        }
    }
}


# ----------------------------------------------------------------------------
#  Command Button::_leave
................................................................................
proc Button::_leave { path } {
    variable _current
    variable _pressed

    set _current ""
    if { ![string equal [$path:cmd cget -state] "disabled"] } {
        $path:cmd configure -state [Widget::cget $path -state]


        set relief [Widget::cget $path -relief]
        if { $_pressed == $path } {
            if { [string equal $relief "link"] } {
                set relief raised
            }
            $path:cmd configure -relief $relief
        } elseif { [string equal $relief "link"] } {
            $path:cmd configure -relief flat

        }
    }
}


# ----------------------------------------------------------------------------
#  Command Button::_press
# ----------------------------------------------------------------------------
proc Button::_press { path } {
    variable _pressed

    if { ![string equal [$path:cmd cget -state] "disabled"] } {
        set _pressed $path




	$path:cmd configure -relief sunken

	set cmd [Widget::getMegawidgetOption $path -armcommand]
        if { $cmd != "" } {
            uplevel \#0 $cmd
	    set repeatdelay [Widget::getMegawidgetOption $path -repeatdelay]
	    set repeatint [Widget::getMegawidgetOption $path -repeatinterval]
            if { $repeatdelay > 0 } {
                after $repeatdelay "Button::_repeat $path"
            } elseif { $repeatint > 0 } {
................................................................................
# ----------------------------------------------------------------------------
proc Button::_release { path } {
    variable _current
    variable _pressed

    if { $_pressed == $path } {
        set _pressed ""
        set relief [Widget::getMegawidgetOption $path -relief]
	after cancel "Button::_repeat $path"




        if { [string equal $relief "link"] } {
            set relief raised
        }
        $path:cmd configure -relief $relief

	set cmd [Widget::getMegawidgetOption $path -disarmcommand]
        if { $cmd != "" } {
            uplevel \#0 $cmd
        }
        if { $_current == $path &&
             ![string equal [$path:cmd cget -state] "disabled"] && \
	     [set cmd [Widget::getMegawidgetOption $path -command]] != "" } {






>










>
>
>
|
>



<
<
<
<







 







|
|
>
>
>
>
>
>
>
>
>
>
>
>







 







|

|
|
>
|
>
>
>
>
>
>
|
|
|
|
|
|
|
|
>
|
>

|
|
|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






>
>
>
>
|
>
|
|



|
>
>
>
>
|
|
|
|
|
<
<
>
|



|





<











>
>
>
|
|
|
|
>







 







>
>
|
|
|
|
|
|
|
|
>













>
>
>
>
|
>
|







 







<

>
>
>
>
|
|
|
|
>







49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74




75
76
77
78
79
80
81
..
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
...
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
...
195
196
197
198
199
200
201
202
203
204
205
206
207
208
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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
...
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
...
345
346
347
348
349
350
351

352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
    bind BwButton <Enter>           {Button::_enter %W}
    bind BwButton <Leave>           {Button::_leave %W}
    bind BwButton <ButtonPress-1>   {Button::_press %W}
    bind BwButton <ButtonRelease-1> {Button::_release %W}
    bind BwButton <Key-space>       {Button::invoke %W; break}
    bind BwButton <Return>          {Button::invoke %W; break}
    bind BwButton <<Invoke>> 	    {Button::invoke %W; break}
    bind BwButton <Destroy>         {Widget::destroy %W}
}


# ----------------------------------------------------------------------------
#  Command Button::create
# ----------------------------------------------------------------------------
proc Button::create { path args } {
    array set maps [list Button {} :cmd {}]
    array set maps [Widget::parseArgs Button $args]
    if {$::Widget::_theme} {
        eval [concat [list ttk::button $path] $maps(:cmd)]
    } else {
        eval [concat [list button $path] $maps(:cmd)]
    }
    Widget::initFromODB Button $path $maps(Button)

    # Do some extra configuration on the button




    set var [Widget::getMegawidgetOption $path -textvariable]
    set st [Widget::getMegawidgetOption $path -state]
    if {  ![string length $var] } {
        set desc [BWidget::getname [Widget::getMegawidgetOption $path -name]]
        if { [llength $desc] } {
            set text  [lindex $desc 0]
            set under [lindex $desc 1]
................................................................................
        }
    } else {
        set under -1
        set text  ""
        Widget::configure $path [list -underline $under]
    }

    $path configure -text $text -underline $under \
        -textvariable $var -state $st
    # Map relief flat on Toolbutton for ttk
    set relief [Widget::getMegawidgetOption $path -relief]
    if {$::Widget::_theme} {
        if { [string equal $relief "link"] } {
            $path configure -style Toolbutton
        }
    } else {
        if { [string equal $relief "link"] } {
            set relief "flat"
        }
        $path configure -relief $relief
    }
    bindtags $path [list $path BwButton [winfo toplevel $path] all]

    set accel1 [string tolower [string index $text $under]]
    set accel2 [string toupper $accel1]
    if { $accel1 != "" } {
        bind [winfo toplevel $path] <Alt-$accel1> [list Button::invoke $path]
        bind [winfo toplevel $path] <Alt-$accel2> [list Button::invoke $path]
................................................................................
        set oldaccel1 ""
        set oldaccel2 ""
    }
    set res [Widget::configure $path $args]

    # Extract all the modified bits we're interested in
    foreach {cr cs cv cn ct cu} [Widget::hasChangedX $path \
        -relief -state -textvariable -name -text -underline] break
    if { $cr || $cs } {
        set relief [Widget::cget $path -relief]
        set state  [Widget::cget $path -state]
        if { $::Widget::_theme} {
			if { [string equal $relief "link"] } {
				$path:cmd configure -style Toolbutton
			} else {
				$path:cmd configure -style ""
			}
		} else {
			if { [string equal $relief "link"] } {
				if { [string equal $state "active"] } {
					set relief "raised"
				} else {
					set relief "flat"
				}
			}
			$path:cmd configure -relief $relief
		}
		$path:cmd configure -state $state
    }

    if { $cv || $cn || $ct || $cu } {
        set var		[Widget::cget $path -textvariable]
        set text	[Widget::cget $path -text]
        set under	[Widget::cget $path -underline]
        if {  ![string length $var] } {
            set desc [BWidget::getname [Widget::cget $path -name]]
            if { [llength $desc] } {
                set text  [lindex $desc 0]
                set under [lindex $desc 1]
            }
        } else {
................................................................................
# ----------------------------------------------------------------------------
#  Command Button::cget
# ----------------------------------------------------------------------------
proc Button::cget { path option } {
    Widget::cget $path $option
}


# ----------------------------------------------------------------------------
#  Command Button::identify
# ----------------------------------------------------------------------------
proc Button::identify { path args } {
    eval $path:cmd identify $args
}


# ----------------------------------------------------------------------------
#  Command Button::instate
# ----------------------------------------------------------------------------
proc Button::instate { path args } {
    eval $path:cmd instate $args
}


# ----------------------------------------------------------------------------
#  Command Button::state
# ----------------------------------------------------------------------------
proc Button::state { path args } {
    eval $path:cmd state $args
}


# ----------------------------------------------------------------------------
#  Command Button::invoke
# ----------------------------------------------------------------------------
proc Button::invoke { path } {
    if { ![string equal [$path:cmd cget -state] "disabled"] } {
        if { $::Widget::_theme} {
            $path:cmd configure -state active
			$path:cmd state pressed
        } else {
            $path:cmd configure -state active -relief sunken
        }
        update idletasks
        set cmd [Widget::getMegawidgetOption $path -armcommand]
        if { $cmd != "" } {
            uplevel \#0 $cmd
        }
        after 100
        $path:cmd configure -state [Widget::getMegawidgetOption $path -state]
        if { $::Widget::_theme} {
            $path:cmd state !pressed
        } else {
            set relief [Widget::getMegawidgetOption $path -relief]
            if { [string equal $relief "link"] } {
                set relief flat
            }
            $path:cmd configure -relief $relief


        }
        set cmd [Widget::getMegawidgetOption $path -disarmcommand]
        if { $cmd != "" } {
            uplevel \#0 $cmd
        }
        set cmd [Widget::getMegawidgetOption $path -command]
        if { $cmd != "" } {
            uplevel \#0 $cmd
        }
    }
}


# ----------------------------------------------------------------------------
#  Command Button::_enter
# ----------------------------------------------------------------------------
proc Button::_enter { path } {
    variable _current
    variable _pressed

    set _current $path
    if { ![string equal [$path:cmd cget -state] "disabled"] } {
        $path:cmd configure -state active
        if { $::Widget::_theme } {
            # $path:cmd state active
        } else {
            if { $_pressed == $path } {
                $path:cmd configure -relief sunken
            } elseif { [string equal [Widget::cget $path -relief] "link"] } {
                $path:cmd configure -relief raised
            }
        }
    }
}


# ----------------------------------------------------------------------------
#  Command Button::_leave
................................................................................
proc Button::_leave { path } {
    variable _current
    variable _pressed

    set _current ""
    if { ![string equal [$path:cmd cget -state] "disabled"] } {
        $path:cmd configure -state [Widget::cget $path -state]
        if { $::Widget::_theme } {
        } else {
            set relief [Widget::cget $path -relief]
            if { $_pressed == $path } {
                if { [string equal $relief "link"] } {
                    set relief raised
                }
                $path:cmd configure -relief $relief
            } elseif { [string equal $relief "link"] } {
                $path:cmd configure -relief flat
            }
        }
    }
}


# ----------------------------------------------------------------------------
#  Command Button::_press
# ----------------------------------------------------------------------------
proc Button::_press { path } {
    variable _pressed

    if { ![string equal [$path:cmd cget -state] "disabled"] } {
        set _pressed $path
        if { $::Widget::_theme} {
            ttk::clickToFocus $path
            $path state pressed
        } else {
            $path:cmd configure -relief sunken
        }
        set cmd [Widget::getMegawidgetOption $path -armcommand]
        if { $cmd != "" } {
            uplevel \#0 $cmd
	    set repeatdelay [Widget::getMegawidgetOption $path -repeatdelay]
	    set repeatint [Widget::getMegawidgetOption $path -repeatinterval]
            if { $repeatdelay > 0 } {
                after $repeatdelay "Button::_repeat $path"
            } elseif { $repeatint > 0 } {
................................................................................
# ----------------------------------------------------------------------------
proc Button::_release { path } {
    variable _current
    variable _pressed

    if { $_pressed == $path } {
        set _pressed ""

	after cancel "Button::_repeat $path"
        if { $::Widget::_theme} {
            $path state !pressed
        } else {
            set relief [Widget::getMegawidgetOption $path -relief]
            if { [string equal $relief "link"] } {
                set relief raised
            }
            $path:cmd configure -relief $relief
        }
	set cmd [Widget::getMegawidgetOption $path -disarmcommand]
        if { $cmd != "" } {
            uplevel \#0 $cmd
        }
        if { $_current == $path &&
             ![string equal [$path:cmd cget -state] "disabled"] && \
	     [set cmd [Widget::getMegawidgetOption $path -command]] != "" } {

Changes to buttonbox.tcl.

141
142
143
144
145
146
147




148
149
150
151
152

153
154
155
156
157
158
159
    set tags ""
    if { [info exists flags(-tags)] } {
	set tags $flags(-tags)
	unset flags(-tags)
	set args [array get flags]
    }





    eval [list Button::create $but \
	      -background [Widget::getoption $path -background]\
	      -padx       [Widget::getoption $path -padx] \
	      -pady       [Widget::getoption $path -pady]] \
        $args [list -default $style]


    # [email protected]:  set up tags, just like the menu items
    foreach tag $tags {
	lappend data(tags,$tag) $but
	if { ![info exists data(tagstate,$tag)] } {
	    set data(tagstate,$tag) 0
	}






>
>
>
>
|
|
|
|
|
>







141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
    set tags ""
    if { [info exists flags(-tags)] } {
	set tags $flags(-tags)
	unset flags(-tags)
	set args [array get flags]
    }

    if { $::Widget::_theme} {
        eval [list Button::create $but] \
            $args [list -default $style]
	} else {
        eval [list Button::create $but \
    	      -background [Widget::getoption $path -background]\
	          -padx       [Widget::getoption $path -padx] \
	          -pady       [Widget::getoption $path -pady]] \
            $args [list -default $style]
	}

    # [email protected]:  set up tags, just like the menu items
    foreach tag $tags {
	lappend data(tags,$tag) $but
	if { ![info exists data(tagstate,$tag)] } {
	    set data(tagstate,$tag) 0
	}