Class: Fzeet::Application

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

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.acceleratorsObject (readonly)

Returns the value of attribute accelerators.



18
19
20
# File 'lib/fzeet/Application.rb', line 18

def accelerators
  @accelerators
end

.authorsObject

Returns the value of attribute authors.



17
18
19
# File 'lib/fzeet/Application.rb', line 17

def authors
  @authors
end

.dialogsObject (readonly)

Returns the value of attribute dialogs.



18
19
20
# File 'lib/fzeet/Application.rb', line 18

def dialogs
  @dialogs
end

.imagesObject (readonly)

Returns the value of attribute images.



18
19
20
# File 'lib/fzeet/Application.rb', line 18

def images
  @images
end

.nameObject

Returns the value of attribute name.



17
18
19
# File 'lib/fzeet/Application.rb', line 17

def name
  @name
end

.quitWhenMainWindowClosesObject

Returns the value of attribute quitWhenMainWindowCloses.



17
18
19
# File 'lib/fzeet/Application.rb', line 17

def quitWhenMainWindowCloses
  @quitWhenMainWindowCloses
end

.versionObject

Returns the value of attribute version.



17
18
19
# File 'lib/fzeet/Application.rb', line 17

def version
  @version
end

.windowObject

Returns the value of attribute window.



18
19
20
# File 'lib/fzeet/Application.rb', line 18

def window
  @window
end

Class Method Details

.quit(code = 0) ⇒ Object



58
59
60
61
62
63
# File 'lib/fzeet/Application.rb', line 58

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

	Windows.PostQuitMessage(code)
end

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



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/fzeet/Application.rb', line 27

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
			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