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,268 @@
1
+ /*
2
+ * tkstate.c,v 1.11 2005/04/06 00:03:09 jenglish Exp
3
+ *
4
+ * Tk widget state utilities.
5
+ *
6
+ * Copyright (c) 2003 Joe English. Freely redistributable.
7
+ *
8
+ */
9
+
10
+ #include <string.h>
11
+
12
+ #include <tk.h>
13
+ #include "tkTheme.h"
14
+
15
+ /*
16
+ * Table of state names. Must be kept in sync with TTK_STATE_*
17
+ * #defines in tkTheme.h.
18
+ */
19
+ static const char *stateNames[] =
20
+ {
21
+ "active", /* Mouse cursor is over widget or element */
22
+ "disabled", /* Widget is disabled */
23
+ "focus", /* Widget has keyboard focus */
24
+ "pressed", /* Pressed or "armed" */
25
+ "selected", /* "on", "true", "current", etc. */
26
+ "background", /* Top-level window lost focus (Mac,Win "inactive") */
27
+ "alternate", /* Widget-specific alternate display style */
28
+ "invalid", /* Bad value */
29
+ "readonly", /* Editing/modification disabled */
30
+ NULL
31
+ };
32
+
33
+ /*------------------------------------------------------------------------
34
+ * +++ StateSpec object type:
35
+ *
36
+ * The string representation consists of a list of state names,
37
+ * each optionally prefixed by an exclamation point (!).
38
+ *
39
+ * The internal representation uses the upper half of the longValue
40
+ * to store the on bits and the lower half to store the off bits.
41
+ * If we ever get more than 16 states, this will need to be reconsidered...
42
+ */
43
+
44
+ static int StateSpecSetFromAny(Tcl_Interp *interp, Tcl_Obj *obj);
45
+ /* static void StateSpecFreeIntRep(Tcl_Obj *); */
46
+ #define StateSpecFreeIntRep 0 /* not needed */
47
+ static void StateSpecDupIntRep(Tcl_Obj *, Tcl_Obj *);
48
+ static void StateSpecUpdateString(Tcl_Obj *);
49
+
50
+ static
51
+ struct Tcl_ObjType StateSpecObjType =
52
+ {
53
+ "StateSpec",
54
+ StateSpecFreeIntRep,
55
+ StateSpecDupIntRep,
56
+ StateSpecUpdateString,
57
+ StateSpecSetFromAny
58
+ };
59
+
60
+ static void StateSpecDupIntRep(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr)
61
+ {
62
+ copyPtr->internalRep.longValue = srcPtr->internalRep.longValue;
63
+ copyPtr->typePtr = &StateSpecObjType;
64
+ }
65
+
66
+ static int StateSpecSetFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr)
67
+ {
68
+ int status;
69
+ int objc;
70
+ Tcl_Obj **objv;
71
+ int i;
72
+ unsigned int onbits = 0, offbits = 0;
73
+
74
+ status = Tcl_ListObjGetElements(interp, objPtr, &objc, &objv);
75
+ if (status != TCL_OK)
76
+ return status;
77
+
78
+ for (i = 0; i < objc; ++i) {
79
+ char *stateName = Tcl_GetString(objv[i]);
80
+ int on, j;
81
+
82
+ if (*stateName == '!') {
83
+ ++stateName;
84
+ on = 0;
85
+ } else {
86
+ on = 1;
87
+ }
88
+
89
+ for (j = 0; stateNames[j] != 0; ++j) {
90
+ if (strcmp(stateName, stateNames[j]) == 0)
91
+ break;
92
+ }
93
+
94
+ if (stateNames[j] == 0) {
95
+ if (interp) {
96
+ Tcl_ResetResult(interp);
97
+ Tcl_AppendResult(interp, "Invalid state name ", stateName,NULL);
98
+ }
99
+ return TCL_ERROR;
100
+ }
101
+
102
+ if (on) {
103
+ onbits |= (1<<j);
104
+ } else {
105
+ offbits |= (1<<j);
106
+ }
107
+ }
108
+
109
+ /* Invalidate old intrep:
110
+ */
111
+ if (objPtr->typePtr && objPtr->typePtr->freeIntRepProc) {
112
+ objPtr->typePtr->freeIntRepProc(objPtr);
113
+ }
114
+
115
+ objPtr->typePtr = &StateSpecObjType;
116
+ objPtr->internalRep.longValue = (onbits << 16) | offbits;
117
+
118
+ return TCL_OK;
119
+ }
120
+
121
+ static void StateSpecUpdateString(Tcl_Obj *objPtr)
122
+ {
123
+ unsigned int onbits = (objPtr->internalRep.longValue & 0xFFFF0000) >> 16;
124
+ unsigned int offbits = objPtr->internalRep.longValue & 0x0000FFFF;
125
+ unsigned int mask = onbits | offbits;
126
+ Tcl_DString result;
127
+ int i, len;
128
+
129
+ Tcl_DStringInit(&result);
130
+
131
+ for (i=0; stateNames[i] != NULL; ++i) {
132
+ if (mask & (1<<i)) {
133
+ if (offbits & (1<<i))
134
+ Tcl_DStringAppend(&result, "!", 1);
135
+ Tcl_DStringAppend(&result, stateNames[i], -1);
136
+ Tcl_DStringAppend(&result, " ", 1);
137
+ }
138
+ }
139
+
140
+ len = Tcl_DStringLength(&result);
141
+ if (len) {
142
+ /* 'len' includes extra trailing ' ' */
143
+ objPtr->bytes = Tcl_Alloc((unsigned)len);
144
+ objPtr->length = len-1;
145
+ strncpy(objPtr->bytes, Tcl_DStringValue(&result), (size_t)len-1);
146
+ objPtr->bytes[len-1] = '\0';
147
+ } else {
148
+ /* empty string */
149
+ objPtr->length = 0;
150
+ objPtr->bytes = Tcl_Alloc(1);
151
+ *objPtr->bytes = '\0';
152
+ }
153
+
154
+ Tcl_DStringFree(&result);
155
+ }
156
+
157
+ Tcl_Obj *Ttk_NewStateSpecObj(unsigned int onbits, unsigned int offbits)
158
+ {
159
+ Tcl_Obj *objPtr = Tcl_NewObj();
160
+
161
+ Tcl_InvalidateStringRep(objPtr);
162
+ objPtr->typePtr = &StateSpecObjType;
163
+ objPtr->internalRep.longValue = (onbits << 16) | offbits;
164
+
165
+ return objPtr;
166
+ }
167
+
168
+ int Ttk_GetStateSpecFromObj(
169
+ Tcl_Interp *interp,
170
+ Tcl_Obj *objPtr,
171
+ Ttk_StateSpec *spec)
172
+ {
173
+ if (objPtr->typePtr != &StateSpecObjType) {
174
+ int status = StateSpecSetFromAny(interp, objPtr);
175
+ if (status != TCL_OK)
176
+ return status;
177
+ }
178
+
179
+ spec->onbits = (objPtr->internalRep.longValue & 0xFFFF0000) >> 16;
180
+ spec->offbits = objPtr->internalRep.longValue & 0x0000FFFF;
181
+ return TCL_OK;
182
+ }
183
+
184
+
185
+ /*
186
+ * Tk_StateMapLookup --
187
+ *
188
+ * A state map is a paired list of StateSpec / value pairs.
189
+ * Returns the value corresponding to the first matching state
190
+ * specification, or NULL if not found or an error occurs.
191
+ */
192
+ Tcl_Obj *Ttk_StateMapLookup(
193
+ Tcl_Interp *interp, /* Where to leave error messages; may be NULL */
194
+ Ttk_StateMap map, /* State map */
195
+ Ttk_State state) /* State to look up */
196
+ {
197
+ Tcl_Obj **specs;
198
+ int nSpecs;
199
+ int j, status;
200
+
201
+ status = Tcl_ListObjGetElements(interp, map, &nSpecs, &specs);
202
+ if (status != TCL_OK)
203
+ return NULL;
204
+
205
+ for (j = 0; j < nSpecs; j += 2) {
206
+ Ttk_StateSpec spec;
207
+ status = Ttk_GetStateSpecFromObj(interp, specs[j], &spec);
208
+ if (status != TCL_OK)
209
+ return NULL;
210
+ if (Ttk_StateMatches(state, &spec))
211
+ return specs[j+1];
212
+ }
213
+ if (interp) {
214
+ Tcl_ResetResult(interp);
215
+ Tcl_AppendResult(interp, "No match in state map", NULL);
216
+ }
217
+ return NULL;
218
+ }
219
+
220
+ /* Ttk_GetStateMapFromObj --
221
+ * Returns a Ttk_StateMap from a Tcl_Obj*.
222
+ * Since a Ttk_StateMap is just a specially-formatted Tcl_Obj,
223
+ * this basically just checks for errors.
224
+ */
225
+ Ttk_StateMap Ttk_GetStateMapFromObj(
226
+ Tcl_Interp *interp, /* Where to leave error messages; may be NULL */
227
+ Tcl_Obj *mapObj) /* State map */
228
+ {
229
+ Tcl_Obj **specs;
230
+ int nSpecs;
231
+ int j, status;
232
+
233
+ status = Tcl_ListObjGetElements(interp, mapObj, &nSpecs, &specs);
234
+ if (status != TCL_OK)
235
+ return NULL;
236
+
237
+ if (nSpecs % 2 != 0) {
238
+ if (interp)
239
+ Tcl_SetResult(interp,
240
+ "State map must have an even number of elements",
241
+ TCL_STATIC);
242
+ return 0;
243
+ }
244
+
245
+ for (j = 0; j < nSpecs; j += 2) {
246
+ Ttk_StateSpec spec;
247
+ if (Ttk_GetStateSpecFromObj(interp, specs[j], &spec) != TCL_OK)
248
+ return NULL;
249
+ }
250
+
251
+ return mapObj;
252
+ }
253
+
254
+ /*
255
+ * Ttk_StateTableLooup --
256
+ * Look up an index from a statically allocated state table.
257
+ */
258
+ int Ttk_StateTableLookup(Ttk_StateTable *map, unsigned int state)
259
+ {
260
+ while ((state & map->onBits) != map->onBits
261
+ || (~state & map->offBits) != map->offBits)
262
+ {
263
+ ++map;
264
+ }
265
+ return map->index;
266
+ }
267
+
268
+ /*EOF*/
@@ -0,0 +1,145 @@
1
+ /* trace.c,v 1.4 2005/09/12 03:11:01 jenglish Exp
2
+ *
3
+ * Copyright 2003, Joe English
4
+ *
5
+ * Simplified interface to Tcl_TraceVariable.
6
+ *
7
+ * PROBLEM: Can't distinguish "variable does not exist" (which is OK)
8
+ * from other errors (which are not).
9
+ */
10
+
11
+ #include <tk.h>
12
+ #include "tkTheme.h"
13
+ #include "widget.h"
14
+
15
+ struct TtkTraceHandle_
16
+ {
17
+ Tcl_Interp *interp; /* Containing interpreter */
18
+ Tcl_Obj *varnameObj; /* Name of variable being traced */
19
+ Ttk_TraceProc callback; /* Callback procedure */
20
+ void *clientData; /* Data to pass to callback */
21
+ };
22
+
23
+ /*
24
+ * Tcl_VarTraceProc for trace handles.
25
+ */
26
+ static char *
27
+ VarTraceProc(
28
+ ClientData clientData, /* Widget record pointer */
29
+ Tcl_Interp *interp, /* Interpreter containing variable. */
30
+ CONST char *name1, /* (unused) */
31
+ CONST char *name2, /* (unused) */
32
+ int flags) /* Information about what happened. */
33
+ {
34
+ Ttk_TraceHandle *tracePtr = clientData;
35
+ const char *name, *value;
36
+ Tcl_Obj *valuePtr;
37
+
38
+ if (flags & TCL_INTERP_DESTROYED) {
39
+ return NULL;
40
+ }
41
+
42
+ name = Tcl_GetString(tracePtr->varnameObj);
43
+
44
+ /*
45
+ * If the variable is being unset, then re-establish the trace:
46
+ */
47
+ if (flags & TCL_TRACE_DESTROYED) {
48
+ Tcl_TraceVar(interp, name,
49
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
50
+ VarTraceProc, clientData);
51
+ tracePtr->callback(tracePtr->clientData, NULL);
52
+ return NULL;
53
+ }
54
+
55
+ /*
56
+ * Call the callback:
57
+ */
58
+ valuePtr = Tcl_GetVar2Ex(interp, name, NULL, TCL_GLOBAL_ONLY);
59
+ value = valuePtr ? Tcl_GetString(valuePtr) : NULL;
60
+ tracePtr->callback(tracePtr->clientData, value);
61
+
62
+ return NULL;
63
+ }
64
+
65
+ /* Ttk_TraceVariable(interp, varNameObj, callback, clientdata) --
66
+ * Attach a write trace to the specified variable,
67
+ * which will pass the variable's value to 'callback'
68
+ * whenever the variable is set.
69
+ *
70
+ * When the variable is unset, passes NULL to the callback
71
+ * and reattaches the trace.
72
+ */
73
+ Ttk_TraceHandle *Ttk_TraceVariable(
74
+ Tcl_Interp *interp,
75
+ Tcl_Obj *varnameObj,
76
+ Ttk_TraceProc callback,
77
+ void *clientData)
78
+ {
79
+ Ttk_TraceHandle *h = (Ttk_TraceHandle*)ckalloc(sizeof(*h));
80
+ int status;
81
+
82
+ h->interp = interp;
83
+ h->varnameObj = Tcl_DuplicateObj(varnameObj);
84
+ Tcl_IncrRefCount(h->varnameObj);
85
+ h->clientData = clientData;
86
+ h->callback = callback;
87
+
88
+ status = Tcl_TraceVar(interp, Tcl_GetString(varnameObj),
89
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
90
+ VarTraceProc, (ClientData)h);
91
+
92
+ if (status != TCL_OK) {
93
+ Tcl_DecrRefCount(h->varnameObj);
94
+ ckfree((ClientData)h);
95
+ return NULL;
96
+ }
97
+
98
+ return h;
99
+ }
100
+
101
+ /*
102
+ * Ttk_UntraceVariable --
103
+ * Remove previously-registered trace and free the handle.
104
+ */
105
+ void Ttk_UntraceVariable(Ttk_TraceHandle *h)
106
+ {
107
+ if (h) {
108
+ Tcl_UntraceVar(h->interp, Tcl_GetString(h->varnameObj),
109
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
110
+ VarTraceProc, (ClientData)h);
111
+ Tcl_DecrRefCount(h->varnameObj);
112
+ ckfree((ClientData)h);
113
+ }
114
+ }
115
+
116
+ /*
117
+ * Ttk_FireTrace --
118
+ * Executes a trace handle as if the variable has been written.
119
+ *
120
+ * Note: may reenter the interpreter.
121
+ */
122
+ int Ttk_FireTrace(Ttk_TraceHandle *tracePtr)
123
+ {
124
+ Tcl_Interp *interp = tracePtr->interp;
125
+ void *clientData = tracePtr->clientData;
126
+ const char *name = Tcl_GetString(tracePtr->varnameObj);
127
+ Ttk_TraceProc callback = tracePtr->callback;
128
+ Tcl_Obj *valuePtr;
129
+ const char *value;
130
+
131
+ /* Read the variable.
132
+ * Note that this can reenter the interpreter, and anything can happen --
133
+ * including the current trace handle being freed!
134
+ */
135
+ valuePtr = Tcl_GetVar2Ex(interp, name, NULL, TCL_GLOBAL_ONLY);
136
+ value = valuePtr ? Tcl_GetString(valuePtr) : NULL;
137
+
138
+ /* Call callback.
139
+ */
140
+ callback(clientData, value);
141
+
142
+ return TCL_OK;
143
+ }
144
+
145
+ /*EOF*/
@@ -0,0 +1,174 @@
1
+ /* track.c,v 1.9 2007/10/22 03:13:34 jenglish Exp
2
+ * Copyright (c) 2004, Joe English
3
+ *
4
+ * TtkTrackElementState() -- helper routine for widgets
5
+ * like scrollbars in which individual elements may
6
+ * be active or pressed instead of the widget as a whole.
7
+ *
8
+ * Usage:
9
+ * TtkTrackElementState(&recordPtr->core);
10
+ *
11
+ * Registers an event handler on the widget that tracks pointer
12
+ * events and updates the state of the element under the
13
+ * mouse cursor.
14
+ *
15
+ * The "active" element is the one under the mouse cursor,
16
+ * and is normally set to the ACTIVE state unless another element
17
+ * is currently being pressed.
18
+ *
19
+ * The active element becomes "pressed" on <ButtonPress> events,
20
+ * and remains "active" and "pressed" until the corresponding
21
+ * <ButtonRelease> event.
22
+ *
23
+ * TODO: Handle "chords" properly (e.g., <B1-ButtonPress-2>)
24
+ */
25
+
26
+ #include <tk.h>
27
+ #include "tkTheme.h"
28
+ #include "widget.h"
29
+
30
+ typedef struct
31
+ {
32
+ WidgetCore *corePtr; /* Widget to track */
33
+ Ttk_LayoutNode *activeElement; /* element under the mouse cursor */
34
+ Ttk_LayoutNode *pressedElement; /* currently pressed element */
35
+ } ElementStateTracker;
36
+
37
+ /*
38
+ * ActivateElement(es, node) --
39
+ * Make 'node' the active element if non-NULL.
40
+ * Deactivates the currently active element if different.
41
+ *
42
+ * The active element has TTK_STATE_ACTIVE set _unless_
43
+ * another element is 'pressed'
44
+ */
45
+ static void ActivateElement(ElementStateTracker *es, Ttk_LayoutNode *node)
46
+ {
47
+ if (es->activeElement == node) {
48
+ /* No change */
49
+ return;
50
+ }
51
+
52
+ if (!es->pressedElement) {
53
+ if (es->activeElement) {
54
+ /* Deactivate old element */
55
+ Ttk_ChangeElementState(es->activeElement, 0,TTK_STATE_ACTIVE);
56
+ }
57
+ if (node) {
58
+ /* Activate new element */
59
+ Ttk_ChangeElementState(node, TTK_STATE_ACTIVE,0);
60
+ }
61
+ TtkRedisplayWidget(es->corePtr);
62
+ }
63
+
64
+ es->activeElement = node;
65
+ }
66
+
67
+ /* ReleaseElement --
68
+ * Releases the currently pressed element, if any.
69
+ */
70
+ static void ReleaseElement(ElementStateTracker *es)
71
+ {
72
+ if (!es->pressedElement)
73
+ return;
74
+
75
+ Ttk_ChangeElementState(
76
+ es->pressedElement, 0,TTK_STATE_PRESSED|TTK_STATE_ACTIVE);
77
+ es->pressedElement = 0;
78
+
79
+ /* Reactivate element under the mouse cursor:
80
+ */
81
+ if (es->activeElement)
82
+ Ttk_ChangeElementState(es->activeElement, TTK_STATE_ACTIVE,0);
83
+
84
+ TtkRedisplayWidget(es->corePtr);
85
+ }
86
+
87
+ /* PressElement --
88
+ * Presses the specified element.
89
+ */
90
+ static void PressElement(ElementStateTracker *es, Ttk_LayoutNode *node)
91
+ {
92
+ if (es->pressedElement) {
93
+ ReleaseElement(es);
94
+ }
95
+
96
+ if (node) {
97
+ Ttk_ChangeElementState(
98
+ node, TTK_STATE_PRESSED|TTK_STATE_ACTIVE, 0);
99
+ }
100
+
101
+ es->pressedElement = node;
102
+ TtkRedisplayWidget(es->corePtr);
103
+ }
104
+
105
+ /* ElementStateEventProc --
106
+ * Event handler for tracking element states.
107
+ */
108
+
109
+ static const unsigned ElementStateMask =
110
+ ButtonPressMask
111
+ | ButtonReleaseMask
112
+ | PointerMotionMask
113
+ | LeaveWindowMask
114
+ | EnterWindowMask
115
+ | StructureNotifyMask
116
+ ;
117
+
118
+ static void
119
+ ElementStateEventProc(ClientData clientData, XEvent *ev)
120
+ {
121
+ ElementStateTracker *es = (ElementStateTracker *)clientData;
122
+ Ttk_LayoutNode *node;
123
+
124
+ switch (ev->type)
125
+ {
126
+ case MotionNotify :
127
+ node = Ttk_LayoutIdentify(
128
+ es->corePtr->layout,ev->xmotion.x,ev->xmotion.y);
129
+ ActivateElement(es, node);
130
+ break;
131
+ case LeaveNotify:
132
+ ActivateElement(es, 0);
133
+ if (ev->xcrossing.mode == NotifyGrab)
134
+ PressElement(es, 0);
135
+ break;
136
+ case EnterNotify:
137
+ node = Ttk_LayoutIdentify(
138
+ es->corePtr->layout,ev->xcrossing.x,ev->xcrossing.y);
139
+ ActivateElement(es, node);
140
+ break;
141
+ case ButtonPress:
142
+ node = Ttk_LayoutIdentify(
143
+ es->corePtr->layout, ev->xbutton.x, ev->xbutton.y);
144
+ if (node)
145
+ PressElement(es, node);
146
+ break;
147
+ case ButtonRelease:
148
+ ReleaseElement(es);
149
+ break;
150
+ case DestroyNotify:
151
+ /* Unregister this event handler and free client data.
152
+ */
153
+ Tk_DeleteEventHandler(es->corePtr->tkwin,
154
+ ElementStateMask, ElementStateEventProc, es);
155
+ ckfree(clientData);
156
+ break;
157
+ }
158
+ }
159
+
160
+ /*
161
+ * TtkTrackElementState --
162
+ * Register an event handler to manage the 'pressed'
163
+ * and 'active' states of individual widget elements.
164
+ */
165
+
166
+ void TtkTrackElementState(WidgetCore *corePtr)
167
+ {
168
+ ElementStateTracker *es = (ElementStateTracker*)ckalloc(sizeof(*es));
169
+ es->corePtr = corePtr;
170
+ es->activeElement = es->pressedElement = 0;
171
+ Tk_CreateEventHandler(corePtr->tkwin,
172
+ ElementStateMask,ElementStateEventProc,es);
173
+ }
174
+