Class: RubyMVC::Toolkit::WxRuby::Dialog

Inherits:
Wx::Dialog
  • Object
show all
Includes:
Common
Defined in:
lib/ruby_mvc/toolkit/peers/wxruby/dialog.rb

Instance Method Summary collapse

Methods included from Common

#title, #title=

Constructor Details

#initialize(options) ⇒ Dialog

Returns a new instance of Dialog.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/ruby_mvc/toolkit/peers/wxruby/dialog.rb', line 33

def initialize(options)
  opts = {}
  title = options[:title] || "Dialog"
  winid = options[:id] || -1
  opts[:size] = [ options[:width], options[:height] ]
  if parent = options[:parent]
    parent = parent.peer
  end
  if options[:modal].nil? || options[:modal]
    @modal = true
  else
    @modal = false
  end
  super(parent, winid, title)
  @buttons = create_separated_button_sizer(Wx::OK|Wx::CANCEL)
end

Instance Method Details

#add(child, options = {}) ⇒ Object

This method is used to add a child to the existing frame.



53
54
55
# File 'lib/ruby_mvc/toolkit/peers/wxruby/dialog.rb', line 53

def add(child, options = {})
  child.peer.reparent(self)
end

#add_form(form) ⇒ Object

This method is used to add a FormView to the main content part of the dialog



60
61
62
63
64
65
# File 'lib/ruby_mvc/toolkit/peers/wxruby/dialog.rb', line 60

def add_form(form)
  @wxform = FormBuilder.build(self, form)
  @wxform.widget.add(@buttons, 0, Wx::ALIGN_RIGHT|Wx::ALL, 5)
  self.sizer = @wxform.widget
  self.sizer.fit(self)
end

#showObject



67
68
69
70
71
72
73
74
75
76
# File 'lib/ruby_mvc/toolkit/peers/wxruby/dialog.rb', line 67

def show
  self.centre
  if @modal
    if Wx::ID_OK == self.show_modal()
      @wxform.submit if @wxform
    end
  else
    sel.show()
  end
end