]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/combo.h
Fix html documentation warnings.
[wxWidgets.git] / interface / wx / combo.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: combo.h
968f15e2 3// Purpose: interface of wxComboCtrl and wxComboPopup
23324ae1 4// Author: wxWidgets team
526954c5 5// Licence: wxWindows licence
23324ae1
FM
6/////////////////////////////////////////////////////////////////////////////
7
f15e6487
RD
8//
9// New window styles for wxComboCtrlBase
10//
11enum
12{
13 // Double-clicking a read-only combo triggers call to popup's OnComboPopup.
14 // In wxOwnerDrawnComboBox, for instance, it cycles item.
15 wxCC_SPECIAL_DCLICK = 0x0100,
16
17 // Dropbutton acts like standard push button.
18 wxCC_STD_BUTTON = 0x0200
19};
20
21
23324ae1
FM
22/**
23 @class wxComboPopup
7c913512 24
968f15e2
BP
25 In order to use a custom popup with wxComboCtrl, an interface class must be
26 derived from wxComboPopup.
1f1d2182 27
968f15e2 28 For more information on how to use it, see @ref comboctrl_custompopup.
7c913512 29
23324ae1 30 @library{wxcore}
968f15e2 31 @category{ctrl}
7c913512 32
e54c96f1 33 @see wxComboCtrl
23324ae1 34*/
7c913512 35class wxComboPopup
23324ae1
FM
36{
37public:
38 /**
968f15e2
BP
39 Default constructor. It is recommended that internal variables are
40 prepared in Init() instead (because m_combo is not valid in
41 constructor).
23324ae1
FM
42 */
43 wxComboPopup();
44
45 /**
46 The derived class must implement this to create the popup control.
3c4f71cc 47
d29a9a8a 48 @return @true if the call succeeded, @false otherwise.
23324ae1 49 */
b91c4601 50 virtual bool Create(wxWindow* parent) = 0;
23324ae1 51
df3c4a42
JS
52 /**
53 You only need to implement this member function if you create
54 your popup class in non-standard way. The default implementation can
55 handle both multiple-inherited popup control (as seen in wxComboCtrl
56 samples) and one allocated separately in heap.
1d037f6c
JS
57
58 If you do completely re-implement this function, make sure it calls
59 Destroy() for the popup control and also deletes @a this object
60 (usually as the last thing).
df3c4a42
JS
61 */
62 virtual void DestroyPopup();
63
23324ae1
FM
64 /**
65 Utility function that hides the popup.
66 */
67 void Dismiss();
68
238b33ab
JS
69 /**
70 Implement to customize matching of value string to an item container
71 entry.
72
73 @param item
74 String entered, usually by user or from SetValue() call.
75
76 @param trueItem
77 When item matches an entry, but the entry's string representation
78 is not exactly the same (case mismatch, for example), then the
79 true item string should be written back to here, if it is not
80 a NULL pointer.
81
82 @remarks
83 Default implementation always return true and does not alter
84 trueItem.
85 */
86 virtual bool FindItem(const wxString& item, wxString* trueItem=NULL);
87
23324ae1 88 /**
968f15e2
BP
89 The derived class may implement this to return adjusted size for the
90 popup control, according to the variables given.
3c4f71cc 91
7c913512 92 @param minWidth
4cc4bfaf 93 Preferred minimum width.
7c913512 94 @param prefHeight
968f15e2 95 Preferred height. May be -1 to indicate no preference.
45a591fa 96 @param maxHeight
968f15e2 97 Max height for window, as limited by screen size.
3c4f71cc 98
968f15e2 99 @remarks This function is called each time popup is about to be shown.
23324ae1 100 */
968f15e2 101 virtual wxSize GetAdjustedSize(int minWidth, int prefHeight, int maxHeight);
23324ae1 102
8c61a9ea
JS
103 /**
104 Returns pointer to the associated parent wxComboCtrl.
105 */
106 wxComboCtrl* GetComboCtrl() const;
107
23324ae1 108 /**
968f15e2
BP
109 The derived class must implement this to return pointer to the
110 associated control created in Create().
23324ae1 111 */
b91c4601 112 virtual wxWindow* GetControl() = 0;
23324ae1
FM
113
114 /**
968f15e2
BP
115 The derived class must implement this to return string representation
116 of the value.
23324ae1 117 */
b91c4601 118 virtual wxString GetStringValue() const = 0;
23324ae1
FM
119
120 /**
968f15e2
BP
121 The derived class must implement this to initialize its internal
122 variables. This method is called immediately after construction
123 finishes. m_combo member variable has been initialized before the call.
23324ae1 124 */
968f15e2 125 virtual void Init();
23324ae1
FM
126
127 /**
128 Utility method that returns @true if Create has been called.
968f15e2 129
23324ae1
FM
130 Useful in conjunction with LazyCreate().
131 */
328f5751 132 bool IsCreated() const;
238b33ab 133
23324ae1 134 /**
968f15e2
BP
135 The derived class may implement this to return @true if it wants to
136 delay call to Create() until the popup is shown for the first time. It
137 is more efficient, but on the other hand it is often more convenient to
138 have the control created immediately.
3c4f71cc 139
23324ae1
FM
140 @remarks Base implementation returns @false.
141 */
968f15e2 142 virtual bool LazyCreate();
23324ae1
FM
143
144 /**
968f15e2
BP
145 The derived class may implement this to do something when the parent
146 wxComboCtrl gets double-clicked.
23324ae1 147 */
968f15e2 148 virtual void OnComboDoubleClick();
23324ae1
FM
149
150 /**
968f15e2
BP
151 The derived class may implement this to receive key events from the
152 parent wxComboCtrl.
153
23324ae1
FM
154 Events not handled should be skipped, as usual.
155 */
968f15e2 156 virtual void OnComboKeyEvent(wxKeyEvent& event);
23324ae1
FM
157
158 /**
968f15e2
BP
159 The derived class may implement this to do special processing when
160 popup is hidden.
23324ae1 161 */
968f15e2 162 virtual void OnDismiss();
23324ae1
FM
163
164 /**
968f15e2
BP
165 The derived class may implement this to do special processing when
166 popup is shown.
23324ae1 167 */
968f15e2 168 virtual void OnPopup();
23324ae1
FM
169
170 /**
968f15e2
BP
171 The derived class may implement this to paint the parent wxComboCtrl.
172
23324ae1
FM
173 Default implementation draws value as string.
174 */
968f15e2 175 virtual void PaintComboControl(wxDC& dc, const wxRect& rect);
23324ae1
FM
176
177 /**
968f15e2
BP
178 The derived class must implement this to receive string value changes
179 from wxComboCtrl.
23324ae1 180 */
968f15e2 181 virtual void SetStringValue(const wxString& value);
23324ae1 182
1fc5f383 183protected:
23324ae1 184 /**
1fc5f383
JS
185 Parent wxComboCtrl. This member variable is prepared automatically
186 before Init() is called.
23324ae1 187 */
1fc5f383 188 wxComboCtrl* m_combo;
23324ae1
FM
189};
190
191
e54c96f1 192
968f15e2
BP
193/**
194 Features enabled for wxComboCtrl.
195
196 @see wxComboCtrl::GetFeatures()
197*/
198struct wxComboCtrlFeatures
199{
200 enum
201 {
202 MovableButton = 0x0001, ///< Button can be on either side of control.
203 BitmapButton = 0x0002, ///< Button may be replaced with bitmap.
204 ButtonSpacing = 0x0004, ///< Button can have spacing from the edge
205 ///< of the control.
0847e36e 206 TextIndent = 0x0008, ///< wxComboCtrl::SetMargins() can be used.
968f15e2
BP
207 PaintControl = 0x0010, ///< Combo control itself can be custom painted.
208 PaintWritable = 0x0020, ///< A variable-width area in front of writable
209 ///< combo control's textctrl can be custom
210 ///< painted.
211 Borderless = 0x0040, ///< wxNO_BORDER window style works.
212
213 All = MovableButton | BitmapButton | ButtonSpacing |
214 TextIndent | PaintControl | PaintWritable |
215 Borderless ///< All features.
216 };
217};
218
219
23324ae1
FM
220/**
221 @class wxComboCtrl
7c913512 222
968f15e2
BP
223 A combo control is a generic combobox that allows totally custom popup. In
224 addition it has other customization features. For instance, position and
225 size of the dropdown button can be changed.
1f1d2182 226
968f15e2 227 @section comboctrl_custompopup Setting Custom Popup for wxComboCtrl
1f1d2182
FM
228
229 wxComboCtrl needs to be told somehow which control to use and this is done
968f15e2
BP
230 by SetPopupControl(). However, we need something more than just a wxControl
231 in this method as, for example, we need to call
232 SetStringValue("initial text value") and wxControl doesn't have such
233 method. So we also need a wxComboPopup which is an interface which must be
234 implemented by a control to be usable as a popup.
1f1d2182
FM
235
236 We couldn't derive wxComboPopup from wxControl as this would make it
237 impossible to have a class deriving from a wxWidgets control and from it,
238 so instead it is just a mix-in.
239
240 Here's a minimal sample of wxListView popup:
241
242 @code
243 #include <wx/combo.h>
244 #include <wx/listctrl.h>
245
968f15e2 246 class wxListViewComboPopup : public wxListView, public wxComboPopup
1f1d2182
FM
247 {
248 public:
1f1d2182
FM
249 // Initialize member variables
250 virtual void Init()
251 {
252 m_value = -1;
253 }
254
255 // Create popup control
256 virtual bool Create(wxWindow* parent)
257 {
258 return wxListView::Create(parent,1,wxPoint(0,0),wxDefaultSize);
259 }
260
261 // Return pointer to the created control
262 virtual wxWindow *GetControl() { return this; }
263
264 // Translate string into a list selection
265 virtual void SetStringValue(const wxString& s)
266 {
267 int n = wxListView::FindItem(-1,s);
268 if ( n >= 0 && n < wxListView::GetItemCount() )
269 wxListView::Select(n);
270 }
271
272 // Get list selection as a string
273 virtual wxString GetStringValue() const
274 {
275 if ( m_value >= 0 )
968f15e2 276 return wxListView::GetItemText(m_value);
1f1d2182
FM
277 return wxEmptyString;
278 }
279
280 // Do mouse hot-tracking (which is typical in list popups)
281 void OnMouseMove(wxMouseEvent& event)
282 {
283 // TODO: Move selection to cursor
284 }
285
286 // On mouse left up, set the value and close the popup
287 void OnMouseClick(wxMouseEvent& WXUNUSED(event))
288 {
289 m_value = wxListView::GetFirstSelected();
290
291 // TODO: Send event as well
292
293 Dismiss();
294 }
295
296 protected:
968f15e2
BP
297
298 int m_value; // current item index
1f1d2182
FM
299
300 private:
a0e9a5df 301 wxDECLARE_EVENT_TABLE();
1f1d2182
FM
302 };
303
a0e9a5df 304 wxBEGIN_EVENT_TABLE(wxListViewComboPopup, wxListView)
1f1d2182
FM
305 EVT_MOTION(wxListViewComboPopup::OnMouseMove)
306 EVT_LEFT_UP(wxListViewComboPopup::OnMouseClick)
a0e9a5df 307 wxEND_EVENT_TABLE()
1f1d2182
FM
308 @endcode
309
310 Here's how you would create and populate it in a dialog constructor:
311
312 @code
968f15e2 313 wxComboCtrl* comboCtrl = new wxComboCtrl(this, wxID_ANY, wxEmptyString);
1f1d2182
FM
314
315 wxListViewComboPopup* popupCtrl = new wxListViewComboPopup();
316
5bc244b8 317 // It is important to call SetPopupControl() as soon as possible
1f1d2182
FM
318 comboCtrl->SetPopupControl(popupCtrl);
319
320 // Populate using wxListView methods
968f15e2
BP
321 popupCtrl->InsertItem(popupCtrl->GetItemCount(), "First Item");
322 popupCtrl->InsertItem(popupCtrl->GetItemCount(), "Second Item");
323 popupCtrl->InsertItem(popupCtrl->GetItemCount(), "Third Item");
1f1d2182 324 @endcode
7c913512 325
23324ae1 326 @beginStyleTable
8c6791e4 327 @style{wxCB_READONLY}
23324ae1 328 Text will not be editable.
8c6791e4 329 @style{wxCB_SORT}
23324ae1 330 Sorts the entries in the list alphabetically.
8c6791e4 331 @style{wxTE_PROCESS_ENTER}
ce7fe42e 332 The control will generate the event @c wxEVT_TEXT_ENTER
23324ae1
FM
333 (otherwise pressing Enter key is either processed internally by the
334 control or used for navigation between dialog controls). Windows
335 only.
8c6791e4 336 @style{wxCC_SPECIAL_DCLICK}
23324ae1
FM
337 Double-clicking triggers a call to popup's OnComboDoubleClick.
338 Actual behaviour is defined by a derived class. For instance,
339 wxOwnerDrawnComboBox will cycle an item. This style only applies if
340 wxCB_READONLY is used as well.
8c6791e4 341 @style{wxCC_STD_BUTTON}
23324ae1
FM
342 Drop button will behave more like a standard push button.
343 @endStyleTable
7c913512 344
3051a44a 345 @beginEventEmissionTable{wxCommandEvent}
8c6791e4 346 @event{EVT_TEXT(id, func)}
ce7fe42e 347 Process a @c wxEVT_TEXT event, when the text changes.
8c6791e4 348 @event{EVT_TEXT_ENTER(id, func)}
ce7fe42e 349 Process a @c wxEVT_TEXT_ENTER event, when RETURN is pressed in
23324ae1 350 the combo control.
23d74d89 351 @event{EVT_COMBOBOX_DROPDOWN(id, func)}
ce7fe42e 352 Process a @c wxEVT_COMBOBOX_DROPDOWN event, which is generated
a1d5aa93 353 when the popup window is shown (drops down).
23d74d89 354 @event{EVT_COMBOBOX_CLOSEUP(id, func)}
ce7fe42e 355 Process a @c wxEVT_COMBOBOX_CLOSEUP event, which is generated
a1d5aa93 356 when the popup window of the combo control disappears (closes up).
bb3400a8 357 You should avoid adding or deleting items in this event.
23324ae1 358 @endEventTable
7c913512 359
f00f01b3 360 @library{wxcore}
23324ae1 361 @category{ctrl}
ce154616 362 @appearance{comboctrl}
7c913512 363
968f15e2
BP
364 @see wxComboBox, wxChoice, wxOwnerDrawnComboBox, wxComboPopup,
365 wxCommandEvent
23324ae1 366*/
fda62793
JS
367class wxComboCtrl : public wxControl,
368 public wxTextEntry
23324ae1
FM
369{
370public:
968f15e2
BP
371 /**
372 Default constructor.
373 */
374 wxComboCtrl();
375
23324ae1
FM
376 /**
377 Constructor, creating and showing a combo control.
3c4f71cc 378
7c913512 379 @param parent
4cc4bfaf 380 Parent window. Must not be @NULL.
7c913512 381 @param id
4cc4bfaf 382 Window identifier. The value wxID_ANY indicates a default value.
7c913512 383 @param value
4cc4bfaf 384 Initial selection string. An empty string indicates no selection.
7c913512 385 @param pos
4cc4bfaf 386 Window position.
dc1b07fd 387 If ::wxDefaultPosition is specified then a default position is chosen.
7c913512 388 @param size
dc1b07fd
FM
389 Window size.
390 If ::wxDefaultSize is specified then the window is sized appropriately.
7c913512 391 @param style
4cc4bfaf 392 Window style. See wxComboCtrl.
7c913512 393 @param validator
4cc4bfaf 394 Window validator.
7c913512 395 @param name
4cc4bfaf 396 Window name.
3c4f71cc 397
4cc4bfaf 398 @see Create(), wxValidator
23324ae1 399 */
4707b84c
FM
400 wxComboCtrl(wxWindow* parent, wxWindowID id = wxID_ANY,
401 const wxString& value = wxEmptyString,
7c913512
FM
402 const wxPoint& pos = wxDefaultPosition,
403 const wxSize& size = wxDefaultSize,
404 long style = 0,
405 const wxValidator& validator = wxDefaultValidator,
9d9c1c24 406 const wxString& name = wxComboBoxNameStr);
23324ae1
FM
407
408 /**
409 Destructor, destroying the combo control.
410 */
968f15e2 411 virtual ~wxComboCtrl();
23324ae1 412
23324ae1
FM
413 /**
414 Copies the selected text to the clipboard.
415 */
968f15e2 416 virtual void Copy();
23324ae1
FM
417
418 /**
419 Creates the combo control for two-step construction. Derived classes
968f15e2
BP
420 should call or replace this function. See wxComboCtrl() for further
421 details.
23324ae1 422 */
4707b84c
FM
423 bool Create(wxWindow* parent, wxWindowID id = wxID_ANY,
424 const wxString& value = wxEmptyString,
23324ae1
FM
425 const wxPoint& pos = wxDefaultPosition,
426 const wxSize& size = wxDefaultSize,
427 long style = 0,
428 const wxValidator& validator = wxDefaultValidator,
9d9c1c24 429 const wxString& name = wxComboBoxNameStr);
23324ae1
FM
430
431 /**
432 Copies the selected text to the clipboard and removes the selection.
433 */
968f15e2 434 virtual void Cut();
23324ae1 435
ffb9247a
JS
436 /**
437 Dismisses the popup window.
438
439 Notice that calling this function will generate a
ce7fe42e 440 @c wxEVT_COMBOBOX_CLOSEUP event.
ffb9247a
JS
441
442 @since 2.9.2
443 */
444 virtual void Dismiss();
445
446
23324ae1
FM
447 /**
448 Enables or disables popup animation, if any, depending on the value of
449 the argument.
450 */
4cc4bfaf 451 void EnablePopupAnimation(bool enable = true);
23324ae1 452
f15e6487
RD
453
454 /**
455 Returns true if given key combination should toggle the popup.
456 */
457 virtual bool IsKeyPopupToggle(const wxKeyEvent& event) const;
458
459
460 /**
461 Prepare background of combo control or an item in a dropdown list in a
462 way typical on platform. This includes painting the focus/disabled
463 background and setting the clipping region.
464
465 Unless you plan to paint your own focus indicator, you should always
466 call this in your wxComboPopup::PaintComboControl implementation. In
467 addition, it sets pen and text colour to what looks good and proper
468 against the background.
469
470 flags: wxRendererNative flags:
471 wxCONTROL_ISSUBMENU: is drawing a list item instead of combo control
472 wxCONTROL_SELECTED: list item is selected
473 wxCONTROL_DISABLED: control/item is disabled
474 */
475 virtual void PrepareBackground( wxDC& dc, const wxRect& rect, int flags ) const;
476
477 /**
478 Returns true if focus indicator should be drawn in the control.
479 */
480 bool ShouldDrawFocus() const;
481
23324ae1
FM
482 /**
483 Returns disabled button bitmap that has been set with
484 SetButtonBitmaps().
3c4f71cc 485
d29a9a8a 486 @return A reference to the disabled state bitmap.
23324ae1 487 */
4707b84c 488 const wxBitmap& GetBitmapDisabled() const;
23324ae1
FM
489
490 /**
491 Returns button mouse hover bitmap that has been set with
492 SetButtonBitmaps().
3c4f71cc 493
d29a9a8a 494 @return A reference to the mouse hover state bitmap.
23324ae1 495 */
4707b84c 496 const wxBitmap& GetBitmapHover() const;
23324ae1
FM
497
498 /**
499 Returns default button bitmap that has been set with
500 SetButtonBitmaps().
3c4f71cc 501
d29a9a8a 502 @return A reference to the normal state bitmap.
23324ae1 503 */
4707b84c 504 const wxBitmap& GetBitmapNormal() const;
23324ae1
FM
505
506 /**
507 Returns depressed button bitmap that has been set with
508 SetButtonBitmaps().
3c4f71cc 509
d29a9a8a 510 @return A reference to the depressed state bitmap.
23324ae1 511 */
4707b84c 512 const wxBitmap& GetBitmapPressed() const;
23324ae1
FM
513
514 /**
515 Returns current size of the dropdown button.
516 */
517 wxSize GetButtonSize();
518
519 /**
520 Returns custom painted area in control.
3c4f71cc 521
4cc4bfaf 522 @see SetCustomPaintWidth().
23324ae1 523 */
328f5751 524 int GetCustomPaintWidth() const;
23324ae1
FM
525
526 /**
968f15e2
BP
527 Returns features supported by wxComboCtrl. If needed feature is
528 missing, you need to instead use wxGenericComboCtrl, which however may
529 lack a native look and feel (but otherwise sports identical API).
3c4f71cc 530
d29a9a8a
BP
531 @return Value returned is a combination of the flags defined in
532 wxComboCtrlFeatures.
23324ae1
FM
533 */
534 static int GetFeatures();
535
107defe3
JS
536 /**
537 Returns the current hint string.
538
539 See SetHint() for more information about hints.
540
541 @since 2.9.1
542 */
543 virtual wxString GetHint() const;
544
23324ae1
FM
545 /**
546 Returns the insertion point for the combo control's text field.
968f15e2
BP
547
548 @note Under Windows, this function always returns 0 if the combo
549 control doesn't have the focus.
23324ae1 550 */
968f15e2 551 virtual long GetInsertionPoint() const;
23324ae1
FM
552
553 /**
554 Returns the last position in the combo control text field.
555 */
968f15e2 556 virtual long GetLastPosition() const;
23324ae1 557
0847e36e
JS
558 /**
559 Returns the margins used by the control. The @c x field of the returned
560 point is the horizontal margin and the @c y field is the vertical one.
561
562 @remarks If given margin cannot be accurately determined, its value
563 will be set to -1.
564
565 @see SetMargins()
566
567 @since 2.9.1
568 */
569 wxPoint GetMargins() const;
570
23324ae1 571 /**
968f15e2
BP
572 Returns current popup interface that has been set with
573 SetPopupControl().
23324ae1
FM
574 */
575 wxComboPopup* GetPopupControl();
576
577 /**
578 Returns popup window containing the popup control.
579 */
328f5751 580 wxWindow* GetPopupWindow() const;
23324ae1
FM
581
582 /**
583 Get the text control which is part of the combo control.
584 */
328f5751 585 wxTextCtrl* GetTextCtrl() const;
23324ae1
FM
586
587 /**
588 Returns actual indentation in pixels.
0847e36e
JS
589
590 @deprecated Use GetMargins() instead.
23324ae1 591 */
328f5751 592 wxCoord GetTextIndent() const;
23324ae1
FM
593
594 /**
595 Returns area covered by the text field (includes everything except
596 borders and the dropdown button).
597 */
4707b84c 598 const wxRect& GetTextRect() const;
23324ae1
FM
599
600 /**
968f15e2
BP
601 Returns text representation of the current value. For writable combo
602 control it always returns the value in the text field.
23324ae1 603 */
968f15e2 604 virtual wxString GetValue() const;
23324ae1
FM
605
606 /**
607 Dismisses the popup window.
a1d5aa93
JS
608
609 @param generateEvent
610 Set this to @true in order to generate
ce7fe42e 611 @c wxEVT_COMBOBOX_CLOSEUP event.
ffb9247a
JS
612
613 @deprecated Use Dismiss() instead.
23324ae1 614 */
a1d5aa93 615 virtual void HidePopup(bool generateEvent=false);
23324ae1
FM
616
617 /**
618 Returns @true if the popup is currently shown
619 */
328f5751 620 bool IsPopupShown() const;
23324ae1
FM
621
622 /**
968f15e2
BP
623 Returns @true if the popup window is in the given state. Possible
624 values are:
3c4f71cc 625
968f15e2
BP
626 @beginTable
627 @row2col{wxComboCtrl::Hidden, Popup window is hidden.}
628 @row2col{wxComboCtrl::Animating, Popup window is being shown, but the
629 popup animation has not yet finished.}
630 @row2col{wxComboCtrl::Visible, Popup window is fully visible.}
631 @endTable
23324ae1 632 */
328f5751 633 bool IsPopupWindowState(int state) const;
23324ae1
FM
634
635 /**
968f15e2
BP
636 Implement in a derived class to define what happens on dropdown button
637 click. Default action is to show the popup.
638
639 @note If you implement this to do something else than show the popup,
640 you must then also implement DoSetPopupControl() to always return
641 @NULL.
23324ae1 642 */
968f15e2 643 virtual void OnButtonClick();
23324ae1
FM
644
645 /**
646 Pastes text from the clipboard to the text field.
647 */
968f15e2 648 virtual void Paste();
23324ae1 649
ffb9247a
JS
650 /**
651 Shows the popup portion of the combo control.
652
653 Notice that calling this function will generate a
ce7fe42e 654 @c wxEVT_COMBOBOX_DROPDOWN event.
ffb9247a
JS
655
656 @since 2.9.2
657 */
658 virtual void Popup();
659
23324ae1 660 /**
968f15e2
BP
661 Removes the text between the two positions in the combo control text
662 field.
3c4f71cc 663
7c913512 664 @param from
4cc4bfaf 665 The first position.
7c913512 666 @param to
4cc4bfaf 667 The last position.
23324ae1 668 */
968f15e2 669 virtual void Remove(long from, long to);
23324ae1
FM
670
671 /**
968f15e2
BP
672 Replaces the text between two positions with the given text, in the
673 combo control text field.
3c4f71cc 674
7c913512 675 @param from
4cc4bfaf 676 The first position.
7c913512 677 @param to
4cc4bfaf 678 The second position.
7c913512 679 @param text
4cc4bfaf 680 The text to insert.
23324ae1 681 */
45a591fa 682 virtual void Replace(long from, long to, const wxString& text);
23324ae1
FM
683
684 /**
685 Sets custom dropdown button graphics.
3c4f71cc 686
7c913512 687 @param bmpNormal
4cc4bfaf 688 Default button image.
7c913512 689 @param pushButtonBg
968f15e2 690 If @true, blank push button background is painted below the image.
7c913512 691 @param bmpPressed
4cc4bfaf 692 Depressed button image.
7c913512 693 @param bmpHover
968f15e2
BP
694 Button image when mouse hovers above it. This should be ignored on
695 platforms and themes that do not generally draw different kind of
696 button on mouse hover.
7c913512 697 @param bmpDisabled
4cc4bfaf 698 Disabled button image.
23324ae1
FM
699 */
700 void SetButtonBitmaps(const wxBitmap& bmpNormal,
4cc4bfaf 701 bool pushButtonBg = false,
23324ae1
FM
702 const wxBitmap& bmpPressed = wxNullBitmap,
703 const wxBitmap& bmpHover = wxNullBitmap,
704 const wxBitmap& bmpDisabled = wxNullBitmap);
705
706 /**
707 Sets size and position of dropdown button.
3c4f71cc 708
7c913512 709 @param width
4cc4bfaf 710 Button width. Value = 0 specifies default.
7c913512 711 @param height
4cc4bfaf 712 Button height. Value = 0 specifies default.
7c913512 713 @param side
968f15e2
BP
714 Indicates which side the button will be placed. Value can be wxLEFT
715 or wxRIGHT.
7c913512 716 @param spacingX
4cc4bfaf 717 Horizontal spacing around the button. Default is 0.
23324ae1
FM
718 */
719 void SetButtonPosition(int width = -1, int height = -1,
968f15e2 720 int side = wxRIGHT, int spacingX = 0);
23324ae1
FM
721
722 /**
968f15e2
BP
723 Set width, in pixels, of custom painted area in control without
724 @c wxCB_READONLY style. In read-only wxOwnerDrawnComboBox, this is used
23324ae1
FM
725 to indicate area that is not covered by the focus rectangle.
726 */
727 void SetCustomPaintWidth(int width);
728
107defe3
JS
729 /**
730 Sets a hint shown in an empty unfocused combo control.
731
732 Notice that hints are known as <em>cue banners</em> under MSW or
733 <em>placeholder strings</em> under OS X.
734
735 @see wxTextEntry::SetHint()
736
737 @since 2.9.1
738 */
6fbdd267 739 virtual bool SetHint(const wxString& hint);
107defe3 740
23324ae1
FM
741 /**
742 Sets the insertion point in the text field.
3c4f71cc 743
7c913512 744 @param pos
4cc4bfaf 745 The new insertion point.
23324ae1 746 */
968f15e2 747 virtual void SetInsertionPoint(long pos);
23324ae1
FM
748
749 /**
750 Sets the insertion point at the end of the combo control text field.
751 */
968f15e2 752 virtual void SetInsertionPointEnd();
23324ae1 753
0847e36e
JS
754 //@{
755 /**
756 Attempts to set the control margins. When margins are given as wxPoint,
757 x indicates the left and y the top margin. Use -1 to indicate that
758 an existing value should be used.
759
760 @return
761 @true if setting of all requested margins was successful.
762
763 @since 2.9.1
764 */
765 bool SetMargins(const wxPoint& pt);
766 bool SetMargins(wxCoord left, wxCoord top = -1);
767 //@}
768
23324ae1 769 /**
968f15e2
BP
770 Set side of the control to which the popup will align itself. Valid
771 values are @c wxLEFT, @c wxRIGHT and 0. The default value 0 means that
772 the most appropriate side is used (which, currently, is always
773 @c wxLEFT).
23324ae1
FM
774 */
775 void SetPopupAnchor(int anchorSide);
776
777 /**
968f15e2
BP
778 Set popup interface class derived from wxComboPopup. This method should
779 be called as soon as possible after the control has been created,
780 unless OnButtonClick() has been overridden.
23324ae1
FM
781 */
782 void SetPopupControl(wxComboPopup* popup);
783
784 /**
968f15e2
BP
785 Extends popup size horizontally, relative to the edges of the combo
786 control.
3c4f71cc 787
7c913512 788 @param extLeft
968f15e2
BP
789 How many pixel to extend beyond the left edge of the control.
790 Default is 0.
7c913512 791 @param extRight
968f15e2
BP
792 How many pixel to extend beyond the right edge of the control.
793 Default is 0.
3c4f71cc 794
968f15e2
BP
795 @remarks Popup minimum width may override arguments. It is up to the
796 popup to fully take this into account.
23324ae1
FM
797 */
798 void SetPopupExtents(int extLeft, int extRight);
799
800 /**
801 Sets preferred maximum height of the popup.
3c4f71cc 802
23324ae1
FM
803 @remarks Value -1 indicates the default.
804 */
805 void SetPopupMaxHeight(int height);
806
807 /**
968f15e2
BP
808 Sets minimum width of the popup. If wider than combo control, it will
809 extend to the left.
3c4f71cc 810
968f15e2
BP
811 @remarks Value -1 indicates the default. Also, popup implementation may
812 choose to ignore this.
23324ae1
FM
813 */
814 void SetPopupMinWidth(int width);
815
816 /**
968f15e2
BP
817 Selects the text between the two positions, in the combo control text
818 field.
3c4f71cc 819
7c913512 820 @param from
4cc4bfaf 821 The first position.
7c913512 822 @param to
4cc4bfaf 823 The second position.
23324ae1 824 */
968f15e2 825 virtual void SetSelection(long from, long to);
23324ae1
FM
826
827 /**
968f15e2
BP
828 Sets the text for the text field without affecting the popup. Thus,
829 unlike SetValue(), it works equally well with combo control using
830 @c wxCB_READONLY style.
23324ae1
FM
831 */
832 void SetText(const wxString& value);
833
1ac5cfc7
JS
834 /**
835 Set a custom window style for the embedded wxTextCtrl. Usually you
836 will need to use this during two-step creation, just before Create().
837 For example:
838
839 @code
840 wxComboCtrl* comboCtrl = new wxComboCtrl();
841
842 // Let's make the text right-aligned
843 comboCtrl->SetTextCtrlStyle(wxTE_RIGHT);
844
845 comboCtrl->Create(parent, wxID_ANY, wxEmptyString);
846 @endcode
847 */
848 void SetTextCtrlStyle( int style );
849
23324ae1 850 /**
968f15e2
BP
851 This will set the space in pixels between left edge of the control and
852 the text, regardless whether control is read-only or not. Value -1 can
853 be given to indicate platform default.
0847e36e
JS
854
855 @deprecated Use SetMargins() instead.
23324ae1
FM
856 */
857 void SetTextIndent(int indent);
858
859 /**
860 Sets the text for the combo control text field.
968f15e2
BP
861
862 @note For a combo control with @c wxCB_READONLY style the string must
863 be accepted by the popup (for instance, exist in the dropdown
864 list), otherwise the call to SetValue() is ignored.
23324ae1 865 */
968f15e2 866 virtual void SetValue(const wxString& value);
23324ae1 867
f15e6487
RD
868 /**
869 Changes value of the control as if user had done it by selecting an
870 item from a combo box drop-down list.
871 */
872 void SetValueByUser(const wxString& value);
873
23324ae1
FM
874 /**
875 Show the popup.
ffb9247a
JS
876
877 @deprecated Use Popup() instead.
23324ae1 878 */
968f15e2 879 virtual void ShowPopup();
23324ae1
FM
880
881 /**
882 Undoes the last edit in the text field. Windows only.
883 */
968f15e2 884 virtual void Undo();
23324ae1
FM
885
886 /**
968f15e2
BP
887 Enable or disable usage of an alternative popup window, which
888 guarantees ability to focus the popup control, and allows common native
889 controls to function normally. This alternative popup window is usually
890 a wxDialog, and as such, when it is shown, its parent top-level window
891 will appear as if the focus has been lost from it.
23324ae1 892 */
4cc4bfaf 893 void UseAltPopupWindow(bool enable = true);
b91c4601
FM
894
895protected:
896
897 /**
898 This member function is not normally called in application code.
899 Instead, it can be implemented in a derived class to create a custom
900 popup animation.
901
902 The parameters are the same as those for DoShowPopup().
903
904 @return @true if animation finishes before the function returns,
905 @false otherwise. In the latter case you need to manually call
906 DoShowPopup() after the animation ends.
907 */
908 virtual bool AnimateShow(const wxRect& rect, int flags);
909
910 /**
911 This member function is not normally called in application code.
912 Instead, it can be implemented in a derived class to return default
d13b34d3 913 wxComboPopup, in case @a popup is @NULL.
b91c4601
FM
914
915 @note If you have implemented OnButtonClick() to do something else than
916 show the popup, then DoSetPopupControl() must always set @a popup
917 to @NULL.
918 */
919 virtual void DoSetPopupControl(wxComboPopup* popup);
920
921 /**
922 This member function is not normally called in application code.
923 Instead, it must be called in a derived class to make sure popup is
924 properly shown after a popup animation has finished (but only if
925 AnimateShow() did not finish the animation within its function scope).
926
927 @param rect
928 Position to show the popup window at, in screen coordinates.
929 @param flags
930 Combination of any of the following:
931 @beginTable
932 @row2col{wxComboCtrl::ShowAbove,
933 Popup is shown above the control instead of below.}
934 @row2col{wxComboCtrl::CanDeferShow,
935 Showing the popup can be deferred to happen sometime after
936 ShowPopup() has finished. In this case, AnimateShow() must
937 return false.}
938 @endTable
939 */
940 virtual void DoShowPopup(const wxRect& rect, int flags);
23324ae1 941};
e54c96f1 942