Views
Gadgets Package API Reference Guide
Product Documentation:
Views Documentation Home
List of all members | Public Member Functions | Friends
IlvOptionMenu Class Reference

Gadget class. More...

#include <ilviews/gadgets/optmenu.h>

Inheritance diagram for IlvOptionMenu:
IlvGadget IlvListGadgetItemHolder IlvSimpleGraphic IlvGadgetItemHolder IlvGraphic IlvStylable IlvValueInterface

Public Member Functions

 IlvOptionMenu (IlvDisplay *display, const IlvPoint &point, const char *const *labels=0, IlUShort count=0, IlUShort thickness=IlvDefaultGadgetThickness, IlvPalette *palette=0)
 Constructor. More...
 
 IlvOptionMenu (IlvDisplay *display, const IlvRect &rect, const char *const *labels=0, IlUShort count=0, IlUShort thickness=IlvDefaultGadgetThickness, IlvPalette *palette=0)
 Constructor. More...
 
virtual IlvGadgetItemcreateItem (const char *label, IlvGraphic *g=0, IlvBitmap *bitmap=0, IlvBitmap *sbitmap=0, IlBoolean copy=IlTrue) const
 Returns a new gadget item. More...
 
virtual void doIt ()
 Is called when an item is selected in the option menu. More...
 
virtual void empty ()
 Empties the list. More...
 
const char * getLabel () const
 Returns the label displayed in the option menu. More...
 
virtual const IlvPalettegetNormalTextPalette () const
 Returns the default palette used to draw an item. More...
 
virtual const IlvPalettegetOpaquePalette () const
 Returns the opaque palette used to draw opaque items. More...
 
IlvPopupMenugetSubMenu () const
 Returns a pointer to the menu object used by the option menu. More...
 
virtual void recomputeAllItems ()
 Recomputes the size of all the items managed by the holder. More...
 
void setSelected (IlShort index, IlBoolean redraw=IlFalse)
 Sets the selected item of the option menu. More...
 
IlShort whichSelected () const
 Returns the index of the selected item. More...
 
- Public Member Functions inherited from IlvListGadgetItemHolder
virtual void addLabel (const char *label, IlAny data=0)
 Adds an item with a label to the holder list. More...
 
virtual IlvGadgetItemapplyToItems (IlvApplyGadgetItem, IlAny)
 Applies the specified function to all the items of the holder. More...
 
virtual int compareItems (const char *string1, const char *string2, IlAny value1, IlAny value2)
 Compares a pair of items. More...
 
virtual void deSelectAll ()
 Deselects all the items. More...
 
IlUShort getCardinal () const
 Returns the number of items stored in this holder. More...
 
IlShort getFirstSelectedItem () const
 Returns the index of the first selected item. More...
 
IlShort getIndex (const IlvGadgetItem *item, IlUShort start=0, IlUShort stop=(IlUShort) -1) const
 Returns the index of the specified item in the holder list. More...
 
IlvGadgetItemgetItem (IlUShort index) const
 Returns an item from its position in the holder. More...
 
IlAny getItemData (IlUShort index) const
 Returns an item user data. More...
 
IlvGadgetItem *const * getItems (IlUShort &count) const
 Returns the array of all the items. More...
 
const char * getLabel (IlUShort index) const
 Returns the indicated label of the list. More...
 
const char *const * getLabels (IlUShort &count) const
 Returns an array of all the items labels. More...
 
IlShort getPosition (const char *label, IlUShort start=0) const
 Returns the position of an item using its label. More...
 
virtual const char * getSelection () const
 Returns the first selected item label. More...
 
IlUShort const * getSelectionIndices (IlUShort &count) const
 Returns an array containing the indexes of the selected item. More...
 
const char *const * getSelections (IlUShort &count) const
 Returns an array of the selected items. More...
 
IlAny const * getUserDataArray (IlUShort &count) const
 Returns an array of all the user data for the items. More...
 
IlUShort insertBitmap (IlvBitmap *bitmap, IlShort pos=-1)
 Inserts an item with a bitmap at the given position in the holder list. More...
 
IlUShort insertGraphic (IlvGraphic *graphic, IlShort pos=-1)
 Inserts an item with a graphic as picture at a given position in the holder list. More...
 
IlUShort insertItem (IlvGadgetItem *item, IlShort index=-1)
 Inserts an item at a given position in the holder's list. More...
 
virtual void insertLabel (IlUShort pos, const char *label, IlAny data=0)
 Inserts an item with a label at a given position in the holder list. More...
 
IlBoolean isSelected (IlUShort index) const
 Specifies whether the item whose position is specified is selected. More...
 
void removeItem (IlUShort index, IlBoolean destroy=IlTrue)
 Removes an item from the holder. More...
 
void removeLabel (IlUShort index)
 Removes and destroys an item. More...
 
void setItemData (IlUShort index, IlAny itemData)
 Sets an item user data. More...
 
