Class: Fzeet::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/fzeet/windows.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.acceleratorsObject (readonly)

Returns the value of attribute accelerators.



56
57
58
# File 'lib/fzeet/windows.rb', line 56

def accelerators
  @accelerators
end

.authorsObject

Returns the value of attribute authors.



55
56
57
# File 'lib/fzeet/windows.rb', line 55

def authors
  @authors
end

.devcapsObject (readonly)

Returns the value of attribute devcaps.



56
57
58
# File 'lib/fzeet/windows.rb', line 56

def devcaps
  @devcaps
end

.dialogsObject (readonly)

Returns the value of attribute dialogs.



56
57
58
# File 'lib/fzeet/windows.rb', line 56

def dialogs
  @dialogs
end

.imagesObject (readonly)

Returns the value of attribute images.



56
57
58
# File 'lib/fzeet/windows.rb', line 56

def images
  @images
end

.nameObject

Returns the value of attribute name.



55
56
57
# File 'lib/fzeet/windows.rb', line 55

def name
  @name
end

.quitWhenMainWindowClosesObject

Returns the value of attribute quitWhenMainWindowCloses.



55
56
57
# File 'lib/fzeet/windows.rb', line 55

def quitWhenMainWindowCloses
  @quitWhenMainWindowCloses
end

.versionObject

Returns the value of attribute version.



55
56
57
# File 'lib/fzeet/windows.rb', line 55

def version
  @version
end

.windowObject

Returns the value of attribute window.



56
57
58
# File 'lib/fzeet/windows.rb', line 56

def window
  @window
end

Class Method Details

.quit(code = 0) ⇒ Object



97
98
99
100
101
102
# File 'lib/fzeet/windows.rb', line 97

def self.quit(code = 0)
	accelerators.each(&:dispose)
	images.values.each(&:dispose)

	Windows.PostQuitMessage(code)
end

.run(windowOrOpts = {}, &block) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/fzeet/windows.rb', line 65

def self.run(windowOrOpts = {}, &block)
	@window = case windowOrOpts
	when BasicWindow; windowOrOpts.tap { |window| block.call(window) if block }
	when Hash
		if windowOrOpts[:deferCreateWindow].tap { windowOrOpts.delete_if { |k, v| k == :deferCreateWindow } }
			Window.new(windowOrOpts, &block)
		else
			Window.new(windowOrOpts).tap { |window| block.call(window) if block }
		end
	else raise ArgumentError
	end

	return 0 if window.handle.null?

	@window.on(:destroy) { quit } if @quitWhenMainWindowCloses

	@window.show.update

	msg = Message.new

	while msg.get!
		msg.translate.dispatch unless
			(window.client && Windows.TranslateMDISysAccel(window.client.handle, msg) != 0) ||
			accelerators.any? { |table| table.translate?(msg, @window) } ||
			dialogs.any? { |dialog| dialog.dlgmsg?(msg) }
	end

	msg[:wParam]
rescue
	Fzeet.message %Q{#{$!}\n\n#{$!.backtrace.join("\n")}}, icon: :error
end