]>
Commit | Line | Data |
---|---|---|
2bda0e17 | 1 | ///////////////////////////////////////////////////////////////////////////// |
853dcc57 | 2 | // Name: wx/msw/choice.h |
2bda0e17 KB |
3 | // Purpose: wxChoice class |
4 | // Author: Julian Smart | |
8d99be5f | 5 | // Modified by: Vadim Zeitlin to derive from wxChoiceBase |
2bda0e17 KB |
6 | // Created: 01/02/97 |
7 | // RCS-ID: $Id$ | |
bbcdf8bc | 8 | // Copyright: (c) Julian Smart |
65571936 | 9 | // Licence: wxWindows licence |
2bda0e17 KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
bbcdf8bc JS |
12 | #ifndef _WX_CHOICE_H_ |
13 | #define _WX_CHOICE_H_ | |
2bda0e17 | 14 | |
8d99be5f | 15 | // ---------------------------------------------------------------------------- |
2bda0e17 | 16 | // Choice item |
8d99be5f VZ |
17 | // ---------------------------------------------------------------------------- |
18 | ||
53a2db12 | 19 | class WXDLLIMPEXP_CORE wxChoice : public wxChoiceBase |
2bda0e17 | 20 | { |
bfc6fde4 | 21 | public: |
8d99be5f | 22 | // ctors |
6ba93d23 | 23 | wxChoice() { Init(); } |
8ee9d618 | 24 | virtual ~wxChoice(); |
8d99be5f VZ |
25 | |
26 | wxChoice(wxWindow *parent, | |
27 | wxWindowID id, | |
28 | const wxPoint& pos = wxDefaultPosition, | |
29 | const wxSize& size = wxDefaultSize, | |
30 | int n = 0, const wxString choices[] = NULL, | |
31 | long style = 0, | |
32 | const wxValidator& validator = wxDefaultValidator, | |
6463b9f5 JS |
33 | const wxString& name = wxChoiceNameStr) |
34 | { | |
94500b32 | 35 | Init(); |
6463b9f5 JS |
36 | Create(parent, id, pos, size, n, choices, style, validator, name); |
37 | } | |
6ba93d23 | 38 | |
584ad2a3 MB |
39 | wxChoice(wxWindow *parent, |
40 | wxWindowID id, | |
41 | const wxPoint& pos, | |
42 | const wxSize& size, | |
43 | const wxArrayString& choices, | |
44 | long style = 0, | |
45 | const wxValidator& validator = wxDefaultValidator, | |
46 | const wxString& name = wxChoiceNameStr) | |
47 | { | |
94500b32 | 48 | Init(); |
584ad2a3 MB |
49 | Create(parent, id, pos, size, choices, style, validator, name); |
50 | } | |
bfc6fde4 | 51 | |
8d99be5f VZ |
52 | bool Create(wxWindow *parent, |
53 | wxWindowID id, | |
54 | const wxPoint& pos = wxDefaultPosition, | |
55 | const wxSize& size = wxDefaultSize, | |
56 | int n = 0, const wxString choices[] = NULL, | |
57 | long style = 0, | |
58 | const wxValidator& validator = wxDefaultValidator, | |
59 | const wxString& name = wxChoiceNameStr); | |
584ad2a3 MB |
60 | bool Create(wxWindow *parent, |
61 | wxWindowID id, | |
62 | const wxPoint& pos, | |
63 | const wxSize& size, | |
64 | const wxArrayString& choices, | |
65 | long style = 0, | |
66 | const wxValidator& validator = wxDefaultValidator, | |
67 | const wxString& name = wxChoiceNameStr); | |
8d99be5f | 68 | |
5de69dd3 VZ |
69 | virtual void SetLabel(const wxString& label); |
70 | ||
aa61d352 | 71 | virtual unsigned int GetCount() const; |
8d99be5f | 72 | virtual int GetSelection() const; |
6ba93d23 | 73 | virtual int GetCurrentSelection() const; |
bfc6fde4 | 74 | virtual void SetSelection(int n); |
bfc6fde4 | 75 | |
853dcc57 | 76 | virtual int FindString(const wxString& s, bool bCase = false) const; |
aa61d352 VZ |
77 | virtual wxString GetString(unsigned int n) const; |
78 | virtual void SetString(unsigned int n, const wxString& s); | |
bfc6fde4 | 79 | |
2ec335db JS |
80 | virtual wxVisualAttributes GetDefaultAttributes() const |
81 | { | |
82 | return GetClassDefaultAttributes(GetWindowVariant()); | |
83 | } | |
84 | ||
85 | static wxVisualAttributes | |
86 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
87 | ||
8d99be5f | 88 | // MSW only |
bfc6fde4 | 89 | virtual bool MSWCommand(WXUINT param, WXWORD id); |
c140b7e7 | 90 | WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); |
2bae4332 | 91 | virtual WXHBRUSH MSWControlColor(WXHDC hDC, WXHWND hWnd); |
6f02a879 VZ |
92 | virtual bool MSWShouldPreProcessMessage(WXMSG *pMsg); |
93 | virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; | |
bbcdf8bc | 94 | |
a047aff2 JS |
95 | // returns true if the platform should explicitly apply a theme border |
96 | virtual bool CanApplyThemeBorder() const { return false; } | |
97 | ||
bbcdf8bc | 98 | protected: |
dc797d8e JS |
99 | // choose the default border for this window |
100 | virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } | |
101 | ||
6ba93d23 | 102 | // common part of all ctors |
75004dfb VZ |
103 | void Init() |
104 | { | |
105 | m_lastAcceptedSelection = wxID_NONE; | |
106 | m_heightOwn = wxDefaultCoord; | |
107 | } | |
6ba93d23 | 108 | |
3c75d8ba PC |
109 | virtual void DoDeleteOneItem(unsigned int n); |
110 | virtual void DoClear(); | |
111 | ||
a236aa20 VZ |
112 | virtual int DoInsertItems(const wxArrayStringsAdapter& items, |
113 | unsigned int pos, | |
114 | void **clientData, wxClientDataType type); | |
115 | ||
18c50997 | 116 | virtual void DoMoveWindow(int x, int y, int width, int height); |
aa61d352 VZ |
117 | virtual void DoSetItemClientData(unsigned int n, void* clientData); |
118 | virtual void* DoGetItemClientData(unsigned int n) const; | |
bbcdf8bc | 119 | |
8d99be5f | 120 | // MSW implementation |
882a8f40 | 121 | virtual wxSize DoGetBestSize() const; |
d99957b6 | 122 | virtual void DoGetSize(int *w, int *h) const; |
bfc6fde4 | 123 | virtual void DoSetSize(int x, int y, |
4438caf4 VZ |
124 | int width, int height, |
125 | int sizeFlags = wxSIZE_AUTO); | |
8ee9d618 | 126 | |
71e57cd6 VZ |
127 | // update the height of the drop down list to fit the number of items we |
128 | // have (without changing the visible height) | |
75004dfb VZ |
129 | void MSWUpdateDropDownHeight(); |
130 | ||
131 | // set the height of the visible part of the control to m_heightOwn | |
132 | void MSWUpdateVisibleHeight(); | |
71e57cd6 VZ |
133 | |
134 | // create and initialize the control | |
135 | bool CreateAndInit(wxWindow *parent, wxWindowID id, | |
136 | const wxPoint& pos, | |
137 | const wxSize& size, | |
138 | int n, const wxString choices[], | |
139 | long style, | |
140 | const wxValidator& validator, | |
141 | const wxString& name); | |
142 | ||
8ee9d618 VZ |
143 | // free all memory we have (used by Clear() and dtor) |
144 | void Free(); | |
fc7a2a60 | 145 | |
da89830a JS |
146 | // set the height for simple combo box |
147 | int SetHeightSimpleComboBox(int nItems) const; | |
148 | ||
75004dfb VZ |
149 | #if wxUSE_DEFERRED_SIZING |
150 | virtual void MSWEndDeferWindowPos(); | |
151 | #endif // wxUSE_DEFERRED_SIZING | |
6ba93d23 VZ |
152 | |
153 | // last "completed" selection, i.e. not the transient one while the user is | |
154 | // browsing the popup list: this is only used when != wxID_NONE which is | |
155 | // the case while the drop down is opened | |
156 | int m_lastAcceptedSelection; | |
157 | ||
75004dfb VZ |
158 | // the height of the control itself if it was set explicitly or |
159 | // wxDefaultCoord if it hadn't | |
160 | int m_heightOwn; | |
6ba93d23 | 161 | |
fc7a2a60 | 162 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoice) |
2bda0e17 KB |
163 | }; |
164 | ||
8d99be5f | 165 | #endif // _WX_CHOICE_H_ |