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,1172 @@
1
+ /* altTheme.c,v 1.70 2007/11/08 01:39:25 jenglish Exp
2
+ *
3
+ * Copyright (c) 2003, Joe English
4
+ *
5
+ * Tk alternate theme, intended to match the MSUE and Gtk's (old) default theme
6
+ */
7
+
8
+ #include <math.h>
9
+ #include <string.h>
10
+
11
+ #include <tk.h>
12
+ #include <X11/Xlib.h>
13
+ #include <X11/Xutil.h>
14
+ #include "tkTheme.h"
15
+
16
+ #include "gunk.h"
17
+
18
+ #if defined(WIN32)
19
+ static const int WIN32_XDRAWLINE_HACK = 1;
20
+ #else
21
+ static const int WIN32_XDRAWLINE_HACK = 0;
22
+ #endif
23
+
24
+ #define BORDERWIDTH 2
25
+ #define SCROLLBAR_WIDTH 14
26
+ #define MIN_THUMB_SIZE 8
27
+
28
+ #ifndef STRINGIFY
29
+ #define StR(x) #x
30
+ #define STRINGIFY(x) StR(x)
31
+ #endif
32
+
33
+ /*
34
+ *----------------------------------------------------------------------
35
+ *
36
+ * Helper routines for border drawing:
37
+ *
38
+ * NOTE: MSUE specifies a slightly different arrangement
39
+ * for button borders than for other elements; "shadowColors"
40
+ * is for button borders.
41
+ *
42
+ * Please excuse the gross misspelling "LITE" for "LIGHT",
43
+ * but it makes things line up nicer.
44
+ */
45
+
46
+ enum BorderColor { FLAT = 1, LITE = 2, DARK = 3, BRDR = 4 };
47
+
48
+ /* top-left outer, top-left inner, bottom-right inner, bottom-right outer */
49
+ static int shadowColors[6][4] =
50
+ {
51
+ { FLAT, FLAT, FLAT, FLAT }, /* TK_RELIEF_FLAT = 0*/
52
+ { DARK, LITE, DARK, LITE }, /* TK_RELIEF_GROOVE = 1*/
53
+ { LITE, FLAT, DARK, BRDR }, /* TK_RELIEF_RAISED = 2*/
54
+ { LITE, DARK, LITE, DARK }, /* TK_RELIEF_RIDGE = 3*/
55
+ { BRDR, BRDR, BRDR, BRDR }, /* TK_RELIEF_SOLID = 4*/
56
+ { BRDR, DARK, FLAT, LITE } /* TK_RELIEF_SUNKEN = 5*/
57
+ };
58
+
59
+ /* top-left, bottom-right */
60
+ static int thinShadowColors[6][4] =
61
+ {
62
+ { FLAT, FLAT }, /* TK_RELIEF_FLAT = 0*/
63
+ { DARK, LITE }, /* TK_RELIEF_GROOVE = 1*/
64
+ { LITE, DARK }, /* TK_RELIEF_RAISED = 2*/
65
+ { LITE, DARK }, /* TK_RELIEF_RIDGE = 3*/
66
+ { BRDR, BRDR }, /* TK_RELIEF_SOLID = 4*/
67
+ { DARK, LITE } /* TK_RELIEF_SUNKEN = 5*/
68
+ };
69
+
70
+ static void DrawCorner(
71
+ Tk_Window tkwin,
72
+ Drawable d,
73
+ Tk_3DBorder border, /* get most GCs from here... */
74
+ GC borderGC, /* "window border" color GC */
75
+ int x,int y, int width,int height, /* where to draw */
76
+ int corner, /* 0 => top left; 1 => bottom right */
77
+ enum BorderColor color)
78
+ {
79
+ XPoint points[3];
80
+ GC gc;
81
+
82
+ --width; --height;
83
+ points[0].x = x; points[0].y = y+height;
84
+ points[1].x = x+width*corner; points[1].y = y+height*corner;
85
+ points[2].x = x+width; points[2].y = y;
86
+
87
+ if (color == BRDR)
88
+ gc = borderGC;
89
+ else
90
+ gc = Tk_3DBorderGC(tkwin, border, (int)color);
91
+
92
+ XDrawLines(Tk_Display(tkwin), d, gc, points, 3, CoordModeOrigin);
93
+ }
94
+
95
+ static void DrawBorder(
96
+ Tk_Window tkwin, Drawable d, Tk_3DBorder border, XColor *borderColor,
97
+ Ttk_Box b, int borderWidth, int relief)
98
+ {
99
+ GC borderGC = Tk_GCForColor(borderColor, d);
100
+
101
+ switch (borderWidth) {
102
+ case 2: /* "thick" border */
103
+ DrawCorner(tkwin, d, border, borderGC,
104
+ b.x, b.y, b.width, b.height, 0,shadowColors[relief][0]);
105
+ DrawCorner(tkwin, d, border, borderGC,
106
+ b.x+1, b.y+1, b.width-2, b.height-2, 0,shadowColors[relief][1]);
107
+ DrawCorner(tkwin, d, border, borderGC,
108
+ b.x+1, b.y+1, b.width-2, b.height-2, 1,shadowColors[relief][2]);
109
+ DrawCorner(tkwin, d, border, borderGC,
110
+ b.x, b.y, b.width, b.height, 1,shadowColors[relief][3]);
111
+ break;
112
+ case 1: /* "thin" border */
113
+ DrawCorner(tkwin, d, border, borderGC,
114
+ b.x, b.y, b.width, b.height, 0, thinShadowColors[relief][0]);
115
+ DrawCorner(tkwin, d, border, borderGC,
116
+ b.x, b.y, b.width, b.height, 1, thinShadowColors[relief][1]);
117
+ break;
118
+ case 0: /* no border -- do nothing */
119
+ break;
120
+ default: /* Fall back to Motif-style borders: */
121
+ Tk_Draw3DRectangle(tkwin, d, border,
122
+ b.x, b.y, b.width, b.height, borderWidth,relief);
123
+ break;
124
+ }
125
+ }
126
+
127
+ /* Alternate shadow colors for entry fields:
128
+ * NOTE: FLAT color is normally white, and the LITE color is a darker shade.
129
+ */
130
+ static int fieldShadowColors[4] = { DARK, BRDR, LITE, FLAT };
131
+
132
+ static void DrawFieldBorder(
133
+ Tk_Window tkwin, Drawable d, Tk_3DBorder border, XColor *borderColor,
134
+ Ttk_Box b)
135
+ {
136
+ GC borderGC = Tk_GCForColor(borderColor, d);
137
+ DrawCorner(tkwin, d, border, borderGC,
138
+ b.x, b.y, b.width, b.height, 0,fieldShadowColors[0]);
139
+ DrawCorner(tkwin, d, border, borderGC,
140
+ b.x+1, b.y+1, b.width-2, b.height-2, 0,fieldShadowColors[1]);
141
+ DrawCorner(tkwin, d, border, borderGC,
142
+ b.x+1, b.y+1, b.width-2, b.height-2, 1,fieldShadowColors[2]);
143
+ DrawCorner(tkwin, d, border, borderGC,
144
+ b.x, b.y, b.width, b.height, 1,fieldShadowColors[3]);
145
+ return;
146
+ }
147
+
148
+ /*
149
+ * ArrowPoints --
150
+ * Compute points of arrow polygon.
151
+ */
152
+ static void ArrowPoints(Ttk_Box b, ArrowDirection dir, XPoint points[4])
153
+ {
154
+ int cx, cy, h;
155
+
156
+ switch (dir) {
157
+ case ARROW_UP:
158
+ h = (b.width - 1)/2;
159
+ cx = b.x + h;
160
+ cy = b.y;
161
+ if (b.height <= h) h = b.height - 1;
162
+ points[0].x = cx; points[0].y = cy;
163
+ points[1].x = cx - h; points[1].y = cy + h;
164
+ points[2].x = cx + h; points[2].y = cy + h;
165
+ break;
166
+ case ARROW_DOWN:
167
+ h = (b.width - 1)/2;
168
+ cx = b.x + h;
169
+ cy = b.y + b.height - 1;
170
+ if (b.height <= h) h = b.height - 1;
171
+ points[0].x = cx; points[0].y = cy;
172
+ points[1].x = cx - h; points[1].y = cy - h;
173
+ points[2].x = cx + h; points[2].y = cy - h;
174
+ break;
175
+ case ARROW_LEFT:
176
+ h = (b.height - 1)/2;
177
+ cx = b.x;
178
+ cy = b.y + h;
179
+ if (b.width <= h) h = b.width - 1;
180
+ points[0].x = cx; points[0].y = cy;
181
+ points[1].x = cx + h; points[1].y = cy - h;
182
+ points[2].x = cx + h; points[2].y = cy + h;
183
+ break;
184
+ case ARROW_RIGHT:
185
+ h = (b.height - 1)/2;
186
+ cx = b.x + b.width - 1;
187
+ cy = b.y + h;
188
+ if (b.width <= h) h = b.width - 1;
189
+ points[0].x = cx; points[0].y = cy;
190
+ points[1].x = cx - h; points[1].y = cy - h;
191
+ points[2].x = cx - h; points[2].y = cy + h;
192
+ break;
193
+ }
194
+
195
+ points[3].x = points[0].x;
196
+ points[3].y = points[0].y;
197
+ }
198
+
199
+ /*public*/
200
+ void TtkArrowSize(int h, ArrowDirection dir, int *widthPtr, int *heightPtr)
201
+ {
202
+ switch (dir) {
203
+ case ARROW_UP:
204
+ case ARROW_DOWN: *widthPtr = 2*h+1; *heightPtr = h+1; break;
205
+ case ARROW_LEFT:
206
+ case ARROW_RIGHT: *widthPtr = h+1; *heightPtr = 2*h+1;
207
+ }
208
+ }
209
+
210
+ /*
211
+ * TtkDrawArrow, TtkFillArrow --
212
+ * Draw an arrow in the indicated direction inside the specified box.
213
+ */
214
+ /*public*/
215
+ void TtkFillArrow(
216
+ Display *display, Drawable d, GC gc, Ttk_Box b, ArrowDirection dir)
217
+ {
218
+ XPoint points[4];
219
+ ArrowPoints(b, dir, points);
220
+ XFillPolygon(display, d, gc, points, 3, Convex, CoordModeOrigin);
221
+ XDrawLines(display, d, gc, points, 4, CoordModeOrigin);
222
+ }
223
+
224
+ /*public*/
225
+ void TtkDrawArrow(
226
+ Display *display, Drawable d, GC gc, Ttk_Box b, ArrowDirection dir)
227
+ {
228
+ XPoint points[4];
229
+ ArrowPoints(b, dir, points);
230
+ XDrawLines(display, d, gc, points, 4, CoordModeOrigin);
231
+ }
232
+
233
+ /*
234
+ *----------------------------------------------------------------------
235
+ * +++ Border element implementation.
236
+ *
237
+ * This border consists of (from outside-in):
238
+ *
239
+ * + a 1-pixel thick default indicator (defaultable widgets only)
240
+ * + 1- or 2- pixel shaded border (controlled by -background and -relief)
241
+ * + 1 pixel padding (???)
242
+ */
243
+
244
+ typedef struct
245
+ {
246
+ Tcl_Obj *borderObj;
247
+ Tcl_Obj *borderColorObj; /* Extra border color */
248
+ Tcl_Obj *borderWidthObj;
249
+ Tcl_Obj *reliefObj;
250
+ Tcl_Obj *defaultStateObj; /* for buttons */
251
+ } BorderElement;
252
+
253
+ static Ttk_ElementOptionSpec BorderElementOptions[] =
254
+ {
255
+ { "-background", TK_OPTION_BORDER, Tk_Offset(BorderElement,borderObj),
256
+ DEFAULT_BACKGROUND },
257
+ { "-bordercolor",TK_OPTION_COLOR,
258
+ Tk_Offset(BorderElement,borderColorObj), "black" },
259
+ { "-default", TK_OPTION_ANY, Tk_Offset(BorderElement,defaultStateObj),
260
+ "disabled" },
261
+ { "-borderwidth",TK_OPTION_PIXELS,Tk_Offset(BorderElement,borderWidthObj),
262
+ STRINGIFY(BORDERWIDTH) },
263
+ { "-relief", TK_OPTION_RELIEF, Tk_Offset(BorderElement,reliefObj),
264
+ "flat" },
265
+ {NULL}
266
+ };
267
+
268
+ static void BorderElementSize(
269
+ void *clientData, void *elementRecord, Tk_Window tkwin,
270
+ int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
271
+ {
272
+ BorderElement *bd = elementRecord;
273
+ int borderWidth = 0;
274
+ int defaultState = TTK_BUTTON_DEFAULT_DISABLED;
275
+
276
+ Tcl_GetIntFromObj(NULL, bd->borderWidthObj, &borderWidth);
277
+ Ttk_GetButtonDefaultStateFromObj(NULL, bd->defaultStateObj, &defaultState);
278
+
279
+ if (defaultState != TTK_BUTTON_DEFAULT_DISABLED) {
280
+ ++borderWidth;
281
+ }
282
+
283
+ *paddingPtr = Ttk_UniformPadding((short)borderWidth);
284
+ }
285
+
286
+ static void BorderElementDraw(
287
+ void *clientData, void *elementRecord,
288
+ Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state)
289
+ {
290
+ BorderElement *bd = elementRecord;
291
+ Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, bd->borderObj);
292
+ XColor *borderColor = Tk_GetColorFromObj(tkwin, bd->borderColorObj);
293
+ int borderWidth = 2;
294
+ int relief = TK_RELIEF_FLAT;
295
+ int defaultState = TTK_BUTTON_DEFAULT_DISABLED;
296
+
297
+ /*
298
+ * Get option values.
299
+ */
300
+ Tcl_GetIntFromObj(NULL, bd->borderWidthObj, &borderWidth);
301
+ Tk_GetReliefFromObj(NULL, bd->reliefObj, &relief);
302
+ Ttk_GetButtonDefaultStateFromObj(NULL, bd->defaultStateObj, &defaultState);
303
+
304
+ if (defaultState == TTK_BUTTON_DEFAULT_ACTIVE) {
305
+ GC gc = Tk_GCForColor(borderColor, d);
306
+ XDrawRectangle(Tk_Display(tkwin), d, gc,
307
+ b.x, b.y, b.width-1, b.height-1);
308
+ }
309
+ if (defaultState != TTK_BUTTON_DEFAULT_DISABLED) {
310
+ /* Space for default ring: */
311
+ b = Ttk_PadBox(b, Ttk_UniformPadding(1));
312
+ }
313
+
314
+ DrawBorder(tkwin, d, border, borderColor, b, borderWidth, relief);
315
+ }
316
+
317
+ static Ttk_ElementSpec BorderElementSpec =
318
+ {
319
+ TK_STYLE_VERSION_2,
320
+ sizeof(BorderElement),
321
+ BorderElementOptions,
322
+ BorderElementSize,
323
+ BorderElementDraw
324
+ };
325
+
326
+ /*----------------------------------------------------------------------
327
+ * +++ Field element:
328
+ * Used for editable fields.
329
+ */
330
+ typedef struct
331
+ {
332
+ Tcl_Obj *borderObj;
333
+ Tcl_Obj *borderColorObj; /* Extra border color */
334
+ } FieldElement;
335
+
336
+ static Ttk_ElementOptionSpec FieldElementOptions[] =
337
+ {
338
+ { "-fieldbackground", TK_OPTION_BORDER, Tk_Offset(FieldElement,borderObj),
339
+ "white" },
340
+ { "-bordercolor",TK_OPTION_COLOR, Tk_Offset(FieldElement,borderColorObj),
341
+ "black" },
342
+ {NULL}
343
+ };
344
+
345
+ static void FieldElementSize(
346
+ void *clientData, void *elementRecord, Tk_Window tkwin,
347
+ int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
348
+ {
349
+ *paddingPtr = Ttk_UniformPadding(2);
350
+ }
351
+
352
+ static void FieldElementDraw(
353
+ void *clientData, void *elementRecord, Tk_Window tkwin,
354
+ Drawable d, Ttk_Box b, unsigned int state)
355
+ {
356
+ FieldElement *field = elementRecord;
357
+ Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, field->borderObj);
358
+ XColor *borderColor = Tk_GetColorFromObj(tkwin, field->borderColorObj);
359
+
360
+ Tk_Fill3DRectangle(
361
+ tkwin, d, border, b.x, b.y, b.width, b.height, 0, TK_RELIEF_SUNKEN);
362
+ DrawFieldBorder(tkwin, d, border, borderColor, b);
363
+ }
364
+
365
+ static Ttk_ElementSpec FieldElementSpec =
366
+ {
367
+ TK_STYLE_VERSION_2,
368
+ sizeof(FieldElement),
369
+ FieldElementOptions,
370
+ FieldElementSize,
371
+ FieldElementDraw
372
+ };
373
+
374
+ /*------------------------------------------------------------------------
375
+ * Indicators --
376
+ *
377
+ * Code derived (probably incorrectly) from TIP 109 implementation,
378
+ * unix/tkUnixButton.c r 1.15.
379
+ */
380
+
381
+ /*
382
+ * Indicator bitmap descriptor:
383
+ */
384
+ typedef struct
385
+ {
386
+ int width; /* Width of each image */
387
+ int height; /* Height of each image */
388
+ int nimages; /* #images / row */
389
+ char **pixels; /* array[height] of char[width*nimage] */
390
+ Ttk_StateTable *map;/* used to look up image index by state */
391
+ } IndicatorSpec;
392
+
393
+ #if 0
394
+ /*XPM*/
395
+ static char *button_images[] = {
396
+ /* width height ncolors chars_per_pixel */
397
+ "52 26 7 1",
398
+ /* colors */
399
+ "A c #808000000000 s background",
400
+ "B c #000080800000 s background",
401
+ "C c #808080800000 s highlight",
402
+ "D c #000000008080 s select",
403
+ "E c #808000008080 s shadow",
404
+ "F c #000080808080 s background",
405
+ "G c #000000000000 s indicator",
406
+ "H c #000080800000 s disabled",
407
+ };
408
+ #endif
409
+
410
+ static Ttk_StateTable checkbutton_states[] =
411
+ {
412
+ { 0, 0, TTK_STATE_SELECTED|TTK_STATE_DISABLED },
413
+ { 1, TTK_STATE_SELECTED, TTK_STATE_DISABLED },
414
+ { 2, TTK_STATE_DISABLED, TTK_STATE_SELECTED },
415
+ { 3, TTK_STATE_SELECTED|TTK_STATE_DISABLED, 0 },
416
+ { 0, 0, 0 }
417
+ };
418
+ static char *checkbutton_pixels[] = {
419
+ "AAAAAAAAAAAABAAAAAAAAAAAABAAAAAAAAAAAABAAAAAAAAAAAAB",
420
+ "AEEEEEEEEEECBAEEEEEEEEEECBAEEEEEEEEEECBAEEEEEEEEEECB",
421
+ "AEDDDDDDDDDCBAEDDDDDDDDDCBAEFFFFFFFFFCBAEFFFFFFFFFCB",
422
+ "AEDDDDDDDDDCBAEDDDDDDDGDCBAEFFFFFFFFFCBAEFFFFFFFHFCB",
423
+ "AEDDDDDDDDDCBAEDDDDDDGGDCBAEFFFFFFFFFCBAEFFFFFFHHFCB",
424
+ "AEDDDDDDDDDCBAEDGDDDGGGDCBAEFFFFFFFFFCBAEFHFFFHHHFCB",
425
+ "AEDDDDDDDDDCBAEDGGDGGGDDCBAEFFFFFFFFFCBAEFHHFHHHFFCB",
426
+ "AEDDDDDDDDDCBAEDGGGGGDDDCBAEFFFFFFFFFCBAEFHHHHHFFFCB",
427
+ "AEDDDDDDDDDCBAEDDGGGDDDDCBAEFFFFFFFFFCBAEFFHHHFFFFCB",
428
+ "AEDDDDDDDDDCBAEDDDGDDDDDCBAEFFFFFFFFFCBAEFFFHFFFFFCB",
429
+ "AEDDDDDDDDDCBAEDDDDDDDDDCBAEFFFFFFFFFCBAEFFFFFFFFFCB",
430
+ "ACCCCCCCCCCCBACCCCCCCCCCCBACCCCCCCCCCCBACCCCCCCCCCCB",
431
+ "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB",
432
+ };
433
+
434
+ static IndicatorSpec checkbutton_spec =
435
+ {
436
+ 13, 13, 4, /* width, height, nimages */
437
+ checkbutton_pixels,
438
+ checkbutton_states
439
+ };
440
+
441
+ static Ttk_StateTable radiobutton_states[] =
442
+ {
443
+ { 0, 0, TTK_STATE_SELECTED|TTK_STATE_DISABLED },
444
+ { 1, TTK_STATE_SELECTED, TTK_STATE_DISABLED },
445
+ { 2, TTK_STATE_DISABLED, TTK_STATE_SELECTED },
446
+ { 3, TTK_STATE_SELECTED|TTK_STATE_DISABLED, 0 },
447
+ { 0, 0, 0 }
448
+ };
449
+
450
+ static char *radiobutton_pixels[] = {
451
+ "FFFFAAAAFFFFFFFFFAAAAFFFFFFFFFAAAAFFFFFFFFFAAAAFFFFF",
452
+ "FFAAEEEEAAFFFFFAAEEEEAAFFFFFAAEEEEAAFFFFFAAEEEEAAFFF",
453
+ "FAEEDDDDECBFFFAEEDDDDECBFFFAEEFFFFECBFFFAEEFFFFECBFF",
454
+ "FAEDDDDDDCBFFFAEDDDDDDCBFFFAEFFFFFFCBFFFAEFFFFFFCBFF",
455
+ "AEDDDDDDDDCBFAEDDDGGDDDCBFAEFFFFFFFFCBFAEFFFHHFFFCBF",
456
+ "AEDDDDDDDDCBFAEDDGGGGDDCBFAEFFFFFFFFCBFAEFFHHHHFFCBF",
457
+ "AEDDDDDDDDCBFAEDDGGGGDDCBFAEFFFFFFFFCBFAEFFHHHHFFCBF",
458
+ "AEDDDDDDDDCBFAEDDDGGDDDCBFAEFFFFFFFFCBFAEFFFHHFFFCBF",
459
+ "FAEDDDDDDCBFFFAEDDDDDDCBFFFAEFFFFFFCBFFFAEFFFFFFCBFF",
460
+ "FACCDDDDCCBFFFACCDDDDCCBFFFACCFFFFCCBFFFACCFFFFCCBFF",
461
+ "FFBBCCCCBBFFFFFBBCCCCBBFFFFFBBCCCCBBFFFFFBBCCCCBBFFF",
462
+ "FFFFBBBBFFFFFFFFFBBBBFFFFFFFFFBBBBFFFFFFFFFBBBBFFFFF",
463
+ "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
464
+ };
465
+
466
+ static IndicatorSpec radiobutton_spec =
467
+ {
468
+ 13, 13, 4, /* width, height, nimages */
469
+ radiobutton_pixels,
470
+ radiobutton_states
471
+ };
472
+
473
+ typedef struct
474
+ {
475
+ Tcl_Obj *backgroundObj;
476
+ Tcl_Obj *foregroundObj;
477
+ Tcl_Obj *colorObj;
478
+ Tcl_Obj *lightColorObj;
479
+ Tcl_Obj *shadeColorObj;
480
+ Tcl_Obj *marginObj;
481
+ } IndicatorElement;
482
+
483
+ static Ttk_ElementOptionSpec IndicatorElementOptions[] =
484
+ {
485
+ { "-background", TK_OPTION_BORDER,
486
+ Tk_Offset(IndicatorElement,backgroundObj), DEFAULT_BACKGROUND },
487
+ { "-foreground", TK_OPTION_COLOR,
488
+ Tk_Offset(IndicatorElement,foregroundObj), DEFAULT_FOREGROUND },
489
+ { "-indicatorcolor", TK_OPTION_BORDER,
490
+ Tk_Offset(IndicatorElement,colorObj), "#FFFFFF" },
491
+ { "-lightcolor", TK_OPTION_COLOR,
492
+ Tk_Offset(IndicatorElement,lightColorObj), "#DDDDDD" },
493
+ { "-shadecolor", TK_OPTION_COLOR,
494
+ Tk_Offset(IndicatorElement,shadeColorObj), "#888888" },
495
+ { "-indicatormargin", TK_OPTION_STRING,
496
+ Tk_Offset(IndicatorElement,marginObj), "0 2 4 2" },
497
+ {NULL}
498
+ };
499
+
500
+ static void IndicatorElementSize(
501
+ void *clientData, void *elementRecord, Tk_Window tkwin,
502
+ int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
503
+ {
504
+ IndicatorSpec *spec = clientData;
505
+ IndicatorElement *indicator = elementRecord;
506
+ Ttk_Padding margins;
507
+ Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins);
508
+ *widthPtr = spec->width + Ttk_PaddingWidth(margins);
509
+ *heightPtr = spec->height + Ttk_PaddingHeight(margins);
510
+ }
511
+
512
+ static void IndicatorElementDraw(
513
+ void *clientData, void *elementRecord, Tk_Window tkwin,
514
+ Drawable d, Ttk_Box b, unsigned int state)
515
+ {
516
+ IndicatorSpec *spec = clientData;
517
+ IndicatorElement *indicator = elementRecord;
518
+ Display *display = Tk_Display(tkwin);
519
+ Tk_3DBorder bgBorder;
520
+ Ttk_Padding padding;
521
+ XColor *fgColor, *bgColor, *lightColor, *shadeColor, *selectColor;
522
+
523
+ int index, ix, iy;
524
+ XGCValues gcValues;
525
+ GC copyGC;
526
+ unsigned long imgColors[8];
527
+ XImage *img;
528
+
529
+ Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &padding);
530
+ b = Ttk_PadBox(b, padding);
531
+
532
+ if ( b.x < 0
533
+ || b.y < 0
534
+ || Tk_Width(tkwin) < b.x + spec->width
535
+ || Tk_Height(tkwin) < b.y + spec->height)
536
+ {
537
+ /* Oops! not enough room to display the image.
538
+ * Don't draw anything.
539
+ */
540
+ return;
541
+ }
542
+
543
+ /*
544
+ * Fill in imgColors palette:
545
+ *
546
+ * (SHOULD: take light and shade colors from the border object,
547
+ * but Tk doesn't provide easy access to these in the public API.)
548
+ */
549
+ fgColor = Tk_GetColorFromObj(tkwin, indicator->foregroundObj);
550
+ bgBorder = Tk_Get3DBorderFromObj(tkwin, indicator->backgroundObj);
551
+ bgColor = Tk_3DBorderColor(bgBorder);
552
+ lightColor = Tk_GetColorFromObj(tkwin, indicator->lightColorObj);
553
+ shadeColor = Tk_GetColorFromObj(tkwin, indicator->shadeColorObj);
554
+ selectColor = Tk_GetColorFromObj(tkwin, indicator->colorObj);
555
+
556
+ imgColors[0 /*A*/] = bgColor->pixel;
557
+ imgColors[1 /*B*/] = bgColor->pixel;
558
+ imgColors[2 /*C*/] = lightColor->pixel;
559
+ imgColors[3 /*D*/] = selectColor->pixel;
560
+ imgColors[4 /*E*/] = shadeColor->pixel;
561
+ imgColors[5 /*F*/] = bgColor->pixel;
562
+ imgColors[6 /*G*/] = fgColor->pixel;
563
+ imgColors[7 /*H*/] = selectColor->pixel;
564
+
565
+ /*
566
+ * Create a scratch buffer to store the image:
567
+ */
568
+ img = XGetImage(display,d, 0, 0,
569
+ (unsigned int)spec->width, (unsigned int)spec->height,
570
+ AllPlanes, ZPixmap);
571
+ if (img == NULL)
572
+ return;
573
+
574
+ /*
575
+ * Create the image, painting it into an XImage one pixel at a time.
576
+ */
577
+ index = Ttk_StateTableLookup(spec->map, state);
578
+ for (iy=0 ; iy<spec->height ; iy++) {
579
+ for (ix=0 ; ix<spec->width ; ix++) {
580
+ XPutPixel(img, ix, iy,
581
+ imgColors[spec->pixels[iy][index*spec->width+ix] - 'A'] );
582
+ }
583
+ }
584
+
585
+ /*
586
+ * Copy onto our target drawable surface.
587
+ */
588
+ memset(&gcValues, 0, sizeof(gcValues));
589
+ copyGC = Tk_GetGC(tkwin, 0, &gcValues);
590
+
591
+ TkPutImage(NULL, 0, display, d, copyGC, img, 0, 0, b.x, b.y,
592
+ spec->width, spec->height);
593
+
594
+ /*
595
+ * Tidy up.
596
+ */
597
+ Tk_FreeGC(display, copyGC);
598
+ XDestroyImage(img);
599
+ }
600
+
601
+ static Ttk_ElementSpec IndicatorElementSpec =
602
+ {
603
+ TK_STYLE_VERSION_2,
604
+ sizeof(IndicatorElement),
605
+ IndicatorElementOptions,
606
+ IndicatorElementSize,
607
+ IndicatorElementDraw
608
+ };
609
+
610
+ /*----------------------------------------------------------------------
611
+ * +++ Arrow element(s).
612
+ *
613
+ * Draws a solid triangle, inside a box.
614
+ * clientData is an enum ArrowDirection pointer.
615
+ */
616
+
617
+ static int ArrowElements[] = { ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT };
618
+ typedef struct
619
+ {
620
+ Tcl_Obj *sizeObj;
621
+ Tcl_Obj *borderObj;
622
+ Tcl_Obj *borderColorObj; /* Extra color for borders */
623
+ Tcl_Obj *reliefObj;
624
+ Tcl_Obj *colorObj; /* Arrow color */
625
+ } ArrowElement;
626
+
627
+ static Ttk_ElementOptionSpec ArrowElementOptions[] =
628
+ {
629
+ { "-arrowsize", TK_OPTION_PIXELS,
630
+ Tk_Offset(ArrowElement,sizeObj), STRINGIFY(SCROLLBAR_WIDTH) },
631
+ { "-background", TK_OPTION_BORDER,
632
+ Tk_Offset(ArrowElement,borderObj), DEFAULT_BACKGROUND },
633
+ { "-bordercolor", TK_OPTION_COLOR,
634
+ Tk_Offset(ArrowElement,borderColorObj), "black" },
635
+ { "-relief", TK_OPTION_RELIEF,
636
+ Tk_Offset(ArrowElement,reliefObj),"raised"},
637
+ { "-arrowcolor", TK_OPTION_COLOR,
638
+ Tk_Offset(ArrowElement,colorObj),"black"},
639
+ { NULL }
640
+ };
641
+
642
+ /*
643
+ * Note asymmetric padding:
644
+ * top/left padding is 1 less than bottom/right,
645
+ * since in this theme 2-pixel borders are asymmetric.
646
+ */
647
+ static Ttk_Padding ArrowPadding = { 3,3,4,4 };
648
+
649
+ static void ArrowElementSize(
650
+ void *clientData, void *elementRecord, Tk_Window tkwin,
651
+ int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
652
+ {
653
+ ArrowElement *arrow = elementRecord;
654
+ int direction = *(int *)clientData;
655
+ int width = SCROLLBAR_WIDTH;
656
+
657
+ Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &width);
658
+ width -= Ttk_PaddingWidth(ArrowPadding);
659
+ TtkArrowSize(width/2, direction, widthPtr, heightPtr);
660
+ *widthPtr += Ttk_PaddingWidth(ArrowPadding);
661
+ *heightPtr += Ttk_PaddingHeight(ArrowPadding);
662
+ }
663
+
664
+ static void ArrowElementDraw(
665
+ void *clientData, void *elementRecord, Tk_Window tkwin,
666
+ Drawable d, Ttk_Box b, unsigned int state)
667
+ {
668
+ int direction = *(int *)clientData;
669
+ ArrowElement *arrow = elementRecord;
670
+ Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, arrow->borderObj);
671
+ XColor *borderColor = Tk_GetColorFromObj(tkwin, arrow->borderColorObj);
672
+ XColor *arrowColor = Tk_GetColorFromObj(tkwin, arrow->colorObj);
673
+ int relief = TK_RELIEF_RAISED;
674
+ int borderWidth = 2;
675
+
676
+ Tk_GetReliefFromObj(NULL, arrow->reliefObj, &relief);
677
+
678
+ Tk_Fill3DRectangle(
679
+ tkwin, d, border, b.x, b.y, b.width, b.height, 0, TK_RELIEF_FLAT);
680
+ DrawBorder(tkwin,d,border,borderColor,b,borderWidth,relief);
681
+
682
+ TtkFillArrow(Tk_Display(tkwin), d, Tk_GCForColor(arrowColor, d),
683
+ Ttk_PadBox(b, ArrowPadding), direction);
684
+ }
685
+
686
+ static Ttk_ElementSpec ArrowElementSpec =
687
+ {
688
+ TK_STYLE_VERSION_2,
689
+ sizeof(ArrowElement),
690
+ ArrowElementOptions,
691
+ ArrowElementSize,
692
+ ArrowElementDraw
693
+ };
694
+
695
+ /*----------------------------------------------------------------------
696
+ * +++ Menubutton indicator:
697
+ * Draw an arrow in the direction where the menu will be posted.
698
+ */
699
+
700
+ #define MENUBUTTON_ARROW_SIZE 5
701
+
702
+ typedef struct {
703
+ Tcl_Obj *directionObj;
704
+ Tcl_Obj *sizeObj;
705
+ Tcl_Obj *colorObj;
706
+ } MenubuttonArrowElement;
707
+
708
+ static const char *directionStrings[] = { /* See also: button.c */
709
+ "above", "below", "left", "right", "flush", NULL
710
+ };
711
+ enum { POST_ABOVE, POST_BELOW, POST_LEFT, POST_RIGHT, POST_FLUSH };
712
+
713
+ static Ttk_ElementOptionSpec MenubuttonArrowElementOptions[] =
714
+ {
715
+ { "-direction", TK_OPTION_STRING,
716
+ Tk_Offset(MenubuttonArrowElement,directionObj), "below" },
717
+ { "-arrowsize", TK_OPTION_PIXELS,
718
+ Tk_Offset(MenubuttonArrowElement,sizeObj), STRINGIFY(MENUBUTTON_ARROW_SIZE)},
719
+ { "-arrowcolor",TK_OPTION_COLOR,
720
+ Tk_Offset(MenubuttonArrowElement,colorObj), "black"},
721
+ { NULL }
722
+ };
723
+
724
+ static Ttk_Padding MenubuttonArrowPadding = { 3, 0, 3, 0 };
725
+
726
+ static void MenubuttonArrowElementSize(
727
+ void *clientData, void *elementRecord, Tk_Window tkwin,
728
+ int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
729
+ {
730
+ MenubuttonArrowElement *arrow = elementRecord;
731
+ int size = MENUBUTTON_ARROW_SIZE;
732
+ Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &size);
733
+ *widthPtr = *heightPtr = 2 * size + 1;
734
+ *widthPtr += Ttk_PaddingWidth(MenubuttonArrowPadding);
735
+ *heightPtr += Ttk_PaddingHeight(MenubuttonArrowPadding);
736
+ }
737
+
738
+ static void MenubuttonArrowElementDraw(
739
+ void *clientData, void *elementRecord, Tk_Window tkwin,
740
+ Drawable d, Ttk_Box b, unsigned int state)
741
+ {
742
+ MenubuttonArrowElement *arrow = elementRecord;
743
+ XColor *arrowColor = Tk_GetColorFromObj(tkwin, arrow->colorObj);
744
+ GC gc = Tk_GCForColor(arrowColor, d);
745
+ int size = MENUBUTTON_ARROW_SIZE;
746
+ int postDirection = POST_BELOW;
747
+ ArrowDirection arrowDirection = ARROW_DOWN;
748
+ int width = 0, height = 0;
749
+
750
+ Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &size);
751
+ Tcl_GetIndexFromObj(NULL, arrow->directionObj, directionStrings,
752
+ ""/*message*/, 0/*flags*/, &postDirection);
753
+
754
+ /* ... this might not be such a great idea ... */
755
+ switch (postDirection) {
756
+ case POST_ABOVE: arrowDirection = ARROW_UP; break;
757
+ case POST_BELOW: arrowDirection = ARROW_DOWN; break;
758
+ case POST_LEFT: arrowDirection = ARROW_LEFT; break;
759
+ case POST_RIGHT: arrowDirection = ARROW_RIGHT; break;
760
+ case POST_FLUSH: arrowDirection = ARROW_DOWN; break;
761
+ }
762
+
763
+ TtkArrowSize(size, arrowDirection, &width, &height);
764
+ b = Ttk_PadBox(b, MenubuttonArrowPadding);
765
+ b = Ttk_AnchorBox(b, width, height, TK_ANCHOR_CENTER);
766
+ TtkFillArrow(Tk_Display(tkwin), d, gc, b, arrowDirection);
767
+ }
768
+
769
+ static Ttk_ElementSpec MenubuttonArrowElementSpec =
770
+ {
771
+ TK_STYLE_VERSION_2,
772
+ sizeof(MenubuttonArrowElement),
773
+ MenubuttonArrowElementOptions,
774
+ MenubuttonArrowElementSize,
775
+ MenubuttonArrowElementDraw
776
+ };
777
+
778
+ /*----------------------------------------------------------------------
779
+ * +++ Trough element
780
+ *
781
+ * Used in scrollbars and the scale.
782
+ *
783
+ * The -groovewidth option can be used to set the size of the short axis
784
+ * for the drawn area. This will not affect the geometry, but can be used
785
+ * to draw a thin centered trough inside the packet alloted. This is used
786
+ * to show a win32-style scale widget. Use -1 or a large number to use the
787
+ * full area (default).
788
+ *
789
+ */
790
+
791
+ typedef struct
792
+ {
793
+ Tcl_Obj *colorObj;
794
+ Tcl_Obj *borderWidthObj;
795
+ Tcl_Obj *reliefObj;
796
+ Tcl_Obj *grooveWidthObj;
797
+ Tcl_Obj *orientObj;
798
+ } TroughElement;
799
+
800
+ static Ttk_ElementOptionSpec TroughElementOptions[] =
801
+ {
802
+ { "-orient", TK_OPTION_ANY,
803
+ Tk_Offset(TroughElement, orientObj), "horizontal" },
804
+ { "-troughborderwidth", TK_OPTION_PIXELS,
805
+ Tk_Offset(TroughElement,borderWidthObj), "1" },
806
+ { "-troughcolor", TK_OPTION_BORDER,
807
+ Tk_Offset(TroughElement,colorObj), DEFAULT_BACKGROUND },
808
+ { "-troughrelief",TK_OPTION_RELIEF,
809
+ Tk_Offset(TroughElement,reliefObj), "sunken" },
810
+ { "-groovewidth", TK_OPTION_PIXELS,
811
+ Tk_Offset(TroughElement,grooveWidthObj), "-1" },
812
+ { NULL }
813
+ };
814
+
815
+ static void TroughElementSize(
816
+ void *clientData, void *elementRecord, Tk_Window tkwin,
817
+ int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
818
+ {
819
+ TroughElement *troughPtr = elementRecord;
820
+ int borderWidth = 2, grooveWidth = 0;
821
+
822
+ Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->borderWidthObj, &borderWidth);
823
+ Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->grooveWidthObj, &grooveWidth);
824
+
825
+ if (grooveWidth <= 0) {
826
+ *paddingPtr = Ttk_UniformPadding((short)borderWidth);
827
+ }
828
+ }
829
+
830
+ static void TroughElementDraw(
831
+ void *clientData, void *elementRecord, Tk_Window tkwin,
832
+ Drawable d, Ttk_Box b, unsigned int state)
833
+ {
834
+ TroughElement *troughPtr = elementRecord;
835
+ Tk_3DBorder border = NULL;
836
+ int borderWidth = 2, relief, groove, orient;
837
+
838
+ border = Tk_Get3DBorderFromObj(tkwin, troughPtr->colorObj);
839
+ Ttk_GetOrientFromObj(NULL, troughPtr->orientObj, &orient);
840
+ Tk_GetReliefFromObj(NULL, troughPtr->reliefObj, &relief);
841
+ Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->borderWidthObj, &borderWidth);
842
+ Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->grooveWidthObj, &groove);
843
+
844
+ if (groove != -1 && groove < b.height && groove < b.width) {
845
+ if (orient == TTK_ORIENT_HORIZONTAL) {
846
+ b.y = b.y + b.height/2 - groove/2;
847
+ b.height = groove;
848
+ } else {
849
+ b.x = b.x + b.width/2 - groove/2;
850
+ b.width = groove;
851
+ }
852
+ }
853
+
854
+ Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height,
855
+ borderWidth, relief);
856
+ }
857
+
858
+ static Ttk_ElementSpec TroughElementSpec =
859
+ {
860
+ TK_STYLE_VERSION_2,
861
+ sizeof(TroughElement),
862
+ TroughElementOptions,
863
+ TroughElementSize,
864
+ TroughElementDraw
865
+ };
866
+
867
+ /*
868
+ *----------------------------------------------------------------------
869
+ * +++ Thumb element.
870
+ */
871
+
872
+ typedef struct
873
+ {
874
+ Tcl_Obj *sizeObj;
875
+ Tcl_Obj *firstObj;
876
+ Tcl_Obj *lastObj;
877
+ Tcl_Obj *borderObj;
878
+ Tcl_Obj *borderColorObj;
879
+ Tcl_Obj *reliefObj;
880
+ Tcl_Obj *orientObj;
881
+ } ThumbElement;
882
+
883
+ static Ttk_ElementOptionSpec ThumbElementOptions[] =
884
+ {
885
+ { "-width", TK_OPTION_PIXELS, Tk_Offset(ThumbElement,sizeObj),
886
+ STRINGIFY(SCROLLBAR_WIDTH) },
887
+ { "-background", TK_OPTION_BORDER, Tk_Offset(ThumbElement,borderObj),
888
+ DEFAULT_BACKGROUND },
889
+ { "-bordercolor", TK_OPTION_COLOR, Tk_Offset(ThumbElement,borderColorObj),
890
+ "black" },
891
+ { "-relief", TK_OPTION_RELIEF,Tk_Offset(ThumbElement,reliefObj),"raised" },
892
+ { "-orient", TK_OPTION_ANY,Tk_Offset(ThumbElement,orientObj),"horizontal"},
893
+ { NULL }
894
+ };
895
+
896
+ static void ThumbElementSize(
897
+ void *clientData, void *elementRecord, Tk_Window tkwin,
898
+ int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
899
+ {
900
+ ThumbElement *thumb = elementRecord;
901
+ int orient, size;
902
+ Tk_GetPixelsFromObj(NULL, tkwin, thumb->sizeObj, &size);
903
+ Ttk_GetOrientFromObj(NULL, thumb->orientObj, &orient);
904
+
905
+ if (orient == TTK_ORIENT_VERTICAL) {
906
+ *widthPtr = size;
907
+ *heightPtr = MIN_THUMB_SIZE;
908
+ } else {
909
+ *widthPtr = MIN_THUMB_SIZE;
910
+ *heightPtr = size;
911
+ }
912
+ }
913
+
914
+ static void ThumbElementDraw(
915
+ void *clientData, void *elementRecord, Tk_Window tkwin,
916
+ Drawable d, Ttk_Box b, unsigned int state)
917
+ {
918
+ ThumbElement *thumb = elementRecord;
919
+ Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, thumb->borderObj);
920
+ XColor *borderColor = Tk_GetColorFromObj(tkwin, thumb->borderColorObj);
921
+ int relief = TK_RELIEF_RAISED;
922
+ int borderWidth = 2;
923
+
924
+ /*
925
+ * Don't draw the thumb if we are disabled.
926
+ * This makes it behave like Windows ... if that's what we want.
927
+ if (state & TTK_STATE_DISABLED)
928
+ return;
929
+ */
930
+
931
+ Tk_GetReliefFromObj(NULL, thumb->reliefObj, &relief);
932
+
933
+ Tk_Fill3DRectangle(
934
+ tkwin, d, border, b.x,b.y,b.width,b.height, 0, TK_RELIEF_FLAT);
935
+ DrawBorder(tkwin, d, border, borderColor, b, borderWidth, relief);
936
+ }
937
+
938
+ static Ttk_ElementSpec ThumbElementSpec =
939
+ {
940
+ TK_STYLE_VERSION_2,
941
+ sizeof(ThumbElement),
942
+ ThumbElementOptions,
943
+ ThumbElementSize,
944
+ ThumbElementDraw
945
+ };
946
+
947
+ /*
948
+ *----------------------------------------------------------------------
949
+ * +++ Slider element.
950
+ *
951
+ * This is the moving part of the scale widget.
952
+ *
953
+ * The slider element is the thumb in the scale widget. This is drawn
954
+ * as an arrow-type element that can point up, down, left or right.
955
+ *
956
+ */
957
+
958
+ typedef struct
959
+ {
960
+ Tcl_Obj *lengthObj; /* Long axis dimension */
961
+ Tcl_Obj *thicknessObj; /* Short axis dimension */
962
+ Tcl_Obj *reliefObj; /* Relief for this object */
963
+ Tcl_Obj *borderObj; /* Border / background color */
964
+ Tcl_Obj *borderColorObj; /* Additional border color */
965
+ Tcl_Obj *borderWidthObj;
966
+ Tcl_Obj *orientObj; /* Orientation of overall slider */
967
+ } SliderElement;
968
+
969
+ static Ttk_ElementOptionSpec SliderElementOptions[] =
970
+ {
971
+ { "-sliderlength", TK_OPTION_PIXELS, Tk_Offset(SliderElement,lengthObj),
972
+ "15" },
973
+ { "-sliderthickness",TK_OPTION_PIXELS,Tk_Offset(SliderElement,thicknessObj),
974
+ "15" },
975
+ { "-sliderrelief", TK_OPTION_RELIEF, Tk_Offset(SliderElement,reliefObj),
976
+ "raised" },
977
+ { "-borderwidth", TK_OPTION_PIXELS, Tk_Offset(SliderElement,borderWidthObj),
978
+ STRINGIFY(BORDERWIDTH) },
979
+ { "-background", TK_OPTION_BORDER, Tk_Offset(SliderElement,borderObj),
980
+ DEFAULT_BACKGROUND },
981
+ { "-bordercolor", TK_OPTION_COLOR, Tk_Offset(ThumbElement,borderColorObj),
982
+ "black" },
983
+ { "-orient", TK_OPTION_ANY, Tk_Offset(SliderElement,orientObj),
984
+ "horizontal" },
985
+ { NULL }
986
+ };
987
+
988
+ static void SliderElementSize(
989
+ void *clientData, void *elementRecord, Tk_Window tkwin,
990
+ int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
991
+ {
992
+ SliderElement *slider = elementRecord;
993
+ int orient, length, thickness, borderWidth;
994
+
995
+ Ttk_GetOrientFromObj(NULL, slider->orientObj, &orient);
996
+ Tk_GetPixelsFromObj(NULL, tkwin, slider->borderWidthObj, &borderWidth);
997
+ Tk_GetPixelsFromObj(NULL, tkwin, slider->lengthObj, &length);
998
+ Tk_GetPixelsFromObj(NULL, tkwin, slider->thicknessObj, &thickness);
999
+
1000
+ switch (orient) {
1001
+ case TTK_ORIENT_VERTICAL:
1002
+ *widthPtr = thickness + (borderWidth *2);
1003
+ *heightPtr = *widthPtr/2;
1004
+ break;
1005
+
1006
+ case TTK_ORIENT_HORIZONTAL:
1007
+ *heightPtr = thickness + (borderWidth *2);
1008
+ *widthPtr = *heightPtr/2;
1009
+ break;
1010
+ }
1011
+ }
1012
+
1013
+ static void SliderElementDraw(
1014
+ void *clientData, void *elementRecord, Tk_Window tkwin,
1015
+ Drawable d, Ttk_Box b, unsigned int state)
1016
+ {
1017
+ SliderElement *slider = elementRecord;
1018
+ Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, slider->borderObj);
1019
+ XColor *borderColor = Tk_GetColorFromObj(tkwin, slider->borderColorObj);
1020
+ int relief = TK_RELIEF_RAISED, borderWidth = 2;
1021
+
1022
+ Tk_GetPixelsFromObj(NULL, tkwin, slider->borderWidthObj, &borderWidth);
1023
+ Tk_GetReliefFromObj(NULL, slider->reliefObj, &relief);
1024
+
1025
+ Tk_Fill3DRectangle(tkwin, d, border,
1026
+ b.x, b.y, b.width, b.height,
1027
+ borderWidth, TK_RELIEF_FLAT);
1028
+ DrawBorder(tkwin, d, border, borderColor, b, borderWidth, relief);
1029
+ }
1030
+
1031
+ static Ttk_ElementSpec SliderElementSpec =
1032
+ {
1033
+ TK_STYLE_VERSION_2,
1034
+ sizeof(SliderElement),
1035
+ SliderElementOptions,
1036
+ SliderElementSize,
1037
+ SliderElementDraw
1038
+ };
1039
+
1040
+ /*------------------------------------------------------------------------
1041
+ * +++ Tree indicator element.
1042
+ */
1043
+
1044
+ #define TTK_STATE_OPEN TTK_STATE_USER1 /* XREF: treeview.c */
1045
+ #define TTK_STATE_LEAF TTK_STATE_USER2
1046
+
1047
+ typedef struct
1048
+ {
1049
+ Tcl_Obj *colorObj;
1050
+ Tcl_Obj *marginObj;
1051
+ Tcl_Obj *diameterObj;
1052
+ } TreeitemIndicator;
1053
+
1054
+ static Ttk_ElementOptionSpec TreeitemIndicatorOptions[] =
1055
+ {
1056
+ { "-foreground", TK_OPTION_COLOR,
1057
+ Tk_Offset(TreeitemIndicator,colorObj), DEFAULT_FOREGROUND },
1058
+ { "-diameter", TK_OPTION_PIXELS,
1059
+ Tk_Offset(TreeitemIndicator,diameterObj), "9" },
1060
+ { "-indicatormargins", TK_OPTION_STRING,
1061
+ Tk_Offset(TreeitemIndicator,marginObj), "2 2 4 2" },
1062
+ {NULL}
1063
+ };
1064
+
1065
+ static void TreeitemIndicatorSize(
1066
+ void *clientData, void *elementRecord, Tk_Window tkwin,
1067
+ int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
1068
+ {
1069
+ TreeitemIndicator *indicator = elementRecord;
1070
+ int diameter = 0;
1071
+ Ttk_Padding margins;
1072
+
1073
+ Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins);
1074
+ Tk_GetPixelsFromObj(NULL, tkwin, indicator->diameterObj, &diameter);
1075
+ *widthPtr = diameter + Ttk_PaddingWidth(margins);
1076
+ *heightPtr = diameter + Ttk_PaddingHeight(margins);
1077
+ }
1078
+
1079
+ static void TreeitemIndicatorDraw(
1080
+ void *clientData, void *elementRecord, Tk_Window tkwin,
1081
+ Drawable d, Ttk_Box b, Ttk_State state)
1082
+ {
1083
+ TreeitemIndicator *indicator = elementRecord;
1084
+ XColor *color = Tk_GetColorFromObj(tkwin, indicator->colorObj);
1085
+ GC gc = Tk_GCForColor(color, d);
1086
+ Ttk_Padding padding = Ttk_UniformPadding(0);
1087
+ int w = WIN32_XDRAWLINE_HACK;
1088
+ int cx, cy;
1089
+
1090
+ if (state & TTK_STATE_LEAF) {
1091
+ /* don't draw anything ... */
1092
+ return;
1093
+ }
1094
+
1095
+ Ttk_GetPaddingFromObj(NULL,tkwin,indicator->marginObj,&padding);
1096
+ b = Ttk_PadBox(b, padding);
1097
+
1098
+ XDrawRectangle(Tk_Display(tkwin), d, gc,
1099
+ b.x, b.y, b.width - 1, b.height - 1);
1100
+
1101
+ cx = b.x + (b.width - 1) / 2;
1102
+ cy = b.y + (b.height - 1) / 2;
1103
+ XDrawLine(Tk_Display(tkwin), d, gc, b.x+2, cy, b.x+b.width-3+w, cy);
1104
+
1105
+ if (!(state & TTK_STATE_OPEN)) {
1106
+ /* turn '-' into a '+' */
1107
+ XDrawLine(Tk_Display(tkwin), d, gc, cx, b.y+2, cx, b.y+b.height-3+w);
1108
+ }
1109
+ }
1110
+
1111
+ static Ttk_ElementSpec TreeitemIndicatorElementSpec =
1112
+ {
1113
+ TK_STYLE_VERSION_2,
1114
+ sizeof(TreeitemIndicator),
1115
+ TreeitemIndicatorOptions,
1116
+ TreeitemIndicatorSize,
1117
+ TreeitemIndicatorDraw
1118
+ };
1119
+
1120
+
1121
+
1122
+
1123
+ /*------------------------------------------------------------------------
1124
+ * TtkAltTheme_Init --
1125
+ * Install alternate theme.
1126
+ */
1127
+ int TtkAltTheme_Init(Tcl_Interp *interp)
1128
+ {
1129
+ Ttk_Theme theme = Ttk_CreateTheme(interp, "alt", NULL);
1130
+
1131
+ if (!theme) {
1132
+ return TCL_ERROR;
1133
+ }
1134
+
1135
+ Ttk_RegisterElement(interp, theme, "border", &BorderElementSpec, NULL);
1136
+
1137
+ Ttk_RegisterElement(interp, theme, "Checkbutton.indicator",
1138
+ &IndicatorElementSpec, &checkbutton_spec);
1139
+ Ttk_RegisterElement(interp, theme, "Radiobutton.indicator",
1140
+ &IndicatorElementSpec, &radiobutton_spec);
1141
+ Ttk_RegisterElement(interp, theme, "Menubutton.indicator",
1142
+ &MenubuttonArrowElementSpec, NULL);
1143
+
1144
+ Ttk_RegisterElement(interp, theme, "field", &FieldElementSpec, NULL);
1145
+
1146
+ Ttk_RegisterElement(interp, theme, "trough", &TroughElementSpec, NULL);
1147
+ Ttk_RegisterElement(interp, theme, "thumb", &ThumbElementSpec, NULL);
1148
+ Ttk_RegisterElement(interp, theme, "slider", &SliderElementSpec, NULL);
1149
+
1150
+ Ttk_RegisterElement(interp, theme, "uparrow",
1151
+ &ArrowElementSpec, &ArrowElements[0]);
1152
+ Ttk_RegisterElement(interp, theme, "downarrow",
1153
+ &ArrowElementSpec, &ArrowElements[1]);
1154
+ Ttk_RegisterElement(interp, theme, "leftarrow",
1155
+ &ArrowElementSpec, &ArrowElements[2]);
1156
+ Ttk_RegisterElement(interp, theme, "rightarrow",
1157
+ &ArrowElementSpec, &ArrowElements[3]);
1158
+ Ttk_RegisterElement(interp, theme, "arrow",
1159
+ &ArrowElementSpec, &ArrowElements[0]);
1160
+
1161
+ Ttk_RegisterElement(interp, theme, "arrow",
1162
+ &ArrowElementSpec, &ArrowElements[0]);
1163
+
1164
+ Ttk_RegisterElement(interp, theme, "Treeitem.indicator",
1165
+ &TreeitemIndicatorElementSpec, 0);
1166
+
1167
+ Tcl_PkgProvide(interp, "ttk::theme::alt", TILE_VERSION);
1168
+
1169
+ return TCL_OK;
1170
+ }
1171
+
1172
+ /*EOF*/