how good and how pleasant it would be
before god and man
to see the unification of all Africans
as it's been said already
let it be done right now
we are the children of the rastaman
we are the children of the higher man
B.Marley "Africa Unite"
Windows has a number of predefined special windows with useful behaviors. Tne idea of these windows, called controls, is to supply standard interface elements similar to an appliance's controls. For example the control, called checkbox, is used to enable or disable some options. You can use it in your applications without spending your time on thinking how to draw it, whether it is checked or not. All you need is:
cb : CHECK_BUTTON ... !!cb.make("&Fast &Save",rect,0) ... cb.press ... if cb.is_pressed then fast_save := True end
This text confirms to one of the attractive features of OOP-style: information encapsulating. When control is implemented, you can forget about its realization. All you need is to know about its interface which is usually very simple.
Another advantage of common controls is the unification of any applications. When you know how common controls work you can use this knowledge anywhere in any others Windows applications.
Class CONTROL introduces two new features:
set_font ( new_font : FONT ) font : FONT
Their usage is clear and understandable. Only note if you set a non-default font into the control, your control might look very unusual on another screen resolution, another computer and so on. Be careful and remember about non-standard font mapping.
Buttons are very simple controls. They hold no information except their states (pressed or not pressed).
Class BUTTON has the following features:
set_tabstop clear_tabstop
These are the features for the set/reset control. They are "bus stops" in keyboard's traveling through the set of controls while using keys Tab and Shift+Tab. These "bus stops" are defined only for tabstoppable controls (interface style STYLE_TABSTOP must be set).
press release toggle is_pressed : BOOLEAN
Features implement the "boolean" nature of buttons. By using them you can set the controls inside your program and check their state.
height_init : REAL minimal_width ( title : STRING ) : REAL
These actions are used to check the size of the control.
This is a simple push button. It is used for immediate actions. The typical way to work with a set of controls is to set all these controls and then press the push button to confirm your selection. You can only press it or release and check its state.
Figure 4.1 A push button.
This is a TEXT_BUTTON control. When it is pushed by User the parent window is automatically notified via the on_clicked callback. It has four new features:
make ( n : STRING, r : RECT, ctx : INTEGER ) mark_default mark_not_default is_default : BOOLEAN
These features mark the default push-button. The default button is the button being pushed when User presses the Enter key in any dialog box.
Note There must be only one default button in any dialog box.
A check box is an optional check mark. It can be on, off or disabled. If there is a set of check boxes their states are independent from each other. The control is used in independent option combinations like at the following picture:
Figure 4.2 A group of check boxes.
Radio buttons are similar to check boxes but differ in one: in a group of radio buttons there must be only one checked button.
Figure 4.3 A radio buttons group.
These classes are text entry controls. You can use them for a single line input or mini-editor. The parent window can redefine its on_changed callback to handle any events from these controls.
This is a deferred class for all entry components. It includes the following features for text settings:
set_text ( new_text : STRING ) set_limit ( text_size : INTEGER ) get_text : STRING get_size : INTEGER
Use it to initialize the control, for example, to limit the size of the input string (of the control).
The next part is the Cut'n'Paste features. If you use any text editor you can guess what they are for.
copy_selection cut_selection clear_selection paste_selection select_range ( start_pos, end_pos : INTEGER ) select_all replace_selection ( new_text : STRING) get_selection_range : POINT
The next group defines the internal modification flag. It can be useful to check whether User has changed something or not.
set_modified (state : BOOLEAN) is_modified : BOOLEAN
The following features are used for undoing the last operation done under the control.
undo clear_undo can_undo : BOOLEAN
This is a single line input control. When User changes the contents of TEXT_LINE_ENTRY the parent window is notified via the on_changed callback.
Figure 4.4 A text line entry.
make ( a_name : STRING, area : RECT, a_context : INTEGER ) make_fixed (a_name : STRING, area : RECT, a_context, a_max_size : INTEGER ) make_password (a_name : STRING, area: RECT, a_context, a_max_size : INTEGER )
Creation procedure make is a typical one. Two additional creation procedures allow to limit the size of the entry and show all entered characters as asterisks (this can be useful for password fields).
Other features are clear from their names.
set_border ( state : BOOLEAN ) has_border : BOOLEAN is_password : BOOLEAN
This class represents the multiline text entry control.
Figure 4.5 A memo entry.
The creation procedures are similar to the single line entry ones - except makex. This feature has additional parameters defining the scroll, align and read-only states of the entry.
make (a_name: STRING, area: RECT, a_context: INTEGER) make_fixed (a_name: STRING, area: RECT, a_context: INTEGER) makex (a_name: STRING, area: RECT, a_context, scroll_dir, align: INTEGER, state: BOOLEAN)
Below you can see the list of the constants defining the scroll and align states:
NO_SCROLL : INTEGER V_SCROLL : INTEGER H_SCROLL : INTEGER VH_SCROLL : INTEGER LEFT : INTEGER CENTER : INTEGER RIGHT : INTEGER
The next features extend the ENTRY service for a multiline editor. Using it you can work with an editor on per-line level, take a line by numberand get the first visible line on the screen.
set_read_only ( state : BOOLEAN ) read_only_flag : BOOLEAN scroll ( vertical_step, horiz_step : INTEGER ) scroll_direction : INTEGER alignment : INTEGER get_size : INTEGER get_line ( line_index : INTEGER) : STRING get_line_count : INTEGER get_char_line ( char_offset : INTEGER ) : INTEGER get_line_index ( line_number : INTEGER ) : INTEGER get_length ( line_index : INTEGER ) : INTEGER get_first_visible_line : INTEGER
STATIC_ TEXT is a very simple control that allows you to draw some text in a window. It has three features defining the text justification:
justify_left justify_right justify_center
Figure 4.6 A centered static text control.
GROUP_BOX is a static control which has only a visual effect - surrounding a logical group of the controls - note the borders in the picture below.
Figure 4.7 Two group boxes.
Use this control to unite related controls into a group.
LISTBOX is a structure used to present a list of text strings. User can select one or more elements in it.
Figure 4.8 List boxes.
On the picture above you can see three types of list box: simple list box "Alphabetical List" and two combo boxes "Not Found" and "Replace with synonym". The last two differ in the way of representing their contents.
This control has only one creation feature make. It has two unusual parameters: multi_sel which defines ability to select more than one element inside the list and selfdrawing which defines the list box as an abstract list with self-drawing elements. For example you can draw a small icon near each element.
make ( n : STRING, r : RECT, ctx : INTEGER, multi_sel, selfdrawing : BOOLEAN )
To understand other functions consider a list box as a container of text strings. Amount of the features is rather big, but all of them are very simple to understand.
add ( c : COMPONENT ) insert_at_pos ( c : COMPONENT, pos : INTEGER ) insert_before ( c : COMPONENT, before : COMPONENT ) insert_after ( c : COMPONENT, after : COMPONENT ) remove ( c : COMPONENT ) remove_at_pos ( pos : INTEGER ) wipe adapt ( ca : ARRAY_MODEL[COMPONENT] ) set_current ( c : COMPONENT ) set_current_pos ( pos : INTEGER ) clear_selection select_all unselect_all set_columns_number ( num : INTEGER ) set_item_height ( ih : INTEGER ) select_component ( c : COMPONENT ) unselect_component ( c : COMPONENT ) select_pos ( pos : INTEGER ) unselect_pos ( pos : INTEGER ) lock unlock number_of_entries : INTEGER get_current : COMPONENT get_current_pos : INTEGER get_component_pos ( c : COMPONENT ) : INTEGER get_component ( i : INTEGER ) : COMPONENT is_selected ( c : COMPONENT ) : BOOLEAN selected_count : INTEGER is_selected_pos ( pos : INTEGER ) : BOOLEAN multi : BOOLEAN self_drawing : BOOLEAN item_height : INTEGER columns : INTEGER
COMBO_BOX is a version of the list box showing only the string currently selected. The other strings are shown only after clicking on it. The class interface is the same as the list box's one.
It is the version of the combo box storing all previous selections. You can select either a previously selected string or the new one. Feature get_entry_text returns the current text line.