Rogue Wave Views 5.5.1 |
Rogue Wave Views |
Rogue Wave Views Documentation Home |
Gadget class. More...
#include <ilviews/gadgets/amenu.h>
Public Member Functions | |
void | addHighlightCallback (const IlSymbol *callbackName, IlBoolean submenus=IlTrue) |
Adds a named "Highlight" callback to the menu. | |
void | addHighlightCallback (IlvGraphicCallback callback, IlBoolean sub=IlTrue) |
Adds a "Highlight" callback to the menu. | |
virtual IlvGadgetItem * | createItem (const char *label, IlvGraphic *graphic=0, IlvBitmap *bitmap=0, IlvBitmap *selbitmap=0, IlBoolean copy=IlTrue) const |
Returns a new gadget item. | |
void | deSelectAll () |
Deselects all the items. | |
virtual void | empty () |
Empties the list. | |
IlvMenuItem * | getItem (IlUShort pos) const |
Returns an item from its position in the holder. | |
virtual IlvGadgetItem * | getItemByName (const char *) const |
Returns the item whose name is specified. | |
IlvMenuItem *const * | getItems (IlUShort &count) const |
Returns an array of all the items in the menu. | |
virtual void | getLabelOrientation (IlvOrientation &orientation, IlBoolean &flip) const |
Returns the default orientation of the labels associated with the menu items. | |
virtual IlvPosition | getLabelPosition () const |
Returns the default position of the labels associated with the menu items, relative to their picture. | |
virtual IlvPalette * | getNormalTextPalette () const |
Returns the default palette used to draw an item. | |
virtual IlvPalette * | getOpaquePalette () const |
Returns the opaque palette used to draw opaque items. | |
IlUShort | insertItem (IlUShort pos, const char *label, const IlvPopupMenu *menu=0, IlBoolean copy=IlTrue) |
Inserts a menu item that has a label. | |
IlUShort | insertItem (IlvMenuItem *item, IlShort pos=-1) |
Inserts a menu item at the specified position. | |
virtual IlBoolean | isSelectable (const IlvMenuItem *item) const |
Indicates whether the specified item can be selected. | |
virtual IlBoolean | isShowingLabel () const |
Returns IlTrue if the labels associated with the menu items are displayed. | |
virtual IlBoolean | isShowingPicture () const |
Returns IlTrue if the pictures associated with the menu items are displayed. | |
virtual void | itemBBox (IlUShort index, IlvRect &bbox, const IlvTransformer *t=0) const =0 |
Returns the bounding box of a menu item in the menu. | |
virtual IlShort | pointToPosition (const IlvPoint &point, const IlvTransformer *t=0) const |
Returns the index of the menu item located at the position indicated by point. | |
virtual void | recomputeAllItems () |
Recomputes the size of all the items managed by the holder. | |
virtual void | select (IlUShort pos) |
Is called when an item has been selected. | |
virtual IlShort | selectNext () |
Is called when the user tries to select the next menu item using the keyboard. | |
virtual IlShort | selectPrevious () |
Is called when the user tries to select the previous menu item using the keyboard. | |
void | setHighlightCallback (const IlSymbol *callbackName, IlBoolean submenus=IlTrue) |
Sets a named "Highlight" callback to the menu. | |
void | setHighlightCallback (IlvGraphicCallback callback, IlBoolean submenus=IlTrue) |
Sets a "Highlight" callback to the menu. | |
virtual void | setItems (IlvGadgetItem *const *items, IlUShort count) |
Replaces the entire list of items. | |
void | setItems (IlvMenuItem *const *items, IlUShort count) |
Replaces the entire list of items in the menu. | |
void | setLabelOrientation (IlvOrientation orientation, IlBoolean flip=IlFalse, IlBoolean redraw=IlTrue) |
Sets the default orientation of the labels associated with the menu items. | |
void | setLabelPosition (IlvPosition position, IlBoolean redraw=IlTrue) |
Sets the default position of the menu item labels, relative to their picture. | |
void | showLabel (IlBoolean value=IlTrue, IlBoolean redraw=IlTrue) |
Specifies whether the menu item labels should be shown or hidden. | |
void | showPicture (IlBoolean value=IlTrue, IlBoolean redraw=IlTrue) |
Specifies whether the menu item pictures should be shown or hidden. | |
virtual void | unSelect (IlUShort pos) |
Is called when an item has been deselected. | |
IlShort | whichSelected () const |
Returns the index of the selected item. | |
Static Public Member Functions | |
static IlSymbol * | HighlightCBSymbol () |
Returns the callback type for the Highlight callback. | |
Protected Member Functions | |
IlvAbstractMenu (IlvDisplay *display, IlUShort count, IlvMenuItem *items, IlUShort thickness=IlvDefaultGadgetThickness, IlvPalette *palette=0) | |
Constructor. | |
IlvAbstractMenu (IlvDisplay *display, IlUShort count=0, const char *const *labels=0, IlUShort thickness=IlvDefaultGadgetThickness, IlvPalette *palette=0) | |
Constructor. | |
virtual void | itemActivated (IlvGadgetItem *) |
Is called when an item is activated. |
Gadget class.
Library: ilvgadgt
This pure abstract class is used to facilitate the use of menu classes, such as IlvMenuBar
, IlvToolBar
, and IlvPopupMenu
.
IlvAbstractMenu::IlvAbstractMenu | ( | IlvDisplay * | display, | |
IlUShort | count = 0 , |
|||
const char *const * | labels = 0 , |
|||
IlUShort | thickness = IlvDefaultGadgetThickness , |
|||
IlvPalette * | palette = 0 | |||
) | [protected] |
Constructor.
Initializes a new instance of the IlvAbstractMenu
class.
display | The connection to the display. | |
count | The number of elements in the labels array. | |
labels | An array of predefined labels. | |
thickness | The thickness of the menu. | |
palette | The palette used to draw the menu. |
IlvAbstractMenu::IlvAbstractMenu | ( | IlvDisplay * | display, | |
IlUShort | count, | |||
IlvMenuItem * | items, | |||
IlUShort | thickness = IlvDefaultGadgetThickness , |
|||
IlvPalette * | palette = 0 | |||
) | [protected] |
Constructor.
Initializes a new instance of the IlvAbstractMenu
class. The items are copied by this constructor.
display | The connection to the display. | |
count | The number of elements in the items array. | |
items | An array of predefined items. | |
thickness | The thickness of the menu. | |
palette | The palette used to draw the menu. |
void IlvAbstractMenu::addHighlightCallback | ( | const IlSymbol * | callbackName, | |
IlBoolean | submenus = IlTrue | |||
) |
Adds a named "Highlight" callback to the menu.
Adds the highlight callback specified by callbackName to the menu. If submenus is set to IlTrue
, the same callback name is added to the submenus. When the callback is invoked, its IlAny
parameter can be cast in a pointer to an IlShort
. This IlShort
indicates the position of the currently highlighted menu item or is set to -1
if no menu item is highlighted. See the example in the setHighlightCallback
method above. A "Highlight" callback is invoked when a menu item is highlighted.
callbackName | The name of the callback. | |
submenus | A Boolean value specifying whether the callback should be propagated to the submenus. |
void IlvAbstractMenu::addHighlightCallback | ( | IlvGraphicCallback | callback, | |
IlBoolean | sub = IlTrue | |||
) |
Adds a "Highlight" callback to the menu.
Adds the "Highlight" callback specified by callback
to the menu. If submenus
is set to IlTrue
, the same callback is added to the submenus. When the callback is invoked, its IlAny
parameter can be cast in a pointer to an IlShort
. This IlShort
indicates the position of the currently highlighted menu item or is set to -1
if no menu item is highlighted. See the example in the setHighlightCallback
method above. A "Highlight" callback is invoked when an item of the menu is highlighted.
callback | A pointer to the callback. | |
submenus | A Boolean value specifying whether the callback should be propagated to the submenus. |
virtual IlvGadgetItem* IlvAbstractMenu::createItem | ( | const char * | label, | |
IlvGraphic * | graphic = 0 , |
|||
IlvBitmap * | bitmap = 0 , |
|||
IlvBitmap * | selbitmap = 0 , |
|||
IlBoolean | copy = IlTrue | |||
) | const [virtual] |
Returns a new gadget item.
You can override this member function in a subclass to create your own items.
label | The item label. | |
graphic | The IlvGraphic object representing the picture associated with the item. | |
bitmap | The IlvBitmap object representing the picture associated with the item. | |
selbitmap | The IlvBitmap object representing the picture of the item when it is selected. | |
copy | A Boolean value specifying whether a label should be copied. If the value is IlFalse |
[note] If both the second and third parameters are not null, only the second parameter is used.
The created gadget item.
Reimplemented from IlvGadgetItemHolder.
void IlvAbstractMenu::deSelectAll | ( | ) | [virtual] |
Deselects all the items.
Reimplemented from IlvListGadgetItemHolder.
virtual void IlvAbstractMenu::empty | ( | ) | [virtual] |
Empties the list.
Implements IlvListGadgetItemHolder.
Reimplemented in IlvPopupMenu, and IlvToolBar.
IlvMenuItem* IlvAbstractMenu::getItem | ( | IlUShort | index | ) | const |
Returns an item from its position in the holder.
index | The item position. |
index
th item. Returns 0
if index is not valid. Reimplemented from IlvListGadgetItemHolder.
virtual IlvGadgetItem* IlvAbstractMenu::getItemByName | ( | const char * | name | ) | const [virtual] |
Returns the item whose name is specified.
name | The name of the item. |
0
if the specified item cannot be found. IlvGadgetItem::setName
, applyToItems
. Reimplemented from IlvGadgetItemHolder.
IlvMenuItem* const* IlvAbstractMenu::getItems | ( | IlUShort & | count | ) | const |
Returns an array of all the items in the menu.
count | The number of items managed by this menu. |
Reimplemented from IlvListGadgetItemHolder.
virtual void IlvAbstractMenu::getLabelOrientation | ( | IlvOrientation & | orientation, | |
IlBoolean & | flip | |||
) | const [virtual] |
Returns the default orientation of the labels associated with the menu items.
orientation | The default orientation of the labels. | |
flip | A Boolean value specifying whether the labels are flipped or not. For more information, see the setLabelOrientation method. |
Reimplemented from IlvGadgetItemHolder.
virtual IlvPosition IlvAbstractMenu::getLabelPosition | ( | ) | const [virtual] |
Returns the default position of the labels associated with the menu items, relative to their picture.
Reimplemented from IlvGadgetItemHolder.
virtual IlvPalette* IlvAbstractMenu::getNormalTextPalette | ( | ) | const [virtual] |
Returns the default palette used to draw an item.
Implements IlvGadgetItemHolder.
virtual IlvPalette* IlvAbstractMenu::getOpaquePalette | ( | ) | const [virtual] |
Returns the opaque palette used to draw opaque items.
Reimplemented from IlvGadgetItemHolder.
static IlSymbol* IlvAbstractMenu::HighlightCBSymbol | ( | ) | [static] |
Returns the callback type for the Highlight callback.
The Highlight callback is called when the highlighted item has changed. see IlvGraphic::setCallback, IlvGadgetItem::highlight
IlUShort IlvAbstractMenu::insertItem | ( | IlUShort | pos, | |
const char * | label, | |||
const IlvPopupMenu * | menu = 0 , |
|||
IlBoolean | copy = IlTrue | |||
) |
Inserts a menu item that has a label.
Creates a new menu item with the specified label, sets menu as the submenu of this new item, and adds the item to the menu at the position specified by pos. Note that the pop-up menu is always copied. The last parameter copy is not used and is kept only to allow compatibility with version 2.1.
pos | The position where the new item should be inserted. | |
label | The label of the new menu item. | |
menu | The submenu associated with the new menu item. | |
copy | Not used. |
IlUShort IlvAbstractMenu::insertItem | ( | IlvMenuItem * | item, | |
IlShort | pos = -1 | |||
) |
Inserts a menu item at the specified position.
Inserts the menu item item at the position specified by pos.
item | The menu item to insert. | |
pos | The position where the menu item should be inserted. If pos equals -1 , the menu item is added at the last position. |
virtual IlBoolean IlvAbstractMenu::isSelectable | ( | const IlvMenuItem * | item | ) | const [virtual] |
Indicates whether the specified item can be selected.
item | The menu item. |
IlTrue
if item can be selected and IlFalse
otherwise. Reimplemented in IlvToolBar.
virtual IlBoolean IlvAbstractMenu::isShowingLabel | ( | ) | const [virtual] |
Returns IlTrue
if the labels associated with the menu items are displayed.
IlTrue
if the labels associated with the menu items are displayed. Reimplemented from IlvGadgetItemHolder.
virtual IlBoolean IlvAbstractMenu::isShowingPicture | ( | ) | const [virtual] |
Returns IlTrue
if the pictures associated with the menu items are displayed.
IlTrue
if the pictures associated with the menu items are displayed. Reimplemented from IlvGadgetItemHolder.
virtual void IlvAbstractMenu::itemActivated | ( | IlvGadgetItem * | item | ) | [protected, virtual] |
Is called when an item is activated.
The default implementation calls the Activate callback.
item | The activated gadget item. |
Reimplemented from IlvGadgetItemHolder.
virtual void IlvAbstractMenu::itemBBox | ( | IlUShort | index, | |
IlvRect & | bbox, | |||
const IlvTransformer * | t = 0 | |||
) | const [pure virtual] |
Returns the bounding box of a menu item in the menu.
Uses bbox to return the bounding box of the item specified by index when the object is displayed with the transformer t.
index | The index of the item. | |
bbox | The returned menu item's bounding box. | |
t | The transformer used to compute the item's bounding box. |
Implemented in IlvAbstractBar, and IlvPopupMenu.
virtual IlShort IlvAbstractMenu::pointToPosition | ( | const IlvPoint & | point, | |
const IlvTransformer * | t = 0 | |||
) | const [virtual] |
Returns the index of the menu item located at the position indicated by point.
Returns the index of the menu item located at the position indicated by point when the object is displayed with the transformer t.
point | The point used to located the item. | |
t | The transformer used to compute the item bounding box. |
virtual void IlvAbstractMenu::recomputeAllItems | ( | ) | [virtual] |
Recomputes the size of all the items managed by the holder.
Calls the IlvGadgetItem::recomputeSize
member function for all the items managed by this holder.
IlvGadgetItem::recomputeSize
, applyToItems
. Reimplemented from IlvGadgetItemHolder.
Reimplemented in IlvPopupMenu.
virtual void IlvAbstractMenu::select | ( | IlUShort | pos | ) | [virtual] |
Is called when an item has been selected.
pos | The index of the selected item. |
Reimplemented in IlvAbstractBar, and IlvPopupMenu.
virtual IlShort IlvAbstractMenu::selectNext | ( | ) | [virtual] |
Is called when the user tries to select the next menu item using the keyboard.
virtual IlShort IlvAbstractMenu::selectPrevious | ( | ) | [virtual] |
Is called when the user tries to select the previous menu item using the keyboard.
void IlvAbstractMenu::setHighlightCallback | ( | const IlSymbol * | callbackName, | |
IlBoolean | submenus = IlTrue | |||
) |
Sets a named "Highlight" callback to the menu.
Removes all the highlight callbacks and associates the highlight callback specified by callbackName to the menu. If submenus is set to IlTrue
, the same callback name is added to the submenus. When the callback is invoked, its IlAny
parameter can be cast in a pointer to an IlShort
. This IlShort
indicates the position of the currently highlighted menu item or is set to -1
if no menu item is highlighted. See the example in the setHighlightCallback
method above. A "Highlight" callback is invoked when an item of the menu is highlighted.
callbackName | The name of the callback. | |
submenus | A Boolean value specifying whether the callback should be propagated to the submenus. |
void IlvAbstractMenu::setHighlightCallback | ( | IlvGraphicCallback | callback, | |
IlBoolean | submenus = IlTrue | |||
) |
Sets a "Highlight" callback to the menu.
Removes all the highlight callbacks and associates the highlight callback specified by callback to the menu. If submenus is set to IlTrue
, the same callback is added to the submenus. When the callback is invoked, its IlAny
parameter can be cast in a pointer to an IlShort
. This IlShort
indicates the position of the currently highlighted menu item or is set to -1
if no menu item is highlighted. For example:
void myHighlightCB(IlvGraphic* mygraphic, IlAny itemptr) { IlShort hilited_item = *(IlShort*) itemptr; IlvAbstractMenu* mymenu= (IlvAbstractMenu*) mygraphic; if (hilited_item != -1) { IlvMenuItem* current_item = mymenu->getItem((IlUShort)hilited_item); ... } }
A "Highlight" callback is invoked when a menu item is highlighted.
callback | A pointer to the callback. | |
submenus | A Boolean value specifying whether the callback should be propagated to the submenus. |
virtual void IlvAbstractMenu::setItems | ( | IlvGadgetItem *const * | items, | |
IlUShort | count | |||
) | [virtual] |
Replaces the entire list of items.
Sets the items of the holder to items, which must be an array of count IlvGadgetItem
objects. Items are not copied, but the deletion of the array items is the responsibility of the caller.
items | The new items. | |
count | The number of items in items. |
Reimplemented from IlvListGadgetItemHolder.
void IlvAbstractMenu::setItems | ( | IlvMenuItem *const * | items, | |
IlUShort | count | |||
) |
Replaces the entire list of items in the menu.
Sets the items of the menu to items, which must be an array of count IlvGadgetItem
objects. Items are not copied, but the deletion of the array items is the responsibility of the caller.
items | The new items. | |
count | The number of items in items. |
void IlvAbstractMenu::setLabelOrientation | ( | IlvOrientation | orientation, | |
IlBoolean | flip = IlFalse , |
|||
IlBoolean | redraw = IlTrue | |||
) |
Sets the default orientation of the labels associated with the menu items.
When orientation is set to IlvHorizontal
, labels are drawn from left to right. When orientation is set to IlvVertical
, labels are drawn from top to bottom if flip is IlFalse
, or from bottom to top if flip is IlFalse
.
orientation | The new orientation of the labels. | |
flip | A Boolean value specifying whether the labels are flipped or not. |
void IlvAbstractMenu::setLabelPosition | ( | IlvPosition | position, | |
IlBoolean | redraw = IlTrue | |||
) |
Sets the default position of the menu item labels, relative to their picture.
Sets the default position of the menu item labels to pos. This setting is used to compute the geometry of each menu item. For more information, see the member function IlvGadgetItem::setLabelPosition
.
position | The new position of the items label, relative to their picture. | |
redraw | A Boolean value specifying whether the menu should be redrawn. |
Specifies whether the menu item labels should be shown or hidden.
Shows the labels associated with the menu items if value is set to IlTrue
.
value | A Boolean value specifying whether the menu item labels should be shown or hidden. | |
redraw | A Boolean value specifying whether the menu should be redrawn. |
Specifies whether the menu item pictures should be shown or hidden.
Shows the pictures associated with the menu items if value is set to IlTrue
.
value | A Boolean value specifying whether the menu item pictures should be shown or hidden. | |
redraw | A Boolean value specifying whether the menu should be redrawn. |
virtual void IlvAbstractMenu::unSelect | ( | IlUShort | pos | ) | [virtual] |
Is called when an item has been deselected.
pos | The index of the unselected item. |
Reimplemented in IlvAbstractBar, and IlvPopupMenu.
IlShort IlvAbstractMenu::whichSelected | ( | ) | const |
Returns the index of the selected item.
-1
if no item is selected. © Copyright 2012, Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.