windows_gui 4.1.0 → 4.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 70fd00b9f6b9731a32b4c777939230d8c975249a
4
- data.tar.gz: 160a0a77b51fe4e98cbf95b22ae193d2ce637d45
3
+ metadata.gz: 6ec23607fe3529f755af6166bb29d24030adca1d
4
+ data.tar.gz: bfd01485c8c783919aedb5f32d25f1e1197d7a19
5
5
  SHA512:
6
- metadata.gz: e0cfb247bd7fcfe942633222d5e5cb692dec09642adefa521f7e0c5c3ff7ff4945fdbfae4d9b1b605e1633ceb7a362fac343160c2da5ec180d2bd83df1c931b6
7
- data.tar.gz: 2e1ec3665a659957201ab32213661b77a399e79c0c05f607d54336daa8702d2842c809d84fab5f70e0a68a91b2011f94e8512cf1cb04572dbcf4fcd789003ce6
6
+ metadata.gz: e791e779aa10e363f028acec6d8d2e6344649ed715b2ff5cb3f1045a18850fae0e2a0f26bedf7aef7c75d180bb68fc4bf8df18875c74dcfd30554428c2eda363
7
+ data.tar.gz: 628ac854859fb18eb80586fb0c788a377d09a8510d05625892aec071672f0ecfa81c6fa243c209bcf1b1243290c132f545962aff63e6ed7f780266cc1bc41fe0
data/README.md CHANGED
@@ -10,4 +10,4 @@ gem install windows_gui
10
10
 
11
11
  ## Use
12
12
 
13
- See examples folder
13
+ See examples folder (the UIRibbon example requires windows_com gem)
@@ -1,5 +1,9 @@
1
1
  # Release Notes
2
2
 
3
+ ## 4.2.0
4
+
5
+ Add crude mechanism for building UIRibbon resources on the fly (requires devenv)
6
+
3
7
  ## 4.1.0
4
8
 
5
9
  Add UIRibbon FFI bindings plus example (requires windows_com gem)
@@ -28,3 +28,7 @@ CmdButton1_SmallImages_RESID = 60019
28
28
  CmdButton1_SmallImages_120__RESID = 60020
29
29
  CmdButton1_LargeImages_RESID = 60021
30
30
  CmdButton1_LargeImages_120__RESID = 60022
31
+ CmdAOT = 8
32
+ CmdAOT_LabelTitle_RESID = 60023
33
+ CmdAOT_LabelDescription_RESID = 60024
34
+ CmdAOT_TooltipDescription_RESID = 60025
@@ -1,7 +1,8 @@
1
1
  #WINDOWS_COM_TRACE_CALLBACK_REFCOUNT = true
2
+ #WINDOWS_COM_TRACE_CALL_ARGS = true
2
3
 
3
4
  require 'windows_gui'
4
- require 'windows_gui/uiribbon' # requires windows_com gem
5
+ require 'windows_gui/uiribbon'
5
6
 
6
7
  include WindowsGUI
7
8
  include UIRibbon
@@ -25,6 +26,16 @@ class UICH < IUICommandHandlerImpl
25
26
 
26
27
  attr_reader :uif
27
28
 
29
+ def OnAOT(*args)
30
+ UsingFFIStructs(PROPVARIANT.new) { |v|
31
+ uif.GetUICommandProperty(CmdAOT, UI_PKEY_BooleanValue, v)
32
+
33
+ SetWindowPos(uif.hwnd,
34
+ (v[:boolVal] == -1) ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE
35
+ )
36
+ }
37
+ end
38
+
28
39
  def OnItem1(*args)
