1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxChoice class interface
4 // Author: Vadim Zeitlin
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_CHOICE_H_BASE_
13 #define _WX_CHOICE_H_BASE_
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
20 #pragma interface "choiccmn.h"
23 #include "wx/control.h" // the base class
25 // ----------------------------------------------------------------------------
27 // ----------------------------------------------------------------------------
29 WXDLLEXPORT_DATA(extern const wxChar
*) wxChoiceNameStr
;
31 // ----------------------------------------------------------------------------
32 // wxChoice allows to select one of a non-modifiable list of strings
33 // ----------------------------------------------------------------------------
35 class WXDLLEXPORT wxChoiceBase
: public wxControl
39 wxChoiceBase() { m_clientDataItemsType
= ClientData_None
; }
41 // add a new item to the list
43 void Append(const wxString
& item
) { DoAppend(item
); }
44 // with client data which belongs to the caller
45 void Append(const wxString
&item
, void* clientData
)
46 { int n
= DoAppend(item
); SetClientData(n
, clientData
); }
47 // with client data which will be deleted by the control
48 void Append(const wxString
&item
, wxClientData
* clientData
)
49 { int n
= DoAppend(item
); SetClientObject(n
, clientData
); }
51 // delete items from the list
53 virtual void Delete(int n
) = 0;
55 virtual void Clear() = 0;
57 // selection (at most one item may be selected in wxChoice)
58 // get the index of currently selected item or -1
59 virtual int GetSelection() const = 0;
60 // get the text of the currently selected item or empty string
61 virtual wxString
GetStringSelection() const;
63 // set selectionto current item
64 virtual void SetSelection(int n
) = 0;
65 // set selection to the current item, returns TRUE if ok
66 virtual bool SetStringSelection(const wxString
& sel
);
68 // accessors to the list of strings
69 // get the number of items in the list of strings
70 virtual int GetCount() const = 0;
72 // find string in the list, return wxNOT_FOUND if not found
73 virtual int FindString(const wxString
& s
) const = 0;
74 // get the string with the specified index
75 virtual wxString
GetString(int n
) const = 0;
77 // set/get the number of columns in the control (as they're not supporte on
78 // most platforms, they do nothing by default)
79 virtual void SetColumns(int WXUNUSED(n
) = 1 ) { }
80 virtual int GetColumns() const { return 1 ; }
83 // untyped (isn't deleted by the control)
84 void SetClientData( int n
, void* clientData
);
85 void* GetClientData( int n
) const;
86 // typed (is owned and deleted by the control)
87 void SetClientObject( int n
, wxClientData
* clientData
);
88 wxClientData
* GetClientObject( int n
) const;
90 // emulate selecting the item event.GetInt() from the control
91 virtual void Command(wxCommandEvent
&event
);
93 // deprecated functions, heer for backwards compatibility only
94 int Number() const { return GetCount(); }
97 // pure virtuals to implement in the derived classes
98 virtual int DoAppend(const wxString
& item
) = 0;
100 virtual void DoSetClientData( int n
, void* clientData
) = 0;
101 virtual void* DoGetClientData( int n
) const = 0;
102 virtual void DoSetClientObject( int n
, wxClientData
* clientData
) = 0;
103 virtual wxClientData
* DoGetClientObject( int n
) const = 0;
105 // the type of the client data for the items
106 wxClientDataType m_clientDataItemsType
;
107 // the above pure virtuals hide these virtuals in wxWindowBase
108 virtual void DoSetClientData(void* clientData
) { wxWindowBase::DoSetClientData(clientData
); };
109 virtual void* DoGetClientData() const { return(wxWindowBase::DoGetClientData()); };
110 virtual void DoSetClientObject( wxClientData
* clientData
) { wxWindowBase::DoSetClientObject(clientData
); };
111 virtual wxClientData
* DoGetClientObject() const { return(wxWindowBase::DoGetClientObject()); };
114 // ----------------------------------------------------------------------------
115 // include the platform-dependent class definition
116 // ----------------------------------------------------------------------------
118 #if defined(__WXMSW__)
119 #include "wx/msw/choice.h"
120 #elif defined(__WXMOTIF__)
121 #include "wx/motif/choice.h"
122 #elif defined(__WXGTK__)
123 #include "wx/gtk/choice.h"
124 #elif defined(__WXQT__)
125 #include "wx/qt/choice.h"
126 #elif defined(__WXMAC__)
127 #include "wx/mac/choice.h"
128 #elif defined(__WXPM__)
129 #include "wx/os2/choice.h"
130 #elif defined(__WXSTUBS__)
131 #include "wx/stubs/choice.h"
135 // _WX_CHOICE_H_BASE_