wrb 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
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,140 @@
1
+ # Progress Bar
2
+ # see <https://msdn.microsoft.com/en-us/library/windows/desktop/bb760818%28v=vs.85%29.aspx>
3
+
4
+ #require 'wrb/commctrl'
5
+ require 'wrb'
6
+ require 'wrb/commctrlconst'
7
+
8
+ module WR
9
+ module RC
10
+ PBS_SMOOTH = 0x1
11
+ PBS_VERTICAL = 0x4
12
+
13
+ PBM_SETRANGE = WM_USER+1
14
+ PBM_SETPOS = WM_USER+2
15
+ PBM_DELTAPOS = WM_USER+3
16
+ PBM_SETSTEP = WM_USER+4
17
+ PBM_STEPIT = WM_USER+5
18
+ PBM_SETRANGE32 = WM_USER+6
19
+ PBM_GETRANGE = WM_USER+7
20
+ PBM_GETPOS = WM_USER+8
21
+ PBM_SETBARCOLOR = WM_USER+9
22
+ PBM_SETMARQUEE = WM_USER+10
23
+ PBM_SETBKCOLOR = CCM_SETBKCOLOR
24
+
25
+
26
+ #if (_WIN32_WINNT >= 0x0600)
27
+ PBS_MARQUEE = 0x8
28
+ PBS_SMOOTHREVERSE = 0x10
29
+
30
+ PBM_GETSTEP = WM_USER+13
31
+ PBM_GETBKCOLOR = WM_USER+14
32
+ PBM_GETBARCOLOR = WM_USER+15
33
+ PBM_SETSTATE = WM_USER+16
34
+ PBM_GETSTATE = WM_USER+17
35
+
36
+ PBST_NORMAL = 1
37
+ PBST_ERROR = 2
38
+ PBST_PAUSED = 3
39
+ #endif /* (_WIN32_WINNT >= 0x0600) */
40
+ end
41
+
42
+ # A window that an application can use to indicate the progress of a lengthy operation.
43
+ # <br>See also <a href="https://docs.microsoft.com/en-us/windows/desktop/Controls/
44
+ # window-controls"> Windows Control section of Microsoft Docs.</a>
45
+ class Progressbar < WinControl #CommonControl
46
+ PBRANGE = API.defstruct "
47
+ int iLow;
48
+ int iHigh;"
49
+
50
+ WinStyles = {
51
+ :smooth => PBS_SMOOTH,
52
+ :vertical => PBS_VERTICAL,
53
+ :marquee => PBS_MARQUEE,
54
+ :smoothreverse => PBS_SMOOTHREVERSE
55
+ }
56
+ PreDefinedEvents = {}
57
+
58
+ # def self.sym2style(*args) _sym2style(WinStyles, args); end
59
+
60
+ def initialize(*args)
61
+ super
62
+ @_classname = "msctls_progress32"
63
+ @_acceptable_events = PreDefinedEvents.dup
64
+ end
65
+ #
66
+ def create()
67
+ super
68
+ self.range = @_range if @_range
69
+ self.pos = @_pos if @_pos
70
+ self.barcolor = @_barcolor if @_barcolor
71
+ self.bkcolor = @_bkcolor if @_bkcolor
72
+ end
73
+
74
+ # Retrieves information about the current high and low limits of this progress bar control.
75
+ def range()
76
+ if alive?
77
+ SendMessage(PBM_GETRANGE, 0, range=PBRANGE.new)
78
+ range.to_a
79
+ else
80
+ @_range
81
+ end
82
+ end
83
+ # range=([low,] high)
84
+ # Sets the minimum and maximum values for this progress bar.
85
+ def range=(*args)
86
+ lo, hi = args[0].is_a?(Array) ? args[0] : [0, args[0]]
87
+ alive? ? SendMessage(PBM_SETRANGE, 0, MAKELPARAM(lo, hi)) : @_range = [lo, hi]
88
+ end
89
+
90
+ # Gets the current position for this progress bar.
91
+ def pos()
92
+ alive? ? SendMessage(PBM_GETPOS, 0, 0) : @_pos
93
+ end
94
+ # Sets the specified position for this progress bar.
95
+ def pos=(ps)
96
+ alive? ? SendMessage(PBM_SETPOS, ps.to_i, 0) : @_pos = ps
97
+ end
98
+
99
+ # Retrieves the step increment for this progress bar.
100
+ def step
101
+ alive? ? SendMessage(PBM_GETSTEP, 0, 0) : @_step
102
+ end
103
+ # Specifies the step increment for this progress bar.
104
+ def step=(stp)
105
+ alive? ? SendMessage(PBM_SETSTEP, stp, 0) : @_step = stp
106
+ end
107
+ # Advances the current position for this progress bar by the step increment.
108
+ def step!()
109
+ SendMessage(PBM_STEPIT, 0, 0)
110
+ end
111
+
112
+ # Sets/Unsets the marquee style for this progress bar.
113
+ def marquee=(f)
114
+ f ? self.style |= PBS_MARQUEE : self.style &= ~PBS_MARQUEE
115
+ end
116
+
117
+ # Sets the progress bar to marquee mode.
118
+ def marquee!(time=0)
119
+ sw = time ? 1 : 0
120
+ SendMessage(PBM_SETMARQUEE, sw, time.to_i)
121
+ end
122
+
123
+ # When visual styles are enabled, this method has no effect
124
+ def barcolor=(clr)
125
+ alive? ? SendMessage(PBM_SETBARCOLOR, 0, clr) : @_barcolor=clr
126
+ end
127
+ # When visual styles are enabled, this method has no effect
128
+ def bkcolor=(clr)
129
+ alive? ? SendMessage(PBM_SETBKCOLOR, 0, clr) : @_bkcolor=clr
130
+ end
131
+
132
+ protected
133
+ def _apply_options(arg)
134
+ if st=WinStyles[arg]
135
+ self.style |= st
136
+ end
137
+ super
138
+ end
139
+ end
140
+ end
@@ -0,0 +1,49 @@
1
+ module WR
2
+ require_relative './button' unless defined? Button
3
+
4
+ # This control consists of a round button that indicates a choice the user can make by selecting the button.
5
+ # <br>See also <a href="https://docs.microsoft.com/en-us/windows/desktop/Controls/
6
+ # window-controls"> Windows Control section of Microsoft Docs.</a>
7
+ class Radiobutton < Button
8
+ DefaultWindowStyle = BS_AUTORADIOBUTTON
9
+
10
+ # def self.sym2style(*args)
11
+ # _sym2style(Button::WinStyles, args)
12
+ # end
13
+
14
+ def initialize(*args)
15
+ super
16
+ @_style |= DefaultWindowStyle
17
+ end
18
+
19
+ # Following Radiobutton styles are available.
20
+ def style=(st)
21
+ st |= DefaultWindowStyle if st & BS_TYPEMASK == 0
22
+ super st
23
+ end
24
+
25
+ # Any other Button's style changes this style to other. So, do not use except following.
26
+ WinStyles = {
27
+ :lefttext => BS_LEFTTEXT,
28
+ :rightbutton => BS_RIGHTBUTTON,
29
+ }
30
+
31
+ #
32
+ def create()
33
+ super
34
+ self.checked = @_checked if @_checked
35
+ end
36
+
37
+ # Retreives check state of the control. <br> Retuens true/false.
38
+ def checked()
39
+ alive? ? (SendMessage(BM_GETCHECK, 0, 0) == 0 ? false : true) : @_checked
40
+ end
41
+ alias checked? checked
42
+
43
+ # Sets a check-state of the control. <br> Give an integer as state.
44
+ def checked=(state)
45
+ alive? ? SendMessage(BM_SETCHECK, state ? 1 : 0, 0) : @_checked = state
46
+ end
47
+ end
48
+ end
49
+
@@ -0,0 +1,830 @@
1
+ require 'wrb'
2
+ require 'wrb/commctrlconst'
3
+
4
+ module WR
5
+ module RC
6
+ RBSTR_CHANGERECT = 0x1
7
+
8
+ RBS_TOOLTIPS = 0x100 # Not implemented yet in comctl.dll ver 6
9
+ RBS_VARHEIGHT = 0x200
10
+ RBS_BANDBORDERS = 0x400
11
+ RBS_FIXEDORDER = 0x800
12
+ RBS_REGISTERDROP = 0x1000
13
+ RBS_AUTOSIZE = 0x2000
14
+ RBS_VERTICALGRIPPER = 0x4000
15
+ RBS_DBLCLKTOGGLE = 0x8000
16
+
17
+ RBIM_IMAGELIST = 0x1
18
+
19
+ RBBS_BREAK = 0x1
20
+ RBBS_FIXEDSIZE = 0x2
21
+ RBBS_CHILDEDGE = 0x4
22
+ RBBS_HIDDEN = 0x8
23
+ RBBS_NOVERT = 0x10
24
+ RBBS_FIXEDBMP = 0x20
25
+ RBBS_VARIABLEHEIGHT = 0x40
26
+ RBBS_GRIPPERALWAYS = 0x80
27
+ RBBS_NOGRIPPER = 0x100
28
+ RBBS_USECHEVRON = 0x200
29
+ RBBS_HIDETITLE = 0x400
30
+ RBBS_TOPALIGN = 0x800
31
+
32
+ RBBIM_STYLE = 0x1
33
+ RBBIM_COLORS = 0x2
34
+ RBBIM_TEXT = 0x4
35
+ RBBIM_IMAGE = 0x8
36
+ RBBIM_CHILD = 0x10
37
+ RBBIM_CHILDSIZE = 0x20
38
+ RBBIM_SIZE = 0x40
39
+ RBBIM_BACKGROUND = 0x80
40
+ RBBIM_ID = 0x100
41
+ RBBIM_IDEALSIZE = 0x200
42
+ RBBIM_LPARAM = 0x400
43
+ RBBIM_HEADERSIZE = 0x800
44
+ RBBIM_DEFAULT = RBBIM_TEXT | RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE |
45
+ RBBIM_ID #RBBIM_LPARAM # | RBBIM_IMAGE
46
+
47
+ RB_INSERTBANDA = WM_USER+1
48
+ RB_DELETEBAND = WM_USER+2
49
+ RB_GETBARINFO = WM_USER+3
50
+ RB_SETBARINFO = WM_USER+4
51
+ RB_SETBANDINFOA = WM_USER+6
52
+ RB_SETPARENT = WM_USER+7
53
+ RB_HITTEST = WM_USER+8
54
+ RB_GETRECT = WM_USER+9
55
+ RB_INSERTBANDW = WM_USER+10
56
+ RB_SETBANDINFOW = WM_USER+11
57
+ RB_GETBANDCOUNT = WM_USER+12
58
+ RB_GETROWCOUNT = WM_USER+13
59
+ RB_GETROWHEIGHT = WM_USER+14
60
+ RB_IDTOINDEX = WM_USER+16
61
+ RB_GETTOOLTIPS = WM_USER+17
62
+ RB_SETTOOLTIPS = WM_USER+18
63
+ RB_SETBKCOLOR = WM_USER+19
64
+ RB_GETBKCOLOR = WM_USER+20
65
+ RB_SETTEXTCOLOR = WM_USER+21
66
+ RB_GETTEXTCOLOR = WM_USER+22
67
+ RB_SIZETORECT = WM_USER+23
68
+ RB_SETCOLORSCHEME = CCM_SETCOLORSCHEME
69
+ RB_GETCOLORSCHEME = CCM_GETCOLORSCHEME
70
+ RB_BEGINDRAG = WM_USER+24
71
+ RB_ENDDRAG = WM_USER+25
72
+ RB_DRAGMOVE = WM_USER+26
73
+ RB_GETBARHEIGHT = WM_USER+27
74
+ RB_GETBANDINFOW = WM_USER+28
75
+ RB_GETBANDINFOA = WM_USER+29
76
+ RB_MINIMIZEBAND = WM_USER+30
77
+ RB_MAXIMIZEBAND = WM_USER+31
78
+ RB_GETDROPTARGET = CCM_GETDROPTARGET
79
+ RB_GETBANDBORDERS = WM_USER+34
80
+ RB_SHOWBAND = WM_USER+35
81
+ RB_SETPALETTE = WM_USER+37
82
+ RB_GETPALETTE = WM_USER+38
83
+ RB_MOVEBAND = WM_USER+39
84
+ RB_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT
85
+ RB_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT
86
+ RB_GETBANDMARGINS = WM_USER+40
87
+ RB_SETWINDOWTHEME = CCM_SETWINDOWTHEME
88
+ RB_PUSHCHEVRON = WM_USER+43
89
+
90
+ if RWin::UNICODE
91
+ RB_INSERTBAND = RB_INSERTBANDW
92
+ RB_GETBANDINFO = RB_GETBANDINFOW
93
+ RB_SETBANDINFO = RB_SETBANDINFOW
94
+ else
95
+ RB_INSERTBAND = RB_INSERTBANDA
96
+ RB_GETBANDINFO = RB_GETBANDINFOA
97
+ RB_SETBANDINFO = RB_SETBANDINFOA
98
+ end
99
+
100
+ RBN_FIRST = -831
101
+ RBN_HEIGHTCHANGE = RBN_FIRST - 0
102
+ RBN_GETOBJECT = RBN_FIRST - 1
103
+ RBN_LAYOUTCHANGED = RBN_FIRST - 2
104
+ RBN_AUTOSIZE = RBN_FIRST - 3
105
+ RBN_BEGINDRAG = RBN_FIRST - 4
106
+ RBN_ENDDRAG = RBN_FIRST - 5
107
+ RBN_DELETINGBAND = RBN_FIRST - 6
108
+ RBN_DELETEDBAND = RBN_FIRST - 7
109
+ RBN_CHILDSIZE = RBN_FIRST - 8
110
+ RBN_CHEVRONPUSHED = RBN_FIRST - 10
111
+ RBN_MINMAX = RBN_FIRST - 21
112
+ RBN_AUTOBREAK = RBN_FIRST - 22
113
+
114
+ RBAB_AUTOSIZE = 0x1
115
+ RBAB_ADDBAND = 0x2
116
+
117
+ RBHT_NOWHERE = 0x1
118
+ RBHT_CAPTION = 0x2
119
+ RBHT_CLIENT = 0x3
120
+ RBHT_GRABBER = 0x4
121
+ RBHT_CHEVRON = 0x8
122
+ end
123
+
124
+ #This control acts as a container for child windows.<br>
125
+ # <br>See also <a href="https://docs.microsoft.com/en-us/windows/desktop/Controls/
126
+ # window-controls"> Windows Control section of Microsoft Docs.</a>
127
+ class Rebar < WinControl
128
+
129
+ RBNM_ID = 0x1
130
+ RBNM_STYLE = 0x2
131
+ RBNM_LPARAM = 0x4
132
+
133
+ NMREBARCHILDSIZE = API.defstruct "
134
+ NMHDR hdr;
135
+ UINT uBand;
136
+ UINT wID;
137
+ RECT rcChild;
138
+ RECT rcBand;"
139
+
140
+ NMREBAR = API.defstruct "
141
+ NMHDR hdr;
142
+ DWORD dwMask;
143
+ UINT uBand;
144
+ UINT fStyle;
145
+ UINT wID;
146
+ LPARAM lParam;"
147
+
148
+ NMRBAUTOSIZE = API.defstruct "
149
+ NMHDR hdr;
150
+ BOOL fChanged;
151
+ RECT rcTarget;
152
+ RECT rcActual;"
153
+
154
+ NMREBARCHEVRON = API.defstruct "
155
+ NMHDR hdr;
156
+ UINT uBand;
157
+ UINT wID;
158
+ LPARAM lParam;
159
+ RECT rc;
160
+ LPARAM lParamNM;"
161
+
162
+ NMREBARAUTOBREAK = API.defstruct "
163
+ NMHDR hdr;
164
+ UINT uBand;
165
+ UINT wID;
166
+ LPARAM lParam;
167
+ UINT uMsg;
168
+ UINT fStyleCurrent;
169
+ BOOL fAutoBreak;"
170
+
171
+ RB_HITTESTINFO = API.defstruct "
172
+ POINT pt;
173
+ UINT flags;
174
+ int iBand;"
175
+
176
+ REBARINFO = API.defstruct "
177
+ UINT cbSize;
178
+ UINT fMask;
179
+ HANDLE himl;"
180
+
181
+ REBARBANDINFO = API.defstruct "
182
+ UINT cbSize;
183
+ UINT fMask;
184
+ UINT fStyle;
185
+ COLORREF clrFore;
186
+ COLORREF clrBack;
187
+ LPTSTR lpText;
188
+ UINT cch;
189
+ int iImage;
190
+ HWND hwndChild;
191
+ UINT cxMinChild;
192
+ UINT cyMinChild;
193
+ UINT cx;
194
+ HBITMAP hbmBack;
195
+ UINT wID;
196
+ UINT cyChild;
197
+ UINT cyMaxChild;
198
+ UINT cyIntegral;
199
+ UINT cxIdeal;
200
+ LPARAM lParam;
201
+ UINT cxHeader;"
202
+
203
+ class Band # wrapper of REBARBANDINFO and holder of its index
204
+ include RC
205
+ RbbStyles = {
206
+ :break => RBBS_BREAK,
207
+ :fixedsize => RBBS_FIXEDSIZE,
208
+ :childedge => RBBS_CHILDEDGE,
209
+ :hidden => RBBS_HIDDEN,
210
+ :novert => RBBS_NOVERT,
211
+ :fixedbmp => RBBS_FIXEDBMP,
212
+ :variableheight => RBBS_VARIABLEHEIGHT,
213
+ :gripperalways => RBBS_GRIPPERALWAYS,
214
+ :nogripper => RBBS_NOGRIPPER,
215
+ :usechevron => RBBS_USECHEVRON,
216
+ :hidetitle => RBBS_HIDETITLE,
217
+ :topalign => RBBS_TOPALIGN,
218
+ }
219
+
220
+ def self.[](*args) self.new(*args); end
221
+
222
+ attr_reader :owner, :idcmd
223
+
224
+ def initialize(*args) # [owner, index] or [[owner], childwin, iimage, text, xsize, style
225
+ # dp "@%p", args
226
+ @owner = args.shift if args[0].is_a?(Rebar)
227
+ if args.size == 1 && args[0].is_a?(Integer)
228
+ @index = args[0]
229
+ @bandinfo = REBARBANDINFO[REBARBANDINFO::Size]
230
+ return
231
+ end
232
+ raise ArgumentError, "1st argument must be Symbol" unless args[0].is_a?(Symbol)
233
+ hsh = args.pop if args.last.is_a?(Hash)
234
+ @name = args.shift
235
+ if @owner
236
+ @idcmd = @owner.new_control_id
237
+ @owner._add_accessor(@idcmd, @name)
238
+ end
239
+ @style = 0
240
+ while args.last.is_a?(Symbol)
241
+ @style |= RbbStyles[args.pop].to_i
242
+ end
243
+ # dpp args.last
244
+ if args.last.is_a?(Window) #|| args.last.is_a?(Array)
245
+ @childwin = args.pop
246
+ class << @childwin
247
+ attr_accessor :__associated_band_id
248
+ end
249
+ @childwin.__associated_band_id = @idcmd
250
+ raise ArgumentError, "Child Window not found." if !@childwin.is_a?(RWin::Window) && !(@childwin.is_a?(Array) && @childwin[0]<RWin::Window)
251
+ @owner.controls << @childwin
252
+ end
253
+
254
+ @iimage, @text, @_cx, style = args
255
+ @_cxideal = @cx
256
+ # dpp @iimage, @text, @_cx, style, @style
257
+ @style |= style.to_i
258
+ hsh.each{|k, v| __send__(k.to_s + "=", v)} if hsh
259
+ @mask = RBBIM_DEFAULT
260
+ @mask |= RBBIM_IMAGE if @iimage
261
+ end
262
+
263
+ def owner=(tgt)
264
+ raise "owner was already asigned" if @owner
265
+ @owner = tgt;
266
+ @idcmd = @owner.new_control_id
267
+ @owner._add_accessor(@idcmd, @name)
268
+ @childwin.parent = @owner #; dp "@%p", @owner
269
+ end
270
+
271
+ def idcmd()
272
+ if @owner.alive?
273
+ @bandinfo.fMask = RBBIM_ID
274
+ @owner.SendMessage(RB_GETBANDINFO, @index, @bandinfo)
275
+ @bandinfo.wID
276
+ else
277
+ @idcmd
278
+ end
279
+ end
280
+
281
+ def name()
282
+ id = idcmd
283
+ (r = @owner._accessors.find{|k, v| v==id}) && r[0]
284
+ end
285
+ def name=(nm)
286
+ @owner._delete_accessor(name)
287
+ @owner._add_accessor(idcmd, nm)
288
+ end
289
+
290
+ def delete()
291
+ @owner.delete(@index)
292
+ end
293
+
294
+ def style()
295
+ if @owner.alive?
296
+ @bandinfo.fMask = RBBIM_STYLE
297
+ @owner.SendMessage(RB_GETBANDINFO, @index, @bandinfo)
298
+ @bandinfo.fStyle
299
+ else
300
+ @style
301
+ end
302
+ end
303
+ def style=(*args) #; dp "@%p", args
304
+ args = args[0] if args[0].is_a?(Array)
305
+ st = 0
306
+ while args.last.is_a?(Symbol)
307
+ st |= RbbStyles[args.pop].to_i
308
+ end
309
+ st |= args[0].to_i
310
+ if @owner.alive?
311
+ @bandinfo.fMask = RBBIM_STYLE
312
+ @bandinfo.fStyle = st
313
+ @owner.SendMessage(RB_SETBANDINFO, @index, @bandinfo)
314
+ else
315
+ @style = st
316
+ end
317
+ end
318
+
319
+ def childwin()
320
+ if @owner.alive?
321
+ @bandinfo.fMask = RBBIM_CHILD
322
+ @owner.SendMessage(RB_GETBANDINFO, @index, @bandinfo)
323
+ APP.hwnd2ref(@bandinfo.hwndChild)
324
+ else
325
+ @childwin
326
+ end
327
+ end
328
+ def childwin=(newchild)
329
+ if @owner.alive?
330
+ childwin.delete if childwin
331
+ class << newchild
332
+ attr_accessor :__associated_band_id
333
+ end
334
+ newchild.__associated_band_id = idcmd
335
+ @owner.controls << newchild
336
+ @bandinfo.hwndChild = newchild._hwnd
337
+ @bandinfo.cxMinChild = newchild.w
338
+ @bandinfo.cyMinChild = newchild.h
339
+ @bandinfo.fMask = RBBIM_CHILD | RBBIM_CHILDSIZE
340
+ @owner.SendMessage(RB_SETBANDINFO, @index, @bandinfo)
341
+ else
342
+ @childwin.delete
343
+ @chilewin = (@owner.controls << newchild)
344
+ end
345
+ end
346
+
347
+ def text()
348
+ if @owner.alive?
349
+ @bandinfo.fMask = RBBIM_TEXT
350
+ @bandinfo.lpText = TCHAR[256]
351
+ @bandinfo.cch = 256
352
+ @owner.SendMessage(RB_GETBANDINFO, @index, @bandinfo)
353
+ @bandinfo.lpText.to_s
354
+ else
355
+ @text
356
+ end
357
+ end
358
+ alias caption text
359
+ def text=(txt)
360
+ if @owner.alive?
361
+ @bandinfo.fMask = RBBIM_TEXT
362
+ @bandinfo.lpText = txt
363
+ @bandinfo.cch = txt.size
364
+ @owner.SendMessage(RB_SETBANDINFO, @index, @bandinfo)
365
+ else
366
+ @text = txt
367
+ end
368
+ end
369
+ alias caption= text=
370
+
371
+ def iimage()
372
+ if @owner.alive?
373
+ @bandinfo.fMask = RBBIM_IMAGE
374
+ @owner.SendMessage(RB_GETBANDINFO, @index, @bandinfo)
375
+ @bandinfo.iImage
376
+ else
377
+ @iimage
378
+ end
379
+ end
380
+ def iimage=(img)
381
+ if @owner.alive?
382
+ @bandinfo.fMask = RBBIM_IMAGE
383
+ @bandinfo.iImage = img
384
+ @owner.SendMessage(RB_SETBANDINFO, @index, @bandinfo)
385
+ else
386
+ @iimage = img
387
+ end
388
+ end
389
+
390
+ def data()
391
+ if @owner.alive?
392
+ @bandinfo.fMask = RBBIM_LPARAM
393
+ @owner.SendMessage(RB_GETBANDINFO, @index, @bandinfo)
394
+ ObjectSpace._id2ref(@bandinfo.lParam)
395
+ else
396
+ @data
397
+ end
398
+ end
399
+ def data=(dtnew)
400
+ if @owner.alive?
401
+ dtold = self.data
402
+ if idx=@owner._ar_data.index(dtold)
403
+ @owner._ar_data.delete_at(idx)
404
+ end
405
+ lparam = dtnew.__id__
406
+ @owner._ar_data << @data if (lparam&1)==0 && lparam>NilID
407
+ @bandinfo.fMask = RBBIM_LPARAM
408
+ @bandinfo.lParam = lparam
409
+ @owner.SendMessage(RB_SETBANDINFO, @index, @bandinfo)
410
+ else
411
+ @data = dtnew
412
+ end
413
+ end
414
+
415
+ def color()
416
+ if @owner.alive?
417
+ @bandinfo.fMask = RBBIM_COLORS
418
+ @owner.SendMessage(RB_GETBANDINFO, @index, @bandinfo)
419
+ [@bandinfo.clrFore, @bandinfo.clrBack]
420
+ else
421
+ [@_forecolor, @_backcolor]
422
+ end
423
+ end
424
+ def color=(*clrs)
425
+ fore, back = clrs[0]
426
+ if @owner.alive?
427
+ @bandinfo.fMask = RBBIM_COLORS
428
+ @owner.SendMessage(RB_GETBANDINFO, @index, @bandinfo)
429
+ @bandinfo.clrFore = fore if fore
430
+ @bandinfo.clrBack = back if back
431
+ @owner.SendMessage(RB_SETBANDINFO, @index, @bandinfo)
432
+ else
433
+ @mask |= RBBIM_COLORS
434
+ @_forecolor = fore
435
+ @_backcolor = back
436
+ end
437
+ end
438
+ def forecolor() self.color[0]; end
439
+ def forecolor=(clr) self.color = clr; end
440
+ def backcolor() self.color[1]; end
441
+ def backcolor=(clr) self.color = nil, clr; end
442
+
443
+ def bitmap()
444
+ if @owner.alive?
445
+ @bandinfo.fMask = RBBIM_BACKGROUND
446
+ @owner.SendMessage(RB_GETBANDINFO, @index, @bandinfo)
447
+ APP.hrsc2ref(@bandinfo.hbmBack)
448
+ else
449
+ @_bitmap
450
+ end
451
+ end
452
+ def bitmap=(bmp)
453
+ bmp = WR::Bitmap.loadb64(bmp) if bmp.is_a?(String)
454
+ if !bmp.is_a?(RWin::Bitmap)
455
+ raise ArgumentError, "Argument must be RWin::Bitmap"
456
+ end
457
+
458
+ if @owner.alive?
459
+ @bandinfo.fMask = RBBIM_BACKGROUND
460
+ @bandinfo.hbmBack = bmp._hddbitmap
461
+ @owner.SendMessage(RB_SETBANDINFO, @index, @bandinfo)
462
+ else
463
+ @mask |= RBBIM_BACKGROUND
464
+ @_bitmap = bmp
465
+ end
466
+ end
467
+
468
+ def size()
469
+ if @owner.alive?
470
+ @bandinfo.fMask = RBBIM_SIZE
471
+ @owner.SendMessage(RB_GETBANDINFO, @index, @bandinfo)
472
+ @bandinfo.cx
473
+ else
474
+ @_cx
475
+ end
476
+ end
477
+ def size=(len)
478
+ if @owner.alive?
479
+ @bandinfo.fMask = RBBIM_SIZE
480
+ @bandinfo.cx = len
481
+ @owner.SendMessage(RB_SETBANDINFO, @index, @bandinfo)
482
+ else
483
+ @mask |= RBBIM_SIZE
484
+ @_cx = len
485
+ end
486
+ end
487
+
488
+ def idealsize
489
+ if @owner.alive?
490
+ @bandinfo.fMask = RBBIM_IDEALSIZE
491
+ @owner.SendMessage(RB_GETBANDINFO, @index, @bandinfo)
492
+ @bandinfo.cxIdeal
493
+ else
494
+ @_cxideal
495
+ end
496
+ end
497
+ def idealsize=(len)
498
+ if @owner.alive?
499
+ @bandinfo.fMask = RBBIM_IDEALSIZE
500
+ @bandinfo.cxIdeal = len
501
+ @owner.SendMessage(RB_SETBANDINFO, @index, @bandinfo)
502
+ else
503
+ @mask |= RBBIM_IDEALSIZE
504
+ @_cxideal = len
505
+ end
506
+ end
507
+
508
+ def minchildsize()
509
+ if @owner.alive?
510
+ @bandinfo.fMask = RBBIM_CHILDSIZE
511
+ @owner.SendMessage(RB_GETBANDINFO, @index, @bandinfo)
512
+ @bandinfo.cxMinChild
513
+ else
514
+ @_cxminchild
515
+ end
516
+ end
517
+ def minchildsize=(len)
518
+ if @owner.alive?
519
+ @bandinfo.fMask = RBBIM_CHILDSIZE
520
+ @bandinfo.cxMinChild = len
521
+ @owner.SendMessage(RB_SETBANDINFO, @index, @bandinfo)
522
+ else
523
+ @mask |= RBBIM_CHILDSIZE
524
+ @_cxminchild = len
525
+ end
526
+ end
527
+
528
+ def rect
529
+ @owner.SendMessage(RB_GETRECT, @index, rc=RECT.new)
530
+ rc
531
+ end
532
+
533
+ def _rebarbandinfo() #; dpp @text, @style
534
+ bandinfo = REBARBANDINFO[REBARBANDINFO::Size, @mask]
535
+ bandinfo.fStyle = ((@style==0) ? RBBS_CHILDEDGE : @style)
536
+ if @text
537
+ bandinfo.lpText = @text
538
+ bandinfo.cch = @text.size
539
+ end
540
+ if @childwin
541
+ @childwin.create if !@childwin.alive?
542
+ bandinfo.hwndChild = @childwin._hwnd
543
+ bandinfo.cxMinChild = @childwin.w
544
+ bandinfo.cyMinChild = @childwin.h
545
+ end
546
+ bandinfo.iImage = @iimage if @iimage
547
+ bandinfo.wID = @idcmd
548
+ if (@mask & RBBIM_COLORS) > 0
549
+ bandinfo.clrFore = @_forecolor || @owner.SendMessage(RB_GETTEXTCOLOR, 0, 0)
550
+ bandinfo.clrBack = @_backcolor || @owner.SendMessage(RB_GETBKCOLOR, 0, 0)
551
+ end
552
+ bandinfo.hbmBack = @_bitmap._hddbitmap(@owner) if @_bitmap
553
+ bandinfo.cx = @_cx if @_cx
554
+ bandinfo.cxIdeal = @_cxideal if @_cxideal
555
+ bandinfo.cxMinChild = @_cxminchild if @_cxminchild
556
+
557
+ lparam = @data.__id__
558
+ @owner._ar_data << @data if (lparam&1)==0 && lparam>NilID
559
+ bandinfo.lParam = lparam
560
+ bandinfo
561
+ end
562
+ end # class Band
563
+
564
+ ########################## Main ########################
565
+ include ModCommCtrl
566
+ include ModParent
567
+ include ModAccessor
568
+
569
+ WinStyles = {
570
+ :varheight => RBS_VARHEIGHT,
571
+ :bandborders => RBS_BANDBORDERS,
572
+ :fixedorder => RBS_FIXEDORDER,
573
+ :registerdrop => RBS_REGISTERDROP,
574
+ :autosize => RBS_AUTOSIZE,
575
+ :verticalgripper => RBS_VERTICALGRIPPER,
576
+ :dblclktoggle => RBS_DBLCLKTOGGLE
577
+ # :tooltips => RBS_TOOLTIPS, # Not impremented yet in comctl.dll ver 6
578
+ }
579
+ DefaultWindowStyle = CCS_TOP
580
+ # def self.sym2style(*args) _sym2style(WinStyles, args); end
581
+
582
+ # RBNBandTemplate = 'x' + NMREBAR.to_template(:uBand, :wID)
583
+ # RBNChevronTtemplate = 'x' + NMREBARCHEVRON.to_template(:uBand, :wID, :lParamNM)
584
+
585
+ PreDefinedEvents = {
586
+ :customdraw => [WM_NOTIFY, NM_CUSTOMDRAW , 'xs', NMCUSTOMDRAW],
587
+ :nchittest => [WM_NOTIFY, NM_NCHITTEST, 'xs', NMMOUSE],
588
+ :releasedcapture => [WM_NOTIFY, NM_RELEASEDCAPTURE, 'xs', NMHDR],
589
+ :heightchange => [WM_NOTIFY, RBN_HEIGHTCHANGE, 'xs', NMHDR],
590
+ :layoutchanged => [WM_NOTIFY, RBN_LAYOUTCHANGED, 'xs', NMHDR],
591
+ :autosize => [WM_NOTIFY, RBN_AUTOSIZE, 'xs', NMRBAUTOSIZE],
592
+ :begindrag => [WM_NOTIFY, RBN_BEGINDRAG, 'xs', NMREBAR],
593
+ :enddrag => [WM_NOTIFY, RBN_ENDDRAG, 'xs', NMREBAR],
594
+ :deletingband => [WM_NOTIFY, RBN_DELETINGBAND, 'xs', NMREBAR],
595
+ :deletedband => [WM_NOTIFY, RBN_DELETEDBAND, 'xs', NMREBAR],
596
+ :childsize => [WM_NOTIFY, RBN_CHILDSIZE, 'xs', NMREBARCHILDSIZE],
597
+ :chevronpushed => [WM_NOTIFY, RBN_CHEVRONPUSHED, 'xs', NMREBARCHEVRON],
598
+ :minmax => [WM_NOTIFY, RBN_MINMAX, nil], # ???_minmax()
599
+ :autobreak => [WM_NOTIFY, RBN_AUTOBREAK, 'xs', NMREBARAUTOBREAK]
600
+ # :getobject => [WM_NOTIFY, RBN_GETOBJECT, 'xs']
601
+ }
602
+ DefaultEvents = []
603
+
604
+ attr_reader :_ar_data
605
+ def initialize(*args)
606
+ super
607
+ @_classname = "ReBarWindow32"
608
+ @_ar_data = []
609
+ @_bands = []
610
+ @_exstyle = WS_EX_TOOLWINDOW
611
+ @_acceptable_events = PreDefinedEvents.dup
612
+ end
613
+ #
614
+ def controls()
615
+ @controls ||= Controls.new(self, parent)
616
+ @controls
617
+ end
618
+ #
619
+ def new_control_id()
620
+ parent.new_control_id
621
+ end
622
+ #
623
+ def create()
624
+ icex = INITCOMMONCONTROLSEX[INITCOMMONCONTROLSEX::Size, ICC_COOL_CLASSES | ICC_BAR_CLASSES]
625
+ API.InitCommonControlsEx(icex)
626
+ super
627
+ # SendMessage(RB_SETBARINFO, 0, REBARINFO[REBARINFO::Size, 0, 0])
628
+ parent.register_event(WM_SIZE, '__rebar_resize__', 'ii', self)
629
+ self.imagelist = @_imagelist if @_imagelist
630
+ self.tooltips = @_tooltips if @_tooltips
631
+ self.textcolor = @_textcolor if @_textcolor
632
+
633
+ @_bands.each{|i| insert(-1, i)}
634
+ @_bands.clear
635
+ @_bands = nil
636
+ end
637
+
638
+ # Retrieves the count of bands currently in this rebar control.
639
+ def count()
640
+ alive? ? SendMessage(RB_GETBANDCOUNT, 0, 0) : @_bands.size
641
+ end
642
+
643
+ # Inserts a new band in a rebar control.<br>
644
+ # Give a Rebar::Band or array of [childwin, iimage=nil, text=nil, xsize=nil, style=nil] as args.
645
+ def insert(idx, args)
646
+ if args.is_a?(Band)
647
+ args.owner = self unless args.owner
648
+ band = args
649
+ else
650
+ band = Band.new(self, *args)
651
+ end
652
+ if alive?
653
+ SendMessage(RB_INSERTBAND, idx, band._rebarbandinfo)
654
+ else
655
+ idx = @_bands.size if idx>@_bands.size || idx==-1
656
+ @_bands.insert(idx, band)
657
+ end
658
+ band
659
+ end
660
+
661
+ # Deletes a band and a child window from this rebar control.
662
+ def delete(idx=nil)
663
+ return super() unless idx
664
+ if alive?
665
+ band = Band.new(self, idx)
666
+ childwin = band.childwin
667
+ parent.controls.delete(childwin) if childwin
668
+ (n=@_ar_data.index(band.data)) && @_ar_data.delete_at(n)
669
+ _delete_accessor(band.name)
670
+ SendMessage(RB_DELETEBAND, idx, 0)
671
+ parent.refresh
672
+ else
673
+ @_bands.delete_at(idx)
674
+ end
675
+ end
676
+
677
+ # Appends a new band in a rebar control.
678
+ def <<(arg)
679
+ if arg.is_a?(Array) && !arg[0].is_a?(Symbol)
680
+ arg.each{|i| insert(-1, i)}
681
+ else
682
+ insert(-1, arg)
683
+ end
684
+ end
685
+
686
+ # Retreives a Rebar::Band at specified index.
687
+ def [](idx)
688
+ self.alive? ? Band.new(self, idx) : @_bands[idx]
689
+ end
690
+
691
+ # Inserts multiple bands in this rebar control by specified arguments.
692
+ def []=(idx, *args)
693
+ num = args[0].is_a?(Integer) ? args.shift : 1
694
+ num.times{delete(idx)}
695
+ raise ArgumentError, "Num of arguments must be 2 or more" unless args[0].is_a?(Array)
696
+ if args[0][0].is_a?(Array) && !(args[0][0][0].is_a?(Class))
697
+ args[0].each_with_index{|v, i| insert(idx+i, v)}
698
+ else
699
+ insert(idx, args[0])
700
+ end
701
+ end
702
+
703
+ # Assignes an imagelist to this rebar control.
704
+ def imagelist=(il)
705
+ il = Imagelist.loadb64(il) if il.is_a?(String)
706
+ if alive?
707
+ barinfo = REBARINFO[REBARINFO::Size, RBIM_IMAGELIST, il._himagelist]
708
+ SendMessage(RB_SETBARINFO, 0, barinfo)
709
+ else
710
+ @_imagelist = il
711
+ end
712
+ end
713
+ # Gets an imagelist assigned to this rebar control.
714
+ def imagelist()
715
+ if alive?
716
+ barinfo = REBARINFO[REBARINFO::Size, RBIM_IMAGELIST]
717
+ SendMessage(RB_GETBARINFO, 0, barinfo)
718
+ APP.hrsc2ref(barinfo.himl)
719
+ else
720
+ @_imagelist
721
+ end
722
+ end
723
+
724
+ # Sets the text color of a rebar control.
725
+ def textcolor=(clr)
726
+ alive? ? SendMessage(RB_SETTEXTCOLOR, 0, clr) : @_textcolor = clr
727
+ end
728
+ # Gets the text color of this rebar control.
729
+ def textcolor()
730
+ alive? ? SendMessage(RB_GETTEXTCOLOR, 0, 0) : @_textcolor
731
+ end
732
+
733
+ # Sets the tooltip control that the rebar control will use to display tooltips.
734
+ def tooltips=(tip)
735
+ alive? ? SendMessage(RB_SETTOOLTIPS, tip.hWnd, 0) : @_tooltips = tip
736
+ end
737
+ # Retrieves the tooltip control that the rebar control uses to display tooltips.
738
+ def tooltips()
739
+ alive? ? APP.hwnd2ref(SendMessage(RB_GETTOOLTIPS, 0, 0)) : @_tooltips
740
+ end
741
+
742
+ # Determines which portion of a rebar band is at a given point on the screen.
743
+ def hittest(x, y, flag=nil)
744
+ hittestinfo = RB_HITTESTINFO[POINT[x, y]]
745
+ SendMessage(RB_HITTEST, 0, hittestinfo)
746
+ flag ? [hittestinfo.iBand, hittestinfo.flags] : hittestinfo.iBand
747
+ end
748
+
749
+ # each(){|band| ... }
750
+ # Performs the block for each <i>band</i> in this rebar control as a block parameter.
751
+ def each()
752
+ count.times{|i| yield self[i]}
753
+ end
754
+
755
+ protected
756
+ def _apply_options(arg)
757
+ if st = WinStyles[arg]
758
+ self.style |= st
759
+ end
760
+ super
761
+ end
762
+
763
+ private
764
+ # def __deleteband__(idx, wid)
765
+ def __deleteband__(nmrebar)
766
+
767
+ # bandinfo = REBARBANDINFO[REBARINFO::Size, RBBIM_LPARAM] # ???
768
+ # lparam = bandinfo.lParam # ??? always 0
769
+ lparam = nmrebar.lParam # ???
770
+ if (lparam&1)==0 && lparam>NilID
771
+ data = ObjectSpace._id2ref(lparam)
772
+ if n = @_ar_data.index(data)
773
+ @_ar_data.delete_at(n)
774
+ end
775
+ end
776
+ end
777
+
778
+ def __rebar_resize__(wp, lp)
779
+ SendMessage(WM_SIZE, wp, lp) if alive?
780
+ end
781
+
782
+ def _band_id2ref(id)
783
+ if alive?
784
+ idx = SendMessage(RB_IDTOINDEX, id, 0)
785
+ Band.new(self, idx)
786
+ else
787
+ @_bands.find{|i| i.idcmd == id}
788
+ end
789
+ end
790
+
791
+ def _define_access_method(name, obj) #; dp "@%p, %p", name, obj
792
+ instance_eval "def #{name}() _band_id2ref(@_accessors[:#{name}]); end"
793
+ instance_eval "def _#{name}() _band_id2ref(@_accessors[:#{name}]); end"
794
+ end
795
+ end
796
+ end
797
+
798
+ __END__
799
+ module WR
800
+ class Form1 < Form
801
+ def initialize()
802
+ self.font = Font["Meiryo", 18]
803
+ inheritfont true #Font["Meiryo", 18]
804
+ resize 640, 480
805
+ controls << Rebar[:rebar1, '', 0, 0, 0, 0, :varheight]
806
+ tb1 = Toolbar[:toolbar1, "", 0, 0, 200, 28, :list, :noresize, :nodivider, :tooltips, :transparent]
807
+ controls.rebar1 << [:band1, "band", Button[:button1, 'Button1', 0, 0, 80, 24]]
808
+ controls.rebar1 << [:band2, "toolbar", tb1]
809
+ tb1.imagelist = :systemsmall
810
+ tb1 << [:bt1, :filenew, 'New', :infotip=>'New!!']
811
+ tb1 << [:bt1, :fileopen, 'Open']
812
+ tb1 << [:bt1, :filesave, 'Save']
813
+ controls.rebar1 << [:band3, 'band3', 2, Combobox[:cmb1, '', 0, 0, 100, 100]]
814
+ controls.rebar1.band1.color = 0xff0000, 0xffffff
815
+ controls.rebar1.band2.color = 0xffff00, 0
816
+ #
817
+ controls << Button[:button2, "Set Bitmap", 0, 100, 100, 24]
818
+ end
819
+
820
+ def button1_clicked(*args)
821
+ dpp args
822
+ end
823
+
824
+ def button2_clicked(*args)
825
+ controls.rebar1.band1.bitmap = "IRNGwDAAAAAAAAAG0AcBRALAIAAAAAIQEwAIADEBk4ECQJjgWGwGAwGAwGAwGAwGAwGAwGAwGAwGAwICfwJeQCAQCAQCAQCAQCAQCAQCAQCAQEBHYK+QMAf7/f7/f7/f7/f7/f7/f7/gHVBOCBh8DD4ITQMPgwfBvmDB8JD4GHxGphgfBg+Bh8PP4gpw8PiQfDA+Eh8VP4MHx4DjAfGPCOLMbD42HxxTjW/JDCPB8GBpMJgB/v8AP9/ybWkgfJSOBa0pf5VPwLZguzLT+XLMIdoSBg=="
826
+ end
827
+
828
+ self.start
829
+ end
830
+ end if $0 == __FILE__