1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxChoice class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "choice.h"
19 #include "wx/clntdata.h"
21 #ifndef wxWIDGET_ARRAY_DEFINED
22 #define wxWIDGET_ARRAY_DEFINED
24 #include "wx/dynarray.h"
25 WX_DEFINE_ARRAY_PTR(WXWidget
, wxWidgetArray
);
29 class WXDLLEXPORT wxChoice
: public wxChoiceBase
31 DECLARE_DYNAMIC_CLASS(wxChoice
)
37 wxChoice(wxWindow
*parent
, wxWindowID id
,
38 const wxPoint
& pos
= wxDefaultPosition
,
39 const wxSize
& size
= wxDefaultSize
,
40 int n
= 0, const wxString choices
[] = NULL
,
42 const wxValidator
& validator
= wxDefaultValidator
,
43 const wxString
& name
= wxChoiceNameStr
)
46 Create(parent
, id
, pos
, size
, n
, choices
, style
, validator
, name
);
49 wxChoice(wxWindow
*parent
, wxWindowID id
,
52 const wxArrayString
& choices
,
54 const wxValidator
& validator
= wxDefaultValidator
,
55 const wxString
& name
= wxChoiceNameStr
)
58 Create(parent
, id
, pos
, size
, choices
, style
, validator
, name
);
61 bool Create(wxWindow
*parent
, wxWindowID id
,
62 const wxPoint
& pos
= wxDefaultPosition
,
63 const wxSize
& size
= wxDefaultSize
,
64 int n
= 0, const wxString choices
[] = NULL
,
66 const wxValidator
& validator
= wxDefaultValidator
,
67 const wxString
& name
= wxChoiceNameStr
);
69 bool Create(wxWindow
*parent
, wxWindowID id
,
72 const wxArrayString
& choices
,
74 const wxValidator
& validator
= wxDefaultValidator
,
75 const wxString
& name
= wxChoiceNameStr
);
77 // implementation of wxControlWithItems
78 virtual int GetCount() const;
79 virtual int DoAppend(const wxString
& item
);
80 virtual int DoInsert(const wxString
& item
, int pos
);
81 virtual void DoSetItemClientData(int n
, void* clientData
);
82 virtual void* DoGetItemClientData(int n
) const;
83 virtual void DoSetItemClientObject(int n
, wxClientData
* clientData
);
84 virtual wxClientData
* DoGetItemClientObject(int n
) const;
85 virtual int GetSelection() const;
86 virtual void Delete(int n
);
87 virtual int FindString(const wxString
& s
) const;
89 virtual void SetString(int n
, const wxString
& s
);
90 virtual wxString
GetString(int n
) const;
92 // implementation of wxChoiceBase
93 virtual void SetSelection(int n
);
94 virtual void SetColumns(int n
= 1 );
95 virtual int GetColumns() const ;
98 virtual void Command(wxCommandEvent
& event
);
103 virtual void ChangeFont(bool keepOriginalSize
= true);
104 virtual void ChangeBackgroundColour();
105 virtual void ChangeForegroundColour();
106 WXWidget
GetTopWidget() const { return m_formWidget
; }
107 WXWidget
GetMainWidget() const { return m_buttonWidget
; }
109 virtual wxSize
DoGetBestSize() const;
111 // implementation, for wxChoiceCallback
112 const wxWidgetArray
& GetWidgets() const { return m_widgetArray
; }
113 const wxStringList
& GetStrings() const { return m_stringList
; }
115 // minimum size for the text ctrl
116 wxSize
GetItemsSize() const;
117 // common part of all contructors
121 WXWidget m_menuWidget
;
122 WXWidget m_buttonWidget
;
123 wxWidgetArray m_widgetArray
;
124 WXWidget m_formWidget
;
125 wxStringList m_stringList
;
126 wxClientDataDictionary m_clientDataDict
;
128 virtual void DoSetSize(int x
, int y
,
129 int width
, int height
,
130 int sizeFlags
= wxSIZE_AUTO
);