COptionMenu
#include <vstcontrols.h>
class COptionMenu : public CParamDisplay;
Define a rectangle view where a text-value can be displayed with a given font
and color. The text-value is centered in the given rect. A pixmap can be used
as background, a second pixmap can be used when the option menu is popuped.
There are 2 styles with or without a shadowed text. When a mouse click occurs,
a popup menu is displayed.
Creates an option popup-menu.
size |
|
The coordinates of the enclosing rectangle, relative to the parent frame. |
listener |
|
The object responsible for handling events in this control. |
tag |
|
The index of the control. |
background |
|
A background pixmap. |
bgWhenClick |
|
A background pixmap displayed when a mouse click occurs. |
style |
|
A constant from CControlEnum . |
Example :
CRect size (
kMyMenu_left,
kMyMenu_top,
kMyMenu_right,
kMyMenu_bottom
);
myBackground = new CBitmap (kMyBackgroundID);
myBackgroundOnClick = new CBitmap (
kMyBackgroundOnClickID
);
myMenu = new COptionMenu (
size,
this,
kMyParameter,
myBackground,
myBackgroundOnClick,
0
);
myMenu->addEntry ("first item", -1);
...
myMenu->addEntry ("last item", -1);
myMenu->setFontColor (kBlackCColor);
myMenu->setBackColor (kWhiteCColor);
frame->addView (myMenu);
~COptionMenu ();
Destroys an option menu object.
virtual void setValue (float val);
Used to set the actual value for the menu.
bool addEntry (char *txt, int index = -1);
Inserts <txt>
at position <index>
in the
menu.
txt |
The text to appear in the menu. A value of "-" inserts a separator line. |
index |
-1 : |
Appends the text to the end of the menu. |
0...127 : |
Inserts the text at this position. |
|
virtual bool addEntry (char *txt, long index);
Adds an entry to the menu.
int getCurrent (char *txt = 0);
Returns the current selected item.
txt |
If an optional string is provided, it will be stuffed with the selected item's
text. |
return |
The index to the selected item, starting with 0. |
Example :
char itemText[10];
myMenu->getCurrent (itemText);
if (strcmp (itemText, kMyString) == 0)
...
or
int myItem = myMenu->getCurrent (NULL);
switch (myItem) {
case kMyItem :
...
break;
default :
break;
}
bool setCurrent (int index);
Sets the current selected item.
bool getEntry (int index, char *txt);
Returns the entry at a given index.
bool setEntry (int index, char *txt);
Sets a given text to the entry at a given index.
bool removeEntry (int index);
Removes an entry at a given index.
bool removeAllEntry ();
Removes all entries.
int getNbEntries ();
Returns the number of entries.
int getIndex (char *txt);
Returns the index of a specified name in the menu.
bool checkEntry (int index, bool state);
Checks the menu's item given by its index (Available when kMultipleCheckStyle
is used as style).
bool checkEntryAlone (int index);
Checks only the given item's index.
bool isCheckEntry (int index);
Returns true
if the menu's entry is checked.
Called when this control object needs to be drawed.
Called when there is a mouse-click inside this control object. The popup menu is
displayed.
context |
|
where |
The coordinates of the mouse, in pixel and relative to the parent frame. |
See also :
-
The
CControlListener
's valueChanged
method which is called when the value has changed.
void takeFocus ();
The menu has the focus.
void looseFocus ();
The menu doesn't have the focus anymore.
void setNbItemsPerColumn (long val);
Sets the number of items per column.
long getNbItemsPerColumn ();
Returns the number of items per column.
long getLastResult ();
Returns the last choice.
COptionMenu *getLastItemMenu (long &idxInMenu);
Sets the menu's scheme.
Returns the menu's scheme.
void setPrefixNumbers (long preCount);
For an enumerated menu, sets the number of digits for the entry's index.