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

Gadget class. More...

#include <ilviews/gadgets/combo.h>

Inheritance diagram for IlvComboBox:
IlvTextField IlvListGadgetItemHolder IlvGadget IlvGadgetItemHolder IlvSimpleGraphic IlvGraphic IlvStylable IlvValueInterface IlvScrolledComboBox

Classes

class  PopupMenu
 A subclass of IlvPopupMenu defined specifically for the IlvComboBox. More...
 
class  PopupMenuFactory
 

Public Member Functions

 IlvComboBox (IlvDisplay *display, const IlvPoint &point, const char *label, const char *const *labels=0, IlUShort count=0, IlUShort thickness=IlvDefaultGadgetThickness, IlvPalette *palette=0)
 Initializes a new IlvComboBox instance. More...
 
 IlvComboBox (IlvDisplay *display, const IlvRect &rect, const char *label, const char *const *labels=0, IlUShort count=0, IlUShort thickness=IlvDefaultGadgetThickness, IlvPalette *palette=0)
 Initializes a new IlvComboBox instance. More...
 
virtual IlvGadgetItemcreateItem (const char *, IlvGraphic *=0, IlvBitmap *=0, IlvBitmap *=0, IlBoolean=IlTrue) const
 Returns a new gadget item. More...
 
virtual void empty ()
 Empties the list. 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...
 
const char * getSelection () const
 Returns the string displayed in the combo box. More...
 
IlvPopupMenugetSubMenu () const
 Returns a pointer to the pop-up menu attached to the combo box. More...
 
virtual IlBoolean isListVisible () const
 Indicates whether the list of items of the combo box is visible. More...
 
void itemsBBox (IlvRect &labelRect, IlvRect &arrowRect, const IlvTransformer *t=0) const
 The bounding boxes of the main two components of the combo box. More...
 
virtual void labelChanged ()
 Is called by the interactor whenever the label of the text field changes. More...
 
virtual void setItems (IlvGadgetItem *const *, IlUShort)
 Replaces the entire list of items. More...
 
virtual void setLabel (const char *, IlBoolean=IlFalse)
 Sets the label of the text field. More...
 
void setSelected (IlUShort i, IlBoolean redraw=IlTrue)
 Sets the selected item in the combo box. More...
 
IlShort whichSelected () const
 Returns the index of the selected item. More...
 
- Public Member Functions inherited from IlvTextField
 IlvTextField (IlvDisplay *display, const char *label, const IlvRect &rect, IlUShort thickness=IlvDefaultGadgetThickness, IlvPalette *palette=0)
 Constructor. More...
 
 IlvTextField (IlvDisplay *display, const IlvPoint &point, const char *label, IlUShort thickness=IlvDefaultGadgetThickness, IlvPalette *palette=0)
 Constructor. More...
 
void addChangeCallback (IlSymbol *callbackName)
 Adds a named Label Changed callback. More...
 
void addChangeCallback (IlSymbol *callbackName, IlAny arg)
 Adds a named Label Changed callback. More...
 
void addChangeCallback (IlvGraphicCallback callback)
 Adds a Label Changed callback. More...
 
void addChangeCallback (IlvGraphicCallback callback, IlAny arg)
 Adds a Label Changed callback. More...
 
virtual const char * check (IlUShort character)
 Is called by the interactor for each key down event that corresponds to a regular character. More...
 
void ensureVisible (IlShort position, const IlvTransformer *t=0)
 Ensures that the character located at the specified position is visible. More...
 
IlvPosition getAlignment () const
 Returns the alignment of the text field. More...
 
IlvGraphicCallback getChangeCallback () const
 Returns a pointer to the first unnamed callback in the Label Changed callback list. More...
 
IlSymbolgetChangeCallbackName () const
 Returns the name of the first named callback in the Label Changed callback list. More...
 
IlBoolean getChangeFocusOnValidation () const
 Indicates whether the text field moves the keyboard focus to the next gadget once validated. More...
 
IlShort getCursorPosition () const
 Returns the cursor position. More...
 
IlShort getEndSelection () const
 Returns the index of the last selected character. More...
 
IlFloat getFloatValue () const
 Converts the text field contents to a floating point value and returns the result of the conversion. More...
 
IlInt getIntValue () const
 Converts the text field contents to an integer and returns the result of the conversion. More...
 
const char * getLabel () const
 Returns the label displayed by the text field. More...
 
IlShort getMaxChar () const
 Returns the maximum number of characters that the user can type in the text field. More...
 