29
40
  MessageBox(uif.hwnd,
30
41
  L("#{self}.#{__method__}"),
@@ -49,6 +60,8 @@ class UICH < IUICommandHandlerImpl
49
60
 
50
61
  def Execute(*args)
51
62
  case args[0]
63
+ when CmdAOT
64
+ OnAOT(*args)
52
65
  when CmdItem1
53
66
  OnItem1(*args)
54
67
  when CmdButton1
@@ -86,12 +99,18 @@ def OnCreate(hwnd,
86
99
  )
87
100
  xtra = Id2Ref[GetWindowLong(hwnd, GWL_USERDATA)]
88
101
 
102
+ UIResources.Build(clean: true) if UIResources.BuildNeeded?()
103
+
89
104
  xtra[:uif] = UIF.new(hwnd)
90
105
  xtra[:uich] = UICH.new(xtra[:uif])
91
106
  xtra[:uia] = UIA.new(xtra[:uich])
92
107
 
93
- xtra[:uif].Initialize(hwnd, xtra[:uia].vptr)
94
- xtra[:uif].LoadUI(LoadUIDll(), L('APPLICATION_RIBBON'))
108
+ xtra[:uif].Initialize(hwnd, xtra[:uia])
109
+ xtra[:uif].LoadUI(UIResources.Load(), L('APPLICATION_RIBBON'))
110
+
111
+ UsingFFIStructs(PROPVARIANT[VT_BOOL, :boolVal, -1]) { |v|
112
+ xtra[:uif].SetUICommandProperty(CmdAOT, UI_PKEY_BooleanValue, v)
113
+ }
95
114
 
96
115
  0
97
116
  end
@@ -178,6 +197,7 @@ def WinMain
178
197
  exit(0) if hwnd.null?
179
198
 
180
199
  ShowWindow(hwnd, SW_SHOWNORMAL)
200
+ SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE)
181
201
  UpdateWindow(hwnd)
182
202
 
