1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxComboCtrl declaration
4 // Author: Jaakko Salli
6 // Created: Apr-30-2006
8 // Copyright: (c) Jaakko Salli
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_COMBOCONTROL_H_BASE_
13 #define _WX_COMBOCONTROL_H_BASE_
17 A few words about all the classes defined in this file are probably in
18 order: why do we need extra wxComboCtrl and wxComboPopup classes?
20 This is because a traditional combobox is a combination of a text control
21 (with a button allowing to open the pop down list) with a listbox and
22 wxComboBox class is exactly such control, however we want to also have other
23 combinations - in fact, we want to allow anything at all to be used as pop
24 down list, not just a wxListBox.
26 So we define a base wxComboCtrl which can use any control as pop down
27 list and wxComboBox deriving from it which implements the standard wxWidgets
28 combobox API. wxComboCtrl needs to be told somehow which control to use
29 and this is done by SetPopupControl(). However, we need something more than
30 just a wxControl in this method as, for example, we need to call
31 SetSelection("initial text value") and wxControl doesn't have such method.
32 So we also need a wxComboPopup which is just a very simple interface which
33 must be implemented by a control to be usable as a popup.
35 We couldn't derive wxComboPopup from wxControl as this would make it
36 impossible to have a class deriving from both wxListBx and from it, so
37 instead it is just a mix-in.
45 #include "wx/control.h"
46 #include "wx/renderer.h" // this is needed for wxCONTROL_XXX flags
47 #include "wx/bitmap.h" // wxBitmap used by-value
48 #include "wx/textentry.h"
50 class WXDLLIMPEXP_FWD_CORE wxTextCtrl
;
51 class WXDLLIMPEXP_FWD_CORE wxComboPopup
;
54 // New window styles for wxComboCtrlBase
58 // Double-clicking a read-only combo triggers call to popup's OnComboPopup.
59 // In wxOwnerDrawnComboBox, for instance, it cycles item.
60 wxCC_SPECIAL_DCLICK
= 0x0100,
62 // Dropbutton acts like standard push button.
63 wxCC_STD_BUTTON
= 0x0200
67 // wxComboCtrl internal flags
70 // First those that can be passed to Customize.
71 // It is Windows style for all flags to be clear.
73 // Button is preferred outside the border (GTK style)
74 wxCC_BUTTON_OUTSIDE_BORDER
= 0x0001,
75 // Show popup on mouse up instead of mouse down (which is the Windows style)
76 wxCC_POPUP_ON_MOUSE_UP
= 0x0002,
77 // All text is not automatically selected on click
78 wxCC_NO_TEXT_AUTO_SELECT
= 0x0004,
79 // Drop-button stays down as long as popup is displayed.
80 wxCC_BUTTON_STAYS_DOWN
= 0x0008,
81 // Drop-button covers the entire control.
82 wxCC_FULL_BUTTON
= 0x0010,
83 // Drop-button goes over the custom-border (used under WinVista).
84 wxCC_BUTTON_COVERS_BORDER
= 0x0020,
86 // Internal use: signals creation is complete
87 wxCC_IFLAG_CREATED
= 0x0100,
88 // Internal use: really put button outside
89 wxCC_IFLAG_BUTTON_OUTSIDE
= 0x0200,
90 // Internal use: SetMargins has been succesfully called
91 wxCC_IFLAG_LEFT_MARGIN_SET
= 0x0400,
92 // Internal use: Set wxTAB_TRAVERSAL to parent when popup is dismissed
93 wxCC_IFLAG_PARENT_TAB_TRAVERSAL
= 0x0800,
94 // Internal use: Secondary popup window type should be used (if available).
95 wxCC_IFLAG_USE_ALT_POPUP
= 0x1000,
96 // Internal use: Skip popup animation.
97 wxCC_IFLAG_DISABLE_POPUP_ANIM
= 0x2000,
98 // Internal use: Drop-button is a bitmap button or has non-default size
99 // (but can still be on either side of the control), regardless whether
100 // specified by the platform or the application.
101 wxCC_IFLAG_HAS_NONSTANDARD_BUTTON
= 0x4000
105 // Flags used by PreprocessMouseEvent and HandleButtonMouseEvent
108 wxCC_MF_ON_BUTTON
= 0x0001, // cursor is on dropbutton area
109 wxCC_MF_ON_CLICK_AREA
= 0x0002 // cursor is on dropbutton or other area
110 // that can be clicked to show the popup.
114 // Namespace for wxComboCtrl feature flags
115 struct wxComboCtrlFeatures
119 MovableButton
= 0x0001, // Button can be on either side of control
120 BitmapButton
= 0x0002, // Button may be replaced with bitmap
121 ButtonSpacing
= 0x0004, // Button can have spacing from the edge
123 TextIndent
= 0x0008, // SetMargins can be used to control
125 PaintControl
= 0x0010, // Combo control itself can be custom painted
126 PaintWritable
= 0x0020, // A variable-width area in front of writable
127 // combo control's textctrl can be custom
129 Borderless
= 0x0040, // wxNO_BORDER window style works
131 // There are no feature flags for...
132 // PushButtonBitmapBackground - if its in wxRendererNative, then it should be
133 // not an issue to have it automatically under the bitmap.
135 All
= MovableButton
|BitmapButton
|
136 ButtonSpacing
|TextIndent
|
137 PaintControl
|PaintWritable
|
143 class WXDLLIMPEXP_CORE wxComboCtrlBase
: public wxControl
,
146 friend class wxComboPopup
;
147 friend class wxComboPopupEvtHandler
;
150 wxComboCtrlBase() : wxControl(), wxTextEntry() { Init(); }
152 bool Create(wxWindow
*parent
,
154 const wxString
& value
,
158 const wxValidator
& validator
,
159 const wxString
& name
);
161 virtual ~wxComboCtrlBase();
163 // show/hide popup window
164 virtual void ShowPopup();
165 virtual void HidePopup(bool generateEvent
=false);
167 // Override for totally custom combo action
168 virtual void OnButtonClick();
170 // return true if the popup is currently shown
171 bool IsPopupShown() const { return m_popupWinState
== Visible
; }
173 // set interface class instance derived from wxComboPopup
174 // NULL popup can be used to indicate default in a derived class
175 void SetPopupControl( wxComboPopup
* popup
)
177 DoSetPopupControl(popup
);
180 // get interface class instance derived from wxComboPopup
181 wxComboPopup
* GetPopupControl()
183 EnsurePopupControl();
184 return m_popupInterface
;
187 // get the popup window containing the popup control
188 wxWindow
*GetPopupWindow() const { return m_winPopup
; }
190 // Get the text control which is part of the combobox.
191 wxTextCtrl
*GetTextCtrl() const { return m_text
; }
193 // get the dropdown button which is part of the combobox
194 // note: its not necessarily a wxButton or wxBitmapButton
195 wxWindow
*GetButton() const { return m_btn
; }
197 // forward these methods to all subcontrols
198 virtual bool Enable(bool enable
= true);
199 virtual bool Show(bool show
= true);
200 virtual bool SetFont(const wxFont
& font
);
203 // wxTextEntry methods
205 // NB: We basically need to override all of them because there is
206 // no guarantee how platform-specific wxTextEntry is implemented.
208 virtual void SetValue(const wxString
& value
)
209 { wxTextEntryBase
::SetValue(value
); }
210 virtual void ChangeValue(const wxString
& value
)
211 { wxTextEntryBase
::ChangeValue(value
); }
213 virtual void WriteText(const wxString
& text
);
214 virtual void AppendText(const wxString
& text
)
215 { wxTextEntryBase
::AppendText(text
); }
217 virtual wxString
GetValue() const
218 { return wxTextEntryBase
::GetValue(); }
220 virtual wxString
GetRange(long from
, long to
) const
221 { return wxTextEntryBase
::GetRange(from
, to
); }
223 // Replace() and DoSetValue() need to be fully re-implemented since
224 // EventSuppressor utility class does not work with the way
225 // wxComboCtrl is implemented.
226 virtual void Replace(long from
, long to
, const wxString
& value
);
228 virtual void Remove(long from
, long to
);
232 virtual void Paste();
236 virtual bool CanUndo() const;
237 virtual bool CanRedo() const;
239 virtual void SetInsertionPoint(long pos
);
240 virtual long GetInsertionPoint() const;
241 virtual long GetLastPosition() const;
243 virtual void SetSelection(long from
, long to
);
244 virtual void GetSelection(long *from
, long *to
) const;
246 virtual bool IsEditable() const;
247 virtual void SetEditable(bool editable
);
249 virtual bool SetHint(const wxString
& hint
);
250 virtual wxString
GetHint() const;
252 // This method sets the text without affecting list selection
253 // (ie. wxComboPopup::SetStringValue doesn't get called).
254 void SetText(const wxString
& value
);
256 // This method sets value and also optionally sends EVT_TEXT
257 // (needed by combo popups)
258 wxDEPRECATED( void SetValueWithEvent(const wxString
& value
,
259 bool withEvent
= true) );
261 // Changes value of the control as if user had done it by selecting an
262 // item from a combo box drop-down list. Needs to be public so that
263 // derived popup classes can call it.
264 void SetValueByUser(const wxString
& value
);
267 // Popup customization methods
270 // Sets minimum width of the popup. If wider than combo control, it will extend to the left.
272 // * Value -1 indicates the default.
273 // * Custom popup may choose to ignore this (wxOwnerDrawnComboBox does not).
274 void SetPopupMinWidth( int width
)
276 m_widthMinPopup
= width
;
279 // Sets preferred maximum height of the popup.
281 // * Value -1 indicates the default.
282 // * Custom popup may choose to ignore this (wxOwnerDrawnComboBox does not).
283 void SetPopupMaxHeight( int height
)
285 m_heightPopup
= height
;
288 // Extends popup size horizontally, relative to the edges of the combo control.
290 // * Popup minimum width may override extLeft (ie. it has higher precedence).
291 // * Values 0 indicate default.
292 // * Custom popup may not take this fully into account (wxOwnerDrawnComboBox takes).
293 void SetPopupExtents( int extLeft
, int extRight
)
296 m_extRight
= extRight
;
299 // Set width, in pixels, of custom paint area in writable combo.
300 // In read-only, used to indicate area that is not covered by the
301 // focus rectangle (which may or may not be drawn, depending on the
303 void SetCustomPaintWidth( int width
);
304 int GetCustomPaintWidth() const { return m_widthCustomPaint
; }
306 // Set side of the control to which the popup will align itself.
307 // Valid values are wxLEFT, wxRIGHT and 0. The default value 0 wmeans
308 // that the side of the button will be used.
309 void SetPopupAnchor( int anchorSide
)
311 m_anchorSide
= anchorSide
;
314 // Set position of dropdown button.
315 // width: button width. <= 0 for default.
316 // height: button height. <= 0 for default.
317 // side: wxLEFT or wxRIGHT, indicates on which side the button will be placed.
318 // spacingX: empty space on sides of the button. Default is 0.
320 // There is no spacingY - the button will be centered vertically.
321 void SetButtonPosition( int width
= -1,
326 // Returns current size of the dropdown button.
327 wxSize
GetButtonSize();
330 // Sets dropbutton to be drawn with custom bitmaps.
332 // bmpNormal: drawn when cursor is not on button
333 // pushButtonBg: Draw push button background below the image.
334 // NOTE! This is usually only properly supported on platforms with appropriate
335 // method in wxRendererNative.
336 // bmpPressed: drawn when button is depressed
337 // bmpHover: drawn when cursor hovers on button. This is ignored on platforms
338 // that do not generally display hover differently.
339 // bmpDisabled: drawn when combobox is disabled.
340 void SetButtonBitmaps( const wxBitmap
& bmpNormal
,
341 bool pushButtonBg
= false,
342 const wxBitmap
& bmpPressed
= wxNullBitmap
,
343 const wxBitmap
& bmpHover
= wxNullBitmap
,
344 const wxBitmap
& bmpDisabled
= wxNullBitmap
);
346 #if WXWIN_COMPATIBILITY_2_8
348 // This will set the space in pixels between left edge of the control and the
349 // text, regardless whether control is read-only (ie. no wxTextCtrl) or not.
350 // Platform-specific default can be set with value-1.
352 // * This method may do nothing on some native implementations.
353 wxDEPRECATED( void SetTextIndent( int indent
) );
355 // Returns actual indentation in pixels.
356 wxDEPRECATED( wxCoord
GetTextIndent() const );
359 // Returns area covered by the text field.
360 const wxRect
& GetTextRect() const
365 // Call with enable as true to use a type of popup window that guarantees ability
366 // to focus the popup control, and normal function of common native controls.
367 // This alternative popup window is usually a wxDialog, and as such it's parent
368 // frame will appear as if the focus has been lost from it.
369 void UseAltPopupWindow( bool enable
= true )
371 wxASSERT_MSG( !m_winPopup
,
372 wxT("call this only before SetPopupControl") );
375 m_iFlags
|= wxCC_IFLAG_USE_ALT_POPUP
;
377 m_iFlags
&= ~wxCC_IFLAG_USE_ALT_POPUP
;
380 // Call with false to disable popup animation, if any.
381 void EnablePopupAnimation( bool enable
= true )
384 m_iFlags
&= ~wxCC_IFLAG_DISABLE_POPUP_ANIM
;
386 m_iFlags
|= wxCC_IFLAG_DISABLE_POPUP_ANIM
;
390 // Utilies needed by the popups or native implementations
393 // Returns true if given key combination should toggle the popup.
394 // NB: This is a separate from other keyboard handling because:
395 // 1) Replaceability.
396 // 2) Centralized code (otherwise it'd be split up between
397 // wxComboCtrl key handler and wxVListBoxComboPopup's
399 virtual bool IsKeyPopupToggle(const wxKeyEvent
& event
) const = 0;
401 // Prepare background of combo control or an item in a dropdown list
402 // in a way typical on platform. This includes painting the focus/disabled
403 // background and setting the clipping region.
404 // Unless you plan to paint your own focus indicator, you should always call this
405 // in your wxComboPopup::PaintComboControl implementation.
406 // In addition, it sets pen and text colour to what looks good and proper
407 // against the background.
408 // flags: wxRendererNative flags: wxCONTROL_ISSUBMENU: is drawing a list item instead of combo control
409 // wxCONTROL_SELECTED: list item is selected
410 // wxCONTROL_DISABLED: control/item is disabled
411 virtual void PrepareBackground( wxDC
& dc
, const wxRect
& rect
, int flags
) const;
413 // Returns true if focus indicator should be drawn in the control.
414 bool ShouldDrawFocus() const
416 const wxWindow
* curFocus
= FindFocus();
417 return ( IsPopupWindowState(Hidden
) &&
418 (curFocus
== m_mainCtrlWnd
|| (m_btn
&& curFocus
== m_btn
)) &&
419 (m_windowStyle
& wxCB_READONLY
) );
422 // These methods return references to appropriate dropbutton bitmaps
423 const wxBitmap
& GetBitmapNormal() const { return m_bmpNormal
; }
424 const wxBitmap
& GetBitmapPressed() const { return m_bmpPressed
; }
425 const wxBitmap
& GetBitmapHover() const { return m_bmpHover
; }
426 const wxBitmap
& GetBitmapDisabled() const { return m_bmpDisabled
; }
428 // Set custom style flags for embedded wxTextCtrl. Usually must be used
429 // with two-step creation, before Create() call.
430 void SetTextCtrlStyle( int style
);
432 // Return internal flags
433 wxUint32
GetInternalFlags() const { return m_iFlags
; }
435 // Return true if Create has finished
436 bool IsCreated() const { return m_iFlags
& wxCC_IFLAG_CREATED ?
true : false; }
438 // common code to be called on popup hide/dismiss
439 void OnPopupDismiss(bool generateEvent
);
450 bool IsPopupWindowState( int state
) const { return (state
== m_popupWinState
) ?
true : false; }
452 wxByte
GetPopupWindowState() const { return m_popupWinState
; }
454 // Set value returned by GetMainWindowOfCompositeControl
455 void SetCtrlMainWnd( wxWindow
* wnd
) { m_mainCtrlWnd
= wnd
; }
457 // This is public so we can access it from wxComboCtrlTextCtrl
458 virtual wxWindow
*GetMainWindowOfCompositeControl()
459 { return m_mainCtrlWnd
; }
463 // Returns true if hint text should be drawn in the control
464 bool ShouldUseHintText(int flags
= 0) const
467 !(flags
& wxCONTROL_ISSUBMENU
) &&
468 !m_valueString
.length() &&
469 m_hintText
.length() &&
470 !ShouldDrawFocus() );
474 // Override these for customization purposes
477 // called from wxSizeEvent handler
478 virtual void OnResize() = 0;
480 // Return native text identation
481 // (i.e. text margin, for pure text, not textctrl)
482 virtual wxCoord
GetNativeTextIndent() const;
484 // Called in syscolourchanged handler and base create
485 virtual void OnThemeChange();
487 // Creates wxTextCtrl.
488 // extraStyle: Extra style parameters
489 void CreateTextCtrl( int extraStyle
);
491 // Called when text was changed programmatically
492 // (e.g. from WriteText())
493 void OnSetValue(const wxString
& value
);
495 // Installs standard input handler to combo (and optionally to the textctrl)
496 void InstallInputHandlers();
498 // Flags for DrawButton
501 Button_PaintBackground
= 0x0001, // Paints control background below the button
502 Button_BitmapOnly
= 0x0002 // Only paints the bitmap
505 // Draws dropbutton. Using wxRenderer or bitmaps, as appropriate.
506 // Flags are defined above.
507 virtual void DrawButton( wxDC
& dc
, const wxRect
& rect
, int flags
= Button_PaintBackground
);
509 // Call if cursor is on button area or mouse is captured for the button.
510 //bool HandleButtonMouseEvent( wxMouseEvent& event, bool isInside );
511 bool HandleButtonMouseEvent( wxMouseEvent
& event
, int flags
);
513 // returns true if event was consumed or filtered (event type is also set to 0 in this case)
514 bool PreprocessMouseEvent( wxMouseEvent
& event
, int flags
);
517 // This will handle left_down and left_dclick events outside button in a Windows-like manner.
518 // If you need alternate behaviour, it is recommended you manipulate and filter events to it
519 // instead of building your own handling routine (for reference, on wxEVT_LEFT_DOWN it will
520 // toggle popup and on wxEVT_LEFT_DCLICK it will do the same or run the popup's dclick method,
521 // if defined - you should pass events of other types of it for common processing).
522 void HandleNormalMouseEvent( wxMouseEvent
& event
);
524 // Creates popup window, calls interface->Create(), etc
527 // Destroy popup window and all related constructs
530 // override the base class virtuals involved in geometry calculations
531 virtual wxSize
DoGetBestSize() const;
533 // also set the embedded wxTextCtrl colours
534 virtual bool SetForegroundColour(const wxColour
& colour
);
535 virtual bool SetBackgroundColour(const wxColour
& colour
);
537 // NULL popup can be used to indicate default in a derived class
538 virtual void DoSetPopupControl(wxComboPopup
* popup
);
540 // ensures there is atleast the default popup
541 void EnsurePopupControl();
543 // Recalculates button and textctrl areas. Called when size or button setup change.
544 // btnWidth: default/calculated width of the dropbutton. 0 means unchanged,
546 void CalculateAreas( int btnWidth
= 0 );
548 // Standard textctrl positioning routine. Just give it platform-dependant
549 // textctrl coordinate adjustment.
550 virtual void PositionTextCtrl( int textCtrlXAdjust
, int textCtrlYAdjust
);
553 void OnSizeEvent( wxSizeEvent
& event
);
554 void OnFocusEvent(wxFocusEvent
& event
);
555 void OnIdleEvent(wxIdleEvent
& event
);
556 void OnTextCtrlEvent(wxCommandEvent
& event
);
557 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
558 void OnKeyEvent(wxKeyEvent
& event
);
559 void OnCharEvent(wxKeyEvent
& event
);
561 // Set customization flags (directs how wxComboCtrlBase helpers behave)
562 void Customize( wxUint32 flags
) { m_iFlags
|= flags
; }
564 // Dispatches size event and refreshes
565 void RecalcAndRefresh();
567 // Flags for DoShowPopup and AnimateShow
570 ShowBelow
= 0x0000, // Showing popup below the control
571 ShowAbove
= 0x0001, // Showing popup above the control
572 CanDeferShow
= 0x0002 // Can only return true from AnimateShow if this is set
575 // Shows and positions the popup.
576 virtual void DoShowPopup( const wxRect
& rect
, int flags
);
578 // Implement in derived class to create a drop-down animation.
579 // Return true if finished immediately. Otherwise popup is only
580 // shown when the derived class call DoShowPopup.
581 // Flags are same as for DoShowPopup.
582 virtual bool AnimateShow( const wxRect
& rect
, int flags
);
585 virtual void DoSetToolTip( wxToolTip
*tip
);
588 // protected wxTextEntry methods
589 virtual void DoSetValue(const wxString
& value
, int flags
);
590 virtual wxString
DoGetValue() const;
591 virtual wxWindow
*GetEditableWindow() { return this; }
594 virtual bool DoSetMargins(const wxPoint
& pt
);
595 virtual wxPoint
DoGetMargins() const;
597 // This is used when m_text is hidden (readonly).
598 wxString m_valueString
;
600 // This is used when control is unfocused and m_valueString is empty
603 // the text control and button we show all the time
607 // wxPopupWindow or similar containing the window managed by the interface.
608 wxWindow
* m_winPopup
;
610 // the popup control/panel
614 wxComboPopup
* m_popupInterface
;
616 // this is input etc. handler for the text control
617 wxEvtHandler
* m_textEvtHandler
;
619 // this is for the top level window
620 wxEvtHandler
* m_toplevEvtHandler
;
622 // this is for the control in popup
623 wxEvtHandler
* m_popupEvtHandler
;
625 // this is for the popup window
626 wxEvtHandler
* m_popupWinEvtHandler
;
628 // main (ie. topmost) window of a composite control (default = this)
629 wxWindow
* m_mainCtrlWnd
;
631 // used to prevent immediate re-popupping incase closed popup
632 // by clicking on the combo control (needed because of inconsistent
633 // transient implementation across platforms).
634 wxLongLong m_timeCanAcceptClick
;
636 // how much popup should expand to the left/right of the control
640 // minimum popup width
641 wxCoord m_widthMinPopup
;
643 // preferred popup height
644 wxCoord m_heightPopup
;
646 // how much of writable combo is custom-paint by callback?
647 // also used to indicate area that is not covered by "blue"
648 // selection indicator.
649 wxCoord m_widthCustomPaint
;
651 // left margin, in pixels
652 wxCoord m_marginLeft
;
654 // side on which the popup is aligned
657 // Width of the "fake" border
658 wxCoord m_widthCustomBorder
;
660 // The button and textctrl click/paint areas
664 // current button state (uses renderer flags)
673 // last default button width
676 // custom dropbutton bitmaps
677 wxBitmap m_bmpNormal
;
678 wxBitmap m_bmpPressed
;
680 wxBitmap m_bmpDisabled
;
682 // area used by the button
685 // platform-dependant customization and other flags
688 // custom style for m_text
691 // draw blank button background under bitmap?
692 bool m_blankButtonBg
;
694 // is the popup window currenty shown?
695 wxByte m_popupWinState
;
697 // should the focus be reset to the textctrl in idle time?
703 wxByte m_ignoreEvtText
; // Number of next EVT_TEXTs to ignore
705 // Is popup window wxPopupTransientWindow, wxPopupWindow or wxDialog?
706 wxByte m_popupWinType
;
708 DECLARE_EVENT_TABLE()
710 DECLARE_ABSTRACT_CLASS(wxComboCtrlBase
)
714 // ----------------------------------------------------------------------------
715 // wxComboPopup is the interface which must be implemented by a control to be
716 // used as a popup by wxComboCtrl
717 // ----------------------------------------------------------------------------
720 // wxComboPopup internal flags
723 wxCP_IFLAG_CREATED
= 0x0001 // Set by wxComboCtrlBase after Create is called
726 class WXDLLIMPEXP_FWD_CORE wxComboCtrl
;
729 class WXDLLIMPEXP_CORE wxComboPopup
731 friend class wxComboCtrlBase
;
739 // This is called immediately after construction finishes. m_combo member
740 // variable has been initialized before the call.
741 // NOTE: It is not in constructor so the derived class doesn't need to redefine
742 // a default constructor of its own.
743 virtual void Init() { }
745 virtual ~wxComboPopup();
747 // Create the popup child control.
748 // Return true for success.
749 virtual bool Create(wxWindow
* parent
) = 0;
751 // We must have an associated control which is subclassed by the combobox.
752 virtual wxWindow
*GetControl() = 0;
754 // Called immediately after the popup is shown
755 virtual void OnPopup();
757 // Called when popup is dismissed
758 virtual void OnDismiss();
760 // Called just prior to displaying popup.
761 // Default implementation does nothing.
762 virtual void SetStringValue( const wxString
& value
);
764 // Gets displayed string representation of the value.
765 virtual wxString
GetStringValue() const = 0;
767 // This is called to custom paint in the combo control itself (ie. not the popup).
768 // Default implementation draws value as string.
769 virtual void PaintComboControl( wxDC
& dc
, const wxRect
& rect
);
771 // Receives wxEVT_KEY_DOWN key events from the parent wxComboCtrl.
772 // Events not handled should be skipped, as usual.
773 virtual void OnComboKeyEvent( wxKeyEvent
& event
);
775 // Receives wxEVT_CHAR key events from the parent wxComboCtrl.
776 // Events not handled should be skipped, as usual.
777 virtual void OnComboCharEvent( wxKeyEvent
& event
);
779 // Implement if you need to support special action when user
780 // double-clicks on the parent wxComboCtrl.
781 virtual void OnComboDoubleClick();
783 // Return final size of popup. Called on every popup, just prior to OnShow.
784 // minWidth = preferred minimum width for window
785 // prefHeight = preferred height. Only applies if > 0,
786 // maxHeight = max height for window, as limited by screen size
787 // and should only be rounded down, if necessary.
788 virtual wxSize
GetAdjustedSize( int minWidth
, int prefHeight
, int maxHeight
);
790 // Return true if you want delay call to Create until the popup is shown
791 // for the first time. It is more efficient, but note that it is often
792 // more convenient to have the control created immediately.
793 // Default returns false.
794 virtual bool LazyCreate();
803 // Returns true if Create has been called.
804 bool IsCreated() const
806 return (m_iFlags
& wxCP_IFLAG_CREATED
) ?
true : false;
809 // Returns pointer to the associated parent wxComboCtrl.
810 wxComboCtrl
* GetComboCtrl() const;
812 // Default PaintComboControl behaviour
813 static void DefaultPaintComboControl( wxComboCtrlBase
* combo
,
815 const wxRect
& rect
);
818 wxComboCtrlBase
* m_combo
;
822 // Called in wxComboCtrlBase::SetPopupControl
823 void InitBase(wxComboCtrlBase
*combo
)
830 // ----------------------------------------------------------------------------
831 // include the platform-dependent header defining the real class
832 // ----------------------------------------------------------------------------
834 #if defined(__WXUNIVERSAL__)
835 // No native universal (but it must still be first in the list)
836 #elif defined(__WXMSW__)
837 #include "wx/msw/combo.h"
840 // Any ports may need generic as an alternative
841 #include "wx/generic/combo.h"
843 #endif // wxUSE_COMBOCTRL
846 // _WX_COMBOCONTROL_H_BASE_