rwlogo
Rogue Wave Views 5.5.1

Rogue Wave Views
Gadgets Package API Reference Guide

Product Documentation:

Rogue Wave Views
Documentation Home

IlvAbstractMenu Class Reference

Gadget class. More...

#include <ilviews/gadgets/amenu.h>

Inheritance diagram for IlvAbstractMenu:
IlvGadget IlvListGadgetItemHolder IlvSimpleGraphic IlvGadgetItemHolder IlvGraphic IlvAbstractBar IlvPopupMenu IlvMenuBar IlvToolBar IlvToolBarPath

List of all members.

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 IlvGadgetItemcreateItem (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.
IlvMenuItemgetItem (IlUShort pos) const
 Returns an item from its position in the holder.
virtual IlvGadgetItemgetItemByName (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 IlvPalettegetNormalTextPalette () const
 Returns the default palette used to draw an item.
virtual IlvPalettegetOpaquePalette () 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 IlSymbolHighlightCBSymbol ()
 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.

Detailed Description

Gadget class.

Library: ilvgadgt

This pure abstract class is used to facilitate the use of menu classes, such as IlvMenuBar, IlvToolBar, and IlvPopupMenu.

See also:
IlvMenuBar, IlvToolBar, IlvMenuItem, IlvOptionMenu, IlvPopupMenu

Constructor & Destructor Documentation

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.

Parameters:
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.

Parameters:
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.

Member Function Documentation

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.

Parameters:
callbackName The name of the callback.
submenus A Boolean value specifying whether the callback should be propagated to the submenus.
See also:
setHighlightCallback
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.

Parameters:
callback A pointer to the callback.
submenus A Boolean value specifying whether the callback should be propagated to the submenus.
See also:
setHighlightCallback
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.

Parameters:
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, then you must allocate some memory for the label because in any case the label characters are deleted from the memory by the IlvGadgetItem.
Warning:
[note] If both the second and third parameters are not null, only the second parameter is used.
Returns:
The created gadget item.

Reimplemented from IlvGadgetItemHolder.

void IlvAbstractMenu::deSelectAll (  )  [virtual]

Deselects all the items.

See also:
IlvGadgetItem::deSelect

Reimplemented from IlvListGadgetItemHolder.

virtual void IlvAbstractMenu::empty (  )  [virtual]

Empties the list.

See also:
setItems, removeItem

Implements IlvListGadgetItemHolder.

Reimplemented in IlvPopupMenu, and IlvToolBar.

IlvMenuItem* IlvAbstractMenu::getItem ( IlUShort  index  )  const

Returns an item from its position in the holder.

Parameters:
index The item position.
Returns:
The indexth item. Returns 0 if index is not valid.
See also:
getIndex

Reimplemented from IlvListGadgetItemHolder.

virtual IlvGadgetItem* IlvAbstractMenu::getItemByName ( const char *  name  )  const [virtual]

Returns the item whose name is specified.

Parameters:
name The name of the item.
Returns:
The item found or 0 if the specified item cannot be found.
See also:
IlvGadgetItem::setName, applyToItems.

Reimplemented from IlvGadgetItemHolder.

IlvMenuItem* const* IlvAbstractMenu::getItems ( IlUShort count  )  const

Returns an array of all the items in the menu.

Parameters:
count The number of items managed by this menu.
Returns:
an array of all the items in the menu.
Warning:
[note] The returned array should never be modified or deleted.
See also:
setItems, IlvListGadgetItemHolder::insertItem

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.

Returns:
The default orientation of the labels associated with the menu items.
Parameters:
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.
See also:
setLabelOrientation

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.

Returns:
The default position of the labels associated with the menu items, relative to their picture.
See also:
setLabelPosition

Reimplemented from IlvGadgetItemHolder.

virtual IlvPalette* IlvAbstractMenu::getNormalTextPalette (  )  const [virtual]

Returns the default palette used to draw an item.

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.

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.

Parameters:
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.
Returns:
The real position of the menu item after it has been inserted in the menu.
See also:
IlvGadgetItem::setMenu, IlvListGadgetItemHolder::insertLabel
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.

Parameters:
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.
Returns:
The real position of the menu item after it has been inserted in the menu.
See also:
IlvListGadgetItemHolder::insertItem
virtual IlBoolean IlvAbstractMenu::isSelectable ( const IlvMenuItem item  )  const [virtual]

Indicates whether the specified item can be selected.

Parameters:
item The menu item.
Returns:
IlTrue if item can be selected and IlFalse otherwise.
See also:
IlvGadgetItem::isSelectable

Reimplemented in IlvToolBar.

virtual IlBoolean IlvAbstractMenu::isShowingLabel (  )  const [virtual]

Returns IlTrue if the labels associated with the menu items are displayed.

Returns:
IlTrue if the labels associated with the menu items are displayed.
See also:
showLabel, isShowingPicture

Reimplemented from IlvGadgetItemHolder.

virtual IlBoolean IlvAbstractMenu::isShowingPicture (  )  const [virtual]

Returns IlTrue if the pictures associated with the menu items are displayed.

Returns:
IlTrue if the pictures associated with the menu items are displayed.
See also:
showPicture, isShowingLabel

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.

Parameters:
item The activated gadget item.
See also:
IlvGadgetItem::activate

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.

Parameters:
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.

Parameters:
point The point used to located the item.
t The transformer used to compute the item bounding box.
Returns:
The index of the item located at the position indicated by point. If there is no item a negative value is returned.
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.

See also:
IlvGadgetItem::recomputeSize, applyToItems.

Reimplemented from IlvGadgetItemHolder.

Reimplemented in IlvPopupMenu.

virtual void IlvAbstractMenu::select ( IlUShort  pos  )  [virtual]

Is called when an item has been selected.

Parameters:
pos The index of the selected item.
See also:
unSelect

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.

Returns:
The next selected item.
virtual IlShort IlvAbstractMenu::selectPrevious (  )  [virtual]

Is called when the user tries to select the previous menu item using the keyboard.

Returns:
The previous selected item.
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.

Parameters:
callbackName The name of the callback.
submenus A Boolean value specifying whether the callback should be propagated to the submenus.
See also:
addHighlightCallback
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.

Parameters:
callback A pointer to the callback.
submenus A Boolean value specifying whether the callback should be propagated to the submenus.
See also:
addHighlightCallback
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.

Parameters:
items The new items.
count The number of items in items.
See also:
getItems, insertItem, removeItem

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.

Parameters:
items The new items.
count The number of items in items.
See also:
getItems, insertItem, removeItem
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.

Parameters:
orientation The new orientation of the labels.
flip A Boolean value specifying whether the labels are flipped or not.
See also:
getLabelOrientation
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.

Parameters:
position The new position of the items label, relative to their picture.
redraw A Boolean value specifying whether the menu should be redrawn.
See also:
getLabelPosition
void IlvAbstractMenu::showLabel ( IlBoolean  value = IlTrue,
IlBoolean  redraw = IlTrue 
)

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.

Parameters:
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.
See also:
isShowingLabel, showPicture
void IlvAbstractMenu::showPicture ( IlBoolean  value = IlTrue,
IlBoolean  redraw = IlTrue 
)

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.

Parameters:
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.
See also:
isShowingPicture, showLabel
virtual void IlvAbstractMenu::unSelect ( IlUShort  pos  )  [virtual]

Is called when an item has been deselected.

Parameters:
pos The index of the unselected item.
See also:
select

Reimplemented in IlvAbstractBar, and IlvPopupMenu.

IlShort IlvAbstractMenu::whichSelected (  )  const

Returns the index of the selected item.

Returns:
The index of the selected item or -1 if no item is selected.
See also:
IlvGadgetItem::select

© 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.