fzeet 0.5.3 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. data/examples/Command.rbw +2 -2
  2. data/examples/Control/Button.rbw +33 -11
  3. data/examples/Control/ComboBox.rbw +30 -0
  4. data/examples/Control/ComboBoxEx.rbw +30 -0
  5. data/examples/Control/DateTimePicker.rbw +9 -0
  6. data/examples/Control/Edit.rbw +18 -0
  7. data/examples/Control/Header.rbw +9 -0
  8. data/examples/Control/ListBox.rbw +30 -0
  9. data/examples/Control/ListView.rbw +11 -0
  10. data/examples/Control/MonthCalendar.rbw +9 -0
  11. data/examples/Control/ProgressBar.rbw +22 -0
  12. data/examples/Control/PropertySheet.rbw +50 -0
  13. data/examples/Control/Static.rbw +14 -0
  14. data/examples/Control/SysLink.rbw +9 -0
  15. data/examples/Control/TreeView.rbw +28 -0
  16. data/examples/Control/UpDown.rbw +12 -0
  17. data/examples/Dialog/Dialog.rbw +9 -9
  18. data/examples/Dialog/DialogApplication.rbw +1 -1
  19. data/examples/Menu/ContextMenu.rbw +3 -1
  20. data/examples/Menu/MenuPARGB32.rbw +6 -6
  21. data/examples/Paint.rbw +9 -0
  22. data/examples/UIRibbon/ContextPopup.rbw +7 -4
  23. data/examples/UIRibbon/Control/Button.dll +0 -0
  24. data/examples/UIRibbon/Control/Button.rb +91 -0
  25. data/examples/UIRibbon/Control/Button.rbw +20 -0
  26. data/examples/UIRibbon/Control/Button.xml +247 -0
  27. data/examples/UIRibbon/Size.rbw +13 -0
  28. data/examples/res/audio-volume-muted-big.bmp +0 -0
  29. data/examples/res/audio-volume-muted-small.bmp +0 -0
  30. data/examples/res/audio-volume-muted.bmp +0 -0
  31. data/examples/res/go-down-big.bmp +0 -0
  32. data/examples/res/go-down-small.bmp +0 -0
  33. data/examples/res/go-down.bmp +0 -0
  34. data/examples/res/go-jump-big.bmp +0 -0
  35. data/examples/res/go-jump-small.bmp +0 -0
  36. data/examples/res/go-jump.bmp +0 -0
  37. data/examples/res/media-playback-pause-big.bmp +0 -0
  38. data/examples/res/media-playback-pause-small.bmp +0 -0
  39. data/examples/res/media-playback-pause.bmp +0 -0
  40. data/lib/fzeet/Application.rb +4 -2
  41. data/lib/fzeet/Common.rb +44 -2
  42. data/lib/fzeet/Control/Button.rb +17 -0
  43. data/lib/fzeet/Control/ComboBox.rb +46 -0
  44. data/lib/fzeet/Control/ComboBoxEx.rb +35 -0
  45. data/lib/fzeet/Control/Common.rb +2 -0
  46. data/lib/fzeet/Control/DateTimePicker.rb +38 -0
  47. data/lib/fzeet/Control/Edit.rb +53 -0
  48. data/lib/fzeet/Control/Header.rb +46 -0
  49. data/lib/fzeet/Control/ListBox.rb +72 -0
  50. data/lib/fzeet/Control/ListView.rb +90 -0
  51. data/lib/fzeet/Control/MonthCalendar.rb +38 -0
  52. data/lib/fzeet/Control/ProgressBar.rb +40 -0
  53. data/lib/fzeet/Control/Static.rb +34 -0
  54. data/lib/fzeet/Control/SysLink.rb +40 -0
  55. data/lib/fzeet/Control/TreeView.rb +32 -0
  56. data/lib/fzeet/Control/UpDown.rb +36 -0
  57. data/lib/fzeet/Control.rb +13 -0
  58. data/lib/fzeet/UIRibbon.rb +91 -31
  59. data/lib/fzeet/Window/Common.rb +22 -1
  60. data/lib/fzeet/Window/View.rb +15 -0
  61. data/lib/fzeet/Window/WindowMethods.rb +26 -1
  62. data/lib/fzeet/Window.rb +1 -0
  63. data/lib/fzeet/windows/comctl/Button.rb +3 -0
  64. data/lib/fzeet/windows/comctl/ComboBox.rb +12 -0
  65. data/lib/fzeet/windows/comctl/ComboBoxEx.rb +65 -0
  66. data/lib/fzeet/windows/comctl/Common.rb +52 -1
  67. data/lib/fzeet/windows/comctl/DateTimePicker.rb +54 -0
  68. data/lib/fzeet/windows/comctl/Edit.rb +20 -0
  69. data/lib/fzeet/windows/comctl/Header.rb +128 -0
  70. data/lib/fzeet/windows/comctl/ListView.rb +317 -0
  71. data/lib/fzeet/windows/comctl/MonthCalendar.rb +62 -0
  72. data/lib/fzeet/windows/comctl/ProgressBar.rb +31 -0
  73. data/lib/fzeet/windows/comctl/PropertySheet.rb +205 -0
  74. data/lib/fzeet/windows/comctl/SysLink.rb +34 -0
  75. data/lib/fzeet/windows/comctl/TreeView.rb +198 -0
  76. data/lib/fzeet/windows/comctl/UpDown.rb +43 -0
  77. data/lib/fzeet/windows/comctl.rb +12 -0
  78. data/lib/fzeet/windows/common.rb +74 -2
  79. data/lib/fzeet/windows/gdi.rb +2 -0
  80. data/lib/fzeet/windows/libc.rb +4 -0
  81. data/lib/fzeet/windows/ole.rb +0 -22
  82. data/lib/fzeet/windows/shell/Common.rb +2 -0
  83. data/lib/fzeet/windows/user/Control/Button.rb +6 -0
  84. data/lib/fzeet/windows/user/Control/ComboBox.rb +72 -0
  85. data/lib/fzeet/windows/user/Control/Common.rb +1 -1
  86. data/lib/fzeet/windows/user/Control/Edit.rb +71 -0
  87. data/lib/fzeet/windows/user/Control/ListBox.rb +78 -0
  88. data/lib/fzeet/windows/user/Control/Static.rb +49 -0
  89. data/lib/fzeet/windows/user/Control.rb +4 -0
  90. data/lib/fzeet/windows/user/Window.rb +47 -0
  91. metadata +66 -4
