A combobox is like a combination of an edit control and a listbox. It can be displayed as static list with editable or read-only text field; or a drop-down list with text field; or a drop-down list without a text field.
A combobox permits a single selection only.
Combobox elements are numbered from zero.
The callback function specified for the combobox item will be called for the following events:
Note: this is an experimental panel item, and is implemented for Windows and Motif only. There are some problems with the Motif implementation, which uses a contributed widget.
wxComboBox::wxComboBox
wxComboBox::~wxComboBox
wxComboBox::Append
wxComboBox::Clear
wxComboBox::Create
wxComboBox::Copy
wxComboBox::Cut
wxComboBox::Delete
wxComboBox::Deselect
wxComboBox::FindString
wxComboBox::GetClientData
wxComboBox::GetInsertionPoint
wxComboBox::GetLastPosition
wxComboBox::GetSelection
wxComboBox::GetString
wxComboBox::GetStringSelection
wxComboBox::GetValue
wxComboBox::Number
wxComboBox::Paste
wxComboBox::Remove
wxComboBox::SetClientData
wxComboBox::Replace
wxComboBox::SetInsertionPoint
wxComboBox::SetInsertionPointEnd
wxComboBox::SetSelection
wxComboBox::SetValue
void wxComboBox(void)
Constructor, for deriving classes.
void wxComboBox(wxPanel *parent, wxFunction func, char *label, char *value = "", int x = -1, int y = -1, int width = -1, int height = -1, int n, char *choices[], long style = 0, char *name = "comboBox")
Constructor, creating and showing a combobox.
func may be NULL; otherwise it is used as the callback for the combobox. 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 will be used as the combobox label.
value is the value to place in the edit field.
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 combobox.
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.
style is a bit list of some of the following.
wxCB_SIMPLE | Creates a combobox with a permanently displayed list. |
wxCB_DROPDOWN | Creates a combobox with a drop-down list. |
wxCB_READONLY | Creates a combo box consisting of a drop-down list and static text item displaying the current selection. |
wxCB_SORT | Sorts the entries in the list alphabetically (Windows only). |
The name parameter is used to associate a name with the item, allowing the application user to set Motif resource values for individual comboboxes.
void ~wxComboBox(void)
Destructor, destroying the combobox.
void Append(char * item)
Adds the item to the end of the combobox. item must be deallocated by the calling program, i.e. wxWindows makes its own copy.
void Append(char * item, char *client_data)
Adds the item to the end of the combobox, associating the given data with the item. item must be deallocated by the calling program.
void Clear(void)
Clears all strings from the combobox.
Bool Create(wxPanel *parent, wxFunction func, char *label,
char *value = "", int x = -1, int y = -1,
int width = -1, int height = -1, int n, char *choices[],
long style = 0, char *name = "comboBox")
Creates the combobox for two-step construction. Derived classes should call or replace this function. See wxComboBox::wxComboBox for further details.
void Copy(void)
Copies the selected text to the clipboard under Motif and MS Windows.
void Cut(void)
Copies the selected text to the clipboard and removes the selection. Windows and Motif only.
void Delete(int n)
Delete the nth element in the combobox.
void Deselect(int n)
Deselects the given item in the combobox.
int FindString(int char *s)
Finds a choice matching the given string, returning the position if found, or -1 if not found.
char * GetClientData(int n)
Returns a pointer to the client data associated with the given item (if any).
long GetInsertionPoint(void)
Returns the insertion point. Windows and Motif only.
long GetLastPosition(void)
Returns the last position in the text field. Windows 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 - for single selection comboboxes only. This must be copied by the calling program if long term use is to be made of it.
char * GetValue(void)
Gets a pointer to the current value. Copy this for long-term use.
int Number(void)
Returns the number of items in the combobox list.
void Paste(void)
Pastes text from the clipboard to the text item. Windows and Motif only.
void Remove(long from, long to)
Removes the text between the two positions. Windows and Motif only.
void SetClientData(int n, char *data)
Associates the given client data pointer with the given item.
void Replace(long from, long to, char *value)
Replaces the text between two positions with the given text. Windows and Motif only.
void SetInsertionPoint(long pos)
Sets the insertion point. Windows only.
void SetInsertionPointEnd(void)
Sets the insertion point at the end of the text item. Windows and Motif only.
void SetSelection(int n, Bool select = TRUE)
Selects or deselects the given item.
void SetSelection(long from, long to)
Selects the text between the two positions. Windows and Motif only.
void SetValue(char * value)
Sets the text for the editable field. value must be deallocated by the calling program.