Pratt 1.5.6

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.
Files changed (283) hide show
  1. data/.exrc +61 -0
  2. data/.gitignore +4 -0
  3. data/History.txt +6 -0
  4. data/Manifest.txt +46 -0
  5. data/Pratt.gemspec +351 -0
  6. data/README.txt +66 -0
  7. data/Rakefile +85 -0
  8. data/TODO +54 -0
  9. data/VERSION +1 -0
  10. data/bin/pratt.rb +13 -0
  11. data/config.rb +34 -0
  12. data/lib/pratt.rb +527 -0
  13. data/lib/pratt/array.rb +11 -0
  14. data/lib/pratt/string.rb +18 -0
  15. data/models/app.rb +40 -0
  16. data/models/customer.rb +24 -0
  17. data/models/payment.rb +22 -0
  18. data/models/pratt.rb +19 -0
  19. data/models/project.rb +82 -0
  20. data/models/whence.rb +70 -0
  21. data/pkgs/tile-0.8.2.tar.gz +0 -0
  22. data/pkgs/tile-0.8.2/ANNOUNCE.txt +95 -0
  23. data/pkgs/tile-0.8.2/ChangeLog +4651 -0
  24. data/pkgs/tile-0.8.2/Makefile +250 -0
  25. data/pkgs/tile-0.8.2/Makefile.in +250 -0
  26. data/pkgs/tile-0.8.2/README.txt +86 -0
  27. data/pkgs/tile-0.8.2/aclocal.m4 +2 -0
  28. data/pkgs/tile-0.8.2/altTheme.o +0 -0
  29. data/pkgs/tile-0.8.2/blink.o +0 -0
  30. data/pkgs/tile-0.8.2/button.o +0 -0
  31. data/pkgs/tile-0.8.2/cache.o +0 -0
  32. data/pkgs/tile-0.8.2/clamTheme.o +0 -0
  33. data/pkgs/tile-0.8.2/classicTheme.o +0 -0
  34. data/pkgs/tile-0.8.2/config.log +1330 -0
  35. data/pkgs/tile-0.8.2/config.status +795 -0
  36. data/pkgs/tile-0.8.2/configure +15248 -0
  37. data/pkgs/tile-0.8.2/configure.in +89 -0
  38. data/pkgs/tile-0.8.2/demos/autocomplete.tcl +59 -0
  39. data/pkgs/tile-0.8.2/demos/demo.tcl +870 -0
  40. data/pkgs/tile-0.8.2/demos/dirbrowser.tcl +167 -0
  41. data/pkgs/tile-0.8.2/demos/dlgtest.tcl +97 -0
  42. data/pkgs/tile-0.8.2/demos/iconlib.tcl +110 -0
  43. data/pkgs/tile-0.8.2/demos/repeater.tcl +117 -0
  44. data/pkgs/tile-0.8.2/demos/toolbutton.tcl +101 -0
  45. data/pkgs/tile-0.8.2/doc/Geometry.3 +230 -0
  46. data/pkgs/tile-0.8.2/doc/INDEX.MAP +153 -0
  47. data/pkgs/tile-0.8.2/doc/Makefile +36 -0
  48. data/pkgs/tile-0.8.2/doc/TILE.XML +45 -0
  49. data/pkgs/tile-0.8.2/doc/Theme.3 +34 -0
  50. data/pkgs/tile-0.8.2/doc/button.n +75 -0
  51. data/pkgs/tile-0.8.2/doc/checkbutton.n +61 -0
  52. data/pkgs/tile-0.8.2/doc/combobox.n +98 -0
  53. data/pkgs/tile-0.8.2/doc/converting.txt +97 -0
  54. data/pkgs/tile-0.8.2/doc/dialog.n +122 -0
  55. data/pkgs/tile-0.8.2/doc/entry.n +438 -0
  56. data/pkgs/tile-0.8.2/doc/frame.n +43 -0
  57. data/pkgs/tile-0.8.2/doc/html/Geometry.html +304 -0
  58. data/pkgs/tile-0.8.2/doc/html/Theme.html +48 -0
  59. data/pkgs/tile-0.8.2/doc/html/button.html +120 -0
  60. data/pkgs/tile-0.8.2/doc/html/category-index.html +18 -0
  61. data/pkgs/tile-0.8.2/doc/html/checkbutton.html +94 -0
  62. data/pkgs/tile-0.8.2/doc/html/combobox.html +164 -0
  63. data/pkgs/tile-0.8.2/doc/html/converting.txt +97 -0
  64. data/pkgs/tile-0.8.2/doc/html/dialog.html +159 -0
  65. data/pkgs/tile-0.8.2/doc/html/entry.html +613 -0
  66. data/pkgs/tile-0.8.2/doc/html/frame.html +76 -0
  67. data/pkgs/tile-0.8.2/doc/html/image.html +100 -0
  68. data/pkgs/tile-0.8.2/doc/html/index.html +25 -0
  69. data/pkgs/tile-0.8.2/doc/html/keyword-index.html +228 -0
  70. data/pkgs/tile-0.8.2/doc/html/label.html +133 -0
  71. data/pkgs/tile-0.8.2/doc/html/labelframe.html +91 -0
  72. data/pkgs/tile-0.8.2/doc/html/manpage.css +212 -0
  73. data/pkgs/tile-0.8.2/doc/html/menubutton.html +63 -0
  74. data/pkgs/tile-0.8.2/doc/html/notebook.html +280 -0
  75. data/pkgs/tile-0.8.2/doc/html/paned.html +149 -0
  76. data/pkgs/tile-0.8.2/doc/html/progressbar.html +138 -0
  77. data/pkgs/tile-0.8.2/doc/html/radiobutton.html +89 -0
  78. data/pkgs/tile-0.8.2/doc/html/scrollbar.html +221 -0
  79. data/pkgs/tile-0.8.2/doc/html/separator.html +48 -0
  80. data/pkgs/tile-0.8.2/doc/html/sizegrip.html +62 -0
  81. data/pkgs/tile-0.8.2/doc/html/style.html +172 -0
  82. data/pkgs/tile-0.8.2/doc/html/tile-intro.html +164 -0
  83. data/pkgs/tile-0.8.2/doc/html/treeview.html +634 -0
  84. data/pkgs/tile-0.8.2/doc/html/widget.html +342 -0
  85. data/pkgs/tile-0.8.2/doc/image.n +81 -0
  86. data/pkgs/tile-0.8.2/doc/internals.txt +409 -0
  87. data/pkgs/tile-0.8.2/doc/label.n +75 -0
  88. data/pkgs/tile-0.8.2/doc/labelframe.n +64 -0
  89. data/pkgs/tile-0.8.2/doc/man.macros +239 -0
  90. data/pkgs/tile-0.8.2/doc/menubutton.n +41 -0
  91. data/pkgs/tile-0.8.2/doc/notebook.n +188 -0
  92. data/pkgs/tile-0.8.2/doc/paned.n +95 -0
  93. data/pkgs/tile-0.8.2/doc/progressbar.n +79 -0
  94. data/pkgs/tile-0.8.2/doc/radiobutton.n +57 -0
  95. data/pkgs/tile-0.8.2/doc/scrollbar.n +160 -0
  96. data/pkgs/tile-0.8.2/doc/separator.n +30 -0
  97. data/pkgs/tile-0.8.2/doc/sizegrip.n +53 -0
  98. data/pkgs/tile-0.8.2/doc/style.n +119 -0
  99. data/pkgs/tile-0.8.2/doc/tile-intro.n +165 -0
  100. data/pkgs/tile-0.8.2/doc/tmml.options +4 -0
  101. data/pkgs/tile-0.8.2/doc/treeview.n +415 -0
  102. data/pkgs/tile-0.8.2/doc/widget.n +227 -0
  103. data/pkgs/tile-0.8.2/doc/xml/Geometry.tmml +379 -0
  104. data/pkgs/tile-0.8.2/doc/xml/INDEX.MAP +153 -0
  105. data/pkgs/tile-0.8.2/doc/xml/Theme.tmml +63 -0
  106. data/pkgs/tile-0.8.2/doc/xml/button.tmml +134 -0
  107. data/pkgs/tile-0.8.2/doc/xml/checkbutton.tmml +119 -0
  108. data/pkgs/tile-0.8.2/doc/xml/combobox.tmml +184 -0
  109. data/pkgs/tile-0.8.2/doc/xml/dialog.tmml +195 -0
  110. data/pkgs/tile-0.8.2/doc/xml/entry.tmml +630 -0
  111. data/pkgs/tile-0.8.2/doc/xml/frame.tmml +98 -0
  112. data/pkgs/tile-0.8.2/doc/xml/image.tmml +101 -0
  113. data/pkgs/tile-0.8.2/doc/xml/label.tmml +154 -0
  114. data/pkgs/tile-0.8.2/doc/xml/labelframe.tmml +116 -0
  115. data/pkgs/tile-0.8.2/doc/xml/menubutton.tmml +80 -0
  116. data/pkgs/tile-0.8.2/doc/xml/notebook.tmml +306 -0
  117. data/pkgs/tile-0.8.2/doc/xml/paned.tmml +154 -0
  118. data/pkgs/tile-0.8.2/doc/xml/progressbar.tmml +151 -0
  119. data/pkgs/tile-0.8.2/doc/xml/radiobutton.tmml +109 -0
  120. data/pkgs/tile-0.8.2/doc/xml/scrollbar.tmml +233 -0
  121. data/pkgs/tile-0.8.2/doc/xml/separator.tmml +59 -0
  122. data/pkgs/tile-0.8.2/doc/xml/sizegrip.tmml +82 -0
  123. data/pkgs/tile-0.8.2/doc/xml/style.tmml +171 -0
  124. data/pkgs/tile-0.8.2/doc/xml/tile-intro.tmml +192 -0
  125. data/pkgs/tile-0.8.2/doc/xml/treeview.tmml +604 -0
  126. data/pkgs/tile-0.8.2/doc/xml/widget.tmml +372 -0
  127. data/pkgs/tile-0.8.2/entry.o +0 -0
  128. data/pkgs/tile-0.8.2/frame.o +0 -0
  129. data/pkgs/tile-0.8.2/generic/Makefile.in +221 -0
  130. data/pkgs/tile-0.8.2/generic/TODO +493 -0
  131. data/pkgs/tile-0.8.2/generic/altTheme.c +1172 -0
  132. data/pkgs/tile-0.8.2/generic/blink.c +168 -0
  133. data/pkgs/tile-0.8.2/generic/button.c +858 -0
  134. data/pkgs/tile-0.8.2/generic/cache.c +354 -0
  135. data/pkgs/tile-0.8.2/generic/clamTheme.c +974 -0
  136. data/pkgs/tile-0.8.2/generic/classicTheme.c +518 -0
  137. data/pkgs/tile-0.8.2/generic/configure +10334 -0
  138. data/pkgs/tile-0.8.2/generic/configure.in +100 -0
  139. data/pkgs/tile-0.8.2/generic/entry.c +1922 -0
  140. data/pkgs/tile-0.8.2/generic/frame.c +648 -0
  141. data/pkgs/tile-0.8.2/generic/gunk.h +44 -0
  142. data/pkgs/tile-0.8.2/generic/image.c +416 -0
  143. data/pkgs/tile-0.8.2/generic/label.c +663 -0
  144. data/pkgs/tile-0.8.2/generic/layout.c +1215 -0
  145. data/pkgs/tile-0.8.2/generic/manager.c +554 -0
  146. data/pkgs/tile-0.8.2/generic/manager.h +91 -0
  147. data/pkgs/tile-0.8.2/generic/notebook.c +1380 -0
  148. data/pkgs/tile-0.8.2/generic/paned.c +958 -0
  149. data/pkgs/tile-0.8.2/generic/pkgIndex.tcl.in +7 -0
  150. data/pkgs/tile-0.8.2/generic/progress.c +549 -0
  151. data/pkgs/tile-0.8.2/generic/scale.c +526 -0
  152. data/pkgs/tile-0.8.2/generic/scroll.c +253 -0
  153. data/pkgs/tile-0.8.2/generic/scrollbar.c +346 -0
  154. data/pkgs/tile-0.8.2/generic/separator.c +132 -0
  155. data/pkgs/tile-0.8.2/generic/square.c +306 -0
  156. data/pkgs/tile-0.8.2/generic/tagset.c +147 -0
  157. data/pkgs/tile-0.8.2/generic/tile.c +296 -0
  158. data/pkgs/tile-0.8.2/generic/tkElements.c +1280 -0
  159. data/pkgs/tile-0.8.2/generic/tkTheme.c +1708 -0
  160. data/pkgs/tile-0.8.2/generic/tkTheme.h +419 -0
  161. data/pkgs/tile-0.8.2/generic/tkThemeInt.h +45 -0
  162. data/pkgs/tile-0.8.2/generic/tkstate.c +268 -0
  163. data/pkgs/tile-0.8.2/generic/trace.c +145 -0
  164. data/pkgs/tile-0.8.2/generic/track.c +174 -0
  165. data/pkgs/tile-0.8.2/generic/treeview.c +3211 -0
  166. data/pkgs/tile-0.8.2/generic/ttk.decls +154 -0
  167. data/pkgs/tile-0.8.2/generic/ttkDecls.h +340 -0
  168. data/pkgs/tile-0.8.2/generic/ttkStubInit.c +61 -0
  169. data/pkgs/tile-0.8.2/generic/ttkStubLib.c +70 -0
  170. data/pkgs/tile-0.8.2/generic/widget.c +785 -0
  171. data/pkgs/tile-0.8.2/generic/widget.h +263 -0
  172. data/pkgs/tile-0.8.2/image.o +0 -0
  173. data/pkgs/tile-0.8.2/label.o +0 -0
  174. data/pkgs/tile-0.8.2/layout.o +0 -0
  175. data/pkgs/tile-0.8.2/library/altTheme.tcl +101 -0
  176. data/pkgs/tile-0.8.2/library/aquaTheme.tcl +62 -0
  177. data/pkgs/tile-0.8.2/library/button.tcl +85 -0
  178. data/pkgs/tile-0.8.2/library/clamTheme.tcl +139 -0
  179. data/pkgs/tile-0.8.2/library/classicTheme.tcl +108 -0
  180. data/pkgs/tile-0.8.2/library/combobox.tcl +439 -0
  181. data/pkgs/tile-0.8.2/library/cursors.tcl +36 -0
  182. data/pkgs/tile-0.8.2/library/defaults.tcl +118 -0
  183. data/pkgs/tile-0.8.2/library/dialog.tcl +274 -0
  184. data/pkgs/tile-0.8.2/library/entry.tcl +580 -0
  185. data/pkgs/tile-0.8.2/library/fonts.tcl +153 -0
  186. data/pkgs/tile-0.8.2/library/icons.tcl +105 -0
  187. data/pkgs/tile-0.8.2/library/keynav.tcl +192 -0
  188. data/pkgs/tile-0.8.2/library/menubutton.tcl +171 -0
  189. data/pkgs/tile-0.8.2/library/notebook.tcl +193 -0
  190. data/pkgs/tile-0.8.2/library/paned.tcl +87 -0
  191. data/pkgs/tile-0.8.2/library/progress.tcl +51 -0
  192. data/pkgs/tile-0.8.2/library/scale.tcl +54 -0
  193. data/pkgs/tile-0.8.2/library/scrollbar.tcl +125 -0
  194. data/pkgs/tile-0.8.2/library/sizegrip.tcl +77 -0
  195. data/pkgs/tile-0.8.2/library/tile.tcl +211 -0
  196. data/pkgs/tile-0.8.2/library/treeview.tcl +382 -0
  197. data/pkgs/tile-0.8.2/library/utils.tcl +254 -0
  198. data/pkgs/tile-0.8.2/library/winTheme.tcl +77 -0
  199. data/pkgs/tile-0.8.2/library/xpTheme.tcl +63 -0
  200. data/pkgs/tile-0.8.2/libtile0.8.2.so +0 -0
  201. data/pkgs/tile-0.8.2/libttkstub.a +0 -0
  202. data/pkgs/tile-0.8.2/license.terms +24 -0
  203. data/pkgs/tile-0.8.2/macosx/aquaTheme.c +1076 -0
  204. data/pkgs/tile-0.8.2/manager.o +0 -0
  205. data/pkgs/tile-0.8.2/notebook.o +0 -0
  206. data/pkgs/tile-0.8.2/paned.o +0 -0
  207. data/pkgs/tile-0.8.2/pkgIndex.tcl +3 -0
  208. data/pkgs/tile-0.8.2/progress.o +0 -0
  209. data/pkgs/tile-0.8.2/scale.o +0 -0
  210. data/pkgs/tile-0.8.2/scroll.o +0 -0
  211. data/pkgs/tile-0.8.2/scrollbar.o +0 -0
  212. data/pkgs/tile-0.8.2/separator.o +0 -0
  213. data/pkgs/tile-0.8.2/tagset.o +0 -0
  214. data/pkgs/tile-0.8.2/tclconfig/install-sh +119 -0
  215. data/pkgs/tile-0.8.2/tclconfig/tcl.m4 +4069 -0
  216. data/pkgs/tile-0.8.2/tclconfig/teax.m4 +109 -0
  217. data/pkgs/tile-0.8.2/tests/all.tcl +18 -0
  218. data/pkgs/tile-0.8.2/tests/bwidget.test +103 -0
  219. data/pkgs/tile-0.8.2/tests/cbtest.tcl +125 -0
  220. data/pkgs/tile-0.8.2/tests/combobox.test +51 -0
  221. data/pkgs/tile-0.8.2/tests/compound.tcl +92 -0
  222. data/pkgs/tile-0.8.2/tests/entry.test +285 -0
  223. data/pkgs/tile-0.8.2/tests/entrytest.tcl +78 -0
  224. data/pkgs/tile-0.8.2/tests/image.test +94 -0
  225. data/pkgs/tile-0.8.2/tests/labelframe.tcl +41 -0
  226. data/pkgs/tile-0.8.2/tests/labelframe.test +137 -0
  227. data/pkgs/tile-0.8.2/tests/layout.test +33 -0
  228. data/pkgs/tile-0.8.2/tests/misc.test +35 -0
  229. data/pkgs/tile-0.8.2/tests/nbtest.tcl +66 -0
  230. data/pkgs/tile-0.8.2/tests/notebook.test +500 -0
  231. data/pkgs/tile-0.8.2/tests/paned.test +298 -0
  232. data/pkgs/tile-0.8.2/tests/progress.test +92 -0
  233. data/pkgs/tile-0.8.2/tests/pwtest.tcl +90 -0
  234. data/pkgs/tile-0.8.2/tests/sbtest.tcl +79 -0
  235. data/pkgs/tile-0.8.2/tests/scrollbar.test +77 -0
  236. data/pkgs/tile-0.8.2/tests/sgtest.tcl +52 -0
  237. data/pkgs/tile-0.8.2/tests/testutils.tcl +20 -0
  238. data/pkgs/tile-0.8.2/tests/tile.test +674 -0
  239. data/pkgs/tile-0.8.2/tests/treetags.test +78 -0
  240. data/pkgs/tile-0.8.2/tests/treeview.test +563 -0
  241. data/pkgs/tile-0.8.2/tests/tvtest.tcl +332 -0
  242. data/pkgs/tile-0.8.2/tests/validate.test +278 -0
  243. data/pkgs/tile-0.8.2/tile.o +0 -0
  244. data/pkgs/tile-0.8.2/tkElements.o +0 -0
  245. data/pkgs/tile-0.8.2/tkTheme.o +0 -0
  246. data/pkgs/tile-0.8.2/tkstate.o +0 -0
  247. data/pkgs/tile-0.8.2/tools/genStubs.tcl +861 -0
  248. data/pkgs/tile-0.8.2/trace.o +0 -0
  249. data/pkgs/tile-0.8.2/track.o +0 -0
  250. data/pkgs/tile-0.8.2/treeview.o +0 -0
  251. data/pkgs/tile-0.8.2/ttkStubInit.o +0 -0
  252. data/pkgs/tile-0.8.2/ttkStubLib.o +0 -0
  253. data/pkgs/tile-0.8.2/widget.o +0 -0
  254. data/pkgs/tile-0.8.2/win/Tile.dsp +261 -0
  255. data/pkgs/tile-0.8.2/win/makefile.vc +527 -0
  256. data/pkgs/tile-0.8.2/win/monitor.c +164 -0
  257. data/pkgs/tile-0.8.2/win/nmakehlp.c +483 -0
  258. data/pkgs/tile-0.8.2/win/rules.vc +512 -0
  259. data/pkgs/tile-0.8.2/win/tile.rc +40 -0
  260. data/pkgs/tile-0.8.2/win/winTheme.c +734 -0
  261. data/pkgs/tile-0.8.2/win/xpTheme.c +1029 -0
  262. data/spec/app_spec.rb +48 -0
  263. data/spec/customer_spec.rb +31 -0
  264. data/spec/fixtures/graph.expectation +18 -0
  265. data/spec/payment_spec.rb +19 -0
  266. data/spec/pratt_spec.rb +148 -0
  267. data/spec/project_spec.rb +163 -0
  268. data/spec/rcov.opts +0 -0
  269. data/spec/spec.opts +1 -0
  270. data/spec/spec_helper.rb +21 -0
  271. data/spec/whence_spec.rb +54 -0
  272. data/tasks/pratt.rb +84 -0
  273. data/templates/model.eruby +12 -0
  274. data/templates/spec.eruby +8 -0
  275. data/views/env.rb +22 -0
  276. data/views/graph.eruby +20 -0
  277. data/views/invoice.eruby +148 -0
  278. data/views/main.rb +92 -0
  279. data/views/pid.eruby +3 -0
  280. data/views/pop.rb +94 -0
  281. data/views/pop2.rb +75 -0
  282. data/views/raw.eruby +11 -0
  283. metadata +390 -0