virtual void setItems (IlvGadgetItem *const *items, IlUShort count)
 Replaces the entire list of items. More...
 
void setLabel (IlUShort index, const char *label, IlBoolean copy)
 Modifies the label of an item. More...
 
virtual void setLabels (const char *const *labels, IlAny const *itemData, IlUShort count, IlBoolean copy=IlTrue)
 Replaces the entire list of items. More...
 
virtual void setLabels (const char *const *labels, IlUShort count, IlBoolean copy=IlTrue)
 Replaces the entire list of items. More...
 
virtual void sort (IlvListCompareFunction func=0)
 Sorts the items. More...
 
- Public Member Functions inherited from IlvGadgetItemHolder
virtual void drawGadgetItem (const IlvGadgetItem *item, IlvPort *port, const IlvRect &rect, const IlvTransformer *t=0, const IlvRegion *clip=0) const
 Draws a specific gadget item. More...
 
IlvGadgetItemgetCallbackItem () const
 Returns the item that triggered a callback. More...
 
IlvGadgetItemgetDragDropTarget () const
 Returns the target item of a drag-and-drop operation. More...
 
IlvGraphicgetDraggedImage () const
 Returns the graphic object used to draw the ghost image during a drag-and-drop operation. More...
 
IlvGadgetItemgetDraggedItem () const
 Returns the item that is being dragged during a drag-and-drop operation. More...
 
IlvGadgetItemgetEditedItem () const
 Returns the item that is being edited. More...
 
virtual const IlvPalettegetHighlightTextPalette () const
 Returns the highlight palette used to draw the label of highlighted items. More...
 
virtual IlvGadgetItemgetItemByName (const char *name) const
 Returns the item whose name is specified. More...
 
IlvGadgetItemgetToolTipItem () const
 Returns the item that is displaying a tooltip. More...
 
virtual void initReDrawItems ()
 Begins a redraw session. More...
 
virtual void reDrawItems ()
 Ends a redraw session. More...
 
void setDragDropTarget (IlvGadgetItem *item)
 Sets the target item of a drag-and-drop operation. More...
 
void setDraggedImage (IlvGraphic *graphic)
 Sets the graphic object used to draw the ghost image during a drag-and-drop operation. More...
 
void setDraggedItem (IlvGadgetItem *item)
 Sets the dragged item. More...
 

Friends

class IlvDefaultOptionMenuLFHandler
 
class IlvOptionMenuWLFHandler
 

Additional Inherited Members

- Static Public Member Functions inherited from IlvGadgetItemHolder
static IlSymbolAbortDragItemCallbackType ()
 Returns the callback type of the Abort Drag callback. More...
 
static IlSymbolAbortEditItemCallbackType ()
 Returns the callback type of the Abort Edit callback. More...
 
static IlSymbolActivateCallbackType ()
 Returns the callback type of the Activate callback. More...
 
static IlSymbolDragItemCallbackType ()
 Returns the callback type of the Drag Item callback. More...
 
static IlSymbolEndDragItemCallbackType ()
 Returns the callback type of the End Drag callback. More...
 
static IlSymbolEndEditItemCallbackType ()
 Returns the callback type of the End Edit callback. More...
 
static IlSymbolStartDragItemCallbackType ()
 Returns the callback type of the Start Drag callback. More...
 
static IlSymbolStartEditItemCallbackType ()
 Returns the callback type of the Start Edit callback. More...
 
- Protected Member Functions inherited from IlvGadgetItemHolder
virtual void abortDragItem ()
 Is called when a drag-and-drop operation is aborted. More...
 
virtual void abortEdit (IlvGadgetItem *item)
 Is called when the editing of the specified item is aborted. More...
 
virtual void drawDraggedImage (const IlvPoint &point, const IlvTransformer *t)
 Is called to draw the ghost image during a drag-and-drop operation. More...
 
virtual void endDragItem (const IlvPoint &point)
 Is called when a drag-and-drop operation is finished. More...
 
virtual void endEdit (IlvGadgetItem *item)
 Is called after an item has been edited. More...
 
virtual void itemActivated (IlvGadgetItem *item)
 Is called when an item is activated. More...
 
virtual void itemDeSelected (IlvGadgetItem *item)
 Is called when an item is deselected. More...
 
virtual void itemDragged (const IlvPoint &point)
 Is called each time the user moves the mouse during a drag-and-drop operation. More...
 
virtual void itemHighlighted (IlvGadgetItem *item)
 Is called when an item is highlighted or unhighlighted. More...
 
virtual void itemSelected (IlvGadgetItem *item)
 Is called when an item is selected. More...
 
virtual void startDragItem (IlvGadgetItem *item)
 Is called when a drag-and-drop operation begins. More...
 
virtual void startEdit (IlvGadgetItem *item)
 Is called when an item is edited. More...
 

Detailed Description

