Class: QDA::GUI::MultiTypedControl

Inherits:
Wx::BoxSizer
  • Object
show all
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

Instance Method Summary collapse

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

#controlsObject (readonly)

Returns the value of attribute controls.



4
5
6
# File 'lib/weft/wxgui/controls/multitype_control.rb', line 4

def controls
  @controls
end

#visibleObject (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_itemObject



19
20
21
# File 'lib/weft/wxgui/controls/multitype_control.rb', line 19

def visible_item()
  controls[visible]
end