virtual const char * getMessage () const
 Returns the message displayed by this text field. More...
 
IlShort getStartSelection () const
 Returns the index of the first selected character. More...
 
IlShort getTextPosition () const
 Returns the index of the first visible character of the text field. More...
 
virtual IlBoolean handleControl (IlUShort character)
 Is called by the interactor to handle control keys. More...
 
IlBoolean isCursorShown () const
 Indicates whether the cursor is visible. More...
 
IlBoolean isEditable () const
 Indicates whether the text field can be edited. More...
 
IlShort pointToPosition (const IlvPoint &point, const IlvTransformer *t=0) const
 Returns the index of the character located at the specified point. More...
 
virtual void removeSelection ()
 Removes the selected label from the text field. More...
 
void setAlignment (IlvPosition alignment)
 Sets the alignment of the text field. More...
 
void setChangeCallback (IlSymbol *callbackName)
 Sets a named Label Changed callback. More...
 
void setChangeCallback (IlSymbol *callbackName, IlAny arg)
 Sets a named Label Changed callback. More...
 
void setChangeCallback (IlvGraphicCallback callback)
 Sets a Label Changed callback. More...
 
void setChangeCallback (IlvGraphicCallback callback, IlAny arg)
 Sets a Label Changed callback. More...
 
void setChangeFocusOnValidation (IlBoolean value)
 Specifies whether the text field should move the keyboard focus to the next gadget once validated. More...
 
void setCursorPosition (IlShort position)
 Sets the cursor position. More...
 
void setEditable (IlBoolean value)
 Specifies whether the text field can be edited. More...
 
void setEndSelection (IlShort position)
 Sets the index of the last selected character. More...
 
void setMaxChar (IlShort count)
 Sets the maximum number of characters that the user can type in the text field. More...
 
void setSelection (IlShort start, IlShort end)
 Selects a portion of the text field content. More...
 
void setStartSelection (IlShort position)
 Sets the index of the first selected character. More...
 
void setTextPosition (IlShort position)
 Sets the index of the first visible character of the text field. More...
 
void setValue (IlFloat value, const char *format=0, IlBoolean redraw=IlFalse)
 Sets the text field label to a floating-point value. More...
 
void setValue (IlInt value, IlBoolean redraw=IlFalse)
 Sets the text field label to an integer value. More...
 
void showCursor (IlBoolean value, IlBoolean redraw=IlFalse)
 Specifies whether the cursor should be visible. More...
 
virtual void validate ()
 Is called by the interactor when the user presses the Return or the Enter key. 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...
 
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...
 
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 recomputeAllItems ()
 Recomputes the size of all the items managed by the holder. 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...
 

Static Public Member Functions

static PopupMenuFactoryGetPopupMenuFactory ()
 Returns the current popup menu factory. More...
 
static IlSymbolOpenListSymbol ()
 Returns the symbol of the Open List callback. More...
 
static PopupMenuFactorySetPopupMenuFactory (PopupMenuFactory *f)
 Sets the popup menu factory. More...
 
- 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...
 

Friends

class IlvComboBoxWLFHandler
 
class IlvDefaultComboBoxLFHandler
 

Additional Inherited Members

- 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: ilvgadgt

The IlvComboBox class combines a text field (IlvTextField class) with a pop-up menu displaying a set of predefined entries from which the user can choose.

- A Combo Box -

The user can enter a character string in the text field, or click on the arrow appearing on the right side of the field and select one of the choices from the menu that is displayed. The method getSubMenu() gives access the pop-up menu attached to the combo box to modify its behavior.

The IlvCombBox defines its own subclass of IlvPopupMenu. It also provides a factory mechanism allowing to redefine the way to create and populate the popup menu with menu items.

See also
IlvScrolledComboBox, IlvOptionMenu.

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 IlvTextField 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

◆ IlvComboBox() [1/2]

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

Initializes a new IlvComboBox instance.

The size of the combo box is computed from the label parameter. If you want to specify the size, use the other constructor.

Parameters
displayThe connection to the display.
pointThe position of the combo box.
labelThe label of the combo box.
labelsAn array containing the predefined labels of the combo box.
countThe number of elements in the labels array.
thicknessThe thickness of the combo box.
paletteThe palette used by the combo box.
See also
IlvComboBox::PopupMenu, IlvComboBox::PopupMenuFactory

◆ IlvComboBox() [2/2]

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

Initializes a new IlvComboBox instance.

