arcadia 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- 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,645 @@
|
|
1
|
+
# ----------------------------------------------------------------------------
|
2
|
+
# utils.tcl
|
3
|
+
# This file is part of Unifix BWidget Toolkit
|
4
|
+
# $Id: utils.tcl,v 1.12 2004/09/24 23:57:13 hobbs Exp $
|
5
|
+
# ----------------------------------------------------------------------------
|
6
|
+
# Index of commands:
|
7
|
+
# - GlobalVar::exists
|
8
|
+
# - GlobalVar::setvarvar
|
9
|
+
# - GlobalVar::getvarvar
|
10
|
+
# - BWidget::assert
|
11
|
+
# - BWidget::clonename
|
12
|
+
# - BWidget::get3dcolor
|
13
|
+
# - BWidget::XLFDfont
|
14
|
+
# - BWidget::place
|
15
|
+
# - BWidget::grab
|
16
|
+
# - BWidget::focus
|
17
|
+
# ----------------------------------------------------------------------------
|
18
|
+
|
19
|
+
namespace eval GlobalVar {
|
20
|
+
proc use {} {}
|
21
|
+
}
|
22
|
+
|
23
|
+
|
24
|
+
namespace eval BWidget {
|
25
|
+
variable _top
|
26
|
+
variable _gstack {}
|
27
|
+
variable _fstack {}
|
28
|
+
proc use {} {}
|
29
|
+
}
|
30
|
+
|
31
|
+
|
32
|
+
# ----------------------------------------------------------------------------
|
33
|
+
# Command GlobalVar::exists
|
34
|
+
# ----------------------------------------------------------------------------
|
35
|
+
proc GlobalVar::exists { varName } {
|
36
|
+
return [uplevel \#0 [list info exists $varName]]
|
37
|
+
}
|
38
|
+
|
39
|
+
|
40
|
+
# ----------------------------------------------------------------------------
|
41
|
+
# Command GlobalVar::setvar
|
42
|
+
# ----------------------------------------------------------------------------
|
43
|
+
proc GlobalVar::setvar { varName value } {
|
44
|
+
return [uplevel \#0 [list set $varName $value]]
|
45
|
+
}
|
46
|
+
|
47
|
+
|
48
|
+
# ----------------------------------------------------------------------------
|
49
|
+
# Command GlobalVar::getvar
|
50
|
+
# ----------------------------------------------------------------------------
|
51
|
+
proc GlobalVar::getvar { varName } {
|
52
|
+
return [uplevel \#0 [list set $varName]]
|
53
|
+
}
|
54
|
+
|
55
|
+
|
56
|
+
# ----------------------------------------------------------------------------
|
57
|
+
# Command GlobalVar::tracevar
|
58
|
+
# ----------------------------------------------------------------------------
|
59
|
+
proc GlobalVar::tracevar { cmd varName args } {
|
60
|
+
return [uplevel \#0 [list trace $cmd $varName] $args]
|
61
|
+
}
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
# ----------------------------------------------------------------------------
|
66
|
+
# Command BWidget::lreorder
|
67
|
+
# ----------------------------------------------------------------------------
|
68
|
+
proc BWidget::lreorder { list neworder } {
|
69
|
+
set pos 0
|
70
|
+
set newlist {}
|
71
|
+
foreach e $neworder {
|
72
|
+
if { [lsearch -exact $list $e] != -1 } {
|
73
|
+
lappend newlist $e
|
74
|
+
set tabelt($e) 1
|
75
|
+
}
|
76
|
+
}
|
77
|
+
set len [llength $newlist]
|
78
|
+
if { !$len } {
|
79
|
+
return $list
|
80
|
+
}
|
81
|
+
if { $len == [llength $list] } {
|
82
|
+
return $newlist
|
83
|
+
}
|
84
|
+
set pos 0
|
85
|
+
foreach e $list {
|
86
|
+
if { ![info exists tabelt($e)] } {
|
87
|
+
set newlist [linsert $newlist $pos $e]
|
88
|
+
}
|
89
|
+
incr pos
|
90
|
+
}
|
91
|
+
return $newlist
|
92
|
+
}
|
93
|
+
|
94
|
+
|
95
|
+
# ----------------------------------------------------------------------------
|
96
|
+
# Command BWidget::assert
|
97
|
+
# ----------------------------------------------------------------------------
|
98
|
+
proc BWidget::assert { exp {msg ""}} {
|
99
|
+
set res [uplevel 1 expr $exp]
|
100
|
+
if { !$res} {
|
101
|
+
if { $msg == "" } {
|
102
|
+
return -code error "Assertion failed: {$exp}"
|
103
|
+
} else {
|
104
|
+
return -code error $msg
|
105
|
+
}
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
|
110
|
+
# ----------------------------------------------------------------------------
|
111
|
+
# Command BWidget::clonename
|
112
|
+
# ----------------------------------------------------------------------------
|
113
|
+
proc BWidget::clonename { menu } {
|
114
|
+
set path ""
|
115
|
+
set menupath ""
|
116
|
+
set found 0
|
117
|
+
foreach widget [lrange [split $menu "."] 1 end] {
|
118
|
+
if { $found || [winfo class "$path.$widget"] == "Menu" } {
|
119
|
+
set found 1
|
120
|
+
append menupath "#" $widget
|
121
|
+
append path "." $menupath
|
122
|
+
} else {
|
123
|
+
append menupath "#" $widget
|
124
|
+
append path "." $widget
|
125
|
+
}
|
126
|
+
}
|
127
|
+
return $path
|
128
|
+
}
|
129
|
+
|
130
|
+
|
131
|
+
# ----------------------------------------------------------------------------
|
132
|
+
# Command BWidget::getname
|
133
|
+
# ----------------------------------------------------------------------------
|
134
|
+
proc BWidget::getname { name } {
|
135
|
+
if { [string length $name] } {
|
136
|
+
set text [option get . "${name}Name" ""]
|
137
|
+
if { [string length $text] } {
|
138
|
+
return [parsetext $text]
|
139
|
+
}
|
140
|
+
}
|
141
|
+
return {}
|
142
|
+
}
|
143
|
+
|
144
|
+
|
145
|
+
# ----------------------------------------------------------------------------
|
146
|
+
# Command BWidget::parsetext
|
147
|
+
# ----------------------------------------------------------------------------
|
148
|
+
proc BWidget::parsetext { text } {
|
149
|
+
set result ""
|
150
|
+
set index -1
|
151
|
+
set start 0
|
152
|
+
while { [string length $text] } {
|
153
|
+
set idx [string first "&" $text]
|
154
|
+
if { $idx == -1 } {
|
155
|
+
append result $text
|
156
|
+
set text ""
|
157
|
+
} else {
|
158
|
+
set char [string index $text [expr {$idx+1}]]
|
159
|
+
if { $char == "&" } {
|
160
|
+
append result [string range $text 0 $idx]
|
161
|
+
set text [string range $text [expr {$idx+2}] end]
|
162
|
+
set start [expr {$start+$idx+1}]
|
163
|
+
} else {
|
164
|
+
append result [string range $text 0 [expr {$idx-1}]]
|
165
|
+
set text [string range $text [expr {$idx+1}] end]
|
166
|
+
incr start $idx
|
167
|
+
set index $start
|
168
|
+
}
|
169
|
+
}
|
170
|
+
}
|
171
|
+
return [list $result $index]
|
172
|
+
}
|
173
|
+
|
174
|
+
|
175
|
+
# ----------------------------------------------------------------------------
|
176
|
+
# Command BWidget::get3dcolor
|
177
|
+
# ----------------------------------------------------------------------------
|
178
|
+
proc BWidget::get3dcolor { path bgcolor } {
|
179
|
+
foreach val [winfo rgb $path $bgcolor] {
|
180
|
+
lappend dark [expr {60*$val/100}]
|
181
|
+
set tmp1 [expr {14*$val/10}]
|
182
|
+
if { $tmp1 > 65535 } {
|
183
|
+
set tmp1 65535
|
184
|
+
}
|
185
|
+
set tmp2 [expr {(65535+$val)/2}]
|
186
|
+
lappend light [expr {($tmp1 > $tmp2) ? $tmp1:$tmp2}]
|
187
|
+
}
|
188
|
+
return [list [eval format "#%04x%04x%04x" $dark] [eval format "#%04x%04x%04x" $light]]
|
189
|
+
}
|
190
|
+
|
191
|
+
|
192
|
+
# ----------------------------------------------------------------------------
|
193
|
+
# Command BWidget::XLFDfont
|
194
|
+
# ----------------------------------------------------------------------------
|
195
|
+
proc BWidget::XLFDfont { cmd args } {
|
196
|
+
switch -- $cmd {
|
197
|
+
create {
|
198
|
+
set font "-*-*-*-*-*-*-*-*-*-*-*-*-*-*"
|
199
|
+
}
|
200
|
+
configure {
|
201
|
+
set font [lindex $args 0]
|
202
|
+
set args [lrange $args 1 end]
|
203
|
+
}
|
204
|
+
default {
|
205
|
+
return -code error "XLFDfont: commande incorrect: $cmd"
|
206
|
+
}
|
207
|
+
}
|
208
|
+
set lfont [split $font "-"]
|
209
|
+
if { [llength $lfont] != 15 } {
|
210
|
+
return -code error "XLFDfont: description XLFD incorrect: $font"
|
211
|
+
}
|
212
|
+
|
213
|
+
foreach {option value} $args {
|
214
|
+
switch -- $option {
|
215
|
+
-foundry { set index 1 }
|
216
|
+
-family { set index 2 }
|
217
|
+
-weight { set index 3 }
|
218
|
+
-slant { set index 4 }
|
219
|
+
-size { set index 7 }
|
220
|
+
default { return -code error "XLFDfont: option incorrecte: $option" }
|
221
|
+
}
|
222
|
+
set lfont [lreplace $lfont $index $index $value]
|
223
|
+
}
|
224
|
+
return [join $lfont "-"]
|
225
|
+
}
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
# ----------------------------------------------------------------------------
|
230
|
+
# Command BWidget::place
|
231
|
+
# ----------------------------------------------------------------------------
|
232
|
+
#
|
233
|
+
# Notes:
|
234
|
+
# For Windows systems with more than one monitor the available screen area may
|
235
|
+
# have negative positions. Geometry settings with negative numbers are used
|
236
|
+
# under X to place wrt the right or bottom of the screen. On windows, Tk
|
237
|
+
# continues to do this. However, a geometry such as 100x100+-200-100 can be
|
238
|
+
# used to place a window onto a secondary monitor. Passing the + gets Tk
|
239
|
+
# to pass the remainder unchanged so the Windows manager then handles -200
|
240
|
+
# which is a position on the left hand monitor.
|
241
|
+
# I've tested this for left, right, above and below the primary monitor.
|
242
|
+
# Currently there is no way to ask Tk the extent of the Windows desktop in
|
243
|
+
# a multi monitor system. Nor what the legal co-ordinate range might be.
|
244
|
+
#
|
245
|
+
proc BWidget::place { path w h args } {
|
246
|
+
variable _top
|
247
|
+
|
248
|
+
update idletasks
|
249
|
+
set reqw [winfo reqwidth $path]
|
250
|
+
set reqh [winfo reqheight $path]
|
251
|
+
if { $w == 0 } {set w $reqw}
|
252
|
+
if { $h == 0 } {set h $reqh}
|
253
|
+
|
254
|
+
set arglen [llength $args]
|
255
|
+
if { $arglen > 3 } {
|
256
|
+
return -code error "BWidget::place: bad number of argument"
|
257
|
+
}
|
258
|
+
|
259
|
+
if { $arglen > 0 } {
|
260
|
+
set where [lindex $args 0]
|
261
|
+
set list [list "at" "center" "left" "right" "above" "below"]
|
262
|
+
set idx [lsearch $list $where]
|
263
|
+
if { $idx == -1 } {
|
264
|
+
return -code error [BWidget::badOptionString position $where $list]
|
265
|
+
}
|
266
|
+
if { $idx == 0 } {
|
267
|
+
set err [catch {
|
268
|
+
# purposely removed the {} around these expressions - [PT]
|
269
|
+
set x [expr int([lindex $args 1])]
|
270
|
+
set y [expr int([lindex $args 2])]
|
271
|
+
}]
|
272
|
+
if { $err } {
|
273
|
+
return -code error "BWidget::place: incorrect position"
|
274
|
+
}
|
275
|
+
if {$::tcl_platform(platform) == "windows"} {
|
276
|
+
# handle windows multi-screen. -100 != +-100
|
277
|
+
if {[string index [lindex $args 1] 0] != "-"} {
|
278
|
+
set x "+$x"
|
279
|
+
}
|
280
|
+
if {[string index [lindex $args 2] 0] != "-"} {
|
281
|
+
set y "+$y"
|
282
|
+
}
|
283
|
+
} else {
|
284
|
+
if { $x >= 0 } {
|
285
|
+
set x "+$x"
|
286
|
+
}
|
287
|
+
if { $y >= 0 } {
|
288
|
+
set y "+$y"
|
289
|
+
}
|
290
|
+
}
|
291
|
+
} else {
|
292
|
+
if { $arglen == 2 } {
|
293
|
+
set widget [lindex $args 1]
|
294
|
+
if { ![winfo exists $widget] } {
|
295
|
+
return -code error "BWidget::place: \"$widget\" does not exist"
|
296
|
+
}
|
297
|
+
} else {
|
298
|
+
set widget .
|
299
|
+
}
|
300
|
+
set sw [winfo screenwidth $path]
|
301
|
+
set sh [winfo screenheight $path]
|
302
|
+
if { $idx == 1 } {
|
303
|
+
if { $arglen == 2 } {
|
304
|
+
# center to widget
|
305
|
+
set x0 [expr {[winfo rootx $widget] + ([winfo width $widget] - $w)/2}]
|
306
|
+
set y0 [expr {[winfo rooty $widget] + ([winfo height $widget] - $h)/2}]
|
307
|
+
} else {
|
308
|
+
# center to screen
|
309
|
+
set x0 [expr {([winfo screenwidth $path] - $w)/2 - [winfo vrootx $path]}]
|
310
|
+
set y0 [expr {([winfo screenheight $path] - $h)/2 - [winfo vrooty $path]}]
|
311
|
+
}
|
312
|
+
set x "+$x0"
|
313
|
+
set y "+$y0"
|
314
|
+
if {$::tcl_platform(platform) != "windows"} {
|
315
|
+
if { $x0+$w > $sw } {set x "-0"; set x0 [expr {$sw-$w}]}
|
316
|
+
if { $x0 < 0 } {set x "+0"}
|
317
|
+
if { $y0+$h > $sh } {set y "-0"; set y0 [expr {$sh-$h}]}
|
318
|
+
if { $y0 < 0 } {set y "+0"}
|
319
|
+
}
|
320
|
+
} else {
|
321
|
+
set x0 [winfo rootx $widget]
|
322
|
+
set y0 [winfo rooty $widget]
|
323
|
+
set x1 [expr {$x0 + [winfo width $widget]}]
|
324
|
+
set y1 [expr {$y0 + [winfo height $widget]}]
|
325
|
+
if { $idx == 2 || $idx == 3 } {
|
326
|
+
set y "+$y0"
|
327
|
+
if {$::tcl_platform(platform) != "windows"} {
|
328
|
+
if { $y0+$h > $sh } {set y "-0"; set y0 [expr {$sh-$h}]}
|
329
|
+
if { $y0 < 0 } {set y "+0"}
|
330
|
+
}
|
331
|
+
if { $idx == 2 } {
|
332
|
+
# try left, then right if out, then 0 if out
|
333
|
+
if { $x0 >= $w } {
|
334
|
+
set x [expr {$x0-$sw}]
|
335
|
+
} elseif { $x1+$w <= $sw } {
|
336
|
+
set x "+$x1"
|
337
|
+
} else {
|
338
|
+
set x "+0"
|
339
|
+
}
|
340
|
+
} else {
|
341
|
+
# try right, then left if out, then 0 if out
|
342
|
+
if { $x1+$w <= $sw } {
|
343
|
+
set x "+$x1"
|
344
|
+
} elseif { $x0 >= $w } {
|
345
|
+
set x [expr {$x0-$sw}]
|
346
|
+
} else {
|
347
|
+
set x "-0"
|
348
|
+
}
|
349
|
+
}
|
350
|
+
} else {
|
351
|
+
set x "+$x0"
|
352
|
+
if {$::tcl_platform(platform) != "windows"} {
|
353
|
+
if { $x0+$w > $sw } {set x "-0"; set x0 [expr {$sw-$w}]}
|
354
|
+
if { $x0 < 0 } {set x "+0"}
|
355
|
+
}
|
356
|
+
if { $idx == 4 } {
|
357
|
+
# try top, then bottom, then 0
|
358
|
+
if { $h <= $y0 } {
|
359
|
+
set y [expr {$y0-$sh}]
|
360
|
+
} elseif { $y1+$h <= $sh } {
|
361
|
+
set y "+$y1"
|
362
|
+
} else {
|
363
|
+
set y "+0"
|
364
|
+
}
|
365
|
+
} else {
|
366
|
+
# try bottom, then top, then 0
|
367
|
+
if { $y1+$h <= $sh } {
|
368
|
+
set y "+$y1"
|
369
|
+
} elseif { $h <= $y0 } {
|
370
|
+
set y [expr {$y0-$sh}]
|
371
|
+
} else {
|
372
|
+
set y "-0"
|
373
|
+
}
|
374
|
+
}
|
375
|
+
}
|
376
|
+
}
|
377
|
+
}
|
378
|
+
|
379
|
+
## If there's not a + or - in front of the number, we need to add one.
|
380
|
+
if {[string is integer [string index $x 0]]} { set x +$x }
|
381
|
+
if {[string is integer [string index $y 0]]} { set y +$y }
|
382
|
+
|
383
|
+
wm geometry $path "${w}x${h}${x}${y}"
|
384
|
+
} else {
|
385
|
+
wm geometry $path "${w}x${h}"
|
386
|
+
}
|
387
|
+
update idletasks
|
388
|
+
}
|
389
|
+
|
390
|
+
|
391
|
+
# ----------------------------------------------------------------------------
|
392
|
+
# Command BWidget::grab
|
393
|
+
# ----------------------------------------------------------------------------
|
394
|
+
proc BWidget::grab { option path } {
|
395
|
+
variable _gstack
|
396
|
+
|
397
|
+
if { $option == "release" } {
|
398
|
+
catch {::grab release $path}
|
399
|
+
while { [llength $_gstack] } {
|
400
|
+
set grinfo [lindex $_gstack end]
|
401
|
+
set _gstack [lreplace $_gstack end end]
|
402
|
+
foreach {oldg mode} $grinfo {
|
403
|
+
if { ![string equal $oldg $path] && [winfo exists $oldg] } {
|
404
|
+
if { $mode == "global" } {
|
405
|
+
catch {::grab -global $oldg}
|
406
|
+
} else {
|
407
|
+
catch {::grab $oldg}
|
408
|
+
}
|
409
|
+
return
|
410
|
+
}
|
411
|
+
}
|
412
|
+
}
|
413
|
+
} else {
|
414
|
+
set oldg [::grab current]
|
415
|
+
if { $oldg != "" } {
|
416
|
+
lappend _gstack [list $oldg [::grab status $oldg]]
|
417
|
+
}
|
418
|
+
if { $option == "global" } {
|
419
|
+
::grab -global $path
|
420
|
+
} else {
|
421
|
+
::grab $path
|
422
|
+
}
|
423
|
+
}
|
424
|
+
}
|
425
|
+
|
426
|
+
|
427
|
+
# ----------------------------------------------------------------------------
|
428
|
+
# Command BWidget::focus
|
429
|
+
# ----------------------------------------------------------------------------
|
430
|
+
proc BWidget::focus { option path {refocus 1} } {
|
431
|
+
variable _fstack
|
432
|
+
|
433
|
+
if { $option == "release" } {
|
434
|
+
while { [llength $_fstack] } {
|
435
|
+
set oldf [lindex $_fstack end]
|
436
|
+
set _fstack [lreplace $_fstack end end]
|
437
|
+
if { ![string equal $oldf $path] && [winfo exists $oldf] } {
|
438
|
+
if {$refocus} {catch {::focus -force $oldf}}
|
439
|
+
return
|
440
|
+
}
|
441
|
+
}
|
442
|
+
} elseif { $option == "set" } {
|
443
|
+
lappend _fstack [::focus]
|
444
|
+
::focus -force $path
|
445
|
+
}
|
446
|
+
}
|
447
|
+
|
448
|
+
# BWidget::refocus --
|
449
|
+
#
|
450
|
+
# Helper function used to redirect focus from a container frame in
|
451
|
+
# a megawidget to a component widget. Only redirects focus if
|
452
|
+
# focus is already on the container.
|
453
|
+
#
|
454
|
+
# Arguments:
|
455
|
+
# container container widget to redirect from.
|
456
|
+
# component component widget to redirect to.
|
457
|
+
#
|
458
|
+
# Results:
|
459
|
+
# None.
|
460
|
+
|
461
|
+
proc BWidget::refocus {container component} {
|
462
|
+
if { [string equal $container [::focus]] } {
|
463
|
+
::focus $component
|
464
|
+
}
|
465
|
+
return
|
466
|
+
}
|
467
|
+
|
468
|
+
## These mirror tk::(Set|Restore)FocusGrab
|
469
|
+
|
470
|
+
# BWidget::SetFocusGrab --
|
471
|
+
# swap out current focus and grab temporarily (for dialogs)
|
472
|
+
# Arguments:
|
473
|
+
# grab new window to grab
|
474
|
+
# focus window to give focus to
|
475
|
+
# Results:
|
476
|
+
# Returns nothing
|
477
|
+
#
|
478
|
+
proc BWidget::SetFocusGrab {grab {focus {}}} {
|
479
|
+
variable _focusGrab
|
480
|
+
set index "$grab,$focus"
|
481
|
+
|
482
|
+
lappend _focusGrab($index) [::focus]
|
483
|
+
set oldGrab [::grab current $grab]
|
484
|
+
lappend _focusGrab($index) $oldGrab
|
485
|
+
if {[winfo exists $oldGrab]} {
|
486
|
+
lappend _focusGrab($index) [::grab status $oldGrab]
|
487
|
+
}
|
488
|
+
# The "grab" command will fail if another application
|
489
|
+
# already holds the grab. So catch it.
|
490
|
+
catch {::grab $grab}
|
491
|
+
if {[winfo exists $focus]} {
|
492
|
+
::focus $focus
|
493
|
+
}
|
494
|
+
}
|
495
|
+
|
496
|
+
# BWidget::RestoreFocusGrab --
|
497
|
+
# restore old focus and grab (for dialogs)
|
498
|
+
# Arguments:
|
499
|
+
# grab window that had taken grab
|
500
|
+
# focus window that had taken focus
|
501
|
+
# destroy destroy|withdraw - how to handle the old grabbed window
|
502
|
+
# Results:
|
503
|
+
# Returns nothing
|
504
|
+
#
|
505
|
+
proc BWidget::RestoreFocusGrab {grab focus {destroy destroy}} {
|
506
|
+
variable _focusGrab
|
507
|
+
set index "$grab,$focus"
|
508
|
+
if {[info exists _focusGrab($index)]} {
|
509
|
+
foreach {oldFocus oldGrab oldStatus} $_focusGrab($index) break
|
510
|
+
unset _focusGrab($index)
|
511
|
+
} else {
|
512
|
+
set oldGrab ""
|
513
|
+
}
|
514
|
+
|
515
|
+
catch {::focus $oldFocus}
|
516
|
+
::grab release $grab
|
517
|
+
if {[string equal $destroy "withdraw"]} {
|
518
|
+
wm withdraw $grab
|
519
|
+
} else {
|
520
|
+
::destroy $grab
|
521
|
+
}
|
522
|
+
if {[winfo exists $oldGrab] && [winfo ismapped $oldGrab]} {
|
523
|
+
if {[string equal $oldStatus "global"]} {
|
524
|
+
::grab -global $oldGrab
|
525
|
+
} else {
|
526
|
+
::grab $oldGrab
|
527
|
+
}
|
528
|
+
}
|
529
|
+
}
|
530
|
+
|
531
|
+
# BWidget::badOptionString --
|
532
|
+
#
|
533
|
+
# Helper function to return a proper error string when an option
|
534
|
+
# doesn't match a list of given options.
|
535
|
+
#
|
536
|
+
# Arguments:
|
537
|
+
# type A string that represents the type of option.
|
538
|
+
# value The value that is in-valid.
|
539
|
+
# list A list of valid options.
|
540
|
+
#
|
541
|
+
# Results:
|
542
|
+
# None.
|
543
|
+
proc BWidget::badOptionString {type value list} {
|
544
|
+
set last [lindex $list end]
|
545
|
+
set list [lreplace $list end end]
|
546
|
+
return "bad $type \"$value\": must be [join $list ", "], or $last"
|
547
|
+
}
|
548
|
+
|
549
|
+
|
550
|
+
proc BWidget::wrongNumArgsString { string } {
|
551
|
+
return "wrong # args: should be \"$string\""
|
552
|
+
}
|
553
|
+
|
554
|
+
|
555
|
+
proc BWidget::read_file { file } {
|
556
|
+
set fp [open $file]
|
557
|
+
set x [read $fp [file size $file]]
|
558
|
+
close $fp
|
559
|
+
return $x
|
560
|
+
}
|
561
|
+
|
562
|
+
|
563
|
+
proc BWidget::classes { class } {
|
564
|
+
variable use
|
565
|
+
|
566
|
+
${class}::use
|
567
|
+
set classes [list $class]
|
568
|
+
if {![info exists use($class)]} { return }
|
569
|
+
foreach class $use($class) {
|
570
|
+
eval lappend classes [classes $class]
|
571
|
+
}
|
572
|
+
return [lsort -unique $classes]
|
573
|
+
}
|
574
|
+
|
575
|
+
|
576
|
+
proc BWidget::library { args } {
|
577
|
+
variable use
|
578
|
+
|
579
|
+
set libs [list widget init utils]
|
580
|
+
set classes [list]
|
581
|
+
foreach class $args {
|
582
|
+
${class}::use
|
583
|
+
eval lappend classes [classes $class]
|
584
|
+
}
|
585
|
+
|
586
|
+
eval lappend libs [lsort -unique $classes]
|
587
|
+
|
588
|
+
set library ""
|
589
|
+
foreach lib $libs {
|
590
|
+
if {![info exists use($lib,file)]} {
|
591
|
+
set file [file join $::BWIDGET::LIBRARY $lib.tcl]
|
592
|
+
} else {
|
593
|
+
set file [file join $::BWIDGET::LIBRARY $use($lib,file).tcl]
|
594
|
+
}
|
595
|
+
append library [read_file $file]
|
596
|
+
}
|
597
|
+
|
598
|
+
return $library
|
599
|
+
}
|
600
|
+
|
601
|
+
|
602
|
+
proc BWidget::inuse { class } {
|
603
|
+
variable ::Widget::_inuse
|
604
|
+
|
605
|
+
if {![info exists _inuse($class)]} { return 0 }
|
606
|
+
return [expr $_inuse($class) > 0]
|
607
|
+
}
|
608
|
+
|
609
|
+
|
610
|
+
proc BWidget::write { filename {mode w} } {
|
611
|
+
variable use
|
612
|
+
|
613
|
+
if {![info exists use(classes)]} { return }
|
614
|
+
|
615
|
+
set classes [list]
|
616
|
+
foreach class $use(classes) {
|
617
|
+
if {![inuse $class]} { continue }
|
618
|
+
lappend classes $class
|
619
|
+
}
|
620
|
+
|
621
|
+
set fp [open $filename $mode]
|
622
|
+
puts $fp [eval library $classes]
|
623
|
+
close $fp
|
624
|
+
|
625
|
+
return
|
626
|
+
}
|
627
|
+
|
628
|
+
|
629
|
+
# BWidget::bindMouseWheel --
|
630
|
+
#
|
631
|
+
# Bind mouse wheel actions to a given widget.
|
632
|
+
#
|
633
|
+
# Arguments:
|
634
|
+
# widget - The widget to bind.
|
635
|
+
#
|
636
|
+
# Results:
|
637
|
+
# None.
|
638
|
+
proc BWidget::bindMouseWheel { widget } {
|
639
|
+
bind $widget <MouseWheel> {%W yview scroll [expr {-%D/24}] units}
|
640
|
+
bind $widget <Shift-MouseWheel> {%W yview scroll [expr {-%D/120}] pages}
|
641
|
+
bind $widget <Control-MouseWheel> {%W yview scroll [expr {-%D/120}] units}
|
642
|
+
|
643
|
+
bind $widget <Button-4> {event generate %W <MouseWheel> -delta 120}
|
644
|
+
bind $widget <Button-5> {event generate %W <MouseWheel> -delta -120}
|
645
|
+
}
|