@@ -0,0 +1,247 @@
1
+ <?xml version='1.0' encoding='utf-8' ?>
2
+ <Application xmlns='http://schemas.microsoft.com/windows/2009/Ribbon'>
3
+ <Application.Commands>
4
+ <Command Name='cmdAppMenu' />
5
+
6
+ <Command Name='cmdQAT' />
7
+
8
+ <Command Name='cmdTab1' LabelTitle='Button' />
9
+ <Command Name='cmdTab1Group1' LabelTitle='&amp;Button' LabelDescription='LabelDescription...' TooltipDescription='TooltipDescription...'>
10
+ <Command.SmallImages>
11
+ <Image>../../res/go-next-small.bmp</Image>
12
+ <Image MinDPI='120'>../../res/go-next.bmp</Image>
13
+ </Command.SmallImages>
14
+ <Command.LargeImages>
15
+ <Image>../../res/go-next.bmp</Image>
16
+ <Image MinDPI='120'>../../res/go-next-big.bmp</Image>
17
+ </Command.LargeImages>
18
+ </Command>
19
+ <Command Name='cmdTab1Group2' LabelTitle='&amp;DropDownButton' LabelDescription='LabelDescription...' TooltipDescription='TooltipDescription...'>
20
+ <Command.SmallImages>
21
+ <Image>../../res/go-down-small.bmp</Image>
22
+ <Image MinDPI='120'>../../res/go-down.bmp</Image>
23
+ </Command.SmallImages>
24
+ <Command.LargeImages>
25
+ <Image>../../res/go-down.bmp</Image>
26
+ <Image MinDPI='120'>../../res/go-down-big.bmp</Image>
27
+ </Command.LargeImages>
28
+ </Command>
29
+ <Command Name='cmdTab1Group3' LabelTitle='&amp;SplitButton' LabelDescription='LabelDescription...' TooltipDescription='TooltipDescription...'>
30
+ <Command.SmallImages>
31
+ <Image>../../res/go-jump-small.bmp</Image>
32
+ <Image MinDPI='120'>../../res/go-jump.bmp</Image>
33
+ </Command.SmallImages>
34
+ <Command.LargeImages>
35
+ <Image>../../res/go-jump.bmp</Image>
36
+ <Image MinDPI='120'>../../res/go-jump-big.bmp</Image>
37
+ </Command.LargeImages>
38
+ </Command>
39
+ <Command Name='cmdTab1Group4' LabelTitle='&amp;ToggleButton' LabelDescription='LabelDescription...' TooltipDescription='TooltipDescription...'>
40
+ <Command.SmallImages>
41
+ <Image>../../res/audio-volume-muted-small.bmp</Image>
42
+ <Image MinDPI='120'>../../res/audio-volume-muted.bmp</Image>
43
+ </Command.SmallImages>
44
+ <Command.LargeImages>
45
+ <Image>../../res/audio-volume-muted.bmp</Image>
46
+ <Image MinDPI='120'>../../res/audio-volume-muted-big.bmp</Image>
47
+ </Command.LargeImages>
48
+ </Command>
49
+ <Command Name='cmdTab1Group5' LabelTitle='&amp;CheckBox' LabelDescription='LabelDescription...' TooltipDescription='TooltipDescription...'>
50
+ <Command.SmallImages>
51
+ <Image>../../res/media-playback-pause-small.bmp</Image>
52
+ <Image MinDPI='120'>../../res/media-playback-pause.bmp</Image>
53
+ </Command.SmallImages>
54
+ <Command.LargeImages>
55
+ <Image>../../res/media-playback-pause.bmp</Image>
56
+ <Image MinDPI='120'>../../res/media-playback-pause-big.bmp</Image>
57
+ </Command.LargeImages>
58
+ </Command>
59
+
60
+ <Command Name='cmdButton1' LabelTitle='&amp;Button1' LabelDescription='LabelDescription...' TooltipDescription='TooltipDescription...'>
61
+ <Command.SmallImages>
62
+ <Image>../../res/go-next-small.bmp</Image>
63
+ <Image MinDPI='120'>../../res/go-next.bmp</Image>
64
+ </Command.SmallImages>
65
+ <Command.LargeImages>
66
+ <Image>../../res/go-next.bmp</Image>
67
+ <Image MinDPI='120'>../../res/go-next-big.bmp</Image>
68
+ </Command.LargeImages>
69
+ </Command>
70
+ <Command Name='cmdDrop1' LabelTitle='&amp;Drop1' LabelDescription='LabelDescription...' TooltipDescription='TooltipDescription...'>
71
+ <Command.SmallImages>
72
+ <Image>../../res/go-down-small.bmp</Image>
73
+ <Image MinDPI='120'>../../res/go-down.bmp</Image>
74
+ </Command.SmallImages>
75
+ <Command.LargeImages>
76
+ <Image>../../res/go-down.bmp</Image>
77
+ <Image MinDPI='120'>../../res/go-down-big.bmp</Image>
78
+ </Command.LargeImages>
79
+ </Command>
80
+ <Command Name='cmdSplit1' LabelTitle='&amp;Split1' LabelDescription='LabelDescription...' TooltipDescription='TooltipDescription...'>
81
+ <Command.SmallImages>
82
+ <Image>../../res/go-jump-small.bmp</Image>
83
+ <Image MinDPI='120'>../../res/go-jump.bmp</Image>
84
+ </Command.SmallImages>
85
+ <Command.LargeImages>
86
+ <Image>../../res/go-jump.bmp</Image>
87
+ <Image MinDPI='120'>../../res/go-jump-big.bmp</Image>
88
+ </Command.LargeImages>
89
+ </Command>
90
+ <Command Name='cmdToggle1' LabelTitle='&amp;Toggle1' LabelDescription='LabelDescription...' TooltipDescription='TooltipDescription...'>
91
+ <Command.SmallImages>
92
+ <Image>../../res/audio-volume-muted-small.bmp</Image>
93
+ <Image MinDPI='120'>../../res/audio-volume-muted.bmp</Image>
94
+ </Command.SmallImages>
95
+ <Command.LargeImages>
96
+ <Image>../../res/audio-volume-muted.bmp</Image>
97
+ <Image MinDPI='120'>../../res/audio-volume-muted-big.bmp</Image>
98
+ </Command.LargeImages>
99
+ </Command>
100
+ <Command Name='cmdCheck1' LabelTitle='&amp;Check1' LabelDescription='LabelDescription...' TooltipDescription='TooltipDescription...'>
101
+ <Command.SmallImages>
102
+ <Image>../../res/media-playback-pause-small.bmp</Image>
103
+ <Image MinDPI='120'>../../res/media-playback-pause.bmp</Image>
104
+ </Command.SmallImages>
105
+ <Command.LargeImages>
106
+ <Image>../../res/media-playback-pause.bmp</Image>
107
+ <Image MinDPI='120'>../../res/media-playback-pause-big.bmp</Image>
108
+ </Command.LargeImages>
109
+ </Command>
110
+
111
+ <Command Name='cmdContextMap1' />
112
+ </Application.Commands>
113
+
114
+ <Application.Views>
115
+ <Ribbon>
116
+ <Ribbon.ApplicationMenu>
117
+ <ApplicationMenu CommandName='cmdAppMenu'>
118
+ <MenuGroup Class='MajorItems'>
119
+ <Button CommandName='cmdButton1' />
120
+ <DropDownButton CommandName='cmdDrop1'>
121
+ <MenuGroup Class='MajorItems'>
122
+ <Button CommandName='cmdButton1' />
123
+ </MenuGroup>
124
+ </DropDownButton>
125
+ <SplitButton>
126
+ <SplitButton.ButtonItem>
127
+ <Button CommandName='cmdSplit1' />
128
+ </SplitButton.ButtonItem>
129
+ <SplitButton.MenuGroups>
130
+ <MenuGroup Class='MajorItems'>
131
+ <ToggleButton CommandName='cmdToggle1' />
132
+ <CheckBox CommandName='cmdCheck1' />
133
+ </MenuGroup>
134
+ </SplitButton.MenuGroups>
135
+ </SplitButton>
136
+ <!--<ToggleButton CommandName='cmdToggle1' />
137
+ <CheckBox CommandName='cmdCheck1' />-->
138
+ </MenuGroup>
139
+ </ApplicationMenu>
140
+ </Ribbon.ApplicationMenu>
141
+
142
+ <Ribbon.QuickAccessToolbar>
143
+ <QuickAccessToolbar CommandName='cmdQAT'>
144
+ <QuickAccessToolbar.ApplicationDefaults>
145
+ <Button CommandName='cmdButton1' />
146
+ </QuickAccessToolbar.ApplicationDefaults>
147
+ </QuickAccessToolbar>
148
+ </Ribbon.QuickAccessToolbar>
149
+
150
+ <Ribbon.Tabs>
151
+ <Tab CommandName='cmdTab1'>
152
+ <Group CommandName='cmdTab1Group1' SizeDefinition='OneButton'>
153
+ <Button CommandName='cmdButton1' />
154
+ </Group>
155
+
156
+ <Group CommandName='cmdTab1Group2' SizeDefinition='OneButton'>
157
+ <DropDownButton CommandName='cmdDrop1'>
158
+ <MenuGroup>
159
+ <Button CommandName='cmdButton1' />
160
+ </MenuGroup>
161
+ </DropDownButton>
162
+ </Group>
163
+
164
+ <Group CommandName='cmdTab1Group3' SizeDefinition='OneButton'>
165
+ <SplitButton>
166
+ <SplitButton.ButtonItem>
167
+ <Button CommandName='cmdSplit1' />
168
+ </SplitButton.ButtonItem>
169
+ <SplitButton.MenuGroups>
170
+ <MenuGroup>
171
+ <ToggleButton CommandName='cmdToggle1' />
172
+ <CheckBox CommandName='cmdCheck1' />
173
+ </MenuGroup>
174
+ </SplitButton.MenuGroups>
175
+ </SplitButton>
176
+ </Group>
177
+
178
+ <Group CommandName='cmdTab1Group4' SizeDefinition='OneButton'>
179
+ <ToggleButton CommandName='cmdToggle1' />
180
+ </Group>
181
+
182
+ <Group CommandName='cmdTab1Group5'>
183
+ <CheckBox CommandName='cmdCheck1' />
184
+ </Group>
185
+ </Tab>
186
+ </Ribbon.Tabs>
187
+ </Ribbon>
188
+
189
+ <ContextPopup>
190
+ <ContextPopup.MiniToolbars>
191
+ <MiniToolbar Name='miniToolbar1'>
192
+ <MenuGroup>
193
+ <Button CommandName='cmdButton1' />
194
+ <DropDownButton CommandName='cmdDrop1'>
195
+ <MenuGroup>
196
+ <Button CommandName='cmdButton1' />
197
+ </MenuGroup>
198
+ </DropDownButton>
199
+ <SplitButton>
200
+ <SplitButton.ButtonItem>
201
+ <Button CommandName='cmdSplit1' />
202
+ </SplitButton.ButtonItem>
203
+ <SplitButton.MenuGroups>
204
+ <MenuGroup>
205
+ <ToggleButton CommandName='cmdToggle1' />
206
+ <CheckBox CommandName='cmdCheck1' />
207
+ </MenuGroup>
208
+ </SplitButton.MenuGroups>
209
+ </SplitButton>
210
+ <ToggleButton CommandName='cmdToggle1' />
211
+ <CheckBox CommandName='cmdCheck1' />
212
+ </MenuGroup>
213
+ </MiniToolbar>
214
+ </ContextPopup.MiniToolbars>
215
+
216
+ <ContextPopup.ContextMenus>
217
+ <ContextMenu Name='contextMenu1'>
218
+ <MenuGroup>
219
+ <Button CommandName='cmdButton1' />
220
+ <DropDownButton CommandName='cmdDrop1'>
221
+ <MenuGroup>
222
+ <Button CommandName='cmdButton1' />
223
+ </MenuGroup>
224
+ </DropDownButton>
225
+ <SplitButton>
226
+ <SplitButton.ButtonItem>
227
+ <Button CommandName='cmdSplit1' />
228
+ </SplitButton.ButtonItem>
229
+ <SplitButton.MenuGroups>
230
+ <MenuGroup>
231
+ <ToggleButton CommandName='cmdToggle1' />
232
+ <CheckBox CommandName='cmdCheck1' />
233
+ </MenuGroup>
234
+ </SplitButton.MenuGroups>
235
+ </SplitButton>
236
+ <ToggleButton CommandName='cmdToggle1' />
237
+ <CheckBox CommandName='cmdCheck1' />
238
+ </MenuGroup>
239
+ </ContextMenu>
240
+ </ContextPopup.ContextMenus>
241
+
242
+ <ContextPopup.ContextMaps>
243
+ <ContextMap CommandName='cmdContextMap1' MiniToolbar='miniToolbar1' ContextMenu='contextMenu1' />
244
+ </ContextPopup.ContextMaps>
245
+ </ContextPopup>
246
+ </Application.Views>
247
+ </Application>
@@ -0,0 +1,13 @@
1
+ require 'fzeet'
2
+
3
+ include Fzeet
4
+
5
+ Application.run(View.new) { |window|
6
+ UIRibbon.new(window, 'Minimal').
7
+ on(:size) { window.invalidate }.
8
+ on(CmdButton1) { message 'on(CmdButton1)' }.
9
+
10
+ window.on(:draw, Control::Font) { |dc|
11
+ dc.sms 'The quick brown fox jumps over the lazy dog. 1234567890'
12
+ }
13
+ }
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -11,10 +11,11 @@ module Fzeet
11
11
  @window = nil
