Version: 2.9.4
Public Member Functions
wxChoice Class Reference

#include </home/zeitlin/src/wx/github/interface/wx/choice.h>

Inheritance diagram for wxChoice:

Detailed Description

A choice item is used to select one of a list of strings.

Unlike a wxListBox, only the selection is visible until the user pulls down the menu of choices.

Styles

This class supports the following styles:

Events emitted by this class

The following event handler macros redirect the events to member function handlers 'func' with prototypes like:

void handlerFuncName(wxCommandEvent& event)

Event macros for events emitted by this class:

Library:  wxCore
Category:  Controls

Appearance:
wxMSW appearancewxGTK appearancewxMac appearance
wxMSW appearancewxGTK appearancewxMac appearance
参照:
wxListBox, wxComboBox, wxCommandEvent

Public Member Functions

 wxChoice ()
 Default constructor.
 wxChoice (wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, int n=0, const wxString choices[]=NULL, long style=0, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxChoiceNameStr)
 Constructor, creating and showing a choice.
 wxChoice (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, const wxArrayString &choices, long style=0, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxChoiceNameStr)
 Constructor, creating and showing a choice.
virtual ~wxChoice ()
 Destructor, destroying the choice item.
virtual int GetColumns () const
 Gets the number of columns in this choice item.
virtual int GetCurrentSelection () const
 Unlike wxControlWithItems::GetSelection() which only returns the accepted selection value, i.e.
virtual void SetColumns (int n=1)
 Sets the number of columns in this choice item.
virtual bool IsSorted () const
virtual unsigned int GetCount () const
 Returns the number of items in the control.
virtual int GetSelection () const
 Returns the index of the selected item or wxNOT_FOUND if no item is selected.
virtual void SetSelection (int n)
 Sets the selection to the given item n or removes the selection entirely if n == wxNOT_FOUND.
virtual int FindString (const wxString &s, bool bCase=false) const
 Finds an item whose label matches the given string.
virtual wxString GetString (unsigned int n) const
 Returns the label of the item with the given index.
virtual void SetString (unsigned int pos, const wxString &s)
 Sets the label for the given item.
bool Create (wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, int n=0, const wxString choices[]=NULL, long style=0, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxChoiceNameStr)
 Creates the choice for two-step construction.
bool Create (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, const wxArrayString &choices, long style=0, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxChoiceNameStr)
 Creates the choice for two-step construction.

List of all members.


Constructor & Destructor Documentation

wxChoice::wxChoice ( )

Default constructor.

参照:
Create(), wxValidator
wxChoice::wxChoice ( wxWindow parent,
wxWindowID  id,
const wxPoint pos = wxDefaultPosition,
const wxSize size = wxDefaultSize,
int  n = 0,
const wxString  choices[] = NULL,
long  style = 0,
const wxValidator validator = wxDefaultValidator,
const wxString name = wxChoiceNameStr 
)

Constructor, creating and showing a choice.

Parameters:
parentParent window. Must not be NULL.
idWindow identifier. The value wxID_ANY indicates a default value.
posWindow position. If wxDefaultPosition is specified then a default position is chosen.
sizeWindow size. If wxDefaultSize is specified then the choice is sized appropriately.
nNumber of strings with which to initialise the choice control.
choicesAn array of strings with which to initialise the choice control.
styleWindow style. See wxChoice.
validatorWindow validator.
nameWindow name.
参照:
Create(), wxValidator

wxPerl Note: Not supported by wxPerl.

wxChoice::wxChoice ( wxWindow parent,
wxWindowID  id,
const wxPoint pos,
const wxSize size,
const wxArrayString choices,
long  style = 0,
const wxValidator validator = wxDefaultValidator,
const wxString name = wxChoiceNameStr 
)

Constructor, creating and showing a choice.