Parameters
displayThe connection to the display.
rectThe size and position of the combo box.
labelThe label of the combo box.
labelsAn array containing the predefined labels of the combo box.
countThe number of elements in the labels array.
thicknessThe thickness of the combo box.
paletteThe palette used by the combo box.
See also
IlvComboBox::PopupMenu, IlvComboBox::PopupMenuFactory

Member Function Documentation

◆ createItem()

virtual IlvGadgetItem* IlvComboBox::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.

◆ empty()

virtual void IlvComboBox::empty ( )
virtual

Empties the list.

See also
setItems(), removeItem().

Implements IlvListGadgetItemHolder.

◆ getNormalTextPalette()

virtual const IlvPalette* IlvComboBox::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* IlvComboBox::getOpaquePalette ( ) const
virtual

Returns the opaque palette used to draw opaque items.

Returns
The opaque palette used to draw opaque items.

Reimplemented from IlvGadgetItemHolder.

◆ GetPopupMenuFactory()

static PopupMenuFactory* IlvComboBox::GetPopupMenuFactory ( )
static

Returns the current popup menu factory.

By default, no factory is set.

Returns
The popup menu factory currently set, or 0 if there is none.

◆ getSelection()

const char* IlvComboBox::getSelection ( ) const
virtual

Returns the string displayed in the combo box.

Returns
The string displayed in the combo box.

Reimplemented from IlvListGadgetItemHolder.

◆ getSubMenu()

IlvPopupMenu* IlvComboBox::getSubMenu ( ) const

Returns a pointer to the pop-up menu attached to the combo box.

Returns
A pointer to the pop-up menu attached to the combo box.
Note
The IlvScrolledComboBox subclass has no associated submenu. Therefore, the IlvComboBox::getSubMenu() member function always returns 0. To get the IlvStringList of an IlvScrolledComboBox object, use IlvScrolledComboBox::getStringList() instead.
See also
IlvScrolledComboBox::getStringList().

◆ isListVisible()

virtual IlBoolean IlvComboBox::isListVisible ( ) const
virtual

Indicates whether the list of items of the combo box is visible.

Returns
IlTrue if the list of items of the combo box is visible and IlFalse if it is not.
See also
showList, hideList

Reimplemented in IlvScrolledComboBox.

◆ itemsBBox()

void IlvComboBox::itemsBBox ( IlvRect labelRect,
IlvRect arrowRect,
const IlvTransformer t = 0 
) const

The bounding boxes of the main two components of the combo box.

Parameters
labelRectThe bounding box of the text field.
arrowRectThe bounding box of the arrow.
tThe transformer applied to the combo box.

◆ labelChanged()

virtual void IlvComboBox::labelChanged ( )
virtual

Is called by the interactor whenever the label of the text field changes.

The default implementation calls the Label Changed callback.

See also
setChangeCallback().

Reimplemented from IlvTextField.

◆ OpenListSymbol()

static IlSymbol* IlvComboBox::OpenListSymbol ( )
static

Returns the symbol of the Open List callback.

The Open List callback is invoked when the user opens the combo box list.

Returns
The symbol of the Open List callback.
See also
IlvGraphic::setCallback

◆ setItems()

virtual void IlvComboBox::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
itemsThe new items.
countThe number of items in items.
See also
getItems(), insertItem(), removeItem().

Reimplemented from IlvListGadgetItemHolder.

◆ setLabel()

virtual void IlvComboBox::setLabel ( const char *  label,
IlBoolean  redraw = IlFalse 
)
virtual

Sets the label of the text field.

Parameters
labelThe new label of the text field. The old label is deleted and the new one is copied.
redrawSpecifies whether the text field should be redrawn.
See also
getLabel(), getIntValue(), getFloatValue().

Reimplemented from IlvTextField.

◆ SetPopupMenuFactory()

static PopupMenuFactory* IlvComboBox::SetPopupMenuFactory ( PopupMenuFactory f)
static

Sets the popup menu factory.

Parameters
fThe factory to set.
Returns
The factory that was previously set, or 0 if there was none.

◆ setSelected()

void IlvComboBox::setSelected ( IlUShort  i,
IlBoolean  redraw = IlTrue 
)

Sets the selected item in the combo box.

Parameters
iThe index of the selected item.
redrawA Boolean value specifying whether the combo box should be redrawn.
See also
whichSelected, getSelection

◆ whichSelected()

IlShort IlvComboBox::whichSelected ( ) const

Returns the index of the selected item.

Returns
The index of the item in the combo box list that matches the combo box selection. If no match is found, it returns -1.
See also
setSelected