12
12
  @accelerators = []
13
13
  @dialogs = []
14
+ @images = {}
14
15
 
15
16
  class << self
16
17
  attr_accessor :name, :version, :authors, :quitWhenMainWindowCloses
17
- attr_reader :window, :accelerators, :dialogs
18
+ attr_reader :window, :accelerators, :dialogs, :images
18
19
  end
19
20
 
20
21
  def self.window=(window)
@@ -25,7 +26,7 @@ module Fzeet
25
26
 
26
27
  def self.run(windowOrOpts = {}, &block)
27
28
  @window = case windowOrOpts
28
- when Window; windowOrOpts.tap { |window| block.call(window) if block }
29
+ when BasicWindow; windowOrOpts.tap { |window| block.call(window) if block }
29
30
  when Hash
30
31
  if windowOrOpts[:deferCreateWindow].tap { windowOrOpts.delete_if { |k, v| k == :deferCreateWindow } }
31
32
  Window.new(windowOrOpts, &block)
@@ -56,6 +57,7 @@ module Fzeet
56
57
 
57
58
  def self.quit(code = 0)
58
59
  accelerators.each(&:dispose)
60
+ images.values.each(&:dispose)
59
61
 
60
62
  Windows.PostQuitMessage(code)
61
63
  end
data/lib/fzeet/Common.rb CHANGED
@@ -45,7 +45,17 @@ module Fzeet
45
45
  module_function :constant, :flags
