arcadia 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +126 -123
- data/arcadia.rb +770 -756
- data/base/a-contracts.rb +130 -93
- data/base/a-ext.rb +280 -280
- data/base/a-libs.rb +5 -11
- data/base/a-utils.rb +235 -44
- data/conf/arcadia.conf +20 -16
- data/conf/arcadia.init.rb +0 -0
- data/conf/arcadia.res.rb +74 -0
- data/ext/ae-complete-code/ae-complete-code.conf +0 -0
- data/ext/ae-complete-code/ae-complete-code.rb +80 -79
- data/ext/ae-debug/ae-debug.conf +0 -0
- data/ext/ae-debug/ae-debug.rb +2 -6
- data/ext/ae-debug/debug1.57.rb +0 -0
- data/ext/ae-doc-code/ae-doc-code.conf +15 -0
- data/ext/ae-doc-code/ae-doc-code.rb +289 -0
- data/ext/ae-editor/ae-editor.conf +17 -8
- data/ext/ae-editor/ae-editor.rb +738 -396
- data/ext/ae-event-log/ae-event-log.conf +0 -0
- data/ext/ae-event-log/ae-event-log.rb +0 -0
- data/ext/ae-file-history/ae-file-history.conf +2 -2
- data/ext/ae-file-history/ae-file-history.rb +286 -290
- data/ext/ae-inspector/ae-inspector.conf +0 -0
- data/ext/ae-inspector/ae-inspector.rb +0 -0
- data/ext/ae-output-event/ae-output-event.conf +2 -2
- data/ext/ae-output/ae-output.conf +2 -2
- data/ext/ae-output/ae-output.rb +173 -178
- data/ext/ae-palette/ae-palette.conf +0 -0
- data/ext/ae-palette/ae-palette.rb +0 -0
- data/ext/ae-shell/ae-shell.conf +0 -0
- data/ext/ae-shell/ae-shell.rb +54 -54
- data/lib/tk/al-tk.rb +3076 -3082
- data/lib/tk/al-tk.res.rb +0 -0
- data/lib/tk/al-tkarcadia.rb +0 -0
- data/lib/tk/al-tkcustom.rb +0 -0
- data/lib/tkext/al-bwidget.rb +0 -0
- data/lib/tkext/al-iwidgets.rb +0 -0
- data/lib/tkext/al-tile.rb +0 -0
- data/lib/tkext/al-tktable.rb +0 -0
- data/tcl/BWidget-1.8.0/BWman/ArrowButton.html +276 -0
- data/tcl/BWidget-1.8.0/BWman/BWidget.html +228 -0
- data/tcl/BWidget-1.8.0/BWman/Button.html +273 -0
- data/tcl/BWidget-1.8.0/BWman/ButtonBox.html +264 -0
- data/tcl/BWidget-1.8.0/BWman/ComboBox.html +402 -0
- data/tcl/BWidget-1.8.0/BWman/Dialog.html +314 -0
- data/tcl/BWidget-1.8.0/BWman/DragSite.html +139 -0
- data/tcl/BWidget-1.8.0/BWman/DropSite.html +254 -0
- data/tcl/BWidget-1.8.0/BWman/DynamicHelp.html +248 -0
- data/tcl/BWidget-1.8.0/BWman/Entry.html +341 -0
- data/tcl/BWidget-1.8.0/BWman/Label.html +331 -0
- data/tcl/BWidget-1.8.0/BWman/LabelEntry.html +194 -0
- data/tcl/BWidget-1.8.0/BWman/LabelFrame.html +144 -0
- data/tcl/BWidget-1.8.0/BWman/ListBox.html +678 -0
- data/tcl/BWidget-1.8.0/BWman/MainFrame.html +283 -0
- data/tcl/BWidget-1.8.0/BWman/MessageDlg.html +218 -0
- data/tcl/BWidget-1.8.0/BWman/NoteBook.html +374 -0
- data/tcl/BWidget-1.8.0/BWman/PagesManager.html +180 -0
- data/tcl/BWidget-1.8.0/BWman/PanedWindow.html +142 -0
- data/tcl/BWidget-1.8.0/BWman/PanelFrame.html +153 -0
- data/tcl/BWidget-1.8.0/BWman/PasswdDlg.html +214 -0
- data/tcl/BWidget-1.8.0/BWman/ProgressBar.html +152 -0
- data/tcl/BWidget-1.8.0/BWman/ProgressDlg.html +145 -0
- data/tcl/BWidget-1.8.0/BWman/ScrollView.html +130 -0
- data/tcl/BWidget-1.8.0/BWman/ScrollableFrame.html +191 -0
- data/tcl/BWidget-1.8.0/BWman/ScrolledWindow.html +116 -0
- data/tcl/BWidget-1.8.0/BWman/SelectColor.html +164 -0
- data/tcl/BWidget-1.8.0/BWman/SelectFont.html +152 -0
- data/tcl/BWidget-1.8.0/BWman/Separator.html +77 -0
- data/tcl/BWidget-1.8.0/BWman/SpinBox.html +250 -0
- data/tcl/BWidget-1.8.0/BWman/StatusBar.html +147 -0
- data/tcl/BWidget-1.8.0/BWman/TitleFrame.html +107 -0
- data/tcl/BWidget-1.8.0/BWman/Tree.html +947 -0
- data/tcl/BWidget-1.8.0/BWman/Widget.html +502 -0
- data/tcl/BWidget-1.8.0/BWman/contents.html +84 -0
- data/tcl/BWidget-1.8.0/BWman/index.html +7 -0
- data/tcl/BWidget-1.8.0/BWman/navtree.html +41 -0
- data/tcl/BWidget-1.8.0/BWman/options.htm +458 -0
- data/tcl/BWidget-1.8.0/CHANGES.txt +266 -0
- data/tcl/BWidget-1.8.0/ChangeLog +1641 -0
- data/tcl/BWidget-1.8.0/LICENSE.txt +41 -0
- data/tcl/BWidget-1.8.0/README.txt +127 -0
- data/tcl/BWidget-1.8.0/arrow.tcl +551 -0
- data/tcl/BWidget-1.8.0/bitmap.tcl +94 -0
- data/tcl/BWidget-1.8.0/button.tcl +324 -0
- data/tcl/BWidget-1.8.0/buttonbox.tcl +403 -0
- data/tcl/BWidget-1.8.0/color.tcl +493 -0
- data/tcl/BWidget-1.8.0/combobox.tcl +809 -0
- data/tcl/BWidget-1.8.0/demo/basic.tcl +199 -0
- data/tcl/BWidget-1.8.0/demo/bwidget.xbm +46 -0
- data/tcl/BWidget-1.8.0/demo/demo.tcl +212 -0
- data/tcl/BWidget-1.8.0/demo/dnd.tcl +42 -0
- data/tcl/BWidget-1.8.0/demo/manager.tcl +141 -0
- data/tcl/BWidget-1.8.0/demo/select.tcl +59 -0
- data/tcl/BWidget-1.8.0/demo/tmpldlg.tcl +214 -0
- data/tcl/BWidget-1.8.0/demo/tree.tcl +260 -0
- data/tcl/BWidget-1.8.0/demo/x1.xbm +2258 -0
- data/tcl/BWidget-1.8.0/dialog.tcl +345 -0
- data/tcl/BWidget-1.8.0/dragsite.tcl +197 -0
- data/tcl/BWidget-1.8.0/dropsite.tcl +455 -0
- data/tcl/BWidget-1.8.0/dynhelp.tcl +625 -0
- data/tcl/BWidget-1.8.0/entry.tcl +469 -0
- data/tcl/BWidget-1.8.0/font.tcl +566 -0
- data/tcl/BWidget-1.8.0/images/bold.gif +0 -0
- data/tcl/BWidget-1.8.0/images/copy.gif +0 -0
- data/tcl/BWidget-1.8.0/images/cut.gif +0 -0
- data/tcl/BWidget-1.8.0/images/dragfile.gif +0 -0
- data/tcl/BWidget-1.8.0/images/dragicon.gif +0 -0
- data/tcl/BWidget-1.8.0/images/error.gif +0 -0
- data/tcl/BWidget-1.8.0/images/file.gif +0 -0
- data/tcl/BWidget-1.8.0/images/folder.gif +0 -0
- data/tcl/BWidget-1.8.0/images/hourglass.gif +0 -0
- data/tcl/BWidget-1.8.0/images/info.gif +0 -0
- data/tcl/BWidget-1.8.0/images/italic.gif +0 -0
- data/tcl/BWidget-1.8.0/images/minus.xbm +5 -0
- data/tcl/BWidget-1.8.0/images/new.gif +0 -0
- data/tcl/BWidget-1.8.0/images/opcopy.xbm +5 -0
- data/tcl/BWidget-1.8.0/images/open.gif +0 -0
- data/tcl/BWidget-1.8.0/images/openfold.gif +0 -0
- data/tcl/BWidget-1.8.0/images/oplink.xbm +5 -0
- data/tcl/BWidget-1.8.0/images/opmove.xbm +5 -0
- data/tcl/BWidget-1.8.0/images/overstrike.gif +0 -0
- data/tcl/BWidget-1.8.0/images/palette.gif +0 -0
- data/tcl/BWidget-1.8.0/images/passwd.gif +0 -0
- data/tcl/BWidget-1.8.0/images/paste.gif +0 -0
- data/tcl/BWidget-1.8.0/images/plus.xbm +5 -0
- data/tcl/BWidget-1.8.0/images/print.gif +0 -0
- data/tcl/BWidget-1.8.0/images/question.gif +0 -0
- data/tcl/BWidget-1.8.0/images/redo.gif +0 -0
- data/tcl/BWidget-1.8.0/images/save.gif +0 -0
- data/tcl/BWidget-1.8.0/images/target.xbm +9 -0
- data/tcl/BWidget-1.8.0/images/underline.gif +0 -0
- data/tcl/BWidget-1.8.0/images/undo.gif +0 -0
- data/tcl/BWidget-1.8.0/images/warning.gif +0 -0
- data/tcl/BWidget-1.8.0/init.tcl +40 -0
- data/tcl/BWidget-1.8.0/label.tcl +271 -0
- data/tcl/BWidget-1.8.0/labelentry.tcl +100 -0
- data/tcl/BWidget-1.8.0/labelframe.tcl +160 -0
- data/tcl/BWidget-1.8.0/lang/da.rc +52 -0
- data/tcl/BWidget-1.8.0/lang/de.rc +52 -0
- data/tcl/BWidget-1.8.0/lang/en.rc +52 -0
- data/tcl/BWidget-1.8.0/lang/es.rc +53 -0
- data/tcl/BWidget-1.8.0/lang/fr.rc +52 -0
- data/tcl/BWidget-1.8.0/listbox.tcl +1638 -0
- data/tcl/BWidget-1.8.0/mainframe.tcl +711 -0
- data/tcl/BWidget-1.8.0/messagedlg.tcl +128 -0
- data/tcl/BWidget-1.8.0/notebook.tcl +1164 -0
- data/tcl/BWidget-1.8.0/pagesmgr.tcl +294 -0
- data/tcl/BWidget-1.8.0/panedw.tcl +381 -0
- data/tcl/BWidget-1.8.0/panelframe.tcl +246 -0
- data/tcl/BWidget-1.8.0/passwddlg.tcl +178 -0
- data/tcl/BWidget-1.8.0/pkgIndex.tcl +47 -0
- data/tcl/BWidget-1.8.0/progressbar.tcl +208 -0
- data/tcl/BWidget-1.8.0/progressdlg.tcl +87 -0
- data/tcl/BWidget-1.8.0/scrollframe.tcl +226 -0
- data/tcl/BWidget-1.8.0/scrollview.tcl +254 -0
- data/tcl/BWidget-1.8.0/scrollw.tcl +280 -0
- data/tcl/BWidget-1.8.0/separator.tcl +75 -0
- data/tcl/BWidget-1.8.0/spinbox.tcl +331 -0
- data/tcl/BWidget-1.8.0/statusbar.tcl +422 -0
- data/tcl/BWidget-1.8.0/tests/entry.test +173 -0
- data/tcl/BWidget-1.8.0/titleframe.tcl +170 -0
- data/tcl/BWidget-1.8.0/tree.tcl +2228 -0
- data/tcl/BWidget-1.8.0/utils.tcl +645 -0
- data/tcl/BWidget-1.8.0/widget.tcl +1576 -0
- data/tcl/BWidget-1.8.0/wizard.tcl +1028 -0
- data/tcl/BWidget-1.8.0/xpm2image.tcl +115 -0
- metadata +141 -5
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# ------------------------------------------------------------------------------
|
|
2
|
+
# bitmap.tcl
|
|
3
|
+
# This file is part of Unifix BWidget Toolkit
|
|
4
|
+
# $Id: bitmap.tcl,v 1.4 2003/10/20 21:23:52 damonc Exp $
|
|
5
|
+
# ------------------------------------------------------------------------------
|
|
6
|
+
# Index of commands:
|
|
7
|
+
# - Bitmap::get
|
|
8
|
+
# - Bitmap::_init
|
|
9
|
+
# ----------------------------------------------------------------------------
|
|
10
|
+
namespace eval Bitmap {
|
|
11
|
+
Widget::define Bitmap bitmap -classonly
|
|
12
|
+
|
|
13
|
+
variable path
|
|
14
|
+
variable _bmp
|
|
15
|
+
variable _types {
|
|
16
|
+
photo .gif
|
|
17
|
+
photo .ppm
|
|
18
|
+
bitmap .xbm
|
|
19
|
+
photo .xpm
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
proc use {} {}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
# ----------------------------------------------------------------------------
|
|
27
|
+
# Command Bitmap::get
|
|
28
|
+
# ----------------------------------------------------------------------------
|
|
29
|
+
proc Bitmap::get { name } {
|
|
30
|
+
variable path
|
|
31
|
+
variable _bmp
|
|
32
|
+
variable _types
|
|
33
|
+
|
|
34
|
+
if {[info exists _bmp($name)]} {
|
|
35
|
+
return $_bmp($name)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
# --- Nom de fichier avec extension ---------------------------------
|
|
39
|
+
set ext [file extension $name]
|
|
40
|
+
if { $ext != "" } {
|
|
41
|
+
if { ![info exists _bmp($ext)] } {
|
|
42
|
+
error "$ext not supported"
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if { [file exists $name] } {
|
|
46
|
+
if {[string equal $ext ".xpm"]} {
|
|
47
|
+
set _bmp($name) [xpm-to-image $name]
|
|
48
|
+
return $_bmp($name)
|
|
49
|
+
}
|
|
50
|
+
if {![catch {set _bmp($name) [image create $_bmp($ext) -file $name]}]} {
|
|
51
|
+
return $_bmp($name)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
foreach dir $path {
|
|
57
|
+
foreach {type ext} $_types {
|
|
58
|
+
if { [file exists [file join $dir $name$ext]] } {
|
|
59
|
+
if {[string equal $ext ".xpm"]} {
|
|
60
|
+
set _bmp($name) [xpm-to-image [file join $dir $name$ext]]
|
|
61
|
+
return $_bmp($name)
|
|
62
|
+
} else {
|
|
63
|
+
if {![catch {set _bmp($name) [image create $type -file [file join $dir $name$ext]]}]} {
|
|
64
|
+
return $_bmp($name)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return -code error "$name not found"
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
# ----------------------------------------------------------------------------
|
|
76
|
+
# Command Bitmap::_init
|
|
77
|
+
# ----------------------------------------------------------------------------
|
|
78
|
+
proc Bitmap::_init { } {
|
|
79
|
+
global env
|
|
80
|
+
variable path
|
|
81
|
+
variable _bmp
|
|
82
|
+
variable _types
|
|
83
|
+
|
|
84
|
+
set path [list "." [file join $::BWIDGET::LIBRARY images]]
|
|
85
|
+
set supp [image types]
|
|
86
|
+
foreach {type ext} $_types {
|
|
87
|
+
if { [lsearch $supp $type] != -1} {
|
|
88
|
+
set _bmp($ext) $type
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
Bitmap::_init
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
# ----------------------------------------------------------------------------
|
|
2
|
+
# button.tcl
|
|
3
|
+
# This file is part of Unifix BWidget Toolkit
|
|
4
|
+
# ----------------------------------------------------------------------------
|
|
5
|
+
# Index of commands:
|
|
6
|
+
# Public commands
|
|
7
|
+
# - Button::create
|
|
8
|
+
# - Button::configure
|
|
9
|
+
# - Button::cget
|
|
10
|
+
# - Button::invoke
|
|
11
|
+
# Private commands (event bindings)
|
|
12
|
+
# - Button::_destroy
|
|
13
|
+
# - Button::_enter
|
|
14
|
+
# - Button::_leave
|
|
15
|
+
# - Button::_press
|
|
16
|
+
# - Button::_release
|
|
17
|
+
# - Button::_repeat
|
|
18
|
+
# ----------------------------------------------------------------------------
|
|
19
|
+
|
|
20
|
+
namespace eval Button {
|
|
21
|
+
Widget::define Button button DynamicHelp
|
|
22
|
+
|
|
23
|
+
set remove [list -command -relief -text -textvariable -underline -state]
|
|
24
|
+
if {[info tclversion] > 8.3} {
|
|
25
|
+
lappend remove -repeatdelay -repeatinterval
|
|
26
|
+
}
|
|
27
|
+
Widget::tkinclude Button button :cmd remove $remove
|
|
28
|
+
|
|
29
|
+
Widget::declare Button {
|
|
30
|
+
{-name String "" 0}
|
|
31
|
+
{-text String "" 0}
|
|
32
|
+
{-textvariable String "" 0}
|
|
33
|
+
{-underline Int -1 0 "%d >= -1"}
|
|
34
|
+
{-armcommand String "" 0}
|
|
35
|
+
{-disarmcommand String "" 0}
|
|
36
|
+
{-command String "" 0}
|
|
37
|
+
{-state TkResource "" 0 button}
|
|
38
|
+
{-repeatdelay Int 0 0 "%d >= 0"}
|
|
39
|
+
{-repeatinterval Int 0 0 "%d >= 0"}
|
|
40
|
+
{-relief Enum raised 0 {raised sunken flat ridge solid groove link}}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
DynamicHelp::include Button balloon
|
|
44
|
+
|
|
45
|
+
Widget::syncoptions Button "" :cmd {-text {} -underline {}}
|
|
46
|
+
|
|
47
|
+
variable _current ""
|
|
48
|
+
variable _pressed ""
|
|
49
|
+
|
|
50
|
+
bind BwButton <Enter> {Button::_enter %W}
|
|
51
|
+
bind BwButton <Leave> {Button::_leave %W}
|
|
52
|
+
bind BwButton <ButtonPress-1> {Button::_press %W}
|
|
53
|
+
bind BwButton <ButtonRelease-1> {Button::_release %W}
|
|
54
|
+
bind BwButton <Key-space> {Button::invoke %W; break}
|
|
55
|
+
bind BwButton <Return> {Button::invoke %W; break}
|
|
56
|
+
bind BwButton <Destroy> {Widget::destroy %W}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
# ----------------------------------------------------------------------------
|
|
61
|
+
# Command Button::create
|
|
62
|
+
# ----------------------------------------------------------------------------
|
|
63
|
+
proc Button::create { path args } {
|
|
64
|
+
array set maps [list Button {} :cmd {}]
|
|
65
|
+
array set maps [Widget::parseArgs Button $args]
|
|
66
|
+
eval [concat [list button $path] $maps(:cmd)]
|
|
67
|
+
Widget::initFromODB Button $path $maps(Button)
|
|
68
|
+
|
|
69
|
+
# Do some extra configuration on the button
|
|
70
|
+
set relief [Widget::getMegawidgetOption $path -relief]
|
|
71
|
+
if { [string equal $relief "link"] } {
|
|
72
|
+
set relief "flat"
|
|
73
|
+
}
|
|
74
|
+
set var [Widget::getMegawidgetOption $path -textvariable]
|
|
75
|
+
set st [Widget::getMegawidgetOption $path -state]
|
|
76
|
+
if { ![string length $var] } {
|
|
77
|
+
set desc [BWidget::getname [Widget::getMegawidgetOption $path -name]]
|
|
78
|
+
if { [llength $desc] } {
|
|
79
|
+
set text [lindex $desc 0]
|
|
80
|
+
set under [lindex $desc 1]
|
|
81
|
+
Widget::configure $path [list -text $text]
|
|
82
|
+
Widget::configure $path [list -underline $under]
|
|
83
|
+
} else {
|
|
84
|
+
set text [Widget::getMegawidgetOption $path -text]
|
|
85
|
+
set under [Widget::getMegawidgetOption $path -underline]
|
|
86
|
+
}
|
|
87
|
+
} else {
|
|
88
|
+
set under -1
|
|
89
|
+
set text ""
|
|
90
|
+
Widget::configure $path [list -underline $under]
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
$path configure -relief $relief -text $text -underline $under \
|
|
94
|
+
-textvariable $var -state $st
|
|
95
|
+
bindtags $path [list $path BwButton [winfo toplevel $path] all]
|
|
96
|
+
|
|
97
|
+
set accel1 [string tolower [string index $text $under]]
|
|
98
|
+
set accel2 [string toupper $accel1]
|
|
99
|
+
if { $accel1 != "" } {
|
|
100
|
+
bind [winfo toplevel $path] <Alt-$accel1> [list Button::invoke $path]
|
|
101
|
+
bind [winfo toplevel $path] <Alt-$accel2> [list Button::invoke $path]
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
DynamicHelp::sethelp $path $path 1
|
|
105
|
+
|
|
106
|
+
return [Widget::create Button $path]
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
# ----------------------------------------------------------------------------
|
|
111
|
+
# Command Button::configure
|
|
112
|
+
# ----------------------------------------------------------------------------
|
|
113
|
+
proc Button::configure { path args } {
|
|
114
|
+
set oldunder [$path:cmd cget -underline]
|
|
115
|
+
if { $oldunder != -1 } {
|
|
116
|
+
set oldaccel1 [string tolower [string index [$path:cmd cget -text] $oldunder]]
|
|
117
|
+
set oldaccel2 [string toupper $oldaccel1]
|
|
118
|
+
} else {
|
|
119
|
+
set oldaccel1 ""
|
|
120
|
+
set oldaccel2 ""
|
|
121
|
+
}
|
|
122
|
+
set res [Widget::configure $path $args]
|
|
123
|
+
|
|
124
|
+
# Extract all the modified bits we're interested in
|
|
125
|
+
foreach {cr cs cv cn ct cu} [Widget::hasChangedX $path \
|
|
126
|
+
-relief -state -textvariable -name -text -underline] break
|
|
127
|
+
if { $cr || $cs } {
|
|
128
|
+
set relief [Widget::cget $path -relief]
|
|
129
|
+
set state [Widget::cget $path -state]
|
|
130
|
+
if { [string equal $relief "link"] } {
|
|
131
|
+
if { [string equal $state "active"] } {
|
|
132
|
+
set relief "raised"
|
|
133
|
+
} else {
|
|
134
|
+
set relief "flat"
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
$path:cmd configure -relief $relief -state $state
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if { $cv || $cn || $ct || $cu } {
|
|
141
|
+
set var [Widget::cget $path -textvariable]
|
|
142
|
+
set text [Widget::cget $path -text]
|
|
143
|
+
set under [Widget::cget $path -underline]
|
|
144
|
+
if { ![string length $var] } {
|
|
145
|
+
set desc [BWidget::getname [Widget::cget $path -name]]
|
|
146
|
+
if { [llength $desc] } {
|
|
147
|
+
set text [lindex $desc 0]
|
|
148
|
+
set under [lindex $desc 1]
|
|
149
|
+
}
|
|
150
|
+
} else {
|
|
151
|
+
set under -1
|
|
152
|
+
set text ""
|
|
153
|
+
}
|
|
154
|
+
set top [winfo toplevel $path]
|
|
155
|
+
if { $oldaccel1 != "" } {
|
|
156
|
+
bind $top <Alt-$oldaccel1> {}
|
|
157
|
+
bind $top <Alt-$oldaccel2> {}
|
|
158
|
+
}
|
|
159
|
+
set accel1 [string tolower [string index $text $under]]
|
|
160
|
+
set accel2 [string toupper $accel1]
|
|
161
|
+
if { $accel1 != "" } {
|
|
162
|
+
bind $top <Alt-$accel1> [list Button::invoke $path]
|
|
163
|
+
bind $top <Alt-$accel2> [list Button::invoke $path]
|
|
164
|
+
}
|
|
165
|
+
$path:cmd configure -text $text -underline $under -textvariable $var
|
|
166
|
+
}
|
|
167
|
+
DynamicHelp::sethelp $path $path
|
|
168
|
+
|
|
169
|
+
set res
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
# ----------------------------------------------------------------------------
|
|
174
|
+
# Command Button::cget
|
|
175
|
+
# ----------------------------------------------------------------------------
|
|
176
|
+
proc Button::cget { path option } {
|
|
177
|
+
Widget::cget $path $option
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
# ----------------------------------------------------------------------------
|
|
182
|
+
# Command Button::invoke
|
|
183
|
+
# ----------------------------------------------------------------------------
|
|
184
|
+
proc Button::invoke { path } {
|
|
185
|
+
if { ![string equal [$path:cmd cget -state] "disabled"] } {
|
|
186
|
+
$path:cmd configure -state active -relief sunken
|
|
187
|
+
update idletasks
|
|
188
|
+
set cmd [Widget::getMegawidgetOption $path -armcommand]
|
|
189
|
+
if { $cmd != "" } {
|
|
190
|
+
uplevel \#0 $cmd
|
|
191
|
+
}
|
|
192
|
+
after 100
|
|
193
|
+
set relief [Widget::getMegawidgetOption $path -relief]
|
|
194
|
+
if { [string equal $relief "link"] } {
|
|
195
|
+
set relief flat
|
|
196
|
+
}
|
|
197
|
+
$path:cmd configure \
|
|
198
|
+
-state [Widget::getMegawidgetOption $path -state] \
|
|
199
|
+
-relief $relief
|
|
200
|
+
set cmd [Widget::getMegawidgetOption $path -disarmcommand]
|
|
201
|
+
if { $cmd != "" } {
|
|
202
|
+
uplevel \#0 $cmd
|
|
203
|
+
}
|
|
204
|
+
set cmd [Widget::getMegawidgetOption $path -command]
|
|
205
|
+
if { $cmd != "" } {
|
|
206
|
+
uplevel \#0 $cmd
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
# ----------------------------------------------------------------------------
|
|
213
|
+
# Command Button::_enter
|
|
214
|
+
# ----------------------------------------------------------------------------
|
|
215
|
+
proc Button::_enter { path } {
|
|
216
|
+
variable _current
|
|
217
|
+
variable _pressed
|
|
218
|
+
|
|
219
|
+
set _current $path
|
|
220
|
+
if { ![string equal [$path:cmd cget -state] "disabled"] } {
|
|
221
|
+
$path:cmd configure -state active
|
|
222
|
+
if { $_pressed == $path } {
|
|
223
|
+
$path:cmd configure -relief sunken
|
|
224
|
+
} elseif { [string equal [Widget::cget $path -relief] "link"] } {
|
|
225
|
+
$path:cmd configure -relief raised
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
# ----------------------------------------------------------------------------
|
|
232
|
+
# Command Button::_leave
|
|
233
|
+
# ----------------------------------------------------------------------------
|
|
234
|
+
proc Button::_leave { path } {
|
|
235
|
+
variable _current
|
|
236
|
+
variable _pressed
|
|
237
|
+
|
|
238
|
+
set _current ""
|
|
239
|
+
if { ![string equal [$path:cmd cget -state] "disabled"] } {
|
|
240
|
+
$path:cmd configure -state [Widget::cget $path -state]
|
|
241
|
+
set relief [Widget::cget $path -relief]
|
|
242
|
+
if { $_pressed == $path } {
|
|
243
|
+
if { [string equal $relief "link"] } {
|
|
244
|
+
set relief raised
|
|
245
|
+
}
|
|
246
|
+
$path:cmd configure -relief $relief
|
|
247
|
+
} elseif { [string equal $relief "link"] } {
|
|
248
|
+
$path:cmd configure -relief flat
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
# ----------------------------------------------------------------------------
|
|
255
|
+
# Command Button::_press
|
|
256
|
+
# ----------------------------------------------------------------------------
|
|
257
|
+
proc Button::_press { path } {
|
|
258
|
+
variable _pressed
|
|
259
|
+
|
|
260
|
+
if { ![string equal [$path:cmd cget -state] "disabled"] } {
|
|
261
|
+
set _pressed $path
|
|
262
|
+
$path:cmd configure -relief sunken
|
|
263
|
+
set cmd [Widget::getMegawidgetOption $path -armcommand]
|
|
264
|
+
if { $cmd != "" } {
|
|
265
|
+
uplevel \#0 $cmd
|
|
266
|
+
set repeatdelay [Widget::getMegawidgetOption $path -repeatdelay]
|
|
267
|
+
set repeatint [Widget::getMegawidgetOption $path -repeatinterval]
|
|
268
|
+
if { $repeatdelay > 0 } {
|
|
269
|
+
after $repeatdelay "Button::_repeat $path"
|
|
270
|
+
} elseif { $repeatint > 0 } {
|
|
271
|
+
after $repeatint "Button::_repeat $path"
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
# ----------------------------------------------------------------------------
|
|
279
|
+
# Command Button::_release
|
|
280
|
+
# ----------------------------------------------------------------------------
|
|
281
|
+
proc Button::_release { path } {
|
|
282
|
+
variable _current
|
|
283
|
+
variable _pressed
|
|
284
|
+
|
|
285
|
+
if { $_pressed == $path } {
|
|
286
|
+
set _pressed ""
|
|
287
|
+
set relief [Widget::getMegawidgetOption $path -relief]
|
|
288
|
+
after cancel "Button::_repeat $path"
|
|
289
|
+
if { [string equal $relief "link"] } {
|
|
290
|
+
set relief raised
|
|
291
|
+
}
|
|
292
|
+
$path:cmd configure -relief $relief
|
|
293
|
+
set cmd [Widget::getMegawidgetOption $path -disarmcommand]
|
|
294
|
+
if { $cmd != "" } {
|
|
295
|
+
uplevel \#0 $cmd
|
|
296
|
+
}
|
|
297
|
+
if { $_current == $path &&
|
|
298
|
+
![string equal [$path:cmd cget -state] "disabled"] && \
|
|
299
|
+
[set cmd [Widget::getMegawidgetOption $path -command]] != "" } {
|
|
300
|
+
uplevel \#0 $cmd
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
# ----------------------------------------------------------------------------
|
|
307
|
+
# Command Button::_repeat
|
|
308
|
+
# ----------------------------------------------------------------------------
|
|
309
|
+
proc Button::_repeat { path } {
|
|
310
|
+
variable _current
|
|
311
|
+
variable _pressed
|
|
312
|
+
|
|
313
|
+
if { $_current == $path && $_pressed == $path &&
|
|
314
|
+
![string equal [$path:cmd cget -state] "disabled"] &&
|
|
315
|
+
[set cmd [Widget::getMegawidgetOption $path -armcommand]] != "" } {
|
|
316
|
+
uplevel \#0 $cmd
|
|
317
|
+
}
|
|
318
|
+
if { $_pressed == $path &&
|
|
319
|
+
([set delay [Widget::getMegawidgetOption $path -repeatinterval]] >0 ||
|
|
320
|
+
[set delay [Widget::getMegawidgetOption $path -repeatdelay]] > 0) } {
|
|
321
|
+
after $delay "Button::_repeat $path"
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
# ----------------------------------------------------------------------------
|
|
2
|
+
# buttonbox.tcl
|
|
3
|
+
# This file is part of Unifix BWidget Toolkit
|
|
4
|
+
# ----------------------------------------------------------------------------
|
|
5
|
+
# Index of commands:
|
|
6
|
+
# - ButtonBox::create
|
|
7
|
+
# - ButtonBox::configure
|
|
8
|
+
# - ButtonBox::cget
|
|
9
|
+
# - ButtonBox::add
|
|
10
|
+
# - ButtonBox::itemconfigure
|
|
11
|
+
# - ButtonBox::itemcget
|
|
12
|
+
# - ButtonBox::setfocus
|
|
13
|
+
# - ButtonBox::invoke
|
|
14
|
+
# - ButtonBox::index
|
|
15
|
+
# - ButtonBox::_destroy
|
|
16
|
+
# ----------------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
namespace eval ButtonBox {
|
|
19
|
+
Widget::define ButtonBox buttonbox Button
|
|
20
|
+
|
|
21
|
+
Widget::declare ButtonBox {
|
|
22
|
+
{-background TkResource "" 0 frame}
|
|
23
|
+
{-orient Enum horizontal 1 {horizontal vertical}}
|
|
24
|
+
{-state Enum "normal" 0 {normal disabled}}
|
|
25
|
+
{-homogeneous Boolean 1 1}
|
|
26
|
+
{-spacing Int 10 0 "%d >= 0"}
|
|
27
|
+
{-padx TkResource "" 0 button}
|
|
28
|
+
{-pady TkResource "" 0 button}
|
|
29
|
+
{-default Int -1 0 "%d >= -1"}
|
|
30
|
+
{-bg Synonym -background}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
Widget::addmap ButtonBox "" :cmd {-background {}}
|
|
34
|
+
|
|
35
|
+
bind ButtonBox <Destroy> [list ButtonBox::_destroy %W]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# ----------------------------------------------------------------------------
|
|
40
|
+
# Command ButtonBox::create
|
|
41
|
+
# ----------------------------------------------------------------------------
|
|
42
|
+
proc ButtonBox::create { path args } {
|
|
43
|
+
Widget::init ButtonBox $path $args
|
|
44
|
+
|
|
45
|
+
variable $path
|
|
46
|
+
upvar 0 $path data
|
|
47
|
+
|
|
48
|
+
eval [list frame $path] [Widget::subcget $path :cmd] \
|
|
49
|
+
[list -class ButtonBox -takefocus 0 -highlightthickness 0]
|
|
50
|
+
# For 8.4+ we don't want to inherit the padding
|
|
51
|
+
catch {$path configure -padx 0 -pady 0}
|
|
52
|
+
|
|
53
|
+
set data(max) 0
|
|
54
|
+
set data(nbuttons) 0
|
|
55
|
+
set data(buttons) [list]
|
|
56
|
+
set data(default) [Widget::getoption $path -default]
|
|
57
|
+
|
|
58
|
+
return [Widget::create ButtonBox $path]
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
# ----------------------------------------------------------------------------
|
|
63
|
+
# Command ButtonBox::configure
|
|
64
|
+
# ----------------------------------------------------------------------------
|
|
65
|
+
proc ButtonBox::configure { path args } {
|
|
66
|
+
variable $path
|
|
67
|
+
upvar 0 $path data
|
|
68
|
+
|
|
69
|
+
set res [Widget::configure $path $args]
|
|
70
|
+
|
|
71
|
+
if { [Widget::hasChanged $path -default val] } {
|
|
72
|
+
if { $data(default) != -1 && $val != -1 } {
|
|
73
|
+
set but $path.b$data(default)
|
|
74
|
+
if { [winfo exists $but] } {
|
|
75
|
+
$but configure -default normal
|
|
76
|
+
}
|
|
77
|
+
set but $path.b$val
|
|
78
|
+
if { [winfo exists $but] } {
|
|
79
|
+
$but configure -default active
|
|
80
|
+
}
|
|
81
|
+
set data(default) $val
|
|
82
|
+
} else {
|
|
83
|
+
Widget::setoption $path -default $data(default)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if {[Widget::hasChanged $path -state val]} {
|
|
88
|
+
foreach i $data(buttons) {
|
|
89
|
+
$path.b$i configure -state $val
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return $res
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
# ----------------------------------------------------------------------------
|
|
98
|
+
# Command ButtonBox::cget
|
|
99
|
+
# ----------------------------------------------------------------------------
|
|
100
|
+
proc ButtonBox::cget { path option } {
|
|
101
|
+
return [Widget::cget $path $option]
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
# ----------------------------------------------------------------------------
|
|
106
|
+
# Command ButtonBox::add
|
|
107
|
+
# ----------------------------------------------------------------------------
|
|
108
|
+
proc ButtonBox::add { path args } {
|
|
109
|
+
return [eval [linsert $args 0 insert $path end]]
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
proc ButtonBox::insert { path idx args } {
|
|
114
|
+
variable $path
|
|
115
|
+
upvar 0 $path data
|
|
116
|
+
|
|
117
|
+
set but $path.b$data(nbuttons)
|
|
118
|
+
set spacing [Widget::getoption $path -spacing]
|
|
119
|
+
|
|
120
|
+
## Save the current spacing setting for this button. Buttons
|
|
121
|
+
## appended to the end of the box have their spacing applied
|
|
122
|
+
## to their left while all other have their spacing applied
|
|
123
|
+
## to their right.
|
|
124
|
+
if {$idx == "end"} {
|
|
125
|
+
set data(spacing,$data(nbuttons)) [list left $spacing]
|
|
126
|
+
lappend data(buttons) $data(nbuttons)
|
|
127
|
+
} else {
|
|
128
|
+
set data(spacing,$data(nbuttons)) [list right $spacing]
|
|
129
|
+
set data(buttons) [linsert $data(buttons) $idx $data(nbuttons)]
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if { $data(nbuttons) == $data(default) } {
|
|
133
|
+
set style active
|
|
134
|
+
} elseif { $data(default) == -1 } {
|
|
135
|
+
set style disabled
|
|
136
|
+
} else {
|
|
137
|
+
set style normal
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
array set flags $args
|
|
141
|
+
set tags ""
|
|
142
|
+
if { [info exists flags(-tags)] } {
|
|
143
|
+
set tags $flags(-tags)
|
|
144
|
+
unset flags(-tags)
|
|
145
|
+
set args [array get flags]
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
eval [list Button::create $but \
|
|
149
|
+
-background [Widget::getoption $path -background]\
|
|
150
|
+
-padx [Widget::getoption $path -padx] \
|
|
151
|
+
-pady [Widget::getoption $path -pady]] \
|
|
152
|
+
$args [list -default $style]
|
|
153
|
+
|
|
154
|
+
# ericm@scriptics.com: set up tags, just like the menu items
|
|
155
|
+
foreach tag $tags {
|
|
156
|
+
lappend data(tags,$tag) $but
|
|
157
|
+
if { ![info exists data(tagstate,$tag)] } {
|
|
158
|
+
set data(tagstate,$tag) 0
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
set data(buttontags,$but) $tags
|
|
162
|
+
# ericm@scriptics.com
|
|
163
|
+
|
|
164
|
+
_redraw $path
|
|
165
|
+
|
|
166
|
+
incr data(nbuttons)
|
|
167
|
+
|
|
168
|
+
return $but
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
proc ButtonBox::delete { path idx } {
|
|
173
|
+
variable $path
|
|
174
|
+
upvar 0 $path data
|
|
175
|
+
|
|
176
|
+
set i [lindex $data(buttons) $idx]
|
|
177
|
+
set data(buttons) [lreplace $data(buttons) $idx $idx]
|
|
178
|
+
destroy $path.b$i
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
# ButtonBox::setbuttonstate --
|
|
183
|
+
#
|
|
184
|
+
# Set the state of a given button tag. If this makes any buttons
|
|
185
|
+
# enable-able (ie, all of their tags are TRUE), enable them.
|
|
186
|
+
#
|
|
187
|
+
# Arguments:
|
|
188
|
+
# path the button box widget name
|
|
189
|
+
# tag the tag to modify
|
|
190
|
+
# state the new state of $tag (0 or 1)
|
|
191
|
+
#
|
|
192
|
+
# Results:
|
|
193
|
+
# None.
|
|
194
|
+
|
|
195
|
+
proc ButtonBox::setbuttonstate {path tag state} {
|
|
196
|
+
variable $path
|
|
197
|
+
upvar 0 $path data
|
|
198
|
+
# First see if this is a real tag
|
|
199
|
+
if { [info exists data(tagstate,$tag)] } {
|
|
200
|
+
set data(tagstate,$tag) $state
|
|
201
|
+
foreach but $data(tags,$tag) {
|
|
202
|
+
set expression "1"
|
|
203
|
+
foreach buttontag $data(buttontags,$but) {
|
|
204
|
+
append expression " && $data(tagstate,$buttontag)"
|
|
205
|
+
}
|
|
206
|
+
if { [expr $expression] } {
|
|
207
|
+
set state normal
|
|
208
|
+
} else {
|
|
209
|
+
set state disabled
|
|
210
|
+
}
|
|
211
|
+
$but configure -state $state
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
# ButtonBox::getbuttonstate --
|
|
218
|
+
#
|
|
219
|
+
# Retrieve the state of a given button tag.
|
|
220
|
+
#
|
|
221
|
+
# Arguments:
|
|
222
|
+
# path the button box widget name
|
|
223
|
+
# tag the tag to modify
|
|
224
|
+
#
|
|
225
|
+
# Results:
|
|
226
|
+
# None.
|
|
227
|
+
|
|
228
|
+
proc ButtonBox::getbuttonstate {path tag} {
|
|
229
|
+
variable $path
|
|
230
|
+
upvar 0 $path data
|
|
231
|
+
# First see if this is a real tag
|
|
232
|
+
if { [info exists data(tagstate,$tag)] } {
|
|
233
|
+
return $data(tagstate,$tag)
|
|
234
|
+
} else {
|
|
235
|
+
error "unknown tag $tag"
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
# ----------------------------------------------------------------------------
|
|
240
|
+
# Command ButtonBox::itemconfigure
|
|
241
|
+
# ----------------------------------------------------------------------------
|
|
242
|
+
proc ButtonBox::itemconfigure { path index args } {
|
|
243
|
+
if { [set idx [lsearch $args -default]] != -1 } {
|
|
244
|
+
set args [lreplace $args $idx [expr {$idx+1}]]
|
|
245
|
+
}
|
|
246
|
+
return [eval [list Button::configure $path.b[index $path $index]] $args]
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
# ----------------------------------------------------------------------------
|
|
251
|
+
# Command ButtonBox::itemcget
|
|
252
|
+
# ----------------------------------------------------------------------------
|
|
253
|
+
proc ButtonBox::itemcget { path index option } {
|
|
254
|
+
return [Button::cget $path.b[index $path $index] $option]
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
# ----------------------------------------------------------------------------
|
|
259
|
+
# Command ButtonBox::setfocus
|
|
260
|
+
# ----------------------------------------------------------------------------
|
|
261
|
+
proc ButtonBox::setfocus { path index } {
|
|
262
|
+
set but $path.b[index $path $index]
|
|
263
|
+
if { [winfo exists $but] } {
|
|
264
|
+
focus $but
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
# ----------------------------------------------------------------------------
|
|
270
|
+
# Command ButtonBox::invoke
|
|
271
|
+
# ----------------------------------------------------------------------------
|
|
272
|
+
proc ButtonBox::invoke { path index } {
|
|
273
|
+
set but $path.b[index $path $index]
|
|
274
|
+
if { [winfo exists $but] } {
|
|
275
|
+
Button::invoke $but
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
# ----------------------------------------------------------------------------
|
|
281
|
+
# Command ButtonBox::index
|
|
282
|
+
# ----------------------------------------------------------------------------
|
|
283
|
+
proc ButtonBox::index { path index } {
|
|
284
|
+
variable $path
|
|
285
|
+
upvar 0 $path data
|
|
286
|
+
|
|
287
|
+
set n [expr {$data(nbuttons) - 1}]
|
|
288
|
+
|
|
289
|
+
if {[string equal $index "default"]} {
|
|
290
|
+
set res [Widget::getoption $path -default]
|
|
291
|
+
} elseif {$index == "end" || $index == "last"} {
|
|
292
|
+
set res $n
|
|
293
|
+
} elseif {![string is integer -strict $index]} {
|
|
294
|
+
## It's not an integer. Search the text of each button
|
|
295
|
+
## in the box and return the index that matches.
|
|
296
|
+
foreach i $data(buttons) {
|
|
297
|
+
set w $path.b$i
|
|
298
|
+
lappend text [$w cget -text]
|
|
299
|
+
lappend names [$w cget -name]
|
|
300
|
+
}
|
|
301
|
+
set res [lsearch -exact [concat $names $text] $index]
|
|
302
|
+
} else {
|
|
303
|
+
set res $index
|
|
304
|
+
if {$index > $n} { set res $n }
|
|
305
|
+
}
|
|
306
|
+
return $res
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
# ButtonBox::gettags --
|
|
311
|
+
#
|
|
312
|
+
# Return a list of all the tags on all the buttons in a buttonbox.
|
|
313
|
+
#
|
|
314
|
+
# Arguments:
|
|
315
|
+
# path the buttonbox to query.
|
|
316
|
+
#
|
|
317
|
+
# Results:
|
|
318
|
+
# taglist a list of tags on the buttons in the buttonbox
|
|
319
|
+
|
|
320
|
+
proc ButtonBox::gettags {path} {
|
|
321
|
+
upvar ::ButtonBox::$path data
|
|
322
|
+
set taglist {}
|
|
323
|
+
foreach tag [array names data "tags,*"] {
|
|
324
|
+
lappend taglist [string range $tag 5 end]
|
|
325
|
+
}
|
|
326
|
+
return $taglist
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
# ----------------------------------------------------------------------------
|
|
331
|
+
# Command ButtonBox::_redraw
|
|
332
|
+
# ----------------------------------------------------------------------------
|
|
333
|
+
proc ButtonBox::_redraw { path } {
|
|
334
|
+
variable $path
|
|
335
|
+
upvar 0 $path data
|
|
336
|
+
Widget::getVariable $path buttons
|
|
337
|
+
|
|
338
|
+
## We re-grid the buttons from left-to-right. As we go through
|
|
339
|
+
## each button, we check its spacing and which direction the
|
|
340
|
+
## spacing applies to. Once spacing has been applied to an index,
|
|
341
|
+
## it is not changed. This means spacing takes precedence from
|
|
342
|
+
## left-to-right.
|
|
343
|
+
|
|
344
|
+
set idx 0
|
|
345
|
+
set idxs [list]
|
|
346
|
+
foreach i $data(buttons) {
|
|
347
|
+
set dir [lindex $data(spacing,$i) 0]
|
|
348
|
+
set spacing [lindex $data(spacing,$i) 1]
|
|
349
|
+
set but $path.b$i
|
|
350
|
+
if {[string equal [Widget::getoption $path -orient] "horizontal"]} {
|
|
351
|
+
grid $but -column $idx -row 0 -sticky nsew
|
|
352
|
+
if { [Widget::getoption $path -homogeneous] } {
|
|
353
|
+
set req [winfo reqwidth $but]
|
|
354
|
+
if { $req > $data(max) } {
|
|
355
|
+
grid columnconfigure $path [expr {2*$i}] -minsize $req
|
|
356
|
+
set data(max) $req
|
|
357
|
+
}
|
|
358
|
+
grid columnconfigure $path $idx -weight 1
|
|
359
|
+
} else {
|
|
360
|
+
grid columnconfigure $path $idx -weight 0
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
set col [expr {$idx - 1}]
|
|
364
|
+
if {[string equal $dir "right"]} { set col [expr {$idx + 1}] }
|
|
365
|
+
if {$col > 0 && [lsearch $idxs $col] < 0} {
|
|
366
|
+
lappend idxs $col
|
|
367
|
+
grid columnconfigure $path $col -minsize $spacing
|
|
368
|
+
}
|
|
369
|
+
} else {
|
|
370
|
+
grid $but -column 0 -row $idx -sticky nsew
|
|
371
|
+
grid rowconfigure $path $idx -weight 0
|
|
372
|
+
|
|
373
|
+
set row [expr {$idx - 1}]
|
|
374
|
+
if {[string equal $dir "right"]} { set row [expr {$idx + 1}] }
|
|
375
|
+
if {$row > 0 && [lsearch $idxs $row] < 0} {
|
|
376
|
+
lappend idxs $row
|
|
377
|
+
grid rowconfigure $path $row -minsize $spacing
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
incr idx 2
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
# Now that the maximum size has been calculated, go back through
|
|
384
|
+
# and correctly set the size for homogeneous horizontal buttons.
|
|
385
|
+
if { [string equal [Widget::getoption $path -orient] "horizontal"] && [Widget::getoption $path -homogeneous] } {
|
|
386
|
+
set idx 0
|
|
387
|
+
foreach i $data(buttons) {
|
|
388
|
+
grid columnconfigure $path $idx -minsize $data(max)
|
|
389
|
+
incr idx 2
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
# ----------------------------------------------------------------------------
|
|
396
|
+
# Command ButtonBox::_destroy
|
|
397
|
+
# ----------------------------------------------------------------------------
|
|
398
|
+
proc ButtonBox::_destroy { path } {
|
|
399
|
+
variable $path
|
|
400
|
+
upvar 0 $path data
|
|
401
|
+
Widget::destroy $path
|
|
402
|
+
unset data
|
|
403
|
+
}
|