Bwidget Source Code
Check-in [3193692912]
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:ttk style related code change
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3193692912fd18b4ea74298fcbe55635ace0bcc4
User & Date: oberdorfer 2009-09-08 19:55:45
Context
2009-09-08
20:28
BWidget::bindMiddleMouseMovement added check-in: 5ab352a476 user: oberdorfer tags: trunk
19:55
ttk style related code change check-in: 3193692912 user: oberdorfer tags: trunk
2009-09-07
20:11
minor theme related code change check-in: c66dab3edb user: oberdorfer tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to button.tcl.

1
2
3
4
5
6
7
8
9
10
11
..
22
23
24
25
26
27
28

29
30
31
32
33
34
35
..
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
91
92
93
94

95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
...
170
171
172
173
174
175
176










177
178
179
180
181
182
183
# ----------------------------------------------------------------------------
#  button.tcl
#  This file is part of Unifix BWidget Toolkit
#  $Id: button.tcl,v 1.12 2009/09/07 20:11:39 oberdorfer Exp $
# ----------------------------------------------------------------------------
#  Index of commands:
#   Public commands
#     - Button::create
#     - Button::configure
#     - Button::cget
#     - Button::invoke
................................................................................

    Widget::define Button button DynamicHelp

    set remove [list -command -relief -text -textvariable -underline -state]
    if {[info tclversion] > 8.3} {
	lappend remove -repeatdelay -repeatinterval
    }

    # if { [BWidget::using ttk] } { lappend remove -borderwidth }

    Widget::tkinclude Button button :cmd remove $remove

    Widget::declare Button {
        {-name            String "" 0}
        {-text            String "" 0}
................................................................................
    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}






}


proc Button::createButtonStyles {} {
    variable _styles_created
 
    if { [info exists _styles_created] && $_styles_created != 0 } {
        return
    } 
    if { ![BWidget::using ttk] } { return }









    # emulate tk behavior, referenced later on such like:
    #    -style "${relief}BW.TButton"

    ::ttk::style configure raisedBW.TButton -relief raised
    ::ttk::style configure sunkenBW.TButton -relief sunken
    ::ttk::style configure flatBW.TButton   -relief flat
    ::ttk::style configure solidBW.TButton  -relief solid
    ::ttk::style configure grooveBW.TButton -relief groove
    ::ttk::style configure linkBW.TButton   -relief flat -bd 2



    set _styles_created 1
}



# ----------------------------------------------------------------------------
#  Command Button::create
# ----------------------------------------------------------------------------
proc Button::create { path args } {


    if { [BWidget::using ttk] } {
        createButtonStyles

        # remove unsupported tk options
	# (hope that's all we need to take care about)
	foreach opt {-font -fg -foreground -background
	             -highlightthickness -bd -borderwidth
		     -padx -pady -anchor} {
            set args [Widget::getArgument $args $opt tmp]
	}
        set args [Widget::getArgument $args "-relief" relief]

    } else {
        set args [Widget::getArgument $args "-style" tmp]
    }
................................................................................
}


# ----------------------------------------------------------------------------
#  Command Button::configure
# ----------------------------------------------------------------------------
proc Button::configure { path args } {










    set oldunder [$path:cmd cget -underline]
    if { $oldunder != -1 } {
        set oldaccel1 [string tolower [string index [$path:cmd cget -text] $oldunder]]
        set oldaccel2 [string toupper $oldaccel1]
    } else {
        set oldaccel1 ""
        set oldaccel2 ""


|







 







>







 







>
>
>
>
>
>











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










>






|
<
<







 







>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
..
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
..
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120


121
122
123
124
125
126
127
...
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# ----------------------------------------------------------------------------
#  button.tcl
#  This file is part of Unifix BWidget Toolkit
#  $Id: button.tcl,v 1.13 2009/09/08 19:55:45 oberdorfer Exp $
# ----------------------------------------------------------------------------
#  Index of commands:
#   Public commands
#     - Button::create
#     - Button::configure
#     - Button::cget
#     - Button::invoke
................................................................................

    Widget::define Button button DynamicHelp

    set remove [list -command -relief -text -textvariable -underline -state]
    if {[info tclversion] > 8.3} {
	lappend remove -repeatdelay -repeatinterval
    }
    
    # if { [BWidget::using ttk] } { lappend remove -borderwidth }

    Widget::tkinclude Button button :cmd remove $remove

    Widget::declare Button {
        {-name            String "" 0}
        {-text            String "" 0}
................................................................................
    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}
    
    variable _ttkunsupported
    set _ttkunsupported_opt \
           { -font -fg -foreground -background
	     -highlightthickness -bd -borderwidth
	     -padx -pady -anchor }
}


proc Button::createButtonStyles {} {
    variable _styles_created
 
    if { [info exists _styles_created] && $_styles_created != 0 } {
        return
    } 
    if { ![BWidget::using ttk] } { return }

    # create a new element for each available theme...
    foreach themeName [ttk::style theme names] {

       # temporarily sets the current theme to themeName,
       # evaluate script, then restore the previous theme.

        ttk::style theme settings $themeName {
  
            # emulate tk behavior, referenced later on such like:
            #    -style "${relief}BW.TButton"

            ::ttk::style configure raisedBW.TButton -relief raised
            ::ttk::style configure sunkenBW.TButton -relief sunken
            ::ttk::style configure flatBW.TButton   -relief flat
            ::ttk::style configure solidBW.TButton  -relief solid
            ::ttk::style configure grooveBW.TButton -relief groove
            ::ttk::style configure linkBW.TButton   -relief flat -bd 2
        }
    }

    set _styles_created 1
}



# ----------------------------------------------------------------------------
#  Command Button::create
# ----------------------------------------------------------------------------
proc Button::create { path args } {
    variable _ttkunsupported_opt

    if { [BWidget::using ttk] } {
        createButtonStyles

        # remove unsupported tk options
	# (hope that's all we need to take care about)
	foreach opt $_ttkunsupported_opt {


            set args [Widget::getArgument $args $opt tmp]
	}
        set args [Widget::getArgument $args "-relief" relief]

    } else {
        set args [Widget::getArgument $args "-style" tmp]
    }
................................................................................
}


# ----------------------------------------------------------------------------
#  Command Button::configure
# ----------------------------------------------------------------------------
proc Button::configure { path args } {
    variable _ttkunsupported_opt

    # remove unsupported tk options 1st...

    if { [BWidget::using ttk] } {
	foreach opt $_ttkunsupported_opt {
            set args [Widget::getArgument $args $opt tmp]
	}
    }

    set oldunder [$path:cmd cget -underline]
    if { $oldunder != -1 } {
        set oldaccel1 [string tolower [string index [$path:cmd cget -text] $oldunder]]
        set oldaccel2 [string toupper $oldaccel1]
    } else {
        set oldaccel1 ""
        set oldaccel2 ""