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