Class: Fzeet::ExplorerBrowser
- Inherits:
-
Windows::ExplorerBrowser
- Object
- Windows::ExplorerBrowser
- Fzeet::ExplorerBrowser
- Defined in:
- lib/fzeet/windows/shell/Common.rb
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#handlers ⇒ Object
readonly
Returns the value of attribute handlers.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
- #back ⇒ Object
- #forward ⇒ Object
- #goto(where) ⇒ Object
-
#initialize(parent) ⇒ ExplorerBrowser
constructor
A new instance of ExplorerBrowser.
- #on(event, &block) ⇒ Object
- #up ⇒ Object
Constructor Details
#initialize(parent) ⇒ ExplorerBrowser
Returns a new instance of ExplorerBrowser.
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 |
# File 'lib/fzeet/windows/shell/Common.rb', line 324 def initialize(parent) @parent = parent super() @events = Windows::ExplorerBrowserEvents.new @events.instance_variable_set(:@browser, self) class << @events attr_reader :browser (self::VTBL.members - Windows::IUnknown::VTBL.members).each { |name| define_method(name) { |*args| (handlers = browser.handlers && browser.handlers[name]) && handlers.each { |handler| (handler.arity == 0) ? handler.call : handler.call(*args) } Windows::S_OK } } end @cookie = nil FFI::MemoryPointer.new(:ulong) { |p| Advise(@events, p); @cookie = p.get_ulong(0) } Initialize(@parent.handle, parent.rect, nil) @parent. on(:size) { SetRect(nil, @parent.rect) }. on(:destroy) { Unadvise(@cookie); @events.Release; Destroy(); Release() }. instance_variable_set(:@__ExplorerBrowser__, self) end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
359 360 361 |
# File 'lib/fzeet/windows/shell/Common.rb', line 359 def events @events end |
#handlers ⇒ Object (readonly)
Returns the value of attribute handlers.
359 360 361 |
# File 'lib/fzeet/windows/shell/Common.rb', line 359 def handlers @handlers end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
359 360 361 |
# File 'lib/fzeet/windows/shell/Common.rb', line 359 def parent @parent end |
Instance Method Details
#back ⇒ Object
381 |
# File 'lib/fzeet/windows/shell/Common.rb', line 381 def back; BrowseToIDList(nil, Windows::SBSP_NAVIGATEBACK); self end |
#forward ⇒ Object
382 |
# File 'lib/fzeet/windows/shell/Common.rb', line 382 def forward; BrowseToIDList(nil, Windows::SBSP_NAVIGATEFORWARD); self end |
#goto(where) ⇒ Object
367 368 369 370 371 372 373 374 375 376 377 378 379 |
# File 'lib/fzeet/windows/shell/Common.rb', line 367 def goto(where) pidl = nil FFI::MemoryPointer.new(:pointer) { |p| Windows.SHGetKnownFolderIDList(Windows.const_get("FOLDERID_#{where}"), 0, nil, p) BrowseToIDList(pidl = p.read_pointer, 0) } self ensure Windows.CoTaskMemFree(pidl) end |
#on(event, &block) ⇒ Object
361 362 363 364 365 |
# File 'lib/fzeet/windows/shell/Common.rb', line 361 def on(event, &block) ((@handlers ||= {})["On#{event}".to_sym] ||= []) << block self end |
#up ⇒ Object
383 |
# File 'lib/fzeet/windows/shell/Common.rb', line 383 def up; BrowseToIDList(nil, Windows::SBSP_PARENT); self end |