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,253 @@
1
+ /* scroll.c,v 1.9 2006/12/18 15:05:58 jenglish Exp
2
+ *
3
+ * Copyright 2004, Joe English
4
+ *
5
+ * Support routines for scrollable widgets.
6
+ *
7
+ * (This is sort of half-baked; needs some work)
8
+ *
9
+ * Scrollable interface:
10
+ *
11
+ * + 'first' is controlled by [xy]view widget command
12
+ * and other scrolling commands like 'see';
13
+ * + 'total' depends on widget contents;
14
+ * + 'last' depends on first, total, and widget size.
15
+ *
16
+ * Choreography (typical usage):
17
+ *
18
+ * 1. User adjusts scrollbar, scrollbar widget calls its -command
19
+ * 2. Scrollbar -command invokes the scrollee [xy]view widget method
20
+ * 3. TtkScrollviewCommand calls TtkScrollTo(), which updates
21
+ * 'first' and schedules a redisplay.
22
+ * 4. Once the scrollee knows 'total' and 'last' (typically in
23
+ * the LayoutProc), call TtkScrolled(h,first,last,total) to
24
+ * synchronize the scrollbar.
25
+ * 5. The scrollee -[xy]scrollcommand is called (in an idle callback)
26
+ * 6. Which calls the scrollbar 'set' method and redisplays the scrollbar.
27
+ *
28
+ * If the scrollee has internal scrolling (e.g., a 'see' method),
29
+ * it should TtkScrollTo() directly (step 2).
30
+ *
31
+ * If the widget value changes, it should call TtkScrolled() (step 4).
32
+ * (This usually happens automatically when the widget is redisplayed).
33
+ *
34
+ * If the scrollee's -[xy]scrollcommand changes, it should call
35
+ * TtkScrollbarUpdateRequired, which will invoke step (5) (@@@ Fix this)
36
+ */
37
+
38
+ #include <tk.h>
39
+ #include "tkTheme.h"
40
+ #include "widget.h"
41
+
42
+ /* Private data:
43
+ */
44
+ #define SCROLL_UPDATE_PENDING (0x1)
45
+ #define SCROLL_UPDATE_REQUIRED (0x2)
46
+
47
+ struct ScrollHandleRec
48
+ {
49
+ unsigned flags;
50
+ WidgetCore *corePtr;
51
+ Scrollable *scrollPtr;
52
+ };
53
+
54
+ /* TtkCreateScrollHandle --
55
+ * Initialize scroll handle.
56
+ */
57
+ ScrollHandle TtkCreateScrollHandle(WidgetCore *corePtr, Scrollable *scrollPtr)
58
+ {
59
+ ScrollHandle h = (ScrollHandle)ckalloc(sizeof(*h));
60
+
61
+ h->flags = 0;
62
+ h->corePtr = corePtr;
63
+ h->scrollPtr = scrollPtr;
64
+
65
+ scrollPtr->first = 0;
66
+ scrollPtr->last = 1;
67
+ scrollPtr->total = 1;
68
+ return h;
69
+ }
70
+
71
+ /* UpdateScrollbar --
72
+ * Call the -scrollcommand callback to sync the scrollbar.
73
+ * Returns: Whatever the -scrollcommand does.
74
+ */
75
+ static int UpdateScrollbar(Tcl_Interp *interp, ScrollHandle h)
76
+ {
77
+ Scrollable *s = h->scrollPtr;
78
+ WidgetCore *corePtr = h->corePtr;
79
+ char args[TCL_DOUBLE_SPACE * 2];
80
+ int code;
81
+
82
+ h->flags &= ~SCROLL_UPDATE_REQUIRED;
83
+
84
+ if (s->scrollCmd == NULL) {
85
+ return TCL_OK;
86
+ }
87
+
88
+ sprintf(args, " %g %g",
89
+ (double)s->first / s->total,
90
+ (double)s->last / s->total);
91
+
92
+ Tcl_Preserve(corePtr);
93
+ code = Tcl_VarEval(interp, s->scrollCmd, args, NULL);
94
+ if (WidgetDestroyed(corePtr)) {
95
+ Tcl_Release(corePtr);
96
+ return TCL_ERROR;
97
+ }
98
+ Tcl_Release(corePtr);
99
+
100
+ if (code != TCL_OK && !Tcl_InterpDeleted(interp)) {
101
+ /* Disable the -scrollcommand, add to stack trace:
102
+ */
103
+ ckfree(s->scrollCmd);
104
+ s->scrollCmd = 0;
105
+
106
+ Tcl_AddErrorInfo(interp, /* @@@ "horizontal" / "vertical" */
107
+ "\n (scrolling command executed by ");
108
+ Tcl_AddErrorInfo(interp, Tk_PathName(h->corePtr->tkwin));
109
+ Tcl_AddErrorInfo(interp, ")");
110
+ }
111
+ return code;
112
+ }
113
+
114
+ /* UpdateScrollbarBG --
115
+ * Idle handler to update the scrollbar.
116
+ */
117
+ static void UpdateScrollbarBG(ClientData clientData)
118
+ {
119
+ ScrollHandle h = (ScrollHandle)clientData;
120
+ Tcl_Interp *interp = h->corePtr->interp;
121
+ int code;
122
+
123
+ h->flags &= ~SCROLL_UPDATE_PENDING;
124
+ Tcl_Preserve((ClientData) interp);
125
+ code = UpdateScrollbar(interp, h);
126
+ if (code == TCL_ERROR && !Tcl_InterpDeleted(interp)) {
127
+ Tcl_BackgroundError(interp);
128
+ }
129
+ Tcl_Release((ClientData) interp);
130
+ }
131
+
132
+ /* TtkScrolled --
133
+ * Update scroll info, schedule scrollbar update.
134
+ */
135
+ void TtkScrolled(ScrollHandle h, int first, int last, int total)
136
+ {
137
+ Scrollable *s = h->scrollPtr;
138
+
139
+ /* Sanity-check inputs:
140
+ */
141
+ if (total <= 0) {
142
+ first = 0;
143
+ last = 1;
144
+ total = 1;
145
+ }
146
+
147
+ if (last > total) {
148
+ first -= (last - total);
149
+ if (first < 0) first = 0;
150
+ last = total;
151
+ }
152
+
153
+ if (s->first != first || s->last != last || s->total != total
154
+ || (h->flags & SCROLL_UPDATE_REQUIRED))
155
+ {
156
+ s->first = first;
157
+ s->last = last;
158
+ s->total = total;
159
+
160
+ if (!(h->flags & SCROLL_UPDATE_PENDING)) {
161
+ Tcl_DoWhenIdle(UpdateScrollbarBG, (ClientData)h);
162
+ h->flags |= SCROLL_UPDATE_PENDING;
163
+ }
164
+ }
165
+ }
166
+
167
+ /* TtkScrollbarUpdateRequired --
168
+ * Force a scrollbar update at the next call to TtkScrolled(),
169
+ * even if scroll parameters haven't changed (e.g., if
170
+ * -yscrollcommand has changed).
171
+ */
172
+
173
+ void TtkScrollbarUpdateRequired(ScrollHandle h)
174
+ {
175
+ h->flags |= SCROLL_UPDATE_REQUIRED;
176
+ }
177
+
178
+ /* TtkScrollviewCommand --
179
+ * Widget [xy]view command implementation.
180
+ *
181
+ * $w [xy]view -- return current view region
182
+ * $w [xy]view $index -- set topmost item
183
+ * $w [xy]view moveto $fraction
184
+ * $w [xy]view scroll $number $what -- scrollbar interface
185
+ */
186
+ int TtkScrollviewCommand(
187
+ Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], ScrollHandle h)
188
+ {
189
+ Scrollable *s = h->scrollPtr;
190
+ int newFirst = s->first;
191
+
192
+ if (objc == 2) {
193
+ char buf[TCL_DOUBLE_SPACE * 2];
194
+ sprintf(buf, "%g %g",
195
+ (double)s->first / s->total,
196
+ (double)s->last / s->total);
197
+ Tcl_SetResult(interp, buf, TCL_VOLATILE);
198
+ return TCL_OK;
199
+ } else if (objc == 3) {
200
+ if (Tcl_GetIntFromObj(interp, objv[2], &newFirst) != TCL_OK) {
201
+ return TCL_ERROR;
202
+ }
203
+ } else {
204
+ double fraction;
205
+ int count;
206
+
207
+ switch (Tk_GetScrollInfoObj(interp, objc, objv, &fraction, &count)) {
208
+ case TK_SCROLL_ERROR:
209
+ return TCL_ERROR;
210
+ case TK_SCROLL_MOVETO:
211
+ newFirst = (int) ((fraction * s->total) + 0.5);
212
+ break;
213
+ case TK_SCROLL_UNITS:
214
+ newFirst = s->first + count;
215
+ break;
216
+ case TK_SCROLL_PAGES: {
217
+ int perPage = s->last - s->first; /* @@@ */
218
+ newFirst = s->first + count * perPage;
219
+ break;
220
+ }
221
+ }
222
+ }
223
+
224
+ TtkScrollTo(h, newFirst);
225
+
226
+ return TCL_OK;
227
+ }
228
+
229
+ void TtkScrollTo(ScrollHandle h, int newFirst)
230
+ {
231
+ Scrollable *s = h->scrollPtr;
232
+
233
+ if (newFirst >= s->total)
234
+ newFirst = s->total - 1;
235
+ if (newFirst > s->first && s->last >= s->total) /* don't scroll past end */
236
+ newFirst = s->first;
237
+ if (newFirst < 0)
238
+ newFirst = 0;
239
+
240
+ if (newFirst != s->first) {
241
+ s->first = newFirst;
242
+ TtkRedisplayWidget(h->corePtr);
243
+ }
244
+ }
245
+
246
+ void TtkFreeScrollHandle(ScrollHandle h)
247
+ {
248
+ if (h->flags & SCROLL_UPDATE_PENDING) {
249
+ Tcl_CancelIdleCall(UpdateScrollbarBG, (ClientData)h);
250
+ }
251
+ ckfree((ClientData)h);
252
+ }
253
+
@@ -0,0 +1,346 @@
1
+ /* scrollbar.c,v 1.49 2007/10/25 06:42:47 jenglish Exp
2
+ * Copyright (c) 2003, Joe English
3
+ *
4
+ * ttk::scrollbar widget.
5
+ */
6
+
7
+ #include <tk.h>
8
+
9
+ #include "tkTheme.h"
10
+ #include "widget.h"
11
+
12
+ /*------------------------------------------------------------------------
13
+ * +++ Scrollbar widget record.
14
+ */
15
+ typedef struct
16
+ {
17
+ Tcl_Obj *commandObj;
18
+
19
+ int orient;
20
+ Tcl_Obj *orientObj;
21
+
22
+ double first; /* top fraction */
23
+ double last; /* bottom fraction */
24
+
25
+ Ttk_Box troughBox; /* trough parcel */
26
+ int minSize; /* minimum size of thumb */
27
+ } ScrollbarPart;
28
+
29
+ typedef struct
30
+ {
31
+ WidgetCore core;
32
+ ScrollbarPart scrollbar;
33
+ } Scrollbar;
34
+
35
+ static Tk_OptionSpec ScrollbarOptionSpecs[] =
36
+ {
37
+ {TK_OPTION_STRING, "-command", "command", "Command", "",
38
+ Tk_Offset(Scrollbar,scrollbar.commandObj), -1, 0,0,0},
39
+
40
+ {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "vertical",
41
+ Tk_Offset(Scrollbar,scrollbar.orientObj),
42
+ Tk_Offset(Scrollbar,scrollbar.orient),
43
+ 0,(ClientData)ttkOrientStrings,STYLE_CHANGED },
44
+
45
+ WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
46
+ };
47
+
48
+ /*------------------------------------------------------------------------
49
+ * +++ Widget hooks.
50
+ */
51
+
52
+ static int
53
+ ScrollbarInitialize(Tcl_Interp *interp, void *recordPtr)
54
+ {
55
+ Scrollbar *sb = recordPtr;
56
+ sb->scrollbar.first = 0.0;
57
+ sb->scrollbar.last = 1.0;
58
+
59
+ TtkTrackElementState(&sb->core);
60
+
61
+ return TCL_OK;
62
+ }
63
+
64
+ static Ttk_Layout ScrollbarGetLayout(
65
+ Tcl_Interp *interp, Ttk_Theme theme, void *recordPtr)
66
+ {
67
+ Scrollbar *sb = recordPtr;
68
+ return TtkWidgetGetOrientedLayout(
69
+ interp, theme, recordPtr, sb->scrollbar.orientObj);
70
+ }
71
+
72
+ /*
73
+ * ScrollbarDoLayout --
74
+ * Layout hook. Adjusts the position of the scrollbar thumb.
75
+ *
76
+ * Side effects:
77
+ * Sets sb->troughBox and sb->minSize.
78
+ */
79
+ static void ScrollbarDoLayout(void *recordPtr)
80
+ {
81
+ Scrollbar *sb = recordPtr;
82
+ WidgetCore *corePtr = &sb->core;
83
+ Ttk_LayoutNode *thumb;
84
+ Ttk_Box thumbBox;
85
+ int thumbWidth, thumbHeight;
86
+ double first, last, size;
87
+ int minSize;
88
+
89
+ /*
90
+ * Use generic layout manager to compute initial layout:
91
+ */
92
+ Ttk_PlaceLayout(corePtr->layout,corePtr->state,Ttk_WinBox(corePtr->tkwin));
93
+
94
+ /*
95
+ * Locate thumb element, extract parcel and requested minimum size:
96
+ */
97
+ thumb = Ttk_LayoutFindNode(corePtr->layout, "thumb");
98
+ if (!thumb) /* Something has gone wrong -- bail */
99
+ return;
100
+
101
+ sb->scrollbar.troughBox = thumbBox = Ttk_LayoutNodeParcel(thumb);
102
+ Ttk_LayoutNodeReqSize(
103
+ corePtr->layout, thumb, &thumbWidth,&thumbHeight);
104
+
105
+ /*
106
+ * Adjust thumb element parcel:
107
+ */
108
+ first = sb->scrollbar.first;
109
+ last = sb->scrollbar.last;
110
+
111
+ if (sb->scrollbar.orient == TTK_ORIENT_VERTICAL) {
112
+ minSize = thumbHeight;
113
+ size = thumbBox.height - minSize;
114
+ thumbBox.y += (int)(size * first);
115
+ thumbBox.height = (int)(size * last) + minSize - (int)(size * first);
116
+ } else {
117
+ minSize = thumbWidth;
118
+ size = thumbBox.width - minSize;
119
+ thumbBox.x += (int)(size * first);
120
+ thumbBox.width = (int)(size * last) + minSize - (int)(size * first);
121
+ }
122
+ sb->scrollbar.minSize = minSize;
123
+ Ttk_PlaceLayoutNode(corePtr->layout, thumb, thumbBox);
124
+ }
125
+
126
+ /*------------------------------------------------------------------------
127
+ * +++ Widget commands.
128
+ */
129
+
130
+ /* $sb set $first $last --
131
+ * Set the position of the scrollbar.
132
+ */
133
+ static int
134
+ ScrollbarSetCommand(
135
+ Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr)
136
+ {
137
+ Scrollbar *scrollbar = recordPtr;
138
+ Tcl_Obj *firstObj, *lastObj;
139
+ double first, last;
140
+
141
+ if (objc != 4) {
142
+ Tcl_WrongNumArgs(interp, 2, objv, "first last");
143
+ return TCL_ERROR;
144
+ }
145
+
146
+ firstObj = objv[2];
147
+ lastObj = objv[3];
148
+ if (Tcl_GetDoubleFromObj(interp, firstObj, &first) != TCL_OK
149
+ || Tcl_GetDoubleFromObj(interp, lastObj, &last) != TCL_OK)
150
+ return TCL_ERROR;
151
+
152
+ /* Range-checks:
153
+ */
154
+ if (first < 0.0) {
155
+ first = 0.0;
156
+ } else if (first > 1.0) {
157
+ first = 1.0;
158
+ }
159
+
160
+ if (last < first) {
161
+ last = first;
162
+ } else if (last > 1.0) {
163
+ last = 1.0;
164
+ }
165
+
166
+ /* ASSERT: 0.0 <= first <= last <= 1.0 */
167
+
168
+ scrollbar->scrollbar.first = first;
169
+ scrollbar->scrollbar.last = last;
170
+ if (first <= 0.0 && last >= 1.0) {
171
+ scrollbar->core.state |= TTK_STATE_DISABLED;
172
+ } else {
173
+ scrollbar->core.state &= ~TTK_STATE_DISABLED;
174
+ }
175
+
176
+ TtkRedisplayWidget(&scrollbar->core);
177
+
178
+ return TCL_OK;
179
+ }
180
+
181
+ /* $sb get --
182
+ * Returns the last thing passed to 'set'.
183
+ */
184
+ static int
185
+ ScrollbarGetCommand(
186
+ Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr)
187
+ {
188
+ Scrollbar *scrollbar = recordPtr;
189
+ Tcl_Obj *result[2];
190
+
191
+ if (objc != 2) {
192
+ Tcl_WrongNumArgs(interp, 2, objv, "");
193
+ return TCL_ERROR;
194
+ }
195
+
196
+ result[0] = Tcl_NewDoubleObj(scrollbar->scrollbar.first);
197
+ result[1] = Tcl_NewDoubleObj(scrollbar->scrollbar.last);
198
+ Tcl_SetObjResult(interp, Tcl_NewListObj(2, result));
199
+
200
+ return TCL_OK;
201
+ }
202
+
203
+ /* $sb delta $dx $dy --
204
+ * Returns the percentage change corresponding to a mouse movement
205
+ * of $dx, $dy.
206
+ */
207
+ static int
208
+ ScrollbarDeltaCommand(
209
+ Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr)
210
+ {
211
+ Scrollbar *sb = recordPtr;
212
+ double dx, dy;
213
+ double delta = 0.0;
214
+
215
+ if (objc != 4) {
216
+ Tcl_WrongNumArgs(interp, 2, objv, "dx dy");
217
+ return TCL_ERROR;
218
+ }
219
+
220
+ if (Tcl_GetDoubleFromObj(interp, objv[2], &dx) != TCL_OK
221
+ || Tcl_GetDoubleFromObj(interp, objv[3], &dy) != TCL_OK)
222
+ {
223
+ return TCL_ERROR;
224
+ }
225
+
226
+ delta = 0.0;
227
+ if (sb->scrollbar.orient == TTK_ORIENT_VERTICAL) {
228
+ int size = sb->scrollbar.troughBox.height - sb->scrollbar.minSize;
229
+ if (size > 0) {
230
+ delta = (double)dy / (double)size;
231
+ }
232
+ } else {
233
+ int size = sb->scrollbar.troughBox.width - sb->scrollbar.minSize;
234
+ if (size > 0) {
235
+ delta = (double)dx / (double)size;
236
+ }
237
+ }
238
+
239
+ Tcl_SetObjResult(interp, Tcl_NewDoubleObj(delta));
240
+ return TCL_OK;
241
+ }
242
+
243
+ /* $sb fraction $x $y --
244
+ * Returns a real number between 0 and 1 indicating where the
245
+ * point given by x and y lies in the trough area of the scrollbar.
246
+ */
247
+ static int
248
+ ScrollbarFractionCommand(
249
+ Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr)
250
+ {
251
+ Scrollbar *sb = recordPtr;
252
+ Ttk_Box b = sb->scrollbar.troughBox;
253
+ int minSize = sb->scrollbar.minSize;
254
+ double x, y;
255
+ double fraction = 0.0;
256
+
257
+ if (objc != 4) {
258
+ Tcl_WrongNumArgs(interp, 2, objv, "x y");
259
+ return TCL_ERROR;
260
+ }
261
+
262
+ if (Tcl_GetDoubleFromObj(interp, objv[2], &x) != TCL_OK
263
+ || Tcl_GetDoubleFromObj(interp, objv[3], &y) != TCL_OK)
264
+ {
265
+ return TCL_ERROR;
266
+ }
267
+
268
+ fraction = 0.0;
269
+ if (sb->scrollbar.orient == TTK_ORIENT_VERTICAL) {
270
+ if (b.height > minSize) {
271
+ fraction = (double)(y - b.y) / (double)(b.height - minSize);
272
+ }
273
+ } else {
274
+ if (b.width > minSize) {
275
+ fraction = (double)(x - b.x) / (double)(b.width - minSize);
276
+ }
277
+ }
278
+
279
+ Tcl_SetObjResult(interp, Tcl_NewDoubleObj(fraction));
280
+ return TCL_OK;
281
+ }
282
+
283
+ static WidgetCommandSpec ScrollbarCommands[] =
284
+ {
285
+ { "configure", TtkWidgetConfigureCommand },
286
+ { "cget", TtkWidgetCgetCommand },
287
+ { "delta", ScrollbarDeltaCommand },
288
+ { "fraction", ScrollbarFractionCommand },
289
+ { "get", ScrollbarGetCommand },
290
+ { "identify", TtkWidgetIdentifyCommand },
291
+ { "instate", TtkWidgetInstateCommand },
292
+ { "set", ScrollbarSetCommand },
293
+ { "state", TtkWidgetStateCommand },
294
+ { 0,0 }
295
+ };
296
+
297
+ /*------------------------------------------------------------------------
298
+ * +++ Widget specification.
299
+ */
300
+ static WidgetSpec ScrollbarWidgetSpec =
301
+ {
302
+ "TScrollbar", /* className */
303
+ sizeof(Scrollbar), /* recordSize */
304
+ ScrollbarOptionSpecs, /* optionSpecs */
305
+ ScrollbarCommands, /* subcommands */
306
+ ScrollbarInitialize, /* initializeProc */
307
+ TtkNullCleanup, /* cleanupProc */
308
+ TtkCoreConfigure, /* configureProc */
309
+ TtkNullPostConfigure, /* postConfigureProc */
310
+ ScrollbarGetLayout, /* getLayoutProc */
311
+ TtkWidgetSize, /* sizeProc */
312
+ ScrollbarDoLayout, /* layoutProc */
313
+ TtkWidgetDisplay /* displayProc */
314
+ };
315
+
316
+ TTK_BEGIN_LAYOUT(VerticalScrollbarLayout)
317
+ TTK_GROUP("Vertical.Scrollbar.trough", TTK_FILL_Y,
318
+ TTK_NODE("Vertical.Scrollbar.uparrow", TTK_PACK_TOP)
319
+ TTK_NODE("Vertical.Scrollbar.downarrow", TTK_PACK_BOTTOM)
320
+ TTK_NODE(
321
+ "Vertical.Scrollbar.thumb", TTK_PACK_TOP|TTK_EXPAND|TTK_FILL_BOTH))
322
+ TTK_END_LAYOUT
323
+
324
+ TTK_BEGIN_LAYOUT(HorizontalScrollbarLayout)
325
+ TTK_GROUP("Horizontal.Scrollbar.trough", TTK_FILL_X,
326
+ TTK_NODE("Horizontal.Scrollbar.leftarrow", TTK_PACK_LEFT)
327
+ TTK_NODE("Horizontal.Scrollbar.rightarrow", TTK_PACK_RIGHT)
328
+ TTK_NODE(
329
+ "Horizontal.Scrollbar.thumb", TTK_PACK_LEFT|TTK_EXPAND|TTK_FILL_BOTH))
330
+ TTK_END_LAYOUT
331
+
332
+ /*------------------------------------------------------------------------
333
+ * +++ Initialization.
334
+ */
335
+
336
+ void TtkScrollbar_Init(Tcl_Interp *interp)
337
+ {
338
+ Ttk_Theme theme = Ttk_GetDefaultTheme(interp);
339
+
340
+ Ttk_RegisterLayout(theme,"Vertical.TScrollbar",VerticalScrollbarLayout);
341
+ Ttk_RegisterLayout(theme,"Horizontal.TScrollbar",HorizontalScrollbarLayout);
342
+
343
+ RegisterWidget(interp, "ttk::scrollbar", &ScrollbarWidgetSpec);
344
+ }
345
+
346
+ /*EOF*/