Module: XRC2Ruby::ObjectTypes::Parent
- Included in:
- Container, Menu, MenuBar, ToolBar, TopLevelWindow
- Defined in:
- lib/wx_sugar/xrc/xrc2ruby_types/parent.rb
Overview
Module used by all Windows which can contain other windows, optionally arranging those windows with a Sizer
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#main_sizer ⇒ Object
readonly
Returns the value of attribute main_sizer.
-
#sizer_items ⇒ Object
readonly
Returns the value of attribute sizer_items.
Instance Method Summary collapse
- #add_child(child) ⇒ Object
-
#child_output ⇒ Object
Returns a string containing the ruby code needed to instantiate all the child windows of this container, as well as arranging them in any sizer.
-
#named_windows ⇒ Object
Collects all the contained windows (recursively) that have user-defined names that should be exposed externally.
- #output ⇒ Object
-
#size_child(sizer_item) ⇒ Object
Associates a sizer_item with this parent; keep a map of which settings apply to which child.
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
5 6 7 |
# File 'lib/wx_sugar/xrc/xrc2ruby_types/parent.rb', line 5 def children @children end |
#main_sizer ⇒ Object (readonly)
Returns the value of attribute main_sizer.
5 6 7 |
# File 'lib/wx_sugar/xrc/xrc2ruby_types/parent.rb', line 5 def main_sizer @main_sizer end |
#sizer_items ⇒ Object (readonly)
Returns the value of attribute sizer_items.
5 6 7 |
# File 'lib/wx_sugar/xrc/xrc2ruby_types/parent.rb', line 5 def sizer_items @sizer_items end |
Instance Method Details
#add_child(child) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/wx_sugar/xrc/xrc2ruby_types/parent.rb', line 7 def add_child(child) @children ||= [] @children << child if child.kind_of?(Sizer) and not main_sizer @main_sizer = child end end |
#child_output ⇒ Object
Returns a string containing the ruby code needed to instantiate all the child windows of this container, as well as arranging them in any sizer.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/wx_sugar/xrc/xrc2ruby_types/parent.rb', line 29 def child_output output = '' if children children.each_with_index do | child, i | output += child.output + "\n" if @sizers and ( sizer_item = @sizers[child] ) output += sizer_item.output end end end if self.main_sizer output << "#{var_name}.sizer = #{main_sizer.var_name}" end output end |
#named_windows ⇒ Object
Collects all the contained windows (recursively) that have user-defined names that should be exposed externally. Used by top-level windows to create a list of attribute readers to access named controls within the window.
50 51 52 53 54 55 56 57 |
# File 'lib/wx_sugar/xrc/xrc2ruby_types/parent.rb', line 50 def named_windows return [] unless children children.inject([]) do | names, child | names << child.name if child.name names += child.named_windows if child.kind_of?(Parent) names end end |
#output ⇒ Object
22 23 24 |
# File 'lib/wx_sugar/xrc/xrc2ruby_types/parent.rb', line 22 def output super + child_output end |
#size_child(sizer_item) ⇒ Object
Associates a sizer_item with this parent; keep a map of which settings apply to which child
17 18 19 20 |
# File 'lib/wx_sugar/xrc/xrc2ruby_types/parent.rb', line 17 def size_child(sizer_item) @sizers ||= {} @sizers[sizer_item.window] = sizer_item end |