1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxChoice class
4 // Author: Julian Smart
5 // Modified by: Vadim Zeitlin to derive from wxChoiceBase
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "choice.h"
19 // ----------------------------------------------------------------------------
21 // ----------------------------------------------------------------------------
23 class WXDLLEXPORT wxChoice
: public wxChoiceBase
27 wxChoice() { Init(); }
30 wxChoice(wxWindow
*parent
,
32 const wxPoint
& pos
= wxDefaultPosition
,
33 const wxSize
& size
= wxDefaultSize
,
34 int n
= 0, const wxString choices
[] = NULL
,
36 const wxValidator
& validator
= wxDefaultValidator
,
37 const wxString
& name
= wxChoiceNameStr
)
39 Create(parent
, id
, pos
, size
, n
, choices
, style
, validator
, name
);
42 wxChoice(wxWindow
*parent
,
46 const wxArrayString
& choices
,
48 const wxValidator
& validator
= wxDefaultValidator
,
49 const wxString
& name
= wxChoiceNameStr
)
51 Create(parent
, id
, pos
, size
, choices
, style
, validator
, name
);
54 bool Create(wxWindow
*parent
,
56 const wxPoint
& pos
= wxDefaultPosition
,
57 const wxSize
& size
= wxDefaultSize
,
58 int n
= 0, const wxString choices
[] = NULL
,
60 const wxValidator
& validator
= wxDefaultValidator
,
61 const wxString
& name
= wxChoiceNameStr
);
62 bool Create(wxWindow
*parent
,
66 const wxArrayString
& choices
,
68 const wxValidator
& validator
= wxDefaultValidator
,
69 const wxString
& name
= wxChoiceNameStr
);
71 // implement base class pure virtuals
72 virtual int DoAppend(const wxString
& item
);
73 virtual int DoInsert(const wxString
& item
, int pos
);
74 virtual void Delete(int n
);
77 virtual int GetCount() const;
78 virtual int GetSelection() const;
79 #if wxABI_VERSION >= 20602
80 virtual int GetCurrentSelection() const;
82 virtual void SetSelection(int n
);
84 virtual int FindString(const wxString
& s
) const;
85 virtual wxString
GetString(int n
) const;
86 virtual void SetString(int n
, const wxString
& s
);
89 virtual bool MSWCommand(WXUINT param
, WXWORD id
);
90 WXLRESULT
MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
91 virtual WXHBRUSH
MSWControlColor(WXHDC hDC
, WXHWND hWnd
);
94 // common part of all ctors
95 void Init() { m_lastAcceptedSelection
= wxID_NONE
; }
97 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
98 virtual void DoSetItemClientData( int n
, void* clientData
);
99 virtual void* DoGetItemClientData( int n
) const;
100 virtual void DoSetItemClientObject( int n
, wxClientData
* clientData
);
101 virtual wxClientData
* DoGetItemClientObject( int n
) const;
103 // MSW implementation
104 virtual wxSize
DoGetBestSize() const;
105 virtual void DoGetSize(int *w
, int *h
) const;
106 virtual void DoSetSize(int x
, int y
,
107 int width
, int height
,
108 int sizeFlags
= wxSIZE_AUTO
);
110 virtual bool MSWShouldPreProcessMessage(WXMSG
*pMsg
);
112 virtual WXDWORD
MSWGetStyle(long style
, WXDWORD
*exstyle
) const;
114 // update the height of the drop down list to fit the number of items we
115 // have (without changing the visible height)
116 void UpdateVisibleHeight();
118 // create and initialize the control
119 bool CreateAndInit(wxWindow
*parent
, wxWindowID id
,
122 int n
, const wxString choices
[],
124 const wxValidator
& validator
,
125 const wxString
& name
);
127 // free all memory we have (used by Clear() and dtor)
131 // last "completed" selection, i.e. not the transient one while the user is
132 // browsing the popup list: this is only used when != wxID_NONE which is
133 // the case while the drop down is opened
134 int m_lastAcceptedSelection
;
137 DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoice
)
140 #endif // _WX_CHOICE_H_