]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: combo.h | |
968f15e2 | 3 | // Purpose: interface of wxComboCtrl and wxComboPopup |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxComboPopup | |
11 | @wxheader{combo.h} | |
7c913512 | 12 | |
968f15e2 BP |
13 | In order to use a custom popup with wxComboCtrl, an interface class must be |
14 | derived from wxComboPopup. | |
1f1d2182 | 15 | |
968f15e2 | 16 | For more information on how to use it, see @ref comboctrl_custompopup. |
7c913512 | 17 | |
23324ae1 | 18 | @library{wxcore} |
968f15e2 | 19 | @category{ctrl} |
7c913512 | 20 | |
e54c96f1 | 21 | @see wxComboCtrl |
23324ae1 | 22 | */ |
7c913512 | 23 | class wxComboPopup |
23324ae1 FM |
24 | { |
25 | public: | |
26 | /** | |
968f15e2 BP |
27 | Default constructor. It is recommended that internal variables are |
28 | prepared in Init() instead (because m_combo is not valid in | |
29 | constructor). | |
23324ae1 FM |
30 | */ |
31 | wxComboPopup(); | |
32 | ||
33 | /** | |
34 | The derived class must implement this to create the popup control. | |
3c4f71cc | 35 | |
23324ae1 FM |
36 | @returns @true if the call succeeded, @false otherwise. |
37 | */ | |
968f15e2 | 38 | virtual bool Create(wxWindow* parent); |
23324ae1 FM |
39 | |
40 | /** | |
41 | Utility function that hides the popup. | |
42 | */ | |
43 | void Dismiss(); | |
44 | ||
45 | /** | |
968f15e2 BP |
46 | The derived class may implement this to return adjusted size for the |
47 | popup control, according to the variables given. | |
3c4f71cc | 48 | |
7c913512 | 49 | @param minWidth |
4cc4bfaf | 50 | Preferred minimum width. |
7c913512 | 51 | @param prefHeight |
968f15e2 | 52 | Preferred height. May be -1 to indicate no preference. |
7c913512 | 53 | @param maxWidth |
968f15e2 | 54 | Max height for window, as limited by screen size. |
3c4f71cc | 55 | |
968f15e2 | 56 | @remarks This function is called each time popup is about to be shown. |
23324ae1 | 57 | */ |
968f15e2 | 58 | virtual wxSize GetAdjustedSize(int minWidth, int prefHeight, int maxHeight); |
23324ae1 FM |
59 | |
60 | /** | |
968f15e2 BP |
61 | The derived class must implement this to return pointer to the |
62 | associated control created in Create(). | |
23324ae1 | 63 | */ |
968f15e2 | 64 | virtual wxWindow* GetControl(); |
23324ae1 FM |
65 | |
66 | /** | |
968f15e2 BP |
67 | The derived class must implement this to return string representation |
68 | of the value. | |
23324ae1 | 69 | */ |
968f15e2 | 70 | virtual wxString GetStringValue() const; |
23324ae1 FM |
71 | |
72 | /** | |
968f15e2 BP |
73 | The derived class must implement this to initialize its internal |
74 | variables. This method is called immediately after construction | |
75 | finishes. m_combo member variable has been initialized before the call. | |
23324ae1 | 76 | */ |
968f15e2 | 77 | virtual void Init(); |
23324ae1 FM |
78 | |
79 | /** | |
80 | Utility method that returns @true if Create has been called. | |
968f15e2 | 81 | |
23324ae1 FM |
82 | Useful in conjunction with LazyCreate(). |
83 | */ | |
328f5751 | 84 | bool IsCreated() const; |
23324ae1 FM |
85 | |
86 | /** | |
968f15e2 BP |
87 | The derived class may implement this to return @true if it wants to |
88 | delay call to Create() until the popup is shown for the first time. It | |
89 | is more efficient, but on the other hand it is often more convenient to | |
90 | have the control created immediately. | |
3c4f71cc | 91 | |
23324ae1 FM |
92 | @remarks Base implementation returns @false. |
93 | */ | |
968f15e2 | 94 | virtual bool LazyCreate(); |
23324ae1 FM |
95 | |
96 | /** | |
968f15e2 BP |
97 | The derived class may implement this to do something when the parent |
98 | wxComboCtrl gets double-clicked. | |
23324ae1 | 99 | */ |
968f15e2 | 100 | virtual void OnComboDoubleClick(); |
23324ae1 FM |
101 | |
102 | /** | |
968f15e2 BP |
103 | The derived class may implement this to receive key events from the |
104 | parent wxComboCtrl. | |
105 | ||
23324ae1 FM |
106 | Events not handled should be skipped, as usual. |
107 | */ | |
968f15e2 | 108 | virtual void OnComboKeyEvent(wxKeyEvent& event); |
23324ae1 FM |
109 | |
110 | /** | |
968f15e2 BP |
111 | The derived class may implement this to do special processing when |
112 | popup is hidden. | |
23324ae1 | 113 | */ |
968f15e2 | 114 | virtual void OnDismiss(); |
23324ae1 FM |
115 | |
116 | /** | |
968f15e2 BP |
117 | The derived class may implement this to do special processing when |
118 | popup is shown. | |
23324ae1 | 119 | */ |
968f15e2 | 120 | virtual void OnPopup(); |
23324ae1 FM |
121 | |
122 | /** | |
968f15e2 BP |
123 | The derived class may implement this to paint the parent wxComboCtrl. |
124 | ||
23324ae1 FM |
125 | Default implementation draws value as string. |
126 | */ | |
968f15e2 | 127 | virtual void PaintComboControl(wxDC& dc, const wxRect& rect); |
23324ae1 FM |
128 | |
129 | /** | |
968f15e2 BP |
130 | The derived class must implement this to receive string value changes |
131 | from wxComboCtrl. | |
23324ae1 | 132 | */ |
968f15e2 | 133 | virtual void SetStringValue(const wxString& value); |
23324ae1 FM |
134 | |
135 | /** | |
968f15e2 BP |
136 | Parent wxComboCtrl. This is parameter has been prepared before Init() |
137 | is called. | |
23324ae1 | 138 | */ |
968f15e2 | 139 | wxComboCtrl m_combo; |
23324ae1 FM |
140 | }; |
141 | ||
142 | ||
e54c96f1 | 143 | |
968f15e2 BP |
144 | /** |
145 | Features enabled for wxComboCtrl. | |
146 | ||
147 | @see wxComboCtrl::GetFeatures() | |
148 | */ | |
149 | struct wxComboCtrlFeatures | |
150 | { | |
151 | enum | |
152 | { | |
153 | MovableButton = 0x0001, ///< Button can be on either side of control. | |
154 | BitmapButton = 0x0002, ///< Button may be replaced with bitmap. | |
155 | ButtonSpacing = 0x0004, ///< Button can have spacing from the edge | |
156 | ///< of the control. | |
157 | TextIndent = 0x0008, ///< wxComboCtrl::SetTextIndent() can be used. | |
158 | PaintControl = 0x0010, ///< Combo control itself can be custom painted. | |
159 | PaintWritable = 0x0020, ///< A variable-width area in front of writable | |
160 | ///< combo control's textctrl can be custom | |
161 | ///< painted. | |
162 | Borderless = 0x0040, ///< wxNO_BORDER window style works. | |
163 | ||
164 | All = MovableButton | BitmapButton | ButtonSpacing | | |
165 | TextIndent | PaintControl | PaintWritable | | |
166 | Borderless ///< All features. | |
167 | }; | |
168 | }; | |
169 | ||
170 | ||
23324ae1 FM |
171 | /** |
172 | @class wxComboCtrl | |
173 | @wxheader{combo.h} | |
7c913512 | 174 | |
968f15e2 BP |
175 | A combo control is a generic combobox that allows totally custom popup. In |
176 | addition it has other customization features. For instance, position and | |
177 | size of the dropdown button can be changed. | |
1f1d2182 | 178 | |
968f15e2 | 179 | @section comboctrl_custompopup Setting Custom Popup for wxComboCtrl |
1f1d2182 FM |
180 | |
181 | wxComboCtrl needs to be told somehow which control to use and this is done | |
968f15e2 BP |
182 | by SetPopupControl(). However, we need something more than just a wxControl |
183 | in this method as, for example, we need to call | |
184 | SetStringValue("initial text value") and wxControl doesn't have such | |
185 | method. So we also need a wxComboPopup which is an interface which must be | |
186 | implemented by a control to be usable as a popup. | |
1f1d2182 FM |
187 | |
188 | We couldn't derive wxComboPopup from wxControl as this would make it | |
189 | impossible to have a class deriving from a wxWidgets control and from it, | |
190 | so instead it is just a mix-in. | |
191 | ||
192 | Here's a minimal sample of wxListView popup: | |
193 | ||
194 | @code | |
195 | #include <wx/combo.h> | |
196 | #include <wx/listctrl.h> | |
197 | ||
968f15e2 | 198 | class wxListViewComboPopup : public wxListView, public wxComboPopup |
1f1d2182 FM |
199 | { |
200 | public: | |
1f1d2182 FM |
201 | // Initialize member variables |
202 | virtual void Init() | |
203 | { | |
204 | m_value = -1; | |
205 | } | |
206 | ||
207 | // Create popup control | |
208 | virtual bool Create(wxWindow* parent) | |
209 | { | |
210 | return wxListView::Create(parent,1,wxPoint(0,0),wxDefaultSize); | |
211 | } | |
212 | ||
213 | // Return pointer to the created control | |
214 | virtual wxWindow *GetControl() { return this; } | |
215 | ||
216 | // Translate string into a list selection | |
217 | virtual void SetStringValue(const wxString& s) | |
218 | { | |
219 | int n = wxListView::FindItem(-1,s); | |
220 | if ( n >= 0 && n < wxListView::GetItemCount() ) | |
221 | wxListView::Select(n); | |
222 | } | |
223 | ||
224 | // Get list selection as a string | |
225 | virtual wxString GetStringValue() const | |
226 | { | |
227 | if ( m_value >= 0 ) | |
968f15e2 | 228 | return wxListView::GetItemText(m_value); |
1f1d2182 FM |
229 | return wxEmptyString; |
230 | } | |
231 | ||
232 | // Do mouse hot-tracking (which is typical in list popups) | |
233 | void OnMouseMove(wxMouseEvent& event) | |
234 | { | |
235 | // TODO: Move selection to cursor | |
236 | } | |
237 | ||
238 | // On mouse left up, set the value and close the popup | |
239 | void OnMouseClick(wxMouseEvent& WXUNUSED(event)) | |
240 | { | |
241 | m_value = wxListView::GetFirstSelected(); | |
242 | ||
243 | // TODO: Send event as well | |
244 | ||
245 | Dismiss(); | |
246 | } | |
247 | ||
248 | protected: | |
968f15e2 BP |
249 | |
250 | int m_value; // current item index | |
1f1d2182 FM |
251 | |
252 | private: | |
253 | DECLARE_EVENT_TABLE() | |
254 | }; | |
255 | ||
256 | BEGIN_EVENT_TABLE(wxListViewComboPopup, wxListView) | |
257 | EVT_MOTION(wxListViewComboPopup::OnMouseMove) | |
258 | EVT_LEFT_UP(wxListViewComboPopup::OnMouseClick) | |
259 | END_EVENT_TABLE() | |
260 | @endcode | |
261 | ||
262 | Here's how you would create and populate it in a dialog constructor: | |
263 | ||
264 | @code | |
968f15e2 | 265 | wxComboCtrl* comboCtrl = new wxComboCtrl(this, wxID_ANY, wxEmptyString); |
1f1d2182 FM |
266 | |
267 | wxListViewComboPopup* popupCtrl = new wxListViewComboPopup(); | |
268 | ||
269 | comboCtrl->SetPopupControl(popupCtrl); | |
270 | ||
271 | // Populate using wxListView methods | |
968f15e2 BP |
272 | popupCtrl->InsertItem(popupCtrl->GetItemCount(), "First Item"); |
273 | popupCtrl->InsertItem(popupCtrl->GetItemCount(), "Second Item"); | |
274 | popupCtrl->InsertItem(popupCtrl->GetItemCount(), "Third Item"); | |
1f1d2182 | 275 | @endcode |
7c913512 | 276 | |
23324ae1 | 277 | @beginStyleTable |
8c6791e4 | 278 | @style{wxCB_READONLY} |
23324ae1 | 279 | Text will not be editable. |
8c6791e4 | 280 | @style{wxCB_SORT} |
23324ae1 | 281 | Sorts the entries in the list alphabetically. |
8c6791e4 | 282 | @style{wxTE_PROCESS_ENTER} |
23324ae1 FM |
283 | The control will generate the event wxEVT_COMMAND_TEXT_ENTER |
284 | (otherwise pressing Enter key is either processed internally by the | |
285 | control or used for navigation between dialog controls). Windows | |
286 | only. | |
8c6791e4 | 287 | @style{wxCC_SPECIAL_DCLICK} |
23324ae1 FM |
288 | Double-clicking triggers a call to popup's OnComboDoubleClick. |
289 | Actual behaviour is defined by a derived class. For instance, | |
290 | wxOwnerDrawnComboBox will cycle an item. This style only applies if | |
291 | wxCB_READONLY is used as well. | |
8c6791e4 | 292 | @style{wxCC_STD_BUTTON} |
23324ae1 FM |
293 | Drop button will behave more like a standard push button. |
294 | @endStyleTable | |
7c913512 | 295 | |
1f1d2182 | 296 | @beginEventTable{wxCommandEvent} |
8c6791e4 | 297 | @event{EVT_TEXT(id, func)} |
23324ae1 | 298 | Process a wxEVT_COMMAND_TEXT_UPDATED event, when the text changes. |
8c6791e4 | 299 | @event{EVT_TEXT_ENTER(id, func)} |
23324ae1 FM |
300 | Process a wxEVT_COMMAND_TEXT_ENTER event, when RETURN is pressed in |
301 | the combo control. | |
302 | @endEventTable | |
7c913512 | 303 | |
23324ae1 FM |
304 | @library{wxbase} |
305 | @category{ctrl} | |
968f15e2 | 306 | <!-- @appearance{comboctrl.png} --> |
7c913512 | 307 | |
968f15e2 BP |
308 | @see wxComboBox, wxChoice, wxOwnerDrawnComboBox, wxComboPopup, |
309 | wxCommandEvent | |
23324ae1 FM |
310 | */ |
311 | class wxComboCtrl : public wxControl | |
312 | { | |
313 | public: | |
968f15e2 BP |
314 | /** |
315 | Default constructor. | |
316 | */ | |
317 | wxComboCtrl(); | |
318 | ||
23324ae1 FM |
319 | /** |
320 | Constructor, creating and showing a combo control. | |
3c4f71cc | 321 | |
7c913512 | 322 | @param parent |
4cc4bfaf | 323 | Parent window. Must not be @NULL. |
7c913512 | 324 | @param id |
4cc4bfaf | 325 | Window identifier. The value wxID_ANY indicates a default value. |
7c913512 | 326 | @param value |
4cc4bfaf | 327 | Initial selection string. An empty string indicates no selection. |
7c913512 | 328 | @param pos |
4cc4bfaf | 329 | Window position. |
7c913512 | 330 | @param size |
968f15e2 | 331 | Window size. If wxDefaultSize is specified then the window is sized |
4cc4bfaf | 332 | appropriately. |
7c913512 | 333 | @param style |
4cc4bfaf | 334 | Window style. See wxComboCtrl. |
7c913512 | 335 | @param validator |
4cc4bfaf | 336 | Window validator. |
7c913512 | 337 | @param name |
4cc4bfaf | 338 | Window name. |
3c4f71cc | 339 | |
4cc4bfaf | 340 | @see Create(), wxValidator |
23324ae1 | 341 | */ |
7c913512 FM |
342 | wxComboCtrl(wxWindow* parent, wxWindowID id, |
343 | const wxString& value = "", | |
344 | const wxPoint& pos = wxDefaultPosition, | |
345 | const wxSize& size = wxDefaultSize, | |
346 | long style = 0, | |
347 | const wxValidator& validator = wxDefaultValidator, | |
348 | const wxString& name = "comboCtrl"); | |
23324ae1 FM |
349 | |
350 | /** | |
351 | Destructor, destroying the combo control. | |
352 | */ | |
968f15e2 | 353 | virtual ~wxComboCtrl(); |
23324ae1 FM |
354 | |
355 | /** | |
356 | This member function is not normally called in application code. | |
968f15e2 BP |
357 | Instead, it can be implemented in a derived class to create a custom |
358 | popup animation. | |
3c4f71cc | 359 | |
968f15e2 BP |
360 | The parameters are the same as those for DoShowPopup(). |
361 | ||
362 | @returns @true if animation finishes before the function returns, | |
363 | @false otherwise. In the latter case you need to manually call | |
364 | DoShowPopup() after the animation ends. | |
23324ae1 FM |
365 | */ |
366 | virtual bool AnimateShow(const wxRect& rect, int flags); | |
367 | ||
368 | /** | |
369 | Copies the selected text to the clipboard. | |
370 | */ | |
968f15e2 | 371 | virtual void Copy(); |
23324ae1 FM |
372 | |
373 | /** | |
374 | Creates the combo control for two-step construction. Derived classes | |
968f15e2 BP |
375 | should call or replace this function. See wxComboCtrl() for further |
376 | details. | |
23324ae1 FM |
377 | */ |
378 | bool Create(wxWindow* parent, wxWindowID id, | |
379 | const wxString& value = "", | |
380 | const wxPoint& pos = wxDefaultPosition, | |
381 | const wxSize& size = wxDefaultSize, | |
382 | long style = 0, | |
383 | const wxValidator& validator = wxDefaultValidator, | |
384 | const wxString& name = "comboCtrl"); | |
385 | ||
386 | /** | |
387 | Copies the selected text to the clipboard and removes the selection. | |
388 | */ | |
968f15e2 | 389 | virtual void Cut(); |
23324ae1 FM |
390 | |
391 | /** | |
392 | This member function is not normally called in application code. | |
968f15e2 BP |
393 | Instead, it can be implemented in a derived class to return default |
394 | wxComboPopup, incase @a popup is @NULL. | |
395 | ||
396 | @note If you have implemented OnButtonClick() to do something else than | |
397 | show the popup, then DoSetPopupControl() must always set @a popup | |
398 | to @NULL. | |
23324ae1 FM |
399 | */ |
400 | void DoSetPopupControl(wxComboPopup* popup); | |
401 | ||
402 | /** | |
403 | This member function is not normally called in application code. | |
968f15e2 BP |
404 | Instead, it must be called in a derived class to make sure popup is |
405 | properly shown after a popup animation has finished (but only if | |
406 | AnimateShow() did not finish the animation within its function scope). | |
3c4f71cc | 407 | |
7c913512 | 408 | @param rect |
4cc4bfaf | 409 | Position to show the popup window at, in screen coordinates. |
7c913512 | 410 | @param flags |
4cc4bfaf | 411 | Combination of any of the following: |
968f15e2 BP |
412 | @beginTable |
413 | @row2col{wxComboCtrl::ShowAbove, | |
414 | Popup is shown above the control instead of below.} | |
415 | @row2col{wxComboCtrl::CanDeferShow, | |
416 | Showing the popup can be deferred to happen sometime after | |
417 | ShowPopup() has finished. In this case, AnimateShow() must | |
418 | return false.} | |
419 | @endTable | |
23324ae1 FM |
420 | */ |
421 | virtual void DoShowPopup(const wxRect& rect, int flags); | |
422 | ||
423 | /** | |
424 | Enables or disables popup animation, if any, depending on the value of | |
425 | the argument. | |
426 | */ | |
4cc4bfaf | 427 | void EnablePopupAnimation(bool enable = true); |
23324ae1 FM |
428 | |
429 | /** | |
430 | Returns disabled button bitmap that has been set with | |
431 | SetButtonBitmaps(). | |
3c4f71cc | 432 | |
23324ae1 FM |
433 | @returns A reference to the disabled state bitmap. |
434 | */ | |
328f5751 | 435 | const wxBitmap GetBitmapDisabled() const; |
23324ae1 FM |
436 | |
437 | /** | |
438 | Returns button mouse hover bitmap that has been set with | |
439 | SetButtonBitmaps(). | |
3c4f71cc | 440 | |
23324ae1 FM |
441 | @returns A reference to the mouse hover state bitmap. |
442 | */ | |
328f5751 | 443 | const wxBitmap GetBitmapHover() const; |
23324ae1 FM |
444 | |
445 | /** | |
446 | Returns default button bitmap that has been set with | |
447 | SetButtonBitmaps(). | |
3c4f71cc | 448 | |
23324ae1 FM |
449 | @returns A reference to the normal state bitmap. |
450 | */ | |
328f5751 | 451 | const wxBitmap GetBitmapNormal() const; |
23324ae1 FM |
452 | |
453 | /** | |
454 | Returns depressed button bitmap that has been set with | |
455 | SetButtonBitmaps(). | |
3c4f71cc | 456 | |
23324ae1 FM |
457 | @returns A reference to the depressed state bitmap. |
458 | */ | |
328f5751 | 459 | const wxBitmap GetBitmapPressed() const; |
23324ae1 FM |
460 | |
461 | /** | |
462 | Returns current size of the dropdown button. | |
463 | */ | |
464 | wxSize GetButtonSize(); | |
465 | ||
466 | /** | |
467 | Returns custom painted area in control. | |
3c4f71cc | 468 | |
4cc4bfaf | 469 | @see SetCustomPaintWidth(). |
23324ae1 | 470 | */ |
328f5751 | 471 | int GetCustomPaintWidth() const; |
23324ae1 FM |
472 | |
473 | /** | |
968f15e2 BP |
474 | Returns features supported by wxComboCtrl. If needed feature is |
475 | missing, you need to instead use wxGenericComboCtrl, which however may | |
476 | lack a native look and feel (but otherwise sports identical API). | |
3c4f71cc | 477 | |
968f15e2 BP |
478 | @returns Value returned is a combination of the flags defined in |
479 | wxComboCtrlFeatures. | |
23324ae1 FM |
480 | */ |
481 | static int GetFeatures(); | |
482 | ||
483 | /** | |
484 | Returns the insertion point for the combo control's text field. | |
968f15e2 BP |
485 | |
486 | @note Under Windows, this function always returns 0 if the combo | |
487 | control doesn't have the focus. | |
23324ae1 | 488 | */ |
968f15e2 | 489 | virtual long GetInsertionPoint() const; |
23324ae1 FM |
490 | |
491 | /** | |
492 | Returns the last position in the combo control text field. | |
493 | */ | |
968f15e2 | 494 | virtual long GetLastPosition() const; |
23324ae1 FM |
495 | |
496 | /** | |
968f15e2 BP |
497 | Returns current popup interface that has been set with |
498 | SetPopupControl(). | |
23324ae1 FM |
499 | */ |
500 | wxComboPopup* GetPopupControl(); | |
501 | ||
502 | /** | |
503 | Returns popup window containing the popup control. | |
504 | */ | |
328f5751 | 505 | wxWindow* GetPopupWindow() const; |
23324ae1 FM |
506 | |
507 | /** | |
508 | Get the text control which is part of the combo control. | |
509 | */ | |
328f5751 | 510 | wxTextCtrl* GetTextCtrl() const; |
23324ae1 FM |
511 | |
512 | /** | |
513 | Returns actual indentation in pixels. | |
514 | */ | |
328f5751 | 515 | wxCoord GetTextIndent() const; |
23324ae1 FM |
516 | |
517 | /** | |
518 | Returns area covered by the text field (includes everything except | |
519 | borders and the dropdown button). | |
520 | */ | |
328f5751 | 521 | const wxRect GetTextRect() const; |
23324ae1 FM |
522 | |
523 | /** | |
968f15e2 BP |
524 | Returns text representation of the current value. For writable combo |
525 | control it always returns the value in the text field. | |
23324ae1 | 526 | */ |
968f15e2 | 527 | virtual wxString GetValue() const; |
23324ae1 FM |
528 | |
529 | /** | |
530 | Dismisses the popup window. | |
531 | */ | |
968f15e2 | 532 | virtual void HidePopup(); |
23324ae1 FM |
533 | |
534 | /** | |
535 | Returns @true if the popup is currently shown | |
536 | */ | |
328f5751 | 537 | bool IsPopupShown() const; |
23324ae1 FM |
538 | |
539 | /** | |
968f15e2 BP |
540 | Returns @true if the popup window is in the given state. Possible |
541 | values are: | |
3c4f71cc | 542 | |
968f15e2 BP |
543 | @beginTable |
544 | @row2col{wxComboCtrl::Hidden, Popup window is hidden.} | |
545 | @row2col{wxComboCtrl::Animating, Popup window is being shown, but the | |
546 | popup animation has not yet finished.} | |
547 | @row2col{wxComboCtrl::Visible, Popup window is fully visible.} | |
548 | @endTable | |
23324ae1 | 549 | */ |
328f5751 | 550 | bool IsPopupWindowState(int state) const; |
23324ae1 FM |
551 | |
552 | /** | |
968f15e2 BP |
553 | Implement in a derived class to define what happens on dropdown button |
554 | click. Default action is to show the popup. | |
555 | ||
556 | @note If you implement this to do something else than show the popup, | |
557 | you must then also implement DoSetPopupControl() to always return | |
558 | @NULL. | |
23324ae1 | 559 | */ |
968f15e2 | 560 | virtual void OnButtonClick(); |
23324ae1 FM |
561 | |
562 | /** | |
563 | Pastes text from the clipboard to the text field. | |
564 | */ | |
968f15e2 | 565 | virtual void Paste(); |
23324ae1 FM |
566 | |
567 | /** | |
968f15e2 BP |
568 | Removes the text between the two positions in the combo control text |
569 | field. | |
3c4f71cc | 570 | |
7c913512 | 571 | @param from |
4cc4bfaf | 572 | The first position. |
7c913512 | 573 | @param to |
4cc4bfaf | 574 | The last position. |
23324ae1 | 575 | */ |
968f15e2 | 576 | virtual void Remove(long from, long to); |
23324ae1 FM |
577 | |
578 | /** | |
968f15e2 BP |
579 | Replaces the text between two positions with the given text, in the |
580 | combo control text field. | |
3c4f71cc | 581 | |
7c913512 | 582 | @param from |
4cc4bfaf | 583 | The first position. |
7c913512 | 584 | @param to |
4cc4bfaf | 585 | The second position. |
7c913512 | 586 | @param text |
4cc4bfaf | 587 | The text to insert. |
23324ae1 | 588 | */ |
968f15e2 | 589 | virtual void Replace(long from, long to, const wxString& value); |
23324ae1 FM |
590 | |
591 | /** | |
592 | Sets custom dropdown button graphics. | |
3c4f71cc | 593 | |
7c913512 | 594 | @param bmpNormal |
4cc4bfaf | 595 | Default button image. |
7c913512 | 596 | @param pushButtonBg |
968f15e2 | 597 | If @true, blank push button background is painted below the image. |
7c913512 | 598 | @param bmpPressed |
4cc4bfaf | 599 | Depressed button image. |
7c913512 | 600 | @param bmpHover |
968f15e2 BP |
601 | Button image when mouse hovers above it. This should be ignored on |
602 | platforms and themes that do not generally draw different kind of | |
603 | button on mouse hover. | |
7c913512 | 604 | @param bmpDisabled |
4cc4bfaf | 605 | Disabled button image. |
23324ae1 FM |
606 | */ |
607 | void SetButtonBitmaps(const wxBitmap& bmpNormal, | |
4cc4bfaf | 608 | bool pushButtonBg = false, |
23324ae1 FM |
609 | const wxBitmap& bmpPressed = wxNullBitmap, |
610 | const wxBitmap& bmpHover = wxNullBitmap, | |
611 | const wxBitmap& bmpDisabled = wxNullBitmap); | |
612 | ||
613 | /** | |
614 | Sets size and position of dropdown button. | |
3c4f71cc | 615 | |
7c913512 | 616 | @param width |
4cc4bfaf | 617 | Button width. Value = 0 specifies default. |
7c913512 | 618 | @param height |
4cc4bfaf | 619 | Button height. Value = 0 specifies default. |
7c913512 | 620 | @param side |
968f15e2 BP |
621 | Indicates which side the button will be placed. Value can be wxLEFT |
622 | or wxRIGHT. | |
7c913512 | 623 | @param spacingX |
4cc4bfaf | 624 | Horizontal spacing around the button. Default is 0. |
23324ae1 FM |
625 | */ |
626 | void SetButtonPosition(int width = -1, int height = -1, | |
968f15e2 | 627 | int side = wxRIGHT, int spacingX = 0); |
23324ae1 FM |
628 | |
629 | /** | |
968f15e2 BP |
630 | Set width, in pixels, of custom painted area in control without |
631 | @c wxCB_READONLY style. In read-only wxOwnerDrawnComboBox, this is used | |
23324ae1 FM |
632 | to indicate area that is not covered by the focus rectangle. |
633 | */ | |
634 | void SetCustomPaintWidth(int width); | |
635 | ||
636 | /** | |
637 | Sets the insertion point in the text field. | |
3c4f71cc | 638 | |
7c913512 | 639 | @param pos |
4cc4bfaf | 640 | The new insertion point. |
23324ae1 | 641 | */ |
968f15e2 | 642 | virtual void SetInsertionPoint(long pos); |
23324ae1 FM |
643 | |
644 | /** | |
645 | Sets the insertion point at the end of the combo control text field. | |
646 | */ | |
968f15e2 | 647 | virtual void SetInsertionPointEnd(); |
23324ae1 FM |
648 | |
649 | /** | |
968f15e2 BP |
650 | Set side of the control to which the popup will align itself. Valid |
651 | values are @c wxLEFT, @c wxRIGHT and 0. The default value 0 means that | |
652 | the most appropriate side is used (which, currently, is always | |
653 | @c wxLEFT). | |
23324ae1 FM |
654 | */ |
655 | void SetPopupAnchor(int anchorSide); | |
656 | ||
657 | /** | |
968f15e2 BP |
658 | Set popup interface class derived from wxComboPopup. This method should |
659 | be called as soon as possible after the control has been created, | |
660 | unless OnButtonClick() has been overridden. | |
23324ae1 FM |
661 | */ |
662 | void SetPopupControl(wxComboPopup* popup); | |
663 | ||
664 | /** | |
968f15e2 BP |
665 | Extends popup size horizontally, relative to the edges of the combo |
666 | control. | |
3c4f71cc | 667 | |
7c913512 | 668 | @param extLeft |
968f15e2 BP |
669 | How many pixel to extend beyond the left edge of the control. |
670 | Default is 0. | |
7c913512 | 671 | @param extRight |
968f15e2 BP |
672 | How many pixel to extend beyond the right edge of the control. |
673 | Default is 0. | |
3c4f71cc | 674 | |
968f15e2 BP |
675 | @remarks Popup minimum width may override arguments. It is up to the |
676 | popup to fully take this into account. | |
23324ae1 FM |
677 | */ |
678 | void SetPopupExtents(int extLeft, int extRight); | |
679 | ||
680 | /** | |
681 | Sets preferred maximum height of the popup. | |
3c4f71cc | 682 | |
23324ae1 FM |
683 | @remarks Value -1 indicates the default. |
684 | */ | |
685 | void SetPopupMaxHeight(int height); | |
686 | ||
687 | /** | |
968f15e2 BP |
688 | Sets minimum width of the popup. If wider than combo control, it will |
689 | extend to the left. | |
3c4f71cc | 690 | |
968f15e2 BP |
691 | @remarks Value -1 indicates the default. Also, popup implementation may |
692 | choose to ignore this. | |
23324ae1 FM |
693 | */ |
694 | void SetPopupMinWidth(int width); | |
695 | ||
696 | /** | |
968f15e2 BP |
697 | Selects the text between the two positions, in the combo control text |
698 | field. | |
3c4f71cc | 699 | |
7c913512 | 700 | @param from |
4cc4bfaf | 701 | The first position. |
7c913512 | 702 | @param to |
4cc4bfaf | 703 | The second position. |
23324ae1 | 704 | */ |
968f15e2 | 705 | virtual void SetSelection(long from, long to); |
23324ae1 FM |
706 | |
707 | /** | |
968f15e2 BP |
708 | Sets the text for the text field without affecting the popup. Thus, |
709 | unlike SetValue(), it works equally well with combo control using | |
710 | @c wxCB_READONLY style. | |
23324ae1 FM |
711 | */ |
712 | void SetText(const wxString& value); | |
713 | ||
714 | /** | |
968f15e2 BP |
715 | This will set the space in pixels between left edge of the control and |
716 | the text, regardless whether control is read-only or not. Value -1 can | |
717 | be given to indicate platform default. | |
23324ae1 FM |
718 | */ |
719 | void SetTextIndent(int indent); | |
720 | ||
721 | /** | |
722 | Sets the text for the combo control text field. | |
968f15e2 BP |
723 | |
724 | @note For a combo control with @c wxCB_READONLY style the string must | |
725 | be accepted by the popup (for instance, exist in the dropdown | |
726 | list), otherwise the call to SetValue() is ignored. | |
23324ae1 | 727 | */ |
968f15e2 | 728 | virtual void SetValue(const wxString& value); |
23324ae1 FM |
729 | |
730 | /** | |
968f15e2 BP |
731 | Same as SetValue(), but also sends wxCommandEvent of type |
732 | wxEVT_COMMAND_TEXT_UPDATED if @a withEvent is @true. | |
23324ae1 | 733 | */ |
968f15e2 | 734 | void SetValueWithEvent(const wxString& value, bool withEvent = true); |
23324ae1 FM |
735 | |
736 | /** | |
737 | Show the popup. | |
738 | */ | |
968f15e2 | 739 | virtual void ShowPopup(); |
23324ae1 FM |
740 | |
741 | /** | |
742 | Undoes the last edit in the text field. Windows only. | |
743 | */ | |
968f15e2 | 744 | virtual void Undo(); |
23324ae1 FM |
745 | |
746 | /** | |
968f15e2 BP |
747 | Enable or disable usage of an alternative popup window, which |
748 | guarantees ability to focus the popup control, and allows common native | |
749 | controls to function normally. This alternative popup window is usually | |
750 | a wxDialog, and as such, when it is shown, its parent top-level window | |
751 | will appear as if the focus has been lost from it. | |
23324ae1 | 752 | */ |
4cc4bfaf | 753 | void UseAltPopupWindow(bool enable = true); |
23324ae1 | 754 | }; |
e54c96f1 | 755 |