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(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 bool Create(wxWindow
*parent
, wxWindowID id
,
50 const wxPoint
& pos
= wxDefaultPosition
,
51 const wxSize
& size
= wxDefaultSize
,
52 int n
= 0, const wxString choices
[] = NULL
,
54 const wxValidator
& validator
= wxDefaultValidator
,
55 const wxString
& name
= wxChoiceNameStr
);
57 // implementation of wxControlWithItems
58 virtual int GetCount() const;
59 virtual int DoAppend(const wxString
& item
);
60 virtual int DoInsert(const wxString
& item
, int pos
);
61 virtual void DoSetItemClientData(int n
, void* clientData
);
62 virtual void* DoGetItemClientData(int n
) const;
63 virtual void DoSetItemClientObject(int n
, wxClientData
* clientData
);
64 virtual wxClientData
* DoGetItemClientObject(int n
) const;
65 virtual int GetSelection() const;
66 virtual void Delete(int n
);
67 virtual int FindString(const wxString
& s
) const;
69 virtual void SetString(int n
, const wxString
& s
);
70 virtual wxString
GetString(int n
) const;
72 // implementation of wxChoiceBase
73 virtual void SetSelection(int n
);
74 virtual void SetColumns(int n
= 1 );
75 virtual int GetColumns() const ;
78 virtual void Command(wxCommandEvent
& event
);
83 virtual void ChangeFont(bool keepOriginalSize
= TRUE
);
84 virtual void ChangeBackgroundColour();
85 virtual void ChangeForegroundColour();
86 WXWidget
GetTopWidget() const { return m_formWidget
; }
87 WXWidget
GetMainWidget() const { return m_buttonWidget
; }
89 virtual wxSize
DoGetBestSize() const;
91 // implementation, for wxChoiceCallback
92 const wxWidgetArray
& GetWidgets() const { return m_widgetArray
; }
93 const wxStringList
& GetStrings() const { return m_stringList
; }
95 // minimum size for the text ctrl
96 wxSize
GetItemsSize() const;
97 // common part of all contructors
101 WXWidget m_menuWidget
;
102 WXWidget m_buttonWidget
;
103 wxWidgetArray m_widgetArray
;
104 WXWidget m_formWidget
;
105 wxStringList m_stringList
;
106 wxClientDataDictionary m_clientDataDict
;
108 virtual void DoSetSize(int x
, int y
,
109 int width
, int height
,
110 int sizeFlags
= wxSIZE_AUTO
);