fzeet 0.6.5 → 0.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
require_relative 'Point'
|
|
2
|
+
|
|
3
|
+
module Fzeet
|
|
4
|
+
module Windows
|
|
5
|
+
class RECT < FFI::Struct
|
|
6
|
+
layout \
|
|
7
|
+
:left, :long,
|
|
8
|
+
:top, :long,
|
|
9
|
+
:right, :long,
|
|
10
|
+
:bottom, :long
|
|
11
|
+
|
|
12
|
+
def self.[](*args)
|
|
13
|
+
case args.length
|
|
14
|
+
when 2 # location, size
|
|
15
|
+
new.set(args[0][:x], args[0][:y], args[0][:x] + args[1][:cx], args[0][:y] + args[1][:cy])
|
|
16
|
+
when 4 # left, top, right, bottom
|
|
17
|
+
new.set(*args)
|
|
18
|
+
else raise ArgumentError
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
class << self
|
|
23
|
+
alias from []
|
|
24
|
+
alias wrap new
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def dup; self.class[self[:left], self[:top], self[:right], self[:bottom]] end
|
|
28
|
+
|
|
29
|
+
def get; [self[:left], self[:top], self[:right], self[:bottom]] end
|
|
30
|
+
alias to_a get
|
|
31
|
+
|
|
32
|
+
def set(l, t, r, b) tap { |rect| rect[:left], rect[:top], rect[:right], rect[:bottom] = l, t, r, b } end
|
|
33
|
+
|
|
34
|
+
def clear; set(0, 0, 0, 0) end
|
|
35
|
+
|
|
36
|
+
def lt; POINT[self[:left], self[:top]] end
|
|
37
|
+
def lt=(pt) self[:left], self[:top] = pt[:x], pt[:y] end
|
|
38
|
+
alias location lt
|
|
39
|
+
alias location= lt=
|
|
40
|
+
|
|
41
|
+
def lb; POINT[self[:left], self[:bottom]] end
|
|
42
|
+
def lb=(pt) self[:left], self[:bottom] = pt[:x], pt[:y] end
|
|
43
|
+
|
|
44
|
+
def rt; POINT[self[:right], self[:top]] end
|
|
45
|
+
def rt=(pt) self[:right], self[:top] = pt[:x], pt[:y] end
|
|
46
|
+
|
|
47
|
+
def rb; POINT[self[:right], self[:bottom]] end
|
|
48
|
+
def rb=(pt) self[:right], self[:bottom] = pt[:x], pt[:y] end
|
|
49
|
+
|
|
50
|
+
def width; self[:right] - self[:left] end
|
|
51
|
+
def width=(width) self[:right] = self[:left] + width end
|
|
52
|
+
|
|
53
|
+
def height; self[:bottom] - self[:top] end
|
|
54
|
+
def height=(height) self[:bottom] = self[:top] + height end
|
|
55
|
+
|
|
56
|
+
alias structSize size
|
|
57
|
+
|
|
58
|
+
def size; SIZE[width, height] end
|
|
59
|
+
def size=(s) self.width, self.height = s[:cx], s[:cy] end
|
|
60
|
+
|
|
61
|
+
def ==(other) Windows.EqualRect(self, other) != 0 end
|
|
62
|
+
def empty?; Windows.IsRectEmpty(self) != 0 end
|
|
63
|
+
|
|
64
|
+
def include?(*args)
|
|
65
|
+
return args.all? { |arg| include?(arg) } if args.length > 1
|
|
66
|
+
|
|
67
|
+
case args[0]
|
|
68
|
+
when POINT; Windows.PtInRect(self, args[0]) != 0
|
|
69
|
+
when RECT; [args[0].lt, args[0].lb, args[0].rt, args[0].rb].all? { |pt| include?(pt) }
|
|
70
|
+
else raise ArgumentError
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def exclude?(arg) !include?(arg) end
|
|
75
|
+
|
|
76
|
+
def normalized?; self[:left] <= self[:right] && self[:top] <= self[:bottom] end
|
|
77
|
+
|
|
78
|
+
def normalize; dup.normalize! end
|
|
79
|
+
|
|
80
|
+
def normalize!
|
|
81
|
+
self[:left], self[:right] = self[:right], self[:left] if self[:left] > self[:right]
|
|
82
|
+
self[:top], self[:bottom] = self[:bottom], self[:top] if self[:top] > self[:bottom]
|
|
83
|
+
|
|
84
|
+
self
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def offset(dx, dy) dup.offset!(dx, dy) end
|
|
88
|
+
def offset!(dx, dy) tap { |r| Windows.Detonate(0, :OffsetRect, r, dx, dy) } end
|
|
89
|
+
|
|
90
|
+
def inflate(dx, dy) dup.inflate!(dx, dy) end
|
|
91
|
+
def inflate!(dx, dy) tap { |r| Windows.Detonate(0, :InflateRect, r, dx, dy) } end
|
|
92
|
+
|
|
93
|
+
def |(other) self.class.new.tap { |r| Windows.UnionRect(r, self, other) } end
|
|
94
|
+
def &(other) self.class.new.tap { |r| Windows.IntersectRect(r, self, other) } end
|
|
95
|
+
def -(other) self.class.new.tap { |r| Windows.SubtractRect(r, self, other) } end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
ffi_lib 'user32'
|
|
99
|
+
ffi_convention :stdcall
|
|
100
|
+
|
|
101
|
+
attach_function :EqualRect, [:pointer, :pointer], :int
|
|
102
|
+
attach_function :IsRectEmpty, [:pointer], :int
|
|
103
|
+
attach_function :PtInRect, [:pointer, POINT.by_value], :int
|
|
104
|
+
|
|
105
|
+
attach_function :OffsetRect, [:pointer, :int, :int], :int
|
|
106
|
+
attach_function :InflateRect, [:pointer, :int, :int], :int
|
|
107
|
+
|
|
108
|
+
attach_function :UnionRect, [:pointer, :pointer, :pointer], :int
|
|
109
|
+
attach_function :IntersectRect, [:pointer, :pointer, :pointer], :int
|
|
110
|
+
attach_function :SubtractRect, [:pointer, :pointer, :pointer], :int
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
Rect = Windows::RECT
|
|
114
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require_relative 'Common'
|
|
2
|
+
|
|
3
|
+
module Fzeet
|
|
4
|
+
module Windows
|
|
5
|
+
class SIZE < FFI::Struct
|
|
6
|
+
layout \
|
|
7
|
+
:cx, :long,
|
|
8
|
+
:cy, :long
|
|
9
|
+
|
|
10
|
+
def self.[](cx, cy) new.set(cx, cy) end
|
|
11
|
+
|
|
12
|
+
class << self
|
|
13
|
+
alias from []
|
|
14
|
+
alias wrap new
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def dup; self.class[self[:cx], self[:cy]] end
|
|
18
|
+
|
|
19
|
+
def get; [self[:cx], self[:cy]] end
|
|
20
|
+
alias to_a get
|
|
21
|
+
|
|
22
|
+
def set(cx, cy) tap { |s| s[:cx], s[:cy] = cx, cy } end
|
|
23
|
+
|
|
24
|
+
def clear; set(0, 0) end
|
|
25
|
+
|
|
26
|
+
def ==(other) self[:cx] == other[:cx] && self[:cy] == other[:cy] end
|
|
27
|
+
|
|
28
|
+
def inflate(dx, dy) dup.inflate!(dx, dy) end
|
|
29
|
+
def inflate!(dx, dy) tap { |s| s[:cx] += dx; s[:cy] += dy } end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
Size = Windows::SIZE
|
|
34
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require_relative 'Common'
|
|
2
|
+
|
|
3
|
+
module Fzeet
|
|
4
|
+
module Windows
|
|
5
|
+
class SYSTEMTIME < FFI::Struct
|
|
6
|
+
layout \
|
|
7
|
+
:wYear, :ushort,
|
|
8
|
+
:wMonth, :ushort,
|
|
9
|
+
:wDayOfWeek, :ushort,
|
|
10
|
+
:wDay, :ushort,
|
|
11
|
+
:wHour, :ushort,
|
|
12
|
+
:wMinute, :ushort,
|
|
13
|
+
:wSecond, :ushort,
|
|
14
|
+
:wMilliseconds, :ushort
|
|
15
|
+
|
|
16
|
+
def self.[](time) new.set(time) end
|
|
17
|
+
|
|
18
|
+
class << self
|
|
19
|
+
alias from []
|
|
20
|
+
alias wrap new
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def dup; self.class.new.tap { |st| st.members.each { |member| st[member] = self[member] } } end
|
|
24
|
+
|
|
25
|
+
def get(as = :local)
|
|
26
|
+
Time.send(as,
|
|
27
|
+
self[:wYear], self[:wMonth], self[:wDay],
|
|
28
|
+
self[:wHour], self[:wMinute], self[:wSecond], self[:wMilliseconds] * 1000
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def set(time)
|
|
33
|
+
tap { |st|
|
|
34
|
+
st[:wYear], st[:wMonth], st[:wDay],
|
|
35
|
+
st[:wHour], st[:wMinute], st[:wSecond], st[:wMilliseconds] =
|
|
36
|
+
time.year, time.month, time.day,
|
|
37
|
+
time.hour, time.min, time.sec, (time.usec.to_f / 1000).round
|
|
38
|
+
}
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def ==(other) members.all? { |member| self[member] == other[member] } end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
SystemTime = Windows::SYSTEMTIME
|
|
46
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
require_relative 'Common'
|
|
2
|
+
|
|
3
|
+
module Fzeet
|
|
4
|
+
module Windows
|
|
5
|
+
class OSVERSIONINFOEX < FFI::Struct
|
|
6
|
+
layout \
|
|
7
|
+
:dwOSVersionInfoSize, :ulong,
|
|
8
|
+
:dwMajorVersion, :ulong,
|
|
9
|
+
:dwMinorVersion, :ulong,
|
|
10
|
+
:dwBuildNumber, :ulong,
|
|
11
|
+
:dwPlatformId, :ulong,
|
|
12
|
+
:szCSDVersion, [:char, 128],
|
|
13
|
+
:wServicePackMajor, :ushort,
|
|
14
|
+
:wServicePackMinor, :ushort,
|
|
15
|
+
:wSuiteMask, :ushort,
|
|
16
|
+
:wProductType, :uchar,
|
|
17
|
+
:wReserved, :uchar
|
|
18
|
+
|
|
19
|
+
def get!; tap { |ovi| ovi[:dwOSVersionInfoSize] = size; Windows.DetonateLastError(0, :GetVersionEx, ovi) } end
|
|
20
|
+
|
|
21
|
+
def major; self[:dwMajorVersion] end
|
|
22
|
+
def minor; self[:dwMinorVersion] end
|
|
23
|
+
def build; self[:dwBuildNumber] end
|
|
24
|
+
def sp; self[:wServicePackMajor] end
|
|
25
|
+
|
|
26
|
+
def hex; (major << 8) + minor end
|
|
27
|
+
|
|
28
|
+
def <=>(version)
|
|
29
|
+
hex <=> case version
|
|
30
|
+
when '2000', 2000; 0x0500
|
|
31
|
+
when 'xp', :xp; 0x0501
|
|
32
|
+
when 'vista', :vista; 0x0600
|
|
33
|
+
when '7', 7; 0x0601
|
|
34
|
+
else raise ArgumentError
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
include Comparable
|
|
39
|
+
|
|
40
|
+
def name
|
|
41
|
+
case hex
|
|
42
|
+
when 0x0500...0x0501; 'Windows 2000'
|
|
43
|
+
when 0x0501...0x0600; 'Windows XP'
|
|
44
|
+
when 0x0600...0x0601; 'Windows Vista'
|
|
45
|
+
when 0x0601...0x0700; 'Windows 7'
|
|
46
|
+
else 'Unknown'
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def to_s; "#{major}.#{minor}.#{build} SP#{sp} (#{name})" end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
attach_function :GetVersionEx, :GetVersionExA, [:pointer], :int
|
|
54
|
+
|
|
55
|
+
Version = OSVERSIONINFOEX.new.get!
|
|
56
|
+
end
|
|
57
|
+
end
|
data/lib/fzeet/windows/gdi.rb
CHANGED
|
@@ -1,62 +1 @@
|
|
|
1
|
-
require_relative '
|
|
2
|
-
|
|
3
|
-
module Fzeet
|
|
4
|
-
module Windows
|
|
5
|
-
ffi_lib 'gdi32'
|
|
6
|
-
ffi_convention :stdcall
|
|
7
|
-
|
|
8
|
-
def GetRValue(rgb) LOBYTE(rgb) end
|
|
9
|
-
def GetGValue(rgb) LOBYTE(rgb >> 8) end
|
|
10
|
-
def GetBValue(rgb) LOBYTE(rgb >> 16) end
|
|
11
|
-
def RGB(r, g, b) r | (g << 8) | (b << 16) end
|
|
12
|
-
|
|
13
|
-
module_function \
|
|
14
|
-
:GetRValue, :GetGValue, :GetBValue, :RGB
|
|
15
|
-
|
|
16
|
-
LOGPIXELSX = 88
|
|
17
|
-
LOGPIXELSY = 90
|
|
18
|
-
|
|
19
|
-
attach_function :GetDeviceCaps, [:pointer, :int], :int
|
|
20
|
-
|
|
21
|
-
DEFAULT_GUI_FONT = 17
|
|
22
|
-
|
|
23
|
-
attach_function :GetStockObject, [:int], :pointer
|
|
24
|
-
|
|
25
|
-
=begin
|
|
26
|
-
class LOGFONT < FFI::Struct
|
|
27
|
-
layout \
|
|
28
|
-
:lfHeight, :long,
|
|
29
|
-
:lfWidth, :long,
|
|
30
|
-
:lfEscapement, :long,
|
|
31
|
-
:lfOrientation, :long,
|
|
32
|
-
:lfWeight, :long,
|
|
33
|
-
:lfItalic, :uchar,
|
|
34
|
-
:lfUnderline, :uchar,
|
|
35
|
-
:lfStrikeOut, :uchar,
|
|
36
|
-
:lfCharSet, :uchar,
|
|
37
|
-
:lfOutPrecision, :uchar,
|
|
38
|
-
:lfClipPrecision, :uchar,
|
|
39
|
-
:lfQuality, :uchar,
|
|
40
|
-
:lfPitchAndFamily, :uchar,
|
|
41
|
-
:lfFaceName, [:char, 32]
|
|
42
|
-
end
|
|
43
|
-
=end
|
|
44
|
-
|
|
45
|
-
attach_function :CreateFontIndirect, :CreateFontIndirectA, [:pointer], :pointer
|
|
46
|
-
|
|
47
|
-
attach_function :DeleteObject, [:pointer], :int
|
|
48
|
-
|
|
49
|
-
attach_function :SelectObject, [:pointer, :pointer], :pointer
|
|
50
|
-
|
|
51
|
-
attach_function :GetTextExtentPoint, :GetTextExtentPointA, [:pointer, :string, :int, :pointer], :int
|
|
52
|
-
|
|
53
|
-
attach_function :GetTextColor, [:pointer], :ulong
|
|
54
|
-
attach_function :SetTextColor, [:pointer, :ulong], :ulong
|
|
55
|
-
|
|
56
|
-
attach_function :GetBkColor, [:pointer], :ulong
|
|
57
|
-
attach_function :SetBkColor, [:pointer, :ulong], :ulong
|
|
58
|
-
|
|
59
|
-
attach_function :MoveToEx, [:pointer, :int, :int, :pointer], :int
|
|
60
|
-
attach_function :LineTo, [:pointer, :int, :int], :int
|
|
61
|
-
end
|
|
62
|
-
end
|
|
1
|
+
require_relative 'gdi/Font'
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require_relative '../core'
|
|
2
|
+
|
|
3
|
+
module Fzeet
|
|
4
|
+
module Windows
|
|
5
|
+
ffi_lib 'gdi32'
|
|
6
|
+
ffi_convention :stdcall
|
|
7
|
+
|
|
8
|
+
def GetRValue(rgb) LOBYTE(rgb) end
|
|
9
|
+
def GetGValue(rgb) LOBYTE(rgb >> 8) end
|
|
10
|
+
def GetBValue(rgb) LOBYTE(rgb >> 16) end
|
|
11
|
+
def RGB(r, g, b) r | (g << 8) | (b << 16) end
|
|
12
|
+
|
|
13
|
+
module_function \
|
|
14
|
+
:GetRValue, :GetGValue, :GetBValue, :RGB
|
|
15
|
+
|
|
16
|
+
LOGPIXELSX = 88
|
|
17
|
+
LOGPIXELSY = 90
|
|
18
|
+
|
|
19
|
+
attach_function :GetDeviceCaps, [:pointer, :int], :int
|
|
20
|
+
|
|
21
|
+
DEFAULT_GUI_FONT = 17
|
|
22
|
+
|
|
23
|
+
attach_function :GetStockObject, [:int], :pointer
|
|
24
|
+
|
|
25
|
+
attach_function :DeleteObject, [:pointer], :int
|
|
26
|
+
|
|
27
|
+
attach_function :SelectObject, [:pointer, :pointer], :pointer
|
|
28
|
+
|
|
29
|
+
attach_function :GetTextExtentPoint, :GetTextExtentPointA, [:pointer, :string, :int, :pointer], :int
|
|
30
|
+
|
|
31
|
+
attach_function :GetTextColor, [:pointer], :ulong
|
|
32
|
+
attach_function :SetTextColor, [:pointer, :ulong], :ulong
|
|
33
|
+
|
|
34
|
+
attach_function :GetBkColor, [:pointer], :ulong
|
|
35
|
+
attach_function :SetBkColor, [:pointer, :ulong], :ulong
|
|
36
|
+
|
|
37
|
+
attach_function :MoveToEx, [:pointer, :int, :int, :pointer], :int
|
|
38
|
+
attach_function :LineTo, [:pointer, :int, :int], :int
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
require_relative 'Common'
|
|
2
|
+
|
|
3
|
+
module Fzeet
|
|
4
|
+
module Windows
|
|
5
|
+
class LOGFONT < FFI::Struct
|
|
6
|
+
layout \
|
|
7
|
+
:lfHeight, :long,
|
|
8
|
+
:lfWidth, :long,
|
|
9
|
+
:lfEscapement, :long,
|
|
10
|
+
:lfOrientation, :long,
|
|
11
|
+
:lfWeight, :long,
|
|
12
|
+
:lfItalic, :uchar,
|
|
13
|
+
:lfUnderline, :uchar,
|
|
14
|
+
:lfStrikeOut, :uchar,
|
|
15
|
+
:lfCharSet, :uchar,
|
|
16
|
+
:lfOutPrecision, :uchar,
|
|
17
|
+
:lfClipPrecision, :uchar,
|
|
18
|
+
:lfQuality, :uchar,
|
|
19
|
+
:lfPitchAndFamily, :uchar,
|
|
20
|
+
:lfFaceName, [:char, 32]
|
|
21
|
+
|
|
22
|
+
def face; self[:lfFaceName].to_s end
|
|
23
|
+
def face=(face) self[:lfFaceName] = face end
|
|
24
|
+
|
|
25
|
+
def size; -Rational(self[:lfHeight] * 72, Application.devcaps[:logpixelsy]) end
|
|
26
|
+
def size=(size) self[:lfHeight] = -Windows.MulDiv((size * 10).to_i, Application.devcaps[:logpixelsy], 720) end
|
|
27
|
+
|
|
28
|
+
def bold?; self[:lfWeight] >= 700 end
|
|
29
|
+
def bold=(bold) self[:lfWeight] = (bold) ? 700 : 0 end
|
|
30
|
+
|
|
31
|
+
def italic?; self[:lfItalic] == 1 end
|
|
32
|
+
def italic=(italic) self[:lfItalic] = (italic) ? 1 : 0 end
|
|
33
|
+
|
|
34
|
+
def underline?; self[:lfUnderline] == 1 end
|
|
35
|
+
def underline=(underline) self[:lfUnderline] = (underline) ? 1 : 0 end
|
|
36
|
+
|
|
37
|
+
def strikeout?; self[:lfStrikeOut] == 1 end
|
|
38
|
+
def strikeout=(strikeout) self[:lfStrikeOut] = (strikeout) ? 1 : 0 end
|
|
39
|
+
|
|
40
|
+
def update(from)
|
|
41
|
+
case from
|
|
42
|
+
when PropertyStore
|
|
43
|
+
from.each { |k, v|
|
|
44
|
+
case k
|
|
45
|
+
when UI_PKEY_FontProperties_Family; self.face = v.wstring
|
|
46
|
+
when UI_PKEY_FontProperties_Size; self.size = v.decimal.to_f
|
|
47
|
+
when UI_PKEY_FontProperties_Bold; self.bold = v.uint == 2
|
|
48
|
+
when UI_PKEY_FontProperties_Italic; self.italic = v.uint == 2
|
|
49
|
+
when UI_PKEY_FontProperties_Underline; self.underline = v.uint == 2
|
|
50
|
+
when UI_PKEY_FontProperties_Strikethrough; self.strikeout = v.uint == 2
|
|
51
|
+
end
|
|
52
|
+
}
|
|
53
|
+
else raise ArgumentError
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
self
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
attach_function :CreateFontIndirect, :CreateFontIndirectA, [:pointer], :pointer
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
Windows::LOGFONT.send(:include, Toggle)
|
|
64
|
+
end
|
data/lib/fzeet/windows/kernel.rb
CHANGED
|
@@ -1,92 +1 @@
|
|
|
1
|
-
require_relative '
|
|
2
|
-
|
|
3
|
-
module Fzeet
|
|
4
|
-
module Windows
|
|
5
|
-
ffi_lib 'kernel32'
|
|
6
|
-
ffi_convention :stdcall
|
|
7
|
-
|
|
8
|
-
attach_function :GetModuleHandle, :GetModuleHandleA, [:string], :pointer
|
|
9
|
-
|
|
10
|
-
attach_function :LoadLibrary, :LoadLibraryA, [:string], :pointer
|
|
11
|
-
attach_function :FreeLibrary, [:pointer], :int
|
|
12
|
-
|
|
13
|
-
attach_function :GetSystemDefaultLCID, [], :ulong
|
|
14
|
-
|
|
15
|
-
if WINVER.AtLeastWindowsXP?
|
|
16
|
-
class ACTCTX < FFI::Struct
|
|
17
|
-
layout \
|
|
18
|
-
:cbSize, :ulong,
|
|
19
|
-
:dwFlags, :ulong,
|
|
20
|
-
:lpSource, :pointer,
|
|
21
|
-
:wProcessorArchitecture, :ushort,
|
|
22
|
-
:wLangId, :ushort,
|
|
23
|
-
:lpAssemblyDirectory, :pointer,
|
|
24
|
-
:lpResourceName, :pointer,
|
|
25
|
-
:lpApplicationName, :pointer,
|
|
26
|
-
:hModule, :pointer
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
attach_function :CreateActCtx, :CreateActCtxA, [:pointer], :pointer
|
|
30
|
-
attach_function :ReleaseActCtx, [:pointer], :void
|
|
31
|
-
|
|
32
|
-
attach_function :ActivateActCtx, [:pointer, :pointer], :int
|
|
33
|
-
attach_function :DeactivateActCtx, [:ulong, :ulong], :int
|
|
34
|
-
|
|
35
|
-
COMMON_CONTROLS_ACTCTX = {
|
|
36
|
-
handle: INVALID_HANDLE_VALUE,
|
|
37
|
-
cookie: FFI::MemoryPointer.new(:ulong),
|
|
38
|
-
activated: false
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
at_exit {
|
|
42
|
-
DeactivateActCtx(0, COMMON_CONTROLS_ACTCTX[:cookie].get_ulong(0)) if
|
|
43
|
-
COMMON_CONTROLS_ACTCTX[:activated]
|
|
44
|
-
|
|
45
|
-
COMMON_CONTROLS_ACTCTX[:cookie].free
|
|
46
|
-
|
|
47
|
-
ReleaseActCtx(COMMON_CONTROLS_ACTCTX[:handle]) unless
|
|
48
|
-
COMMON_CONTROLS_ACTCTX[:handle] == INVALID_HANDLE_VALUE
|
|
49
|
-
}
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def EnableVisualStyles
|
|
53
|
-
return unless WINVER.AtLeastWindowsXP?
|
|
54
|
-
|
|
55
|
-
raise 'Visual styles already enabled.' if COMMON_CONTROLS_ACTCTX[:activated]
|
|
56
|
-
|
|
57
|
-
manifest = "#{ENV['TEMP']}/Fzeet.Common-Controls.manifest"
|
|
58
|
-
|
|
59
|
-
File.open(manifest, 'w:utf-8') { |file|
|
|
60
|
-
file << <<-XML
|
|
61
|
-
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
|
|
62
|
-
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
|
|
63
|
-
<dependency>
|
|
64
|
-
<dependentAssembly>
|
|
65
|
-
<assemblyIdentity type='Win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*' />
|
|
66
|
-
</dependentAssembly>
|
|
67
|
-
</dependency>
|
|
68
|
-
</assembly>
|
|
69
|
-
XML
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
ac = ACTCTX.new
|
|
73
|
-
|
|
74
|
-
ac[:cbSize] = ac.size
|
|
75
|
-
ac[:lpSource] = source = FFI::MemoryPointer.from_string(File.expand_path(manifest))
|
|
76
|
-
|
|
77
|
-
COMMON_CONTROLS_ACTCTX[:handle] = DetonateLastError(INVALID_HANDLE_VALUE, :CreateActCtx, ac) { source.free }
|
|
78
|
-
|
|
79
|
-
DetonateLastError(0, :ActivateActCtx, COMMON_CONTROLS_ACTCTX[:handle], COMMON_CONTROLS_ACTCTX[:cookie]) { |failed|
|
|
80
|
-
next unless failed
|
|
81
|
-
|
|
82
|
-
ReleaseActCtx(COMMON_CONTROLS_ACTCTX[:handle]); COMMON_CONTROLS_ACTCTX[:handle] = INVALID_HANDLE_VALUE
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
COMMON_CONTROLS_ACTCTX[:activated] = true
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
module_function :EnableVisualStyles
|
|
89
|
-
|
|
90
|
-
attach_function :MulDiv, [:int, :int, :int], :int
|
|
91
|
-
end
|
|
92
|
-
end
|
|
1
|
+
require_relative 'kernel/Common'
|