]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/choice.h
Fix wxPropertyGrid::GetPropertyRect when the last item is collapsed.
[wxWidgets.git] / include / wx / msw / choice.h
CommitLineData
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 6// Created: 01/02/97
bbcdf8bc 7// Copyright: (c) Julian Smart
65571936 8// Licence: wxWindows licence
2bda0e17
KB
9/////////////////////////////////////////////////////////////////////////////
10
bbcdf8bc
JS
11#ifndef _WX_CHOICE_H_
12#define _WX_CHOICE_H_
2bda0e17 13
df74e2d2
VZ
14struct tagCOMBOBOXINFO;
15
8d99be5f 16// ----------------------------------------------------------------------------
2bda0e17 17// Choice item
8d99be5f
VZ
18// ----------------------------------------------------------------------------
19
53a2db12 20class WXDLLIMPEXP_CORE wxChoice : public wxChoiceBase
2bda0e17 21{
bfc6fde4 22public:
8d99be5f 23 // ctors
6ba93d23 24 wxChoice() { Init(); }
8ee9d618 25 virtual ~wxChoice();
8d99be5f
VZ
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,
6463b9f5
JS
34 const wxString& name = wxChoiceNameStr)
35 {
94500b32 36 Init();
6463b9f5
JS
37 Create(parent, id, pos, size, n, choices, style, validator, name);
38 }
6ba93d23 39
584ad2a3
MB
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 {
94500b32 49 Init();
584ad2a3
MB
50 Create(parent, id, pos, size, choices, style, validator, name);
51 }
bfc6fde4 52
8d99be5f
VZ
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);
584ad2a3
MB
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);
8d99be5f 69
e911dd0a
VZ
70 virtual bool Show(bool show = true);
71
5de69dd3
VZ
72 virtual void SetLabel(const wxString& label);
73
aa61d352 74 virtual unsigned int GetCount() const;
8d99be5f 75 virtual int GetSelection() const;
6ba93d23 76 virtual int GetCurrentSelection() const;
bfc6fde4 77 virtual void SetSelection(int n);
bfc6fde4 78
853dcc57 79 virtual int FindString(const wxString& s, bool bCase = false) const;
aa61d352
VZ
80 virtual wxString GetString(unsigned int n) const;
81 virtual void SetString(unsigned int n, const wxString& s);
bfc6fde4 82
2ec335db
JS
83 virtual wxVisualAttributes GetDefaultAttributes() const
84 {
85 return GetClassDefaultAttributes(GetWindowVariant());
86 }
87
88 static wxVisualAttributes
89 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
90
8d99be5f 91 // MSW only
bfc6fde4 92 virtual bool MSWCommand(WXUINT param, WXWORD id);
c140b7e7 93 WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
2bae4332 94 virtual WXHBRUSH MSWControlColor(WXHDC hDC, WXHWND hWnd);
6f02a879
VZ
95 virtual bool MSWShouldPreProcessMessage(WXMSG *pMsg);
96 virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
bbcdf8bc 97
a047aff2
JS
98 // returns true if the platform should explicitly apply a theme border
99 virtual bool CanApplyThemeBorder() const { return false; }
100
bbcdf8bc 101protected:
dc797d8e
JS
102 // choose the default border for this window
103 virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
104
6ba93d23 105 // common part of all ctors
75004dfb
VZ
106 void Init()
107 {
65676a28
VZ
108 m_lastAcceptedSelection =
109 m_pendingSelection = wxID_NONE;
75004dfb
VZ
110 m_heightOwn = wxDefaultCoord;
111 }
6ba93d23 112
3c75d8ba
PC
113 virtual void DoDeleteOneItem(unsigned int n);
114 virtual void DoClear();
115
a236aa20
VZ
116 virtual int DoInsertItems(const wxArrayStringsAdapter& items,
117 unsigned int pos,
118 void **clientData, wxClientDataType type);
119
18c50997 120 virtual void DoMoveWindow(int x, int y, int width, int height);
aa61d352
VZ
121 virtual void DoSetItemClientData(unsigned int n, void* clientData);
122 virtual void* DoGetItemClientData(unsigned int n) const;
bbcdf8bc 123
8d99be5f 124 // MSW implementation
882a8f40 125 virtual wxSize DoGetBestSize() const;
d99957b6 126 virtual void DoGetSize(int *w, int *h) const;
bfc6fde4 127 virtual void DoSetSize(int x, int y,
4438caf4
VZ
128 int width, int height,
129 int sizeFlags = wxSIZE_AUTO);
aa24f946 130 virtual wxSize DoGetSizeFromTextSize(int xlen, int ylen = -1) const;
8ee9d618 131
a24fb9f8
VZ
132 // Show or hide the popup part of the control.
133 void MSWDoPopupOrDismiss(bool show);
134
71e57cd6
VZ
135 // update the height of the drop down list to fit the number of items we
136 // have (without changing the visible height)
75004dfb
VZ
137 void MSWUpdateDropDownHeight();
138
139 // set the height of the visible part of the control to m_heightOwn
140 void MSWUpdateVisibleHeight();
71e57cd6 141
df74e2d2
VZ
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
71e57cd6
VZ
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
8ee9d618
VZ
155 // free all memory we have (used by Clear() and dtor)
156 void Free();
fc7a2a60 157
da89830a
JS
158 // set the height for simple combo box
159 int SetHeightSimpleComboBox(int nItems) const;
160
75004dfb
VZ
161#if wxUSE_DEFERRED_SIZING
162 virtual void MSWEndDeferWindowPos();
163#endif // wxUSE_DEFERRED_SIZING
6ba93d23 164
65676a28
VZ
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;
6ba93d23 172
75004dfb
VZ
173 // the height of the control itself if it was set explicitly or
174 // wxDefaultCoord if it hadn't
175 int m_heightOwn;
6ba93d23 176
fc7a2a60 177 DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoice)
2bda0e17
KB
178};
179
8d99be5f 180#endif // _WX_CHOICE_H_