]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/choice.h
Somehow, setting a tint color makes gauge work :/.
[wxWidgets.git] / include / wx / msw / choice.h
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 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_CHOICE_H_
12 #define _WX_CHOICE_H_
13
14 struct tagCOMBOBOXINFO;
15
16 // ----------------------------------------------------------------------------
17 // Choice item
18 // ----------------------------------------------------------------------------
19
20 class WXDLLIMPEXP_CORE wxChoice : public wxChoiceBase
21 {
22 public:
23 // ctors
24 wxChoice() { Init(); }
25 virtual ~wxChoice();
26
27 wxChoice(wxWindow *parent,
28 wxWindowID id,
29 const wxPoint& pos = wxDefaultPosition,
30 const wxSize& size = wxDefaultSize,
31 int n = 0, const wxString choices[] = NULL,
32 long style = 0,
33 const wxValidator& validator = wxDefaultValidator,
34 const wxString& name = wxChoiceNameStr)
35 {
36 Init();
37 Create(parent, id, pos, size, n, choices, style, validator, name);
38 }
39
40 wxChoice(wxWindow *parent,
41 wxWindowID id,
42 const wxPoint& pos,
43 const wxSize& size,
44 const wxArrayString& choices,
45 long style = 0,
46 const wxValidator& validator = wxDefaultValidator,
47 const wxString& name = wxChoiceNameStr)
48 {
49 Init();
50 Create(parent, id, pos, size, choices, style, validator, name);
51 }
52
53 bool Create(wxWindow *parent,
54 wxWindowID id,
55 const wxPoint& pos = wxDefaultPosition,
56 const wxSize& size = wxDefaultSize,
57 int n = 0, const wxString choices[] = NULL,
58 long style = 0,
59 const wxValidator& validator = wxDefaultValidator,
60 const wxString& name = wxChoiceNameStr);
61 bool Create(wxWindow *parent,
62 wxWindowID id,
63 const wxPoint& pos,
64 const wxSize& size,
65 const wxArrayString& choices,
66 long style = 0,
67 const wxValidator& validator = wxDefaultValidator,
68 const wxString& name = wxChoiceNameStr);
69
70 virtual bool Show(bool show = true);
71
72 virtual void SetLabel(const wxString& label);
73
74 virtual unsigned int GetCount() const;
75 virtual int GetSelection() const;
76 virtual int GetCurrentSelection() const;
77 virtual void SetSelection(int n);
78
79 virtual int FindString(const wxString& s, bool bCase = false) const;
80 virtual wxString GetString(unsigned int n) const;
81 virtual void SetString(unsigned int n, const wxString& s);
82
83 virtual wxVisualAttributes GetDefaultAttributes() const
84 {
85 return GetClassDefaultAttributes(GetWindowVariant());
86 }
87
88 static wxVisualAttributes
89 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
90
91 // MSW only
92 virtual bool MSWCommand(WXUINT param, WXWORD id);
93 WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
94 virtual WXHBRUSH MSWControlColor(WXHDC hDC, WXHWND hWnd);
95 virtual bool MSWShouldPreProcessMessage(WXMSG *pMsg);
96 virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
97
98 // returns true if the platform should explicitly apply a theme border
99 virtual bool CanApplyThemeBorder() const { return false; }
100
101 protected:
102 // choose the default border for this window
103 virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
104
105 // common part of all ctors
106 void Init()
107 {
108 m_lastAcceptedSelection =
109 m_pendingSelection = wxID_NONE;
110 m_heightOwn = wxDefaultCoord;
111 }
112
113 virtual void DoDeleteOneItem(unsigned int n);
114 virtual void DoClear();
115
116 virtual int DoInsertItems(const wxArrayStringsAdapter& items,
117 unsigned int pos,
118 void **clientData, wxClientDataType type);
119
120 virtual void DoMoveWindow(int x, int y, int width, int height);
121 virtual void DoSetItemClientData(unsigned int n, void* clientData);
122 virtual void* DoGetItemClientData(unsigned int n) const;
123
124 // MSW implementation
125 virtual wxSize DoGetBestSize() const;
126 virtual void DoGetSize(int *w, int *h) const;
127 virtual void DoSetSize(int x, int y,
128 int width, int height,
129 int sizeFlags = wxSIZE_AUTO);
130 virtual wxSize DoGetSizeFromTextSize(int xlen, int ylen = -1) const;
131
132 // Show or hide the popup part of the control.
133 void MSWDoPopupOrDismiss(bool show);
134
135 // update the height of the drop down list to fit the number of items we
136 // have (without changing the visible height)
137 void MSWUpdateDropDownHeight();
138
139 // set the height of the visible part of the control to m_heightOwn
140 void MSWUpdateVisibleHeight();
141
142 // Call GetComboBoxInfo() and return false if it's not supported by this
143 // system. Notice that the caller must initialize info.cbSize.
144 bool MSWGetComboBoxInfo(tagCOMBOBOXINFO* info) const;
145
146 // create and initialize the control
147 bool CreateAndInit(wxWindow *parent, wxWindowID id,
148 const wxPoint& pos,
149 const wxSize& size,
150 int n, const wxString choices[],
151 long style,
152 const wxValidator& validator,
153 const wxString& name);
154
155 // free all memory we have (used by Clear() and dtor)
156 void Free();
157
158 // set the height for simple combo box
159 int SetHeightSimpleComboBox(int nItems) const;
160
161 #if wxUSE_DEFERRED_SIZING
162 virtual void MSWEndDeferWindowPos();
163 #endif // wxUSE_DEFERRED_SIZING
164
165 // These variables are only used while the drop down is opened.
166 //
167 // The first one contains the item that had been originally selected before
168 // the drop down was opened and the second one the item we should select
169 // when the drop down is closed again.
170 int m_lastAcceptedSelection,
171 m_pendingSelection;
172
173 // the height of the control itself if it was set explicitly or
174 // wxDefaultCoord if it hadn't
175 int m_heightOwn;
176
177 DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoice)
178 };
179
180 #endif // _WX_CHOICE_H_