2008-03-08 08:52:38 -05:00
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Name: choice.h
|
2008-03-10 11:24:38 -04:00
|
|
|
|
// Purpose: interface of wxChoice
|
2008-03-08 08:52:38 -05:00
|
|
|
|
// Author: wxWidgets team
|
|
|
|
|
// RCS-ID: $Id$
|
2010-07-13 09:29:13 -04:00
|
|
|
|
// Licence: wxWindows licence
|
2008-03-08 08:52:38 -05:00
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@class wxChoice
|
2008-03-08 09:43:31 -05:00
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
|
A choice item is used to select one of a list of strings. Unlike a
|
2008-04-05 05:12:23 -04:00
|
|
|
|
wxListBox, only the selection is visible until the user pulls down the
|
2008-03-08 08:52:38 -05:00
|
|
|
|
menu of choices.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
|
@beginStyleTable
|
2008-04-06 10:43:04 -04:00
|
|
|
|
@style{wxCB_SORT}
|
2008-03-08 08:52:38 -05:00
|
|
|
|
Sorts the entries alphabetically.
|
|
|
|
|
@endStyleTable
|
2008-03-08 09:43:31 -05:00
|
|
|
|
|
2009-02-18 12:58:51 -05:00
|
|
|
|
@beginEventEmissionTable{wxCommandEvent}
|
2008-04-06 10:43:04 -04:00
|
|
|
|
@event{EVT_CHOICE(id, func)}
|
2011-01-06 14:52:14 -05:00
|
|
|
|
Process a @c wxEVT_COMMAND_CHOICE_SELECTED event, when an item on the
|
2008-03-08 08:52:38 -05:00
|
|
|
|
list is selected.
|
|
|
|
|
@endEventTable
|
2008-03-08 09:43:31 -05:00
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
|
@library{wxcore}
|
|
|
|
|
@category{ctrl}
|
2008-10-13 04:05:18 -04:00
|
|
|
|
@appearance{choice.png}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
@see wxListBox, wxComboBox, wxCommandEvent
|
2008-03-08 08:52:38 -05:00
|
|
|
|
*/
|
|
|
|
|
class wxChoice : public wxControlWithItems
|
|
|
|
|
{
|
|
|
|
|
public:
|
2008-04-05 05:12:23 -04:00
|
|
|
|
/**
|
|
|
|
|
Default constructor.
|
|
|
|
|
|
|
|
|
|
@see Create(), wxValidator
|
|
|
|
|
*/
|
|
|
|
|
wxChoice();
|
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
|
/**
|
|
|
|
|
Constructor, creating and showing a choice.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
|
@param parent
|
2008-03-09 08:33:59 -04:00
|
|
|
|
Parent window. Must not be @NULL.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
@param id
|
2008-03-09 08:33:59 -04:00
|
|
|
|
Window identifier. The value wxID_ANY indicates a default value.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
@param pos
|
2008-03-09 08:33:59 -04:00
|
|
|
|
Window position.
|
2009-04-21 07:21:36 -04:00
|
|
|
|
If ::wxDefaultPosition is specified then a default position is chosen.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
@param size
|
2009-04-21 07:21:36 -04:00
|
|
|
|
Window size.
|
|
|
|
|
If ::wxDefaultSize is specified then the choice is sized appropriately.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
@param n
|
2008-03-09 08:33:59 -04:00
|
|
|
|
Number of strings with which to initialise the choice control.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
@param choices
|
2008-03-09 08:33:59 -04:00
|
|
|
|
An array of strings with which to initialise the choice control.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
@param style
|
2008-03-09 08:33:59 -04:00
|
|
|
|
Window style. See wxChoice.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
@param validator
|
2008-03-09 08:33:59 -04:00
|
|
|
|
Window validator.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
@param name
|
2008-03-09 08:33:59 -04:00
|
|
|
|
Window name.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
|
@see Create(), wxValidator
|
2008-04-05 05:12:23 -04:00
|
|
|
|
|
|
|
|
|
@beginWxPythonOnly
|
|
|
|
|
|
|
|
|
|
The wxChoice constructor in wxPython reduces the @a n and @a choices
|
|
|
|
|
arguments to a single argument, which is a list of strings.
|
|
|
|
|
|
|
|
|
|
@endWxPythonOnly
|
2009-10-18 13:47:01 -04:00
|
|
|
|
|
|
|
|
|
@beginWxPerlOnly
|
|
|
|
|
Not supported by wxPerl.
|
|
|
|
|
@endWxPerlOnly
|
2008-03-08 08:52:38 -05:00
|
|
|
|
*/
|
2009-01-10 18:44:44 -05:00
|
|
|
|
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 );
|
2008-08-30 08:44:43 -04:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Constructor, creating and showing a choice.
|
|
|
|
|
|
|
|
|
|
@param parent
|
|
|
|
|
Parent window. Must not be @NULL.
|
|
|
|
|
@param id
|
|
|
|
|
Window identifier. The value wxID_ANY indicates a default value.
|
|
|
|
|
@param pos
|
|
|
|
|
Window position.
|
|
|
|
|
@param size
|
|
|
|
|
Window size. If wxDefaultSize is specified then the choice is sized
|
|
|
|
|
appropriately.
|
|
|
|
|
@param choices
|
|
|
|
|
An array of strings with which to initialise the choice control.
|
|
|
|
|
@param style
|
|
|
|
|
Window style. See wxChoice.
|
|
|
|
|
@param validator
|
|
|
|
|
Window validator.
|
|
|
|
|
@param name
|
|
|
|
|
Window name.
|
|
|
|
|
|
|
|
|
|
@see Create(), wxValidator
|
|
|
|
|
|
|
|
|
|
@beginWxPythonOnly
|
|
|
|
|
|
|
|
|
|
The wxChoice constructor in wxPython reduces the @a n and @a choices
|
|
|
|
|
arguments to a single argument, which is a list of strings.
|
|
|
|
|
|
|
|
|
|
@endWxPythonOnly
|
2009-10-18 13:47:01 -04:00
|
|
|
|
|
|
|
|
|
@beginWxPerlOnly
|
|
|
|
|
Use an array reference for the @a choices parameter.
|
|
|
|
|
@endWxPerlOnly
|
2008-08-30 08:44:43 -04:00
|
|
|
|
*/
|
2009-01-10 18:44:44 -05:00
|
|
|
|
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 );
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Destructor, destroying the choice item.
|
|
|
|
|
*/
|
2008-09-22 15:01:17 -04:00
|
|
|
|
virtual ~wxChoice();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
|
|
//@{
|
|
|
|
|
/**
|
|
|
|
|
Creates the choice for two-step construction. See wxChoice().
|
|
|
|
|
*/
|
2009-01-10 18:44:44 -05:00
|
|
|
|
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 );
|
|
|
|
|
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 );
|
2008-03-08 08:52:38 -05:00
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Gets the number of columns in this choice item.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
|
2009-01-10 18:44:44 -05:00
|
|
|
|
@remarks This is implemented for GTK and Motif only and always
|
2008-06-16 09:32:43 -04:00
|
|
|
|
returns 1 for the other platforms.
|
2008-03-08 08:52:38 -05:00
|
|
|
|
*/
|
2008-09-22 15:01:17 -04:00
|
|
|
|
virtual int GetColumns() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
|
|
/**
|
2008-04-05 05:12:23 -04:00
|
|
|
|
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.
|
|
|
|
|
|
2008-04-21 06:34:23 -04:00
|
|
|
|
@since 2.6.2.
|
|
|
|
|
In older versions, wxControlWithItems::GetSelection() itself
|
|
|
|
|
behaved like this.
|
2008-03-08 08:52:38 -05:00
|
|
|
|
*/
|
2008-09-22 15:01:17 -04:00
|
|
|
|
virtual int GetCurrentSelection() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Sets the number of columns in this choice item.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
|
@param n
|
2008-03-09 08:33:59 -04:00
|
|
|
|
Number of columns.
|
2008-04-05 05:12:23 -04:00
|
|
|
|
|
2009-01-10 18:44:44 -05:00
|
|
|
|
@remarks This is implemented for GTK and Motif only and doesn’t do
|
2008-06-16 09:32:43 -04:00
|
|
|
|
anything under other platforms.
|
2008-03-08 08:52:38 -05:00
|
|
|
|
*/
|
2008-09-22 15:01:17 -04:00
|
|
|
|
virtual void SetColumns(int n = 1);
|
2011-09-02 21:39:02 -04:00
|
|
|
|
|
|
|
|
|
virtual bool IsSorted() const;
|
|
|
|
|
|
|
|
|
|
virtual unsigned int GetCount() const ;
|
|
|
|
|
virtual int GetSelection() const ;
|
|
|
|
|
virtual void SetSelection(int n);
|
|
|
|
|
|
|
|
|
|
virtual int FindString(const wxString& s, bool bCase = false) const;
|
|
|
|
|
virtual wxString GetString(unsigned int n) const ;
|
|
|
|
|
virtual void SetString(unsigned int pos, const wxString& s);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|
|