1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/combocmn.cpp
3 // Purpose: wxComboCtrlBase
4 // Author: Jaakko Salli
6 // Created: Apr-30-2006
8 // Copyright: (c) 2005 Jaakko Salli
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 #include "wx/wxprec.h"
28 #include "wx/combobox.h"
33 #include "wx/dcclient.h"
34 #include "wx/settings.h"
36 #include "wx/textctrl.h"
39 #include "wx/tooltip.h"
46 // ----------------------------------------------------------------------------
48 #define DEFAULT_DROPBUTTON_WIDTH 19
50 #define BMP_BUTTON_MARGIN 4
52 #define DEFAULT_POPUP_HEIGHT 400
54 #define DEFAULT_TEXT_INDENT 3
56 #define COMBO_MARGIN 2 // spacing right of wxTextCtrl
59 #if defined(__WXMSW__)
61 // Let's use wxFrame as a fall-back solution until wxMSW gets wxNonOwnedWindow
63 #define wxCC_GENERIC_TLW_IS_FRAME
64 #define wxComboCtrlGenericTLW wxFrame
66 #define USE_TRANSIENT_POPUP 1 // Use wxPopupWindowTransient (preferred, if it works properly on platform)
67 #define TRANSIENT_POPUPWIN_IS_PERFECT 0 // wxPopupTransientWindow works, its child can have focus, and common
68 // native controls work on it like normal.
69 #define POPUPWIN_IS_PERFECT 0 // Same, but for non-transient popup window.
70 #define TEXTCTRL_TEXT_CENTERED 0 // 1 if text in textctrl is vertically centered
71 #define FOCUS_RING 0 // No focus ring on wxMSW
73 //#undef wxUSE_POPUPWIN
74 //#define wxUSE_POPUPWIN 0
76 #elif defined(__WXGTK__)
78 // NB: It is not recommended to use wxDialog as popup on wxGTK, because of
79 // this bug: If wxDialog is hidden, its position becomes corrupt
80 // between hide and next show, but without internal coordinates being
81 // reflected (or something like that - atleast commenting out ->Hide()
82 // seemed to eliminate the position change).
84 #include "wx/dialog.h"
85 #define wxCC_GENERIC_TLW_IS_DIALOG
86 #define wxComboCtrlGenericTLW wxDialog
88 #if defined(__WXGTK20__)
89 # include "wx/gtk/private.h"
91 # include "wx/gtk1/private.h"
94 // NB: Let's not be afraid to use wxGTK's wxPopupTransientWindow as a
95 // 'perfect' popup, as it can succesfully host child controls even in
96 // popups that are shown in modal dialogs.
98 #define USE_TRANSIENT_POPUP 1 // Use wxPopupWindowTransient (preferred, if it works properly on platform)
99 #define TRANSIENT_POPUPWIN_IS_PERFECT 1 // wxPopupTransientWindow works, its child can have focus, and common
100 // native controls work on it like normal.
101 #define POPUPWIN_IS_PERFECT 1 // Same, but for non-transient popup window.
102 #define TEXTCTRL_TEXT_CENTERED 1 // 1 if text in textctrl is vertically centered
103 #define FOCUS_RING 0 // No focus ring on wxGTK
105 #elif defined(__WXMAC__)
107 #include "wx/nonownedwnd.h"
108 #define wxCC_GENERIC_TLW_IS_NONOWNEDWINDOW
109 #define wxComboCtrlGenericTLW wxNonOwnedWindow
111 #define USE_TRANSIENT_POPUP 1 // Use wxPopupWindowTransient (preferred, if it works properly on platform)
112 #define TRANSIENT_POPUPWIN_IS_PERFECT 1 // wxPopupTransientWindow works, its child can have focus, and common
113 // native controls work on it like normal.
114 #define POPUPWIN_IS_PERFECT 1 // Same, but for non-transient popup window.
115 #define TEXTCTRL_TEXT_CENTERED 1 // 1 if text in textctrl is vertically centered
116 #define FOCUS_RING 3 // Reserve room for the textctrl's focus ring to display
118 #undef DEFAULT_DROPBUTTON_WIDTH
119 #define DEFAULT_DROPBUTTON_WIDTH 22
121 #define COMBO_MARGIN FOCUS_RING
125 #include "wx/dialog.h"
126 #define wxCC_GENERIC_TLW_IS_DIALOG
127 #define wxComboCtrlGenericTLW wxDialog
129 #define USE_TRANSIENT_POPUP 0 // Use wxPopupWindowTransient (preferred, if it works properly on platform)
130 #define TRANSIENT_POPUPWIN_IS_PERFECT 0 // wxPopupTransientWindow works, its child can have focus, and common
131 // native controls work on it like normal.
132 #define POPUPWIN_IS_PERFECT 0 // Same, but for non-transient popup window.
133 #define TEXTCTRL_TEXT_CENTERED 1 // 1 if text in textctrl is vertically centered
139 // Popupwin is really only supported on wxMSW (not WINCE) and wxGTK, regardless
140 // what the wxUSE_POPUPWIN says.
141 // FIXME: Why isn't wxUSE_POPUPWIN reliable any longer? (it was in wxW2.6.2)
142 #if (!defined(__WXMSW__) && !defined(__WXGTK__) && !defined(__WXMAC__)) || defined(__WXWINCE__)
143 #undef wxUSE_POPUPWIN
144 #define wxUSE_POPUPWIN 0
149 #include "wx/popupwin.h"
151 #undef USE_TRANSIENT_POPUP
152 #define USE_TRANSIENT_POPUP 0
156 // Define different types of popup windows
160 POPUPWIN_WXPOPUPTRANSIENTWINDOW
= 1,
161 POPUPWIN_WXPOPUPWINDOW
= 2,
162 POPUPWIN_GENERICTLW
= 3
166 #if USE_TRANSIENT_POPUP
167 // wxPopupTransientWindow is implemented
169 #define wxComboPopupWindowBase wxPopupTransientWindow
170 #define PRIMARY_POPUP_TYPE POPUPWIN_WXPOPUPTRANSIENTWINDOW
171 #define USES_WXPOPUPTRANSIENTWINDOW 1
173 #if TRANSIENT_POPUPWIN_IS_PERFECT
175 #elif POPUPWIN_IS_PERFECT
176 #define wxComboPopupWindowBase2 wxPopupWindow
177 #define SECONDARY_POPUP_TYPE POPUPWIN_WXPOPUPWINDOW
178 #define USES_WXPOPUPWINDOW 1
180 #define wxComboPopupWindowBase2 wxComboCtrlGenericTLW
181 #define SECONDARY_POPUP_TYPE POPUPWIN_GENERICTLW
182 #define USES_GENERICTLW 1
186 // wxPopupWindow (but not wxPopupTransientWindow) is properly implemented
188 #define wxComboPopupWindowBase wxPopupWindow
189 #define PRIMARY_POPUP_TYPE POPUPWIN_WXPOPUPWINDOW
190 #define USES_WXPOPUPWINDOW 1
192 #if !POPUPWIN_IS_PERFECT
193 #define wxComboPopupWindowBase2 wxComboCtrlGenericTLW
194 #define SECONDARY_POPUP_TYPE POPUPWIN_GENERICTLW
195 #define USES_GENERICTLW 1
199 // wxPopupWindow is not implemented
201 #define wxComboPopupWindowBase wxComboCtrlGenericTLW
202 #define PRIMARY_POPUP_TYPE POPUPWIN_GENERICTLW
203 #define USES_GENERICTLW 1
208 #ifndef USES_WXPOPUPTRANSIENTWINDOW
209 #define USES_WXPOPUPTRANSIENTWINDOW 0
212 #ifndef USES_WXPOPUPWINDOW
213 #define USES_WXPOPUPWINDOW 0
216 #ifndef USES_GENERICTLW
217 #define USES_GENERICTLW 0
221 #if USES_WXPOPUPWINDOW
222 #define INSTALL_TOPLEV_HANDLER 1
224 #define INSTALL_TOPLEV_HANDLER 0
228 // Returns true if given popup window type can be classified as perfect
230 static inline bool IsPopupWinTypePerfect( wxByte popupWinType
)
232 #if POPUPWIN_IS_PERFECT && TRANSIENT_POPUPWIN_IS_PERFECT
233 wxUnusedVar(popupWinType
);
236 return ( popupWinType
== POPUPWIN_GENERICTLW
237 #if POPUPWIN_IS_PERFECT
238 || popupWinType
== POPUPWIN_WXPOPUPWINDOW
240 #if TRANSIENT_POPUPWIN_IS_PERFECT
241 || popupWinType
== POPUPWIN_WXPOPUPTRANSIENTWINDOW
250 // * wxComboPopupWindow for external use (ie. replace old wxUniv wxPopupComboWindow)
254 // ----------------------------------------------------------------------------
255 // wxComboFrameEventHandler takes care of hiding the popup when events happen
256 // in its top level parent.
257 // ----------------------------------------------------------------------------
259 #if INSTALL_TOPLEV_HANDLER
262 // This will no longer be necessary after wxTransientPopupWindow
263 // works well on all platforms.
266 class wxComboFrameEventHandler
: public wxEvtHandler
269 wxComboFrameEventHandler( wxComboCtrlBase
* pCb
);
270 virtual ~wxComboFrameEventHandler();
274 void OnIdle( wxIdleEvent
& event
);
275 void OnMouseEvent( wxMouseEvent
& event
);
276 void OnActivate( wxActivateEvent
& event
);
277 void OnResize( wxSizeEvent
& event
);
278 void OnMove( wxMoveEvent
& event
);
279 void OnMenuEvent( wxMenuEvent
& event
);
280 void OnClose( wxCloseEvent
& event
);
283 wxWindow
* m_focusStart
;
284 wxComboCtrlBase
* m_combo
;
287 DECLARE_EVENT_TABLE()
290 BEGIN_EVENT_TABLE(wxComboFrameEventHandler
, wxEvtHandler
)
291 EVT_IDLE(wxComboFrameEventHandler::OnIdle
)
292 EVT_LEFT_DOWN(wxComboFrameEventHandler::OnMouseEvent
)
293 EVT_RIGHT_DOWN(wxComboFrameEventHandler::OnMouseEvent
)
294 EVT_SIZE(wxComboFrameEventHandler::OnResize
)
295 EVT_MOVE(wxComboFrameEventHandler::OnMove
)
296 EVT_MENU_HIGHLIGHT(wxID_ANY
,wxComboFrameEventHandler::OnMenuEvent
)
297 EVT_MENU_OPEN(wxComboFrameEventHandler::OnMenuEvent
)
298 EVT_ACTIVATE(wxComboFrameEventHandler::OnActivate
)
299 EVT_CLOSE(wxComboFrameEventHandler::OnClose
)
302 wxComboFrameEventHandler::wxComboFrameEventHandler( wxComboCtrlBase
* combo
)
308 wxComboFrameEventHandler::~wxComboFrameEventHandler()
312 void wxComboFrameEventHandler::OnPopup()
314 m_focusStart
= ::wxWindow::FindFocus();
317 void wxComboFrameEventHandler::OnIdle( wxIdleEvent
& event
)
319 wxWindow
* winFocused
= ::wxWindow::FindFocus();
321 wxWindow
* popup
= m_combo
->GetPopupControl()->GetControl();
322 wxWindow
* winpopup
= m_combo
->GetPopupWindow();
325 winFocused
!= m_focusStart
&&
326 winFocused
!= popup
&&
327 winFocused
->GetParent() != popup
&&
328 winFocused
!= winpopup
&&
329 winFocused
->GetParent() != winpopup
&&
330 winFocused
!= m_combo
&&
331 winFocused
!= m_combo
->GetButton() // GTK (atleast) requires this
334 m_combo
->HidePopup(true);
340 void wxComboFrameEventHandler::OnMenuEvent( wxMenuEvent
& event
)
342 m_combo
->HidePopup(true);
346 void wxComboFrameEventHandler::OnMouseEvent( wxMouseEvent
& event
)
348 m_combo
->HidePopup(true);
352 void wxComboFrameEventHandler::OnClose( wxCloseEvent
& event
)
354 m_combo
->HidePopup(true);
358 void wxComboFrameEventHandler::OnActivate( wxActivateEvent
& event
)
360 m_combo
->HidePopup(true);
364 void wxComboFrameEventHandler::OnResize( wxSizeEvent
& event
)
366 m_combo
->HidePopup(true);
370 void wxComboFrameEventHandler::OnMove( wxMoveEvent
& event
)
372 m_combo
->HidePopup(true);
376 #endif // INSTALL_TOPLEV_HANDLER
378 // ----------------------------------------------------------------------------
379 // wxComboPopupWindow is, in essence, wxPopupWindow customized for
381 // ----------------------------------------------------------------------------
383 class wxComboPopupWindow
: public wxComboPopupWindowBase
387 wxComboPopupWindow( wxComboCtrlBase
*parent
,
389 #if USES_WXPOPUPWINDOW || USES_WXPOPUPTRANSIENTWINDOW
390 : wxComboPopupWindowBase(parent
,style
)
392 : wxComboPopupWindowBase(parent
,
403 #if USES_WXPOPUPTRANSIENTWINDOW
404 virtual bool Show( bool show
);
405 virtual bool ProcessLeftDown(wxMouseEvent
& event
);
407 virtual void OnDismiss();
415 #if USES_WXPOPUPTRANSIENTWINDOW
416 bool wxComboPopupWindow::Show( bool show
)
418 // Guard against recursion
420 return wxComboPopupWindowBase::Show(show
);
424 wxASSERT( IsKindOf(CLASSINFO(wxPopupTransientWindow
)) );
426 wxPopupTransientWindow
* ptw
= (wxPopupTransientWindow
*) this;
428 if ( show
!= ptw
->IsShown() )
431 // We used to do wxPopupTransientWindow::Popup here,
432 // but this would hide normal Show, which we are
433 // also going to need.
444 bool wxComboPopupWindow::ProcessLeftDown(wxMouseEvent
& event
)
446 return wxPopupTransientWindow::ProcessLeftDown(event
);
449 // First thing that happens when a transient popup closes is that this method gets called.
450 void wxComboPopupWindow::OnDismiss()
452 wxComboCtrlBase
* combo
= (wxComboCtrlBase
*) GetParent();
453 wxASSERT_MSG( combo
->IsKindOf(CLASSINFO(wxComboCtrlBase
)),
454 wxT("parent might not be wxComboCtrl, but check IMPLEMENT_DYNAMIC_CLASS(2) macro for correctness") );
456 combo
->OnPopupDismiss(true);
458 #endif // USES_WXPOPUPTRANSIENTWINDOW
461 // ----------------------------------------------------------------------------
462 // wxComboPopupWindowEvtHandler does bulk of the custom event handling
463 // of a popup window. It is separate so we can have different types
465 // ----------------------------------------------------------------------------
467 class wxComboPopupWindowEvtHandler
: public wxEvtHandler
471 wxComboPopupWindowEvtHandler( wxComboCtrlBase
*parent
)
476 void OnSizeEvent( wxSizeEvent
& event
);
477 void OnKeyEvent(wxKeyEvent
& event
);
479 void OnActivate( wxActivateEvent
& event
);
483 wxComboCtrlBase
* m_combo
;
485 DECLARE_EVENT_TABLE()
489 BEGIN_EVENT_TABLE(wxComboPopupWindowEvtHandler
, wxEvtHandler
)
490 EVT_KEY_DOWN(wxComboPopupWindowEvtHandler::OnKeyEvent
)
491 EVT_KEY_UP(wxComboPopupWindowEvtHandler::OnKeyEvent
)
492 EVT_CHAR(wxComboPopupWindowEvtHandler::OnKeyEvent
)
494 EVT_ACTIVATE(wxComboPopupWindowEvtHandler::OnActivate
)
496 EVT_SIZE(wxComboPopupWindowEvtHandler::OnSizeEvent
)
500 void wxComboPopupWindowEvtHandler::OnSizeEvent( wxSizeEvent
& WXUNUSED(event
) )
502 // Block the event so that the popup control does not get auto-resized.
505 void wxComboPopupWindowEvtHandler::OnKeyEvent( wxKeyEvent
& event
)
507 // Relay keyboard event to the main child controls
508 wxWindowList children
= m_combo
->GetPopupWindow()->GetChildren();
509 wxWindowList::iterator node
= children
.begin();
510 wxWindow
* child
= (wxWindow
*)*node
;
511 child
->GetEventHandler()->ProcessEvent(event
);
515 void wxComboPopupWindowEvtHandler::OnActivate( wxActivateEvent
& event
)
517 if ( !event
.GetActive() )
519 // Tell combo control that we are dismissed.
520 m_combo
->HidePopup(true);
528 // ----------------------------------------------------------------------------
531 // ----------------------------------------------------------------------------
533 wxComboPopup::~wxComboPopup()
537 void wxComboPopup::OnPopup()
541 void wxComboPopup::OnDismiss()
545 wxComboCtrl
* wxComboPopup::GetComboCtrl() const
547 return wxStaticCast(m_combo
, wxComboCtrl
);
550 wxSize
wxComboPopup::GetAdjustedSize( int minWidth
,
552 int WXUNUSED(maxHeight
) )
554 return wxSize(minWidth
,prefHeight
);
557 void wxComboPopup::DefaultPaintComboControl( wxComboCtrlBase
* combo
,
558 wxDC
& dc
, const wxRect
& rect
)
560 if ( combo
->GetWindowStyle() & wxCB_READONLY
) // ie. no textctrl
562 combo
->PrepareBackground(dc
,rect
,0);
564 dc
.DrawText( combo
->GetValue(),
565 rect
.x
+ combo
->m_marginLeft
,
566 (rect
.height
-dc
.GetCharHeight())/2 + rect
.y
);
570 void wxComboPopup::PaintComboControl( wxDC
& dc
, const wxRect
& rect
)
572 DefaultPaintComboControl(m_combo
,dc
,rect
);
575 void wxComboPopup::OnComboKeyEvent( wxKeyEvent
& event
)
580 void wxComboPopup::OnComboCharEvent( wxKeyEvent
& event
)
585 void wxComboPopup::OnComboDoubleClick()
589 void wxComboPopup::SetStringValue( const wxString
& WXUNUSED(value
) )
593 bool wxComboPopup::LazyCreate()
598 void wxComboPopup::Dismiss()
600 m_combo
->HidePopup(true);
603 // ----------------------------------------------------------------------------
605 // ----------------------------------------------------------------------------
608 // This is pushed to the event handler queue of the child textctrl.
610 class wxComboBoxExtraInputHandler
: public wxEvtHandler
614 wxComboBoxExtraInputHandler( wxComboCtrlBase
* combo
)
619 virtual ~wxComboBoxExtraInputHandler() { }
620 void OnKey(wxKeyEvent
& event
);
621 void OnFocus(wxFocusEvent
& event
);
624 wxComboCtrlBase
* m_combo
;
627 DECLARE_EVENT_TABLE()
631 BEGIN_EVENT_TABLE(wxComboBoxExtraInputHandler
, wxEvtHandler
)
632 EVT_KEY_DOWN(wxComboBoxExtraInputHandler::OnKey
)
633 EVT_KEY_UP(wxComboBoxExtraInputHandler::OnKey
)
634 EVT_CHAR(wxComboBoxExtraInputHandler::OnKey
)
635 EVT_SET_FOCUS(wxComboBoxExtraInputHandler::OnFocus
)
636 EVT_KILL_FOCUS(wxComboBoxExtraInputHandler::OnFocus
)
640 void wxComboBoxExtraInputHandler::OnKey(wxKeyEvent
& event
)
642 // Let the wxComboCtrl event handler have a go first.
643 wxComboCtrlBase
* combo
= m_combo
;
645 wxKeyEvent
redirectedEvent(event
);
646 redirectedEvent
.SetId(combo
->GetId());
647 redirectedEvent
.SetEventObject(combo
);
649 if ( !combo
->GetEventHandler()->ProcessEvent(redirectedEvent
) )
651 // Don't let TAB through to the text ctrl - looks ugly
652 if ( event
.GetKeyCode() != WXK_TAB
)
657 void wxComboBoxExtraInputHandler::OnFocus(wxFocusEvent
& event
)
659 // FIXME: This code does run when control is clicked,
660 // yet on Windows it doesn't select all the text.
661 if ( event
.GetEventType() == wxEVT_SET_FOCUS
&&
662 !(m_combo
->GetInternalFlags() & wxCC_NO_TEXT_AUTO_SELECT
) )
664 if ( m_combo
->GetTextCtrl() )
665 m_combo
->GetTextCtrl()->SelectAll();
667 m_combo
->SetSelection(-1,-1);
670 // Send focus indication to parent.
671 // NB: This is needed for cases where the textctrl gets focus
672 // instead of its parent. While this may trigger multiple
673 // wxEVT_SET_FOCUSes (since m_text->SetFocus is called
674 // from combo's focus event handler), they should be quite
676 wxFocusEvent
evt2(event
.GetEventType(),m_combo
->GetId());
677 evt2
.SetEventObject(m_combo
);
678 m_combo
->GetEventHandler()->ProcessEvent(evt2
);
685 // This is pushed to the event handler queue of the control in popup.
688 class wxComboPopupEvtHandler
: public wxEvtHandler
692 wxComboPopupEvtHandler( wxComboCtrlBase
* combo
)
696 m_beenInside
= false;
698 // Let's make it so that the popup control will not receive mouse
699 // events until mouse left button has been up.
700 m_blockEventsToPopup
= true;
702 virtual ~wxComboPopupEvtHandler() { }
704 void OnMouseEvent( wxMouseEvent
& event
);
706 // Called from wxComboCtrlBase::OnPopupDismiss
707 void OnPopupDismiss()
709 m_beenInside
= false;
710 m_blockEventsToPopup
= true;
714 wxComboCtrlBase
* m_combo
;
717 bool m_blockEventsToPopup
;
720 DECLARE_EVENT_TABLE()
724 BEGIN_EVENT_TABLE(wxComboPopupEvtHandler
, wxEvtHandler
)
725 EVT_MOUSE_EVENTS(wxComboPopupEvtHandler::OnMouseEvent
)
729 void wxComboPopupEvtHandler::OnMouseEvent( wxMouseEvent
& event
)
731 wxPoint pt
= event
.GetPosition();
732 wxSize sz
= m_combo
->GetPopupControl()->GetControl()->GetClientSize();
733 int evtType
= event
.GetEventType();
734 bool isInside
= pt
.x
>= 0 && pt
.y
>= 0 && pt
.x
< sz
.x
&& pt
.y
< sz
.y
;
735 bool relayToButton
= false;
739 if ( !isInside
|| !m_combo
->IsPopupShown() )
741 // Mouse is outside the popup or popup is not actually shown (yet)
743 if ( evtType
== wxEVT_MOTION
||
744 evtType
== wxEVT_LEFT_DOWN
||
745 evtType
== wxEVT_LEFT_UP
||
746 evtType
== wxEVT_RIGHT_DOWN
)
748 // Block motion and click events outside the popup
754 // Mouse is inside the popup, which is fully shown
758 // Do not let the popup control respond to mouse events until
759 // mouse press used to display the popup has been lifted. This
760 // is important for users with slower mouse fingers or mouse
761 // drivers. Note that we have some redundancy here, just in
762 // case the popup is some native control that does not emit all
763 // mouse event types.
764 if ( evtType
== wxEVT_MOTION
)
766 if ( m_blockEventsToPopup
)
768 if ( event
.LeftIsDown() )
771 m_blockEventsToPopup
= false;
774 else if ( evtType
== wxEVT_LEFT_DOWN
)
776 if ( m_blockEventsToPopup
)
777 m_blockEventsToPopup
= false;
779 else if ( evtType
== wxEVT_LEFT_UP
)
781 if ( m_blockEventsToPopup
)
783 // On first left up, stop blocking mouse events (but still
785 m_blockEventsToPopup
= false;
788 // Also, this button press was (probably) used to display
789 // the popup, so relay it back to the drop-down button
790 // (which supposedly originated it). This is necessary to
791 // refresh it properly.
792 relayToButton
= true;
795 else if ( m_blockEventsToPopup
)
802 // Some mouse events to popup that happen outside it, before cursor
803 // has been inside the popup, need to be ignored by it but relayed to
806 if ( evtType
== wxEVT_LEFT_UP
)
808 if ( !m_combo
->IsPopupShown() )
811 relayToButton
= true;
813 else if ( !isInside
&& !m_beenInside
)
815 // Popup is shown but the cursor is not inside, nor it has been
816 relayToButton
= true;
822 wxWindow
* btn
= m_combo
->GetButton();
824 btn
->GetEventHandler()->ProcessEvent(event
);
826 // Bypass the event handling mechanism. Using it would be
827 // confusing for the platform-specific wxComboCtrl
829 m_combo
->HandleButtonMouseEvent(event
, 0);
833 // ----------------------------------------------------------------------------
834 // wxComboCtrlTextCtrl
835 // ----------------------------------------------------------------------------
837 class wxComboCtrlTextCtrl
: public wxTextCtrl
840 wxComboCtrlTextCtrl() : wxTextCtrl() { }
841 virtual ~wxComboCtrlTextCtrl() { }
843 virtual wxWindow
*GetMainWindowOfCompositeControl()
845 wxComboCtrl
* combo
= (wxComboCtrl
*) GetParent();
847 // Returning this instead of just 'parent' lets FindFocus work
848 // correctly even when parent control is a child of a composite
849 // generic control (as is case with wxGenericDatePickerCtrl).
850 return combo
->GetMainWindowOfCompositeControl();
854 // ----------------------------------------------------------------------------
856 // ----------------------------------------------------------------------------
859 BEGIN_EVENT_TABLE(wxComboCtrlBase
, wxControl
)
860 EVT_TEXT(wxID_ANY
,wxComboCtrlBase::OnTextCtrlEvent
)
861 EVT_SIZE(wxComboCtrlBase::OnSizeEvent
)
862 EVT_SET_FOCUS(wxComboCtrlBase::OnFocusEvent
)
863 EVT_KILL_FOCUS(wxComboCtrlBase::OnFocusEvent
)
864 EVT_IDLE(wxComboCtrlBase::OnIdleEvent
)
865 //EVT_BUTTON(wxID_ANY,wxComboCtrlBase::OnButtonClickEvent)
866 EVT_KEY_DOWN(wxComboCtrlBase::OnKeyEvent
)
867 EVT_CHAR(wxComboCtrlBase::OnCharEvent
)
868 EVT_TEXT_ENTER(wxID_ANY
,wxComboCtrlBase::OnTextCtrlEvent
)
869 EVT_SYS_COLOUR_CHANGED(wxComboCtrlBase::OnSysColourChanged
)
873 IMPLEMENT_ABSTRACT_CLASS(wxComboCtrlBase
, wxControl
)
875 void wxComboCtrlBase::Init()
879 m_popupWinState
= Hidden
;
882 m_popupInterface
= NULL
;
884 m_popupEvtHandler
= NULL
;
885 m_textEvtHandler
= NULL
;
887 #if INSTALL_TOPLEV_HANDLER
888 m_toplevEvtHandler
= NULL
;
891 m_mainCtrlWnd
= this;
894 m_widthMinPopup
= -1;
896 m_widthCustomPaint
= 0;
897 m_widthCustomBorder
= 0;
901 m_blankButtonBg
= false;
903 m_popupWinType
= POPUPWIN_NONE
;
904 m_btnWid
= m_btnHei
= -1;
913 m_timeCanAcceptClick
= 0;
915 m_resetFocus
= false;
918 bool wxComboCtrlBase::Create(wxWindow
*parent
,
920 const wxString
& value
,
924 const wxValidator
& validator
,
925 const wxString
& name
)
927 if ( !wxControl::Create(parent
,
931 style
| wxWANTS_CHARS
,
936 m_valueString
= value
;
940 m_marginLeft
= GetNativeTextIndent();
942 m_iFlags
|= wxCC_IFLAG_CREATED
;
944 // If x and y indicate valid size, wxSizeEvent won't be
945 // emitted automatically, so we need to add artifical one.
946 if ( size
.x
> 0 && size
.y
> 0 )
948 wxSizeEvent
evt(size
,GetId());
949 GetEventHandler()->AddPendingEvent(evt
);
955 void wxComboCtrlBase::InstallInputHandlers()
959 m_textEvtHandler
= new wxComboBoxExtraInputHandler(this);
960 m_text
->PushEventHandler(m_textEvtHandler
);
965 wxComboCtrlBase::CreateTextCtrl(int style
, const wxValidator
& validator
)
967 if ( !(m_windowStyle
& wxCB_READONLY
) )
972 // wxTE_PROCESS_TAB is needed because on Windows, wxTAB_TRAVERSAL is
973 // not used by the wxPropertyGrid and therefore the tab is processed by
974 // looking at ancestors to see if they have wxTAB_TRAVERSAL. The
975 // navigation event is then sent to the wrong window.
976 style
|= wxTE_PROCESS_TAB
| m_textCtrlStyle
;
978 if ( HasFlag(wxTE_PROCESS_ENTER
) )
979 style
|= wxTE_PROCESS_ENTER
;
981 // Ignore EVT_TEXT generated by the constructor (but only
982 // if the event redirector already exists)
983 // NB: This must be " = 1" instead of "++";
984 if ( m_textEvtHandler
)
989 m_text
= new wxComboCtrlTextCtrl();
990 m_text
->Create(this, wxID_ANY
, m_valueString
,
991 wxDefaultPosition
, wxSize(10,-1),
993 m_text
->SetHint(m_hintText
);
997 void wxComboCtrlBase::OnThemeChange()
999 // Leave the default bg on the Mac so the area used by the focus ring will
1000 // be the correct colour and themed brush. Instead we'll use
1001 // wxSYS_COLOUR_WINDOW in the EVT_PAINT handler as needed.
1003 #if defined(__WXMSW__) || defined(__WXGTK__)
1004 wxVisualAttributes vattrs
= wxComboBox::GetClassDefaultAttributes();
1006 wxVisualAttributes vattrs
;
1007 vattrs
.colFg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
1008 vattrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW
);
1011 // Only change the colours if application has not specified
1015 SetOwnForegroundColour(vattrs
.colFg
);
1020 SetOwnBackgroundColour(vattrs
.colBg
);
1023 #endif // !__WXMAC__
1026 wxComboCtrlBase::~wxComboCtrlBase()
1031 #if INSTALL_TOPLEV_HANDLER
1032 delete ((wxComboFrameEventHandler
*)m_toplevEvtHandler
);
1033 m_toplevEvtHandler
= NULL
;
1039 m_text
->RemoveEventHandler(m_textEvtHandler
);
1041 delete m_textEvtHandler
;
1045 // ----------------------------------------------------------------------------
1047 // ----------------------------------------------------------------------------
1049 // Recalculates button and textctrl areas
1050 void wxComboCtrlBase::CalculateAreas( int btnWidth
)
1052 wxSize sz
= GetClientSize();
1053 int customBorder
= m_widthCustomBorder
;
1054 int btnBorder
; // border for button only
1056 // check if button should really be outside the border: we'll do it it if
1057 // its platform default or bitmap+pushbutton background is used, but not if
1058 // there is vertical size adjustment or horizontal spacing.
1059 if ( ( (m_iFlags
& wxCC_BUTTON_OUTSIDE_BORDER
) ||
1060 (m_bmpNormal
.Ok() && m_blankButtonBg
) ) &&
1061 m_btnSpacingX
== 0 &&
1064 m_iFlags
|= wxCC_IFLAG_BUTTON_OUTSIDE
;
1067 else if ( (m_iFlags
& wxCC_BUTTON_COVERS_BORDER
) &&
1068 m_btnSpacingX
== 0 && !m_bmpNormal
.Ok() )
1070 m_iFlags
&= ~(wxCC_IFLAG_BUTTON_OUTSIDE
);
1075 m_iFlags
&= ~(wxCC_IFLAG_BUTTON_OUTSIDE
);
1076 btnBorder
= customBorder
;
1079 // Defaul indentation
1080 if ( m_marginLeft
< 0 )
1081 m_marginLeft
= GetNativeTextIndent();
1083 int butWidth
= btnWidth
;
1085 if ( butWidth
<= 0 )
1086 butWidth
= m_btnWidDefault
;
1088 m_btnWidDefault
= butWidth
;
1090 if ( butWidth
<= 0 )
1093 int butHeight
= sz
.y
- btnBorder
*2;
1095 // Adjust button width
1097 butWidth
= m_btnWid
;
1100 // Adjust button width to match aspect ratio
1101 // (but only if control is smaller than best size).
1102 int bestHeight
= GetBestSize().y
;
1103 int height
= GetSize().y
;
1105 if ( height
< bestHeight
)
1107 // Make very small buttons square, as it makes
1108 // them accommodate arrow image better and still
1111 butWidth
= (height
*butWidth
)/bestHeight
;
1113 butWidth
= butHeight
;
1117 // Adjust button height
1119 butHeight
= m_btnHei
;
1121 // Use size of normal bitmap if...
1124 // button width is set to default and blank button bg is not drawn
1125 if ( m_bmpNormal
.Ok() )
1127 int bmpReqWidth
= m_bmpNormal
.GetWidth();
1128 int bmpReqHeight
= m_bmpNormal
.GetHeight();
1130 // If drawing blank button background, we need to add some margin.
1131 if ( m_blankButtonBg
)
1133 bmpReqWidth
+= BMP_BUTTON_MARGIN
*2;
1134 bmpReqHeight
+= BMP_BUTTON_MARGIN
*2;
1137 if ( butWidth
< bmpReqWidth
|| ( m_btnWid
== 0 && !m_blankButtonBg
) )
1138 butWidth
= bmpReqWidth
;
1139 if ( butHeight
< bmpReqHeight
|| ( m_btnHei
== 0 && !m_blankButtonBg
) )
1140 butHeight
= bmpReqHeight
;
1142 // Need to fix height?
1143 if ( (sz
.y
-(customBorder
*2)) < butHeight
&& btnWidth
== 0 )
1145 int newY
= butHeight
+(customBorder
*2);
1146 SetClientSize(wxDefaultCoord
,newY
);
1147 if ( m_bmpNormal
.Ok() || m_btnArea
.width
!= butWidth
|| m_btnArea
.height
!= butHeight
)
1148 m_iFlags
|= wxCC_IFLAG_HAS_NONSTANDARD_BUTTON
;
1150 m_iFlags
&= ~wxCC_IFLAG_HAS_NONSTANDARD_BUTTON
;
1156 int butAreaWid
= butWidth
+ (m_btnSpacingX
*2);
1158 m_btnSize
.x
= butWidth
;
1159 m_btnSize
.y
= butHeight
;
1161 m_btnArea
.x
= ( m_btnSide
==wxRIGHT
? sz
.x
- butAreaWid
- btnBorder
: btnBorder
);
1162 m_btnArea
.y
= btnBorder
+ FOCUS_RING
;
1163 m_btnArea
.width
= butAreaWid
;
1164 m_btnArea
.height
= sz
.y
- ((btnBorder
+FOCUS_RING
)*2);
1166 m_tcArea
.x
= ( m_btnSide
==wxRIGHT
? 0 : butAreaWid
) + customBorder
+ FOCUS_RING
;
1167 m_tcArea
.y
= customBorder
+ FOCUS_RING
;
1168 m_tcArea
.width
= sz
.x
- butAreaWid
- (customBorder
*2) - (FOCUS_RING
*2);
1169 m_tcArea
.height
= sz
.y
- ((customBorder
+FOCUS_RING
)*2);
1174 ::wxMessageBox(wxString::Format(wxT("ButtonArea (%i,%i,%i,%i)\n"),m_btnArea.x,m_btnArea.y,m_btnArea.width,m_btnArea.height) +
1175 wxString::Format(wxT("TextCtrlArea (%i,%i,%i,%i)"),m_tcArea.x,m_tcArea.y,m_tcArea.width,m_tcArea.height));
1180 void wxComboCtrlBase::PositionTextCtrl( int textCtrlXAdjust
, int textCtrlYAdjust
)
1185 wxSize sz
= GetClientSize();
1187 int customBorder
= m_widthCustomBorder
;
1188 if ( (m_text
->GetWindowStyleFlag() & wxBORDER_MASK
) == wxNO_BORDER
)
1192 if ( !m_widthCustomPaint
)
1194 // No special custom paint area - we can use 0 left margin
1196 if ( m_text
->SetMargins(0) )
1197 textCtrlXAdjust
= 0;
1198 x
= m_tcArea
.x
+ m_marginLeft
+ textCtrlXAdjust
;
1202 // There is special custom paint area - it is better to
1203 // use some margin with the wxTextCtrl.
1204 m_text
->SetMargins(m_marginLeft
);
1205 x
= m_tcArea
.x
+ m_widthCustomPaint
+
1206 m_marginLeft
+ textCtrlXAdjust
;
1209 // Centre textctrl vertically, if needed
1210 #if !TEXTCTRL_TEXT_CENTERED
1211 int tcSizeY
= m_text
->GetBestSize().y
;
1212 int diff0
= sz
.y
- tcSizeY
;
1213 int y
= textCtrlYAdjust
+ (diff0
/2);
1215 wxUnusedVar(textCtrlYAdjust
);
1219 if ( y
< customBorder
)
1224 m_tcArea
.width
- m_tcArea
.x
- x
,
1227 // Make sure textctrl doesn't exceed the bottom custom border
1228 wxSize tsz
= m_text
->GetSize();
1229 int diff1
= (y
+ tsz
.y
) - (sz
.y
- customBorder
);
1232 tsz
.y
= tsz
.y
- diff1
- 1;
1233 m_text
->SetSize(tsz
);
1238 // If it has border, have textctrl fill the entire text field.
1239 m_text
->SetSize( m_tcArea
.x
+ m_widthCustomPaint
,
1241 m_tcArea
.width
- m_widthCustomPaint
,
1246 wxSize
wxComboCtrlBase::DoGetBestSize() const
1248 wxSize
sizeText(150,0);
1251 sizeText
= m_text
->GetBestSize();
1253 // TODO: Better method to calculate close-to-native control height.
1257 fhei
= (m_font
.GetPointSize()*2) + 5;
1258 else if ( wxNORMAL_FONT
->Ok() )
1259 fhei
= (wxNORMAL_FONT
->GetPointSize()*2) + 5;
1261 fhei
= sizeText
.y
+ 4;
1263 // Need to force height to accomodate bitmap?
1264 int btnSizeY
= m_btnSize
.y
;
1265 if ( m_bmpNormal
.Ok() && fhei
< btnSizeY
)
1268 // Control height doesn't depend on border
1271 int border = m_windowStyle & wxBORDER_MASK;
1272 if ( border == wxSIMPLE_BORDER )
1274 else if ( border == wxNO_BORDER )
1275 fhei += (m_widthCustomBorder*2);
1281 // Final adjustments
1287 // these are the numbers from the HIG:
1288 switch ( m_windowVariant
)
1290 case wxWINDOW_VARIANT_NORMAL
:
1294 case wxWINDOW_VARIANT_SMALL
:
1297 case wxWINDOW_VARIANT_MINI
:
1303 fhei
+= 2 * FOCUS_RING
;
1304 int width
= sizeText
.x
+ FOCUS_RING
+ COMBO_MARGIN
+ DEFAULT_DROPBUTTON_WIDTH
;
1306 wxSize
ret(width
, fhei
);
1311 void wxComboCtrlBase::OnSizeEvent( wxSizeEvent
& event
)
1316 // defined by actual wxComboCtrls
1322 // ----------------------------------------------------------------------------
1323 // standard operations
1324 // ----------------------------------------------------------------------------
1326 bool wxComboCtrlBase::Enable(bool enable
)
1328 if ( !wxControl::Enable(enable
) )
1332 m_btn
->Enable(enable
);
1334 m_text
->Enable(enable
);
1341 bool wxComboCtrlBase::Show(bool show
)
1343 if ( !wxControl::Show(show
) )
1355 bool wxComboCtrlBase::SetFont ( const wxFont
& font
)
1357 if ( !wxControl::SetFont(font
) )
1362 // Without hiding the wxTextCtrl there would be some
1363 // visible 'flicker' (at least on Windows XP).
1365 m_text
->SetFont(font
);
1374 void wxComboCtrlBase::DoSetToolTip(wxToolTip
*tooltip
)
1376 wxControl::DoSetToolTip(tooltip
);
1378 // Set tool tip for button and text box
1381 const wxString
&tip
= tooltip
->GetTip();
1382 if ( m_text
) m_text
->SetToolTip(tip
);
1383 if ( m_btn
) m_btn
->SetToolTip(tip
);
1387 if ( m_text
) m_text
->SetToolTip( NULL
);
1388 if ( m_btn
) m_btn
->SetToolTip( NULL
);
1391 #endif // wxUSE_TOOLTIPS
1393 #if wxUSE_VALIDATORS
1394 void wxComboCtrlBase::SetValidator(const wxValidator
& validator
)
1396 wxTextCtrl
* textCtrl
= GetTextCtrl();
1399 textCtrl
->SetValidator( validator
);
1401 wxControl::SetValidator( validator
);
1404 wxValidator
* wxComboCtrlBase::GetValidator()
1406 wxTextCtrl
* textCtrl
= GetTextCtrl();
1408 return textCtrl
? textCtrl
->GetValidator() : wxControl::GetValidator();
1410 #endif // wxUSE_VALIDATORS
1412 bool wxComboCtrlBase::SetForegroundColour(const wxColour
& colour
)
1414 if ( wxControl::SetForegroundColour(colour
) )
1417 m_text
->SetForegroundColour(colour
);
1423 bool wxComboCtrlBase::SetBackgroundColour(const wxColour
& colour
)
1425 if ( wxControl::SetBackgroundColour(colour
) )
1428 m_text
->SetBackgroundColour(colour
);
1433 // ----------------------------------------------------------------------------
1435 // ----------------------------------------------------------------------------
1437 #if (!defined(__WXMSW__)) || defined(__WXUNIVERSAL__)
1438 // prepare combo box background on area in a way typical on platform
1439 void wxComboCtrlBase::PrepareBackground( wxDC
& dc
, const wxRect
& rect
, int flags
) const
1441 wxSize sz
= GetClientSize();
1443 bool doDrawFocusRect
; // also selected
1445 // For smaller size control (and for disabled background) use less spacing
1449 if ( !(flags
& wxCONTROL_ISSUBMENU
) )
1452 isEnabled
= IsEnabled();
1453 doDrawFocusRect
= ShouldDrawFocus() && !(m_iFlags
& wxCC_FULL_BUTTON
);
1455 // Windows-style: for smaller size control (and for disabled background) use less spacing
1456 focusSpacingX
= isEnabled
? 2 : 1;
1457 focusSpacingY
= sz
.y
> (GetCharHeight()+2) && isEnabled
? 2 : 1;
1461 // Drawing a list item
1462 isEnabled
= true; // they are never disabled
1463 doDrawFocusRect
= (flags
& wxCONTROL_SELECTED
) != 0;
1469 // Set the background sub-rectangle for selection, disabled etc
1470 wxRect
selRect(rect
);
1471 selRect
.y
+= focusSpacingY
;
1472 selRect
.height
-= (focusSpacingY
*2);
1476 if ( !(flags
& wxCONTROL_ISSUBMENU
) )
1477 wcp
+= m_widthCustomPaint
;
1479 selRect
.x
+= wcp
+ focusSpacingX
;
1480 selRect
.width
-= wcp
+ (focusSpacingX
*2);
1485 bool doDrawSelRect
= true;
1487 // Determine foreground colour
1490 if ( doDrawFocusRect
)
1492 fgCol
= wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT
);
1494 else if ( m_hasFgCol
)
1496 // Honour the custom foreground colour
1497 fgCol
= GetForegroundColour();
1501 fgCol
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
1506 fgCol
= wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT
);
1509 // Determine background colour
1512 if ( doDrawFocusRect
)
1514 bgCol
= wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT
);
1516 else if ( m_hasBgCol
)
1518 // Honour the custom background colour
1519 bgCol
= GetBackgroundColour();
1523 #ifndef __WXMAC__ // see note in OnThemeChange
1524 doDrawSelRect
= false;
1525 bgCol
= GetBackgroundColour();
1527 bgCol
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW
);
1533 #ifndef __WXMAC__ // see note in OnThemeChange
1534 bgCol
= GetBackgroundColour();
1536 bgCol
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW
);
1540 dc
.SetTextForeground( fgCol
);
1541 dc
.SetBrush( bgCol
);
1542 if ( doDrawSelRect
)
1545 dc
.DrawRectangle( selRect
);
1548 // Don't clip exactly to the selection rectangle so we can draw
1549 // to the non-selected area in front of it.
1550 wxRect
clipRect(rect
.x
,rect
.y
,
1551 (selRect
.x
+selRect
.width
)-rect
.x
,rect
.height
);
1552 dc
.SetClippingRegion(clipRect
);
1555 // Save the library size a bit for platforms that re-implement this.
1556 void wxComboCtrlBase::PrepareBackground( wxDC
&, const wxRect
&, int ) const
1561 void wxComboCtrlBase::DrawButton( wxDC
& dc
, const wxRect
& rect
, int flags
)
1563 int drawState
= m_btnState
;
1565 if ( (m_iFlags
& wxCC_BUTTON_STAYS_DOWN
) &&
1566 GetPopupWindowState() >= Animating
)
1567 drawState
|= wxCONTROL_PRESSED
;
1569 wxRect
drawRect(rect
.x
+m_btnSpacingX
,
1570 rect
.y
+((rect
.height
-m_btnSize
.y
)/2),
1574 // Make sure area is not larger than the control
1575 if ( drawRect
.y
< rect
.y
)
1576 drawRect
.y
= rect
.y
;
1577 if ( drawRect
.height
> rect
.height
)
1578 drawRect
.height
= rect
.height
;
1580 bool enabled
= IsEnabled();
1583 drawState
|= wxCONTROL_DISABLED
;
1585 if ( !m_bmpNormal
.Ok() )
1587 if ( flags
& Button_BitmapOnly
)
1590 // Need to clear button background even if m_btn is present
1591 if ( flags
& Button_PaintBackground
)
1595 if ( m_iFlags
& wxCC_IFLAG_BUTTON_OUTSIDE
)
1596 bgCol
= GetParent()->GetBackgroundColour();
1598 bgCol
= GetBackgroundColour();
1602 dc
.DrawRectangle(rect
);
1605 // Draw standard button
1606 wxRendererNative::Get().DrawComboBoxDropButton(this,
1618 pBmp
= &m_bmpDisabled
;
1619 else if ( m_btnState
& wxCONTROL_PRESSED
)
1620 pBmp
= &m_bmpPressed
;
1621 else if ( m_btnState
& wxCONTROL_CURRENT
)
1624 pBmp
= &m_bmpNormal
;
1626 if ( m_blankButtonBg
)
1628 // If using blank button background, we need to clear its background
1629 // with button face colour instead of colour for rest of the control.
1630 if ( flags
& Button_PaintBackground
)
1632 wxColour bgCol
= GetParent()->GetBackgroundColour(); //wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE);
1633 //wxColour bgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
1636 dc
.DrawRectangle(rect
);
1639 if ( !(flags
& Button_BitmapOnly
) )
1641 wxRendererNative::Get().DrawPushButton(this,
1650 // Need to clear button background even if m_btn is present
1651 // (assume non-button background was cleared just before this call so brushes are good)
1652 if ( flags
& Button_PaintBackground
)
1653 dc
.DrawRectangle(rect
);
1656 // Draw bitmap centered in drawRect
1657 dc
.DrawBitmap(*pBmp
,
1658 drawRect
.x
+ (drawRect
.width
-pBmp
->GetWidth())/2,
1659 drawRect
.y
+ (drawRect
.height
-pBmp
->GetHeight())/2,
1664 void wxComboCtrlBase::RecalcAndRefresh()
1668 wxSizeEvent
evt(GetSize(),GetId());
1669 GetEventHandler()->ProcessEvent(evt
);
1674 // ----------------------------------------------------------------------------
1675 // miscellaneous event handlers
1676 // ----------------------------------------------------------------------------
1678 void wxComboCtrlBase::OnTextCtrlEvent(wxCommandEvent
& event
)
1680 if ( event
.GetEventType() == wxEVT_COMMAND_TEXT_UPDATED
)
1682 if ( m_ignoreEvtText
> 0 )
1689 // Change event id, object and string before relaying it forward
1690 event
.SetId(GetId());
1691 wxString s
= event
.GetString();
1692 event
.SetEventObject(this);
1697 // call if cursor is on button area or mouse is captured for the button
1698 bool wxComboCtrlBase::HandleButtonMouseEvent( wxMouseEvent
& event
,
1701 int type
= event
.GetEventType();
1703 if ( type
== wxEVT_MOTION
)
1705 if ( (flags
& wxCC_MF_ON_BUTTON
) &&
1706 IsPopupWindowState(Hidden
) )
1708 if ( !(m_btnState
& wxCONTROL_CURRENT
) )
1710 // Mouse hover begins
1711 m_btnState
|= wxCONTROL_CURRENT
;
1712 if ( HasCapture() ) // Retain pressed state.
1713 m_btnState
|= wxCONTROL_PRESSED
;
1717 else if ( (m_btnState
& wxCONTROL_CURRENT
) )
1720 m_btnState
&= ~(wxCONTROL_CURRENT
|wxCONTROL_PRESSED
);
1724 else if ( type
== wxEVT_LEFT_DOWN
|| type
== wxEVT_LEFT_DCLICK
)
1726 if ( flags
& (wxCC_MF_ON_CLICK_AREA
|wxCC_MF_ON_BUTTON
) )
1728 m_btnState
|= wxCONTROL_PRESSED
;
1731 if ( !(m_iFlags
& wxCC_POPUP_ON_MOUSE_UP
) )
1734 // If showing popup now, do not capture mouse or there will be interference
1738 else if ( type
== wxEVT_LEFT_UP
)
1741 // Only accept event if mouse was left-press was previously accepted
1745 if ( m_btnState
& wxCONTROL_PRESSED
)
1747 // If mouse was inside, fire the click event.
1748 if ( m_iFlags
& wxCC_POPUP_ON_MOUSE_UP
)
1750 if ( flags
& (wxCC_MF_ON_CLICK_AREA
|wxCC_MF_ON_BUTTON
) )
1754 m_btnState
&= ~(wxCONTROL_PRESSED
);
1758 else if ( type
== wxEVT_LEAVE_WINDOW
)
1760 if ( m_btnState
& (wxCONTROL_CURRENT
|wxCONTROL_PRESSED
) )
1762 m_btnState
&= ~(wxCONTROL_CURRENT
);
1765 if ( IsPopupWindowState(Hidden
) )
1767 m_btnState
&= ~(wxCONTROL_PRESSED
);
1775 // Never have 'hot' state when popup is being shown
1776 // (this is mostly needed because of the animation).
1777 if ( !IsPopupWindowState(Hidden
) )
1778 m_btnState
&= ~wxCONTROL_CURRENT
;
1783 // returns true if event was consumed or filtered
1784 bool wxComboCtrlBase::PreprocessMouseEvent( wxMouseEvent
& event
,
1785 int WXUNUSED(flags
) )
1787 wxLongLong t
= ::wxGetLocalTimeMillis();
1788 int evtType
= event
.GetEventType();
1790 #if USES_WXPOPUPWINDOW || USES_GENERICTLW
1791 if ( m_popupWinType
!= POPUPWIN_WXPOPUPTRANSIENTWINDOW
)
1793 if ( IsPopupWindowState(Visible
) &&
1794 ( evtType
== wxEVT_LEFT_DOWN
|| evtType
== wxEVT_RIGHT_DOWN
) )
1802 // Filter out clicks on button immediately after popup dismiss
1803 if ( evtType
== wxEVT_LEFT_DOWN
&& t
< m_timeCanAcceptClick
)
1805 event
.SetEventType(0);
1812 void wxComboCtrlBase::HandleNormalMouseEvent( wxMouseEvent
& event
)
1814 int evtType
= event
.GetEventType();
1816 if ( (evtType
== wxEVT_LEFT_DOWN
|| evtType
== wxEVT_LEFT_DCLICK
) &&
1817 (m_windowStyle
& wxCB_READONLY
) )
1819 if ( GetPopupWindowState() >= Animating
)
1821 #if USES_WXPOPUPWINDOW
1822 // Click here always hides the popup.
1823 if ( m_popupWinType
== POPUPWIN_WXPOPUPWINDOW
)
1829 if ( !(m_windowStyle
& wxCC_SPECIAL_DCLICK
) )
1831 // In read-only mode, clicking the text is the
1832 // same as clicking the button.
1835 else if ( /*evtType == wxEVT_LEFT_UP || */evtType
== wxEVT_LEFT_DCLICK
)
1837 //if ( m_popupInterface->CycleValue() )
1839 if ( m_popupInterface
)
1840 m_popupInterface
->OnComboDoubleClick();
1844 else if ( evtType
== wxEVT_MOUSEWHEEL
)
1846 if ( IsPopupShown() )
1848 // relay (some) mouse events to the popup
1849 m_popup
->GetEventHandler()->ProcessEvent(event
);
1851 else if ( event
.GetWheelAxis() == 0 &&
1852 event
.GetWheelRotation() != 0 &&
1853 event
.GetModifiers() == 0 )
1855 // Translate mousewheel actions into key up/down. This is
1856 // the simplest way of getting native behaviour: scrolling the
1857 // wheel moves selection up/down by one item.
1858 wxKeyEvent
kevent(wxEVT_KEY_DOWN
);
1859 kevent
.m_keyCode
= event
.GetWheelRotation() > 0
1862 GetEventHandler()->ProcessEvent(kevent
);
1875 void wxComboCtrlBase::OnKeyEvent(wxKeyEvent
& event
)
1877 if ( IsPopupShown() )
1879 // pass it to the popped up control
1880 GetPopupControl()->GetControl()->GetEventHandler()->ProcessEvent(event
);
1884 wxWindow
* mainCtrl
= GetMainWindowOfCompositeControl();
1886 if ( mainCtrl
->GetParent()->HasFlag(wxTAB_TRAVERSAL
) )
1888 if ( mainCtrl
->HandleAsNavigationKey(event
) )
1892 if ( IsKeyPopupToggle(event
) )
1898 int comboStyle
= GetWindowStyle();
1899 wxComboPopup
* popupInterface
= GetPopupControl();
1901 if ( !popupInterface
)
1907 int keycode
= event
.GetKeyCode();
1909 if ( (comboStyle
& wxCB_READONLY
) ||
1910 (keycode
!= WXK_RIGHT
&& keycode
!= WXK_LEFT
) )
1912 popupInterface
->OnComboKeyEvent(event
);
1919 void wxComboCtrlBase::OnCharEvent(wxKeyEvent
& event
)
1921 if ( IsPopupShown() )
1923 // pass it to the popped up control
1924 GetPopupControl()->GetControl()->GetEventHandler()->ProcessEvent(event
);
1928 wxComboPopup
* popupInterface
= GetPopupControl();
1929 if ( popupInterface
)
1931 popupInterface
->OnComboCharEvent(event
);
1940 void wxComboCtrlBase::OnFocusEvent( wxFocusEvent
& event
)
1942 if ( event
.GetEventType() == wxEVT_SET_FOCUS
)
1944 wxWindow
* tc
= GetTextCtrl();
1945 if ( tc
&& tc
!= DoFindFocus() )
1954 void wxComboCtrlBase::OnIdleEvent( wxIdleEvent
& WXUNUSED(event
) )
1958 m_resetFocus
= false;
1959 wxWindow
* tc
= GetTextCtrl();
1965 void wxComboCtrlBase::OnSysColourChanged(wxSysColourChangedEvent
& WXUNUSED(event
))
1968 // left margin may also have changed
1969 if ( !(m_iFlags
& wxCC_IFLAG_LEFT_MARGIN_SET
) )
1970 m_marginLeft
= GetNativeTextIndent();
1974 // ----------------------------------------------------------------------------
1976 // ----------------------------------------------------------------------------
1978 // Create popup window and the child control
1979 void wxComboCtrlBase::CreatePopup()
1981 wxComboPopup
* popupInterface
= m_popupInterface
;
1986 #ifdef wxComboPopupWindowBase2
1987 if ( m_iFlags
& wxCC_IFLAG_USE_ALT_POPUP
)
1989 #if !USES_GENERICTLW
1990 m_winPopup
= new wxComboPopupWindowBase2( this, wxNO_BORDER
);
1992 int tlwFlags
= wxNO_BORDER
;
1993 #ifdef wxCC_GENERIC_TLW_IS_FRAME
1994 tlwFlags
|= wxFRAME_NO_TASKBAR
;
1997 #ifdef wxCC_GENERIC_TLW_IS_NONOWNEDWINDOW
1998 m_winPopup
= new wxComboPopupWindowBase2( this, wxID_ANY
,
1999 wxPoint(-21,-21), wxSize(20, 20),
2002 m_winPopup
= new wxComboPopupWindowBase2( this, wxID_ANY
, wxEmptyString
,
2003 wxPoint(-21,-21), wxSize(20, 20),
2007 m_popupWinType
= SECONDARY_POPUP_TYPE
;
2010 #endif // wxComboPopupWindowBase2
2012 m_winPopup
= new wxComboPopupWindow( this, wxNO_BORDER
);
2013 m_popupWinType
= PRIMARY_POPUP_TYPE
;
2015 m_popupWinEvtHandler
= new wxComboPopupWindowEvtHandler(this);
2016 m_winPopup
->PushEventHandler(m_popupWinEvtHandler
);
2019 popupInterface
->Create(m_winPopup
);
2020 m_popup
= popup
= popupInterface
->GetControl();
2022 m_popupEvtHandler
= new wxComboPopupEvtHandler(this);
2023 popup
->PushEventHandler( m_popupEvtHandler
);
2025 // This may be helpful on some platforms
2026 // (eg. it bypasses a wxGTK popupwindow bug where
2027 // window is not initially hidden when it should be)
2030 popupInterface
->m_iFlags
|= wxCP_IFLAG_CREATED
;
2033 // Destroy popup window and the child control
2034 void wxComboCtrlBase::DestroyPopup()
2039 m_popup
->RemoveEventHandler(m_popupEvtHandler
);
2041 wxDELETE(m_popupEvtHandler
);
2043 wxDELETE(m_popupInterface
);
2047 m_winPopup
->RemoveEventHandler(m_popupWinEvtHandler
);
2048 wxDELETE(m_popupWinEvtHandler
);
2049 m_winPopup
->Destroy();
2056 void wxComboCtrlBase::DoSetPopupControl(wxComboPopup
* iface
)
2058 wxCHECK_RET( iface
, wxT("no popup interface set for wxComboCtrl") );
2062 iface
->InitBase(this);
2065 m_popupInterface
= iface
;
2067 if ( !iface
->LazyCreate() )
2076 // This must be done after creation
2077 if ( m_valueString
.length() )
2079 iface
->SetStringValue(m_valueString
);
2084 // Ensures there is atleast the default popup
2085 void wxComboCtrlBase::EnsurePopupControl()
2087 if ( !m_popupInterface
)
2088 SetPopupControl(NULL
);
2091 void wxComboCtrlBase::OnButtonClick()
2093 // Derived classes can override this method for totally custom
2095 switch ( GetPopupWindowState() )
2099 wxCommandEvent
event(wxEVT_COMMAND_COMBOBOX_DROPDOWN
, GetId());
2100 event
.SetEventObject(this);
2101 HandleWindowEvent(event
);
2116 void wxComboCtrlBase::ShowPopup()
2118 EnsurePopupControl();
2119 wxCHECK_RET( !IsPopupWindowState(Visible
), wxT("popup window already shown") );
2121 if ( IsPopupWindowState(Animating
) )
2126 // Space above and below
2132 wxSize ctrlSz
= GetSize();
2134 screenHeight
= wxSystemSettings::GetMetric( wxSYS_SCREEN_Y
);
2135 scrPos
= GetParent()->ClientToScreen(GetPosition());
2137 spaceAbove
= scrPos
.y
;
2138 spaceBelow
= screenHeight
- spaceAbove
- ctrlSz
.y
;
2140 maxHeightPopup
= spaceBelow
;
2141 if ( spaceAbove
> spaceBelow
)
2142 maxHeightPopup
= spaceAbove
;
2145 int widthPopup
= ctrlSz
.x
+ m_extLeft
+ m_extRight
;
2147 if ( widthPopup
< m_widthMinPopup
)
2148 widthPopup
= m_widthMinPopup
;
2150 wxWindow
* winPopup
= m_winPopup
;
2153 // Need to disable tab traversal of parent
2155 // NB: This is to fix a bug in wxMSW. In theory it could also be fixed
2156 // by, for instance, adding check to window.cpp:wxWindowMSW::MSWProcessMessage
2157 // that if transient popup is open, then tab traversal is to be ignored.
2158 // However, I think this code would still be needed for cases where
2159 // transient popup doesn't work yet (wxWinCE?).
2160 wxWindow
* mainCtrl
= GetMainWindowOfCompositeControl();
2161 wxWindow
* parent
= mainCtrl
->GetParent();
2162 int parentFlags
= parent
->GetWindowStyle();
2163 if ( parentFlags
& wxTAB_TRAVERSAL
)
2165 parent
->SetWindowStyle( parentFlags
& ~(wxTAB_TRAVERSAL
) );
2166 m_iFlags
|= wxCC_IFLAG_PARENT_TAB_TRAVERSAL
;
2172 winPopup
= m_winPopup
;
2182 wxASSERT( !m_popup
|| m_popup
== popup
); // Consistency check.
2184 wxSize adjustedSize
= m_popupInterface
->GetAdjustedSize(widthPopup
,
2185 m_heightPopup
<=0?DEFAULT_POPUP_HEIGHT
:m_heightPopup
,
2188 popup
->SetSize(adjustedSize
);
2190 m_popupInterface
->OnPopup();
2193 // Reposition and resize popup window
2196 wxSize szp
= popup
->GetSize();
2199 int popupY
= scrPos
.y
+ ctrlSz
.y
;
2201 // Default anchor is wxLEFT
2202 int anchorSide
= m_anchorSide
;
2204 anchorSide
= wxLEFT
;
2206 int rightX
= scrPos
.x
+ ctrlSz
.x
+ m_extRight
- szp
.x
;
2207 int leftX
= scrPos
.x
- m_extLeft
;
2209 if ( wxTheApp
->GetLayoutDirection() == wxLayout_RightToLeft
)
2212 int screenWidth
= wxSystemSettings::GetMetric( wxSYS_SCREEN_X
);
2214 // If there is not enough horizontal space, anchor on the other side.
2215 // If there is no space even then, place the popup at x 0.
2216 if ( anchorSide
== wxRIGHT
)
2220 if ( (leftX
+szp
.x
) < screenWidth
)
2221 anchorSide
= wxLEFT
;
2228 if ( (leftX
+szp
.x
) >= screenWidth
)
2231 anchorSide
= wxRIGHT
;
2237 // Select x coordinate according to the anchor side
2238 if ( anchorSide
== wxRIGHT
)
2240 else if ( anchorSide
== wxLEFT
)
2245 int showFlags
= CanDeferShow
;
2247 if ( spaceBelow
< szp
.y
)
2249 popupY
= scrPos
.y
- szp
.y
;
2250 showFlags
|= ShowAbove
;
2253 #if INSTALL_TOPLEV_HANDLER
2254 // Put top level window event handler into place
2255 if ( m_popupWinType
== POPUPWIN_WXPOPUPWINDOW
)
2257 if ( !m_toplevEvtHandler
)
2258 m_toplevEvtHandler
= new wxComboFrameEventHandler(this);
2260 wxWindow
* toplev
= ::wxGetTopLevelParent( this );
2262 ((wxComboFrameEventHandler
*)m_toplevEvtHandler
)->OnPopup();
2263 toplev
->PushEventHandler( m_toplevEvtHandler
);
2267 // Set string selection (must be this way instead of SetStringSelection)
2270 if ( !(m_iFlags
& wxCC_NO_TEXT_AUTO_SELECT
) )
2271 m_text
->SelectAll();
2273 m_popupInterface
->SetStringValue( m_text
->GetValue() );
2277 // This is neede since focus/selection indication may change when popup is shown
2281 // This must be after SetStringValue
2282 m_popupWinState
= Animating
;
2284 wxRect
popupWinRect( popupX
, popupY
, szp
.x
, szp
.y
);
2287 if ( (m_iFlags
& wxCC_IFLAG_DISABLE_POPUP_ANIM
) ||
2288 AnimateShow( popupWinRect
, showFlags
) )
2290 DoShowPopup( popupWinRect
, showFlags
);
2294 bool wxComboCtrlBase::AnimateShow( const wxRect
& WXUNUSED(rect
), int WXUNUSED(flags
) )
2299 void wxComboCtrlBase::DoShowPopup( const wxRect
& rect
, int WXUNUSED(flags
) )
2301 wxWindow
* winPopup
= m_winPopup
;
2303 if ( IsPopupWindowState(Animating
) )
2305 // Make sure the popup window is shown in the right position.
2306 // Should not matter even if animation already did this.
2308 // Some platforms (GTK) may like SetSize and Move to be separate
2309 // (though the bug was probably fixed).
2310 winPopup
->SetSize( rect
);
2312 #if USES_WXPOPUPTRANSIENTWINDOW
2313 if ( m_popupWinType
== POPUPWIN_WXPOPUPTRANSIENTWINDOW
)
2314 ((wxPopupTransientWindow
*)winPopup
)->Popup(m_popup
);
2319 m_popupWinState
= Visible
;
2321 // If popup window was a generic top-level window, or the
2322 // wxPopupWindow implemenation on this platform is classified as
2323 // perfect, then we should be able to safely set focus to the popup
2325 if ( IsPopupWinTypePerfect(m_popupWinType
) )
2326 m_popup
->SetFocus();
2328 else if ( IsPopupWindowState(Hidden
) )
2330 // Animation was aborted
2332 wxASSERT( !winPopup
->IsShown() );
2334 m_popupWinState
= Hidden
;
2340 void wxComboCtrlBase::OnPopupDismiss(bool generateEvent
)
2342 // Just in case, avoid double dismiss
2343 if ( IsPopupWindowState(Hidden
) )
2346 // This must be set before focus - otherwise there will be recursive
2347 // OnPopupDismisses.
2348 m_popupWinState
= Hidden
;
2351 m_winPopup
->Disable();
2353 // Inform popup control itself
2354 m_popupInterface
->OnDismiss();
2356 if ( m_popupEvtHandler
)
2357 ((wxComboPopupEvtHandler
*)m_popupEvtHandler
)->OnPopupDismiss();
2359 #if INSTALL_TOPLEV_HANDLER
2360 // Remove top level window event handler
2361 if ( m_toplevEvtHandler
)
2363 wxWindow
* toplev
= ::wxGetTopLevelParent( this );
2365 toplev
->RemoveEventHandler( m_toplevEvtHandler
);
2369 m_timeCanAcceptClick
= ::wxGetLocalTimeMillis();
2371 if ( m_popupWinType
== POPUPWIN_WXPOPUPTRANSIENTWINDOW
)
2372 m_timeCanAcceptClick
+= 150;
2374 // If cursor not on dropdown button, then clear its state
2375 // (technically not required by all ports, but do it for all just in case)
2376 if ( !m_btnArea
.Contains(ScreenToClient(::wxGetMousePosition())) )
2379 // Return parent's tab traversal flag.
2380 // See ShowPopup for notes.
2381 if ( m_iFlags
& wxCC_IFLAG_PARENT_TAB_TRAVERSAL
)
2383 wxWindow
* parent
= GetParent();
2384 parent
->SetWindowStyle( parent
->GetWindowStyle() | wxTAB_TRAVERSAL
);
2385 m_iFlags
&= ~(wxCC_IFLAG_PARENT_TAB_TRAVERSAL
);
2388 // refresh control (necessary even if m_text)
2393 if ( generateEvent
)
2395 wxCommandEvent
event(wxEVT_COMMAND_COMBOBOX_CLOSEUP
, GetId());
2396 event
.SetEventObject(this);
2397 HandleWindowEvent(event
);
2401 void wxComboCtrlBase::HidePopup(bool generateEvent
)
2403 // Should be able to call this without popup interface
2404 if ( IsPopupWindowState(Hidden
) )
2407 // transfer value and show it in textctrl, if any
2408 if ( !IsPopupWindowState(Animating
) )
2409 SetValue( m_popupInterface
->GetStringValue() );
2413 OnPopupDismiss(generateEvent
);
2416 // ----------------------------------------------------------------------------
2417 // customization methods
2418 // ----------------------------------------------------------------------------
2420 void wxComboCtrlBase::SetButtonPosition( int width
, int height
,
2421 int side
, int spacingX
)
2426 m_btnSpacingX
= spacingX
;
2428 if ( width
> 0 || height
> 0 || spacingX
)
2429 m_iFlags
|= wxCC_IFLAG_HAS_NONSTANDARD_BUTTON
;
2434 wxSize
wxComboCtrlBase::GetButtonSize()
2436 if ( m_btnSize
.x
> 0 )
2439 wxSize
retSize(m_btnWid
,m_btnHei
);
2441 // Need to call CalculateAreas now if button size is
2442 // is not explicitly specified.
2443 if ( retSize
.x
<= 0 || retSize
.y
<= 0)
2447 retSize
= m_btnSize
;
2453 void wxComboCtrlBase::SetButtonBitmaps( const wxBitmap
& bmpNormal
,
2455 const wxBitmap
& bmpPressed
,
2456 const wxBitmap
& bmpHover
,
2457 const wxBitmap
& bmpDisabled
)
2459 m_bmpNormal
= bmpNormal
;
2460 m_blankButtonBg
= blankButtonBg
;
2462 if ( bmpPressed
.Ok() )
2463 m_bmpPressed
= bmpPressed
;
2465 m_bmpPressed
= bmpNormal
;
2467 if ( bmpHover
.Ok() )
2468 m_bmpHover
= bmpHover
;
2470 m_bmpHover
= bmpNormal
;
2472 if ( bmpDisabled
.Ok() )
2473 m_bmpDisabled
= bmpDisabled
;
2475 m_bmpDisabled
= bmpNormal
;
2480 void wxComboCtrlBase::SetCustomPaintWidth( int width
)
2484 // move textctrl accordingly
2485 wxRect r
= m_text
->GetRect();
2486 int inc
= width
- m_widthCustomPaint
;
2489 m_text
->SetSize( r
);
2492 m_widthCustomPaint
= width
;
2497 bool wxComboCtrlBase::DoSetMargins(const wxPoint
& margins
)
2499 // For general sanity's sake, we ignore top margin. Instead
2500 // we will always try to center the text vertically.
2503 if ( margins
.x
!= -1 )
2505 m_marginLeft
= margins
.x
;
2506 m_iFlags
|= wxCC_IFLAG_LEFT_MARGIN_SET
;
2510 m_marginLeft
= GetNativeTextIndent();
2511 m_iFlags
&= ~(wxCC_IFLAG_LEFT_MARGIN_SET
);
2514 if ( margins
.y
!= -1 )
2524 wxPoint
wxComboCtrlBase::DoGetMargins() const
2526 return wxPoint(m_marginLeft
, -1);
2529 #if WXWIN_COMPATIBILITY_2_8
2530 void wxComboCtrlBase::SetTextIndent( int indent
)
2534 m_marginLeft
= GetNativeTextIndent();
2535 m_iFlags
&= ~(wxCC_IFLAG_LEFT_MARGIN_SET
);
2539 m_marginLeft
= indent
;
2540 m_iFlags
|= wxCC_IFLAG_LEFT_MARGIN_SET
;
2546 wxCoord
wxComboCtrlBase::GetTextIndent() const
2548 return m_marginLeft
;
2552 wxCoord
wxComboCtrlBase::GetNativeTextIndent() const
2554 return DEFAULT_TEXT_INDENT
;
2557 void wxComboCtrlBase::SetTextCtrlStyle( int style
)
2559 m_textCtrlStyle
= style
;
2562 m_text
->SetWindowStyle(style
);
2565 // ----------------------------------------------------------------------------
2566 // methods forwarded to wxTextCtrl
2567 // ----------------------------------------------------------------------------
2569 wxString
wxComboCtrlBase::GetValue() const
2572 return m_text
->GetValue();
2573 return m_valueString
;
2576 void wxComboCtrlBase::SetValueWithEvent(const wxString
& value
, bool withEvent
)
2583 m_text
->SetValue(value
);
2585 if ( !(m_iFlags
& wxCC_NO_TEXT_AUTO_SELECT
) )
2586 m_text
->SelectAll();
2589 // Since wxComboPopup may want to paint the combo as well, we need
2590 // to set the string value here (as well as sometimes in ShowPopup).
2591 if ( m_valueString
!= value
)
2593 m_valueString
= value
;
2595 EnsurePopupControl();
2597 if (m_popupInterface
)
2598 m_popupInterface
->SetStringValue(value
);
2604 void wxComboCtrlBase::SetValue(const wxString
& value
)
2606 SetValueWithEvent(value
, false);
2609 // In this SetValue variant wxComboPopup::SetStringValue is not called
2610 void wxComboCtrlBase::SetText(const wxString
& value
)
2612 // Unlike in SetValue(), this must be called here or
2613 // the behaviour will no be consistent in readonlys.
2614 EnsurePopupControl();
2616 m_valueString
= value
;
2621 m_text
->SetValue( value
);
2627 void wxComboCtrlBase::Copy()
2633 void wxComboCtrlBase::Cut()
2639 void wxComboCtrlBase::Paste()
2645 void wxComboCtrlBase::SetInsertionPoint(long pos
)
2648 m_text
->SetInsertionPoint(pos
);
2651 void wxComboCtrlBase::SetInsertionPointEnd()
2654 m_text
->SetInsertionPointEnd();
2657 long wxComboCtrlBase::GetInsertionPoint() const
2660 return m_text
->GetInsertionPoint();
2665 long wxComboCtrlBase::GetLastPosition() const
2668 return m_text
->GetLastPosition();
2673 void wxComboCtrlBase::Replace(long from
, long to
, const wxString
& value
)
2676 m_text
->Replace(from
, to
, value
);
2679 void wxComboCtrlBase::Remove(long from
, long to
)
2682 m_text
->Remove(from
, to
);
2685 void wxComboCtrlBase::SetSelection(long from
, long to
)
2688 m_text
->SetSelection(from
, to
);
2691 void wxComboCtrlBase::Undo()
2697 bool wxComboCtrlBase::SetHint(const wxString
& hint
)
2702 res
= m_text
->SetHint(hint
);
2707 wxString
wxComboCtrlBase::GetHint() const
2712 #endif // wxUSE_COMBOCTRL