wxChoice: wxItem

A choice item is used to select one of a list of strings. Unlike a listbox, only the selection is visible until the user pulls down the menu of choices. Under XView and Motif, all selections are visible when the menu is displayed. Under Windows 3, a scrolling list is displayed when the user wants to change the selection. Note that under XView, creating a choice item with a large number of strings takes a long time due to the inefficiency of Sun's implementation of the XView choice item.

wxChoice::wxChoice

voidwxChoicewxPanel *parent, wxFunction func, char *label,
int x = -1, int y = -1, int width = -1, int height = -1, int n, char *choices[]

Constructor, creating and showing a choice. If width or height are omitted (or are less than zero), an appropriate size will be used for the choice. func may be NULL; otherwise it is used as the callback for the choice. Note that the cast (wxFunction) must be used when passing your callback function name, or the compiler may complain that the function does not match the constructor declaration.

n is the number of possible choices, and choices is an array of strings of size n. wxWindows allocates its own memory for these strings so the calling program must deallocate the array itself.

wxChoice::wxChoice

voidwxChoice

Destructor, destroying the choice item.

wxChoice::Append

voidAppendchar * item

Adds the item to the end of the choice item. item must be deallocated by the calling program, i.e. wxWindows makes its own copy.

wxChoice::Clear

voidClear

Clears the strings from the choice item. Under XView, this is done by deleting and reconstructing the item, but it doesn't redisplay properly until the user refreshes the window.

wxChoice::FindString

intFindStringchar *s

Finds a choice matching the given string, returning the position if found, or -1 if not found.

wxChoice::GetSelection

intGetSelection

Gets the id (position) of the selected string.

wxChoice::GetStringSelection

char *GetStringSelection

Gets the selected string. This must be copied by the calling program if long term use is to be made of it.

wxChoice::SetSelection

voidSetSelectionint n

Sets the choice by passing the desired string position.

wxChoice::SetStringSelection

voidSetStringSelectionchar * s

Sets the choice by passing the desired string.

wxChoice::String

char *Stringint n

Returns a temporary pointer to the string at position n.