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.


COptionMenu

1.0

COptionMenu (CRect &size, CControlListener *listener, int tag, CBitmap *background = 0, CBitmap *bgWhenClick = 0, int style = 0);

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

1.0

~COptionMenu ();

Destroys an option menu object.


setValue

2.2

virtual void setValue (float val);

Used to set the actual value for the menu.


addEntry

1.0

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.

addEntry

2.2

virtual bool addEntry (char *txt, long index);

Adds an entry to the menu.


getCurrent

1.0

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;
}

setCurrent

1.0

bool setCurrent (int index);

Sets the current selected item.


getEntry

1.0

bool getEntry (int index, char *txt);

Returns the entry at a given index.


setEntry

2.1

bool setEntry (int index, char *txt);

Sets a given text to the entry at a given index.


removeEntry

1.0

bool removeEntry (int index);

Removes an entry at a given index.


removeAllEntry

1.0

bool removeAllEntry ();

Removes all entries.


getNbEntries

1.0

int getNbEntries ();

Returns the number of entries.


getIndex

2.1

int getIndex (char *txt);

Returns the index of a specified name in the menu.


checkEntry

2.1

bool checkEntry (int index, bool state);

Checks the menu's item given by its index (Available when kMultipleCheckStyle is used as style).


checkEntryAlone

2.1

bool checkEntryAlone (int index);

Checks only the given item's index.


isCheckEntry

2.1

bool isCheckEntry (int index);

Returns true if the menu's entry is checked.


draw

1.0

void draw (CDrawContext*);

Called when this control object needs to be drawed.


mouse

1.0

void mouse (CDrawContext *context, CPoint &where);

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 :


takeFocus

1.0

void takeFocus ();

The menu has the focus.


looseFocus

1.0

void looseFocus ();

The menu doesn't have the focus anymore.


setNbItemsPerColumn

2.1

void setNbItemsPerColumn (long val);

Sets the number of items per column.


getNbItemsPerColumn

2.1

long getNbItemsPerColumn ();

Returns the number of items per column.


getLastResult

2.2

long getLastResult ();

Returns the last choice.


getLastItemMenu

2.2

COptionMenu *getLastItemMenu (long &idxInMenu);


setScheme

2.2

void setScheme (COptionMenuScheme*s);

Sets the menu's scheme.


getScheme

2.2

COptionMenuScheme* getScheme ();

Returns the menu's scheme.


setPrefixNumbers

2.2

void setPrefixNumbers (long preCount);

For an enumerated menu, sets the number of digits for the entry's index.
Copyright ©2003 Steinberg Media Technologies GmbH. All Rights Reserved.