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