Class: QDA::GUI::MultiTypedControl
- Inherits:
-
Wx::BoxSizer
- Object
- Wx::BoxSizer
- QDA::GUI::MultiTypedControl
- Defined in:
- lib/weft/wxgui/controls/multitype_control.rb
Overview
A control which has multiple different forms which can be shown or hidden
Instance Attribute Summary collapse
-
#controls ⇒ Object
readonly
Returns the value of attribute controls.
-
#visible ⇒ Object
readonly
Returns the value of attribute visible.
Instance Method Summary collapse
- #add_control(control) ⇒ Object
-
#initialize(first_item) ⇒ MultiTypedControl
constructor
A new instance of MultiTypedControl.
- #show(i) ⇒ Object
- #visible_item ⇒ Object
Constructor Details
#initialize(first_item) ⇒ MultiTypedControl
Returns a new instance of MultiTypedControl.
7 8 9 10 11 12 |
# File 'lib/weft/wxgui/controls/multitype_control.rb', line 7 def initialize( first_item ) super(Wx::HORIZONTAL) @controls = [ first_item ] @visible = 0 add(visible_item, 1, Wx::ALL) end |
Instance Attribute Details
#controls ⇒ Object (readonly)
Returns the value of attribute controls.
4 5 6 |
# File 'lib/weft/wxgui/controls/multitype_control.rb', line 4 def controls @controls end |
#visible ⇒ Object (readonly)
Returns the value of attribute visible.
4 5 6 |
# File 'lib/weft/wxgui/controls/multitype_control.rb', line 4 def visible @visible end |
Instance Method Details
#add_control(control) ⇒ Object
14 15 16 17 |
# File 'lib/weft/wxgui/controls/multitype_control.rb', line 14 def add_control(control) controls.push(control) control.hide() end |
#show(i) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/weft/wxgui/controls/multitype_control.rb', line 23 def show(i) return if i == visible if i < 0 or i >= controls.length raise ArgumentError, "Bad Index" end visible_item.hide() remove(visible_item) @visible = i add(visible_item, 1, Wx::ADJUST_MINSIZE|Wx::ALL) visible_item.show() layout() end |
#visible_item ⇒ Object
19 20 21 |
# File 'lib/weft/wxgui/controls/multitype_control.rb', line 19 def visible_item() controls[visible] end |