183
203
  UsingFFIStructs(MSG.new) { |msg|
@@ -8,35 +8,38 @@
8
8
  <Command Name='cmdTab1' LabelTitle='Tab1' />
9
9
  <Command Name='cmdTab1Group1' LabelTitle='&amp;Group1' LabelDescription='LabelDescription...' TooltipDescription='TooltipDescription...'>
10
10
  <Command.SmallImages>
11
- <Image>../../res/go-next-small.bmp</Image>
12
- <Image MinDPI='120'>../../res/go-next.bmp</Image>
11
+ <Image>../res/go-next-small.bmp</Image>
12
+ <Image MinDPI='120'>../res/go-next.bmp</Image>
13
13
  </Command.SmallImages>
14
14
  <Command.LargeImages>
15
- <Image>../../res/go-next.bmp</Image>
16
- <Image MinDPI='120'>../../res/go-next-big.bmp</Image>
15
+ <Image>../res/go-next.bmp</Image>
16
+ <Image MinDPI='120'>../res/go-next-big.bmp</Image>
17
17
  </Command.LargeImages>
18
18
  </Command>
19
19
 
20
20
  <Command Name='cmdItem1' LabelTitle='&amp;Item1' LabelDescription='LabelDescription...' TooltipDescription='TooltipDescription...'>
21
21
  <Command.SmallImages>
22
- <Image>../../res/go-previous-small.bmp</Image>
23
- <Image MinDPI='120'>../../res/go-previous.bmp</Image>
22
+ <Image>../res/go-previous-small.bmp</Image>
23
+ <Image MinDPI='120'>../res/go-previous.bmp</Image>
24
24
  </Command.SmallImages>
25
25
  <Command.LargeImages>
26
- <Image>../../res/go-previous.bmp</Image>
27
- <Image MinDPI='120'>../../res/go-previous-big.bmp</Image>
26
+ <Image>../res/go-previous.bmp</Image>
27
+ <Image MinDPI='120'>../res/go-previous-big.bmp</Image>
28
28
  </Command.LargeImages>
29
29
  </Command>
30
30
 
31
31
  <Command Name='cmdButton1' LabelTitle='&amp;Button1' LabelDescription='LabelDescription...' TooltipDescription='TooltipDescription...'>
32
32
  <Command.SmallImages>
33
- <Image>../../res/go-next-small.bmp</Image>
34
- <Image MinDPI='120'>../../res/go-next.bmp</Image>
33
+ <Image>../res/go-next-small.bmp</Image>
34
+ <Image MinDPI='120'>../res/go-next.bmp</Image>
35
35
  </Command.SmallImages>
36
36
  <Command.LargeImages>
37
- <Image>../../res/go-next.bmp</Image>
38
- <Image MinDPI='120'>../../res/go-next-big.bmp</Image>
37
+ <Image>../res/go-next.bmp</Image>
38
+ <Image MinDPI='120'>../res/go-next-big.bmp</Image>
39
39
  </Command.LargeImages>
40
+ </Command>
41
+
42
+ <Command Name='cmdAOT' LabelTitle='&amp;Always On Top' LabelDescription='LabelDescription...' TooltipDescription='TooltipDescription...'>
40
43
  </Command>
41
44
  </Application.Commands>
42
45
 
@@ -53,6 +56,7 @@
53
56
  <Ribbon.QuickAccessToolbar>
54
57
  <QuickAccessToolbar CommandName='cmdQAT'>
55
58
  <QuickAccessToolbar.ApplicationDefaults>
59
+ <CheckBox CommandName='cmdAOT' />
56
60
  <Button CommandName='cmdItem1' />
57
61
  <Button CommandName='cmdButton1' />
58
62
  </QuickAccessToolbar.ApplicationDefaults>
Binary file
@@ -1,7 +1,7 @@
1
1
  require 'weakref'
2
2
  require 'ffi'
3
3
 
4
- WINDOWS_GUI_VERSION = '4.1.0'
4
+ WINDOWS_GUI_VERSION = '4.2.0'
5
5
 
6
6
  WINDOWS_GUI_VISUAL_STYLES = true unless defined?(WINDOWS_GUI_VISUAL_STYLES)
7
7
  WINDOWS_GUI_DPI_AWARE = true unless defined?(WINDOWS_GUI_DPI_AWARE)
@@ -12,31 +12,107 @@ module WindowsGUI
12
12
  module UIRibbon
13
13
  include WindowsCOM
14
14
 
15
- def LoadUIDll(name = File.basename($0, '.rbw'))
16
- path = File.dirname(File.expand_path($0))
17
- dll_path = "#{path}/#{name}.dll"
15
+ module UIResources
16
+ def BuildNeeded?(opts = {})
17
+ opts[:name] ||= File.basename($0, '.rbw')
18
18
 
19
- # pull in generated UIRibbon constants
20
- require "#{path}/#{name}"
19
+ path = File.dirname(File.expand_path($0))
21
20
 
22
- # load UIRibbon dll
23
- hdll = DetonateLastError(FFI::Pointer::NULL, :LoadLibrary,
24
- L(dll_path.dup)
25
- )
21
+ dll_path = "#{path}/#{opts[:name]}.dll"
22
+ xml_path = "#{path}/#{opts[:name]}.xml"
26
23
 
27
- STDERR.puts "#{dll_path} loaded (hdll: #{hdll})" if $DEBUG
24
+ yeah = !File.exist?(dll_path) || (
25
+ File.exist?(xml_path) &&
26
+ test(?M, xml_path) > test(?M, dll_path)
27
+ )
28
28
 
29
- at_exit {
30
- FreeLibrary(hdll)
29
+ STDERR.puts "UIRibbon resources build needed" if yeah
31
30
 
32
- STDERR.puts "#{dll_path} unloaded" if $DEBUG
33
- }
31
+ yeah
32
+ end
34
33
 
35
- hdll
36
- end
34
+ def Build(opts = {})
35
+ opts[:name] ||= File.basename($0, '.rbw')
37
36
 
38
- module_function \
39
- :LoadUIDll
37
+ path = File.dirname(File.expand_path($0))
38
+
39
+ xml_path = "#{path}/#{opts[:name]}.xml"
40
+ rb_path = "#{path}/#{opts[:name]}.rb"
41
+ dll_path = "#{path}/#{opts[:name]}.dll"
42
+ log_path = "#{path}/#{opts[:name]}.log"
43
+
44
+ opts[:sdkroot] ||= "#{ENV['ProgramFiles']}/Windows Kits/10"
45
+ opts[:vcroot] ||= "#{ENV['ProgramFiles']}/Microsoft Visual Studio 14.0/VC"
46
+
47
+ opts[:uicc] ||= "#{opts[:sdkroot]}/bin/x86/uicc.exe"
48
+ opts[:rc] ||= "#{opts[:sdkroot]}/bin/x86/rc.exe"
49
+ opts[:vcvars] ||= "#{opts[:vcroot]}/bin/vcvars32.bat"
50
+ opts[:link] ||= "#{opts[:vcroot]}/bin/link.exe"
51
+
52
+ raise 'Building the UIRibbon resources requires Windows SDK and VC' unless
53
+ [:uicc, :rc, :vcvars, :link].all? { |tool| File.exist?(opts[tool]) }
54
+
55
+ STDERR.puts "UIRibbon resources build toolchain OK"
56
+
57
+ File.delete(log_path) if File.exist?(log_path)
58
+
59
+ system <<-CMD
60
+ @echo off && \
61
+ "#{opts[:uicc]}" "#{opts[:name]}.xml" "#{opts[:name]}.bml" /header:"#{opts[:name]}.h" /res:"#{opts[:name]}.rc" > "#{opts[:name]}.log" && \
62
+ "#{opts[:rc]}" /nologo /fo"#{ENV['TEMP']}/#{opts[:name]}.res" "#{opts[:name]}.rc" >> "#{opts[:name]}.log" && \
63
+ call "#{opts[:vcvars]}" >> "#{opts[:name]}.log" && \
64
+ "#{opts[:link]}" /nologo /machine:x86 /dll /noentry /out:"#{opts[:name]}.dll" "#{ENV['TEMP']}/#{opts[:name]}.res" >> "#{opts[:name]}.log"
65
+ CMD
66
+
67
+ raise "UIRibbon resources build FAILED - see #{log_path} for details" if
68
+ File.read(log_path) =~ /error/im
69
+
70
+ File.open(rb_path, 'w') { |rb|
71
+ rb.puts "# Generated by the UIRibbon build, do NOT modify\n\n"
72
+
73
+ File.foreach("#{path}/#{opts[:name]}.h") { |line|
74
+ rb.puts "#{$1[0].upcase}#{$1[1..-1]} = #{$2}" if line =~ /^\s*#define\s+(\w+)\s+(\d+)/
75
+ }
76
+ }
77
+
78
+ %w{bml h rc}.each { |ext|
79
+ File.delete("#{path}/#{opts[:name]}.#{ext}") if File.exist?("#{path}/#{opts[:name]}.#{ext}")
80
+ } if opts[:clean]
81
+
82
+ STDERR.puts "UIRibbon resources build succeeded"
83
+ end
84
+
85
+ def Load(opts = {})
86
+ opts[:name] ||= File.basename($0, '.rbw')
87
+
88
+ path = File.dirname(File.expand_path($0))
89
+
90
+ dll_path = "#{path}/#{opts[:name]}.dll"
91
+
92
+ # pull in generated UIRibbon constants
93
+ require "#{path}/#{opts[:name]}"
94
+
95
+ # load UIRibbon dll
96
+ hdll = DetonateLastError(FFI::Pointer::NULL, :LoadLibrary,
97
+ L(dll_path.dup)
98
+ )
99
+
100
+ STDERR.puts "#{dll_path} loaded (hdll: #{hdll})" if $DEBUG
101
+
102
+ at_exit {
103
+ FreeLibrary(hdll)
104
+
105
+ STDERR.puts "#{dll_path} unloaded" if $DEBUG
106
+ }
107
+
108
+ hdll
109
+ end
110
+
111
+ module_function \
112
+ :BuildNeeded?,
113
+ :Build,
114
+ :Load
115
+ end
40
116
 
41
117
  UI_PKEY_Enabled = PROPERTYKEY[VT_BOOL, 1]
42
118
  UI_PKEY_LabelDescription = PROPERTYKEY[VT_LPWSTR, 2]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: windows_gui
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Radoslav Peev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-02 00:00:00.000000000 Z
11
+ date: 2017-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -57,6 +57,12 @@ files:
57
57
  - examples/Version.rbw
58
58
  - examples/WndExtra.rbw
59
59
  - examples/res/face-devilish.bmp
60
+ - examples/res/go-next-big.bmp
61
+ - examples/res/go-next-small.bmp
62
+ - examples/res/go-next.bmp
63
+ - examples/res/go-previous-big.bmp
64
+ - examples/res/go-previous-small.bmp
65
+ - examples/res/go-previous.bmp
60
66
  - lib/windows_gui.rb
61
67
  - lib/windows_gui/common.rb
62
68
  - lib/windows_gui/gdi.rb