46
46
 
47
47
  module Toggle
48
- def toggle(what) send("#{what}=", !send("#{what}?")); self end
48
+ def toggle(what)
49
+ send("#{what}=", !send("#{what}?"))
50
+
51
+ begin
52
+ yield self
53
+ ensure
54
+ toggle(what)
55
+ end if block_given?
56
+
57
+ self
58
+ end
49
59
  end
50
60
 
51
61
  class Command
@@ -111,7 +121,11 @@ module Fzeet
111
121
  message(message, opts)
112
122
  end
113
123
 
114
- module_function :message, :question
124
+ def shell(name, args = nil, dir = nil, verb = 'open')
125
+ raise 'ShellExecute failed.' unless Windows.ShellExecute(nil, verb, name, args, dir, Windows::SW_NORMAL).to_i > 32
126
+ end
127
+
128
+ module_function :message, :question, :shell
115
129
 
116
130
  class Point < Windows::POINT
117
131
  def initialize(x = 0, y = 0) self[:x], self[:y] = x, y end
@@ -266,6 +280,34 @@ module Fzeet
266
280
  end
267
281
 
268
282
  module DCMethods
283
+ def select(*objects)
284
+ holds = []
285
+
286
+ objects.each { |object|
287
+ holds << Windows.DetonateLastError(FFI::Pointer::NULL, :SelectObject, @handle, object.handle)
288
+ }
289
+
290
+ yield self
291
+
292
+ self
293
+ ensure
294
+ holds.each { |hold| Windows.SelectObject(@handle, hold) }
295
+ end
296
+
297
+ def fillRect(rect, brush) Windows.DetonateLastError(0, :FillRect, @handle, rect, brush.handle); self end
298
+
299
+ def text(text, rect, flags = 0) Windows.DetonateLastError(0, :DrawText, @handle, text, -1, rect, Fzeet.flags(flags, :dt_)); self end
300
+
301
+ def sms(message)
302
+ r = window.rect
303
+
304
+ r[:top] += window.ribbon.height if window.ribbon
305
+
306
+ text(message, r, [:singleline, :center, :vcenter])
307
+
308
+ self
309
+ end
310
+
269
311
  def move(x, y) Windows.DetonateLastError(0, :MoveToEx, @handle, x, y, nil); self end
