arcadia 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. data/README +126 -123
  2. data/arcadia.rb +770 -756
  3. data/base/a-contracts.rb +130 -93
  4. data/base/a-ext.rb +280 -280
  5. data/base/a-libs.rb +5 -11
  6. data/base/a-utils.rb +235 -44
  7. data/conf/arcadia.conf +20 -16
  8. data/conf/arcadia.init.rb +0 -0
  9. data/conf/arcadia.res.rb +74 -0
  10. data/ext/ae-complete-code/ae-complete-code.conf +0 -0
  11. data/ext/ae-complete-code/ae-complete-code.rb +80 -79
  12. data/ext/ae-debug/ae-debug.conf +0 -0
  13. data/ext/ae-debug/ae-debug.rb +2 -6
  14. data/ext/ae-debug/debug1.57.rb +0 -0
  15. data/ext/ae-doc-code/ae-doc-code.conf +15 -0
  16. data/ext/ae-doc-code/ae-doc-code.rb +289 -0
  17. data/ext/ae-editor/ae-editor.conf +17 -8
  18. data/ext/ae-editor/ae-editor.rb +738 -396
  19. data/ext/ae-event-log/ae-event-log.conf +0 -0
  20. data/ext/ae-event-log/ae-event-log.rb +0 -0
  21. data/ext/ae-file-history/ae-file-history.conf +2 -2
  22. data/ext/ae-file-history/ae-file-history.rb +286 -290
  23. data/ext/ae-inspector/ae-inspector.conf +0 -0
  24. data/ext/ae-inspector/ae-inspector.rb +0 -0
  25. data/ext/ae-output-event/ae-output-event.conf +2 -2
  26. data/ext/ae-output/ae-output.conf +2 -2
  27. data/ext/ae-output/ae-output.rb +173 -178
  28. data/ext/ae-palette/ae-palette.conf +0 -0
  29. data/ext/ae-palette/ae-palette.rb +0 -0
  30. data/ext/ae-shell/ae-shell.conf +0 -0
  31. data/ext/ae-shell/ae-shell.rb +54 -54
  32. data/lib/tk/al-tk.rb +3076 -3082
  33. data/lib/tk/al-tk.res.rb +0 -0
  34. data/lib/tk/al-tkarcadia.rb +0 -0
  35. data/lib/tk/al-tkcustom.rb +0 -0
  36. data/lib/tkext/al-bwidget.rb +0 -0
  37. data/lib/tkext/al-iwidgets.rb +0 -0
  38. data/lib/tkext/al-tile.rb +0 -0
  39. data/lib/tkext/al-tktable.rb +0 -0
  40. data/tcl/BWidget-1.8.0/BWman/ArrowButton.html +276 -0
  41. data/tcl/BWidget-1.8.0/BWman/BWidget.html +228 -0
  42. data/tcl/BWidget-1.8.0/BWman/Button.html +273 -0
  43. data/tcl/BWidget-1.8.0/BWman/ButtonBox.html +264 -0
  44. data/tcl/BWidget-1.8.0/BWman/ComboBox.html +402 -0
  45. data/tcl/BWidget-1.8.0/BWman/Dialog.html +314 -0
  46. data/tcl/BWidget-1.8.0/BWman/DragSite.html +139 -0
  47. data/tcl/BWidget-1.8.0/BWman/DropSite.html +254 -0
  48. data/tcl/BWidget-1.8.0/BWman/DynamicHelp.html +248 -0
  49. data/tcl/BWidget-1.8.0/BWman/Entry.html +341 -0
  50. data/tcl/BWidget-1.8.0/BWman/Label.html +331 -0
  51. data/tcl/BWidget-1.8.0/BWman/LabelEntry.html +194 -0
  52. data/tcl/BWidget-1.8.0/BWman/LabelFrame.html +144 -0
  53. data/tcl/BWidget-1.8.0/BWman/ListBox.html +678 -0
  54. data/tcl/BWidget-1.8.0/BWman/MainFrame.html +283 -0
  55. data/tcl/BWidget-1.8.0/BWman/MessageDlg.html +218 -0
  56. data/tcl/BWidget-1.8.0/BWman/NoteBook.html +374 -0
  57. data/tcl/BWidget-1.8.0/BWman/PagesManager.html +180 -0
  58. data/tcl/BWidget-1.8.0/BWman/PanedWindow.html +142 -0
  59. data/tcl/BWidget-1.8.0/BWman/PanelFrame.html +153 -0
  60. data/tcl/BWidget-1.8.0/BWman/PasswdDlg.html +214 -0
  61. data/tcl/BWidget-1.8.0/BWman/ProgressBar.html +152 -0
  62. data/tcl/BWidget-1.8.0/BWman/ProgressDlg.html +145 -0
  63. data/tcl/BWidget-1.8.0/BWman/ScrollView.html +130 -0
  64. data/tcl/BWidget-1.8.0/BWman/ScrollableFrame.html +191 -0
  65. data/tcl/BWidget-1.8.0/BWman/ScrolledWindow.html +116 -0
  66. data/tcl/BWidget-1.8.0/BWman/SelectColor.html +164 -0
  67. data/tcl/BWidget-1.8.0/BWman/SelectFont.html +152 -0
  68. data/tcl/BWidget-1.8.0/BWman/Separator.html +77 -0
  69. data/tcl/BWidget-1.8.0/BWman/SpinBox.html +250 -0
  70. data/tcl/BWidget-1.8.0/BWman/StatusBar.html +147 -0
  71. data/tcl/BWidget-1.8.0/BWman/TitleFrame.html +107 -0
  72. data/tcl/BWidget-1.8.0/BWman/Tree.html +947 -0
  73. data/tcl/BWidget-1.8.0/BWman/Widget.html +502 -0
  74. data/tcl/BWidget-1.8.0/BWman/contents.html +84 -0
  75. data/tcl/BWidget-1.8.0/BWman/index.html +7 -0
  76. data/tcl/BWidget-1.8.0/BWman/navtree.html +41 -0
  77. data/tcl/BWidget-1.8.0/BWman/options.htm +458 -0
  78. data/tcl/BWidget-1.8.0/CHANGES.txt +266 -0
  79. data/tcl/BWidget-1.8.0/ChangeLog +1641 -0
  80. data/tcl/BWidget-1.8.0/LICENSE.txt +41 -0
  81. data/tcl/BWidget-1.8.0/README.txt +127 -0
  82. data/tcl/BWidget-1.8.0/arrow.tcl +551 -0
  83. data/tcl/BWidget-1.8.0/bitmap.tcl +94 -0
  84. data/tcl/BWidget-1.8.0/button.tcl +324 -0
  85. data/tcl/BWidget-1.8.0/buttonbox.tcl +403 -0
  86. data/tcl/BWidget-1.8.0/color.tcl +493 -0
  87. data/tcl/BWidget-1.8.0/combobox.tcl +809 -0
  88. data/tcl/BWidget-1.8.0/demo/basic.tcl +199 -0
  89. data/tcl/BWidget-1.8.0/demo/bwidget.xbm +46 -0
  90. data/tcl/BWidget-1.8.0/demo/demo.tcl +212 -0
  91. data/tcl/BWidget-1.8.0/demo/dnd.tcl +42 -0
  92. data/tcl/BWidget-1.8.0/demo/manager.tcl +141 -0
  93. data/tcl/BWidget-1.8.0/demo/select.tcl +59 -0
  94. data/tcl/BWidget-1.8.0/demo/tmpldlg.tcl +214 -0
  95. data/tcl/BWidget-1.8.0/demo/tree.tcl +260 -0
  96. data/tcl/BWidget-1.8.0/demo/x1.xbm +2258 -0
  97. data/tcl/BWidget-1.8.0/dialog.tcl +345 -0
  98. data/tcl/BWidget-1.8.0/dragsite.tcl +197 -0
  99. data/tcl/BWidget-1.8.0/dropsite.tcl +455 -0
  100. data/tcl/BWidget-1.8.0/dynhelp.tcl +625 -0
  101. data/tcl/BWidget-1.8.0/entry.tcl +469 -0
  102. data/tcl/BWidget-1.8.0/font.tcl +566 -0
  103. data/tcl/BWidget-1.8.0/images/bold.gif +0 -0
  104. data/tcl/BWidget-1.8.0/images/copy.gif +0 -0
  105. data/tcl/BWidget-1.8.0/images/cut.gif +0 -0
  106. data/tcl/BWidget-1.8.0/images/dragfile.gif +0 -0
  107. data/tcl/BWidget-1.8.0/images/dragicon.gif +0 -0
  108. data/tcl/BWidget-1.8.0/images/error.gif +0 -0
  109. data/tcl/BWidget-1.8.0/images/file.gif +0 -0
  110. data/tcl/BWidget-1.8.0/images/folder.gif +0 -0
  111. data/tcl/BWidget-1.8.0/images/hourglass.gif +0 -0
  112. data/tcl/BWidget-1.8.0/images/info.gif +0 -0
  113. data/tcl/BWidget-1.8.0/images/italic.gif +0 -0
  114. data/tcl/BWidget-1.8.0/images/minus.xbm +5 -0
  115. data/tcl/BWidget-1.8.0/images/new.gif +0 -0
  116. data/tcl/BWidget-1.8.0/images/opcopy.xbm +5 -0
  117. data/tcl/BWidget-1.8.0/images/open.gif +0 -0
  118. data/tcl/BWidget-1.8.0/images/openfold.gif +0 -0
  119. data/tcl/BWidget-1.8.0/images/oplink.xbm +5 -0
  120. data/tcl/BWidget-1.8.0/images/opmove.xbm +5 -0
  121. data/tcl/BWidget-1.8.0/images/overstrike.gif +0 -0
  122. data/tcl/BWidget-1.8.0/images/palette.gif +0 -0
  123. data/tcl/BWidget-1.8.0/images/passwd.gif +0 -0
  124. data/tcl/BWidget-1.8.0/images/paste.gif +0 -0
  125. data/tcl/BWidget-1.8.0/images/plus.xbm +5 -0
  126. data/tcl/BWidget-1.8.0/images/print.gif +0 -0
  127. data/tcl/BWidget-1.8.0/images/question.gif +0 -0
  128. data/tcl/BWidget-1.8.0/images/redo.gif +0 -0
  129. data/tcl/BWidget-1.8.0/images/save.gif +0 -0
  130. data/tcl/BWidget-1.8.0/images/target.xbm +9 -0
  131. data/tcl/BWidget-1.8.0/images/underline.gif +0 -0
  132. data/tcl/BWidget-1.8.0/images/undo.gif +0 -0
  133. data/tcl/BWidget-1.8.0/images/warning.gif +0 -0
  134. data/tcl/BWidget-1.8.0/init.tcl +40 -0
  135. data/tcl/BWidget-1.8.0/label.tcl +271 -0
  136. data/tcl/BWidget-1.8.0/labelentry.tcl +100 -0
  137. data/tcl/BWidget-1.8.0/labelframe.tcl +160 -0
  138. data/tcl/BWidget-1.8.0/lang/da.rc +52 -0
  139. data/tcl/BWidget-1.8.0/lang/de.rc +52 -0
  140. data/tcl/BWidget-1.8.0/lang/en.rc +52 -0
  141. data/tcl/BWidget-1.8.0/lang/es.rc +53 -0
  142. data/tcl/BWidget-1.8.0/lang/fr.rc +52 -0
  143. data/tcl/BWidget-1.8.0/listbox.tcl +1638 -0
  144. data/tcl/BWidget-1.8.0/mainframe.tcl +711 -0
  145. data/tcl/BWidget-1.8.0/messagedlg.tcl +128 -0
  146. data/tcl/BWidget-1.8.0/notebook.tcl +1164 -0
  147. data/tcl/BWidget-1.8.0/pagesmgr.tcl +294 -0
  148. data/tcl/BWidget-1.8.0/panedw.tcl +381 -0
  149. data/tcl/BWidget-1.8.0/panelframe.tcl +246 -0
  150. data/tcl/BWidget-1.8.0/passwddlg.tcl +178 -0
  151. data/tcl/BWidget-1.8.0/pkgIndex.tcl +47 -0
  152. data/tcl/BWidget-1.8.0/progressbar.tcl +208 -0
  153. data/tcl/BWidget-1.8.0/progressdlg.tcl +87 -0
  154. data/tcl/BWidget-1.8.0/scrollframe.tcl +226 -0
  155. data/tcl/BWidget-1.8.0/scrollview.tcl +254 -0
  156. data/tcl/BWidget-1.8.0/scrollw.tcl +280 -0
  157. data/tcl/BWidget-1.8.0/separator.tcl +75 -0
  158. data/tcl/BWidget-1.8.0/spinbox.tcl +331 -0
  159. data/tcl/BWidget-1.8.0/statusbar.tcl +422 -0
  160. data/tcl/BWidget-1.8.0/tests/entry.test +173 -0
  161. data/tcl/BWidget-1.8.0/titleframe.tcl +170 -0
  162. data/tcl/BWidget-1.8.0/tree.tcl +2228 -0
  163. data/tcl/BWidget-1.8.0/utils.tcl +645 -0
  164. data/tcl/BWidget-1.8.0/widget.tcl +1576 -0
  165. data/tcl/BWidget-1.8.0/wizard.tcl +1028 -0
  166. data/tcl/BWidget-1.8.0/xpm2image.tcl +115 -0
  167. metadata +141 -5
