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