mirror of
https://github.com/EiffelSoftware/eiffel-org.git
synced 2025-12-07 15:22:31 +01:00
Minor refinements, grammar, etc.
Author:vwheeler Date:2014-04-29T16:52:23.000000Z git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@1345 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
@@ -1,62 +1,64 @@
|
||||
[[Property:title|Containers]]
|
||||
[[Property:weight|1]]
|
||||
[[Property:uuid|aa71e29d-f0e0-9eb2-a289-675d24aac927]]
|
||||
All EiffelVision 2 containers inherit [[ref:libraries/vision2/reference/ev_container_chart|EV_CONTAINER]]
|
||||
A container is a EiffelVision 2 widget that may contain other widgets. All containers inherit from [[ref:libraries/vision2/reference/ev_container_chart|EV_CONTAINER]]. Some containers such as [[ref:libraries/vision2/reference/ev_cell_chart|EV_CELL]] may only hold one widget while containers such as [[ref:libraries/vision2/reference/ev_box_chart|EV_BOX]] may hold multiple widgets. Since all containers inherit from type [[ref:libraries/vision2/reference/ev_widget_chart|EV_WIDGET]], this means that a container may be placed inside another container. Windows inherit from [[ref:libraries/vision2/reference/ev_cell_chart|EV_CELL]] and are therefore also classified as containers.
|
||||
|
||||
==What is a container?==
|
||||
{{note|Containers may only contain other widgets. Items may only be placed in certain primitives. For example, an [[ref:libraries/vision2/reference/ev_list_item_chart| EV_LIST_ITEM]] may only be contained in an [[ref:libraries/vision2/reference/ev_list_chart| EV_LIST]]. }}
|
||||
|
||||
A container is a EiffelVision 2 widget that may contain other widgets. Some containers such as [[ref:libraries/vision2/reference/ev_cell_chart|EV_CELL]] may only hold one widget while containers such as [[ref:libraries/vision2/reference/ev_box_chart|EV_BOX]] may hold multiple widgets. As a container is of type [[ref:libraries/vision2/reference/ev_widget_chart|EV_WIDGET]] , this means that a container may be placed within a container. Windows inherit from [[ref:libraries/vision2/reference/ev_cell_chart|EV_CELL]] and are therefore classed as containers also.
|
||||
|
||||
{{note|Containers may only contain other widgets. Items may only be placed in certain primitives. For example, an [[ref:libraries/vision2/reference/ev_list_item_chart| EV_LIST_ITEM]] may be contained in an [[ref:libraries/vision2/reference/ev_list_chart| EV_LIST]] . }}
|
||||
|
||||
==Inheritance from Base==
|
||||
==Inheritance from EiffelBase==
|
||||
|
||||
Wherever possible, EiffelVision 2 containers reuse the container structures provided by [[EiffelBase]]. This provides three main advantages:
|
||||
# Familiarity for operations such as access, insertions and removals. Anybody who already uses [[EiffelBase]] should find it easy to adapt to using EiffelVision 2 containers.
|
||||
# The underlying structures used have been tried and tested for many years and their design has been proved to be robust and effective.
|
||||
# It provides powerful methods of querying the contents. In the original EiffelVision library, you needed to keep reference to widgets as you could not query the contents of a container.
|
||||
|
||||
For example, [[ref:libraries/vision2/reference/ev_container_chart|EV_CONTAINER]] inherits <eiffel>BOX</eiffel> and <eiffel>COLLECTION</eiffel>. Descendents of [[ref:libraries/vision2/reference/ev_container_chart|EV_CONTAINER]] such as [[ref:libraries/vision2/reference/ev_box_chart|EV_BOX]] may also inherit other structures from [[EiffelBase]] .
|
||||
# Familiarity for operations such as access, insertions, and removals. Anybody who already uses [[EiffelBase]] should find it easy to use EiffelVision 2 containers.
|
||||
# The underlying structures used have been tried and tested for many years and their designs have proven to be robust and effective.
|
||||
# Containers provide powerful methods of traversing and searching their contents. In the original EiffelVision library, you needed to keep references to widgets since you could not query the contents of their containers.
|
||||
|
||||
==Usage of Containers==
|
||||
For example, [[ref:libraries/vision2/reference/ev_container_chart|EV_CONTAINER]] inherits from <eiffel>BOX</eiffel> and <eiffel>COLLECTION</eiffel>. Descendents of [[ref:libraries/vision2/reference/ev_container_chart|EV_CONTAINER]] such as [[ref:libraries/vision2/reference/ev_box_chart|EV_TABLE]] may also inherit from other structures in [[EiffelBase]].
|
||||
|
||||
The main role of a container is to position its children in a certain way. An [[ref:libraries/vision2/reference/ev_horizontal_box_chart| EV_HORIZONTAL_BOX]] for example positions its children side by side along the horizontal axis. To achieve vertical stacking you would use an [[ref:libraries/vision2/reference/ev_vertical_box_chart| EV_VERTICAL_BOX]] .
|
||||
|
||||
==Using Containers==
|
||||
|
||||
The main role of a container is to position its children in a certain way. An [[ref:libraries/vision2/reference/ev_horizontal_box_chart| EV_HORIZONTAL_BOX]] for example positions its children side by side. To achieve vertical stacking you would use an [[ref:libraries/vision2/reference/ev_vertical_box_chart| EV_VERTICAL_BOX]] .
|
||||
A code example of adding widgets to a container is as follows:
|
||||
<code>
|
||||
add_to_container is
|
||||
add_to_container
|
||||
-- Add 3 buttons to a hbox and then show in window.
|
||||
local
|
||||
a_window: EV_TITLED_WINDOW
|
||||
a_hbox: EV_HORIZONTAL_BOX
|
||||
a_button: EV_BUTTON
|
||||
my_window: EV_TITLED_WINDOW
|
||||
my_hbox: EV_HORIZONTAL_BOX
|
||||
my_button: EV_BUTTON
|
||||
do
|
||||
create a_window
|
||||
create a_hbox
|
||||
create a_button.make_with_text ("Button1")
|
||||
a_hbox.extend (a_button)
|
||||
a_hbox.extend (create {EV_BUTTON}.make_with_text ("Button2"))
|
||||
a_hbox.extend (create {EV_BUTTON}.make_with_text ("Button3"))
|
||||
a_window.extend (a_hbox)
|
||||
a_window.show
|
||||
create my_window
|
||||
create my_hbox
|
||||
create my_button.make_with_text ("Button1")
|
||||
my_hbox.extend (my_button)
|
||||
my_hbox.extend (create {EV_BUTTON}.make_with_text ("Button2"))
|
||||
my_hbox.extend (create {EV_BUTTON}.make_with_text ("Button3"))
|
||||
my_window.extend (my_hbox)
|
||||
my_window.show
|
||||
end
|
||||
</code>
|
||||
|
||||
The mapping of a EiffelVision 2 container interface is very close to that of containers in [[EiffelBase]], such as a linked list.
|
||||
* To add a widget to a container call `extend'.
|
||||
* To remove a widget from the container call `prune'.
|
||||
* To empty a container call `wipe_out'.
|
||||
* To traverse the container, you can use features such as start, forth, item and off.
|
||||
* To add a widget to a container call <code>`extend'</code>.
|
||||
* To remove a widget from the container call <code>`prune'</code>.
|
||||
* To empty a container call <code>`wipe_out'</code>.
|
||||
* To traverse the container, you can use features such as <code>start</code>, <code>forth</code>, <code>item</code>, and <code>off</code>.
|
||||
|
||||
{{note|When a widget is added to a container, the container is the parent of the widget. }}
|
||||
|
||||
==Size of widget within a container==
|
||||
|
||||
The size of a widget in a container is always at least its minimum size. By default, when a widget is added to a container it is expandable. This means that if the container gets bigger, the widget will expand to fit the extra space. This convenient functionality means that you don't have to worry about handling the size of the widget (such as when a user alters the size of a window) as this is all performed automatically. If, on the other hand, you decide you want the widget to remain at a certain size (its minimum size), [[ref:libraries/vision2/reference/ev_box_chart| EV_BOX]] contains the convenient call disable_item_resize.
|
||||
==Size of a Widget Within a Container==
|
||||
|
||||
==Sizing of containers==
|
||||
As [[ref:libraries/vision2/reference/ev_container_chart|EV_CONTAINER]] is of type [[ref:libraries/vision2/reference/ev_widget_chart|EV_WIDGET]] , the following facilities are provided for setting the minimum size: set_minimum_width, set_minimum_height and set_minimum_size. It is important to remember that as a general rule, '''the current size of a container is always at least the minimum size of all its contents.'''
|
||||
{{note|The exception to this is: [[ref:libraries/vision2/reference/ev_fixed_chart|EV_FIXED]] , [[ref:libraries/vision2/reference/ev_viewport_chart|EV_VIEWPORT]] and [[ref:libraries/vision2/reference/ev_scrollable_area_chart|EV_SCROLLABLE_AREA]] which do actually allow their contents to be larger than their current size. <br/>
|
||||
}}
|
||||
The size of a widget in a container is always at least its minimum size. By default, when a widget is added to a container it is expandable. This means that if the container gets bigger, the widget will expand to fit the extra space. This convenient functionality means that you don't have to worry about handling the size of the widget (such as when a user alters the size of a window) as this is all performed automatically. If, on the other hand, you decide you want the widget to remain at a certain size (its minimum size), [[ref:libraries/vision2/reference/ev_box_chart| EV_BOX]] (and therefore its descendants) contain the convenient call <code>disable_item_resize</code>.
|
||||
|
||||
|
||||
==Sizing of Containers==
|
||||
|
||||
Since [[ref:libraries/vision2/reference/ev_container_chart|EV_CONTAINER]] inherits from type [[ref:libraries/vision2/reference/ev_widget_chart|EV_WIDGET]], the following facilities are provided for setting the minimum size: <code>set_minimum_width</code>, <code>set_minimum_height</code> and <code>set_minimum_size</code>. It is important to remember that as a general rule, '''the current size of a container is always at least the minimum size of all its contents.'''
|
||||
|
||||
{{note|The exception to this is: [[ref:libraries/vision2/reference/ev_fixed_chart|EV_FIXED]], [[ref:libraries/vision2/reference/ev_viewport_chart|EV_VIEWPORT]], and [[ref:libraries/vision2/reference/ev_scrollable_area_chart|EV_SCROLLABLE_AREA]] which do actually allow their contents to be larger than their current size.}}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user