1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/choice.h
3 // Purpose: wxChoice class
4 // Author: Julian Smart
5 // Modified by: Vadim Zeitlin to derive from wxChoiceBase
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
14 struct tagCOMBOBOXINFO
;
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 class WXDLLIMPEXP_CORE wxChoice
: public wxChoiceBase
24 wxChoice() { Init(); }
27 wxChoice(wxWindow
*parent
,
29 const wxPoint
& pos
= wxDefaultPosition
,
30 const wxSize
& size
= wxDefaultSize
,
31 int n
= 0, const wxString choices
[] = NULL
,
33 const wxValidator
& validator
= wxDefaultValidator
,
34 const wxString
& name
= wxChoiceNameStr
)
37 Create(parent
, id
, pos
, size
, n
, choices
, style
, validator
, name
);
40 wxChoice(wxWindow
*parent
,
44 const wxArrayString
& choices
,
46 const wxValidator
& validator
= wxDefaultValidator
,
47 const wxString
& name
= wxChoiceNameStr
)
50 Create(parent
, id
, pos
, size
, choices
, style
, validator
, name
);
53 bool Create(wxWindow
*parent
,
55 const wxPoint
& pos
= wxDefaultPosition
,
56 const wxSize
& size
= wxDefaultSize
,
57 int n
= 0, const wxString choices
[] = NULL
,
59 const wxValidator
& validator
= wxDefaultValidator
,
60 const wxString
& name
= wxChoiceNameStr
);
61 bool Create(wxWindow
*parent
,
65 const wxArrayString
& choices
,
67 const wxValidator
& validator
= wxDefaultValidator
,
68 const wxString
& name
= wxChoiceNameStr
);
70 virtual bool Show(bool show
= true);
72 virtual void SetLabel(const wxString
& label
);
74 virtual unsigned int GetCount() const;
75 virtual int GetSelection() const;
76 virtual int GetCurrentSelection() const;
77 virtual void SetSelection(int n
);
79 virtual int FindString(const wxString
& s
, bool bCase
= false) const;
80 virtual wxString
GetString(unsigned int n
) const;
81 virtual void SetString(unsigned int n
, const wxString
& s
);
83 virtual wxVisualAttributes
GetDefaultAttributes() const
85 return GetClassDefaultAttributes(GetWindowVariant());
88 static wxVisualAttributes
89 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
92 virtual bool MSWCommand(WXUINT param
, WXWORD id
);
93 WXLRESULT
MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
94 virtual WXHBRUSH
MSWControlColor(WXHDC hDC
, WXHWND hWnd
);
95 virtual bool MSWShouldPreProcessMessage(WXMSG
*pMsg
);
96 virtual WXDWORD
MSWGetStyle(long style
, WXDWORD
*exstyle
) const;
98 // returns true if the platform should explicitly apply a theme border
99 virtual bool CanApplyThemeBorder() const { return false; }
102 // choose the default border for this window
103 virtual wxBorder
GetDefaultBorder() const { return wxBORDER_NONE
; }
105 // common part of all ctors
108 m_lastAcceptedSelection
=
109 m_pendingSelection
= 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 // These variables are only used while the drop down is opened.
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
,
173 // the height of the control itself if it was set explicitly or
174 // wxDefaultCoord if it hadn't
177 DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoice
)
180 #endif // _WX_CHOICE_H_