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 MS Windows, 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.
See also wxListBox.
wxChoice::wxChoice
wxChoice::~wxChoice
wxChoice::Append
wxChoice::Clear
wxChoice::Create
wxChoice::FindString
wxChoice::GetColumns
wxChoice::GetSelection
wxChoice::GetString
wxChoice::GetStringSelection
wxChoice::Number
wxChoice::SetColumns
wxChoice::SetSelection
wxChoice::SetStringSelection
wxChoice::GetString
void wxChoice(void)
Constructor, for use by derived classes.
void wxChoice(wxPanel *parent, wxFunction func,
char *label,
int x = -1, int y = -1, int width = -1,
int height = -1,
int n, char *choices[],
long style = 0, char *name = "choice")
Constructor, creating and showing a 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.
If label is non-NULL, it is used as the label for the choice item.
The parameters x and y are used to specify an absolute position, or a position after the previous panel item if omitted or default.
If width or height are omitted (or are less than zero), an appropriate size will be used for the choice.
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.
The style parameter is a bitlist of the following:
wxFIXED_LENGTH | Allows the values of a column of items to be left-aligned. Create an item with this style, and pad out your labels with spaces to the same length. The item labels will initially created with a string of identical characters, positioning all the values at the same x-position. Then the real label is restored. |
The name parameter is used to associate a name with the item, allowing the application user to set Motif resource values for individual choice items.
void ~wxChoice(void)
Destructor, destroying the choice item.
void Append(char * 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.
void Clear(void)
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.
Bool Create(wxPanel *parent, wxFunction func,
char *label,
int x = -1, int y = -1, int width = -1,
int height = -1, int n, char *choices[]
long style = 0, char *name = "choice")
Creates the choice for two-step construction. Derived classes should call or replace this function. See wxChoice::wxChoice for further details.
int FindString(char *s)
Finds a choice matching the given string, returning the position if found, or -1 if not found.
int GetColumns(void)
Gets the number of columns in this choice item.
This is implemented for XView and Motif only.
int GetSelection(void)
Gets the id (position) of the selected string.
char * GetString(int n)
Returns a temporary pointer to the string at position n.
char * GetStringSelection(void)
Gets the selected string. This must be copied by the calling program if long term use is to be made of it.
int Number(void)
Returns the number of strings in the choice item.
void SetColumns(int n = 1)
Sets the number of columns in this choice item.
This is implemented for XView and Motif only.
void SetSelection(int n)
Sets the choice by passing the desired string position.
void SetStringSelection(char * s)
Sets the choice by passing the desired string.
char * GetString(int n)
Returns a temporary pointer to the string at position n.