Class: Wads::SectionLayout
- Inherits:
-
WadsLayout
- Object
- WadsLayout
- Wads::SectionLayout
- Defined in:
- lib/wads/widgets.rb
Overview
SectionLayout is an intermediate class in the layout class hierarchy that is used to divide the visible screen into different sections. The commonly used sections include SECTION_TOP or SECTION_NORTH, SECTION_MIDDLE or SECTION_CENTER, SECTION_BOTTOM or SECTION_SOUTH, SECTION_LEFT or SECTION_WEST, SECTION_RIGHT or SECTION_EAST.
Direct Known Subclasses
BorderLayout, ContentFooterLayout, EastWestLayout, HeaderContentLayout, TopMiddleBottomLayout
Instance Attribute Summary collapse
-
#container_map ⇒ Object
Returns the value of attribute container_map.
Attributes inherited from WadsLayout
#args, #border_coords, #parent_widget
Instance Method Summary collapse
-
#add_east_west_panel(args) ⇒ Object
This is a convenience method that creates a panel divided into a left and right, or east and west section.
-
#get_coordinates(element_type, args = {}) ⇒ Object
Get the coordinates for the given element type.
-
#initialize(x, y, width, height, parent_widget, args = {}) ⇒ SectionLayout
constructor
A new instance of SectionLayout.
Methods inherited from WadsLayout
#add_button, #add_document, #add_graph_display, #add_horizontal_panel, #add_image, #add_max_panel, #add_multi_select_table, #add_plot, #add_single_select_table, #add_table, #add_text, #add_text_input, #add_vertical_panel, #add_widget, #internal_add_panel
Constructor Details
#initialize(x, y, width, height, parent_widget, args = {}) ⇒ SectionLayout
Returns a new instance of SectionLayout.
787 788 789 790 |
# File 'lib/wads/widgets.rb', line 787 def initialize(x, y, width, height, , args = {}) super @container_map = {} end |
Instance Attribute Details
#container_map ⇒ Object
Returns the value of attribute container_map.
785 786 787 |
# File 'lib/wads/widgets.rb', line 785 def container_map @container_map end |
Instance Method Details
#add_east_west_panel(args) ⇒ Object
This is a convenience method that creates a panel divided into a left and right, or east and west section. It will take up the entire space of the specified ARG_SECTION in the args map.
814 815 816 817 818 819 820 821 822 823 824 825 826 827 |
# File 'lib/wads/widgets.rb', line 814 def add_east_west_panel(args) section = args[ARG_SECTION] if section.nil? raise "East west panels require the arg '#{ARG_SECTION}' with value #{@container_map.keys.join(', ')}" end container = @container_map[section] new_panel = Panel.new(container.start_x, container.start_y, container.max_width, container.max_height) new_panel.set_layout(LAYOUT_EAST_WEST, args) new_panel.base_z = @parent_widget.base_z new_panel.disable_border @parent_widget.add_child(new_panel) new_panel end |
#get_coordinates(element_type, args = {}) ⇒ Object
Get the coordinates for the given element type. A generic map of parameters is accepted, however the ARG_SECTION is required so the layout can determine which section or container is used.
797 798 799 800 801 802 803 804 805 806 807 |
# File 'lib/wads/widgets.rb', line 797 def get_coordinates(element_type, args = {}) section = args[ARG_SECTION] if section.nil? raise "Layout addition requires the arg '#{ARG_SECTION}' with value #{@container_map.keys.join(', ')}" end container = @container_map[section] if container.nil? raise "Invalid section #{section}. Value values are #{@container_map.keys.join(', ')}" end container.get_coordinates(element_type, args) end |