@@ -0,0 +1,75 @@
1
+ # ------------------------------------------------------------------------------
2
+ # separator.tcl
3
+ # This file is part of Unifix BWidget Toolkit
4
+ # ------------------------------------------------------------------------------
5
+ # Index of commands:
6
+ # - Separator::create
7
+ # - Separator::configure
8
+ # - Separator::cget
9
+ # ------------------------------------------------------------------------------
10
+
11
+ namespace eval Separator {
12
+ Widget::define Separator separator
13
+
14
+ Widget::declare Separator {
15
+ {-background TkResource "" 0 frame}
16
+ {-cursor TkResource "" 0 frame}
17
+ {-relief Enum groove 0 {ridge groove}}
18
+ {-orient Enum horizontal 1 {horizontal vertical}}
19
+ {-bg Synonym -background}
20
+ }
21
+ Widget::addmap Separator "" :cmd { -background {} -cursor {} }
22
+
23
+ bind Separator <Destroy> [list Widget::destroy %W]
24
+ }
25
+
26
+
27
+ # ------------------------------------------------------------------------------
28
+ # Command Separator::create
29
+ # ------------------------------------------------------------------------------
30
+ proc Separator::create { path args } {
31
+ array set maps [list Separator {} :cmd {}]
32
+ array set maps [Widget::parseArgs Separator $args]
33
+ eval [list frame $path] $maps(:cmd) -class Separator
34
+ Widget::initFromODB Separator $path $maps(Separator)
35
+
36
+ if { [Widget::cget $path -orient] == "horizontal" } {
37
+ $path configure -borderwidth 1 -height 2
38
+ } else {
39
+ $path configure -borderwidth 1 -width 2
40
+ }
41
+
42
+ if { [string equal [Widget::cget $path -relief] "groove"] } {
43
+ $path configure -relief sunken
44
+ } else {
45
+ $path configure -relief raised
46
+ }
47
+
48
+ return [Widget::create Separator $path]
49
+ }
50
+
51
+
52
+ # ------------------------------------------------------------------------------
53
+ # Command Separator::configure
54
+ # ------------------------------------------------------------------------------
55
+ proc Separator::configure { path args } {
56
+ set res [Widget::configure $path $args]
57
+
58
+ if { [Widget::hasChanged $path -relief relief] } {
59
+ if { $relief == "groove" } {
60
+ $path:cmd configure -relief sunken
61
+ } else {
62
+ $path:cmd configure -relief raised
63
+ }
64
+ }
65
+
66
+ return $res
67
+ }
68
+
69
+
70
+ # ------------------------------------------------------------------------------
71
+ # Command Separator::cget
72
+ # ------------------------------------------------------------------------------
73
+ proc Separator::cget { path option } {
74
+ return [Widget::cget $path $option]
75
+ }
@@ -0,0 +1,331 @@
1
+ # spinbox.tcl --
2
+ #
3
+ # BWidget SpinBox implementation.
4
+ #
5
+ # Copyright (c) 1999 by Unifix
6
+ # Copyright (c) 2000 by Ajuba Solutions
7
+ # All rights reserved.
8
+ #
9
+ # RCS: @(#) $Id: spinbox.tcl,v 1.12 2003/10/20 21:23:52 damonc Exp $
10
+ # -----------------------------------------------------------------------------
11
+ # Index of commands:
12
+ # - SpinBox::create
13
+ # - SpinBox::configure
14
+ # - SpinBox::cget
15
+ # - SpinBox::setvalue
16
+ # - SpinBox::_destroy
17
+ # - SpinBox::_modify_value
18
+ # - SpinBox::_test_options
19
+ # -----------------------------------------------------------------------------
20
+
21
+ namespace eval SpinBox {
22
+ Widget::define SpinBox spinbox Entry ArrowButton
23
+
24
+ Widget::tkinclude SpinBox frame :cmd \
25
+ include {-background -borderwidth -bg -bd -relief} \
26
+ initialize {-relief sunken -borderwidth 2}
27
+
28
+ Widget::bwinclude SpinBox Entry .e \
29
+ remove {-relief -bd -borderwidth -fg -bg} \
30
+ rename {-foreground -entryfg -background -entrybg}
31
+
32
+ Widget::declare SpinBox {
33
+ {-range String "" 0}
34
+ {-values String "" 0}
35
+ {-modifycmd String "" 0}
36
+ {-repeatdelay Int 400 0 {%d >= 0}}
37
+ {-repeatinterval Int 100 0 {%d >= 0}}
38
+ {-foreground TkResource black 0 {button}}
39
+ }
40
+
41
+ Widget::addmap SpinBox "" :cmd {-background {}}
42
+ Widget::addmap SpinBox ArrowButton .arrup {
43
+ -foreground {} -background {} -disabledforeground {} -state {} \
44
+ -repeatinterval {} -repeatdelay {}
45
+ }
46
+ Widget::addmap SpinBox ArrowButton .arrdn {
47
+ -foreground {} -background {} -disabledforeground {} -state {} \
48
+ -repeatinterval {} -repeatdelay {}
49
+ }
50
+
51
+ ::bind SpinBox <FocusIn> [list after idle {BWidget::refocus %W %W.e}]
52
+ ::bind SpinBox <Destroy> [list SpinBox::_destroy %W]
53
+
54
+ variable _widget
55
+ }
56
+
57
+
58
+ # -----------------------------------------------------------------------------
59
+ # Command SpinBox::create
60
+ # -----------------------------------------------------------------------------
61
+ proc SpinBox::create { path args } {
62
+ array set maps [list SpinBox {} :cmd {} .e {} .arrup {} .arrdn {}]
63
+ array set maps [Widget::parseArgs SpinBox $args]
64
+ eval [list frame $path] $maps(:cmd) \
65
+ [list -highlightthickness 0 -takefocus 0 -class SpinBox]
66
+ Widget::initFromODB SpinBox $path $maps(SpinBox)
67
+
68
+ set entry [eval [list Entry::create $path.e] $maps(.e) -relief flat -bd 0]
69
+ bindtags $path.e [linsert [bindtags $path.e] 1 SpinBoxEntry]
70
+
71
+ set farr [frame $path.farr -relief flat -bd 0 -highlightthickness 0]
72
+ set height [expr {[winfo reqheight $path.e]/2-2}]
73
+ set width 11
74
+ set arrup [eval [list ArrowButton::create $path.arrup -dir top] \
75
+ $maps(.arrup) \
76
+ [list -highlightthickness 0 -borderwidth 1 -takefocus 0 \
77
+ -type button -width $width -height $height \
78
+ -armcommand [list SpinBox::_modify_value $path next arm] \
79
+ -disarmcommand [list SpinBox::_modify_value $path next disarm]]]
80
+ set arrdn [eval [list ArrowButton::create $path.arrdn -dir bottom] \
81
+ $maps(.arrdn) \
82
+ [list -highlightthickness 0 -borderwidth 1 -takefocus 0 \
83
+ -type button -width $width -height $height \
84
+ -armcommand [list SpinBox::_modify_value $path previous arm] \
85
+ -disarmcommand [list SpinBox::_modify_value $path previous disarm]]]
86
+
87
+ # --- update SpinBox value ---
88
+ _test_options $path
89
+ set val [Entry::cget $path.e -text]
90
+ if { [string equal $val ""] } {
91
+ Entry::configure $path.e -text $::SpinBox::_widget($path,curval)
92
+ } else {
93
+ set ::SpinBox::_widget($path,curval) $val
94
+ }
95
+
96
+ grid $arrup -in $farr -column 0 -row 0 -sticky nsew
97
+ grid $arrdn -in $farr -column 0 -row 2 -sticky nsew
98
+ grid rowconfigure $farr 0 -weight 1
99
+ grid rowconfigure $farr 2 -weight 1
100
+
101
+ pack $farr -side right -fill y
102
+ pack $entry -side left -fill both -expand yes
103
+
104
+ ::bind $entry <Key-Up> [list SpinBox::_modify_value $path next activate]
105
+ ::bind $entry <Key-Down> [list SpinBox::_modify_value $path previous activate]
106
+ ::bind $entry <Key-Prior> [list SpinBox::_modify_value $path last activate]
107
+ ::bind $entry <Key-Next> [list SpinBox::_modify_value $path first activate]
108
+
109
+ ::bind $farr <Configure> {grid rowconfigure %W 1 -minsize [expr {%h%%2}]}
110
+
111
+ return [Widget::create SpinBox $path]
112
+ }
113
+
114
+ # -----------------------------------------------------------------------------
115
+ # Command SpinBox::configure
116
+ # -----------------------------------------------------------------------------
117
+ proc SpinBox::configure { path args } {
118
+ set res [Widget::configure $path $args]
119
+ if { [Widget::hasChangedX $path -values] ||
120
+ [Widget::hasChangedX $path -range] } {
121
+ _test_options $path
122
+ }
123
+ return $res
124
+ }
125
+
126
+
127
+ # -----------------------------------------------------------------------------
128
+ # Command SpinBox::cget
129
+ # -----------------------------------------------------------------------------
130
+ proc SpinBox::cget { path option } {
131
+ return [Widget::cget $path $option]
132
+ }
133
+
134
+
135
+ # -----------------------------------------------------------------------------
136
+ # Command SpinBox::setvalue
137
+ # -----------------------------------------------------------------------------
138
+ proc SpinBox::setvalue { path index } {
139
+ variable _widget
140
+
141
+ set values [Widget::getMegawidgetOption $path -values]
142
+ set value [Entry::cget $path.e -text]
143
+
144
+ if { [llength $values] } {
145
+ # --- -values SpinBox ---
146
+ switch -- $index {
147
+ next {
148
+ if { [set idx [lsearch $values $value]] != -1 } {
149
+ incr idx
150
+ } elseif { [set idx [lsearch $values "$value*"]] == -1 } {
151
+ set idx [lsearch $values $_widget($path,curval)]
152
+ }
153
+ }
154
+ previous {
155
+ if { [set idx [lsearch $values $value]] != -1 } {
156
+ incr idx -1
157
+ } elseif { [set idx [lsearch $values "$value*"]] == -1 } {
158
+ set idx [lsearch $values $_widget($path,curval)]
159
+ }
160
+ }
161
+ first {
162
+ set idx 0
163
+ }
164
+ last {
165
+ set idx [expr {[llength $values]-1}]
166
+ }
167
+ default {
168
+ if { [string index $index 0] == "@" } {
169
+ set idx [string range $index 1 end]
170
+ if { [catch {string compare [expr {int($idx)}] $idx} res] || $res != 0 } {
171
+ return -code error "bad index \"$index\""
172
+ }
173
+ } else {
174
+ return -code error "bad index \"$index\""
175
+ }
176
+ }
177
+ }
178
+ if { $idx >= 0 && $idx < [llength $values] } {
179
+ set newval [lindex $values $idx]
180
+ } else {
181
+ return 0
182
+ }
183
+ } else {
184
+ # --- -range SpinBox ---
185
+ foreach {vmin vmax incr} [Widget::getMegawidgetOption $path -range] {
186
+ break
187
+ }
188
+ # Allow zero padding on the value; strip it out for calculation by
189
+ # scanning the value into a floating point number.
190
+ scan $value %f value
191
+ switch -- $index {
192
+ next {
193
+ if { [catch {expr {double($value-$vmin)/$incr}} idx] } {
194
+ set newval $_widget($path,curval)
195
+ } else {
196
+ set newval [expr {$vmin+(round($idx)+1)*$incr}]
197
+ if { $newval < $vmin } {
198
+ set newval $vmin
199
+ } elseif { $newval > $vmax } {
200
+ set newval $vmax
201
+ }
202
+ }
203
+ }
204
+ previous {
205
+ if { [catch {expr {double($value-$vmin)/$incr}} idx] } {
206
+ set newval $_widget($path,curval)
207
+ } else {
208
+ set newval [expr {$vmin+(round($idx)-1)*$incr}]
209
+ if { $newval < $vmin } {
210
+ set newval $vmin
211
+ } elseif { $newval > $vmax } {
212
+ set newval $vmax
213
+ }
214
+ }
215
+ }
216
+ first {
217
+ set newval $vmin
218
+ }
219
+ last {
220
+ set newval $vmax
221
+ }
222
+ default {
223
+ if { [string index $index 0] == "@" } {
224
+ set idx [string range $index 1 end]
225
+ if { [catch {string compare [expr {int($idx)}] $idx} res] || $res != 0 } {
226
+ return -code error "bad index \"$index\""
227
+ }
228
+ set newval [expr {$vmin+int($idx)*$incr}]
229
+ if { $newval < $vmin || $newval > $vmax } {
230
+ return 0
231
+ }
232
+ } else {
233
+ return -code error "bad index \"$index\""
234
+ }
235
+ }
236
+ }
237
+ }
238
+ set _widget($path,curval) $newval
239
+ Entry::configure $path.e -text $newval
240
+ return 1
241
+ }
242
+
243
+
244
+ # -----------------------------------------------------------------------------
245
+ # Command SpinBox::getvalue
246
+ # -----------------------------------------------------------------------------
247
+ proc SpinBox::getvalue { path } {
248
+ variable _widget
249
+
250
+ set values [Widget::getMegawidgetOption $path -values]
251
+ set value [Entry::cget $path.e -text]
252
+
253
+ if { [llength $values] } {
254
+ # --- -values SpinBox ---
255
+ return [lsearch $values $value]
256
+ } else {
257
+ foreach {vmin vmax incr} [Widget::getMegawidgetOption $path -range] {
258
+ break
259
+ }
260
+ if { ![catch {expr {double($value-$vmin)/$incr}} idx] &&
261
+ $idx == int($idx) } {
262
+ return [expr {int($idx)}]
263
+ }
264
+ return -1
265
+ }
266
+ }
267
+
268
+
269
+ # -----------------------------------------------------------------------------
270
+ # Command SpinBox::bind
271
+ # -----------------------------------------------------------------------------
272
+ proc SpinBox::bind { path args } {
273
+ return [eval [list ::bind $path.e] $args]
274
+ }
275
+
276
+
277
+ # -----------------------------------------------------------------------------
278
+ # Command SpinBox::_modify_value
279
+ # -----------------------------------------------------------------------------
280
+ proc SpinBox::_modify_value { path direction reason } {
281
+ if { $reason == "arm" || $reason == "activate" } {
282
+ SpinBox::setvalue $path $direction
283
+ }
284
+ if { ($reason == "disarm" || $reason == "activate") &&
285
+ [set cmd [Widget::getMegawidgetOption $path -modifycmd]] != "" } {
286
+ uplevel \#0 $cmd
287
+ }
288
+ }
289
+
290
+ # -----------------------------------------------------------------------------
291
+ # Command SpinBox::_test_options
292
+ # -----------------------------------------------------------------------------
293
+ proc SpinBox::_test_options { path } {
294
+ set values [Widget::getMegawidgetOption $path -values]
295
+ if { [llength $values] } {
296
+ set ::SpinBox::_widget($path,curval) [lindex $values 0]
297
+ } else {
298
+ foreach {vmin vmax incr} [Widget::getMegawidgetOption $path -range] {
299
+ break
300
+ }
301
+ set update 0
302
+ if { [catch {expr {int($vmin)}}] } {
303
+ set vmin 0
304
+ set update 1
305
+ }
306
+ if { [catch {expr {$vmax<$vmin}} res] || $res } {
307
+ set vmax $vmin
308
+ set update 1
309
+ }
310
+ if { [catch {expr {$incr<0}} res] || $res } {
311
+ set incr 1
312
+ set update 1
313
+ }
314
+ # Only do the set back (which is expensive) if we changed a value
315
+ if { $update } {
316
+ Widget::setMegawidgetOption $path -range [list $vmin $vmax $incr]
317
+ }
318
+ set ::SpinBox::_widget($path,curval) $vmin
319
+ }
320
+ }
321
+
322
+
323
+ # -----------------------------------------------------------------------------
324
+ # Command SpinBox::_destroy
325
+ # -----------------------------------------------------------------------------
326
+ proc SpinBox::_destroy { path } {
327
+ variable _widget
328
+
329
+ unset _widget($path,curval)
330
+ Widget::destroy $path
331
+ }
@@ -0,0 +1,422 @@
1
+ # ------------------------------------------------------------------------
2
+ # statusbar.tcl
3
+ # Create a status bar Tk widget
4
+ #
5
+ # Provides a status bar to be placed at the bottom of a toplevel.
6
+ # Currently does not support being placed in a toplevel that has
7
+ # gridding applied (via widget -setgrid or wm grid).
8
+ #
9
+ # Ensure that the widget is placed at the very bottom of the toplevel,
10
+ # otherwise the resize behavior may behave oddly.
11
+ # ------------------------------------------------------------------------
12
+
13
+ package require Tk 8.3
14
+
15
+ if {0} {
16
+ proc sample {} {
17
+ # sample usage
18
+ eval destroy [winfo children .]
19
+ pack [text .t -width 0 -height 0] -fill both -expand 1
20
+
21
+ set sbar .s
22
+ StatusBar $sbar
23
+ pack $sbar -side bottom -fill x
24
+ set f [$sbar getframe]
25
+
26
+ # Specify -width 1 for the label widget so it truncates nicely
27
+ # instead of requesting large sizes for long messages
28
+ set w [label $f.status -width 1 -anchor w -textvariable ::STATUS]
29
+ set ::STATUS "This is a status message"
30
+ # give the entry weight, as we want it to be the one that expands
31
+ $sbar add $w -weight 1
32
+
33
+ # BWidget's progressbar
34
+ set w [ProgressBar $f.bpbar -orient horizontal \
35
+ -variable ::PROGRESS -bd 1 -relief sunken]
36
+ set ::PROGRESS 50
37
+ $sbar add $w
38
+ }
39
+ }
40
+
41
+ namespace eval StatusBar {
42
+ Widget::define StatusBar statusbar
43
+
44
+ Widget::declare StatusBar {
45
+ {-background TkResource "" 0 frame}
46
+ {-borderwidth TkResource 0 0 frame}
47
+ {-relief TkResource flat 0 frame}
48
+ {-showseparator Boolean 1 0}
49
+ {-showresizesep Boolean 0 0}
50
+ {-showresize Boolean 1 0}
51
+ {-width TkResource 100 0 frame}
52
+ {-height TkResource 18 0 frame}
53
+ {-ipad String 1 0}
54
+ {-pad String 0 0}
55
+ {-bg Synonym -background}
56
+ {-bd Synonym -borderwidth}
57
+ }
58
+
59
+ # -background, -borderwidth and -relief apply to outer frame, but relief
60
+ # should be left flat for proper look
61
+ Widget::addmap StatusBar "" :cmd {
62
+ -background {} -width {} -height {} -borderwidth {} -relief {}
63
+ }
64
+ Widget::addmap StatusBar "" .sbar {
65
+ -background {}
66
+ }
67
+ Widget::addmap StatusBar "" .resize {
68
+ -background {}
69
+ }
70
+ Widget::addmap StatusBar "" .hsep {
71
+ -background {}
72
+ }
73
+
74
+ # -pad provides general padding around the status bar
75
+ # -ipad provides padding around each status bar item
76
+ # Padding can be a list of {padx pady}
77
+
78
+ variable HaveMarlett \
79
+ [expr {[lsearch -exact [font families] "Marlett"] != -1}]
80
+
81
+ bind StatusResize <1> \
82
+ [namespace code [list begin_resize %W %X %Y]]
83
+ bind StatusResize <B1-Motion> \
84
+ [namespace code [list continue_resize %W %X %Y]]
85
+ bind StatusResize <ButtonRelease-1> \
86
+ [namespace code [list end_resize %W %X %Y]]
87
+
88
+ bind StatusBar <Destroy> [list StatusBar::_destroy %W]
89
+
90
+ # PNG version has partial alpha transparency for better look
91
+ variable pngdata {
92
+ iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAFM0aXcAAAABGdBTUEAAYagM
93
+ eiWXwAAAGJJREFUGJW9kVEOgCAMQzs8GEezN69fkKlbUAz2r3l5NGTA+pCU+Q
94
+ IA5sv39wGgZKClZGBhJMVTklRr3VNwMz04mVfQzQiEm79EkrYZycxIkq8kkv2
95
+ v6RFGku9TUrj8RGr9AGy6mhv2ymLwAAAAAElFTkSuQmCC
96
+ }
97
+ variable gifdata {
98
+ R0lGODlhDwAPAJEAANnZ2f///4CAgD8/PyH5BAEAAAAALAAAAAAPAA8AAAJEh
99
+ I+py+1IQvh4IZlG0Qg+QshkAokGQfAvZCBIhG8hA0Ea4UPIQJBG+BAyEKQhCH
100
+ bIQAgNEQCAIA0hAyE0AEIGgjSEDBQAOw==
101
+ }
102
+ if {[package provide img::png] != ""} {
103
+ image create photo ::StatusBar::resizer -format PNG -data $pngdata
104
+ } else {
105
+ image create photo ::StatusBar::resizer -format GIF -data $gifdata
106
+ }
107
+ }
108
+
109
+
110
+ # ------------------------------------------------------------------------
111
+ # Command StatusBar::create
112
+ # ------------------------------------------------------------------------
113
+ proc StatusBar::create { path args } {
114
+ variable _widget
115
+ variable HaveMarlett
116
+
117
+ # Allow for img::png loaded after initial source
118
+ if {[package provide img::png] != ""} {
119
+ variable pngdata
120
+ ::StatusBar::resizer configure -format PNG -data $pngdata
121
+ }
122
+
123
+ Widget::init StatusBar $path $args
124
+
125
+ eval [list frame $path -class StatusBar] [Widget::subcget $path :cmd]
126
+
127
+ foreach {padx pady} [_padval [Widget::cget $path -pad]] \
128
+ {ipadx ipady} [_padval [Widget::cget $path -ipad]] { break }
129
+
130
+ if {[Widget::theme]} {
131
+ set sbar [ttk::frame $path.sbar -padding [list $padx $pady]]
132
+ } else {
133
+ set sbar [eval [list frame $path.sbar -padx $padx -pady $pady] \
134
+ [Widget::subcget $path .sbar]]
135
+ }
136
+ if {[string equal $::tcl_platform(platform) "windows"]} {
137
+ set cursor size_nw_se
138
+ } else {
139
+ set cursor sizing; # bottom_right_corner ??
140
+ }
141
+ set resize [eval [list label $path.resize] \
142
+ [Widget::subcget $path .resize] \
143
+ [list -borderwidth 0 -relief flat -anchor se \
144
+ -cursor $cursor -anchor se -padx 0 -pady 0]]
145
+ if {$HaveMarlett} {
146
+ $resize configure -font "Marlett -16" -text \u006f
147
+ } else {
148
+ $resize configure -image ::StatusBar::resizer
149
+ }
150
+ bindtags $resize [list all [winfo toplevel $path] StatusResize $resize]
151
+
152
+ if {[Widget::theme]} {
153
+ set fsep [ttk::separator $path.hsep -orient horizontal]
154
+ } else {
155
+ set fsep [eval [list frame $path.hsep -bd 1 -height 2 -relief sunken] \
156
+ [Widget::subcget $path .hsep]]
157
+ }
158
+ set sep [_sep $path sepresize {}]
159
+
160
+ grid $fsep -row 0 -column 0 -columnspan 3 -sticky ew
161
+ grid $sbar -row 1 -column 0 -sticky news
162
+ grid $sep -row 1 -column 1 -sticky ns -padx $ipadx -pady $ipady
163
+ grid $resize -row 1 -column 2 -sticky news
164
+ grid columnconfigure $path 0 -weight 1
165
+ if {![Widget::cget $path -showseparator]} {
166
+ grid remove $fsep
167
+ }
168
+ if {![Widget::cget $path -showresize]} {
169
+ grid remove $sep $resize
170
+ } elseif {![Widget::cget $path -showresizesep]} {
171
+ grid remove $sep
172
+ }
173
+ set _widget($path,items) {}
174
+
175
+ return [Widget::create StatusBar $path]
176
+ }
177
+
178
+
179
+ # ------------------------------------------------------------------------
180
+ # Command StatusBar::configure
181
+ # ------------------------------------------------------------------------
182
+ proc StatusBar::configure { path args } {
183
+ variable _widget
184
+
185
+ set res [Widget::configure $path $args]
186
+
187
+ foreach {chshow chshowrsep chshowsep chipad chpad} \
188
+ [Widget::hasChangedX $path -showresize -showresizesep -showseparator \
189
+ -ipad -pad] { break }
190
+
191
+ if {$chshow} {
192
+ set show [Widget::cget $path -showresize]
193
+ set showrsep [Widget::cget $path -showresizesep]
194
+ if {$show} {
195
+ if {$showrsep} {
196
+ grid $path.sepresize
197
+ }
198
+ grid $path.resize
199
+ } else {
200
+ grid remove $path.sepresize $path.resize
201
+ }
202
+ }
203
+ if {$chshowsep} {
204
+ if {$show} {
205
+ grid $path.hsep
206
+ } else {
207
+ grid remove $path.hsep
208
+ }
209
+ }
210
+ if {$chipad} {
211
+ foreach {ipadx ipady} [_padval [Widget::cget $path -ipad]] { break }
212
+ foreach w [grid slaves $path.sbar] {
213
+ grid configure $w -padx $ipadx -pady $ipady
214
+ }
215
+ }
216
+ if {$chpad} {
217
+ foreach {padx pady} [_padval [Widget::cget $path -pad]] { break }
218
+ if {[string equal [winfo class $path.sbar] "TFrame"]} {
219
+ $path.sbar configure -padding [list $padx $pady]
220
+ } else {
221
+ $path.sbar configure -padx $padx -pady $pady
222
+ }
223
+ }
224
+ return $res
225
+ }
226
+
227
+
228
+ # ------------------------------------------------------------------------
229
+ # Command StatusBar::cget
230
+ # ------------------------------------------------------------------------
231
+ proc StatusBar::cget { path option } {
232
+ return [Widget::cget $path $option]
233
+ }
234
+
235
+ # ------------------------------------------------------------------------
236
+ # Command StatusBar::getframe
237
+ # ------------------------------------------------------------------------
238
+ proc StatusBar::getframe {path} {
239
+ # This is the frame that users should place their statusbar widgets in
240
+ return $path.sbar
241
+ }
242
+
243
+ # ------------------------------------------------------------------------
244
+ # Command StatusBar::add
245
+ # ------------------------------------------------------------------------
246
+ proc StatusBar::add {path w args} {
247
+ variable _widget
248
+
249
+ array set opts [list \
250
+ -weight 0 \
251
+ -separator 1 \
252
+ -sticky news \
253
+ -pad [Widget::cget $path -ipad] \
254
+ ]
255
+ foreach {key val} $args {
256
+ if {[info exists opts($key)]} {
257
+ set opts($key) $val
258
+ } else {
259
+ set msg "unknown option \"$key\", must be one of: "
260
+ append msg [join [lsort [array names opts]] {, }]
261
+ return -code error $msg
262
+ }
263
+ }
264
+ foreach {ipadx ipady} [_padval $opts(-pad)] { break }
265
+
266
+ set sbar $path.sbar
267
+ foreach {cols rows} [grid size $sbar] break
268
+ # Add separator if requested, and we aren't the first element
269
+ if {$opts(-separator) && $cols != 0} {
270
+ set sep [_sep $path sep[winfo name $w]]
271
+ # only append name, to distinguish us from them
272
+ lappend _widget($path,items) [winfo name $sep]
273
+ grid $sep -in $sbar -row 0 -column $cols \
274
+ -sticky ns -padx $ipadx -pady $ipady
275
+ incr cols
276
+ }
277
+
278
+ lappend _widget($path,items) $w
279
+ grid $w -in $sbar -row 0 -column $cols -sticky $opts(-sticky) \
280
+ -padx $ipadx -pady $ipady
281
+ grid columnconfigure $sbar $cols -weight $opts(-weight)
282
+
283
+ return $w
284
+ }
285
+
286
+ # ------------------------------------------------------------------------
287
+ # Command StatusBar::delete
288
+ # ------------------------------------------------------------------------
289
+ proc StatusBar::remove {path args} {
290
+ variable _widget
291
+
292
+ set destroy [string equal [lindex $args 0] "-destroy"]
293
+ if {$destroy} {
294
+ set args [lrange $args 1 end]
295
+ }
296
+ foreach w $args {
297
+ set idx [lsearch -exact $_widget($path,items) $w]
298
+ if {$idx == -1 || ![winfo exists $w]} {
299
+ # ignore unknown or non-widget items (like our separators)
300
+ continue
301
+ }
302
+ # separator is always previous item
303
+ set sidx [expr {$idx - 1}]
304
+ set sep [lindex $_widget($path,items) $sidx]
305
+ if {[string match .* $sep]} {
306
+ # not one of our separators
307
+ incr sidx
308
+ } elseif {$sep != ""} {
309
+ # destroy separator too
310
+ set sep $path.sbar.$sep
311
+ destroy $sep
312
+ }
313
+ if {$destroy} {
314
+ destroy $w
315
+ } else {
316
+ grid forget $w
317
+ }
318
+ if {$idx == 0} {
319
+ # separator of next item is no longer necessary
320
+ set sep [lindex $_widget($path,items) [expr {$idx + 1}]]
321
+ if {$sep != "" && ![string match .* $sep]} {
322
+ incr idx
323
+ set sep $path.sbar.$sep
324
+ destroy $sep
325
+ }
326
+ }
327
+ set _widget($path,items) [lreplace $_widget($path,items) $sidx $idx]
328
+ }
329
+ }
330
+
331
+ # ------------------------------------------------------------------------
332
+ # Command StatusBar::delete
333
+ # ------------------------------------------------------------------------
334
+ proc StatusBar::delete {path args} {
335
+ return [StatusBar::remove $path -destroy $args]
336
+ }
337
+
338
+ # ------------------------------------------------------------------------
339
+ # Command StatusBar::items
340
+ # ------------------------------------------------------------------------
341
+ proc StatusBar::items {path} {
342
+ variable _widget
343
+ return $_widget($path,items)
344
+ }
345
+
346
+ proc StatusBar::_sep {path name {sub .sbar}} {
347
+ if {[Widget::theme]} {
348
+ return [ttk::separator $path$sub.$name -orient vertical]
349
+ } else {
350
+ return [frame $path$sub.$name -bd 1 -width 2 -relief sunken]
351
+ }
352
+ }
353
+
354
+ proc StatusBar::_padval {padval} {
355
+ set len [llength $padval]
356
+ foreach {a b} $padval { break }
357
+ if {$len == 0 || $len > 2} {
358
+ return -code error \
359
+ "invalid pad value \"$padval\", must be 1 or 2 pixel values"
360
+ } elseif {$len == 1} {
361
+ return [list $a $a]
362
+ } elseif {$len == 2} {
363
+ return $padval
364
+ }
365
+ }
366
+
367
+ # ------------------------------------------------------------------------
368
+ # Command StatusBar::_destroy
369
+ # ------------------------------------------------------------------------
370
+ proc StatusBar::_destroy { path } {
371
+ variable _widget
372
+ variable resize
373
+ array unset widget $path,*
374
+ array unset resize $path.resize,*
375
+ Widget::destroy $path
376
+ }
377
+
378
+ # The following proc handles the mouse click on the resize control. It stores
379
+ # the original size of the window and the initial coords of the mouse relative
380
+ # to the root.
381
+
382
+ proc StatusBar::begin_resize {w rootx rooty} {
383
+ variable resize
384
+ set t [winfo toplevel $w]
385
+ set relx [expr {$rootx - [winfo rootx $t]}]
386
+ set rely [expr {$rooty - [winfo rooty $t]}]
387
+ set resize($w,x) $relx
388
+ set resize($w,y) $rely
389
+ set resize($w,w) [winfo width $t]
390
+ set resize($w,h) [winfo height $t]
391
+ set resize($w,winc) 1
392
+ set resize($w,hinc) 1
393
+ set resize($w,grid) [wm grid $t]
394
+ }
395
+
396
+ # The following proc handles mouse motion on the resize control by asking the
397
+ # wm to adjust the size of the window.
398
+
399
+ proc StatusBar::continue_resize {w rootx rooty} {
400
+ variable resize
401
+ if {[llength $resize($w,grid)]} {
402
+ # at this time, we don't know how to handle gridded resizing
403
+ return
404
+ }
405
+ set t [winfo toplevel $w]
406
+ set relx [expr {$rootx - [winfo rootx $t]}]
407
+ set rely [expr {$rooty - [winfo rooty $t]}]
408
+ set width [expr {$relx - $resize($w,x) + $resize($w,w)}]
409
+ set height [expr {$rely - $resize($w,y) + $resize($w,h)}]
410
+ if {$width < 0} { set width 0 }
411
+ if {$height < 0} { set height 0 }
412
+ wm geometry $t ${width}x${height}
413
+ }
414
+
415
+ # The following proc cleans up when the user releases the mouse button.
416
+
417
+ proc StatusBar::end_resize {w rootx rooty} {
418
+ variable resize
419
+ #continue_resize $w $rootx $rooty
420
+ #wm grid $t $resize($w,grid)
421
+ array unset resize $w,*
422
+ }