Parameters:
parentParent window. Must not be NULL.
idWindow identifier. The value wxID_ANY indicates a default value.
posWindow position.
sizeWindow size. If wxDefaultSize is specified then the choice is sized appropriately.
choicesAn array of strings with which to initialise the choice control.
styleWindow style. See wxChoice.
validatorWindow validator.
nameWindow name.
参照:
Create(), wxValidator

wxPerl Note: Use an array reference for the choices parameter.

virtual wxChoice::~wxChoice ( ) [virtual]

Destructor, destroying the choice item.


Member Function Documentation

bool wxChoice::Create ( wxWindow parent,
wxWindowID  id,
const wxPoint pos = wxDefaultPosition,
const wxSize size = wxDefaultSize,
int  n = 0,
const wxString  choices[] = NULL,
long  style = 0,
const wxValidator validator = wxDefaultValidator,
const wxString name = wxChoiceNameStr 
)

Creates the choice for two-step construction.

See wxChoice().

bool wxChoice::Create ( wxWindow parent,
wxWindowID  id,
const wxPoint pos,
const wxSize size,
const wxArrayString choices,
long  style = 0,
const wxValidator validator = wxDefaultValidator,
const wxString name = wxChoiceNameStr 
)

Creates the choice for two-step construction.

See wxChoice().

virtual int wxChoice::FindString ( const wxString string,
bool  caseSensitive = false 
) const [virtual]

Finds an item whose label matches the given string.

Parameters:
stringString to find.
caseSensitiveWhether search is case sensitive (default is not).
Returns:
The zero-based position of the item, or wxNOT_FOUND if the string was not found.

Reimplemented from wxItemContainerImmutable.

virtual int wxChoice::GetColumns ( ) const [virtual]

Gets the number of columns in this choice item.

注意:
This is implemented for GTK and Motif only and always returns 1 for the other platforms.
virtual unsigned int wxChoice::GetCount ( ) const [virtual]

Returns the number of items in the control.

参照:
IsEmpty()

Implements wxItemContainerImmutable.

virtual int wxChoice::GetCurrentSelection ( ) const [virtual]

Unlike wxControlWithItems::GetSelection() which only returns the accepted selection value, i.e.

the selection in the control once the user closes the dropdown list, this function returns the current selection. That is, while the dropdown list is shown, it returns the currently selected item in it. When it is not shown, its result is the same as for the other function.

Since:
2.6.2. In older versions, wxControlWithItems::GetSelection() itself behaved like this.
virtual int wxChoice::GetSelection ( ) const [virtual]

Returns the index of the selected item or wxNOT_FOUND if no item is selected.

Returns:
The position of the current selection.
注意:
This method can be used with single selection list boxes only, you should use wxListBox::GetSelections() for the list boxes with wxLB_MULTIPLE style.
参照:
SetSelection(), GetStringSelection()

Implements wxItemContainerImmutable.

virtual wxString wxChoice::GetString ( unsigned int  n) const [virtual]

Returns the label of the item with the given index.

Parameters:
nThe zero-based index.
Returns:
The label of the item or an empty string if the position was invalid.

Implements wxItemContainerImmutable.

virtual bool wxChoice::IsSorted ( ) const [virtual]
virtual void wxChoice::SetColumns ( int  n = 1) [virtual]

Sets the number of columns in this choice item.

Parameters:
nNumber of columns.
注意:
This is implemented for GTK and Motif only and doesn’t do anything under other platforms.
virtual void wxChoice::SetSelection ( int  n) [virtual]

Sets the selection to the given item n or removes the selection entirely if n == wxNOT_FOUND.

Note that this does not cause any command events to be emitted nor does it deselect any other items in the controls which support multiple selections.

Parameters:
nThe string position to select, starting from zero.
参照:
SetString(), SetStringSelection()

Implements wxItemContainerImmutable.

virtual void wxChoice::SetString ( unsigned int  n,
const wxString string 
) [virtual]

Sets the label for the given item.

Parameters:
nThe zero-based item index.
stringThe label to set.

Implements wxItemContainerImmutable.

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines