Class: RubyMVC::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_mvc/application.rb

Overview

This provides the entry point for a basic application.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, &block) ⇒ Application

Returns a new instance of Application.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/ruby_mvc/application.rb', line 39

def initialize(options, &block)
  @windows = []
  if ico = options[:icon]
    ico = options[:icon] = File.expand_path(ico)
    puts "icon requested: #{ico}"
  end
  @windows << (self.frame = Toolkit::Frame.new(options))
  if cc = options[:controller]
    self.controller = cc
    self.controller.app = self
    self.controller.init
  end
  @frame_width = options[:width]
  @frame_height = options[:height]
  self.instance_eval(&block) if block
  self.frame.show
end

Instance Attribute Details

#controllerObject

Returns the value of attribute controller.



36
37
38
# File 'lib/ruby_mvc/application.rb', line 36

def controller
  @controller
end

#frameObject

FIXME 2011-12-29 ast: The relationship between Toolkit::App and the AppController classes don’t really make sense. This needs to be revisited in a future iteration.



35
36
37
# File 'lib/ruby_mvc/application.rb', line 35

def frame
  @frame
end

#windowsObject

Returns the value of attribute windows.



37
38
39
# File 'lib/ruby_mvc/application.rb', line 37

def windows
  @windows
end

Instance Method Details

#dialog(options, &block) ⇒ Object



73
74
75
76
77
78
79
# File 'lib/ruby_mvc/application.rb', line 73

def dialog(options, &block)
  set_parent(options)
  dlg = Toolkit::Dialog.new(options)
  block.call(dlg) if block
  dlg.show
  dlg
end

#error(msg, options) ⇒ Object



81
82
83
84
85
# File 'lib/ruby_mvc/application.rb', line 81

def error(msg, options)
  options[:class] = :error
  dlg = Toolkit::MessageBox.new(msg, options)
  dlg.show
end

#window(options, &block) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/ruby_mvc/application.rb', line 57

def window(options, &block)
  set_parent(options)

  # FIXME: this is a bit of a hack for wxRuby peers
  options[:height] = @frame_height if !options[:height]
  options[:width] = @frame_width if !options[:width]
  win = Toolkit::Frame.new(options)
  block.call(win) if block
  win.show

  # FIXME: need to be able to intercept the close event so
  # we can remove the window from the list
  @windows << win
  win
end