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.



69
70
71
# File 'lib/fzeet/windows.rb', line 69

def accelerators
  @accelerators
end

.authorsObject

Returns the value of attribute authors.



68
69
70
# File 'lib/fzeet/windows.rb', line 68

def authors
  @authors
end

.devcapsObject (readonly)

Returns the value of attribute devcaps.



69
70
71
# File 'lib/fzeet/windows.rb', line 69

def devcaps
  @devcaps
end

.dialogsObject (readonly)

Returns the value of attribute dialogs.



69
70
71
# File 'lib/fzeet/windows.rb', line 69

def dialogs
  @dialogs
end

.imagesObject (readonly)

Returns the value of attribute images.



69
70
71
# File 'lib/fzeet/windows.rb', line 69

def images
  @images
end

.nameObject

Returns the value of attribute name.



68
69
70
# File 'lib/fzeet/windows.rb', line 68

def name
  @name
end

.quitWhenMainWindowClosesObject

Returns the value of attribute quitWhenMainWindowCloses.



68
69
70
# File 'lib/fzeet/windows.rb', line 68

def quitWhenMainWindowCloses
  @quitWhenMainWindowCloses
end

.versionObject

Returns the value of attribute version.



68
69
70
# File 'lib/fzeet/windows.rb', line 68

def version
  @version
end

.windowObject

Returns the value of attribute window.



69
70
71
# File 'lib/fzeet/windows.rb', line 69

def window
  @window
end

Class Method Details

.quit(code = 0) ⇒ Object



110
111
112
113
114
115
# File 'lib/fzeet/windows.rb', line 110

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

  Windows.PostQuitMessage(code)
end

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



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/fzeet/windows.rb', line 78

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