270
312
  def line(x, y) Windows.DetonateLastError(0, :LineTo, @handle, x, y); self end
271
313
  end
@@ -1,7 +1,24 @@
1
1
  require_relative 'Common'
2
2
 
3
3
  module Fzeet
4
+ module ButtonMethods
5
+ def image=(image) sendmsg(:setimage, Windows::IMAGE_BITMAP, image.handle) end
6
+
7
+ def note=(text) Windows.LPWSTR(text) { |p| sendmsg(:setnote, 0, p) } end
8
+
9
+ def checked?; sendmsg(:getcheck) == Windows::BST_CHECKED end
10
+ def checked=(checked) sendmsg(:setcheck, (checked) ? Windows::BST_CHECKED : Windows::BST_UNCHECKED) end
11
+
12
+ def indeterminate?; sendmsg(:getcheck) == Windows::BST_INDETERMINATE end
13
+ def indeterminate=(indeterminate) sendmsg(:setcheck, (indeterminate) ? Windows::BST_INDETERMINATE : Windows::BST_UNCHECKED) end
14
+
15
+ def pushed?; (sendmsg(:getstate) & Windows::BST_PUSHED) == Windows::BST_PUSHED end
16
+ def pushed=(pushed) sendmsg(:setstate, (pushed) ? 1 : 0) end
17
+ end
18
+
4
19
  class Button < Control
