A menu_item is an item of a menu. Note that class popup
is a subclass of menu and therefore menu_items also describe entries of
popups.
The menu_items of a menu are organised in a chain (menu<-members).
The menu decides on the layout and how they are displayed. The menu also
takes care of handling the user-interaction.
The menu_item<->value
of a menu_item is used to address it in the menu. The
menu_item<->label
determines what is shown on the display, It can either be a string or a
bitmap. The menu_item<->message
what happens if the user selects this menu_item. The message may be @default,
in which case the message associated with the menu is used. menu_item<->end_group
tells the menu this is the last entry of a logical group. Used by
popup's only. Finally, the menu_item<->condition
is a code object that
determines whether or not the item should be active when in a popup.
User interface:
Menu_items are no graphical objects. Their visual appearance and user-interface is entirely determined by the menu.
Bugs:
The menu_item<->end_group
facility is at te wrong place: it harms reusability (which is not used
very often anyway) and it makes changes to menu's difficult. It might be
wiser to introduce a menu_item_group object to bundle menu
items.
->key, which will make the
menu behave as if this menu_item was selected if the argument key
matches this slot.Defaults: @on (active to events)
Defaults:
@default (its
default value) will paint the menu_item in the colour of its associated menu_item<-menu.
<-active
according the this truth value.
Tested by popup->update.
Defaults: @nil
(popup->update
does not change activation status).
Defaults: @off (no line is painted).
<-label.
Normally used to realise font-selection menus.
Defaults: When @default, menu<-value_font
of the associated menu_item<-menu
is used.
|image]<-colour
and menu_item<-font
specified with this item. When is is an image, the menu will display
this image in menu_item<-colour.
The initial value is normally computed by menu_item<-default_label
from the
menu_item<-value
by menu_item->initialise.
The menu maintains a list of menu_items manipulated in menu<-members.
<-message
from the associated menu_item<-menu
will be sent.
The arguments forwarded depend on the menu. See description with class menu.
<-convert
method transforms popup
objects in menu_items with this popup associated, which allows appending
popup menu's to popup menus to create pullright menus.
Defaults: @nil
<->multiple_selection.
The visual feedback is determined by
menu<->feedback.
This separation is useful for two purposes. First of all menu's are
often used to select some value. For example a colour in a drawing tool.
In this case the colour
object is used as a value, while an all-1's image with is used as label
and menu_item<->colour
is set to
menu_item<->value.
When the user selects a menu-item, the colour
object to be used may be read directly from the menu_item<->value
object of the menu_item.
Second, this mechanism may be used to implement multi-language
interfaces. In this case the menu_item<->value
represents the internal name used by the program and the menu_item<->label
the external name that may be in a different language.
The default menu_item<->label
is compute from the initial menu_item<->value
using
menu_item<-default_label.
-value_font|image], end_group=[bool],
condition=[code]*, accelerator=[name]*
<->value
(any) This argument is the value associated with this item.
<->message
[code]* Message sent when item is activated. @default
uses the
dialog_item<->message.
<->label
[name|image] Visual appearance: text or image. When @default,
this is computed using menu_item<-default_label
from the value.
<->end_group
[bool] Popup menu's only. When @on,
a line is drawn between this item and the next.
<->condition
[code]* Popup menu's only. Condition to determine menu_item<->active
status. When @nil
(default), this is not evaluated when the popup is mapped on the screen.
->active.
Backward compatibility.
->active.
Backward compatibility.
|image]->initialise.
<-name
and relate the popup with this menu_item using (menu_item->popup
and popup->context). This conversion
allows simple specification of pull-right menus:
new(P, popup(attributes)), new(C, popup(colour)), new(F, popup(font)), send_list(C, append, [...]), % fill sub-popups here send_list(F, append, [...]), send_list(P, append, [C, F]). % associate as pullright
When the argument is not a popup, menu_item<-convert
will create a menu-item using the argument as a value and leaving all
other menu_item->initialise
parameters @default.
|image<-initialise when the
label argument is @default.
It performs the following steps:
->draw_in
to draw the graphical in the image.
<-label_name
to map the word-separator (default’_’, see pce->syntax)
to a space and capitalise all the words.
<-name yields a
name, call
char_array<-label_name
on it and return the result.
To realise multi-language support, one might wish to redefine this method yielding labels in the user's preferred language from internal program names.