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.
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
# File 'lib/fzeet/windows/shell/Common.rb', line 343 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.
378 379 380 |
# File 'lib/fzeet/windows/shell/Common.rb', line 378 def events @events end |
#handlers ⇒ Object (readonly)
Returns the value of attribute handlers.
378 379 380 |
# File 'lib/fzeet/windows/shell/Common.rb', line 378 def handlers @handlers end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
378 379 380 |
# File 'lib/fzeet/windows/shell/Common.rb', line 378 def parent @parent end |
Instance Method Details
#back ⇒ Object
400 |
# File 'lib/fzeet/windows/shell/Common.rb', line 400 def back; BrowseToIDList(nil, Windows::SBSP_NAVIGATEBACK); self end |
#forward ⇒ Object
401 |
# File 'lib/fzeet/windows/shell/Common.rb', line 401 def forward; BrowseToIDList(nil, Windows::SBSP_NAVIGATEFORWARD); self end |
#goto(where) ⇒ Object
386 387 388 389 390 391 392 393 394 395 396 397 398 |
# File 'lib/fzeet/windows/shell/Common.rb', line 386 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
380 381 382 383 384 |
# File 'lib/fzeet/windows/shell/Common.rb', line 380 def on(event, &block) ((@handlers ||= {})["On#{event}".to_sym] ||= []) << block self end |
#up ⇒ Object
402 |
# File 'lib/fzeet/windows/shell/Common.rb', line 402 def up; BrowseToIDList(nil, Windows::SBSP_PARENT); self end |