]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/choice.h
fix wxBitmapComboBox Gtk-CRITICAL assertion `GTK_IS_ENTRY (entry)' failed
[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
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
df74e2d2
VZ
15struct tagCOMBOBOXINFO;
16
8d99be5f 17// ----------------------------------------------------------------------------
2bda0e17 18// Choice item
8d99be5f
VZ
19// ----------------------------------------------------------------------------
20
53a2db12 21class WXDLLIMPEXP_CORE wxChoice : public wxChoiceBase
2bda0e17 22{
bfc6fde4 23public:
8d99be5f 24 // ctors
6ba93d23 25 wxChoice() { Init(); }
8ee9d618 26 virtual ~wxChoice();
8d99be5f
VZ
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,
6463b9f5
JS
35 const wxString& name = wxChoiceNameStr)
36 {
94500b32 37 Init();
6463b9f5
JS
38 Create(parent, id, pos, size, n, choices, style, validator, name);
39 }
6ba93d23 40
584ad2a3
MB
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 {
94500b32 50 Init();
584ad2a3
MB
51 Create(parent, id, pos, size, choices, style, validator, name);
52 }
bfc6fde4 53
8d99be5f
VZ
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);
584ad2a3
MB
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);
8d99be5f 70
e911dd0a
VZ
71 virtual bool Show(bool show = true);
72
5de69dd3
VZ
73 virtual void SetLabel(const wxString& label);
74
aa61d352 75 virtual unsigned int GetCount() const;
8d99be5f 76 virtual int GetSelection() const;
6ba93d23 77 virtual int GetCurrentSelection() const;
bfc6fde4 78 virtual void SetSelection(int n);
bfc6fde4 79
853dcc57 80 virtual int FindString(const wxString& s, bool bCase = false) const;
aa61d352
VZ
81 virtual wxString GetString(unsigned int n) const;
82 virtual void SetString(unsigned int n, const wxString& s);
bfc6fde4 83
2ec335db
JS
84 virtual wxVisualAttributes GetDefaultAttributes() const
85 {
86 return GetClassDefaultAttributes(GetWindowVariant());
87 }
88
89 static wxVisualAttributes
90 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
91
8d99be5f 92 // MSW only
bfc6fde4 93 virtual bool MSWCommand(WXUINT param, WXWORD id);
c140b7e7 94 WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
2bae4332 95 virtual WXHBRUSH MSWControlColor(WXHDC hDC, WXHWND hWnd);
6f02a879
VZ
96 virtual bool MSWShouldPreProcessMessage(WXMSG *pMsg);
97 virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
bbcdf8bc 98
a047aff2
JS
99 // returns true if the platform should explicitly apply a theme border
100 virtual bool CanApplyThemeBorder() const { return false; }
101
bbcdf8bc 102protected:
dc797d8e
JS
103 // choose the default border for this window
104 virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
105
6ba93d23 106 // common part of all ctors
75004dfb
VZ
107 void Init()
108 {
109 m_lastAcceptedSelection = wxID_NONE;
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
VZ
164
165 // last "completed" selection, i.e. not the transient one while the user is
166 // browsing the popup list: this is only used when != wxID_NONE which is
167 // the case while the drop down is opened
168 int m_lastAcceptedSelection;
169
75004dfb
VZ
170 // the height of the control itself if it was set explicitly or
171 // wxDefaultCoord if it hadn't
172 int m_heightOwn;
6ba93d23 173
fc7a2a60 174 DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoice)
2bda0e17
KB
175};
176
8d99be5f 177#endif // _WX_CHOICE_H_