Class: Fzeet::ExplorerBrowser

Inherits:
Windows::ExplorerBrowser
  • Object
show all
Defined in:
lib/fzeet/windows/shell/Common.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#eventsObject (readonly)

Returns the value of attribute events.



378
379
380
# File 'lib/fzeet/windows/shell/Common.rb', line 378

def events
  @events
end

#handlersObject (readonly)

Returns the value of attribute handlers.



378
379
380
# File 'lib/fzeet/windows/shell/Common.rb', line 378

def handlers
  @handlers
end

#parentObject (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

#backObject



400
# File 'lib/fzeet/windows/shell/Common.rb', line 400

def back; BrowseToIDList(nil, Windows::SBSP_NAVIGATEBACK); self end

#forwardObject



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

#upObject



402
# File 'lib/fzeet/windows/shell/Common.rb', line 402

def up; BrowseToIDList(nil, Windows::SBSP_PARENT); self end