20
+ include ButtonMethods
21
+
5
22
  Prefix = {
6
23
  xstyle: [:ws_ex_],
7
24
  style: [:bs_, :ws_],
@@ -0,0 +1,46 @@
1
+ require_relative 'ListBox'
2
+
3
+ module Fzeet
4
+ module ComboBoxMethods
5
+ include ListBoxMethods
6
+
7
+ def textlen(i) raise "GETLBTEXTLEN failed." if (len = sendmsg(:getlbtextlen, i)) == -1; len end
8
+
9
+ def [](i)
10
+ i = sendmsg(:getcursel) if i == :selected
11
+
12
+ return '' if i == -1 || (len = textlen(i) + 1) == 1
13
+
14
+ ''.tap { |item|
15
+ FFI::MemoryPointer.new(:char, len) { |buf|
16
+ raise "GETLBTEXT failed." if sendmsg(:getlbtext, i, buf) == -1
17
+
18
+ item << buf.read_string
19
+ }
20
+ }
21
+ end
22
+ end
23
+
24
+ class ComboBox < Control
25
+ include ComboBoxMethods
26
+
27
+ Prefix = {
28
+ xstyle: [:ws_ex_],
29
+ style: [:cbs_, :ws_],
30
+ message: [:cb_, :wm_],
31
+ notification: [:cbn_]
32
+ }
33
+
34
+ def initialize(parent, id, opts = {}, &block)
35
+ super('ComboBox', parent, id, opts)
36
+
37
+ @parent.on(:command, @id, &block) if block
38
+ end
39
+
40
+ def on(notification, &block)
41
+ @parent.on(:command, @id, Fzeet.constant(notification, *self.class::Prefix[:notification]), &block)
42
+
43
+ self
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,35 @@
1
+ require_relative 'ComboBox'
2
+
3
+ module Fzeet
4
+ module ComboBoxExMethods
5
+ include ComboBoxMethods
6
+
7
+ end
8
+
9
+ class ComboBoxEx < Control
10
+ include ComboBoxExMethods
11
+
12
+ Prefix = {
13
+ xstyle: [:cbes_ex_, :ws_ex_],
14
+ style: [:cbs_, :ws_],
15
+ message: [:cb_, :cbem_, :ccm_, :wm_],
16
+ notification: [:cbn_, :cben_, :nm_]
17
+ }
18
+
19
+ def initialize(parent, id, opts = {}, &block)
20
+ super('ComboBoxEx32', parent, id, opts)
21
+
22
+ @parent.on(:command, @id, &block) if block
23
+ end
24
+
25
+ def on(notification, &block)
26
+ if (notification = Fzeet.constant(notification, *self.class::Prefix[:notification])) < Windows::CBEN_LAST
27
+ @parent.on(:command, @id, notification, &block)
28
+ else
29
+ @parent.on(:notify, @id, notification, &block)
30
+ end
31
+
32
+ self
33
+ end
34
+ end
35
+ end
@@ -36,6 +36,7 @@ module Fzeet
36
36
  y: Windows::CW_USEDEFAULT,
37
37
  width: Windows::CW_USEDEFAULT,
38
38
  height: Windows::CW_USEDEFAULT,
39
+ position: []
39
40
  }
