]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/msw/choice.h | |
3 | // Purpose: wxChoice class | |
4 | // Author: Julian Smart | |
5 | // Modified by: Vadim Zeitlin to derive from wxChoiceBase | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_CHOICE_H_ | |
13 | #define _WX_CHOICE_H_ | |
14 | ||
15 | // ---------------------------------------------------------------------------- | |
16 | // Choice item | |
17 | // ---------------------------------------------------------------------------- | |
18 | ||
19 | class WXDLLIMPEXP_CORE wxChoice : public wxChoiceBase | |
20 | { | |
21 | public: | |
22 | // ctors | |
23 | wxChoice() { Init(); } | |
24 | virtual ~wxChoice(); | |
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, | |
33 | const wxString& name = wxChoiceNameStr) | |
34 | { | |
35 | Init(); | |
36 | Create(parent, id, pos, size, n, choices, style, validator, name); | |
37 | } | |
38 | ||
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 | { | |
48 | Init(); | |
49 | Create(parent, id, pos, size, choices, style, validator, name); | |
50 | } | |
51 | ||
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); | |
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); | |
68 | ||
69 | virtual void SetLabel(const wxString& label); | |
70 | ||
71 | virtual unsigned int GetCount() const; | |
72 | virtual int GetSelection() const; | |
73 | virtual int GetCurrentSelection() const; | |
74 | virtual void SetSelection(int n); | |
75 | ||
76 | virtual int FindString(const wxString& s, bool bCase = false) const; | |
77 | virtual wxString GetString(unsigned int n) const; | |
78 | virtual void SetString(unsigned int n, const wxString& s); | |
79 | ||
80 | // MSW only | |
81 | virtual bool MSWCommand(WXUINT param, WXWORD id); | |
82 | WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); | |
83 | virtual WXHBRUSH MSWControlColor(WXHDC hDC, WXHWND hWnd); | |
84 | virtual bool MSWShouldPreProcessMessage(WXMSG *pMsg); | |
85 | virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; | |
86 | ||
87 | // returns true if the platform should explicitly apply a theme border | |
88 | virtual bool CanApplyThemeBorder() const { return false; } | |
89 | ||
90 | protected: | |
91 | // choose the default border for this window | |
92 | virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } | |
93 | ||
94 | // common part of all ctors | |
95 | void Init() | |
96 | { | |
97 | m_lastAcceptedSelection = wxID_NONE; | |
98 | m_heightOwn = wxDefaultCoord; | |
99 | } | |
100 | ||
101 | virtual void DoDeleteOneItem(unsigned int n); | |
102 | virtual void DoClear(); | |
103 | ||
104 | virtual int DoInsertItems(const wxArrayStringsAdapter& items, | |
105 | unsigned int pos, | |
106 | void **clientData, wxClientDataType type); | |
107 | ||
108 | virtual void DoMoveWindow(int x, int y, int width, int height); | |
109 | virtual void DoSetItemClientData(unsigned int n, void* clientData); | |
110 | virtual void* DoGetItemClientData(unsigned int n) const; | |
111 | ||
112 | // MSW implementation | |
113 | virtual wxSize DoGetBestSize() const; | |
114 | virtual void DoGetSize(int *w, int *h) const; | |
115 | virtual void DoSetSize(int x, int y, | |
116 | int width, int height, | |
117 | int sizeFlags = wxSIZE_AUTO); | |
118 | ||
119 | // update the height of the drop down list to fit the number of items we | |
120 | // have (without changing the visible height) | |
121 | void MSWUpdateDropDownHeight(); | |
122 | ||
123 | // set the height of the visible part of the control to m_heightOwn | |
124 | void MSWUpdateVisibleHeight(); | |
125 | ||
126 | // create and initialize the control | |
127 | bool CreateAndInit(wxWindow *parent, wxWindowID id, | |
128 | const wxPoint& pos, | |
129 | const wxSize& size, | |
130 | int n, const wxString choices[], | |
131 | long style, | |
132 | const wxValidator& validator, | |
133 | const wxString& name); | |
134 | ||
135 | // free all memory we have (used by Clear() and dtor) | |
136 | void Free(); | |
137 | ||
138 | #if wxUSE_DEFERRED_SIZING | |
139 | virtual void MSWEndDeferWindowPos(); | |
140 | #endif // wxUSE_DEFERRED_SIZING | |
141 | ||
142 | // last "completed" selection, i.e. not the transient one while the user is | |
143 | // browsing the popup list: this is only used when != wxID_NONE which is | |
144 | // the case while the drop down is opened | |
145 | int m_lastAcceptedSelection; | |
146 | ||
147 | // the height of the control itself if it was set explicitly or | |
148 | // wxDefaultCoord if it hadn't | |
149 | int m_heightOwn; | |
150 | ||
151 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoice) | |
152 | }; | |
153 | ||
154 | #endif // _WX_CHOICE_H_ |