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
data/lib/fzeet/Menu.rb
DELETED
@@ -1,133 +0,0 @@
|
|
1
|
-
require_relative 'Common'
|
2
|
-
|
3
|
-
module Fzeet
|
4
|
-
module MenuMethods
|
5
|
-
def rdetach; submenus.each(&:rdetach); detach end
|
6
|
-
|
7
|
-
class Item
|
8
|
-
include Toggle
|
9
|
-
|
10
|
-
def initialize(menu, id) @menu, @id = menu, Command[id] end
|
11
|
-
|
12
|
-
attr_reader :menu, :id
|
13
|
-
|
14
|
-
def enabled?
|
15
|
-
flags = Windows.DetonateLastError(-1, :GetMenuState, @menu.handle, @id, 0)
|
16
|
-
|
17
|
-
(flags & Windows::MF_GRAYED) != Windows::MF_GRAYED
|
18
|
-
end
|
19
|
-
|
20
|
-
def enabled=(enabled)
|
21
|
-
Windows.DetonateLastError(-1, :EnableMenuItem,
|
22
|
-
@menu.handle,
|
23
|
-
@id,
|
24
|
-
(enabled) ? Windows::MF_ENABLED : Windows::MF_GRAYED
|
25
|
-
)
|
26
|
-
end
|
27
|
-
|
28
|
-
def checked?
|
29
|
-
flags = Windows.DetonateLastError(-1, :GetMenuState, @menu.handle, @id, 0)
|
30
|
-
|
31
|
-
(flags & Windows::MF_CHECKED) == Windows::MF_CHECKED
|
32
|
-
end
|
33
|
-
|
34
|
-
def checked=(checked)
|
35
|
-
Windows.DetonateLastError(-1, :CheckMenuItem,
|
36
|
-
@menu.handle,
|
37
|
-
@id,
|
38
|
-
(checked) ? Windows::MF_CHECKED : Windows::MF_UNCHECKED
|
39
|
-
)
|
40
|
-
end
|
41
|
-
|
42
|
-
def select(first, last)
|
43
|
-
Windows.DetonateLastError(0, :CheckMenuRadioItem,
|
44
|
-
@menu.handle, Command[first], Command[last], @id, 0
|
45
|
-
)
|
46
|
-
|
47
|
-
self
|
48
|
-
end
|
49
|
-
|
50
|
-
def info(mask)
|
51
|
-
Windows.DetonateLastError(0, :GetMenuItemInfo,
|
52
|
-
@menu.handle,
|
53
|
-
@id,
|
54
|
-
0,
|
55
|
-
info = Windows::MENUITEMINFO.new.tap { |mii|
|
56
|
-
mii[:cbSize] = mii.size
|
57
|
-
mii[:fMask] = Fzeet.constant(mask, :miim_)
|
58
|
-
}
|
59
|
-
)
|
60
|
-
|
61
|
-
info
|
62
|
-
end
|
63
|
-
|
64
|
-
def info=(mii)
|
65
|
-
Windows.DetonateLastError(0, :SetMenuItemInfo,
|
66
|
-
@menu.handle,
|
67
|
-
@id,
|
68
|
-
0,
|
69
|
-
mii.tap { mii[:cbSize] = mii.size }
|
70
|
-
)
|
71
|
-
end
|
72
|
-
|
73
|
-
def image; (Handle.instance?(handle = info(:bitmap)[:hbmpItem])) ? Handle.instance(handle) : nil end
|
74
|
-
|
75
|
-
def image=(image)
|
76
|
-
self.info = Windows::MENUITEMINFO.new.tap { |mii|
|
77
|
-
mii[:fMask] = Windows::MIIM_BITMAP
|
78
|
-
mii[:hbmpItem] = image.handle
|
79
|
-
}
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def [](id) Item.new(self, id) end
|
84
|
-
|
85
|
-
def append(flags, item = nil, id = 0)
|
86
|
-
Windows.DetonateLastError(0, :AppendMenu,
|
87
|
-
@handle,
|
88
|
-
Fzeet.flags(flags, :mf_, :mft_, :mfs_),
|
89
|
-
case id
|
90
|
-
when Integer; id
|
91
|
-
when Symbol; Command[id]
|
92
|
-
when MenuMethods; submenus << id; id.handle.to_i
|
93
|
-
else raise ArgumentError
|
94
|
-
end,
|
95
|
-
item
|
96
|
-
)
|
97
|
-
|
98
|
-
self
|
99
|
-
end
|
100
|
-
|
101
|
-
def images=(images) images.each { |id, image| self[id].image = image } end
|
102
|
-
end
|
103
|
-
|
104
|
-
class Menu < Handle
|
105
|
-
include MenuMethods
|
106
|
-
|
107
|
-
def initialize
|
108
|
-
@submenus = []
|
109
|
-
|
110
|
-
@handle = Windows.DetonateLastError(FFI::Pointer::NULL, :CreateMenu); attach
|
111
|
-
end
|
112
|
-
|
113
|
-
attr_reader :submenus
|
114
|
-
|
115
|
-
def dispose; Windows.DestroyMenu(@handle); rdetach end
|
116
|
-
end
|
117
|
-
|
118
|
-
class PopupMenu < Handle
|
119
|
-
include MenuMethods
|
120
|
-
|
121
|
-
def initialize
|
122
|
-
@submenus = []
|
123
|
-
|
124
|
-
@handle = Windows.DetonateLastError(FFI::Pointer::NULL, :CreatePopupMenu); attach
|
125
|
-
end
|
126
|
-
|
127
|
-
attr_reader :submenus
|
128
|
-
|
129
|
-
def dispose; Windows.DestroyMenu(@handle); rdetach end
|
130
|
-
|
131
|
-
def track(window, x, y, flags = 0) Windows.TrackPopupMenu(@handle, Fzeet.flags(flags, :tpm_), x, y, 0, window.handle, nil); self end
|
132
|
-
end
|
133
|
-
end
|
data/lib/fzeet/UIRibbon.rb
DELETED
@@ -1,417 +0,0 @@
|
|
1
|
-
require_relative 'Common'
|
2
|
-
|
3
|
-
module Fzeet
|
4
|
-
class Windows::PropertyStore
|
5
|
-
def uiprop(*args)
|
6
|
-
args[0] = Windows.const_get("UI_PKEY_#{args[0]}")
|
7
|
-
|
8
|
-
prop(*args)
|
9
|
-
end
|
10
|
-
|
11
|
-
def update(from)
|
12
|
-
case from
|
13
|
-
when Windows::LOGFONT
|
14
|
-
uiprop(:FontProperties_Family, Windows::PROPVARIANT[:wstring, from.face])
|
15
|
-
uiprop(:FontProperties_Size, Windows::PROPVARIANT[:decimal, from.size.round])
|
16
|
-
uiprop(:FontProperties_Bold, Windows::PROPVARIANT[:uint, (from.bold?) ? 2 : 1])
|
17
|
-
uiprop(:FontProperties_Italic, Windows::PROPVARIANT[:uint, (from.italic?) ? 2 : 1])
|
18
|
-
uiprop(:FontProperties_Underline, Windows::PROPVARIANT[:uint, (from.underline?) ? 2 : 1])
|
19
|
-
uiprop(:FontProperties_Strikethrough, Windows::PROPVARIANT[:uint, (from.strikeout?) ? 2 : 1])
|
20
|
-
else raise ArgumentError
|
21
|
-
end
|
22
|
-
|
23
|
-
self
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
class Windows::UISimplePropertySet
|
28
|
-
def get(k) Windows::PROPVARIANT.new.tap { |v| GetValue(k, v) } end
|
29
|
-
|
30
|
-
def prop(*args)
|
31
|
-
case args.length
|
32
|
-
when 1; get(*args)
|
33
|
-
else raise ArgumentError
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def uiprop(*args)
|
38
|
-
args[0] = Windows.const_get("UI_PKEY_#{args[0]}")
|
39
|
-
|
40
|
-
prop(*args)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
class UIRibbon
|
45
|
-
class Command
|
46
|
-
include Toggle
|
47
|
-
|
48
|
-
def initialize(ribbon, id)
|
49
|
-
@ribbon, @id = ribbon, id
|
50
|
-
end
|
51
|
-
|
52
|
-
attr_reader :ribbon, :id
|
53
|
-
|
54
|
-
def [](k) Windows::PROPVARIANT.new.tap { |v| ribbon.uif.GetUICommandProperty(id, k, v) } end
|
55
|
-
def []=(k, v) ribbon.uif.SetUICommandProperty(id, k, v) end
|
56
|
-
|
57
|
-
def enabled?; self[Windows::UI_PKEY_Enabled].bool end
|
58
|
-
def enabled=(enabled) self[Windows::UI_PKEY_Enabled] = Windows::PROPVARIANT[:bool, enabled] end
|
59
|
-
|
60
|
-
def checked?; self[Windows::UI_PKEY_BooleanValue].bool end
|
61
|
-
def checked=(checked) self[Windows::UI_PKEY_BooleanValue] = Windows::PROPVARIANT[:bool, checked] end
|
62
|
-
end
|
63
|
-
|
64
|
-
def [](id) Command.new(self, id) end
|
65
|
-
|
66
|
-
module Color
|
67
|
-
def self.enhance(hsb, ribbon, method)
|
68
|
-
hsb.instance_variable_set(:@ribbon, ribbon)
|
69
|
-
hsb.instance_variable_set(:@method, method)
|
70
|
-
|
71
|
-
class << hsb
|
72
|
-
attr_reader :ribbon, :method
|
73
|
-
|
74
|
-
include Color
|
75
|
-
end
|
76
|
-
|
77
|
-
hsb
|
78
|
-
end
|
79
|
-
|
80
|
-
def darken(amount) self[2] -= amount; ribbon.send("#{method}=", self); self end
|
81
|
-
def lighten(amount) self[2] += amount; ribbon.send("#{method}=", self); self end
|
82
|
-
|
83
|
-
def saturate(amount) self[1] += amount; ribbon.send("#{method}=", self); self end
|
84
|
-
def bleach(amount) self[1] -= amount; ribbon.send("#{method}=", self); self end
|
85
|
-
|
86
|
-
def shift(amount) self[0] += amount; ribbon.send("#{method}=", self); self end
|
87
|
-
end
|
88
|
-
|
89
|
-
def background
|
90
|
-
hsb = nil
|
91
|
-
|
92
|
-
uif.QueryInstance(Windows::PropertyStore) { |ps|
|
93
|
-
hsb = ps.uiprop(:GlobalBackgroundColor).uint
|
94
|
-
}
|
95
|
-
|
96
|
-
Color.enhance([Windows::UI_GetHValue(hsb), Windows::UI_GetSValue(hsb), Windows::UI_GetBValue(hsb)], self, __method__)
|
97
|
-
end
|
98
|
-
|
99
|
-
def background=(hsb)
|
100
|
-
uif.QueryInstance(Windows::PropertyStore) { |ps|
|
101
|
-
ps.uiprop(:GlobalBackgroundColor, Windows::PROPVARIANT[:uint, Windows::UI_HSB(*hsb)]).commit
|
102
|
-
}
|
103
|
-
end
|
104
|
-
|
105
|
-
def color
|
106
|
-
hsb = nil
|
107
|
-
|
108
|
-
uif.QueryInstance(Windows::PropertyStore) { |ps|
|
109
|
-
hsb = ps.uiprop(:GlobalTextColor).uint
|
110
|
-
}
|
111
|
-
|
112
|
-
Color.enhance([Windows::UI_GetHValue(hsb), Windows::UI_GetSValue(hsb), Windows::UI_GetBValue(hsb)], self, __method__)
|
113
|
-
end
|
114
|
-
|
115
|
-
def color=(hsb)
|
116
|
-
uif.QueryInstance(Windows::PropertyStore) { |ps|
|
117
|
-
ps.uiprop(:GlobalTextColor, Windows::PROPVARIANT[:uint, Windows::UI_HSB(*hsb)]).commit
|
118
|
-
}
|
119
|
-
end
|
120
|
-
|
121
|
-
def highlight
|
122
|
-
hsb = nil
|
123
|
-
|
124
|
-
uif.QueryInstance(Windows::PropertyStore) { |ps|
|
125
|
-
hsb = ps.uiprop(:GlobalHighlightColor).uint
|
126
|
-
}
|
127
|
-
|
128
|
-
Color.enhance([Windows::UI_GetHValue(hsb), Windows::UI_GetSValue(hsb), Windows::UI_GetBValue(hsb)], self, __method__)
|
129
|
-
end
|
130
|
-
|
131
|
-
def highlight=(hsb)
|
132
|
-
uif.QueryInstance(Windows::PropertyStore) { |ps|
|
133
|
-
ps.uiprop(:GlobalHighlightColor, Windows::PROPVARIANT[:uint, Windows::UI_HSB(*hsb)]).commit
|
134
|
-
}
|
135
|
-
end
|
136
|
-
|
137
|
-
class GalleryItem < Windows::UISimplePropertySetCallback
|
138
|
-
def initialize(label, categoryId = 0, image = nil)
|
139
|
-
@label, @categoryId, @image = label, categoryId, image
|
140
|
-
|
141
|
-
super()
|
142
|
-
end
|
143
|
-
|
144
|
-
attr_reader :label, :categoryId, :image
|
145
|
-
|
146
|
-
def GetValue(pkey, pvalue)
|
147
|
-
key, value = Windows::PROPERTYKEY.new(pkey), Windows::PROPVARIANT.new(pvalue)
|
148
|
-
|
149
|
-
case key
|
150
|
-
when Windows::UI_PKEY_CategoryId
|
151
|
-
value.uint = @categoryId; Windows::S_OK
|
152
|
-
when Windows::UI_PKEY_Label
|
153
|
-
value.wstring = @label; Windows::S_OK
|
154
|
-
when Windows::UI_PKEY_ItemImage
|
155
|
-
FFI::MemoryPointer.new(:pointer) { |punk|
|
156
|
-
Windows::UIImageFromBitmap.new.CreateImage(PARGB32.new(@image).handle, Windows::UI_OWNERSHIP_TRANSFER, punk)
|
157
|
-
|
158
|
-
unk = Windows::Unknown.new(punk.read_pointer)
|
159
|
-
value.unknown = unk
|
160
|
-
unk.Release
|
161
|
-
}
|
162
|
-
|
163
|
-
Windows::S_OK
|
164
|
-
else
|
165
|
-
Windows::E_NOTIMPL
|
166
|
-
end
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
def initialize(_window, opts = {})
|
171
|
-
handlers = {}
|
172
|
-
|
173
|
-
opts.delete_if { |k, v|
|
174
|
-
next false unless v.kind_of?(Proc)
|
175
|
-
|
176
|
-
handlers[k] = v; true
|
177
|
-
}
|
178
|
-
|
179
|
-
_opts = {
|
180
|
-
name: Application.name,
|
181
|
-
resname: 'APPLICATION_RIBBON'
|
182
|
-
}
|
183
|
-
badopts = opts.keys - _opts.keys; raise "Bad option(s): #{badopts.join(', ')}." unless badopts.empty?
|
184
|
-
_opts.merge!(opts)
|
185
|
-
|
186
|
-
@creates = []
|
187
|
-
@destroys = []
|
188
|
-
@sizes = []
|
189
|
-
@executesAllVerbs = {}
|
190
|
-
@executesExecute = {}
|
191
|
-
@executesPreview = {}
|
192
|
-
@executesCancelPreview = {}
|
193
|
-
@updatesAllKeys = {}
|
194
|
-
|
195
|
-
@window = _window
|
196
|
-
|
197
|
-
window.instance_variable_set(:@ribbon, self)
|
198
|
-
|
199
|
-
class << window
|
200
|
-
attr_reader :ribbon
|
201
|
-
end
|
202
|
-
|
203
|
-
@uich = Windows::UICommandHandler.new
|
204
|
-
|
205
|
-
uich.instance_variable_set(:@ribbon, self)
|
206
|
-
|
207
|
-
class << uich
|
208
|
-
attr_reader :ribbon
|
209
|
-
|
210
|
-
def Execute(*args) ribbon.execute(*args); Windows::S_OK end
|
211
|
-
def UpdateProperty(*args) ribbon.update(*args); Windows::S_OK end
|
212
|
-
end
|
213
|
-
|
214
|
-
@uia = Windows::UIApplication.new
|
215
|
-
|
216
|
-
uia.instance_variable_set(:@uich, @uich)
|
217
|
-
|
218
|
-
class << uia
|
219
|
-
attr_reader :uich, :uir
|
220
|
-
|
221
|
-
def OnViewChanged(viewId, typeId, view, verb, reason)
|
222
|
-
return Windows::S_OK unless typeId == Windows::UI_VIEWTYPE_RIBBON
|
223
|
-
|
224
|
-
args = {
|
225
|
-
viewId: viewId,
|
226
|
-
typeId: typeId,
|
227
|
-
view: view,
|
228
|
-
verb: verb,
|
229
|
-
reason: reason,
|
230
|
-
ribbon: self,
|
231
|
-
sender: self
|
232
|
-
}
|
233
|
-
|
234
|
-
case verb
|
235
|
-
when Windows::UI_VIEWVERB_CREATE
|
236
|
-
@uir = Windows::Unknown.new(view).QueryInstance(Windows::UIRibbon)
|
237
|
-
|
238
|
-
uir.instance_variable_set(:@height, 0)
|
239
|
-
|
240
|
-
class << uir
|
241
|
-
attr_accessor :height
|
242
|
-
end
|
243
|
-
|
244
|
-
uich.ribbon.instance_variable_get(:@creates).each { |handler|
|
245
|
-
(handler.arity == 0) ? handler.call : handler.call(args)
|
246
|
-
}
|
247
|
-
when Windows::UI_VIEWVERB_DESTROY
|
248
|
-
uich.ribbon.instance_variable_get(:@destroys).each { |handler|
|
249
|
-
(handler.arity == 0) ? handler.call : handler.call(args)
|
250
|
-
}
|
251
|
-
|
252
|
-
uir.Release
|
253
|
-
when Windows::UI_VIEWVERB_SIZE
|
254
|
-
FFI::MemoryPointer.new(:uint) { |p| uir.GetHeight(p); uir.height = p.read_int }
|
255
|
-
|
256
|
-
uich.ribbon.instance_variable_get(:@sizes).each { |handler|
|
257
|
-
(handler.arity == 0) ? handler.call : handler.call(args)
|
258
|
-
}
|
259
|
-
end
|
260
|
-
|
261
|
-
Windows::S_OK
|
262
|
-
rescue
|
263
|
-
Fzeet.message %Q{#{$!}\n\n#{$!.backtrace.join("\n")}}, icon: :error
|
264
|
-
|
265
|
-
Windows::S_OK
|
266
|
-
end
|
267
|
-
|
268
|
-
def OnCreateUICommand(*args) uich.QueryInterface(uich.class::IID, args[-1]); Windows::S_OK end
|
269
|
-
end
|
270
|
-
|
271
|
-
@hdll = Windows.LoadRibbonDll(_opts[:name])
|
272
|
-
|
273
|
-
handlers.each { |k, v|
|
274
|
-
k[1] = Object.const_get(k[1]) if k.length > 1
|
275
|
-
|
276
|
-
on(*k, &v)
|
277
|
-
}
|
278
|
-
|
279
|
-
@uif = Windows::UIFramework.new
|
280
|
-
|
281
|
-
uif.Initialize(window.handle, uia)
|
282
|
-
uif.LoadUI(@hdll, "#{_opts[:resname]}\0".encode('utf-16le'))
|
283
|
-
|
284
|
-
window.on(:destroy) {
|
285
|
-
uich.Release
|
286
|
-
uia.Release
|
287
|
-
uif.Destroy; uif.Release
|
288
|
-
}
|
289
|
-
end
|
290
|
-
|
291
|
-
attr_reader :hdll, :window, :uich, :uia, :uif
|
292
|
-
|
293
|
-
def height; uia.uir.height end
|
294
|
-
|
295
|
-
def execute(commandId, verb, key, value, props)
|
296
|
-
args = {
|
297
|
-
commandId: commandId,
|
298
|
-
verb: verb,
|
299
|
-
key: (key.null?) ? nil : Windows::PROPERTYKEY.new(key),
|
300
|
-
value: (value.null?) ? nil : Windows::PROPVARIANT.new(value),
|
301
|
-
props: (props.null?) ? nil : Windows::UISimplePropertySet.new(props),
|
302
|
-
ribbon: self,
|
303
|
-
sender: Command.new(self, commandId)
|
304
|
-
}
|
305
|
-
|
306
|
-
(handlers = @executesAllVerbs[commandId]) and handlers.each { |handler|
|
307
|
-
(handler.arity == 0) ? handler.call : handler.call(args)
|
308
|
-
}
|
309
|
-
|
310
|
-
case verb
|
311
|
-
when Windows::UI_EXECUTIONVERB_EXECUTE
|
312
|
-
(handlers = @executesExecute[commandId]) and handlers.each { |handler|
|
313
|
-
(handler.arity == 0) ? handler.call : handler.call(args)
|
314
|
-
}
|
315
|
-
when Windows::UI_EXECUTIONVERB_PREVIEW
|
316
|
-
(handlers = @executesPreview[commandId]) and handlers.each { |handler|
|
317
|
-
(handler.arity == 0) ? handler.call : handler.call(args)
|
318
|
-
}
|
319
|
-
when Windows::UI_EXECUTIONVERB_CANCELPREVIEW
|
320
|
-
(handlers = @executesCancelPreview[commandId]) and handlers.each { |handler|
|
321
|
-
(handler.arity == 0) ? handler.call : handler.call(args)
|
322
|
-
}
|
323
|
-
end
|
324
|
-
|
325
|
-
self
|
326
|
-
rescue
|
327
|
-
Fzeet.message %Q{#{$!}\n\n#{$!.backtrace.join("\n")}}, icon: :error
|
328
|
-
|
329
|
-
self
|
330
|
-
end
|
331
|
-
|
332
|
-
def update(commandId, key, value, newValue)
|
333
|
-
args = {
|
334
|
-
commandId: commandId,
|
335
|
-
key: (key.null?) ? nil : Windows::PROPERTYKEY.new(key),
|
336
|
-
value: (value.null?) ? nil : Windows::PROPVARIANT.new(value),
|
337
|
-
newValue: (newValue.null?) ? nil : Windows::PROPVARIANT.new(newValue),
|
338
|
-
ribbon: self,
|
339
|
-
sender: Command.new(self, commandId)
|
340
|
-
}
|
341
|
-
|
342
|
-
(handlers = @updatesAllKeys[commandId]) and handlers.each { |handler|
|
343
|
-
(handler.arity == 0) ? handler.call : handler.call(args)
|
344
|
-
}
|
345
|
-
|
346
|
-
self
|
347
|
-
rescue
|
348
|
-
Fzeet.message %Q{#{$!}\n\n#{$!.backtrace.join("\n")}}, icon: :error
|
349
|
-
|
350
|
-
self
|
351
|
-
end
|
352
|
-
|
353
|
-
def invalidate(commandId, flags = Windows::UI_INVALIDATIONS_ALLPROPERTIES, key = nil)
|
354
|
-
@uif.InvalidateUICommand(commandId, flags, key)
|
355
|
-
|
356
|
-
self
|
357
|
-
end
|
358
|
-
|
359
|
-
def on(*args, &block)
|
360
|
-
case args.size
|
361
|
-
when 1
|
362
|
-
case args[0]
|
363
|
-
when /^create$/i; @creates << block
|
364
|
-
when /^destroy$/i; @destroys << block
|
365
|
-
when /^size$/i; @sizes << block
|
366
|
-
when Integer; (@executesAllVerbs[args[0]] ||= []) << block
|
367
|
-
else raise ArgumentError
|
368
|
-
end
|
369
|
-
when 2
|
370
|
-
case args[0]
|
371
|
-
when /^execute$/i; (@executesExecute[args[1]] ||= []) << block
|
372
|
-
when /^preview$/i; (@executesPreview[args[1]] ||= []) << block
|
373
|
-
when /^cancelpreview$/i; (@executesCancelPreview[args[1]] ||= []) << block
|
374
|
-
when /^update$/i; (@updatesAllKeys[args[1]] ||= []) << block
|
375
|
-
else raise ArgumentError
|
376
|
-
end
|
377
|
-
else raise ArgumentError
|
378
|
-
end
|
379
|
-
|
380
|
-
self
|
381
|
-
end
|
382
|
-
|
383
|
-
def fontPropsUpdate(args)
|
384
|
-
return self unless args[:key] == Windows::UI_PKEY_FontProperties
|
385
|
-
|
386
|
-
args[:value].unknown { |current|
|
387
|
-
current.QueryInstance(Windows::PropertyStore) { |ps|
|
388
|
-
yield ps
|
389
|
-
|
390
|
-
args[:newValue].unknown = current
|
391
|
-
}
|
392
|
-
}
|
393
|
-
|
394
|
-
self
|
395
|
-
end
|
396
|
-
|
397
|
-
def fontPropsChanged(args)
|
398
|
-
return self unless args[:key] == Windows::UI_PKEY_FontProperties
|
399
|
-
|
400
|
-
args[:props].uiprop(:FontProperties_ChangedProperties).unknown { |changed|
|
401
|
-
changed.QueryInstance(Windows::PropertyStore) { |ps|
|
402
|
-
yield ps
|
403
|
-
}
|
404
|
-
}
|
405
|
-
|
406
|
-
self
|
407
|
-
end
|
408
|
-
|
409
|
-
def contextualUI(id, x, y)
|
410
|
-
uif.UseInstance(Windows::UIContextualUI, :GetView, id) { |view|
|
411
|
-
view.ShowAtLocation(x, y)
|
412
|
-
}
|
413
|
-
|
414
|
-
self
|
415
|
-
end
|
416
|
-
end
|
417
|
-
end
|