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