40
41
  badopts = opts.keys - _opts.keys; raise "Bad option(s): #{badopts.join(', ')}." unless badopts.empty?
41
42
  _opts.merge!(opts)
@@ -43,6 +44,7 @@ module Fzeet
43
44
  _opts[:xstyle] = Fzeet.flags(_opts[:xstyle], *self.class::Prefix[:xstyle])
44
45
  _opts[:caption] = _opts[:caption].to_s
45
46
  _opts[:style] = Fzeet.flags([:child, :visible, :tabstop], :ws_) | Fzeet.flags(_opts[:style], *self.class::Prefix[:style])
47
+ _opts[:x], _opts[:y], _opts[:width], _opts[:height] = _opts[:position] unless _opts[:position].empty?
46
48
 
47
49
  @handle = Windows.DetonateLastError(FFI::Pointer::NULL, :CreateWindowEx,
48
50
  _opts[:xstyle], className, _opts[:caption], _opts[:style],
@@ -0,0 +1,38 @@
1
+ require_relative 'Common'
2
+
3
+ module Fzeet
4
+ module DateTimePickerMethods
5
+
6
+ end
7
+
8
+ class DateTimePicker < Control
9
+ include DateTimePickerMethods
10
+
11
+ Prefix = {
12
+ xstyle: [:ws_ex_],
13
+ style: [:dts_, :ws_],
14
+ message: [:dtm_, :ccm_, :wm_],
15
+ notification: [:dtn_, :nm_]
16
+ }
17
+
18
+ def self.crackNotification(args)
19
+ case args[:notification]
20
+ when Windows::DTN_DATETIMECHANGE
21
+ args[:dtc] = Windows::NMDATETIMECHANGE.new(FFI::Pointer.new(args[:lParam]))
22
+ args[:st] = args[:dtc][:st] if args[:dtc][:dwFlags] == Windows::GDT_VALID
23
+ end
24
+ end
25
+
26
+ def initialize(parent, id, opts = {}, &block)
27
+ super('SysDateTimePick32', parent, id, opts)
28
+
29
+ @parent.on(:notify, @id, &block) if block
30
+ end
31
+
32
+ def on(notification, &block)
33
+ @parent.on(:notify, @id, Fzeet.constant(notification, *self.class::Prefix[:notification]), &block)
34
+
35
+ self
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,53 @@
1
+ require_relative 'Common'
2
+
3
+ module Fzeet
4
+ module EditMethods
5
+ def clear; self.text = ''; self end
6
+
7
+ def select(s = 0, e = -1) sendmsg(:setsel, s, e); self end
8
+
9
+ def cuebanner=(text) Windows.LPWSTR(text) { |p| sendmsg(:setcuebanner, 1, p) } end
10
+
11
+ def showBalloontip(text, title = '', icon = 1)
12
+ Windows.LPWSTR(text) { |ptext| Windows.LPWSTR(title) { |ptitle|
13
+ ebt = Windows::EDITBALLOONTIP.new
14
+
15
+ ebt[:cbStruct] = ebt.size
16
+ ebt[:pszTitle] = ptitle
17
+ ebt[:pszText] = ptext
18
+ ebt[:ttiIcon] = Fzeet.constant(icon, :tti_)
19
+
20
+ sendmsg(:showBalloontip, 0, ebt.pointer)
21
+ }}
22
+
23
+ self
24
+ end
25
+
26
+ def hideBalloontip; sendmsg(:hideBalloontip); self end
27
+ end
28
+
29
+ class Edit < Control
30
+ include EditMethods
31
+
32
+ Prefix = {
33
+ xstyle: [:ws_ex_],
34
+ style: [:es_, :ws_],
35
+ message: [:em_, :wm_],
36
+ notification: [:en_]
37
+ }
38
+
39
+ def initialize(parent, id, opts = {}, &block)
40
+ super('Edit', parent, id, opts)
41
+
42
+ style << :border; reframe
43
+
44
+ @parent.on(:command, @id, &block) if block
45
+ end
46
+
47
+ def on(notification, &block)
48
+ @parent.on(:command, @id, Fzeet.constant(notification, *self.class::Prefix[:notification]), &block)
49
+
50
+ self
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,46 @@
1
+ require_relative 'Common'
2
+
3
+ module Fzeet
4
+ module HeaderMethods
5
+ def insertItem(i, text, width)
6
+ hdi = Windows::HDITEM.new
7
+
8
+ hdi[:mask] = Fzeet.flags([:width, :text, :format, :order], :hdi_)
9
+ hdi[:cxy] = width
10
+ hdi[:pszText] = ptext = FFI::MemoryPointer.from_string(text)
11
+ hdi[:fmt] = Fzeet.flags([:left, :string], :hdf_)
12
+ hdi[:iOrder] = i
13
+
14
+ sendmsg(:insertitem, 0, hdi.pointer)
15
+
16
+ self
17
+ ensure
18
+ ptext.free
19
+ end
20
+ end
21
+
22
+ class Header < Control
23
+ include HeaderMethods
24
+
25
+ Prefix = {
26
+ xstyle: [:ws_ex_],
27
+ style: [:hds_, :ws_],
28
+ message: [:hdm_, :ccm_, :wm_],
29
+ notification: [:hdn_, :nm_]
30
+ }
31
+
32
+ def self.crackNotification(args) end
33
+
34
+ def initialize(parent, id, opts = {}, &block)
35
+ super('SysHeader32', parent, id, opts)
36
+
37
+ @parent.on(:notify, @id, &block) if block
38
+ end
39
+
40
+ def on(notification, &block)
41
+ @parent.on(:notify, @id, Fzeet.constant(notification, *self.class::Prefix[:notification]), &block)
42
+
43
+ self
44
+ end
45
+ end
46
+ end