fzeet 0.6.5 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE_CEF +29 -0
- data/checks/Bstr.rb +14 -0
- data/checks/Decimal.rb +27 -0
- data/checks/OSVERSIONINFOEX.rb +14 -0
- data/checks/Point.rb +65 -0
- data/checks/Rect.rb +104 -0
- data/checks/RunAll.rb +2 -0
- data/checks/SafeArray.rb +27 -0
- data/checks/Size.rb +45 -0
- data/checks/SystemTime.rb +43 -0
- data/checks/Variant.rb +160 -0
- data/examples/Control/DateTimePicker.rbw +1 -1
- data/examples/Control/MonthCalendar.rbw +1 -1
- data/examples/Control/{WebBrowser.rbw → WebBrowser/WebBrowser.rbw} +2 -2
- data/examples/Control/{WebBrowser1.rbw → WebBrowser/WebBrowser1.rbw} +0 -0
- data/examples/Control/WebBrowser/WebBrowser2.rbw +24 -0
- data/examples/Control/{WebBrowser3.rbw → WebBrowser/WebBrowser3.rbw} +0 -0
- data/examples/Control/{WebBrowser4.rbw → WebBrowser/WebBrowser4.rbw} +8 -3
- data/examples/Control/{WebBrowser4Sinatra.rb → WebBrowser/WebBrowser4Sinatra.rb} +0 -0
- data/examples/Control/{WebBrowser5.rbw → WebBrowser/WebBrowser5.rbw} +4 -2
- data/examples/Control/WebBrowser/jQueryUI.html +53 -0
- data/examples/Control/WebBrowser/jQueryUI.rbw +26 -0
- data/examples/MDI.rbw +2 -2
- data/examples/Raw/UIRibbon/Command.rbw +3 -3
- data/examples/Raw/UIRibbon/Minimal.rbw +3 -3
- data/examples/Version.rbw +1 -1
- data/lib/fzeet.rb +22 -7
- data/lib/fzeet/windows.rb +82 -5
- data/lib/fzeet/windows/com.rb +1 -318
- data/lib/fzeet/windows/com/Common.rb +318 -0
- data/lib/fzeet/windows/comctl.rb +1 -1
- data/lib/fzeet/windows/comctl/ComboBoxEx.rb +32 -0
- data/lib/fzeet/windows/comctl/DateTimePicker.rb +35 -0
- data/lib/fzeet/windows/comctl/Header.rb +61 -1
- data/lib/fzeet/windows/comctl/ListView.rb +133 -3
- data/lib/fzeet/windows/comctl/MonthCalendar.rb +35 -0
- data/lib/fzeet/windows/comctl/ProgressBar.rb +37 -0
- data/lib/fzeet/windows/comctl/PropertySheet.rb +50 -2
- data/lib/fzeet/windows/comctl/SysLink.rb +37 -0
- data/lib/fzeet/windows/comctl/Tab.rb +56 -0
- data/lib/fzeet/windows/comctl/TreeView.rb +81 -2
- data/lib/fzeet/windows/comctl/UpDown.rb +33 -0
- data/lib/fzeet/windows/comdlg.rb +1 -0
- data/lib/fzeet/windows/comdlg/ColorDialog.rb +41 -0
- data/lib/fzeet/windows/comdlg/Common.rb +87 -0
- data/lib/fzeet/windows/comdlg/FileDialog.rb +133 -0
- data/lib/fzeet/windows/comdlg/FindReplaceDialog.rb +102 -0
- data/lib/fzeet/windows/comdlg/FontDialog.rb +36 -0
- data/lib/fzeet/windows/comdlg/PrintDialog.rb +72 -0
- data/lib/fzeet/{Dialog → windows/comdlg}/ShellFileDialog.rb +0 -0
- data/lib/fzeet/windows/core.rb +5 -0
- data/lib/fzeet/windows/core/Common.rb +324 -0
- data/lib/fzeet/windows/core/Point.rb +42 -0
- data/lib/fzeet/windows/core/Rect.rb +114 -0
- data/lib/fzeet/windows/core/Size.rb +34 -0
- data/lib/fzeet/windows/core/SystemTime.rb +46 -0
- data/lib/fzeet/windows/core/Version.rb +57 -0
- data/lib/fzeet/windows/gdi.rb +1 -62
- data/lib/fzeet/windows/gdi/Common.rb +40 -0
- data/lib/fzeet/windows/gdi/Font.rb +64 -0
- data/lib/fzeet/windows/kernel.rb +1 -92
- data/lib/fzeet/windows/kernel/Common.rb +92 -0
- data/lib/fzeet/windows/libc.rb +1 -1
- data/lib/fzeet/windows/libcef.rb +1 -0
- data/lib/fzeet/windows/mshtml.rb +1 -1135
- data/lib/fzeet/windows/mshtml/Common.rb +1135 -0
- data/lib/fzeet/windows/ole.rb +1 -561
- data/lib/fzeet/windows/ole/Common.rb +112 -0
- data/lib/fzeet/windows/ole/PropVariant.rb +141 -0
- data/lib/fzeet/windows/oleaut.rb +3 -0
- data/lib/fzeet/windows/oleaut/Bstr.rb +39 -0
- data/lib/fzeet/windows/oleaut/Common.rb +187 -0
- data/lib/fzeet/windows/oleaut/SafeArray.rb +104 -0
- data/lib/fzeet/windows/oleaut/Variant.rb +269 -0
- data/lib/fzeet/windows/scintilla.rb +115 -1
- data/lib/fzeet/windows/{SciLexer.dll → scintilla/SciLexer.dll} +0 -0
- data/lib/fzeet/windows/shdocvw.rb +150 -0
- data/lib/fzeet/windows/shell.rb +1 -1
- data/lib/fzeet/windows/shell/Common.rb +94 -2
- data/lib/fzeet/windows/shlwapi.rb +1 -1
- data/lib/fzeet/windows/uiribbon.rb +416 -0
- data/lib/fzeet/windows/urlmon.rb +2 -2
- data/lib/fzeet/windows/user.rb +20 -0
- data/lib/fzeet/windows/user/Accelerator.rb +45 -0
- data/lib/fzeet/windows/user/Common.rb +3 -2
- data/lib/fzeet/windows/user/Control/Button.rb +54 -0
- data/lib/fzeet/windows/user/Control/ComboBox.rb +44 -1
- data/lib/fzeet/windows/user/Control/Common.rb +88 -1
- data/lib/fzeet/windows/user/Control/Edit.rb +50 -0
- data/lib/fzeet/windows/user/Control/ListBox.rb +69 -0
- data/lib/fzeet/windows/user/Control/Static.rb +31 -0
- data/lib/fzeet/windows/user/Menu.rb +130 -0
- data/lib/fzeet/windows/user/Message.rb +9 -0
- data/lib/fzeet/windows/user/MessageBox.rb +47 -0
- data/lib/fzeet/windows/user/SystemParametersInfo.rb +1 -1
- data/lib/fzeet/windows/user/Window.rb +5 -463
- data/lib/fzeet/{Window → windows/user/Window}/Common.rb +460 -0
- data/lib/fzeet/{Window → windows/user/Window}/Container.rb +0 -0
- data/lib/fzeet/{Window → windows/user/Window}/Dialog.rb +0 -0
- data/lib/fzeet/{Window → windows/user/Window}/MDI.rb +0 -0
- data/lib/fzeet/{Window → windows/user/Window}/View.rb +0 -0
- data/lib/fzeet/{Window → windows/user/Window}/Window.rb +0 -0
- data/lib/fzeet/{Window → windows/user/Window}/WindowMethods.rb +1 -1
- metadata +55 -61
- data/examples/Control/WebBrowser2.rbw +0 -39
- data/lib/fzeet/Accelerator.rb +0 -48
- data/lib/fzeet/Application.rb +0 -71
- data/lib/fzeet/Common.rb +0 -350
- data/lib/fzeet/Control.rb +0 -19
- data/lib/fzeet/Control/Button.rb +0 -57
- data/lib/fzeet/Control/ComboBox.rb +0 -46
- data/lib/fzeet/Control/ComboBoxEx.rb +0 -35
- data/lib/fzeet/Control/Common.rb +0 -89
- data/lib/fzeet/Control/DateTimePicker.rb +0 -38
- data/lib/fzeet/Control/Edit.rb +0 -53
- data/lib/fzeet/Control/ExplorerBrowser.rb +0 -66
- data/lib/fzeet/Control/Header.rb +0 -63
- data/lib/fzeet/Control/ListBox.rb +0 -72
- data/lib/fzeet/Control/ListView.rb +0 -133
- data/lib/fzeet/Control/MonthCalendar.rb +0 -38
- data/lib/fzeet/Control/ProgressBar.rb +0 -40
- data/lib/fzeet/Control/PropertySheet.rb +0 -51
- data/lib/fzeet/Control/Scintilla.rb +0 -117
- data/lib/fzeet/Control/Static.rb +0 -34
- data/lib/fzeet/Control/SysLink.rb +0 -40
- data/lib/fzeet/Control/Tab.rb +0 -59
- data/lib/fzeet/Control/TreeView.rb +0 -82
- data/lib/fzeet/Control/UpDown.rb +0 -36
- data/lib/fzeet/Control/WebBrowser.rb +0 -153
- data/lib/fzeet/Dialog.rb +0 -6
- data/lib/fzeet/Dialog/ColorDialog.rb +0 -44
- data/lib/fzeet/Dialog/Common.rb +0 -89
- data/lib/fzeet/Dialog/FileDialog.rb +0 -136
- data/lib/fzeet/Dialog/FindReplaceDialog.rb +0 -105
- data/lib/fzeet/Dialog/FontDialog.rb +0 -39
- data/lib/fzeet/Dialog/PrintDialog.rb +0 -75
- data/lib/fzeet/Menu.rb +0 -133
- data/lib/fzeet/UIRibbon.rb +0 -417
- data/lib/fzeet/Window.rb +0 -5
- data/lib/fzeet/windows/common.rb +0 -244
@@ -195,4 +195,76 @@ module Fzeet
|
|
195
195
|
|
196
196
|
attach_function :PrintDlgEx, :PrintDlgExA, [:pointer], :long
|
197
197
|
end
|
198
|
+
|
199
|
+
class PageSetupDialog
|
200
|
+
def initialize(opts = {})
|
201
|
+
_opts = {
|
202
|
+
|
203
|
+
}
|
204
|
+
badopts = opts.keys - _opts.keys; raise "Bad option(s): #{badopts.join(', ')}." unless badopts.empty?
|
205
|
+
_opts.merge!(opts)
|
206
|
+
|
207
|
+
@struct = Windows::PAGESETUPDLG.new
|
208
|
+
|
209
|
+
@struct[:lStructSize] = @struct.size
|
210
|
+
@struct[:hInstance] = Windows.GetModuleHandle(nil)
|
211
|
+
@struct[:Flags] = Fzeet.flags(0, :psd_)
|
212
|
+
end
|
213
|
+
|
214
|
+
attr_reader :struct
|
215
|
+
|
216
|
+
def show(window = Application.window)
|
217
|
+
@struct[:hwndOwner] = window.handle
|
218
|
+
|
219
|
+
DialogResult.new((Windows.PageSetupDlg(@struct) == 0) ? Windows::IDCANCEL : Windows::IDOK)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
class PrintDialog
|
224
|
+
def initialize(opts = {})
|
225
|
+
_opts = {
|
226
|
+
|
227
|
+
}
|
228
|
+
badopts = opts.keys - _opts.keys; raise "Bad option(s): #{badopts.join(', ')}." unless badopts.empty?
|
229
|
+
_opts.merge!(opts)
|
230
|
+
|
231
|
+
@struct = Windows::PRINTDLG.new
|
232
|
+
|
233
|
+
@struct[:lStructSize] = 66
|
234
|
+
@struct[:hInstance] = Windows.GetModuleHandle(nil)
|
235
|
+
@struct[:Flags] = Fzeet.flags([:returndc, :usedevmodecopiesandcollate], :pd_)
|
236
|
+
end
|
237
|
+
|
238
|
+
attr_reader :struct
|
239
|
+
|
240
|
+
def show(window = Application.window)
|
241
|
+
@struct[:hwndOwner] = window.handle
|
242
|
+
|
243
|
+
DialogResult.new((Windows.PrintDlg(@struct) == 0) ? Windows::IDCANCEL : Windows::IDOK)
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
class PrintDialogEx
|
248
|
+
def initialize(opts = {})
|
249
|
+
_opts = {
|
250
|
+
|
251
|
+
}
|
252
|
+
badopts = opts.keys - _opts.keys; raise "Bad option(s): #{badopts.join(', ')}." unless badopts.empty?
|
253
|
+
_opts.merge!(opts)
|
254
|
+
|
255
|
+
@struct = Windows::PRINTDLGEX.new
|
256
|
+
|
257
|
+
@struct[:lStructSize] = @struct.size
|
258
|
+
@struct[:hInstance] = Windows.GetModuleHandle(nil)
|
259
|
+
@struct[:Flags] = Fzeet.flags([:returndc, :usedevmodecopiesandcollate], :pd_)
|
260
|
+
end
|
261
|
+
|
262
|
+
attr_reader :struct
|
263
|
+
|
264
|
+
def show(window = Application.window)
|
265
|
+
@struct[:hwndOwner] = window.handle
|
266
|
+
|
267
|
+
DialogResult.new((Windows.PrintDlgEx(@struct) != Windows::S_OK) ? Windows::IDCANCEL : Windows::IDOK)
|
268
|
+
end
|
269
|
+
end
|
198
270
|
end
|
File without changes
|
@@ -0,0 +1,324 @@
|
|
1
|
+
require 'ffi'
|
2
|
+
|
3
|
+
module Fzeet
|
4
|
+
module Windows
|
5
|
+
extend FFI::Library
|
6
|
+
|
7
|
+
ffi_lib 'kernel32'
|
8
|
+
ffi_convention :stdcall
|
9
|
+
|
10
|
+
INVALID_HANDLE_VALUE = FFI::Pointer.new(-1)
|
11
|
+
INVALID_FILE_SIZE = 0xFFFFFFFF
|
12
|
+
INVALID_SET_FILE_POINTER = 0xFFFFFFFF
|
13
|
+
INVALID_FILE_ATTRIBUTES = 0xFFFFFFFF
|
14
|
+
INVALID_ATOM = 0
|
15
|
+
|
16
|
+
attach_function :GetLastError, [], :ulong
|
17
|
+
attach_function :SetLastError, [:ulong], :void
|
18
|
+
|
19
|
+
def Detonate(on, name, *args)
|
20
|
+
raise "#{name} failed." if (failed = [*on].include?(result = send(name, *args)))
|
21
|
+
|
22
|
+
result
|
23
|
+
ensure
|
24
|
+
yield failed if block_given?
|
25
|
+
end
|
26
|
+
|
27
|
+
def DetonateLastError(on, name, *args)
|
28
|
+
raise "#{name} failed (last error #{GetLastError()})." if (failed = [*on].include?(result = send(name, *args)))
|
29
|
+
|
30
|
+
result
|
31
|
+
ensure
|
32
|
+
yield failed if block_given?
|
33
|
+
end
|
34
|
+
|
35
|
+
module_function :Detonate, :DetonateLastError
|
36
|
+
|
37
|
+
def LOBYTE(w) w & 0xff end
|
38
|
+
def HIBYTE(w) (w >> 8) & 0xff end
|
39
|
+
def MAKEWORD(low, high) (low & 0xff) | ((high & 0xff) << 8) end
|
40
|
+
|
41
|
+
def LOWORD(l) l & 0xffff end
|
42
|
+
def HIWORD(l) (l >> 16) & 0xffff end
|
43
|
+
def MAKELONG(low, high) (low & 0xffff) | ((high & 0xffff) << 16) end
|
44
|
+
|
45
|
+
def GET_X_LPARAM(l) ((w = LOWORD(l)) > 0x7fff) ? w - 0x1_0000 : w end
|
46
|
+
def GET_Y_LPARAM(l) ((w = HIWORD(l)) > 0x7fff) ? w - 0x1_0000 : w end
|
47
|
+
|
48
|
+
def LPWSTR(s)
|
49
|
+
p = FFI::MemoryPointer.new(:uchar, (s.length + 2) * 2)
|
50
|
+
|
51
|
+
"#{s}\0".encode('utf-16le').each_byte.with_index { |b, i| p.put_char(i, b) }
|
52
|
+
|
53
|
+
begin
|
54
|
+
yield p; return nil
|
55
|
+
ensure
|
56
|
+
p.free
|
57
|
+
end if block_given?
|
58
|
+
|
59
|
+
p
|
60
|
+
end
|
61
|
+
|
62
|
+
def WCSTOMBS(p)
|
63
|
+
result = ''
|
64
|
+
|
65
|
+
FFI::MemoryPointer.new(:uchar, len = wcslen(p) + 1) { |buf|
|
66
|
+
raise 'wcstombs failed.' if wcstombs(buf, p, len) == 0xffffffff
|
67
|
+
|
68
|
+
result << buf.read_string
|
69
|
+
}
|
70
|
+
|
71
|
+
result
|
72
|
+
end
|
73
|
+
|
74
|
+
module_function \
|
75
|
+
:LOBYTE, :HIBYTE, :MAKEWORD,
|
76
|
+
:LOWORD, :HIWORD, :MAKELONG,
|
77
|
+
:GET_X_LPARAM, :GET_Y_LPARAM,
|
78
|
+
:LPWSTR, :WCSTOMBS
|
79
|
+
|
80
|
+
module AnonymousSupport
|
81
|
+
def [](k)
|
82
|
+
if members.include?(k)
|
83
|
+
super
|
84
|
+
elsif self[:_].members.include?(k)
|
85
|
+
self[:_][k]
|
86
|
+
else
|
87
|
+
self[:_][:_][k]
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def []=(k, v)
|
92
|
+
if members.include?(k)
|
93
|
+
super
|
94
|
+
elsif self[:_].members.include?(k)
|
95
|
+
self[:_][k] = v
|
96
|
+
else
|
97
|
+
self[:_][:_][k] = v
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
class HANDLE
|
103
|
+
@@instances = {}
|
104
|
+
|
105
|
+
def self.instance?(handle) @@instances.include?(handle.to_i) end
|
106
|
+
def self.instance(handle) raise "#{self}.#{__method__} failed." unless (instance = @@instances[handle.to_i]); instance end
|
107
|
+
|
108
|
+
def self.wrap(handle, *ifaces)
|
109
|
+
Object.new.tap { |o|
|
110
|
+
o.instance_variable_set(:@handle, handle)
|
111
|
+
o.class.send(:attr_reader, :handle)
|
112
|
+
ifaces.each { |iface| o.class.send(:include, iface) }
|
113
|
+
}
|
114
|
+
end
|
115
|
+
|
116
|
+
attr_reader :handle
|
117
|
+
|
118
|
+
def attach; @@instances[@handle.to_i] = self end
|
119
|
+
def detach; @@instances.delete(@handle.to_i) end
|
120
|
+
|
121
|
+
def dup; raise "#{self}.#{__method__} is not implemented." end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
Handle = Windows::HANDLE
|
126
|
+
|
127
|
+
module Toggle
|
128
|
+
def toggle(what)
|
129
|
+
send("#{what}=", !send("#{what}?"))
|
130
|
+
|
131
|
+
begin
|
132
|
+
yield self
|
133
|
+
ensure
|
134
|
+
toggle(what)
|
135
|
+
end if block_given?
|
136
|
+
|
137
|
+
self
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def constant(c, *prefixes)
|
142
|
+
return c if c.kind_of?(Integer) || c.kind_of?(FFI::Pointer)
|
143
|
+
|
144
|
+
c = c.upcase
|
145
|
+
|
146
|
+
prefixes.map! { |prefix|
|
147
|
+
prefix = prefix.upcase
|
148
|
+
|
149
|
+
"#{prefix}#{c}".tap { |name|
|
150
|
+
return Windows.const_get(name) if Windows.const_defined?(name)
|
151
|
+
}
|
152
|
+
}
|
153
|
+
|
154
|
+
raise "Constant not found: #{c} (tried: #{prefixes.join(', ')})."
|
155
|
+
end
|
156
|
+
|
157
|
+
def flags(flags, *prefixes)
|
158
|
+
return flags if flags.kind_of?(Integer)
|
159
|
+
|
160
|
+
[*flags].inject(0) { |flags, flag| flags |= constant(flag, *prefixes) }
|
161
|
+
end
|
162
|
+
|
163
|
+
module_function :constant, :flags
|
164
|
+
|
165
|
+
def using(o, cleanup = :dispose)
|
166
|
+
yield o
|
167
|
+
ensure
|
168
|
+
o.send(cleanup)
|
169
|
+
end
|
170
|
+
|
171
|
+
module_function :using
|
172
|
+
|
173
|
+
module IconMethods
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
class SystemIcon < Handle
|
178
|
+
include IconMethods
|
179
|
+
|
180
|
+
def initialize(id)
|
181
|
+
@handle = Windows.DetonateLastError(FFI::Pointer::NULL, :LoadIcon, nil, @id = Fzeet.constant(id, :idi_)); attach
|
182
|
+
end
|
183
|
+
|
184
|
+
attr_reader :id
|
185
|
+
|
186
|
+
def dispose; detach end
|
187
|
+
end
|
188
|
+
|
189
|
+
module CursorMethods
|
190
|
+
|
191
|
+
end
|
192
|
+
|
193
|
+
class SystemCursor < Handle
|
194
|
+
include CursorMethods
|
195
|
+
|
196
|
+
def initialize(id)
|
197
|
+
@handle = Windows.DetonateLastError(FFI::Pointer::NULL, :LoadCursor, nil, @id = Fzeet.constant(id, :idc_)); attach
|
198
|
+
end
|
199
|
+
|
200
|
+
attr_reader :id
|
201
|
+
|
202
|
+
def dispose; detach end
|
203
|
+
end
|
204
|
+
|
205
|
+
module BrushMethods
|
206
|
+
|
207
|
+
end
|
208
|
+
|
209
|
+
class SystemBrush < Handle
|
210
|
+
include BrushMethods
|
211
|
+
|
212
|
+
def initialize(id)
|
213
|
+
@handle = FFI::Pointer.new((@id = Fzeet.constant(id, :color_, :ctlcolor_)) + 1); attach
|
214
|
+
end
|
215
|
+
|
216
|
+
attr_reader :id
|
217
|
+
|
218
|
+
def dispose; detach end
|
219
|
+
end
|
220
|
+
|
221
|
+
module FontMethods
|
222
|
+
|
223
|
+
end
|
224
|
+
|
225
|
+
class IndirectFont < Handle
|
226
|
+
include FontMethods
|
227
|
+
|
228
|
+
def initialize(logfont)
|
229
|
+
@handle = Windows.DetonateLastError(FFI::Pointer::NULL, :CreateFontIndirect, @logfont = logfont); attach
|
230
|
+
end
|
231
|
+
|
232
|
+
attr_reader :logfont
|
233
|
+
|
234
|
+
def dispose; Windows.DeleteObject(@handle); detach end
|
235
|
+
end
|
236
|
+
|
237
|
+
module BitmapMethods
|
238
|
+
|
239
|
+
end
|
240
|
+
|
241
|
+
class PARGB32 < Handle
|
242
|
+
include BitmapMethods
|
243
|
+
|
244
|
+
def initialize(path, width = 0, height = 0)
|
245
|
+
@handle = Windows.DetonateLastError(FFI::Pointer::NULL, :LoadImage,
|
246
|
+
nil,
|
247
|
+
@path = path,
|
248
|
+
Windows::IMAGE_BITMAP,
|
249
|
+
width,
|
250
|
+
height,
|
251
|
+
Windows::LR_LOADFROMFILE | Windows::LR_CREATEDIBSECTION
|
252
|
+
)
|
253
|
+
|
254
|
+
attach
|
255
|
+
end
|
256
|
+
|
257
|
+
attr_reader :path
|
258
|
+
|
259
|
+
def dispose; Windows.DeleteObject(@handle); detach end
|
260
|
+
end
|
261
|
+
|
262
|
+
module DCMethods
|
263
|
+
def select(*objects)
|
264
|
+
holds = []
|
265
|
+
|
266
|
+
objects.each { |object|
|
267
|
+
holds << Windows.DetonateLastError(FFI::Pointer::NULL, :SelectObject, @handle, object.handle)
|
268
|
+
}
|
269
|
+
|
270
|
+
yield self
|
271
|
+
|
272
|
+
self
|
273
|
+
ensure
|
274
|
+
holds.each { |hold| Windows.SelectObject(@handle, hold) }
|
275
|
+
end
|
276
|
+
|
277
|
+
def textExtent(text) Windows.DetonateLastError(0, :GetTextExtentPoint, @handle, text, text.length, s = Size.new); s end
|
278
|
+
|
279
|
+
def color; Windows.GetTextColor(@handle) end
|
280
|
+
def color=(color) Windows.SetTextColor(@handle, color) end
|
281
|
+
|
282
|
+
def background; Windows.GetBkColor(@handle) end
|
283
|
+
def background=(background) Windows.SetBkColor(@handle, background) end
|
284
|
+
|
285
|
+
def fillRect(rect, brush) Windows.DetonateLastError(0, :FillRect, @handle, rect, (brush.kind_of?(FFI::Pointer)) ? brush : brush.handle); self end
|
286
|
+
|
287
|
+
def text(text, rect, flags = 0) Windows.DetonateLastError(0, :DrawText, @handle, text, -1, rect, Fzeet.flags(flags, :dt_)); self end
|
288
|
+
|
289
|
+
def sms(message)
|
290
|
+
r = window.rect
|
291
|
+
|
292
|
+
r[:top] += window.ribbon.height if window.ribbon
|
293
|
+
|
294
|
+
text(message, r, [:singleline, :center, :vcenter])
|
295
|
+
|
296
|
+
self
|
297
|
+
end
|
298
|
+
|
299
|
+
def move(x, y) Windows.DetonateLastError(0, :MoveToEx, @handle, x, y, nil); self end
|
300
|
+
def line(x, y) Windows.DetonateLastError(0, :LineTo, @handle, x, y); self end
|
301
|
+
end
|
302
|
+
|
303
|
+
class ClientDC < Handle
|
304
|
+
include DCMethods
|
305
|
+
|
306
|
+
def initialize(window)
|
307
|
+
@handle = Windows.DetonateLastError(FFI::Pointer::NULL, :GetDC, (@window = window).handle); attach
|
308
|
+
end
|
309
|
+
|
310
|
+
attr_reader :window
|
311
|
+
|
312
|
+
def dispose; Windows.ReleaseDC(@window.handle, @handle); detach end
|
313
|
+
end
|
314
|
+
|
315
|
+
class ScreenDC < Handle
|
316
|
+
include DCMethods
|
317
|
+
|
318
|
+
def initialize
|
319
|
+
@handle = Windows.DetonateLastError(FFI::Pointer::NULL, :GetDC, nil); attach
|
320
|
+
end
|
321
|
+
|
322
|
+
def dispose; Windows.ReleaseDC(nil, @handle); detach end
|
323
|
+
end
|
324
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require_relative 'Common'
|
2
|
+
|
3
|
+
module Fzeet
|
4
|
+
module Windows
|
5
|
+
class POINT < FFI::Struct
|
6
|
+
layout \
|
7
|
+
:x, :long,
|
8
|
+
:y, :long
|
9
|
+
|
10
|
+
def self.[](x, y) new.set(x, y) end
|
11
|
+
|
12
|
+
class << self
|
13
|
+
alias from []
|
14
|
+
alias wrap new
|
15
|
+
end
|
16
|
+
|
17
|
+
def dup; self.class[self[:x], self[:y]] end
|
18
|
+
|
19
|
+
def get; [self[:x], self[:y]] end
|
20
|
+
alias to_a get
|
21
|
+
|
22
|
+
def set(x, y) tap { |pt| pt[:x], pt[:y] = x, y } end
|
23
|
+
|
24
|
+
def clear; set(0, 0) end
|
25
|
+
|
26
|
+
def ==(other) self[:x] == other[:x] && self[:y] == other[:y] end
|
27
|
+
def inside?(r) r.include?(self) end
|
28
|
+
def outside?(r) !inside?(r) end
|
29
|
+
|
30
|
+
def offset(dx, dy) dup.offset!(dx, dy) end
|
31
|
+
def offset!(dx, dy) tap { |pt| pt[:x] += dx; pt[:y] += dy } end
|
32
|
+
|
33
|
+
def client(window) dup.client!(window) end
|
34
|
+
def client!(window) tap { |pt| Windows.Detonate(0, :ScreenToClient, window.handle, pt) } end
|
35
|
+
|
36
|
+
def screen(window) dup.screen!(window) end
|
37
|
+
def screen!(window) tap { |pt| Windows.Detonate(0, :ClientToScreen, window.handle, pt) } end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
Point = Windows::POINT
|
42
|
+
end
|