wrb 2.0.0

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 (271) hide show
  1. checksums.yaml +7 -0
  2. data/README +28 -0
  3. data/Rakefile +66 -0
  4. data/bin/wrb +41 -0
  5. data/bin/wrb.bat +6 -0
  6. data/ext/rwin/aatree.c +192 -0
  7. data/ext/rwin/aatree.h +55 -0
  8. data/ext/rwin/extconf.rb +47 -0
  9. data/ext/rwin/rw_api.c +2058 -0
  10. data/ext/rwin/rw_devices.c +215 -0
  11. data/ext/rwin/rw_gdiplus.h +278 -0
  12. data/ext/rwin/rw_graphics.c +1583 -0
  13. data/ext/rwin/rw_resources.c +1988 -0
  14. data/ext/rwin/rw_ubfuncs.c +281 -0
  15. data/ext/rwin/rw_windows.c +1936 -0
  16. data/ext/rwin/rwin.c +451 -0
  17. data/ext/rwin/rwin.h +442 -0
  18. data/lib/rwin.rb +820 -0
  19. data/lib/wrb.rb +20 -0
  20. data/lib/wrb/applications/frmdesigner/angle.cur +0 -0
  21. data/lib/wrb/applications/frmdesigner/angle2.cur +0 -0
  22. data/lib/wrb/applications/frmdesigner/controls/Button.bmp +0 -0
  23. data/lib/wrb/applications/frmdesigner/controls/Button.rb +34 -0
  24. data/lib/wrb/applications/frmdesigner/controls/Checkbox.bmp +0 -0
  25. data/lib/wrb/applications/frmdesigner/controls/Checkbox.rb +10 -0
  26. data/lib/wrb/applications/frmdesigner/controls/Combobox.bmp +0 -0
  27. data/lib/wrb/applications/frmdesigner/controls/Combobox.rb +88 -0
  28. data/lib/wrb/applications/frmdesigner/controls/ComboboxEx.rb +97 -0
  29. data/lib/wrb/applications/frmdesigner/controls/Comboboxex.bmp +0 -0
  30. data/lib/wrb/applications/frmdesigner/controls/DateTimePicker.bmp +0 -0
  31. data/lib/wrb/applications/frmdesigner/controls/DateTimePicker.rb +11 -0
  32. data/lib/wrb/applications/frmdesigner/controls/Edit.bmp +0 -0
  33. data/lib/wrb/applications/frmdesigner/controls/Edit.rb +8 -0
  34. data/lib/wrb/applications/frmdesigner/controls/Groupbox.bmp +0 -0
  35. data/lib/wrb/applications/frmdesigner/controls/Groupbox.rb +9 -0
  36. data/lib/wrb/applications/frmdesigner/controls/Hotkeyctrl.bmp +0 -0
  37. data/lib/wrb/applications/frmdesigner/controls/Hotkeyctrl.rb +9 -0
  38. data/lib/wrb/applications/frmdesigner/controls/Imagelist.bmp +0 -0
  39. data/lib/wrb/applications/frmdesigner/controls/Imagelist.rb +115 -0
  40. data/lib/wrb/applications/frmdesigner/controls/Listbox.bmp +0 -0
  41. data/lib/wrb/applications/frmdesigner/controls/Listbox.rb +77 -0
  42. data/lib/wrb/applications/frmdesigner/controls/Listview.bmp +0 -0
  43. data/lib/wrb/applications/frmdesigner/controls/Listview.rb +157 -0
  44. data/lib/wrb/applications/frmdesigner/controls/Menu.bmp +0 -0
  45. data/lib/wrb/applications/frmdesigner/controls/Menu.rb +198 -0
  46. data/lib/wrb/applications/frmdesigner/controls/Menubar.bmp +0 -0
  47. data/lib/wrb/applications/frmdesigner/controls/Menubar.rb +9 -0
  48. data/lib/wrb/applications/frmdesigner/controls/MonthCalender.bmp +0 -0
  49. data/lib/wrb/applications/frmdesigner/controls/Monthcalender.rb +9 -0
  50. data/lib/wrb/applications/frmdesigner/controls/Panel.bmp +0 -0
  51. data/lib/wrb/applications/frmdesigner/controls/Panel.rb +30 -0
  52. data/lib/wrb/applications/frmdesigner/controls/Progressbar.rb +10 -0
  53. data/lib/wrb/applications/frmdesigner/controls/Radiobutton.bmp +0 -0
  54. data/lib/wrb/applications/frmdesigner/controls/Radiobutton.rb +13 -0
  55. data/lib/wrb/applications/frmdesigner/controls/Rebar.bmp +0 -0
  56. data/lib/wrb/applications/frmdesigner/controls/Rebar.rb +162 -0
  57. data/lib/wrb/applications/frmdesigner/controls/Splitter.bmp +0 -0
  58. data/lib/wrb/applications/frmdesigner/controls/Splitter.rb +66 -0
  59. data/lib/wrb/applications/frmdesigner/controls/Static.bmp +0 -0
  60. data/lib/wrb/applications/frmdesigner/controls/Static.rb +9 -0
  61. data/lib/wrb/applications/frmdesigner/controls/Statusbar.bmp +0 -0
  62. data/lib/wrb/applications/frmdesigner/controls/Statusbar.rb +103 -0
  63. data/lib/wrb/applications/frmdesigner/controls/Tabctrl.bmp +0 -0
  64. data/lib/wrb/applications/frmdesigner/controls/Tabctrl.rb +136 -0
  65. data/lib/wrb/applications/frmdesigner/controls/Timer.bmp +0 -0
  66. data/lib/wrb/applications/frmdesigner/controls/Timer.rb +36 -0
  67. data/lib/wrb/applications/frmdesigner/controls/Toolbar.bmp +0 -0
  68. data/lib/wrb/applications/frmdesigner/controls/Toolbar.rb +165 -0
  69. data/lib/wrb/applications/frmdesigner/controls/Trackbar.bmp +0 -0
  70. data/lib/wrb/applications/frmdesigner/controls/Trackbar.rb +34 -0
  71. data/lib/wrb/applications/frmdesigner/controls/Treeview.bmp +0 -0
  72. data/lib/wrb/applications/frmdesigner/controls/Treeview.rb +107 -0
  73. data/lib/wrb/applications/frmdesigner/controls/Updown.bmp +0 -0
  74. data/lib/wrb/applications/frmdesigner/controls/Updown.rb +31 -0
  75. data/lib/wrb/applications/frmdesigner/controls/default.bmp +0 -0
  76. data/lib/wrb/applications/frmdesigner/controls/progressbar.bmp +0 -0
  77. data/lib/wrb/applications/frmdesigner/controls/unselect.bmp +0 -0
  78. data/lib/wrb/applications/frmdesigner/fddialogs.rb +87 -0
  79. data/lib/wrb/applications/frmdesigner/fdesign.rb +1315 -0
  80. data/lib/wrb/applications/frmdesigner/fdmodules.rb +1394 -0
  81. data/lib/wrb/applications/frmdesigner/fdparseform.rb +197 -0
  82. data/lib/wrb/applications/frmdesigner/img13.bmp +0 -0
  83. data/lib/wrb/base.rb +1294 -0
  84. data/lib/wrb/combocommon.rb +77 -0
  85. data/lib/wrb/commctrlconst.rb +139 -0
  86. data/lib/wrb/commdlg.rb +77 -0
  87. data/lib/wrb/components/animate.rb +114 -0
  88. data/lib/wrb/components/bitmap.rb +116 -0
  89. data/lib/wrb/components/button.rb +134 -0
  90. data/lib/wrb/components/canvas.rb +266 -0
  91. data/lib/wrb/components/checkbox.rb +118 -0
  92. data/lib/wrb/components/choosecolordlg.rb +87 -0
  93. data/lib/wrb/components/choosefontdlg.rb +142 -0
  94. data/lib/wrb/components/clipboard.rb +174 -0
  95. data/lib/wrb/components/combobox.rb +282 -0
  96. data/lib/wrb/components/comboboxex.rb +574 -0
  97. data/lib/wrb/components/cursor.rb +91 -0
  98. data/lib/wrb/components/datetimepicker.rb +197 -0
  99. data/lib/wrb/components/ddeclient.rb +180 -0
  100. data/lib/wrb/components/ddeserver.rb +131 -0
  101. data/lib/wrb/components/dialog.rb +228 -0
  102. data/lib/wrb/components/edit.rb +412 -0
  103. data/lib/wrb/components/font.rb +35 -0
  104. data/lib/wrb/components/form.rb +65 -0
  105. data/lib/wrb/components/groupbox.rb +122 -0
  106. data/lib/wrb/components/header.rb +479 -0
  107. data/lib/wrb/components/hotkeyctrl.rb +72 -0
  108. data/lib/wrb/components/icon.rb +109 -0
  109. data/lib/wrb/components/imagelist.rb +396 -0
  110. data/lib/wrb/components/inifile.rb +97 -0
  111. data/lib/wrb/components/listbox.rb +149 -0
  112. data/lib/wrb/components/listview.rb +1467 -0
  113. data/lib/wrb/components/menu.rb +592 -0
  114. data/lib/wrb/components/menubar.rb +84 -0
  115. data/lib/wrb/components/monthcalender.rb +164 -0
  116. data/lib/wrb/components/openfilenamedlg.rb +147 -0
  117. data/lib/wrb/components/pager.rb +199 -0
  118. data/lib/wrb/components/panel.rb +103 -0
  119. data/lib/wrb/components/picture.rb +55 -0
  120. data/lib/wrb/components/printdlg.rb +148 -0
  121. data/lib/wrb/components/printdlgex.rb +117 -0
  122. data/lib/wrb/components/printer.rb +97 -0
  123. data/lib/wrb/components/progressbar.rb +140 -0
  124. data/lib/wrb/components/radiobutton.rb +49 -0
  125. data/lib/wrb/components/rebar.rb +830 -0
  126. data/lib/wrb/components/registry.rb +408 -0
  127. data/lib/wrb/components/richedit.rb +1181 -0
  128. data/lib/wrb/components/savefilenamedlg.rb +27 -0
  129. data/lib/wrb/components/scintilla.rb +1298 -0
  130. data/lib/wrb/components/scrollbar.rb +239 -0
  131. data/lib/wrb/components/splitter.rb +494 -0
  132. data/lib/wrb/components/static.rb +198 -0
  133. data/lib/wrb/components/statusbar.rb +490 -0
  134. data/lib/wrb/components/tabctrl.rb +686 -0
  135. data/lib/wrb/components/timer.rb +117 -0
  136. data/lib/wrb/components/toolbar.rb +1107 -0
  137. data/lib/wrb/components/tooltip.rb +651 -0
  138. data/lib/wrb/components/trackbar.rb +298 -0
  139. data/lib/wrb/components/treeview.rb +845 -0
  140. data/lib/wrb/components/updown.rb +198 -0
  141. data/lib/wrb/ddeml.rb +241 -0
  142. data/lib/wrb/documents/animate.html +46 -0
  143. data/lib/wrb/documents/bitmap.html +69 -0
  144. data/lib/wrb/documents/button.html +78 -0
  145. data/lib/wrb/documents/canvas.html +137 -0
  146. data/lib/wrb/documents/checkbox.html +77 -0
  147. data/lib/wrb/documents/choosecolordlg.html +29 -0
  148. data/lib/wrb/documents/choosefontdlg.html +31 -0
  149. data/lib/wrb/documents/clipboard.html +31 -0
  150. data/lib/wrb/documents/combobox.html +117 -0
  151. data/lib/wrb/documents/comboboxex.html +139 -0
  152. data/lib/wrb/documents/control.html +53 -0
  153. data/lib/wrb/documents/cursor.html +45 -0
  154. data/lib/wrb/documents/datetimepicker.html +70 -0
  155. data/lib/wrb/documents/ddeclient.html +33 -0
  156. data/lib/wrb/documents/ddeserver.html +26 -0
  157. data/lib/wrb/documents/dialog.html +78 -0
  158. data/lib/wrb/documents/edit.html +169 -0
  159. data/lib/wrb/documents/empty.html +11 -0
  160. data/lib/wrb/documents/favicon.png +0 -0
  161. data/lib/wrb/documents/font.html +38 -0
  162. data/lib/wrb/documents/form.html +63 -0
  163. data/lib/wrb/documents/groupbox.html +57 -0
  164. data/lib/wrb/documents/header.html +85 -0
  165. data/lib/wrb/documents/hotkeyctrl.html +42 -0
  166. data/lib/wrb/documents/icon.html +45 -0
  167. data/lib/wrb/documents/imagelist.html +101 -0
  168. data/lib/wrb/documents/images/button.png +0 -0
  169. data/lib/wrb/documents/images/checkbox.png +0 -0
  170. data/lib/wrb/documents/images/combobox.png +0 -0
  171. data/lib/wrb/documents/images/comboboxex.png +0 -0
  172. data/lib/wrb/documents/images/datetimepicker.png +0 -0
  173. data/lib/wrb/documents/images/edit.png +0 -0
  174. data/lib/wrb/documents/images/groupbox.png +0 -0
  175. data/lib/wrb/documents/images/hotkeyctrl.png +0 -0
  176. data/lib/wrb/documents/images/listbox.png +0 -0
  177. data/lib/wrb/documents/images/listview.png +0 -0
  178. data/lib/wrb/documents/images/menu.png +0 -0
  179. data/lib/wrb/documents/images/menubar.png +0 -0
  180. data/lib/wrb/documents/images/monthcalender.png +0 -0
  181. data/lib/wrb/documents/images/progressbar.png +0 -0
  182. data/lib/wrb/documents/images/radiobutton.png +0 -0
  183. data/lib/wrb/documents/images/rebar.png +0 -0
  184. data/lib/wrb/documents/images/richedit.png +0 -0
  185. data/lib/wrb/documents/images/splitter.png +0 -0
  186. data/lib/wrb/documents/images/static.png +0 -0
  187. data/lib/wrb/documents/images/statusbar.png +0 -0
  188. data/lib/wrb/documents/images/tabctrl.png +0 -0
  189. data/lib/wrb/documents/images/toolbar.png +0 -0
  190. data/lib/wrb/documents/images/tooltip.png +0 -0
  191. data/lib/wrb/documents/images/trackbar.png +0 -0
  192. data/lib/wrb/documents/images/treeview.png +0 -0
  193. data/lib/wrb/documents/images/updown.png +0 -0
  194. data/lib/wrb/documents/index.html +155 -0
  195. data/lib/wrb/documents/inifile.html +36 -0
  196. data/lib/wrb/documents/license.txt +22 -0
  197. data/lib/wrb/documents/listbox.html +96 -0
  198. data/lib/wrb/documents/listview.html +277 -0
  199. data/lib/wrb/documents/make_doc.rb +596 -0
  200. data/lib/wrb/documents/menu.html +144 -0
  201. data/lib/wrb/documents/menubar.html +54 -0
  202. data/lib/wrb/documents/monthcalender.html +48 -0
  203. data/lib/wrb/documents/openfilenamedlg.html +36 -0
  204. data/lib/wrb/documents/pager.html +63 -0
  205. data/lib/wrb/documents/panel.html +32 -0
  206. data/lib/wrb/documents/picture.html +48 -0
  207. data/lib/wrb/documents/printdlg.html +35 -0
  208. data/lib/wrb/documents/printdlgex.html +35 -0
  209. data/lib/wrb/documents/printer.html +40 -0
  210. data/lib/wrb/documents/progressbar.html +69 -0
  211. data/lib/wrb/documents/radiobutton.html +51 -0
  212. data/lib/wrb/documents/rebar.html +143 -0
  213. data/lib/wrb/documents/registry.html +36 -0
  214. data/lib/wrb/documents/richedit.html +232 -0
  215. data/lib/wrb/documents/samples/editimg.bmp +0 -0
  216. data/lib/wrb/documents/samples/editimg.iml +0 -0
  217. data/lib/wrb/documents/samples/fileimg.bmp +0 -0
  218. data/lib/wrb/documents/samples/fileimg.iml +0 -0
  219. data/lib/wrb/documents/samples/sample_button.rb +21 -0
  220. data/lib/wrb/documents/samples/sample_checkbox.rb +18 -0
  221. data/lib/wrb/documents/samples/sample_combobox.rb +18 -0
  222. data/lib/wrb/documents/samples/sample_comboboxex.rb +23 -0
  223. data/lib/wrb/documents/samples/sample_datetimepicker.rb +11 -0
  224. data/lib/wrb/documents/samples/sample_edit.rb +25 -0
  225. data/lib/wrb/documents/samples/sample_groupbox.rb +19 -0
  226. data/lib/wrb/documents/samples/sample_hotkeyctrl.rb +12 -0
  227. data/lib/wrb/documents/samples/sample_listbox.rb +12 -0
  228. data/lib/wrb/documents/samples/sample_listview.rb +32 -0
  229. data/lib/wrb/documents/samples/sample_menu.rb +21 -0
  230. data/lib/wrb/documents/samples/sample_menubar.rb +23 -0
  231. data/lib/wrb/documents/samples/sample_monthcalender.rb +11 -0
  232. data/lib/wrb/documents/samples/sample_progressbar.rb +14 -0
  233. data/lib/wrb/documents/samples/sample_radiobutton.rb +14 -0
  234. data/lib/wrb/documents/samples/sample_rebar.rb +25 -0
  235. data/lib/wrb/documents/samples/sample_richedit.rb +60 -0
  236. data/lib/wrb/documents/samples/sample_splitter.rb +33 -0
  237. data/lib/wrb/documents/samples/sample_static.rb +15 -0
  238. data/lib/wrb/documents/samples/sample_statusbar.rb +17 -0
  239. data/lib/wrb/documents/samples/sample_tabctrl.rb +19 -0
  240. data/lib/wrb/documents/samples/sample_toolbar.rb +29 -0
  241. data/lib/wrb/documents/samples/sample_tooltip.rb +50 -0
  242. data/lib/wrb/documents/samples/sample_trackbar.rb +30 -0
  243. data/lib/wrb/documents/samples/sample_treeview.rb +19 -0
  244. data/lib/wrb/documents/samples/sample_updown.rb +18 -0
  245. data/lib/wrb/documents/samples/sampleimg16.iml +0 -0
  246. data/lib/wrb/documents/samples/sampleimg32.iml +0 -0
  247. data/lib/wrb/documents/samples/samplemg16.png +0 -0
  248. data/lib/wrb/documents/samples/samplemg32.png +0 -0
  249. data/lib/wrb/documents/samples/wrb.ico +0 -0
  250. data/lib/wrb/documents/savefilenamedlg.html +19 -0
  251. data/lib/wrb/documents/scrollbar.html +60 -0
  252. data/lib/wrb/documents/splitter.html +96 -0
  253. data/lib/wrb/documents/static.html +84 -0
  254. data/lib/wrb/documents/statusbar.html +110 -0
  255. data/lib/wrb/documents/tabctrl.html +151 -0
  256. data/lib/wrb/documents/timer.html +43 -0
  257. data/lib/wrb/documents/toolbar.html +181 -0
  258. data/lib/wrb/documents/tooltip.html +131 -0
  259. data/lib/wrb/documents/trackbar.html +107 -0
  260. data/lib/wrb/documents/treeview.html +210 -0
  261. data/lib/wrb/documents/updown.html +85 -0
  262. data/lib/wrb/documents/wincontrol.html +258 -0
  263. data/lib/wrb/documents/window.html +499 -0
  264. data/lib/wrb/documents/wrb.css +228 -0
  265. data/lib/wrb/gmem.rb +26 -0
  266. data/lib/wrb/imecommon.rb +59 -0
  267. data/lib/wrb/listcommon.rb +185 -0
  268. data/lib/wrb/lzss.rb +126 -0
  269. data/lib/wrb/scrollinfo.rb +142 -0
  270. data/lib/wrb/toplevelcommon.rb +634 -0
  271. metadata +315 -0