@@ -0,0 +1,168 @@
1
+ /*
2
+ * blink.c,v 1.4 2006/11/11 22:16:39 jenglish Exp
3
+ *
4
+ * Copyright 2004, Joe English.
5
+ *
6
+ * Usage:
7
+ * TtkBlinkCursor(corePtr), usually called in a widget's Init hook,
8
+ * arranges to periodically toggle the corePtr->flags CURSOR_ON bit
9
+ * on and off (and schedule a redisplay) whenever the widget has focus.
10
+ *
11
+ * Note: Widgets may have additional logic to decide whether
12
+ * to display the cursor or not (e.g., readonly or disabled states);
13
+ * TtkBlinkCursor() does not account for this.
14
+ *
15
+ * TODO:
16
+ * Add script-level access to configure application-wide blink rate.
17
+ */
18
+
19
+ #include <tk.h>
20
+ #include "tkTheme.h"
21
+ #include "widget.h"
22
+
23
+ #define DEF_CURSOR_ON_TIME 600 /* milliseconds */
24
+ #define DEF_CURSOR_OFF_TIME 300 /* milliseconds */
25
+
26
+ /* Interp-specific data for tracking cursors:
27
+ */
28
+ typedef struct
29
+ {
30
+ WidgetCore *owner; /* Widget that currently has cursor */
31
+ Tcl_TimerToken timer; /* Blink timer */
32
+ int onTime; /* #milliseconds to blink cursor on */
33
+ int offTime; /* #milliseconds to blink cursor off */
34
+ } CursorManager;
35
+
36
+ /* CursorManagerDeleteProc --
37
+ * InterpDeleteProc for cursor manager.
38
+ */
39
+ static void CursorManagerDeleteProc(ClientData clientData, Tcl_Interp *interp)
40
+ {
41
+ CursorManager *cm = (CursorManager*)clientData;
42
+ if (cm->timer) {
43
+ Tcl_DeleteTimerHandler(cm->timer);
44
+ }
45
+ ckfree(clientData);
46
+ }
47
+
48
+ /* GetCursorManager --
49
+ * Look up and create if necessary the interp's cursor manager.
50
+ */
51
+ static CursorManager *GetCursorManager(Tcl_Interp *interp)
52
+ {
53
+ static const char *cm_key = "tile::CursorManager";
54
+ CursorManager *cm = (CursorManager *) Tcl_GetAssocData(interp, cm_key,0);
55
+
56
+ if (!cm) {
57
+ cm = (CursorManager*)ckalloc(sizeof(*cm));
58
+ cm->timer = 0;
59
+ cm->owner = 0;
60
+ cm->onTime = DEF_CURSOR_ON_TIME;
61
+ cm->offTime = DEF_CURSOR_OFF_TIME;
62
+ Tcl_SetAssocData(interp,cm_key,CursorManagerDeleteProc,(ClientData)cm);
63
+ }
64
+ return cm;
65
+ }
66
+
67
+ /* CursorBlinkProc --
68
+ * Timer handler to blink the insert cursor on and off.
69
+ */
70
+ static void
71
+ CursorBlinkProc(ClientData clientData)
72
+ {
73
+ CursorManager *cm = (CursorManager*)clientData;
74
+ int blinkTime;
75
+
76
+ if (cm->owner->flags & CURSOR_ON) {
77
+ cm->owner->flags &= ~CURSOR_ON;
78
+ blinkTime = cm->offTime;
79
+ } else {
80
+ cm->owner->flags |= CURSOR_ON;
81
+ blinkTime = cm->onTime;
82
+ }
83
+ cm->timer = Tcl_CreateTimerHandler(blinkTime, CursorBlinkProc, clientData);
84
+ TtkRedisplayWidget(cm->owner);
85
+ }
86
+
87
+ /* LoseCursor --
88
+ * Turn cursor off, disable blink timer.
89
+ */
90
+ static void LoseCursor(CursorManager *cm, WidgetCore *corePtr)
91
+ {
92
+ if (corePtr->flags & CURSOR_ON) {
93
+ corePtr->flags &= ~CURSOR_ON;
94
+ TtkRedisplayWidget(corePtr);
95
+ }
96
+ if (cm->owner == corePtr) {
97
+ cm->owner = NULL;
98
+ }
99
+ if (cm->timer) {
100
+ Tcl_DeleteTimerHandler(cm->timer);
101
+ cm->timer = 0;
102
+ }
103
+ }
104
+
105
+ /* ClaimCursor --
106
+ * Claim ownership of the insert cursor and blink on.
107
+ */
108
+ static void ClaimCursor(CursorManager *cm, WidgetCore *corePtr)
109
+ {
110
+ if (cm->owner == corePtr)
111
+ return;
112
+ if (cm->owner)
113
+ LoseCursor(cm, cm->owner);
114
+
115
+ corePtr->flags |= CURSOR_ON;
116
+ TtkRedisplayWidget(corePtr);
117
+
118
+ cm->owner = corePtr;
119
+ cm->timer = Tcl_CreateTimerHandler(cm->onTime, CursorBlinkProc, cm);
120
+ }
121
+
122
+ /*
123
+ * CursorEventProc --
124
+ * Event handler for FocusIn and FocusOut events;
125
+ * claim/lose ownership of the insert cursor when the widget
126
+ * acquires/loses keyboard focus.
127
+ */
128
+
129
+ #define CursorEventMask (FocusChangeMask|StructureNotifyMask)
130
+ #define RealFocusEvent(d) \
131
+ (d == NotifyInferior || d == NotifyAncestor || d == NotifyNonlinear)
132
+
133
+ static void
134
+ CursorEventProc(ClientData clientData, XEvent *eventPtr)
135
+ {
136
+ WidgetCore *corePtr = (WidgetCore *)clientData;
137
+ CursorManager *cm = GetCursorManager(corePtr->interp);
138
+
139
+ switch (eventPtr->type) {
140
+ case DestroyNotify:
141
+ if (cm->owner == corePtr)
142
+ LoseCursor(cm, corePtr);
143
+ Tk_DeleteEventHandler(
144
+ corePtr->tkwin, CursorEventMask, CursorEventProc, clientData);
145
+ break;
146
+ case FocusIn:
147
+ if (RealFocusEvent(eventPtr->xfocus.detail))
148
+ ClaimCursor(cm, corePtr);
149
+ break;
150
+ case FocusOut:
151
+ if (RealFocusEvent(eventPtr->xfocus.detail))
152
+ LoseCursor(cm, corePtr);
153
+ break;
154
+ }
155
+ }
156
+
157
+ /*
158
+ * TtkBlinkCursor (main routine) --
159
+ * Arrange to blink the cursor on and off whenever the
160
+ * widget has focus.
161
+ */
162
+ void TtkBlinkCursor(WidgetCore *corePtr)
163
+ {
164
+ Tk_CreateEventHandler(
165
+ corePtr->tkwin, CursorEventMask, CursorEventProc, corePtr);
166
+ }
167
+
168
+ /*EOF*/
@@ -0,0 +1,858 @@
1
+ /* button.c,v 1.52 2007/10/25 06:42:47 jenglish Exp
2
+ * Copyright (c) 2003, Joe English
3
+ *
4
+ * label, button, checkbutton, radiobutton, and menubutton widgets.
5
+ */
6
+
7
+ #include <string.h>
8
+ #include <tk.h>
9
+ #include "tkTheme.h"
10
+ #include "widget.h"
11
+
12
+ /* Bit fields for OptionSpec mask field:
13
+ */
14
+ #define STATE_CHANGED (0x100) /* -state option changed */
15
+ #define DEFAULTSTATE_CHANGED (0x200) /* -default option changed */
16
+
17
+ /*------------------------------------------------------------------------
18
+ * +++ Base resources for labels, buttons, checkbuttons, etc:
19
+ */
20
+ typedef struct
21
+ {
22
+ /*
23
+ * Text element resources:
24
+ */
25
+ Tcl_Obj *textObj;
26
+ Tcl_Obj *textVariableObj;
27
+ Tcl_Obj *underlineObj;
28
+ Tcl_Obj *widthObj;
29
+
30
+ Ttk_TraceHandle *textVariableTrace;
31
+ Ttk_ImageSpec *imageSpec;
32
+
33
+ /*
34
+ * Image element resources:
35
+ */
36
+ Tcl_Obj *imageObj;
37
+
38
+ /*
39
+ * Compound label/image resources:
40
+ */
41
+ Tcl_Obj *compoundObj;
42
+ Tcl_Obj *paddingObj;
43
+
44
+ /*
45
+ * Compatibility/legacy options:
46
+ */
47
+ Tcl_Obj *stateObj;
48
+
49
+ } BasePart;
50
+
51
+ typedef struct
52
+ {
53
+ WidgetCore core;
54
+ BasePart base;
55
+ } Base;
56
+
57
+ static Tk_OptionSpec BaseOptionSpecs[] =
58
+ {
59
+ {TK_OPTION_STRING, "-text", "text", "Text", "",
60
+ Tk_Offset(Base,base.textObj), -1,
61
+ 0,0,GEOMETRY_CHANGED },
62
+ {TK_OPTION_STRING, "-textvariable", "textVariable", "Variable", "",
63
+ Tk_Offset(Base,base.textVariableObj), -1,
64
+ TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
65
+ {TK_OPTION_INT, "-underline", "underline", "Underline",
66
+ "-1", Tk_Offset(Base,base.underlineObj), -1,
67
+ 0,0,0 },
68
+ /* SB: OPTION_INT, see <<NOTE-NULLOPTIONS>> */
69
+ {TK_OPTION_STRING, "-width", "width", "Width",
70
+ NULL, Tk_Offset(Base,base.widthObj), -1,
71
+ TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
72
+
73
+ /*
74
+ * Image options
75
+ */
76
+ {TK_OPTION_STRING, "-image", "image", "Image", NULL/*default*/,
77
+ Tk_Offset(Base,base.imageObj), -1,
78
+ TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
79
+
80
+ /*
81
+ * Compound base/image options
82
+ */
83
+ {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
84
+ "none", Tk_Offset(Base,base.compoundObj), -1,
85
+ 0,(ClientData)ttkCompoundStrings,GEOMETRY_CHANGED },
86
+ {TK_OPTION_STRING, "-padding", "padding", "Pad",
87
+ NULL, Tk_Offset(Base,base.paddingObj), -1,
88
+ TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED},
89
+
90
+ /*
91
+ * Compatibility/legacy options
92
+ */
93
+ {TK_OPTION_STRING, "-state", "state", "State",
94
+ "normal", Tk_Offset(Base,base.stateObj), -1,
95
+ 0,0,STATE_CHANGED },
96
+
97
+ WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
98
+ };
99
+
100
+ /*
101
+ * Variable trace procedure for -textvariable option:
102
+ */
103
+ static void TextVariableChanged(void *clientData, const char *value)
104
+ {
105
+ Base *basePtr = clientData;
106
+ Tcl_Obj *newText;
107
+
108
+ if (WidgetDestroyed(&basePtr->core)) {
109
+ return;
110
+ }
111
+
112
+ newText = value ? Tcl_NewStringObj(value, -1) : Tcl_NewStringObj("", 0);
113
+
114
+ Tcl_IncrRefCount(newText);
115
+ Tcl_DecrRefCount(basePtr->base.textObj);
116
+ basePtr->base.textObj = newText;
117
+
118
+ TtkResizeWidget(&basePtr->core);
119
+ }
120
+
121
+ static int
122
+ BaseInitialize(Tcl_Interp *interp, void *recordPtr)
123
+ {
124
+ Base *basePtr = recordPtr;
125
+ basePtr->base.textVariableTrace = 0;
126
+ basePtr->base.imageSpec = NULL;
127
+ return TCL_OK;
128
+ }
129
+
130
+ static void
131
+ BaseCleanup(void *recordPtr)
132
+ {
133
+ Base *basePtr = recordPtr;
134
+ if (basePtr->base.textVariableTrace)
135
+ Ttk_UntraceVariable(basePtr->base.textVariableTrace);
136
+ if (basePtr->base.imageSpec)
137
+ TtkFreeImageSpec(basePtr->base.imageSpec);
138
+ }
139
+
140
+ static int BaseConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
141
+ {
142
+ Base *basePtr = recordPtr;
143
+ Tcl_Obj *textVarName = basePtr->base.textVariableObj;
144
+ Ttk_TraceHandle *vt = 0;
145
+ Ttk_ImageSpec *imageSpec = NULL;
146
+
147
+ if (textVarName != NULL && *Tcl_GetString(textVarName) != '\0') {
148
+ vt = Ttk_TraceVariable(interp,textVarName,TextVariableChanged,basePtr);
149
+ if (!vt) return TCL_ERROR;
150
+ }
151
+
152
+ if (basePtr->base.imageObj) {
153
+ imageSpec = TtkGetImageSpec(
154
+ interp, basePtr->core.tkwin, basePtr->base.imageObj);
155
+ if (!imageSpec) {
156
+ goto error;
157
+ }
158
+ }
159
+
160
+ if (TtkCoreConfigure(interp, recordPtr, mask) != TCL_OK) {
161
+ error:
162
+ if (imageSpec) TtkFreeImageSpec(imageSpec);
163
+ if (vt) Ttk_UntraceVariable(vt);
164
+ return TCL_ERROR;
165
+ }
166
+
167
+ if (basePtr->base.textVariableTrace) {
168
+ Ttk_UntraceVariable(basePtr->base.textVariableTrace);
169
+ }
170
+ basePtr->base.textVariableTrace = vt;
171
+
172
+ if (basePtr->base.imageSpec) {
173
+ TtkFreeImageSpec(basePtr->base.imageSpec);
174
+ }
175
+ basePtr->base.imageSpec = imageSpec;
176
+
177
+ if (mask & STATE_CHANGED) {
178
+ TtkCheckStateOption(&basePtr->core, basePtr->base.stateObj);
179
+ }
180
+
181
+ return TCL_OK;
182
+ }
183
+
184
+ static int
185
+ BasePostConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
186
+ {
187
+ Base *basePtr = recordPtr;
188
+ int status = TCL_OK;
189
+
190
+ if (basePtr->base.textVariableTrace) {
191
+ status = Ttk_FireTrace(basePtr->base.textVariableTrace);
192
+ }
193
+
194
+ return status;
195
+ }
196
+
197
+ /*------------------------------------------------------------------------
198
+ * +++ Label widget.
199
+ * Just a base widget that adds a few appearance-related options
200
+ */
201
+
202
+ typedef struct
203
+ {
204
+ Tcl_Obj *backgroundObj;
205
+ Tcl_Obj *foregroundObj;
206
+ Tcl_Obj *fontObj;
207
+ Tcl_Obj *borderWidthObj;
208
+ Tcl_Obj *reliefObj;
209
+ Tcl_Obj *anchorObj;
210
+ Tcl_Obj *justifyObj;
211
+ Tcl_Obj *wrapLengthObj;
212
+ } LabelPart;
213
+
214
+ typedef struct
215
+ {
216
+ WidgetCore core;
217
+ BasePart base;
218
+ LabelPart label;
219
+ } Label;
220
+
221
+ static Tk_OptionSpec LabelOptionSpecs[] =
222
+ {
223
+ {TK_OPTION_BORDER, "-background", "frameColor", "FrameColor",
224
+ NULL, Tk_Offset(Label,label.backgroundObj), -1,
225
+ TK_OPTION_NULL_OK,0,0 },
226
+ {TK_OPTION_COLOR, "-foreground", "textColor", "TextColor",
227
+ NULL, Tk_Offset(Label,label.foregroundObj), -1,
228
+ TK_OPTION_NULL_OK,0,0 },
229
+ {TK_OPTION_FONT, "-font", "font", "Font",
230
+ NULL, Tk_Offset(Label,label.fontObj), -1,
231
+ TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
232
+ {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
233
+ NULL, Tk_Offset(Label,label.borderWidthObj), -1,
234
+ TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
235
+ {TK_OPTION_RELIEF, "-relief", "relief", "Relief",
236
+ NULL, Tk_Offset(Label,label.reliefObj), -1,
237
+ TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
238
+ {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
239
+ NULL, Tk_Offset(Label,label.anchorObj), -1,
240
+ TK_OPTION_NULL_OK, 0, GEOMETRY_CHANGED},
241
+ {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
242
+ NULL, Tk_Offset(Label, label.justifyObj), -1,
243
+ TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
244
+ {TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength",
245
+ NULL, Tk_Offset(Label, label.wrapLengthObj), -1,
246
+ TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED /*SB: SIZE_CHANGED*/ },
247
+
248
+ WIDGET_INHERIT_OPTIONS(BaseOptionSpecs)
249
+ };
250
+
251
+ static WidgetCommandSpec LabelCommands[] =
252
+ {
253
+ { "configure", TtkWidgetConfigureCommand },
254
+ { "cget", TtkWidgetCgetCommand },
255
+ { "instate", TtkWidgetInstateCommand },
256
+ { "state", TtkWidgetStateCommand },
257
+ { "identify", TtkWidgetIdentifyCommand },
258
+ { NULL, NULL }
259
+ };
260
+
261
+ static WidgetSpec LabelWidgetSpec =
262
+ {
263
+ "TLabel", /* className */
264
+ sizeof(Label), /* recordSize */
265
+ LabelOptionSpecs, /* optionSpecs */
266
+ LabelCommands, /* subcommands */
267
+ BaseInitialize, /* initializeProc */
268
+ BaseCleanup, /* cleanupProc */
269
+ BaseConfigure, /* configureProc */
270
+ BasePostConfigure, /* postConfigureProc */
271
+ TtkWidgetGetLayout, /* getLayoutProc */
272
+ TtkWidgetSize, /* sizeProc */
273
+ TtkWidgetDoLayout, /* layoutProc */
274
+ TtkWidgetDisplay /* displayProc */
275
+ };
276
+
277
+ TTK_BEGIN_LAYOUT(LabelLayout)
278
+ TTK_GROUP("Label.border", TTK_FILL_BOTH|TTK_BORDER,
279
+ TTK_GROUP("Label.padding", TTK_FILL_BOTH|TTK_BORDER,
280
+ TTK_NODE("Label.label", TTK_FILL_BOTH)))
281
+ TTK_END_LAYOUT
282
+
283
+ /*------------------------------------------------------------------------
284
+ * +++ Button widget.
285
+ * Adds a new subcommand "invoke", and options "-command" and "-default"
286
+ */
287
+
288
+ typedef struct
289
+ {
290
+ Tcl_Obj *commandObj;
291
+ Tcl_Obj *defaultStateObj;
292
+ } ButtonPart;
293
+
294
+ typedef struct
295
+ {
296
+ WidgetCore core;
297
+ BasePart base;
298
+ ButtonPart button;
299
+ } Button;
300
+
301
+ /*
302
+ * Option specifications:
303
+ */
304
+ static Tk_OptionSpec ButtonOptionSpecs[] =
305
+ {
306
+ WIDGET_TAKES_FOCUS,
307
+
308
+ {TK_OPTION_STRING, "-command", "command", "Command",
309
+ "", Tk_Offset(Button, button.commandObj), -1, 0,0,0},
310
+ {TK_OPTION_STRING_TABLE, "-default", "default", "Default",
311
+ "normal", Tk_Offset(Button, button.defaultStateObj), -1,
312
+ 0, (ClientData) ttkDefaultStrings, DEFAULTSTATE_CHANGED},
313
+
314
+ WIDGET_INHERIT_OPTIONS(BaseOptionSpecs)
315
+ };
316
+
317
+ static int ButtonConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
318
+ {
319
+ Button *buttonPtr = recordPtr;
320
+
321
+ if (BaseConfigure(interp, recordPtr, mask) != TCL_OK) {
322
+ return TCL_ERROR;
323
+ }
324
+
325
+ /* Handle "-default" option:
326
+ */
327
+ if (mask & DEFAULTSTATE_CHANGED) {
328
+ int defaultState = TTK_BUTTON_DEFAULT_DISABLED;
329
+ Ttk_GetButtonDefaultStateFromObj(
330
+ NULL, buttonPtr->button.defaultStateObj, &defaultState);
331
+ if (defaultState == TTK_BUTTON_DEFAULT_ACTIVE) {
332
+ TtkWidgetChangeState(&buttonPtr->core, TTK_STATE_ALTERNATE, 0);
333
+ } else {
334
+ TtkWidgetChangeState(&buttonPtr->core, 0, TTK_STATE_ALTERNATE);
335
+ }
336
+ }
337
+ return TCL_OK;
338
+ }
339
+
340
+ /* $button invoke --
341
+ * Evaluate the button's -command.
342
+ */
343
+ static int
344
+ ButtonInvokeCommand(
345
+ Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr)
346
+ {
347
+ Button *buttonPtr = recordPtr;
348
+ if (objc > 2) {
349
+ Tcl_WrongNumArgs(interp, 1, objv, "invoke");
350
+ return TCL_ERROR;
351
+ }
352
+ if (buttonPtr->core.state & TTK_STATE_DISABLED) {
353
+ return TCL_OK;
354
+ }
355
+ return Tcl_EvalObjEx(interp, buttonPtr->button.commandObj, TCL_EVAL_GLOBAL);
356
+ }
357
+
358
+ static WidgetCommandSpec ButtonCommands[] =
359
+ {
360
+ { "configure", TtkWidgetConfigureCommand },
361
+ { "cget", TtkWidgetCgetCommand },
362
+ { "invoke", ButtonInvokeCommand },
363
+ { "instate", TtkWidgetInstateCommand },
364
+ { "state", TtkWidgetStateCommand },
365
+ { "identify", TtkWidgetIdentifyCommand },
366
+ { NULL, NULL }
367
+ };
368
+
369
+ static WidgetSpec ButtonWidgetSpec =
370
+ {
371
+ "TButton", /* className */
372
+ sizeof(Button), /* recordSize */
373
+ ButtonOptionSpecs, /* optionSpecs */
374
+ ButtonCommands, /* subcommands */
375
+ BaseInitialize, /* initializeProc */
376
+ BaseCleanup, /* cleanupProc */
377
+ ButtonConfigure, /* configureProc */
378
+ BasePostConfigure, /* postConfigureProc */
379
+ TtkWidgetGetLayout, /* getLayoutProc */
380
+ TtkWidgetSize, /* sizeProc */
381
+ TtkWidgetDoLayout, /* layoutProc */
382
+ TtkWidgetDisplay /* displayProc */
383
+ };
384
+
385
+ TTK_BEGIN_LAYOUT(ButtonLayout)
386
+ TTK_GROUP("Button.border", TTK_FILL_BOTH|TTK_BORDER,
387
+ TTK_GROUP("Button.focus", TTK_FILL_BOTH,
388
+ TTK_GROUP("Button.padding", TTK_FILL_BOTH,
389
+ TTK_NODE("Button.label", TTK_FILL_BOTH))))
390
+ TTK_END_LAYOUT
391
+
392
+ /*------------------------------------------------------------------------
393
+ * +++ Checkbutton widget.
394
+ */
395
+ typedef struct
396
+ {
397
+ Tcl_Obj *variableObj;
398
+ Tcl_Obj *onValueObj;
399
+ Tcl_Obj *offValueObj;
400
+ Tcl_Obj *commandObj;
401
+
402
+ Ttk_TraceHandle *variableTrace;
403
+
404
+ } CheckbuttonPart;
405
+
406
+ typedef struct
407
+ {
408
+ WidgetCore core;
409
+ BasePart base;
410
+ CheckbuttonPart checkbutton;
411
+ } Checkbutton;
412
+
413
+ /*
414
+ * Option specifications:
415
+ */
416
+ static Tk_OptionSpec CheckbuttonOptionSpecs[] =
417
+ {
418
+ WIDGET_TAKES_FOCUS,
419
+
420
+ {TK_OPTION_STRING, "-variable", "variable", "Variable",
421
+ "", Tk_Offset(Checkbutton, checkbutton.variableObj), -1, 0,0,0},
422
+ {TK_OPTION_STRING, "-onvalue", "onValue", "OnValue",
423
+ "1", Tk_Offset(Checkbutton, checkbutton.onValueObj), -1, 0,0,0},
424
+ {TK_OPTION_STRING, "-offvalue", "offValue", "OffValue",
425
+ "0", Tk_Offset(Checkbutton, checkbutton.offValueObj), -1, 0,0,0},
426
+ {TK_OPTION_STRING, "-command", "command", "Command",
427
+ "", Tk_Offset(Checkbutton, checkbutton.commandObj), -1, 0,0,0},
428
+
429
+ WIDGET_INHERIT_OPTIONS(BaseOptionSpecs)
430
+ };
431
+
432
+ /*
433
+ * Variable trace procedure for checkbutton -variable option
434
+ */
435
+ static void CheckbuttonVariableChanged(void *clientData, const char *value)
436
+ {
437
+ Checkbutton *checkPtr = clientData;
438
+
439
+ if (WidgetDestroyed(&checkPtr->core)) {
440
+ return;
441
+ }
442
+
443
+ if (!value) {
444
+ TtkWidgetChangeState(&checkPtr->core, TTK_STATE_ALTERNATE, 0);
445
+ return;
446
+ }
447
+ /* else */
448
+ TtkWidgetChangeState(&checkPtr->core, 0, TTK_STATE_ALTERNATE);
449
+ if (!strcmp(value, Tcl_GetString(checkPtr->checkbutton.onValueObj))) {
450
+ TtkWidgetChangeState(&checkPtr->core, TTK_STATE_SELECTED, 0);
451
+ } else {
452
+ TtkWidgetChangeState(&checkPtr->core, 0, TTK_STATE_SELECTED);
453
+ }
454
+ }
455
+
456
+ static int CheckbuttonInitialize(Tcl_Interp *interp, void *recordPtr)
457
+ {
458
+ Checkbutton *checkPtr = recordPtr;
459
+ Tcl_Obj *objPtr;
460
+
461
+ /* default -variable is the widget name:
462
+ */
463
+ objPtr = Tcl_NewStringObj(Tk_PathName(checkPtr->core.tkwin), -1);
464
+ Tcl_IncrRefCount(objPtr);
465
+ Tcl_DecrRefCount(checkPtr->checkbutton.variableObj);
466
+ checkPtr->checkbutton.variableObj = objPtr;
467
+
468
+ return BaseInitialize(interp, recordPtr);
469
+ }
470
+
471
+ static void
472
+ CheckbuttonCleanup(void *recordPtr)
473
+ {
474
+ Checkbutton *checkPtr = recordPtr;
475
+ Ttk_UntraceVariable(checkPtr->checkbutton.variableTrace);
476
+ checkPtr->checkbutton.variableTrace = 0;
477
+ BaseCleanup(recordPtr);
478
+ }
479
+
480
+ static int
481
+ CheckbuttonConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
482
+ {
483
+ Checkbutton *checkPtr = recordPtr;
484
+ Ttk_TraceHandle *vt = Ttk_TraceVariable(
485
+ interp, checkPtr->checkbutton.variableObj,
486
+ CheckbuttonVariableChanged, checkPtr);
487
+
488
+ if (!vt) {
489
+ return TCL_ERROR;
490
+ }
491
+
492
+ if (BaseConfigure(interp, recordPtr, mask) != TCL_OK){
493
+ Ttk_UntraceVariable(vt);
494
+ return TCL_ERROR;
495
+ }
496
+
497
+ Ttk_UntraceVariable(checkPtr->checkbutton.variableTrace);
498
+ checkPtr->checkbutton.variableTrace = vt;
499
+
500
+ return TCL_OK;
501
+ }
502
+
503
+ static int
504
+ CheckbuttonPostConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
505
+ {
506
+ Checkbutton *checkPtr = recordPtr;
507
+ int status = TCL_OK;
508
+
509
+ if (checkPtr->checkbutton.variableTrace)
510
+ status = Ttk_FireTrace(checkPtr->checkbutton.variableTrace);
511
+ if (status == TCL_OK && !WidgetDestroyed(&checkPtr->core))
512
+ status = BasePostConfigure(interp, recordPtr, mask);
513
+ return status;
514
+ }
515
+
516
+ /*
517
+ * Checkbutton 'invoke' subcommand:
518
+ * Toggles the checkbutton state.
519
+ */
520
+ static int
521
+ CheckbuttonInvokeCommand(
522
+ Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr)
523
+ {
524
+ Checkbutton *checkPtr = recordPtr;
525
+ WidgetCore *corePtr = &checkPtr->core;
526
+ Tcl_Obj *newValue;
527
+
528
+ if (objc > 2) {
529
+ Tcl_WrongNumArgs(interp, 1, objv, "invoke");
530
+ return TCL_ERROR;
531
+ }
532
+ if (corePtr->state & TTK_STATE_DISABLED)
533
+ return TCL_OK;
534
+
535
+ /*
536
+ * Toggle the selected state.
537
+ */
538
+ if (corePtr->state & TTK_STATE_SELECTED)
539
+ newValue = checkPtr->checkbutton.offValueObj;
540
+ else
541
+ newValue = checkPtr->checkbutton.onValueObj;
542
+
543
+ if (Tcl_ObjSetVar2(interp,
544
+ checkPtr->checkbutton.variableObj, NULL, newValue,
545
+ TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG)
546
+ == NULL)
547
+ return TCL_ERROR;
548
+
549
+ if (WidgetDestroyed(corePtr))
550
+ return TCL_ERROR;
551
+
552
+ return Tcl_EvalObjEx(interp,
553
+ checkPtr->checkbutton.commandObj, TCL_EVAL_GLOBAL);
554
+ }
555
+
556
+ static WidgetCommandSpec CheckbuttonCommands[] =
557
+ {
558
+ { "configure", TtkWidgetConfigureCommand },
559
+ { "cget", TtkWidgetCgetCommand },
560
+ { "invoke", CheckbuttonInvokeCommand },
561
+ { "instate", TtkWidgetInstateCommand },
562
+ { "state", TtkWidgetStateCommand },
563
+ { "identify", TtkWidgetIdentifyCommand },
564
+ /* MISSING: select, deselect, toggle */
565
+ { NULL, NULL }
566
+ };
567
+
568
+ static WidgetSpec CheckbuttonWidgetSpec =
569
+ {
570
+ "TCheckbutton", /* className */
571
+ sizeof(Checkbutton), /* recordSize */
572
+ CheckbuttonOptionSpecs, /* optionSpecs */
573
+ CheckbuttonCommands, /* subcommands */
574
+ CheckbuttonInitialize, /* initializeProc */
575
+ CheckbuttonCleanup, /* cleanupProc */
576
+ CheckbuttonConfigure, /* configureProc */
577
+ CheckbuttonPostConfigure, /* postConfigureProc */
578
+ TtkWidgetGetLayout, /* getLayoutProc */
579
+ TtkWidgetSize, /* sizeProc */
580
+ TtkWidgetDoLayout, /* layoutProc */
581
+ TtkWidgetDisplay /* displayProc */
582
+ };
583
+
584
+ TTK_BEGIN_LAYOUT(CheckbuttonLayout)
585
+ TTK_GROUP("Checkbutton.padding", TTK_FILL_BOTH,
586
+ TTK_NODE("Checkbutton.indicator", TTK_PACK_LEFT)
587
+ TTK_GROUP("Checkbutton.focus", TTK_PACK_LEFT | TTK_STICK_W,
588
+ TTK_NODE("Checkbutton.label", TTK_FILL_BOTH)))
589
+ TTK_END_LAYOUT
590
+
591
+ /*------------------------------------------------------------------------
592
+ * +++ Radiobutton widget.
593
+ */
594
+
595
+ typedef struct
596
+ {
597
+ Tcl_Obj *variableObj;
598
+ Tcl_Obj *valueObj;
599
+ Tcl_Obj *commandObj;
600
+
601
+ Ttk_TraceHandle *variableTrace;
602
+
603
+ } RadiobuttonPart;
604
+
605
+ typedef struct
606
+ {
607
+ WidgetCore core;
608
+ BasePart base;
609
+ RadiobuttonPart radiobutton;
610
+ } Radiobutton;
611
+
612
+ /*
613
+ * Option specifications:
614
+ */
615
+ static Tk_OptionSpec RadiobuttonOptionSpecs[] =
616
+ {
617
+ WIDGET_TAKES_FOCUS,
618
+
619
+ {TK_OPTION_STRING, "-variable", "variable", "Variable",
620
+ "::selectedButton", Tk_Offset(Radiobutton, radiobutton.variableObj),-1,
621
+ 0,0,0},
622
+ {TK_OPTION_STRING, "-value", "Value", "Value",
623
+ "1", Tk_Offset(Radiobutton, radiobutton.valueObj), -1,
624
+ 0,0,0},
625
+ {TK_OPTION_STRING, "-command", "command", "Command",
626
+ "", Tk_Offset(Radiobutton, radiobutton.commandObj), -1,
627
+ 0,0,0},
628
+
629
+ WIDGET_INHERIT_OPTIONS(BaseOptionSpecs)
630
+ };
631
+
632
+ /*
633
+ * Variable trace procedure for radiobuttons.
634
+ */
635
+ static void
636
+ RadiobuttonVariableChanged(void *clientData, const char *value)
637
+ {
638
+ Radiobutton *radioPtr = clientData;
639
+
640
+ if (WidgetDestroyed(&radioPtr->core)) {
641
+ return;
642
+ }
643
+
644
+ if (!value) {
645
+ TtkWidgetChangeState(&radioPtr->core, TTK_STATE_ALTERNATE, 0);
646
+ return;
647
+ }
648
+ /* else */
649
+ TtkWidgetChangeState(&radioPtr->core, 0, TTK_STATE_ALTERNATE);
650
+ if (!strcmp(value, Tcl_GetString(radioPtr->radiobutton.valueObj))) {
651
+ TtkWidgetChangeState(&radioPtr->core, TTK_STATE_SELECTED, 0);
652
+ } else {
653
+ TtkWidgetChangeState(&radioPtr->core, 0, TTK_STATE_SELECTED);
654
+ }
655
+ }
656
+
657
+ static void
658
+ RadiobuttonCleanup(void *recordPtr)
659
+ {
660
+ Radiobutton *radioPtr = recordPtr;
661
+ Ttk_UntraceVariable(radioPtr->radiobutton.variableTrace);
662
+ radioPtr->radiobutton.variableTrace = 0;
663
+ BaseCleanup(recordPtr);
664
+ }
665
+
666
+ static int
667
+ RadiobuttonConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
668
+ {
669
+ Radiobutton *radioPtr = recordPtr;
670
+ Ttk_TraceHandle *vt = Ttk_TraceVariable(
671
+ interp, radioPtr->radiobutton.variableObj,
672
+ RadiobuttonVariableChanged, radioPtr);
673
+
674
+ if (!vt) {
675
+ return TCL_ERROR;
676
+ }
677
+
678
+ if (BaseConfigure(interp, recordPtr, mask) != TCL_OK) {
679
+ Ttk_UntraceVariable(vt);
680
+ return TCL_ERROR;
681
+ }
682
+
683
+ Ttk_UntraceVariable(radioPtr->radiobutton.variableTrace);
684
+ radioPtr->radiobutton.variableTrace = vt;
685
+
686
+ return TCL_OK;
687
+ }
688
+
689
+ static int
690
+ RadiobuttonPostConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
691
+ {
692
+ Radiobutton *radioPtr = recordPtr;
693
+ int status = TCL_OK;
694
+
695
+ if (radioPtr->radiobutton.variableTrace)
696
+ status = Ttk_FireTrace(radioPtr->radiobutton.variableTrace);
697
+ if (status == TCL_OK && !WidgetDestroyed(&radioPtr->core))
698
+ status = BasePostConfigure(interp, recordPtr, mask);
699
+ return status;
700
+ }
701
+
702
+ /*
703
+ * Radiobutton 'invoke' subcommand:
704
+ * Sets the radiobutton -variable to the -value, evaluates the -command.
705
+ */
706
+ static int
707
+ RadiobuttonInvokeCommand(
708
+ Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr)
709
+ {
710
+ Radiobutton *radioPtr = recordPtr;
711
+ WidgetCore *corePtr = &radioPtr->core;
712
+
713
+ if (objc > 2) {
714
+ Tcl_WrongNumArgs(interp, 1, objv, "invoke");
715
+ return TCL_ERROR;
716
+ }
717
+ if (corePtr->state & TTK_STATE_DISABLED)
718
+ return TCL_OK;
719
+
720
+ if (Tcl_ObjSetVar2(interp,
721
+ radioPtr->radiobutton.variableObj, NULL,
722
+ radioPtr->radiobutton.valueObj,
723
+ TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG)
724
+ == NULL)
725
+ return TCL_ERROR;
726
+
727
+ if (WidgetDestroyed(corePtr))
728
+ return TCL_ERROR;
729
+
730
+ return Tcl_EvalObjEx(interp,
731
+ radioPtr->radiobutton.commandObj, TCL_EVAL_GLOBAL);
732
+ }
733
+
734
+ static WidgetCommandSpec RadiobuttonCommands[] =
735
+ {
736
+ { "configure", TtkWidgetConfigureCommand },
737
+ { "cget", TtkWidgetCgetCommand },
738
+ { "invoke", RadiobuttonInvokeCommand },
739
+ { "instate", TtkWidgetInstateCommand },
740
+ { "state", TtkWidgetStateCommand },
741
+ { "identify", TtkWidgetIdentifyCommand },
742
+ /* MISSING: select, deselect */
743
+ { NULL, NULL }
744
+ };
745
+
746
+ static WidgetSpec RadiobuttonWidgetSpec =
747
+ {
748
+ "TRadiobutton", /* className */
749
+ sizeof(Radiobutton), /* recordSize */
750
+ RadiobuttonOptionSpecs, /* optionSpecs */
751
+ RadiobuttonCommands, /* subcommands */
752
+ BaseInitialize, /* initializeProc */
753
+ RadiobuttonCleanup, /* cleanupProc */
754
+ RadiobuttonConfigure, /* configureProc */
755
+ RadiobuttonPostConfigure, /* postConfigureProc */
756
+ TtkWidgetGetLayout, /* getLayoutProc */
757
+ TtkWidgetSize, /* sizeProc */
758
+ TtkWidgetDoLayout, /* layoutProc */
759
+ TtkWidgetDisplay /* displayProc */
760
+ };
761
+
762
+ TTK_BEGIN_LAYOUT(RadiobuttonLayout)
763
+ TTK_GROUP("Radiobutton.padding", TTK_FILL_BOTH,
764
+ TTK_NODE("Radiobutton.indicator", TTK_PACK_LEFT)
765
+ TTK_GROUP("Radiobutton.focus", TTK_PACK_LEFT,
766
+ TTK_NODE("Radiobutton.label", TTK_FILL_BOTH)))
767
+ TTK_END_LAYOUT
768
+
769
+ /*------------------------------------------------------------------------
770
+ * +++ Menubutton widget.
771
+ */
772
+
773
+ typedef struct
774
+ {
775
+ Tcl_Obj *menuObj;
776
+ Tcl_Obj *directionObj;
777
+ } MenubuttonPart;
778
+
779
+ typedef struct
780
+ {
781
+ WidgetCore core;
782
+ BasePart base;
783
+ MenubuttonPart menubutton;
784
+ } Menubutton;
785
+
786
+ /*
787
+ * Option specifications:
788
+ */
789
+ static const char *directionStrings[] = {
790
+ "above", "below", "left", "right", "flush", NULL
791
+ };
792
+ static Tk_OptionSpec MenubuttonOptionSpecs[] =
793
+ {
794
+ WIDGET_TAKES_FOCUS,
795
+
796
+ {TK_OPTION_STRING, "-menu", "menu", "Menu",
797
+ "", Tk_Offset(Menubutton, menubutton.menuObj), -1, 0,0,0},
798
+ {TK_OPTION_STRING_TABLE, "-direction", "direction", "Direction",
799
+ "below", Tk_Offset(Menubutton, menubutton.directionObj), -1,
800
+ 0,(ClientData)directionStrings,GEOMETRY_CHANGED},
801
+
802
+ WIDGET_INHERIT_OPTIONS(BaseOptionSpecs)
803
+ };
804
+
805
+ static WidgetCommandSpec MenubuttonCommands[] =
806
+ {
807
+ { "configure", TtkWidgetConfigureCommand },
808
+ { "cget", TtkWidgetCgetCommand },
809
+ { "instate", TtkWidgetInstateCommand },
810
+ { "state", TtkWidgetStateCommand },
811
+ { "identify", TtkWidgetIdentifyCommand },
812
+ { NULL, NULL }
813
+ };
814
+
815
+ static WidgetSpec MenubuttonWidgetSpec =
816
+ {
817
+ "TMenubutton", /* className */
818
+ sizeof(Menubutton), /* recordSize */
819
+ MenubuttonOptionSpecs, /* optionSpecs */
820
+ MenubuttonCommands, /* subcommands */
821
+ BaseInitialize, /* initializeProc */
822
+ BaseCleanup, /* cleanupProc */
823
+ BaseConfigure, /* configureProc */
824
+ BasePostConfigure, /* postConfigureProc */
825
+ TtkWidgetGetLayout, /* getLayoutProc */
826
+ TtkWidgetSize, /* sizeProc */
827
+ TtkWidgetDoLayout, /* layoutProc */
828
+ TtkWidgetDisplay /* displayProc */
829
+ };
830
+
831
+ TTK_BEGIN_LAYOUT(MenubuttonLayout)
832
+ TTK_GROUP("Menubutton.border", TTK_FILL_BOTH,
833
+ TTK_GROUP("Menubutton.focus", TTK_FILL_BOTH,
834
+ TTK_NODE("Menubutton.indicator", TTK_PACK_RIGHT)
835
+ TTK_GROUP("Menubutton.padding", TTK_PACK_LEFT|TTK_EXPAND|TTK_FILL_X,
836
+ TTK_NODE("Menubutton.label", TTK_PACK_LEFT))))
837
+ TTK_END_LAYOUT
838
+
839
+ /*------------------------------------------------------------------------
840
+ * +++ Initialization.
841
+ */
842
+
843
+ void TtkButton_Init(Tcl_Interp *interp)
844
+ {
845
+ Ttk_Theme theme = Ttk_GetDefaultTheme(interp);
846
+
847
+ Ttk_RegisterLayout(theme, "TLabel", LabelLayout);
848
+ Ttk_RegisterLayout(theme, "TButton", ButtonLayout);
849
+ Ttk_RegisterLayout(theme, "TCheckbutton", CheckbuttonLayout);
850
+ Ttk_RegisterLayout(theme, "TRadiobutton", RadiobuttonLayout);
851
+ Ttk_RegisterLayout(theme, "TMenubutton", MenubuttonLayout);
852
+
853
+ RegisterWidget(interp, "ttk::label", &LabelWidgetSpec);
854
+ RegisterWidget(interp, "ttk::button", &ButtonWidgetSpec);
855
+ RegisterWidget(interp, "ttk::checkbutton", &CheckbuttonWidgetSpec);
856
+ RegisterWidget(interp, "ttk::radiobutton", &RadiobuttonWidgetSpec);
857
+ RegisterWidget(interp, "ttk::menubutton", &MenubuttonWidgetSpec);
858
+ }