module QDA::GUI # A control which has multiple different forms which can be shown or hidden class MultiTypedControl < Wx::BoxSizer # controls is an array of all the individual controls contained in this # swapper # visible is the index of currently visible control attr_reader :controls, :visible # def initialize( first_item ) super(Wx::HORIZONTAL) @visible = 0 @controls = [ first_item ] add(first_item, 1, Wx::ALIGN_CENTRE_VERTICAL) end def add_control(control) controls.push(control) control.hide() end def add_duplicate(control) controls.push(control) end def visible_item() controls[visible] end def show(i) return if i == visible if i < 0 or i >= controls.length raise ArgumentError, "Bad Index" end visible_item.hide() detach(visible_item) @visible = i add(visible_item, 1, Wx::ALIGN_CENTRE_VERTICAL) visible_item.show() layout() end end end