A Widget is the fundamental building block of your applications GUI, components such as Windows, Buttons and Labels are examples of such. The widget set of Vision2 provide you with the flexibility to easily create powerful graphical applications. All widgets in Vision2 inherit from EV_WIDGET and the features provided in EV_WIDGET may be called on any widget.
Within Vision2, widgets have been classified into three different groups:
All widgets in Vision2 are based around the default_create mechanism in Eiffel, this means that all that needs to be done to create a widget is to declare a reference to a type (such as EV_BUTTON) and then call create on that reference. An example of this is as follows.
a_button: EV_BUTTON
create a_button
Along with the default creation, Vision2 also includes a few convenience creation functions. Examples of this are make_with_text for all widgets that may have text associated with them (those that inherit from EV_TEXTABLE), this saves a call to set_text upon default creation of the textable widget.
create a_button.make_with_text ("Click Me")
This would be in place of
create a_button
a_button.set_text ("Click Me")
Note: When a widget is created no extra initialization has to be performed, the only exception is for a window where you have to call show in order for it to be displayed on screen.
As EV_PRIMITIVE is of type EV_WIDGET, the following facilities are provided for setting the minimum size : set_minimum_width, set_minimum_height and set_minimum_size.
The minimum size of a widget is the smallest possible size that it can possibly be inside its parent container. If an EV_BUTTON was created and set with a minimum_size of width/height (100, 100), if this button was inserted in to an EV_HORIZONTAL_BOX, then the box's size could never be below (100, 100) or it would break the minimum size of the button. The size of a container must always be greater or equal to the minimum sizes of its children.
Note: In Vision2, there is no way to set the current size of the primitive. The current size is dependent on the size of the parent or the minimum_size.