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 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 class WXDLLIMPEXP_CORE wxChoice
: public wxChoiceBase
23 wxChoice() { Init(); }
26 wxChoice(wxWindow
*parent
,
28 const wxPoint
& pos
= wxDefaultPosition
,
29 const wxSize
& size
= wxDefaultSize
,
30 int n
= 0, const wxString choices
[] = NULL
,
32 const wxValidator
& validator
= wxDefaultValidator
,
33 const wxString
& name
= wxChoiceNameStr
)
36 Create(parent
, id
, pos
, size
, n
, choices
, style
, validator
, name
);
39 wxChoice(wxWindow
*parent
,
43 const wxArrayString
& choices
,
45 const wxValidator
& validator
= wxDefaultValidator
,
46 const wxString
& name
= wxChoiceNameStr
)
49 Create(parent
, id
, pos
, size
, choices
, style
, validator
, name
);
52 bool Create(wxWindow
*parent
,
54 const wxPoint
& pos
= wxDefaultPosition
,
55 const wxSize
& size
= wxDefaultSize
,
56 int n
= 0, const wxString choices
[] = NULL
,
58 const wxValidator
& validator
= wxDefaultValidator
,
59 const wxString
& name
= wxChoiceNameStr
);
60 bool Create(wxWindow
*parent
,
64 const wxArrayString
& choices
,
66 const wxValidator
& validator
= wxDefaultValidator
,
67 const wxString
& name
= wxChoiceNameStr
);
69 virtual bool Show(bool show
= true);
71 virtual void SetLabel(const wxString
& label
);
73 virtual unsigned int GetCount() const;
74 virtual int GetSelection() const;
75 virtual int GetCurrentSelection() const;
76 virtual void SetSelection(int n
);
78 virtual int FindString(const wxString
& s
, bool bCase
= false) const;
79 virtual wxString
GetString(unsigned int n
) const;
80 virtual void SetString(unsigned int n
, const wxString
& s
);
82 virtual wxVisualAttributes
GetDefaultAttributes() const
84 return GetClassDefaultAttributes(GetWindowVariant());
87 static wxVisualAttributes
88 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
91 virtual bool MSWCommand(WXUINT param
, WXWORD id
);
92 WXLRESULT
MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
93 virtual WXHBRUSH
MSWControlColor(WXHDC hDC
, WXHWND hWnd
);
94 virtual bool MSWShouldPreProcessMessage(WXMSG
*pMsg
);
95 virtual WXDWORD
MSWGetStyle(long style
, WXDWORD
*exstyle
) const;
97 // returns true if the platform should explicitly apply a theme border
98 virtual bool CanApplyThemeBorder() const { return false; }
101 // choose the default border for this window
102 virtual wxBorder
GetDefaultBorder() const { return wxBORDER_NONE
; }
104 // common part of all ctors
107 m_lastAcceptedSelection
= wxID_NONE
;
108 m_heightOwn
= wxDefaultCoord
;
111 virtual void DoDeleteOneItem(unsigned int n
);
112 virtual void DoClear();
114 virtual int DoInsertItems(const wxArrayStringsAdapter
& items
,
116 void **clientData
, wxClientDataType type
);
118 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
119 virtual void DoSetItemClientData(unsigned int n
, void* clientData
);
120 virtual void* DoGetItemClientData(unsigned int n
) const;
122 // MSW implementation
123 virtual wxSize
DoGetBestSize() const;
124 virtual void DoGetSize(int *w
, int *h
) const;
125 virtual void DoSetSize(int x
, int y
,
126 int width
, int height
,
127 int sizeFlags
= wxSIZE_AUTO
);
129 // Show or hide the popup part of the control.
130 void MSWDoPopupOrDismiss(bool show
);
132 // update the height of the drop down list to fit the number of items we
133 // have (without changing the visible height)
134 void MSWUpdateDropDownHeight();
136 // set the height of the visible part of the control to m_heightOwn
137 void MSWUpdateVisibleHeight();
139 // create and initialize the control
140 bool CreateAndInit(wxWindow
*parent
, wxWindowID id
,
143 int n
, const wxString choices
[],
145 const wxValidator
& validator
,
146 const wxString
& name
);
148 // free all memory we have (used by Clear() and dtor)
151 // set the height for simple combo box
152 int SetHeightSimpleComboBox(int nItems
) const;
154 #if wxUSE_DEFERRED_SIZING
155 virtual void MSWEndDeferWindowPos();
156 #endif // wxUSE_DEFERRED_SIZING
158 // last "completed" selection, i.e. not the transient one while the user is
159 // browsing the popup list: this is only used when != wxID_NONE which is
160 // the case while the drop down is opened
161 int m_lastAcceptedSelection
;
163 // the height of the control itself if it was set explicitly or
164 // wxDefaultCoord if it hadn't
167 DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoice
)
170 #endif // _WX_CHOICE_H_