Class: Fzeet::UIRibbon
- Inherits:
-
Object
- Object
- Fzeet::UIRibbon
- Defined in:
- lib/fzeet/UIRibbon.rb
Defined Under Namespace
Modules: Color Classes: Command
Instance Attribute Summary collapse
-
#hdll ⇒ Object
readonly
Returns the value of attribute hdll.
-
#uia ⇒ Object
readonly
Returns the value of attribute uia.
-
#uich ⇒ Object
readonly
Returns the value of attribute uich.
-
#uif ⇒ Object
readonly
Returns the value of attribute uif.
-
#window ⇒ Object
readonly
Returns the value of attribute window.
Instance Method Summary collapse
- #[](id) ⇒ Object
- #background ⇒ Object
- #background=(hsb) ⇒ Object
- #color ⇒ Object
- #color=(hsb) ⇒ Object
- #contextualUI(id, x, y) ⇒ Object
- #execute(commandId, verb, key, value, props) ⇒ Object
- #height ⇒ Object
- #highlight ⇒ Object
- #highlight=(hsb) ⇒ Object
-
#initialize(_window, name = Application.name, resname = 'APPLICATION_RIBBON') ⇒ UIRibbon
constructor
A new instance of UIRibbon.
- #on(*args, &block) ⇒ Object
Constructor Details
#initialize(_window, name = Application.name, resname = 'APPLICATION_RIBBON') ⇒ UIRibbon
Returns a new instance of UIRibbon.
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/fzeet/UIRibbon.rb', line 105 def initialize(_window, name = Application.name, resname = 'APPLICATION_RIBBON') @creates = [] @destroys = [] @sizes = [] @executesAllVerbs = {} @window = _window window.instance_variable_set(:@ribbon, self) class << window attr_reader :ribbon end @uich = Windows::UICommandHandler.new uich.instance_variable_set(:@ribbon, self) class << uich attr_reader :ribbon def Execute(*args) ribbon.execute(*args); Windows::S_OK end end @uia = Windows::UIApplication.new uia.instance_variable_set(:@uich, @uich) class << uia attr_reader :uich, :uir def OnViewChanged(viewId, typeId, view, verb, reason) return Windows::S_OK unless typeId == Windows::UI_VIEWTYPE_RIBBON args = { viewId: viewId, typeId: typeId, view: view, verb: verb, reason: reason, ribbon: self, sender: self } case verb when Windows::UI_VIEWVERB_CREATE @uir = Windows::Unknown.new(view).QueryInstance(Windows::UIRibbon) uir.instance_variable_set(:@height, 0) class << uir attr_accessor :height end uich.ribbon.instance_variable_get(:@creates).each { |handler| (handler.arity == 0) ? handler.call : handler.call(args) } when Windows::UI_VIEWVERB_DESTROY uich.ribbon.instance_variable_get(:@destroys).each { |handler| (handler.arity == 0) ? handler.call : handler.call(args) } uir.Release when Windows::UI_VIEWVERB_SIZE FFI::MemoryPointer.new(:uint) { |p| uir.GetHeight(p); uir.height = p.read_int } uich.ribbon.instance_variable_get(:@sizes).each { |handler| (handler.arity == 0) ? handler.call : handler.call(args) } end Windows::S_OK rescue Fzeet. %Q{#{$!}\n\n#{$!.backtrace.join("\n")}}, icon: :error Windows::S_OK end def OnCreateUICommand(*args) uich.QueryInterface(uich.class::IID, args[-1]); Windows::S_OK end end @uif = Windows::UIFramework.new uif.Initialize(window.handle, uia) uif.LoadUI(@hdll = Windows.LoadRibbonDll(name), "#{resname}\0".encode('utf-16le')) window.on(:destroy) { uich.Release uia.Release uif.Destroy; uif.Release } end |
Instance Attribute Details
#hdll ⇒ Object (readonly)
Returns the value of attribute hdll.
198 199 200 |
# File 'lib/fzeet/UIRibbon.rb', line 198 def hdll @hdll end |
#uia ⇒ Object (readonly)
Returns the value of attribute uia.
198 199 200 |
# File 'lib/fzeet/UIRibbon.rb', line 198 def uia @uia end |
#uich ⇒ Object (readonly)
Returns the value of attribute uich.
198 199 200 |
# File 'lib/fzeet/UIRibbon.rb', line 198 def uich @uich end |
#uif ⇒ Object (readonly)
Returns the value of attribute uif.
198 199 200 |
# File 'lib/fzeet/UIRibbon.rb', line 198 def uif @uif end |
#window ⇒ Object (readonly)
Returns the value of attribute window.
198 199 200 |
# File 'lib/fzeet/UIRibbon.rb', line 198 def window @window end |
Instance Method Details
#background ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/fzeet/UIRibbon.rb', line 57 def background hsb = nil uif.QueryInstance(Windows::PropertyStore) { |ps| hsb = ps.uiprop(:GlobalBackgroundColor).uint } Color.enhance([Windows::UI_GetHValue(hsb), Windows::UI_GetSValue(hsb), Windows::UI_GetBValue(hsb)], self, __method__) end |
#background=(hsb) ⇒ Object
67 68 69 70 71 |
# File 'lib/fzeet/UIRibbon.rb', line 67 def background=(hsb) uif.QueryInstance(Windows::PropertyStore) { |ps| ps.uiprop(:GlobalBackgroundColor, Windows::PROPVARIANT[:uint, Windows::UI_HSB(*hsb)]).commit } end |
#color ⇒ Object
73 74 75 76 77 78 79 80 81 |
# File 'lib/fzeet/UIRibbon.rb', line 73 def color hsb = nil uif.QueryInstance(Windows::PropertyStore) { |ps| hsb = ps.uiprop(:GlobalTextColor).uint } Color.enhance([Windows::UI_GetHValue(hsb), Windows::UI_GetSValue(hsb), Windows::UI_GetBValue(hsb)], self, __method__) end |
#color=(hsb) ⇒ Object
83 84 85 86 87 |
# File 'lib/fzeet/UIRibbon.rb', line 83 def color=(hsb) uif.QueryInstance(Windows::PropertyStore) { |ps| ps.uiprop(:GlobalTextColor, Windows::PROPVARIANT[:uint, Windows::UI_HSB(*hsb)]).commit } end |
#contextualUI(id, x, y) ⇒ Object
242 243 244 245 246 247 248 |
# File 'lib/fzeet/UIRibbon.rb', line 242 def contextualUI(id, x, y) uif.UseInstance(Windows::UIContextualUI, :GetView, id) { |view| view.ShowAtLocation(x, y) } self end |
#execute(commandId, verb, key, value, props) ⇒ Object
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/fzeet/UIRibbon.rb', line 202 def execute(commandId, verb, key, value, props) args = { commandId: commandId, verb: verb, key: key, value: value, props: props, ribbon: self, sender: Command.new(self, commandId) } if @executesAllVerbs.include?(commandId) @executesAllVerbs[commandId].each { |handler| (handler.arity == 0) ? handler.call : handler.call(args) } end self rescue Fzeet. %Q{#{$!}\n\n#{$!.backtrace.join("\n")}}, icon: :error self end |
#height ⇒ Object
200 |
# File 'lib/fzeet/UIRibbon.rb', line 200 def height; uia.uir.height end |
#highlight ⇒ Object
89 90 91 92 93 94 95 96 97 |
# File 'lib/fzeet/UIRibbon.rb', line 89 def highlight hsb = nil uif.QueryInstance(Windows::PropertyStore) { |ps| hsb = ps.uiprop(:GlobalHighlightColor).uint } Color.enhance([Windows::UI_GetHValue(hsb), Windows::UI_GetSValue(hsb), Windows::UI_GetBValue(hsb)], self, __method__) end |
#highlight=(hsb) ⇒ Object
99 100 101 102 103 |
# File 'lib/fzeet/UIRibbon.rb', line 99 def highlight=(hsb) uif.QueryInstance(Windows::PropertyStore) { |ps| ps.uiprop(:GlobalHighlightColor, Windows::PROPVARIANT[:uint, Windows::UI_HSB(*hsb)]).commit } end |
#on(*args, &block) ⇒ Object
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/fzeet/UIRibbon.rb', line 226 def on(*args, &block) case args.size when 1 case args[0] when /^create$/i; @creates << block when /^destroy$/i; @destroys << block when /^size$/i; @sizes << block when Integer; (@executesAllVerbs[args[0]] ||= []) << block else raise ArgumentError end else raise ArgumentError end self end |