@@ -0,0 +1,298 @@
1
+ require 'wrb'
2
+ require 'wrb/commctrlconst'
3
+
4
+ module WR
5
+ module RC
6
+ TBS_AUTOTICKS = 0x1
7
+ TBS_VERT = 0x2
8
+ TBS_HORZ = 0x0
9
+ TBS_TOP = 0x4
10
+ TBS_BOTTOM = 0x0
11
+ TBS_LEFT = 0x4
12
+ TBS_RIGHT = 0x0
13
+ TBS_BOTH = 0x8
14
+ TBS_NOTICKS = 0x10
15
+ TBS_ENABLESELRANGE = 0x20
16
+ TBS_FIXEDLENGTH = 0x40
17
+ TBS_NOTHUMB = 0x80
18
+ TBS_TOOLTIPS = 0x100
19
+ TBS_REVERSED = 0x200
20
+ TBS_DOWNISLEFT = 0x400
21
+
22
+ TBM_GETPOS = WM_USER
23
+ TBM_GETRANGEMIN = WM_USER+1
24
+ TBM_GETRANGEMAX = WM_USER+2
25
+ TBM_GETTIC = WM_USER+3
26
+ TBM_SETTIC = WM_USER+4
27
+ TBM_SETPOS = WM_USER+5
28
+ TBM_SETRANGE = WM_USER+6
29
+ TBM_SETRANGEMIN = WM_USER+7
30
+ TBM_SETRANGEMAX = WM_USER+8
31
+ TBM_CLEARTICS = WM_USER+9
32
+ TBM_SETSEL = WM_USER+10
33
+ TBM_SETSELSTART = WM_USER+11
34
+ TBM_SETSELEND = WM_USER+12
35
+ TBM_GETPTICS = WM_USER+14
36
+ TBM_GETTICPOS = WM_USER+15
37
+ TBM_GETNUMTICS = WM_USER+16
38
+ TBM_GETSELSTART = WM_USER+17
39
+ TBM_GETSELEND = WM_USER+18
40
+ TBM_CLEARSEL = WM_USER+19
41
+ TBM_SETTICFREQ = WM_USER+20
42
+ TBM_SETPAGESIZE = WM_USER+21
43
+ TBM_GETPAGESIZE = WM_USER+22
44
+ TBM_SETLINESIZE = WM_USER+23
45
+ TBM_GETLINESIZE = WM_USER+24
46
+ TBM_GETTHUMBRECT = WM_USER+25
47
+ TBM_GETCHANNELRECT = WM_USER+26
48
+ TBM_SETTHUMBLENGTH = WM_USER+27
49
+ TBM_GETTHUMBLENGTH = WM_USER+28
50
+ TBM_SETTOOLTIPS = WM_USER+29
51
+ TBM_GETTOOLTIPS = WM_USER+30
52
+ TBM_SETTIPSIDE = WM_USER+31
53
+ TBM_SETBUDDY = WM_USER+32
54
+ TBM_GETBUDDY = WM_USER+33
55
+ TBM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT
56
+ TBM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT
57
+
58
+ TBTS_TOP = 0
59
+ TBTS_LEFT = 1
60
+ TBTS_BOTTOM = 2
61
+ TBTS_RIGHT = 3
62
+
63
+ TB_LINEUP = 0
64
+ TB_LINEDOWN = 1
65
+ TB_PAGEUP = 2
66
+ TB_PAGEDOWN = 3
67
+ TB_THUMBPOSITION = 4
68
+ TB_THUMBTRACK = 5
69
+ TB_TOP = 6
70
+ TB_BOTTOM = 7
71
+ TB_ENDTRACK = 8
72
+
73
+ TBCD_TICS = 0x1
74
+ TBCD_THUMB = 0x2
75
+ TBCD_CHANNEL = 0x3
76
+
77
+ TRBN_FIRST = -1501
78
+ TRBN_THUMBPOSCHANGING = TRBN_FIRST-1
79
+ end
80
+
81
+ # A window that contains a slider in a channel, and optional tick marks.
82
+ # <br>See also <a href="https://docs.microsoft.com/en-us/windows/desktop/Controls/
83
+ # window-controls"> Windows Control section of Microsoft Docs.</a>
84
+ class Trackbar < WinControl
85
+ include ModCommCtrl
86
+
87
+ TRBTHUMBPOSCHANGING = API.defstruct "
88
+ NMHDR hdr;
89
+ DWORD dwPos;
90
+ int nReason;"
91
+
92
+ WinStyles = {
93
+ :autotics => TBS_AUTOTICKS,
94
+ :vert => TBS_VERT,
95
+ :horiz => TBS_HORZ,
96
+ :top => TBS_TOP,
97
+ :bottom => TBS_BOTTOM,
98
+ :left => TBS_LEFT,
99
+ :right => TBS_RIGHT,
100
+ :both => TBS_BOTH,
101
+ :notics => TBS_NOTICKS,
102
+ :enableselrange => TBS_ENABLESELRANGE,
103
+ :fixedlength => TBS_FIXEDLENGTH,
104
+ :nothumb => TBS_NOTHUMB,
105
+ :tooltips => TBS_TOOLTIPS,
106
+ :reversed => TBS_REVERSED,
107
+ :downisleft => TBS_DOWNISLEFT,
108
+ }
109
+ # def self.sym2style(*args) _sym2style(WinStyles, args); end
110
+
111
+ PreDefinedEvents = {
112
+ :releasedcapture => [WM_NOTIFY, NM_RELEASEDCAPTURE, 'xs', NMHDR],
113
+ :thumbposchanging => [WM_NOTIFY, TRBN_THUMBPOSCHANGING, 'xs', TRBTHUMBPOSCHANGING],
114
+ :customdraw => [WM_NOTIFY, NM_CUSTOMDRAW, 'xs', NMCUSTOMDRAW]
115
+ }
116
+
117
+ DefaultEvents = [:releasedcapture]
118
+
119
+ def initialize(*args)
120
+ super
121
+ @_classname = "msctls_trackbar32"
122
+ @_acceptable_events = PreDefinedEvents.dup
123
+ end
124
+ #
125
+ def create()
126
+ super
127
+ self.pos = @_pos if @_pos
128
+ self.range = @_range if @_range
129
+ self.tics = @_tics if @_tics
130
+ self.thumblength = @_thumblength if @_thumblength
131
+ self.buddy = @_buddy if @_buddy
132
+ end
133
+
134
+ # Retrieves the current logical position of the slider in this trackbar.
135
+ def pos()
136
+ alive? ? SendMessage(TBM_GETPOS, 0, 0) : @_pos
137
+ end
138
+ # pos=(pos, redraw=true)
139
+ # Sets the current logical position of the slider in a trackbar.
140
+ def pos=(*args)
141
+ ps, redraw = args[0].is_a?(Array) ? args[0] : args[0], true
142
+ alive? ? SendMessage(TBM_SETPOS, redraw ? 1 : 0, ps) : @_pos = ps
143
+ end
144
+
145
+ # Retrieves the minimum and maximum position for the slider in this trackbar.
146
+ def range()
147
+ if alive?
148
+ [SendMessage(TBM_GETRANGEMIN, 0, 0), SendMessage(TBM_GETRANGEMAX, 0, 0)]
149
+ else
150
+ @_range
151
+ end
152
+ end
153
+ # range=(min, max, redraw)
154
+ # Sets the range of minimum and maximum logical positions for the slider in this trackbar.
155
+ def range=(*args)
156
+ lo, hi, redraw = args[0].is_a?(Array) ? args[0] : [0, args[0], true]
157
+ redraw = true if redraw.nil?
158
+ if alive?
159
+ SendMessage(TBM_SETRANGE, redraw ? 1 : 0, MAKELPARAM(lo, hi))
160
+ else
161
+ @_range = [lo, hi, redraw]
162
+ end
163
+ end
164
+
165
+ def selectionrange()
166
+ if alive?
167
+ [SendMessage(TBM_GETSELSTART, 0, 0), SendMessage(TBM_GETSELEND, 0, 0)]
168
+ else
169
+ @_selectionrange
170
+ end
171
+ end
172
+ # Gets/Sets the starting and ending position of the current selection range in this trackbar.<br>
173
+ # These methods are ignored if the trackbar has no TBS_ENABLESELRANGE style.
174
+ def selectionrange=(*args)
175
+ lo, hi, redraw = args[0].is_a?(Array) ? args[0] : [0, args[0], true]
176
+ redraw = true if redraw.nil?
177
+ if alive?
178
+ SendMessage(TBM_SETSEL, redraw ? 1 : 0, MAKELPARAM(lo, hi))
179
+ else
180
+ @_selectionrange = [lo, hi, redraw]
181
+ end
182
+ end
183
+
184
+ # Retrieves all logical position of a tick mark in this trackbar.
185
+ def tics()
186
+ if alive?
187
+ tics = []
188
+ n = SendMessage(TBM_GETNUMTICS, 0, 0)
189
+ (n - 2).times{|i| tics << SendMessage(TBM_GETTIC, i, 0)}
190
+ tics
191
+ else
192
+ @_tics
193
+ end
194
+ end
195
+ # Sets all logical position of a tick mark in this trackbar.<br>
196
+ # Give an array of [int1, int2, ... ].
197
+ def tics=(*args)
198
+ arg = args[0]
199
+ if alive?
200
+ if arg.nil?
201
+ SendMessage(TBM_CLEARTICS, 0, 0)
202
+ else
203
+ arg.each{|i| SendMessage(TBM_SETTIC, 0, i.to_i)}
204
+ end
205
+ else
206
+ @_tics = arg
207
+ end
208
+ end
209
+
210
+ def thumblength()
211
+ if alive?
212
+ SendMessage(TBM_GETTHUMBLENGTH, 0, 0)
213
+ else
214
+ @_thumblength
215
+ end
216
+ end
217
+ # Gets/Sets the length of the slider in a trackbar.
218
+ # This methods are ignored if the trackbar does not have the TBS_FIXEDLENGTH style.
219
+ def thumblength=(len)
220
+ if alive?
221
+ SendMessage(TBM_SETTHUMBLENGTH, len, 0)
222
+ else
223
+ @_thumblength = len
224
+ end
225
+ end
226
+
227
+ # Retrieves a tooltip control assigned to this trackbar, if any.
228
+ def tooltips()
229
+ if alive?
230
+ APP.hwnd2ref(SendMessage(TBM_GETTOOLTIPS, 0, 0))
231
+ else
232
+ @_tooltips
233
+ end
234
+ end
235
+ # Assigns a tooltip control to this trackbar control.
236
+ def tooltips=(tt)
237
+ if alive?
238
+ SendMessage(TBM_SETTOOLTIPS, tt._hwnd, 0)
239
+ else
240
+ @_tooltips
241
+ end
242
+ end
243
+
244
+ # Retrieves the two buddy windows to this trackbar control at both left/top and right/bottom locations.
245
+ def buddy()
246
+ if alive?
247
+ [APP.hwnd2ref(SendMessage(TBM_GETBUDDY, 1, 0)),
248
+ APP.hwnd2ref(SendMessage(TBM_GETBUDDY, 0, 0))]
249
+ else
250
+ @_buddy
251
+ end
252
+ end
253
+ # Assigns the two windows as the buddy window for this trackbar control.
254
+ # Give an array of [left_top_control, right_bottm_control].
255
+ def buddy=(args)
256
+ lt, rb = args
257
+ if alive?
258
+ SendMessage(TBM_SETBUDDY, 1, lt._hwnd) if lt
259
+ SendMessage(TBM_SETBUDDY, 0, rb._hwnd) if rb
260
+ else
261
+ @_buddy = args
262
+ end
263
+ end
264
+
265
+ # The channel is the area over which the slider moves.
266
+ # It contains the highlight when a range is selected.
267
+ def channelrect()
268
+ SendMessage(TBM_GETCHANNELRECT, 0, rect=RECT.new)
269
+ rect.to_a
270
+ end
271
+
272
+ protected
273
+ def _apply_options(arg)
274
+ if st=WinStyles[arg]
275
+ self.style |= st
276
+ end
277
+ super
278
+ end
279
+ end
280
+ end
281
+
282
+ module WR
283
+ class Form1 < Form
284
+ def initialize()
285
+ self.inheritfont = Font['Meiryo', 18]
286
+ resize 640, 480
287
+ controls << Edit[:buddy2, "min", 0, 250, 40, 22]
288
+ controls << Button[:buddy3, "max", 0, 250, 40, 24]
289
+ controls << Trackbar.new(:track1, 80, 100, 50, 150, :vert, #:reversed,
290
+ :tics=>[20,40,60,80], :buddy=>[_buddy3, _buddy2])
291
+ end
292
+ def created()
293
+ dp "@%#x, %d", _track1.style, _track1.pos
294
+ end
295
+
296
+ self.start
297
+ end
298
+ end if $0 == __FILE__
@@ -0,0 +1,845 @@
1
+ require 'wrb'
2
+
3
+ module WR
4
+ module RC
5
+ TVS_HASBUTTONS = 0x1
6
+ TVS_HASLINES = 0x2
7
+ TVS_LINESATROOT = 0x4
8
+ TVS_EDITLABELS = 0x8
9
+ TVS_DISABLEDRAGDROP = 0x10
10
+ TVS_SHOWSELALWAYS = 0x20
11
+ TVS_RTLREADING = 0x40
12
+ TVS_NOTOOLTIPS = 0x80
13
+ TVS_CHECKBOXES = 0x100
14
+ TVS_TRACKSELECT = 0x200
15
+ TVS_SINGLEEXPAND = 0x400
16
+ TVS_INFOTIP = 0x800
17
+ TVS_FULLROWSELECT = 0x1000
18
+ TVS_NOSCROLL = 0x2000
19
+ TVS_NONEVENHEIGHT = 0x4000
20
+ TVS_NOHSCROLL = 0x8000
21
+ TVS_DEFAULT = TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_EDITLABELS
22
+
23
+ TV_FIRST = 0x1100
24
+ TVM_DELETEITEM = TV_FIRST+ 1
25
+ TVM_EXPAND = TV_FIRST+ 2
26
+ TVM_GETCOUNT = TV_FIRST+ 5
27
+ TVM_GETINDENT = TV_FIRST+ 6
28
+ TVM_SETINDENT = TV_FIRST+ 7
29
+ TVM_GETIMAGELIST = TV_FIRST+ 8
30
+ TVM_SETIMAGELIST = TV_FIRST+ 9
31
+ TVM_GETNEXTITEM = TV_FIRST+10
32
+ TVM_SELECTITEM = TV_FIRST+11
33
+
34
+ TVM_INSERTITEMA = TV_FIRST
35
+ TVM_GETITEMA = TV_FIRST+12
36
+ TVM_SETITEMA = TV_FIRST+13
37
+ TVM_GETISEARCHSTRINGA = TV_FIRST+23
38
+
39
+ TVM_INSERTITEMW = TV_FIRST+50
40
+ TVM_GETITEMW = TV_FIRST+62
41
+ TVM_SETITEMW = TV_FIRST+63
42
+ TVM_GETISEARCHSTRINGW = TV_FIRST+64
43
+
44
+ if RWin::UNICODE
45
+ TVM_INSERTITEM = TVM_INSERTITEMW
46
+ TVM_GETITEM = TVM_GETITEMW
47
+ TVM_SETITEM = TVM_SETITEMW
48
+ TVM_GETISEARCHSTRING = TVM_GETISEARCHSTRINGW
49
+ else
50
+ TVM_INSERTITEM = TVM_INSERTITEMA
51
+ TVM_GETITEM = TVM_GETITEMA
52
+ TVM_SETITEM = TVM_SETITEMA
53
+ TVM_GETISEARCHSTRING = TVM_GETISEARCHSTRINGA
54
+ end
55
+
56
+ TVM_HITTEST = TV_FIRST+17
57
+ TVM_CREATEDRAGIMAGE = TV_FIRST+18
58
+ TVM_SORTCHILDREN = TV_FIRST+19
59
+ TVM_ENSUREVISIBLE = TV_FIRST+20
60
+ TVM_SORTCHILDRENCB = TV_FIRST+21
61
+ TVM_ENDEDITLABELNOW = TV_FIRST+22
62
+ TVM_SETTOOLTIPS = TV_FIRST+24
63
+ TVM_GETTOOLTIPS = TV_FIRST+25
64
+ TVM_SETINSERTMARK = TV_FIRST+26
65
+ TVM_SETITEMHEIGHT = TV_FIRST+27
66
+ TVM_GETITEMHEIGHT = TV_FIRST+28
67
+ TVM_SETBKCOLOR = TV_FIRST+29
68
+ TVM_SETTEXTCOLOR = TV_FIRST+30
69
+ TVM_GETBKCOLOR = TV_FIRST+31
70
+ TVM_GETTEXTCOLOR = TV_FIRST+32
71
+ TVM_SETSCROLLTIME = TV_FIRST+33
72
+ TVM_GETSCROLLTIME = TV_FIRST+34
73
+ TVM_SETINSERTMARKCOLOR = TV_FIRST+37
74
+ TVM_GETINSERTMARKCOLOR = TV_FIRST+38
75
+ TVM_GETITEMSTATE = TV_FIRST+39
76
+ TVM_SETLINECOLOR = TV_FIRST+40
77
+ TVM_GETLINECOLOR = TV_FIRST+41
78
+ TVM_MAPACCIDTOHTREEITEM = TV_FIRST+42
79
+ TVM_MAPHTREEITEMTOACCID = TV_FIRST+43
80
+
81
+ TVN_FIRST = -400
82
+ TVN_KEYDOWN = TVN_FIRST-12
83
+ TVN_SINGLEEXPAND = TVN_FIRST-15
84
+
85
+ TVN_SELCHANGINGA = TVN_FIRST-1
86
+ TVN_SELCHANGEDA = TVN_FIRST-2
87
+ TVN_GETDISPINFOA = TVN_FIRST-3
88
+ TVN_SETDISPINFOA = TVN_FIRST-4
89
+ TVN_ITEMEXPANDINGA= TVN_FIRST-5
90
+ TVN_ITEMEXPANDEDA = TVN_FIRST-6
91
+ TVN_BEGINDRAGA = TVN_FIRST-7
92
+ TVN_BEGINRDRAGA = TVN_FIRST-8
93
+ TVN_DELETEITEMA = TVN_FIRST-9
94
+ TVN_BEGINLABELEDITA = TVN_FIRST-10
95
+ TVN_ENDLABELEDITA = TVN_FIRST-11
96
+ TVN_GETINFOTIPA = TVN_FIRST-13
97
+
98
+ TVN_SELCHANGINGW = TVN_FIRST-50
99
+ TVN_SELCHANGEDW = TVN_FIRST-51
100
+ TVN_GETDISPINFOW = TVN_FIRST-52
101
+ TVN_SETDISPINFOW = TVN_FIRST-53
102
+ TVN_ITEMEXPANDINGW= TVN_FIRST-54
103
+ TVN_ITEMEXPANDEDW = TVN_FIRST-55
104
+ TVN_BEGINDRAGW = TVN_FIRST-56
105
+ TVN_BEGINRDRAGW = TVN_FIRST-57
106
+ TVN_DELETEITEMW = TVN_FIRST-58
107
+ TVN_BEGINLABELEDITW = TVN_FIRST-59
108
+ TVN_ENDLABELEDITW = TVN_FIRST-60
109
+ TVN_GETINFOTIPW = TVN_FIRST-14
110
+
111
+ if RWin::UNICODE
112
+ TVN_SELCHANGING = TVN_SELCHANGINGW
113
+ TVN_SELCHANGED = TVN_SELCHANGEDW
114
+ TVN_GETDISPINFO = TVN_GETDISPINFOW
115
+ TVN_SETDISPINFO = TVN_SETDISPINFOW
116
+ TVN_ITEMEXPANDING = TVN_ITEMEXPANDINGW
117
+ TVN_ITEMEXPANDED = TVN_ITEMEXPANDEDW
118
+ TVN_BEGINDRAG = TVN_BEGINDRAGW
119
+ TVN_BEGINRDRAG = TVN_BEGINRDRAGW
120
+ TVN_DELETEITEM = TVN_DELETEITEMW
121
+ TVN_BEGINLABELEDIT = TVN_BEGINLABELEDITW
122
+ TVN_ENDLABELEDIT = TVN_ENDLABELEDITW
123
+ TVN_GETINFOTIP = TVN_GETINFOTIPW
124
+ else
125
+ TVN_SELCHANGING = TVN_SELCHANGINGA
126
+ TVN_SELCHANGED = TVN_SELCHANGEDA
127
+ TVN_GETDISPINFO = TVN_GETDISPINFOA
128
+ TVN_SETDISPINFO = TVN_SETDISPINFOA
129
+ TVN_ITEMEXPANDING = TVN_ITEMEXPANDINGA
130
+ TVN_ITEMEXPANDED = TVN_ITEMEXPANDEDA
131
+ TVN_BEGINDRAG = TVN_BEGINDRAGA
132
+ TVN_BEGINRDRAG = TVN_BEGINRDRAGA
133
+ TVN_DELETEITEM = TVN_DELETEITEMA
134
+ TVN_BEGINLABELEDIT = TVN_BEGINLABELEDITA
135
+ TVN_ENDLABELEDIT = TVN_ENDLABELEDITA
136
+ TVN_GETINFOTIP = TVN_GETINFOTIPA
137
+ end
138
+
139
+ TVI_ROOT = -0x10000
140
+ TVI_FIRST = TVI_ROOT+1
141
+ TVI_LAST = TVI_ROOT+2
142
+ TVI_SORT = TVI_ROOT+3
143
+
144
+ TVGN_ROOT = 0x0
145
+ TVGN_NEXT = 0x1
146
+ TVGN_PREVIOUS = 0x2
147
+ TVGN_PARENT = 0x3
148
+ TVGN_CHILD = 0x4
149
+ TVGN_FIRSTVISIBLE = 0x5
150
+ TVGN_NEXTVISIBLE = 0x6
151
+ TVGN_PREVIOUSVISIBLE = 0x7
152
+ TVGN_DROPHILITE = 0x8
153
+ TVGN_CARET = 0x9
154
+ TVGN_LASTVISIBLE = 0xa
155
+
156
+ TVIF_TEXT = 0x1
157
+ TVIF_IMAGE = 0x2
158
+ TVIF_PARAM = 0x4
159
+ TVIF_STATE = 0x8
160
+ TVIF_HANDLE = 0x10
161
+ TVIF_SELECTEDIMAGE = 0x20
162
+ TVIF_CHILDREN = 0x40
163
+ TVIF_INTEGRAL = 0x80
164
+ TVIF_DEFAULT = TVIF_TEXT | TVIF_IMAGE | TVIF_PARAM | TVIF_SELECTEDIMAGE
165
+
166
+ TVIS_SELECTED = 0x2
167
+ TVIS_CUT = 0x4
168
+ TVIS_DROPHILITED = 0x8
169
+ TVIS_BOLD = 0x10
170
+ TVIS_EXPANDED = 0x20
171
+ TVIS_EXPANDEDONCE = 0x40
172
+ TVIS_EXPANDPARTIAL = 0x80
173
+ TVIS_OVERLAYMASK = 0xf00
174
+ TVIS_STATEIMAGEMASK = 0xF000
175
+ TVIS_USERMASK = 0xF000
176
+
177
+ TVE_COLLAPSE = 0x1
178
+ TVE_EXPAND = 0x2
179
+ TVE_TOGGLE = 0x3
180
+ TVE_EXPANDPARTIAL = 0x4000
181
+ TVE_COLLAPSERESET = 0x8000
182
+ end
183
+
184
+ # A window that displays a hierarchical list of items, such as the headings in a document, the entries in an index.
185
+ # <br>See also <a href="https://docs.microsoft.com/en-us/windows/desktop/Controls/
186
+ # window-controls"> Windows Control section of Microsoft Docs.</a>
187
+ class Treeview < WinControl
188
+ include ModCommCtrl
189
+
190
+ TVITEM = API.defstruct "
191
+ UINT mask;
192
+ HANDLE hItem;
193
+ UINT state;
194
+ UINT stateMask;
195
+ LPTSTR pszText;
196
+ int cchTextMax;
197
+ int iImage;
198
+ int iSelectedImage;
199
+ int cChildren;
200
+ LPARAM lParam;"
201
+
202
+ TREEINSERTITEM = API.defstruct "
203
+ HANDLE hParent;
204
+ HANDLE hInsertAfter;
205
+ TVITEM item;"
206
+
207
+ TVHITTESTINFO = API.defstruct "
208
+ POINT pt;
209
+ UINT flags;
210
+ HANDLE hItem;"
211
+
212
+ NMTREEVIEW = API.defstruct "
213
+ NMHDR hdr;
214
+ UINT action;
215
+ TVITEM itemOld;
216
+ TVITEM itemNew;
217
+ POINT ptDrag;"
218
+
219
+ NMTVCUSTOMDRAW = API.defstruct "
220
+ NMCUSTOMDRAW nmcd;
221
+ COLORREF clrText;
222
+ COLORREF clrTextBk;
223
+ int iLevel;"
224
+
225
+ NMTVKEYDOWN = API.defstruct "
226
+ NMHDR hdr;
227
+ WORD wVKey;
228
+ UINT flags;"
229
+
230
+ NMTVDISPINFO = API.defstruct "
231
+ NMHDR hdr;
232
+ TVITEM item;"
233
+
234
+ API.typealias 'HTREEITEM', 'Q'
235
+ NMTVGETINFOTIP = API.defstruct "
236
+ NMHDR hdr;
237
+ LPTSTR pszText;
238
+ int cchTextMax;
239
+ HTREEITEM hItem;
240
+ LPARAM lParam;"
241
+
242
+ # Wrapper of hitem
243
+ class Item
244
+ include RC
245
+ attr_reader :items, :owner
246
+ attr_accessor :hitem
247
+
248
+ def initialize(onr, hitm, *args)#; dp "@%p", args
249
+ @owner = onr
250
+ @hitem = hitm
251
+ if @hitem.nil?
252
+ @items = [] #text, image, selimage, data
253
+ @_parent, @_text, @_image, @_selimage, @_data = args
254
+ end
255
+ end
256
+ #
257
+ def inspect()
258
+ sprintf("#<%p:%x %p>", self.class, self.__id__, self.text)
259
+ end
260
+
261
+ # Inserts an item at the specified index of this node.<br>
262
+ # The item can be an array of [text, image, selimage, data], or a Treeview::Item.<br>
263
+ # The index can be an integer or a Treeview::Item.<br>
264
+ # If a Treeview::Item was given as index, inserts the item at next of it.
265
+ def insert(idx, item)
266
+ if @owner.alive?
267
+ if idx.is_a? Integer
268
+ if idx < 0
269
+ hinsert = idx
270
+ elsif idx == 0
271
+ hinsert = TVI_FIRST
272
+ else
273
+ hinsert = self[idx-1].hitem
274
+ end
275
+ else
276
+ hinsert = item.hitem
277
+ end
278
+ if item.is_a?(Treeview::Item)
279
+ titem = TREEINSERTITEM[@hitem, hinsert, item._tvitem]
280
+ hitem = @owner.SendMessage(TVM_INSERTITEM, 0, titem)
281
+ item.hitem = hitem
282
+ else
283
+ text, image, selimage, data = item #; dp "@%p", item
284
+ selimage = image unless selimage
285
+ lparam = data.__id__
286
+ @owner._ar_data << data if (lparam&1)==0 && lparam>NilID
287
+ titem = TREEINSERTITEM[@hitem, hinsert, TVITEM[TVIF_DEFAULT, nil, nil, nil,
288
+ text , text.size, image, selimage, nil, lparam]]
289
+ item = Item.new(@owner, @owner.SendMessage(TVM_INSERTITEM, 0, titem))
290
+ end
291
+ else
292
+ if idx.is_a? Integer
293
+ case idx
294
+ when TVI_FIRST
295
+ insert2 = 0
296
+ when TVI_LAST, TVI_SORT
297
+ insert2 = @items.size
298
+ else
299
+ insert2 = idx > @items.size ? @items.size : idx
300
+ end
301
+ else
302
+ insert2 = @items.index(idx) || @items.size
303
+ end
304
+ unless item.is_a?(Treeview::Item)
305
+ text, image, selimage, data = item
306
+ selimage = image unless selimage
307
+ item = Item.new(@owner , nil, self, text, image, selimage, data)
308
+ end
309
+ @items.insert(insert2, item)
310
+ @items.sort!{|a, b| a.text <=> b.text} if idx==TVI_SORT
311
+ end
312
+ item
313
+ end
314
+
315
+ # Delets this node.
316
+ def delete()
317
+ if @owner.alive?
318
+ @owner.SendMessage(TVM_DELETEITEM, 0, @hitem)==0 ? false : true
319
+ else
320
+ @_parent.items.delete(self) if @_parent
321
+ end
322
+ end
323
+
324
+ # Retreives a parent node of this node.
325
+ def parent()
326
+ hitem = @owner.SendMessage(TVM_GETNEXTITEM, TVGN_PARENT, @hitem)
327
+ Item.new(@owner, hitem)
328
+ end
329
+
330
+ # Count items in this node.
331
+ def count()
332
+ if @owner.alive?
333
+ hitem = @owner.SendMessage(TVM_GETNEXTITEM, TVGN_CHILD, @hitem)
334
+ return 0 if hitem == 0
335
+ n = 1
336
+ while (hitem = @owner.SendMessage(TVM_GETNEXTITEM, TVGN_NEXT, hitem)) > 0
337
+ n += 1
338
+ end
339
+ n
340
+ else
341
+ @items.size
342
+ end
343
+ end
344
+
345
+ #
346
+ def create_substance()
347
+ @items.each{|i| #dpp i._tvitem.mask, i._tvitem.iImage, i._tvitem.iSelectedImage
348
+ # hi = @owner.SendMessage(TVM_INSERTITEM, 0, TREEINSERTITEM[@hitem, TVI_LAST, i._tvitem])
349
+ # i.hitem = hi
350
+ self << i
351
+ i.create_substance()
352
+ }
353
+ self._cleanup
354
+ end
355
+
356
+ # Appends the item at the last of this node.
357
+ def <<(item) # [text, data=nil, state=TVS_DEFAULT]
358
+ #self.insert(TVI_LAST, item)
359
+ self[count, 0] = item
360
+ end
361
+
362
+ # Retreives an item of this node.
363
+ def [](idx)
364
+ if @owner.alive?
365
+ hitem = @owner.SendMessage(TVM_GETNEXTITEM, TVGN_CHILD, @hitem)
366
+ if hitem == 0
367
+ nil
368
+ else
369
+ if idx == 0
370
+ Item.new(@owner, hitem)
371
+ else
372
+ (idx).times do
373
+ hitem = @owner.SendMessage(TVM_GETNEXTITEM, TVGN_NEXT, hitem)
374
+ return nil if hitem == 0
375
+ end
376
+ Item.new(@owner, hitem)
377
+ end
378
+ end
379
+ else
380
+ @items[idx]
381
+ end
382
+ end
383
+
384
+ # []=(index, length=1, items)
385
+ # Inserts and replaces the items at specified index and length with given items.
386
+ def []=(idx, *args)
387
+ num = args[0].is_a?(Integer) ? args.shift : 1
388
+ num.times{self[idx].delete} #; dp "@%p", args
389
+ if args[0].is_a?(Array) && (args[0][1].is_a?(String) || args[0][0].is_a?(Array))
390
+ args[0].each_with_index{|v, i| self.insert(idx+i, v)}
391
+ else
392
+ args.each_with_index{|v, i| self.insert(idx+i, v)}
393
+ end
394
+ end
395
+
396
+ # Retreives the next sibling item of current item.
397
+ def next()
398
+ hitem = @owner.SendMessage(TVM_GETNEXTITEM, TVGN_NEXT, @hitem)
399
+ hitem==0 ? nil : Item.new(@owner, hitem)
400
+ end
401
+
402
+ # Retreives the previous sibling item of current item.
403
+ def previous()
404
+ hitem = @owner.SendMessage(TVM_GETNEXTITEM, TVGN_PREVIOUS, @hitem)
405
+ hitem==0 ? nil : Item.new(@owner, hitem)
406
+ end
407
+
408
+ # Retreives the next visible item of current item.
409
+ def nextvisible()
410
+ hitem = @owner.SendMessage(TVM_GETNEXTITEM, TVGN_NEXTVISIBLE, @hitem)
411
+ hitem==0 ? nil : Item.new(@owner, hitem)
412
+ end
413
+
414
+ # Retreives the previous visible item of current item.
415
+ def previousvisible()
416
+ hitem = @owner.SendMessage(TVM_GETNEXTITEM, TVGN_PREVIOUSVISIBLE, @hitem)
417
+ hitem==0 ? nil : Item.new(@owner, hitem)
418
+ end
419
+
420
+ # Retrieves the first item that is visible in this tree-view window.
421
+ def firstvisible()
422
+ hitem = @owner.SendMessage(TVM_GETNEXTITEM, TVGN_FIRSTVISIBLE, @hitem)
423
+ hitem==0 ? nil : Item.new(@owner, hitem)
424
+ end
425
+ # Retrieves the last item that is visible in this tree-view window.
426
+ def lastvisible()
427
+ hitem = @owner.SendMessage(TVM_GETNEXTITEM, TVGN_LASTVISIBLE, @hitem)
428
+ hitem==0 ? nil : Item.new(@owner, hitem)
429
+ end
430
+
431
+ # Retrieves the item that is the target of a drag-and-drop operation.
432
+ def drophilight()
433
+ hitem = @owner.SendMessage(TVM_GETNEXTITEM, TVGN_DROPHILIGHT, @hitem)
434
+ hitem==0 ? nil : Item.new(@owner, hitem)
435
+ end
436
+
437
+ # Retreives the index of current item in the current node.
438
+ def index()
439
+ hparent = @owner.SendMessage(TVM_GETNEXTITEM, TVGN_PARENT, @hitem)
440
+ hitem = @owner.SendMessage(TVM_GETNEXTITEM, TVGN_CHILD, hparent)
441
+ return 0 if hitem == @hitem
442
+ n = 1
443
+ while (hitem = @owner.SendMessage(TVM_GETNEXTITEM, TVGN_NEXT, hitem)) > 0
444
+ return n if hitem == @hitem
445
+ n += 1
446
+ end
447
+ raise "Getting index was failed."
448
+ end
449
+
450
+ # Retreives the last sibling item of current item.
451
+ def last()
452
+ self[count-1]
453
+ end
454
+
455
+ # each(){|item| ... }
456
+ # Performs the block for each <i>item</i> in current node as a block parameter.
457
+ def each()
458
+ count.times{|i| yield self[i]}
459
+ end
460
+
461
+ # Retreives a text of current item.
462
+ def text(textsize=260)
463
+ if @owner.alive?
464
+ tvitem = TVITEM[TVIF_TEXT, @hitem, nil, nil, TCHAR[textsize], textsize]
465
+ @owner.SendMessage(TVM_GETITEM, 0, tvitem)
466
+ tvitem.pszText.to_s
467
+ else
468
+ @_text
469
+ end
470
+ end
471
+
472
+ # Sete a text of current item.
473
+ def text=(txt)
474
+ if @owner.alive?
475
+ s = txt.to_s
476
+ tvitem = TVITEM[TVIF_TEXT, @hitem, nil, nil, s, s.size]
477
+ @owner.SendMessage(TVM_SETITEM, 0, tvitem)
478
+ else
479
+ @_text = txt
480
+ end
481
+ end
482
+
483
+ # Gets a state of current item.
484
+ def state()
485
+ if @owner.alive?
486
+ tvitem = TVITEM[TVIF_STATE, @hitem]
487
+ @owner.SendMessage(TVM_GETITEM, 0, tvitem)
488
+ tvitem.state
489
+ else
490
+ @_state
491
+ end
492
+ end
493
+ # Sets a state of current item.
494
+ def state=(stat)
495
+ if @owner.alive?
496
+ tvitem = TVITEM[TVIF_STATE, @hitem, stat]
497
+ @owner.SendMessage(TVM_SETITEM, 0, tvitem)
498
+ else
499
+ @_state = stat
500
+ end
501
+ end
502
+
503
+ # Gets an image index of current item.
504
+ def image()
505
+ tvitem = TVITEM[TVIF_IMAGE, @hitem]
506
+ @owner.SendMessage(TVM_GETITEM, 0, tvitem)
507
+ return tvitem.iImage
508
+ end
509
+ # Sets an image index of current item.
510
+ def image=(*args)
511
+ if @owner.alive?
512
+ img, selectedimg = args[0].is_a?(Array) ? args[0] : args
513
+ tvitem = TVITEM[TVIF_IMAGE | TVIF_SELECTEDIMAGE, @hitem]
514
+ tvitem.iImage = img
515
+ tvitem.iSelectedImage = selectedimg || img
516
+ @owner.SendMessage(TVM_SETITEM, 0, tvitem)
517
+ else
518
+ @_image = image
519
+ end
520
+ end
521
+
522
+ # Gets a selected image index of current item.
523
+ def selectedimage()
524
+ tvitem = TVITEM[TVIF_IMAGE, @hitem]
525
+ @owner.SendMessage(TVM_GETITEM, 0, tvitem)
526
+ return tvitem.iSelectedImage
527
+ end
528
+ # Sets a selected image index of current item.
529
+ def selectedimage=(selectedimg)
530
+ tvitem = TVITEM[TVIF_IMAGE | TVIF_SELECTEDIMAGE, @hitem]
531
+ tvitem.iSelectedImage = selectedimg
532
+ @owner.SendMessage(TVM_SETITEM, 0, tvitem)
533
+ end
534
+
535
+ # Gets an assigned data that can be an any ofject to current item.
536
+ def data()
537
+ if @owner.alive?
538
+ tvitem = TVITEM[TVIF_PARAM, @hitem]
539
+ @owner.SendMessage(TVM_GETITEM, 0, tvitem)
540
+ ObjectSpace._id2ref(tvitem.lParam) rescue nil
541
+ else
542
+ @_data
543
+ end
544
+ end
545
+ # Assignes a data that can be an any object to current item.
546
+ def data=(dat)
547
+ if @owner.alive?
548
+ tvitem = TVITEM[TVIF_PARAM, @hitem]
549
+ @owner.SendMessage(TVM_GETITEM, 0, tvitem)
550
+ lp = tvitem.lParam
551
+ if (lp&1)==0 && lp>NilID
552
+ @owner._ar_data.delete(ObjectSpace._id2ref(tvitem.lParam)) # delete old data
553
+ @owner._ar_data << dat
554
+ end
555
+ tvitem.lParam = dat.__id__
556
+ @owner.SendMessage(TVM_SETITEM, 0, tvitem)
557
+ else
558
+ @_data = dat
559
+ end
560
+ end
561
+
562
+ ############# Only for owner is alive ###############
563
+
564
+ # Sets the selection to this item.
565
+ def select()
566
+ @owner.SendMessage(TVM_SELECTITEM, TVGN_CARET, self.hitem)
567
+ self
568
+ end
569
+
570
+ # Expands the list of this item.
571
+ def expand()
572
+ @owner.SendMessage(TVM_EXPAND, TVE_EXPAND, self.hitem)
573
+ self
574
+ end
575
+
576
+ # Collapses the list of this item.
577
+ def fold()
578
+ @owner.SendMessage(TVM_EXPAND, TVE_COLLAPSE, self.hitem)
579
+ self
580
+ end
581
+
582
+ # Collapses the list if it is expanded or expands it if it is collapsed.
583
+ def toggle()
584
+ @owner.SendMessage(TVM_EXPAND, TVE_TOGGLE, self.hitem)
585
+ self
586
+ end
587
+
588
+ # Ensures that this tree-view item is visible, expanding the parent item or scrolling the tree-view control, if necessary.
589
+ def ensurevisible()
590
+ @owner.SendMessage(TVM_ENSUREVISIBLE, 0, self.hitem)
591
+ self
592
+ end
593
+
594
+ protected
595
+ def _tvitem()
596
+ lp = @_data.__id__
597
+ if (lp&1)==0 && lp>NilID
598
+ @owner._ar_data << @_data
599
+ end
600
+ TVITEM[TVIF_DEFAULT, nil, nil, nil, @_text , @_text.size, @_image, @_selimage, nil, lp]
601
+ end
602
+
603
+ def _cleanup()
604
+ @items.clear
605
+ @items = @_state = @_text = @_data = nil
606
+ GC.start
607
+ end
608
+ end # class Item
609
+
610
+
611
+ ####################### Main #####################
612
+
613
+ WinStyles = {
614
+ :hasbuttons => TVS_HASBUTTONS,
615
+ :haslines => TVS_HASLINES,
616
+ :linesatroot => TVS_LINESATROOT,
617
+ :editlabels => TVS_EDITLABELS,
618
+ :disabledragdrop => TVS_DISABLEDRAGDROP,
619
+ :showselalways => TVS_SHOWSELALWAYS,
620
+ :rtlreadings => TVS_RTLREADING,
621
+ :notooltips => TVS_NOTOOLTIPS,
622
+ :checkboxes => TVS_CHECKBOXES,
623
+ :trackselect => TVS_TRACKSELECT,
624
+ :singleexpand => TVS_SINGLEEXPAND,
625
+ :infotip => TVS_INFOTIP,
626
+ :fullrowselect => TVS_FULLROWSELECT,
627
+ :noscroll => TVS_NOSCROLL,
628
+ :nonevenheight => TVS_NONEVENHEIGHT,
629
+ :nohscroll => TVS_NOHSCROLL
630
+
631
+ # :default => TVS_DEFAULT
632
+ }
633
+ # def self.sym2style(*args) _sym2style(WinStyles, args); end
634
+
635
+ PreDefinedEvents = {
636
+ :click => [WM_NOTIFY, NM_CLICK, 'xs', NMHDR],
637
+ :dblclk => [WM_NOTIFY, NM_DBLCLK, 'xs', NMHDR],
638
+ :return => [WM_NOTIFY, NM_RETURN, 'xs', NMHDR],
639
+ :rclick => [WM_NOTIFY, NM_RCLICK, 'xs', NMHDR],
640
+ :rdblclk => [WM_NOTIFY, NM_RDBLCLK, 'xs', NMHDR],
641
+ :setfocus => [WM_NOTIFY, NM_SETFOCUS, 'xs', NMHDR],
642
+ :killfocus => [WM_NOTIFY, NM_KILLFOCUS, 'xs', NMHDR],
643
+ :customdraw => [WM_NOTIFY, NM_CUSTOMDRAW, 'xs', NMTVCUSTOMDRAW],
644
+ :releasedcapture => [WM_NOTIFY, NM_RELEASEDCAPTURE, 'xs', NMHDR],
645
+ :setcursor => [WM_NOTIFY, NM_SETCURSOR, 'xs', NMMOUSE],
646
+ :keydown => [WM_NOTIFY, TVN_KEYDOWN, 'xs', NMTVKEYDOWN],
647
+ :singleexpand => [WM_NOTIFY, TVN_SINGLEEXPAND, 'xs', NMTREEVIEW],
648
+ :selchanging => [WM_NOTIFY, TVN_SELCHANGING, 'xs', NMTREEVIEW],
649
+ :selchanged => [WM_NOTIFY, TVN_SELCHANGED, 'xs', NMTREEVIEW],
650
+ :getdispinfo => [WM_NOTIFY, TVN_GETDISPINFO, 'xs', NMTVDISPINFO],
651
+ :setdispinfo => [WM_NOTIFY, TVN_SETDISPINFO, 'xs', NMTVDISPINFO],
652
+ :itemexpanding => [WM_NOTIFY, TVN_ITEMEXPANDING, 'xs', NMTREEVIEW],
653
+ :itemexpanded => [WM_NOTIFY, TVN_ITEMEXPANDED, 'xs', NMTREEVIEW],
654
+ :begindrag => [WM_NOTIFY, TVN_BEGINDRAG, 'xs', NMTREEVIEW],
655
+ :beginrdrag => [WM_NOTIFY, TVN_BEGINRDRAG, 'xs', NMTREEVIEW],
656
+ :deleteitem => [WM_NOTIFY, TVN_DELETEITEM, 'xs', NMTREEVIEW],
657
+ :beginlabeledit => [WM_NOTIFY, TVN_BEGINLABELEDIT, 'xs', NMTVDISPINFO],
658
+ :endlabeledit => [WM_NOTIFY, TVN_ENDLABELEDIT, 'xs', NMTVDISPINFO],
659
+ :getinfotip => [WM_NOTIFY, TVN_GETINFOTIP, 'xs', NMTVGETINFOTIP]
660
+
661
+ # :hover => [WM_NOTIFY, NM_HOVER, 'xs', NMHDR]
662
+ }
663
+ DefaultEvents = [:selchanged]
664
+ DefaultWindowStyle = TVS_DEFAULT
665
+
666
+ attr_reader :root, :_ar_data
667
+
668
+ def initialize(*args)
669
+ super(*args)
670
+ @_classname = "SysTreeView32"
671
+ self.style |= DefaultWindowStyle
672
+ self.exstyle = WS_EX_CLIENTEDGE
673
+ @_acceptable_events = PreDefinedEvents.dup
674
+ @root = Item.new(self, nil)
675
+ @_ar_data = []
676
+ end
677
+ #
678
+ def create()
679
+ if @_parent.event_registered?(idcmd, WM_NOTIFY, TVN_DELETEITEM, "__deleteitem__", self)
680
+ @_parent.register_event(self.idcmd, WM_NOTIFY, TVN_DELETEITEM, "__deleteitem__", 'xs',
681
+ NMTREEVIEW, self) # for internal use
682
+ end
683
+ super
684
+ @root.hitem = TVGN_ROOT
685
+ @root.create_substance()
686
+ self.indent = @_indent if @_indent
687
+ self.imagelist = @_imglist if @_imglist
688
+ self.tooltip = @_tooltip if @_tooltip
689
+ self.itemhieght = @_itemhieght if @_itemhieght
690
+ self.bkcolor = @_bkcolor if @_bkcolor
691
+ self.textcolor = @_textcolor if @_textcolor
692
+ self.scrolltime = @_scrolltime if @_scrolltime
693
+ self.insertmarkcolor = @_imarkclr if @_imarkclr
694
+ self.linecolor = @_linecolor if @_linecolor
695
+ end
696
+
697
+ # Same as root[idx]
698
+ def [](idx)
699
+ self.root[idx]
700
+ end
701
+ # Same as root[idx, length=1]=args
702
+ def []=(idx, *args)
703
+ if args[0].is_a?(Integer)
704
+ n = args.shift
705
+ self.root[idx, n] = *args
706
+ else
707
+ self.root[idx, 1] = *args
708
+ end
709
+ end
710
+
711
+ # Same as root << arg
712
+ def <<(arg)
713
+ @root[@root.count, 0] = arg;
714
+ end
715
+
716
+ # Clears all items in this tree-view control.
717
+ def clear()
718
+ alive? ? SendMessage(TVM_DELETEITEM, 0, TVGN_ROOT) : @root.delete
719
+ self
720
+ end
721
+
722
+ # Retrieves the amount, in pixels, that child items are indented relative to their parent items.
723
+ def indent()
724
+ alive? ? SendMessage(TVM_GETINDENT, 0, 0) : @_indent
725
+ end
726
+ # Sets the width of indentation for this tree-view control.
727
+ def indent=(idt)
728
+ alive? ? SendMessage(TVM_SETINDENT, idt.to_i, 0) : @_indent = idt
729
+ end
730
+
731
+ # Retrieves the normal or state image list associated with this tree-view control.
732
+ def imagelist()
733
+ alive? ? APP.hrsc2ref(SendMessage(TVM_GETIMAGELIST, 0, 0))||nil : @_imglist
734
+ end
735
+ # Sets the normal or state image list for this tree-view control.
736
+ def imagelist=(il)
737
+ il = Imagelist.loadb64(il) if il.is_a?(String)
738
+ alive? ? SendMessage(TVM_SETIMAGELIST,0,il._himagelist) : @_imglist=il
739
+ end
740
+
741
+ # Retrieves the child tooltip control used by this tree-view control.
742
+ def tooltip()
743
+ alive? ? APP.hwnd2ref(SendMessage(TVM_GETTOOLTIPS, 0, 0))||nil : @_tooltip
744
+ end
745
+ # Sets the child tooltip control used by this tree-view control.
746
+ def tooltip=(tt)
747
+ alive? ? SendMessage(TVM_SETTOOLTIPS, 0, tt.hWnd) : @_tooltip=tt
748
+ end
749
+
750
+ # Retrieves the current height of the each tree-view item.
751
+ def itemheight()
752
+ alive? ? SendMessage(TVM_GETITEMHEIGHT, 0, 0) : @_itemhieght
753
+ end
754
+ # Sets the height of this tree-view items.
755
+ def itemheight=(h)
756
+ alive? ? SendMessage(TVM_SETITEMHEIGHT, h, 0) : @_itemheight=h
757
+ end
758
+
759
+ # Retreives the background color of this tree-view control.
760
+ def bkcolor()
761
+ alive? ? SendMessage(TVM_GETBKCOLOR, 0, 0) : @_bkcolor
762
+ end
763
+ # Sets the background color of this tree-view control.
764
+ def bkcolor=(clr)
765
+ alive? ? SendMessage(TVM_SETBKCOLOR, 0, clr) : @_bkcolor=clr
766
+ end
767
+
768
+ # Retreives the text color of this tree-view control.
769
+ def textcolor()
770
+ alive? ? SendMessage(TVM_GETTEXTCOLOR, 0, 0) : @_textcolor
771
+ end
772
+ # Sets the text color of this tree-view control.
773
+ def textcolor=(clr)
774
+ alive? ? SendMessage(TVM_SETTEXTCOLOR, 0, clr) : @_textcolor=clr
775
+ end
776
+
777
+ # Retrieves the maximum scroll time for this tree-view control.
778
+ def scrollteime()
779
+ alive? ? SendMessage(TVM_GETSCROLLTIME, 0, 0) : @_scrolltime
780
+ end
781
+ # Sets the maximum scroll time for this tree-view control.
782
+ def scrollteime=(t)
783
+ alive? ? SendMessage(TVM_SETSCROLLTIME, t, 0) : @_scrolltime=t
784
+ end
785
+
786
+ # Retrieves the color used to draw the insertion mark for this tree view.
787
+ def insertmarkcolor()
788
+ alive? ? SendMessage(TVM_GETINSERTMARKCOLOR, 0, 0) : @_imarkclr
789
+ end
790
+ # Sets the color used to draw the insertion mark for this tree view.
791
+ def insertmarkcolor=(c)
792
+ alive? ? SendMessage(TVM_SETINSERTMARKCOLOR,0,c) : @_imarkclr=c
793
+ end
794
+ # Retreives the current line color.
795
+ def linecolor()
796
+ alive? ? SendMessage(TVM_GETLINECOLOR, 0, 0) : @_linecolor
797
+ end
798
+ # Sets the current line color.
799
+ def linecolor=(clr)
800
+ alive? ? SendMessage(TVM_SETLINECOLOR, 0, clr) : @_linecolor=clr
801
+ end
802
+
803
+ # Retreives a current selected item.
804
+ def selection()
805
+ hitem = SendMessage(TVM_GETNEXTITEM, TVGN_CARET, 0)
806
+ hitem==0 ? nil : Item.new(self, hitem)
807
+ end
808
+
809
+ # Determines the location of the specified coordinates of this tree-view control.
810
+ def hittest(x, y)
811
+ hi = TVHITTESTINFO.new
812
+ hi.pt.x = x
813
+ hi.pt.y = y
814
+ SendMessage(TVM_HITTEST, 0, hi)==0 ? nil : hitem2ref(hi.hItem)
815
+ end
816
+
817
+ # Retreives a Treeview::Item associated to the handle of item.
818
+ def hitem2ref(hitem)
819
+ hitem==0 ? nil : Item.new(self, hitem)
820
+ end
821
+
822
+ # Same as root.each{|item| ... }
823
+ def each()
824
+ root.each{|i| yield i}
825
+ end
826
+
827
+ protected
828
+ def _apply_options(arg)
829
+ if st = WinStyles[arg]
830
+ self.style |= st
831
+ return nil
832
+ end
833
+ super
834
+ end
835
+
836
+ private
837
+ def __deleteitem__(nmtreeview)
838
+ return unless @_ar_data # recycled?
839
+ data = ObjectSpace._id2ref(nmtreeview.itemOld.lParam) rescue nil
840
+ if data && n = @_ar_data.index(data) #; dp "@%p, %p, %p", data, n, @_ar_data
841
+ @_ar_data.delete_at(n)
842
+ end
843
+ end
844
+ end
845
+ end