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

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

Instance Method Summary collapse

Methods included from Common

#title, #title=

Methods included from SignalHandler

#signal_connect, #signal_disconnect, #signal_emit

Constructor Details

#initialize(options) ⇒ Dialog

Returns a new instance of Dialog.



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

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.



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

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



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

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

#add_view(view) ⇒ Object



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

def add_view(view)
  sizer = Wx::BoxSizer.new(Wx::VERTICAL)
  view.peer.reparent(self)
  sizer.add(view.peer, 1, Wx::EXPAND|Wx::ALL, 5)
  sizer.add(@buttons, 0, Wx::ALIGN_RIGHT|Wx::ALL, 5)
  self.sizer = sizer
  layout
end

#showObject



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/ruby_mvc/toolkit/peers/wxruby/dialog.rb', line 77

def show
  self.centre
  if @modal
    case self.show_modal()
    when Wx::ID_OK, Wx::ID_YES
      @wxform.submit if @wxform
      resp = :accept
    else
      resp = :cancel
    end
    signal_emit("response", self, resp)
  else
    sel.show()
  end
end