1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/choice.h
3 // Purpose: wxChoice class
4 // Author: Julian Smart
5 // Modified by: Vadim Zeitlin to derive from wxChoiceBase
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 struct tagCOMBOBOXINFO
;
17 // ----------------------------------------------------------------------------
19 // ----------------------------------------------------------------------------
21 class WXDLLIMPEXP_CORE wxChoice
: public wxChoiceBase
25 wxChoice() { Init(); }
28 wxChoice(wxWindow
*parent
,
30 const wxPoint
& pos
= wxDefaultPosition
,
31 const wxSize
& size
= wxDefaultSize
,
32 int n
= 0, const wxString choices
[] = NULL
,
34 const wxValidator
& validator
= wxDefaultValidator
,
35 const wxString
& name
= wxChoiceNameStr
)
38 Create(parent
, id
, pos
, size
, n
, choices
, style
, validator
, name
);
41 wxChoice(wxWindow
*parent
,
45 const wxArrayString
& choices
,
47 const wxValidator
& validator
= wxDefaultValidator
,
48 const wxString
& name
= wxChoiceNameStr
)
51 Create(parent
, id
, pos
, size
, choices
, style
, validator
, name
);
54 bool Create(wxWindow
*parent
,
56 const wxPoint
& pos
= wxDefaultPosition
,
57 const wxSize
& size
= wxDefaultSize
,
58 int n
= 0, const wxString choices
[] = NULL
,
60 const wxValidator
& validator
= wxDefaultValidator
,
61 const wxString
& name
= wxChoiceNameStr
);
62 bool Create(wxWindow
*parent
,
66 const wxArrayString
& choices
,
68 const wxValidator
& validator
= wxDefaultValidator
,
69 const wxString
& name
= wxChoiceNameStr
);
71 virtual bool Show(bool show
= true);
73 virtual void SetLabel(const wxString
& label
);
75 virtual unsigned int GetCount() const;
76 virtual int GetSelection() const;
77 virtual int GetCurrentSelection() const;
78 virtual void SetSelection(int n
);
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
);
84 virtual wxVisualAttributes
GetDefaultAttributes() const
86 return GetClassDefaultAttributes(GetWindowVariant());
89 static wxVisualAttributes
90 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
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;
99 // returns true if the platform should explicitly apply a theme border
100 virtual bool CanApplyThemeBorder() const { return false; }
103 // choose the default border for this window
104 virtual wxBorder
GetDefaultBorder() const { return wxBORDER_NONE
; }
106 // common part of all ctors
109 m_lastAcceptedSelection
= wxID_NONE
;
110 m_heightOwn
= wxDefaultCoord
;
113 virtual void DoDeleteOneItem(unsigned int n
);
114 virtual void DoClear();
116 virtual int DoInsertItems(const wxArrayStringsAdapter
& items
,
118 void **clientData
, wxClientDataType type
);
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;
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;
132 // Show or hide the popup part of the control.
133 void MSWDoPopupOrDismiss(bool show
);
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();
139 // set the height of the visible part of the control to m_heightOwn
140 void MSWUpdateVisibleHeight();
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;
146 // create and initialize the control
147 bool CreateAndInit(wxWindow
*parent
, wxWindowID id
,
150 int n
, const wxString choices
[],
152 const wxValidator
& validator
,
153 const wxString
& name
);
155 // free all memory we have (used by Clear() and dtor)
158 // set the height for simple combo box
159 int SetHeightSimpleComboBox(int nItems
) const;
161 #if wxUSE_DEFERRED_SIZING
162 virtual void MSWEndDeferWindowPos();
163 #endif // wxUSE_DEFERRED_SIZING
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
;
170 // the height of the control itself if it was set explicitly or
171 // wxDefaultCoord if it hadn't
174 DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoice
)
177 #endif // _WX_CHOICE_H_