Gadget class.

Library: ilvadvgdt

The IlvOptionMenu class defines a drop-down list of items from which the user can choose.

- IlvOptionMenu -

See also
IlvMenuItem, IlvPopupMenu, IlvComboBox

Accessors\nAccessors provide a scriptable and uniform way to inspect and modify an object by using its base class methods <tt>IlvValueInterface::queryValue()</tt>, <tt>IlvValueInterface::queryValues()</tt>, <tt>IlvValueInterface::changeValue()</tt>, <tt>IlvValueInterface::changeValues()</tt>.\n\n\nThis class inherits the accessors of its superclass \c IlvGadget and adds the following ones:

Name Type Equivalent methods
count UInt getCardinal()
selected UInt whichSelected(), setSelected()
subMenu Object getSubMenu()

Styling\nThis class supports the following CSS properties:

Graphic property CSS property Type
Background color background-color Color
Text color color Color

Constructor & Destructor Documentation

◆ IlvOptionMenu() [1/2]

IlvOptionMenu::IlvOptionMenu ( IlvDisplay display,
const IlvPoint point,
const char *const *  labels = 0,
IlUShort  count = 0,
IlUShort  thickness = IlvDefaultGadgetThickness,
IlvPalette palette = 0 
)

Constructor.

Initializes a new instance of the class IlvOptionMenu. The size of the object is computed from the first label of the labels array. If you want to specify its size, use the other constructor. The labels are copied.

Parameters
displayThe connection to the display.
pointThe position of the option menu.
labelsAn array containing the predefined labels of the option menu.
countThe number of elements in the labels array.
thicknessThe thickness of the option menu.
paletteThe palette used by the option menu.

◆ IlvOptionMenu() [2/2]

IlvOptionMenu::IlvOptionMenu ( IlvDisplay display,
const IlvRect rect,
const char *const *  labels = 0,
IlUShort  count = 0,
IlUShort  thickness = IlvDefaultGadgetThickness,
IlvPalette palette = 0 
)

Constructor.

Initializes a new instance of the class IlvOptionMenu. The labels are copied.

Parameters
displayThe connection to the display.
rectThe size and position of the option menu.
labelsAn array containing the predefined labels of the option menu.
countThe number of elements in the labels array.
thicknessThe thickness of the option menu.
paletteThe palette used by the option menu.

Member Function Documentation

◆ createItem()

virtual IlvGadgetItem* IlvOptionMenu::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
labelThe item label.
graphicThe IlvGraphic object representing the picture associated with the item.
bitmapThe IlvBitmap object representing the picture associated with the item.
selbitmapThe IlvBitmap object representing the picture of the item when it is selected.
copySpecifies 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.
Note
If both the second and third parameters are not 0, only the second parameter is used.
Returns
The created gadget item.

Reimplemented from IlvGadgetItemHolder.

◆ doIt()

virtual void IlvOptionMenu::doIt ( )
virtual

Is called when an item is selected in the option menu.

Is called whether the selection changes or not. The default implementation calls the main callback of the option menu.

◆ empty()

virtual void IlvOptionMenu::empty ( )
virtual

Empties the list.

See also
setItems(), removeItem().

Implements IlvListGadgetItemHolder.

◆ getLabel()

const char* IlvOptionMenu::getLabel ( ) const

Returns the label displayed in the option menu.

Returns
The label displayed in the option menu. If the selected item has no label, it returns 0.
See also
setSelected

◆ getNormalTextPalette()

virtual const IlvPalette* IlvOptionMenu::getNormalTextPalette ( ) const
virtual

Returns the default palette used to draw an item.

Returns
The default palette used to draw an item.

Implements IlvGadgetItemHolder.

◆ getOpaquePalette()

virtual const IlvPalette* IlvOptionMenu::getOpaquePalette ( ) const
virtual

Returns the opaque palette used to draw opaque items.

Returns
The opaque palette used to draw opaque items.

Reimplemented from IlvGadgetItemHolder.

◆ getSubMenu()

IlvPopupMenu* IlvOptionMenu::getSubMenu ( ) const

Returns a pointer to the menu object used by the option menu.

Returns
A pointer to the menu object used by the option menu. The IlvPopupMenu class handles lists of items that can be selected.
See also
IlvPopupMenu

◆ recomputeAllItems()

virtual void IlvOptionMenu::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.

◆ setSelected()

void IlvOptionMenu::setSelected ( IlShort  index,
IlBoolean  redraw = IlFalse 
)

Sets the selected item of the option menu.

Parameters
indexThe index of the selected item.
redrawA Boolean value specifying whether the object should be redrawn.
See also
whichSelected, getLabel

◆ whichSelected()

IlShort IlvOptionMenu::whichSelected ( ) const

Returns the index of the selected item.

Returns
The index of the selected item. The first item has an index of 0. If no item is selected, it returns -1.
See also
setSelected, getLabel