1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxChoice class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "choice.h"
19 #include "wx/clntdata.h"
20 #include "wx/dynarray.h"
22 WX_DEFINE_ARRAY(WXWidget
, wxWidgetArray
);
25 class WXDLLEXPORT wxChoice
: public wxChoiceBase
27 DECLARE_DYNAMIC_CLASS(wxChoice
)
33 wxChoice(wxWindow
*parent
, wxWindowID id
,
34 const wxPoint
& pos
= wxDefaultPosition
,
35 const wxSize
& size
= wxDefaultSize
,
36 int n
= 0, const wxString choices
[] = NULL
,
38 const wxValidator
& validator
= wxDefaultValidator
,
39 const wxString
& name
= wxChoiceNameStr
)
42 Create(parent
, id
, pos
, size
, n
, choices
, style
, validator
, name
);
45 bool Create(wxWindow
*parent
, wxWindowID id
,
46 const wxPoint
& pos
= wxDefaultPosition
,
47 const wxSize
& size
= wxDefaultSize
,
48 int n
= 0, const wxString choices
[] = NULL
,
50 const wxValidator
& validator
= wxDefaultValidator
,
51 const wxString
& name
= wxChoiceNameStr
);
53 // implementation of wxControlWithItems
54 virtual int GetCount() const;
55 virtual int DoAppend(const wxString
& item
);
56 virtual int DoInsert(const wxString
& item
, int pos
);
57 virtual void DoSetItemClientData(int n
, void* clientData
);
58 virtual void* DoGetItemClientData(int n
) const;
59 virtual void DoSetItemClientObject(int n
, wxClientData
* clientData
);
60 virtual wxClientData
* DoGetItemClientObject(int n
) const;
61 virtual int GetSelection() const;
62 virtual void Delete(int n
);
63 virtual int FindString(const wxString
& s
) const;
65 virtual void SetString(int n
, const wxString
& s
);
66 virtual wxString
GetString(int n
) const;
68 // implementation of wxChoiceBase
69 virtual void SetSelection(int n
);
70 virtual void SetColumns(int n
= 1 );
71 virtual int GetColumns() const ;
74 virtual void Command(wxCommandEvent
& event
);
79 virtual void ChangeFont(bool keepOriginalSize
= TRUE
);
80 virtual void ChangeBackgroundColour();
81 virtual void ChangeForegroundColour();
82 WXWidget
GetTopWidget() const { return m_formWidget
; }
83 WXWidget
GetMainWidget() const { return m_buttonWidget
; }
85 virtual wxSize
DoGetBestSize() const;
87 // implementation, for wxChoiceCallback
88 const wxWidgetArray
& GetWidgets() const { return m_widgetArray
; }
89 const wxStringList
& GetStrings() const { return m_stringList
; }
91 // minimum size for the text ctrl
92 wxSize
GetItemsSize() const;
93 // common part of all contructors
97 WXWidget m_menuWidget
;
98 WXWidget m_buttonWidget
;
99 wxWidgetArray m_widgetArray
;
100 WXWidget m_formWidget
;
101 wxStringList m_stringList
;
102 wxClientDataDictionary m_clientDataDict
;
104 virtual void DoSetSize(int x
, int y
,
105 int width
, int height
,
106 int sizeFlags
= wxSIZE_AUTO
);