Class: RubyMVC::Toolkit::WxRuby::Frame
- Inherits:
-
Wx::Frame
- Object
- Wx::Frame
- RubyMVC::Toolkit::WxRuby::Frame
- Includes:
- SignalHandler, Common
- Defined in:
- lib/ruby_mvc/toolkit/peers/wxruby/frame.rb
Instance Method Summary collapse
-
#add(child, options = {}) ⇒ Object
This method is used to add a child to the existing frame.
-
#initialize(options) ⇒ Frame
constructor
A new instance of Frame.
- #merge_actions(actions) ⇒ Object
- #unmerge_actions(actions) ⇒ Object
Methods included from Common
Methods included from SignalHandler
#signal_connect, #signal_disconnect, #signal_emit
Constructor Details
#initialize(options) ⇒ Frame
Returns a new instance of Frame.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ruby_mvc/toolkit/peers/wxruby/frame.rb', line 34 def initialize() opts = {} opts[:title] = [:title] opts[:size] = [ [:width], [:height] ] if parent = [:parent] parent = parent.peer end super(parent, opts) if icon = [:icon] self.set_icon WxRuby.load_icon(icon) end @action_index = {} evt_close do |e| e.skip signal_emit("window-closed", self) end end |
Instance Method Details
#add(child, options = {}) ⇒ Object
This method is used to add a child to the existing frame.
56 57 58 59 60 61 62 63 |
# File 'lib/ruby_mvc/toolkit/peers/wxruby/frame.rb', line 56 def add(child, = {}) child.peer.reparent(self) if child.is_a?(RubyMVC::Views::View) && (a = child.actions) child.frame = self merge_actions(a) end end |
#merge_actions(actions) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 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/ruby_mvc/toolkit/peers/wxruby/frame.rb', line 65 def merge_actions(actions) # puts "#merge_actions #{actions.inspect}" tb = actions.each do |a| i = @action_index.size # puts "Action: #{a.label}" case a[:icon] when :stock_new artid = Wx::ART_NEW when :stock_edit artid = Wx::ART_NORMAL_FILE when :stock_delete artid = Wx::ART_DELETE when :stock_home artid = Wx::ART_GO_HOME when :stock_back artid = Wx::ART_GO_BACK when :stock_forward artid = Wx::ART_GO_FORWARD when :stock_reload artid = Wx::ART_REDO end if artid icon = Wx::ArtProvider.get_bitmap(artid, Wx::ART_TOOLBAR, [ 16, 16 ]) else icon = Wx::NULL_BITMAP end tb.add_tool(i, a.label, icon) tb.enable_tool(i, a.sensitive) a.signal_connect("property-changed") do |a, key, old, val| # puts "property changed: #{key} => #{val}" tb.enable_tool(i, val) end evt_tool(i) do |event| # puts "Action[#{i}] triggered: #{a.key}" a.call end @action_index[a.key] = i end @toolbar.realize # puts "action_index: #{@action_index.inspect}" end |
#unmerge_actions(actions) ⇒ Object
110 111 112 113 114 115 116 117 118 |
# File 'lib/ruby_mvc/toolkit/peers/wxruby/frame.rb', line 110 def unmerge_actions(actions) # puts "unmerge actions: #{actions.inspect}" tb = actions.each do |a| idx = @action_index.delete(a.key) # puts "unmerge action[#{idx}] => #{a.inspect}" tb.delete_tool(idx) if idx end end |