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
);
677 evt2
.SetId(m_combo
->GetId());
678 evt2
.SetEventObject(m_combo
);
679 m_combo
->GetEventHandler()->ProcessEvent(evt2
);
686 // This is pushed to the event handler queue of the control in popup.
689 class wxComboPopupEvtHandler
: public wxEvtHandler
693 wxComboPopupEvtHandler( wxComboCtrlBase
* combo
)
697 m_beenInside
= false;
699 // Let's make it so that the popup control will not receive mouse
700 // events until mouse left button has been up.
701 m_blockEventsToPopup
= true;
703 virtual ~wxComboPopupEvtHandler() { }
705 void OnMouseEvent( wxMouseEvent
& event
);
707 // Called from wxComboCtrlBase::OnPopupDismiss
708 void OnPopupDismiss()
710 m_beenInside
= false;
711 m_blockEventsToPopup
= true;
715 wxComboCtrlBase
* m_combo
;
718 bool m_blockEventsToPopup
;
721 DECLARE_EVENT_TABLE()
725 BEGIN_EVENT_TABLE(wxComboPopupEvtHandler
, wxEvtHandler
)
726 EVT_MOUSE_EVENTS(wxComboPopupEvtHandler::OnMouseEvent
)
730 void wxComboPopupEvtHandler::OnMouseEvent( wxMouseEvent
& event
)
732 wxPoint pt
= event
.GetPosition();
733 wxSize sz
= m_combo
->GetPopupControl()->GetControl()->GetClientSize();
734 int evtType
= event
.GetEventType();
735 bool isInside
= pt
.x
>= 0 && pt
.y
>= 0 && pt
.x
< sz
.x
&& pt
.y
< sz
.y
;
736 bool relayToButton
= false;
740 if ( !isInside
|| !m_combo
->IsPopupShown() )
742 // Mouse is outside the popup or popup is not actually shown (yet)
744 if ( evtType
== wxEVT_MOTION
||
745 evtType
== wxEVT_LEFT_DOWN
||
746 evtType
== wxEVT_LEFT_UP
||
747 evtType
== wxEVT_RIGHT_DOWN
)
749 // Block motion and click events outside the popup
755 // Mouse is inside the popup, which is fully shown
759 // Do not let the popup control respond to mouse events until
760 // mouse press used to display the popup has been lifted. This
761 // is important for users with slower mouse fingers or mouse
762 // drivers. Note that we have some redundancy here, just in
763 // case the popup is some native control that does not emit all
764 // mouse event types.
765 if ( evtType
== wxEVT_MOTION
)
767 if ( m_blockEventsToPopup
)
769 if ( event
.LeftIsDown() )
772 m_blockEventsToPopup
= false;
775 else if ( evtType
== wxEVT_LEFT_DOWN
)
777 if ( m_blockEventsToPopup
)
778 m_blockEventsToPopup
= false;
780 else if ( evtType
== wxEVT_LEFT_UP
)
782 if ( m_blockEventsToPopup
)
784 // On first left up, stop blocking mouse events (but still
786 m_blockEventsToPopup
= false;
789 // Also, this button press was (probably) used to display
790 // the popup, so relay it back to the drop-down button
791 // (which supposedly originated it). This is necessary to
792 // refresh it properly.
793 relayToButton
= true;
796 else if ( m_blockEventsToPopup
)
803 // Some mouse events to popup that happen outside it, before cursor
804 // has been inside the popup, need to be ignored by it but relayed to
807 if ( evtType
== wxEVT_LEFT_UP
)
809 if ( !m_combo
->IsPopupShown() )
812 relayToButton
= true;
814 else if ( !isInside
&& !m_beenInside
)
816 // Popup is shown but the cursor is not inside, nor it has been
817 relayToButton
= true;
823 wxWindow
* btn
= m_combo
->GetButton();
825 btn
->GetEventHandler()->ProcessEvent(event
);
827 // Bypass the event handling mechanism. Using it would be
828 // confusing for the platform-specific wxComboCtrl
830 m_combo
->HandleButtonMouseEvent(event
, 0);
834 // ----------------------------------------------------------------------------
835 // wxComboCtrlTextCtrl
836 // ----------------------------------------------------------------------------
838 class wxComboCtrlTextCtrl
: public wxTextCtrl
841 wxComboCtrlTextCtrl() : wxTextCtrl() { }
842 virtual ~wxComboCtrlTextCtrl() { }
844 virtual wxWindow
*GetMainWindowOfCompositeControl()
846 wxComboCtrl
* combo
= (wxComboCtrl
*) GetParent();
848 // Returning this instead of just 'parent' lets FindFocus work
849 // correctly even when parent control is a child of a composite
850 // generic control (as is case with wxGenericDatePickerCtrl).
851 return combo
->GetMainWindowOfCompositeControl();
855 // ----------------------------------------------------------------------------
857 // ----------------------------------------------------------------------------
860 BEGIN_EVENT_TABLE(wxComboCtrlBase
, wxControl
)
861 EVT_TEXT(wxID_ANY
,wxComboCtrlBase::OnTextCtrlEvent
)
862 EVT_SIZE(wxComboCtrlBase::OnSizeEvent
)
863 EVT_SET_FOCUS(wxComboCtrlBase::OnFocusEvent
)
864 EVT_KILL_FOCUS(wxComboCtrlBase::OnFocusEvent
)
865 EVT_IDLE(wxComboCtrlBase::OnIdleEvent
)
866 //EVT_BUTTON(wxID_ANY,wxComboCtrlBase::OnButtonClickEvent)
867 EVT_KEY_DOWN(wxComboCtrlBase::OnKeyEvent
)
868 EVT_CHAR(wxComboCtrlBase::OnCharEvent
)
869 EVT_TEXT_ENTER(wxID_ANY
,wxComboCtrlBase::OnTextCtrlEvent
)
870 EVT_SYS_COLOUR_CHANGED(wxComboCtrlBase::OnSysColourChanged
)
874 IMPLEMENT_ABSTRACT_CLASS(wxComboCtrlBase
, wxControl
)
876 void wxComboCtrlBase::Init()
880 m_popupWinState
= Hidden
;
883 m_popupInterface
= NULL
;
885 m_popupEvtHandler
= NULL
;
886 m_textEvtHandler
= NULL
;
888 #if INSTALL_TOPLEV_HANDLER
889 m_toplevEvtHandler
= NULL
;
892 m_mainCtrlWnd
= this;
895 m_widthMinPopup
= -1;
897 m_widthCustomPaint
= 0;
898 m_widthCustomBorder
= 0;
902 m_blankButtonBg
= false;
904 m_popupWinType
= POPUPWIN_NONE
;
905 m_btnWid
= m_btnHei
= -1;
914 m_timeCanAcceptClick
= 0;
916 m_resetFocus
= false;
919 bool wxComboCtrlBase::Create(wxWindow
*parent
,
921 const wxString
& value
,
925 const wxValidator
& validator
,
926 const wxString
& name
)
928 if ( !wxControl::Create(parent
,
932 style
| wxWANTS_CHARS
,
937 m_valueString
= value
;
941 m_marginLeft
= GetNativeTextIndent();
943 m_iFlags
|= wxCC_IFLAG_CREATED
;
945 // If x and y indicate valid size, wxSizeEvent won't be
946 // emitted automatically, so we need to add artifical one.
947 if ( size
.x
> 0 && size
.y
> 0 )
949 wxSizeEvent
evt(size
,GetId());
950 GetEventHandler()->AddPendingEvent(evt
);
956 void wxComboCtrlBase::InstallInputHandlers()
960 m_textEvtHandler
= new wxComboBoxExtraInputHandler(this);
961 m_text
->PushEventHandler(m_textEvtHandler
);
966 wxComboCtrlBase::CreateTextCtrl(int style
, const wxValidator
& validator
)
968 if ( !(m_windowStyle
& wxCB_READONLY
) )
973 // wxTE_PROCESS_TAB is needed because on Windows, wxTAB_TRAVERSAL is
974 // not used by the wxPropertyGrid and therefore the tab is processed by
975 // looking at ancestors to see if they have wxTAB_TRAVERSAL. The
976 // navigation event is then sent to the wrong window.
977 style
|= wxTE_PROCESS_TAB
| m_textCtrlStyle
;
979 if ( HasFlag(wxTE_PROCESS_ENTER
) )
980 style
|= wxTE_PROCESS_ENTER
;
982 // Ignore EVT_TEXT generated by the constructor (but only
983 // if the event redirector already exists)
984 // NB: This must be " = 1" instead of "++";
985 if ( m_textEvtHandler
)
990 m_text
= new wxComboCtrlTextCtrl();
991 m_text
->Create(this, wxID_ANY
, m_valueString
,
992 wxDefaultPosition
, wxSize(10,-1),
994 m_text
->SetHint(m_hintText
);
998 void wxComboCtrlBase::OnThemeChange()
1000 // Leave the default bg on the Mac so the area used by the focus ring will
1001 // be the correct colour and themed brush. Instead we'll use
1002 // wxSYS_COLOUR_WINDOW in the EVT_PAINT handler as needed.
1004 #if defined(__WXMSW__) || defined(__WXGTK__)
1005 wxVisualAttributes vattrs
= wxComboBox::GetClassDefaultAttributes();
1007 wxVisualAttributes vattrs
;
1008 vattrs
.colFg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
1009 vattrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW
);
1012 // Only change the colours if application has not specified
1016 SetOwnForegroundColour(vattrs
.colFg
);
1021 SetOwnBackgroundColour(vattrs
.colBg
);
1024 #endif // !__WXMAC__
1027 wxComboCtrlBase::~wxComboCtrlBase()
1032 #if INSTALL_TOPLEV_HANDLER
1033 delete ((wxComboFrameEventHandler
*)m_toplevEvtHandler
);
1034 m_toplevEvtHandler
= NULL
;
1040 m_text
->RemoveEventHandler(m_textEvtHandler
);
1042 delete m_textEvtHandler
;
1046 // ----------------------------------------------------------------------------
1048 // ----------------------------------------------------------------------------
1050 // Recalculates button and textctrl areas
1051 void wxComboCtrlBase::CalculateAreas( int btnWidth
)
1053 wxSize sz
= GetClientSize();
1054 int customBorder
= m_widthCustomBorder
;
1055 int btnBorder
; // border for button only
1057 // check if button should really be outside the border: we'll do it it if
1058 // its platform default or bitmap+pushbutton background is used, but not if
1059 // there is vertical size adjustment or horizontal spacing.
1060 if ( ( (m_iFlags
& wxCC_BUTTON_OUTSIDE_BORDER
) ||
1061 (m_bmpNormal
.Ok() && m_blankButtonBg
) ) &&
1062 m_btnSpacingX
== 0 &&
1065 m_iFlags
|= wxCC_IFLAG_BUTTON_OUTSIDE
;
1068 else if ( (m_iFlags
& wxCC_BUTTON_COVERS_BORDER
) &&
1069 m_btnSpacingX
== 0 && !m_bmpNormal
.Ok() )
1071 m_iFlags
&= ~(wxCC_IFLAG_BUTTON_OUTSIDE
);
1076 m_iFlags
&= ~(wxCC_IFLAG_BUTTON_OUTSIDE
);
1077 btnBorder
= customBorder
;
1080 // Defaul indentation
1081 if ( m_marginLeft
< 0 )
1082 m_marginLeft
= GetNativeTextIndent();
1084 int butWidth
= btnWidth
;
1086 if ( butWidth
<= 0 )
1087 butWidth
= m_btnWidDefault
;
1089 m_btnWidDefault
= butWidth
;
1091 if ( butWidth
<= 0 )
1094 int butHeight
= sz
.y
- btnBorder
*2;
1096 // Adjust button width
1098 butWidth
= m_btnWid
;
1101 // Adjust button width to match aspect ratio
1102 // (but only if control is smaller than best size).
1103 int bestHeight
= GetBestSize().y
;
1104 int height
= GetSize().y
;
1106 if ( height
< bestHeight
)
1108 // Make very small buttons square, as it makes
1109 // them accommodate arrow image better and still
1112 butWidth
= (height
*butWidth
)/bestHeight
;
1114 butWidth
= butHeight
;
1118 // Adjust button height
1120 butHeight
= m_btnHei
;
1122 // Use size of normal bitmap if...
1125 // button width is set to default and blank button bg is not drawn
1126 if ( m_bmpNormal
.Ok() )
1128 int bmpReqWidth
= m_bmpNormal
.GetWidth();
1129 int bmpReqHeight
= m_bmpNormal
.GetHeight();
1131 // If drawing blank button background, we need to add some margin.
1132 if ( m_blankButtonBg
)
1134 bmpReqWidth
+= BMP_BUTTON_MARGIN
*2;
1135 bmpReqHeight
+= BMP_BUTTON_MARGIN
*2;
1138 if ( butWidth
< bmpReqWidth
|| ( m_btnWid
== 0 && !m_blankButtonBg
) )
1139 butWidth
= bmpReqWidth
;
1140 if ( butHeight
< bmpReqHeight
|| ( m_btnHei
== 0 && !m_blankButtonBg
) )
1141 butHeight
= bmpReqHeight
;
1143 // Need to fix height?
1144 if ( (sz
.y
-(customBorder
*2)) < butHeight
&& btnWidth
== 0 )
1146 int newY
= butHeight
+(customBorder
*2);
1147 SetClientSize(wxDefaultCoord
,newY
);
1148 if ( m_bmpNormal
.Ok() || m_btnArea
.width
!= butWidth
|| m_btnArea
.height
!= butHeight
)
1149 m_iFlags
|= wxCC_IFLAG_HAS_NONSTANDARD_BUTTON
;
1151 m_iFlags
&= ~wxCC_IFLAG_HAS_NONSTANDARD_BUTTON
;
1157 int butAreaWid
= butWidth
+ (m_btnSpacingX
*2);
1159 m_btnSize
.x
= butWidth
;
1160 m_btnSize
.y
= butHeight
;
1162 m_btnArea
.x
= ( m_btnSide
==wxRIGHT
? sz
.x
- butAreaWid
- btnBorder
: btnBorder
);
1163 m_btnArea
.y
= btnBorder
+ FOCUS_RING
;
1164 m_btnArea
.width
= butAreaWid
;
1165 m_btnArea
.height
= sz
.y
- ((btnBorder
+FOCUS_RING
)*2);
1167 m_tcArea
.x
= ( m_btnSide
==wxRIGHT
? 0 : butAreaWid
) + customBorder
+ FOCUS_RING
;
1168 m_tcArea
.y
= customBorder
+ FOCUS_RING
;
1169 m_tcArea
.width
= sz
.x
- butAreaWid
- (customBorder
*2) - (FOCUS_RING
*2);
1170 m_tcArea
.height
= sz
.y
- ((customBorder
+FOCUS_RING
)*2);
1175 ::wxMessageBox(wxString::Format(wxT("ButtonArea (%i,%i,%i,%i)\n"),m_btnArea.x,m_btnArea.y,m_btnArea.width,m_btnArea.height) +
1176 wxString::Format(wxT("TextCtrlArea (%i,%i,%i,%i)"),m_tcArea.x,m_tcArea.y,m_tcArea.width,m_tcArea.height));
1181 void wxComboCtrlBase::PositionTextCtrl( int textCtrlXAdjust
, int textCtrlYAdjust
)
1186 wxSize sz
= GetClientSize();
1188 int customBorder
= m_widthCustomBorder
;
1189 if ( (m_text
->GetWindowStyleFlag() & wxBORDER_MASK
) == wxNO_BORDER
)
1193 if ( !m_widthCustomPaint
)
1195 // No special custom paint area - we can use 0 left margin
1197 if ( m_text
->SetMargins(0) )
1198 textCtrlXAdjust
= 0;
1199 x
= m_tcArea
.x
+ m_marginLeft
+ textCtrlXAdjust
;
1203 // There is special custom paint area - it is better to
1204 // use some margin with the wxTextCtrl.
1205 m_text
->SetMargins(m_marginLeft
);
1206 x
= m_tcArea
.x
+ m_widthCustomPaint
+
1207 m_marginLeft
+ textCtrlXAdjust
;
1210 // Centre textctrl vertically, if needed
1211 #if !TEXTCTRL_TEXT_CENTERED
1212 int tcSizeY
= m_text
->GetBestSize().y
;
1213 int diff0
= sz
.y
- tcSizeY
;
1214 int y
= textCtrlYAdjust
+ (diff0
/2);
1216 wxUnusedVar(textCtrlYAdjust
);
1220 if ( y
< customBorder
)
1225 m_tcArea
.width
- m_tcArea
.x
- x
,
1228 // Make sure textctrl doesn't exceed the bottom custom border
1229 wxSize tsz
= m_text
->GetSize();
1230 int diff1
= (y
+ tsz
.y
) - (sz
.y
- customBorder
);
1233 tsz
.y
= tsz
.y
- diff1
- 1;
1234 m_text
->SetSize(tsz
);
1239 // If it has border, have textctrl fill the entire text field.
1240 m_text
->SetSize( m_tcArea
.x
+ m_widthCustomPaint
,
1242 m_tcArea
.width
- m_widthCustomPaint
,
1247 wxSize
wxComboCtrlBase::DoGetBestSize() const
1249 wxSize
sizeText(150,0);
1252 sizeText
= m_text
->GetBestSize();
1254 // TODO: Better method to calculate close-to-native control height.
1258 fhei
= (m_font
.GetPointSize()*2) + 5;
1259 else if ( wxNORMAL_FONT
->Ok() )
1260 fhei
= (wxNORMAL_FONT
->GetPointSize()*2) + 5;
1262 fhei
= sizeText
.y
+ 4;
1264 // Need to force height to accomodate bitmap?
1265 int btnSizeY
= m_btnSize
.y
;
1266 if ( m_bmpNormal
.Ok() && fhei
< btnSizeY
)
1269 // Control height doesn't depend on border
1272 int border = m_windowStyle & wxBORDER_MASK;
1273 if ( border == wxSIMPLE_BORDER )
1275 else if ( border == wxNO_BORDER )
1276 fhei += (m_widthCustomBorder*2);
1282 // Final adjustments
1288 // these are the numbers from the HIG:
1289 switch ( m_windowVariant
)
1291 case wxWINDOW_VARIANT_NORMAL
:
1295 case wxWINDOW_VARIANT_SMALL
:
1298 case wxWINDOW_VARIANT_MINI
:
1304 fhei
+= 2 * FOCUS_RING
;
1305 int width
= sizeText
.x
+ FOCUS_RING
+ COMBO_MARGIN
+ DEFAULT_DROPBUTTON_WIDTH
;
1307 wxSize
ret(width
, fhei
);
1312 void wxComboCtrlBase::OnSizeEvent( wxSizeEvent
& event
)
1317 // defined by actual wxComboCtrls
1323 // ----------------------------------------------------------------------------
1324 // standard operations
1325 // ----------------------------------------------------------------------------
1327 bool wxComboCtrlBase::Enable(bool enable
)
1329 if ( !wxControl::Enable(enable
) )
1333 m_btn
->Enable(enable
);
1335 m_text
->Enable(enable
);
1342 bool wxComboCtrlBase::Show(bool show
)
1344 if ( !wxControl::Show(show
) )
1356 bool wxComboCtrlBase::SetFont ( const wxFont
& font
)
1358 if ( !wxControl::SetFont(font
) )
1363 // Without hiding the wxTextCtrl there would be some
1364 // visible 'flicker' (at least on Windows XP).
1366 m_text
->SetFont(font
);
1375 void wxComboCtrlBase::DoSetToolTip(wxToolTip
*tooltip
)
1377 wxControl::DoSetToolTip(tooltip
);
1379 // Set tool tip for button and text box
1382 const wxString
&tip
= tooltip
->GetTip();
1383 if ( m_text
) m_text
->SetToolTip(tip
);
1384 if ( m_btn
) m_btn
->SetToolTip(tip
);
1388 if ( m_text
) m_text
->SetToolTip( NULL
);
1389 if ( m_btn
) m_btn
->SetToolTip( NULL
);
1392 #endif // wxUSE_TOOLTIPS
1394 #if wxUSE_VALIDATORS
1395 void wxComboCtrlBase::SetValidator(const wxValidator
& validator
)
1397 wxTextCtrl
* textCtrl
= GetTextCtrl();
1400 textCtrl
->SetValidator( validator
);
1402 wxControl::SetValidator( validator
);
1405 wxValidator
* wxComboCtrlBase::GetValidator()
1407 wxTextCtrl
* textCtrl
= GetTextCtrl();
1409 return textCtrl
? textCtrl
->GetValidator() : wxControl::GetValidator();
1411 #endif // wxUSE_VALIDATORS
1413 bool wxComboCtrlBase::SetForegroundColour(const wxColour
& colour
)
1415 if ( wxControl::SetForegroundColour(colour
) )
1418 m_text
->SetForegroundColour(colour
);
1424 bool wxComboCtrlBase::SetBackgroundColour(const wxColour
& colour
)
1426 if ( wxControl::SetBackgroundColour(colour
) )
1429 m_text
->SetBackgroundColour(colour
);
1434 // ----------------------------------------------------------------------------
1436 // ----------------------------------------------------------------------------
1438 #if (!defined(__WXMSW__)) || defined(__WXUNIVERSAL__)
1439 // prepare combo box background on area in a way typical on platform
1440 void wxComboCtrlBase::PrepareBackground( wxDC
& dc
, const wxRect
& rect
, int flags
) const
1442 wxSize sz
= GetClientSize();
1444 bool doDrawFocusRect
; // also selected
1446 // For smaller size control (and for disabled background) use less spacing
1450 if ( !(flags
& wxCONTROL_ISSUBMENU
) )
1453 isEnabled
= IsEnabled();
1454 doDrawFocusRect
= ShouldDrawFocus() && !(m_iFlags
& wxCC_FULL_BUTTON
);
1456 // Windows-style: for smaller size control (and for disabled background) use less spacing
1457 focusSpacingX
= isEnabled
? 2 : 1;
1458 focusSpacingY
= sz
.y
> (GetCharHeight()+2) && isEnabled
? 2 : 1;
1462 // Drawing a list item
1463 isEnabled
= true; // they are never disabled
1464 doDrawFocusRect
= (flags
& wxCONTROL_SELECTED
) != 0;
1470 // Set the background sub-rectangle for selection, disabled etc
1471 wxRect
selRect(rect
);
1472 selRect
.y
+= focusSpacingY
;
1473 selRect
.height
-= (focusSpacingY
*2);
1477 if ( !(flags
& wxCONTROL_ISSUBMENU
) )
1478 wcp
+= m_widthCustomPaint
;
1480 selRect
.x
+= wcp
+ focusSpacingX
;
1481 selRect
.width
-= wcp
+ (focusSpacingX
*2);
1486 bool doDrawSelRect
= true;
1488 // Determine foreground colour
1491 if ( doDrawFocusRect
)
1493 fgCol
= wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT
);
1495 else if ( m_hasFgCol
)
1497 // Honour the custom foreground colour
1498 fgCol
= GetForegroundColour();
1502 fgCol
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
1507 fgCol
= wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT
);
1510 // Determine background colour
1513 if ( doDrawFocusRect
)
1515 bgCol
= wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT
);
1517 else if ( m_hasBgCol
)
1519 // Honour the custom background colour
1520 bgCol
= GetBackgroundColour();
1524 #ifndef __WXMAC__ // see note in OnThemeChange
1525 doDrawSelRect
= false;
1526 bgCol
= GetBackgroundColour();
1528 bgCol
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW
);
1534 #ifndef __WXMAC__ // see note in OnThemeChange
1535 bgCol
= GetBackgroundColour();
1537 bgCol
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW
);
1541 dc
.SetTextForeground( fgCol
);
1542 dc
.SetBrush( bgCol
);
1543 if ( doDrawSelRect
)
1546 dc
.DrawRectangle( selRect
);
1549 // Don't clip exactly to the selection rectangle so we can draw
1550 // to the non-selected area in front of it.
1551 wxRect
clipRect(rect
.x
,rect
.y
,
1552 (selRect
.x
+selRect
.width
)-rect
.x
,rect
.height
);
1553 dc
.SetClippingRegion(clipRect
);
1556 // Save the library size a bit for platforms that re-implement this.
1557 void wxComboCtrlBase::PrepareBackground( wxDC
&, const wxRect
&, int ) const
1562 void wxComboCtrlBase::DrawButton( wxDC
& dc
, const wxRect
& rect
, int flags
)
1564 int drawState
= m_btnState
;
1566 if ( (m_iFlags
& wxCC_BUTTON_STAYS_DOWN
) &&
1567 GetPopupWindowState() >= Animating
)
1568 drawState
|= wxCONTROL_PRESSED
;
1570 wxRect
drawRect(rect
.x
+m_btnSpacingX
,
1571 rect
.y
+((rect
.height
-m_btnSize
.y
)/2),
1575 // Make sure area is not larger than the control
1576 if ( drawRect
.y
< rect
.y
)
1577 drawRect
.y
= rect
.y
;
1578 if ( drawRect
.height
> rect
.height
)
1579 drawRect
.height
= rect
.height
;
1581 bool enabled
= IsEnabled();
1584 drawState
|= wxCONTROL_DISABLED
;
1586 if ( !m_bmpNormal
.Ok() )
1588 if ( flags
& Button_BitmapOnly
)
1591 // Need to clear button background even if m_btn is present
1592 if ( flags
& Button_PaintBackground
)
1596 if ( m_iFlags
& wxCC_IFLAG_BUTTON_OUTSIDE
)
1597 bgCol
= GetParent()->GetBackgroundColour();
1599 bgCol
= GetBackgroundColour();
1603 dc
.DrawRectangle(rect
);
1606 // Draw standard button
1607 wxRendererNative::Get().DrawComboBoxDropButton(this,
1619 pBmp
= &m_bmpDisabled
;
1620 else if ( m_btnState
& wxCONTROL_PRESSED
)
1621 pBmp
= &m_bmpPressed
;
1622 else if ( m_btnState
& wxCONTROL_CURRENT
)
1625 pBmp
= &m_bmpNormal
;
1627 if ( m_blankButtonBg
)
1629 // If using blank button background, we need to clear its background
1630 // with button face colour instead of colour for rest of the control.
1631 if ( flags
& Button_PaintBackground
)
1633 wxColour bgCol
= GetParent()->GetBackgroundColour(); //wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE);
1634 //wxColour bgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
1637 dc
.DrawRectangle(rect
);
1640 if ( !(flags
& Button_BitmapOnly
) )
1642 wxRendererNative::Get().DrawPushButton(this,
1651 // Need to clear button background even if m_btn is present
1652 // (assume non-button background was cleared just before this call so brushes are good)
1653 if ( flags
& Button_PaintBackground
)
1654 dc
.DrawRectangle(rect
);
1657 // Draw bitmap centered in drawRect
1658 dc
.DrawBitmap(*pBmp
,
1659 drawRect
.x
+ (drawRect
.width
-pBmp
->GetWidth())/2,
1660 drawRect
.y
+ (drawRect
.height
-pBmp
->GetHeight())/2,
1665 void wxComboCtrlBase::RecalcAndRefresh()
1669 wxSizeEvent
evt(GetSize(),GetId());
1670 GetEventHandler()->ProcessEvent(evt
);
1675 // ----------------------------------------------------------------------------
1676 // miscellaneous event handlers
1677 // ----------------------------------------------------------------------------
1679 void wxComboCtrlBase::OnTextCtrlEvent(wxCommandEvent
& event
)
1681 if ( event
.GetEventType() == wxEVT_COMMAND_TEXT_UPDATED
)
1683 if ( m_ignoreEvtText
> 0 )
1690 // Change event id, object and string before relaying it forward
1691 event
.SetId(GetId());
1692 wxString s
= event
.GetString();
1693 event
.SetEventObject(this);
1698 // call if cursor is on button area or mouse is captured for the button
1699 bool wxComboCtrlBase::HandleButtonMouseEvent( wxMouseEvent
& event
,
1702 int type
= event
.GetEventType();
1704 if ( type
== wxEVT_MOTION
)
1706 if ( (flags
& wxCC_MF_ON_BUTTON
) &&
1707 IsPopupWindowState(Hidden
) )
1709 if ( !(m_btnState
& wxCONTROL_CURRENT
) )
1711 // Mouse hover begins
1712 m_btnState
|= wxCONTROL_CURRENT
;
1713 if ( HasCapture() ) // Retain pressed state.
1714 m_btnState
|= wxCONTROL_PRESSED
;
1718 else if ( (m_btnState
& wxCONTROL_CURRENT
) )
1721 m_btnState
&= ~(wxCONTROL_CURRENT
|wxCONTROL_PRESSED
);
1725 else if ( type
== wxEVT_LEFT_DOWN
|| type
== wxEVT_LEFT_DCLICK
)
1727 if ( flags
& (wxCC_MF_ON_CLICK_AREA
|wxCC_MF_ON_BUTTON
) )
1729 m_btnState
|= wxCONTROL_PRESSED
;
1732 if ( !(m_iFlags
& wxCC_POPUP_ON_MOUSE_UP
) )
1735 // If showing popup now, do not capture mouse or there will be interference
1739 else if ( type
== wxEVT_LEFT_UP
)
1742 // Only accept event if mouse was left-press was previously accepted
1746 if ( m_btnState
& wxCONTROL_PRESSED
)
1748 // If mouse was inside, fire the click event.
1749 if ( m_iFlags
& wxCC_POPUP_ON_MOUSE_UP
)
1751 if ( flags
& (wxCC_MF_ON_CLICK_AREA
|wxCC_MF_ON_BUTTON
) )
1755 m_btnState
&= ~(wxCONTROL_PRESSED
);
1759 else if ( type
== wxEVT_LEAVE_WINDOW
)
1761 if ( m_btnState
& (wxCONTROL_CURRENT
|wxCONTROL_PRESSED
) )
1763 m_btnState
&= ~(wxCONTROL_CURRENT
);
1766 if ( IsPopupWindowState(Hidden
) )
1768 m_btnState
&= ~(wxCONTROL_PRESSED
);
1776 // Never have 'hot' state when popup is being shown
1777 // (this is mostly needed because of the animation).
1778 if ( !IsPopupWindowState(Hidden
) )
1779 m_btnState
&= ~wxCONTROL_CURRENT
;
1784 // returns true if event was consumed or filtered
1785 bool wxComboCtrlBase::PreprocessMouseEvent( wxMouseEvent
& event
,
1786 int WXUNUSED(flags
) )
1788 wxLongLong t
= ::wxGetLocalTimeMillis();
1789 int evtType
= event
.GetEventType();
1791 #if USES_WXPOPUPWINDOW || USES_GENERICTLW
1792 if ( m_popupWinType
!= POPUPWIN_WXPOPUPTRANSIENTWINDOW
)
1794 if ( IsPopupWindowState(Visible
) &&
1795 ( evtType
== wxEVT_LEFT_DOWN
|| evtType
== wxEVT_RIGHT_DOWN
) )
1803 // Filter out clicks on button immediately after popup dismiss
1804 if ( evtType
== wxEVT_LEFT_DOWN
&& t
< m_timeCanAcceptClick
)
1806 event
.SetEventType(0);
1813 void wxComboCtrlBase::HandleNormalMouseEvent( wxMouseEvent
& event
)
1815 int evtType
= event
.GetEventType();
1817 if ( (evtType
== wxEVT_LEFT_DOWN
|| evtType
== wxEVT_LEFT_DCLICK
) &&
1818 (m_windowStyle
& wxCB_READONLY
) )
1820 if ( GetPopupWindowState() >= Animating
)
1822 #if USES_WXPOPUPWINDOW
1823 // Click here always hides the popup.
1824 if ( m_popupWinType
== POPUPWIN_WXPOPUPWINDOW
)
1830 if ( !(m_windowStyle
& wxCC_SPECIAL_DCLICK
) )
1832 // In read-only mode, clicking the text is the
1833 // same as clicking the button.
1836 else if ( /*evtType == wxEVT_LEFT_UP || */evtType
== wxEVT_LEFT_DCLICK
)
1838 //if ( m_popupInterface->CycleValue() )
1840 if ( m_popupInterface
)
1841 m_popupInterface
->OnComboDoubleClick();
1845 else if ( evtType
== wxEVT_MOUSEWHEEL
)
1847 if ( IsPopupShown() )
1849 // relay (some) mouse events to the popup
1850 m_popup
->GetEventHandler()->ProcessEvent(event
);
1852 else if ( event
.GetWheelAxis() == 0 &&
1853 event
.GetWheelRotation() != 0 &&
1854 event
.GetModifiers() == 0 )
1856 // Translate mousewheel actions into key up/down. This is
1857 // the simplest way of getting native behaviour: scrolling the
1858 // wheel moves selection up/down by one item.
1859 wxKeyEvent
kevent(wxEVT_KEY_DOWN
);
1860 kevent
.m_keyCode
= event
.GetWheelRotation() > 0
1863 GetEventHandler()->ProcessEvent(kevent
);
1876 void wxComboCtrlBase::OnKeyEvent(wxKeyEvent
& event
)
1878 if ( IsPopupShown() )
1880 // pass it to the popped up control
1881 GetPopupControl()->GetControl()->GetEventHandler()->ProcessEvent(event
);
1885 wxWindow
* mainCtrl
= GetMainWindowOfCompositeControl();
1887 if ( mainCtrl
->GetParent()->HasFlag(wxTAB_TRAVERSAL
) )
1889 if ( mainCtrl
->HandleAsNavigationKey(event
) )
1893 if ( IsKeyPopupToggle(event
) )
1899 int comboStyle
= GetWindowStyle();
1900 wxComboPopup
* popupInterface
= GetPopupControl();
1902 if ( !popupInterface
)
1908 int keycode
= event
.GetKeyCode();
1910 if ( (comboStyle
& wxCB_READONLY
) ||
1911 (keycode
!= WXK_RIGHT
&& keycode
!= WXK_LEFT
) )
1913 popupInterface
->OnComboKeyEvent(event
);
1920 void wxComboCtrlBase::OnCharEvent(wxKeyEvent
& event
)
1922 if ( IsPopupShown() )
1924 // pass it to the popped up control
1925 GetPopupControl()->GetControl()->GetEventHandler()->ProcessEvent(event
);
1929 wxComboPopup
* popupInterface
= GetPopupControl();
1930 if ( popupInterface
)
1932 popupInterface
->OnComboCharEvent(event
);
1941 void wxComboCtrlBase::OnFocusEvent( wxFocusEvent
& event
)
1943 if ( event
.GetEventType() == wxEVT_SET_FOCUS
)
1945 wxWindow
* tc
= GetTextCtrl();
1946 if ( tc
&& tc
!= DoFindFocus() )
1955 void wxComboCtrlBase::OnIdleEvent( wxIdleEvent
& WXUNUSED(event
) )
1959 m_resetFocus
= false;
1960 wxWindow
* tc
= GetTextCtrl();
1966 void wxComboCtrlBase::OnSysColourChanged(wxSysColourChangedEvent
& WXUNUSED(event
))
1969 // left margin may also have changed
1970 if ( !(m_iFlags
& wxCC_IFLAG_LEFT_MARGIN_SET
) )
1971 m_marginLeft
= GetNativeTextIndent();
1975 // ----------------------------------------------------------------------------
1977 // ----------------------------------------------------------------------------
1979 // Create popup window and the child control
1980 void wxComboCtrlBase::CreatePopup()
1982 wxComboPopup
* popupInterface
= m_popupInterface
;
1987 #ifdef wxComboPopupWindowBase2
1988 if ( m_iFlags
& wxCC_IFLAG_USE_ALT_POPUP
)
1990 #if !USES_GENERICTLW
1991 m_winPopup
= new wxComboPopupWindowBase2( this, wxNO_BORDER
);
1993 int tlwFlags
= wxNO_BORDER
;
1994 #ifdef wxCC_GENERIC_TLW_IS_FRAME
1995 tlwFlags
|= wxFRAME_NO_TASKBAR
;
1998 #ifdef wxCC_GENERIC_TLW_IS_NONOWNEDWINDOW
1999 m_winPopup
= new wxComboPopupWindowBase2( this, wxID_ANY
,
2000 wxPoint(-21,-21), wxSize(20, 20),
2003 m_winPopup
= new wxComboPopupWindowBase2( this, wxID_ANY
, wxEmptyString
,
2004 wxPoint(-21,-21), wxSize(20, 20),
2008 m_popupWinType
= SECONDARY_POPUP_TYPE
;
2011 #endif // wxComboPopupWindowBase2
2013 m_winPopup
= new wxComboPopupWindow( this, wxNO_BORDER
);
2014 m_popupWinType
= PRIMARY_POPUP_TYPE
;
2016 m_popupWinEvtHandler
= new wxComboPopupWindowEvtHandler(this);
2017 m_winPopup
->PushEventHandler(m_popupWinEvtHandler
);
2020 popupInterface
->Create(m_winPopup
);
2021 m_popup
= popup
= popupInterface
->GetControl();
2023 m_popupEvtHandler
= new wxComboPopupEvtHandler(this);
2024 popup
->PushEventHandler( m_popupEvtHandler
);
2026 // This may be helpful on some platforms
2027 // (eg. it bypasses a wxGTK popupwindow bug where
2028 // window is not initially hidden when it should be)
2031 popupInterface
->m_iFlags
|= wxCP_IFLAG_CREATED
;
2034 // Destroy popup window and the child control
2035 void wxComboCtrlBase::DestroyPopup()
2040 m_popup
->RemoveEventHandler(m_popupEvtHandler
);
2042 wxDELETE(m_popupEvtHandler
);
2044 wxDELETE(m_popupInterface
);
2048 m_winPopup
->RemoveEventHandler(m_popupWinEvtHandler
);
2049 wxDELETE(m_popupWinEvtHandler
);
2050 m_winPopup
->Destroy();
2057 void wxComboCtrlBase::DoSetPopupControl(wxComboPopup
* iface
)
2059 wxCHECK_RET( iface
, wxT("no popup interface set for wxComboCtrl") );
2063 iface
->InitBase(this);
2066 m_popupInterface
= iface
;
2068 if ( !iface
->LazyCreate() )
2077 // This must be done after creation
2078 if ( m_valueString
.length() )
2080 iface
->SetStringValue(m_valueString
);
2085 // Ensures there is atleast the default popup
2086 void wxComboCtrlBase::EnsurePopupControl()
2088 if ( !m_popupInterface
)
2089 SetPopupControl(NULL
);
2092 void wxComboCtrlBase::OnButtonClick()
2094 // Derived classes can override this method for totally custom
2096 switch ( GetPopupWindowState() )
2100 wxCommandEvent
event(wxEVT_COMMAND_COMBOBOX_DROPDOWN
, GetId());
2101 event
.SetEventObject(this);
2102 HandleWindowEvent(event
);
2117 void wxComboCtrlBase::ShowPopup()
2119 EnsurePopupControl();
2120 wxCHECK_RET( !IsPopupWindowState(Visible
), wxT("popup window already shown") );
2122 if ( IsPopupWindowState(Animating
) )
2127 // Space above and below
2133 wxSize ctrlSz
= GetSize();
2135 screenHeight
= wxSystemSettings::GetMetric( wxSYS_SCREEN_Y
);
2136 scrPos
= GetParent()->ClientToScreen(GetPosition());
2138 spaceAbove
= scrPos
.y
;
2139 spaceBelow
= screenHeight
- spaceAbove
- ctrlSz
.y
;
2141 maxHeightPopup
= spaceBelow
;
2142 if ( spaceAbove
> spaceBelow
)
2143 maxHeightPopup
= spaceAbove
;
2146 int widthPopup
= ctrlSz
.x
+ m_extLeft
+ m_extRight
;
2148 if ( widthPopup
< m_widthMinPopup
)
2149 widthPopup
= m_widthMinPopup
;
2151 wxWindow
* winPopup
= m_winPopup
;
2154 // Need to disable tab traversal of parent
2156 // NB: This is to fix a bug in wxMSW. In theory it could also be fixed
2157 // by, for instance, adding check to window.cpp:wxWindowMSW::MSWProcessMessage
2158 // that if transient popup is open, then tab traversal is to be ignored.
2159 // However, I think this code would still be needed for cases where
2160 // transient popup doesn't work yet (wxWinCE?).
2161 wxWindow
* mainCtrl
= GetMainWindowOfCompositeControl();
2162 wxWindow
* parent
= mainCtrl
->GetParent();
2163 int parentFlags
= parent
->GetWindowStyle();
2164 if ( parentFlags
& wxTAB_TRAVERSAL
)
2166 parent
->SetWindowStyle( parentFlags
& ~(wxTAB_TRAVERSAL
) );
2167 m_iFlags
|= wxCC_IFLAG_PARENT_TAB_TRAVERSAL
;
2173 winPopup
= m_winPopup
;
2183 wxASSERT( !m_popup
|| m_popup
== popup
); // Consistency check.
2185 wxSize adjustedSize
= m_popupInterface
->GetAdjustedSize(widthPopup
,
2186 m_heightPopup
<=0?DEFAULT_POPUP_HEIGHT
:m_heightPopup
,
2189 popup
->SetSize(adjustedSize
);
2191 m_popupInterface
->OnPopup();
2194 // Reposition and resize popup window
2197 wxSize szp
= popup
->GetSize();
2200 int popupY
= scrPos
.y
+ ctrlSz
.y
;
2202 // Default anchor is wxLEFT
2203 int anchorSide
= m_anchorSide
;
2205 anchorSide
= wxLEFT
;
2207 int rightX
= scrPos
.x
+ ctrlSz
.x
+ m_extRight
- szp
.x
;
2208 int leftX
= scrPos
.x
- m_extLeft
;
2210 if ( wxTheApp
->GetLayoutDirection() == wxLayout_RightToLeft
)
2213 int screenWidth
= wxSystemSettings::GetMetric( wxSYS_SCREEN_X
);
2215 // If there is not enough horizontal space, anchor on the other side.
2216 // If there is no space even then, place the popup at x 0.
2217 if ( anchorSide
== wxRIGHT
)
2221 if ( (leftX
+szp
.x
) < screenWidth
)
2222 anchorSide
= wxLEFT
;
2229 if ( (leftX
+szp
.x
) >= screenWidth
)
2232 anchorSide
= wxRIGHT
;
2238 // Select x coordinate according to the anchor side
2239 if ( anchorSide
== wxRIGHT
)
2241 else if ( anchorSide
== wxLEFT
)
2246 int showFlags
= CanDeferShow
;
2248 if ( spaceBelow
< szp
.y
)
2250 popupY
= scrPos
.y
- szp
.y
;
2251 showFlags
|= ShowAbove
;
2254 #if INSTALL_TOPLEV_HANDLER
2255 // Put top level window event handler into place
2256 if ( m_popupWinType
== POPUPWIN_WXPOPUPWINDOW
)
2258 if ( !m_toplevEvtHandler
)
2259 m_toplevEvtHandler
= new wxComboFrameEventHandler(this);
2261 wxWindow
* toplev
= ::wxGetTopLevelParent( this );
2263 ((wxComboFrameEventHandler
*)m_toplevEvtHandler
)->OnPopup();
2264 toplev
->PushEventHandler( m_toplevEvtHandler
);
2268 // Set string selection (must be this way instead of SetStringSelection)
2271 if ( !(m_iFlags
& wxCC_NO_TEXT_AUTO_SELECT
) )
2272 m_text
->SelectAll();
2274 m_popupInterface
->SetStringValue( m_text
->GetValue() );
2278 // This is neede since focus/selection indication may change when popup is shown
2282 // This must be after SetStringValue
2283 m_popupWinState
= Animating
;
2285 wxRect
popupWinRect( popupX
, popupY
, szp
.x
, szp
.y
);
2288 if ( (m_iFlags
& wxCC_IFLAG_DISABLE_POPUP_ANIM
) ||
2289 AnimateShow( popupWinRect
, showFlags
) )
2291 DoShowPopup( popupWinRect
, showFlags
);
2295 bool wxComboCtrlBase::AnimateShow( const wxRect
& WXUNUSED(rect
), int WXUNUSED(flags
) )
2300 void wxComboCtrlBase::DoShowPopup( const wxRect
& rect
, int WXUNUSED(flags
) )
2302 wxWindow
* winPopup
= m_winPopup
;
2304 if ( IsPopupWindowState(Animating
) )
2306 // Make sure the popup window is shown in the right position.
2307 // Should not matter even if animation already did this.
2309 // Some platforms (GTK) may like SetSize and Move to be separate
2310 // (though the bug was probably fixed).
2311 winPopup
->SetSize( rect
);
2313 #if USES_WXPOPUPTRANSIENTWINDOW
2314 if ( m_popupWinType
== POPUPWIN_WXPOPUPTRANSIENTWINDOW
)
2315 ((wxPopupTransientWindow
*)winPopup
)->Popup(m_popup
);
2320 m_popupWinState
= Visible
;
2322 // If popup window was a generic top-level window, or the
2323 // wxPopupWindow implemenation on this platform is classified as
2324 // perfect, then we should be able to safely set focus to the popup
2326 if ( IsPopupWinTypePerfect(m_popupWinType
) )
2327 m_popup
->SetFocus();
2329 else if ( IsPopupWindowState(Hidden
) )
2331 // Animation was aborted
2333 wxASSERT( !winPopup
->IsShown() );
2335 m_popupWinState
= Hidden
;
2341 void wxComboCtrlBase::OnPopupDismiss(bool generateEvent
)
2343 // Just in case, avoid double dismiss
2344 if ( IsPopupWindowState(Hidden
) )
2347 // This must be set before focus - otherwise there will be recursive
2348 // OnPopupDismisses.
2349 m_popupWinState
= Hidden
;
2352 m_winPopup
->Disable();
2354 // Inform popup control itself
2355 m_popupInterface
->OnDismiss();
2357 if ( m_popupEvtHandler
)
2358 ((wxComboPopupEvtHandler
*)m_popupEvtHandler
)->OnPopupDismiss();
2360 #if INSTALL_TOPLEV_HANDLER
2361 // Remove top level window event handler
2362 if ( m_toplevEvtHandler
)
2364 wxWindow
* toplev
= ::wxGetTopLevelParent( this );
2366 toplev
->RemoveEventHandler( m_toplevEvtHandler
);
2370 m_timeCanAcceptClick
= ::wxGetLocalTimeMillis();
2372 if ( m_popupWinType
== POPUPWIN_WXPOPUPTRANSIENTWINDOW
)
2373 m_timeCanAcceptClick
+= 150;
2375 // If cursor not on dropdown button, then clear its state
2376 // (technically not required by all ports, but do it for all just in case)
2377 if ( !m_btnArea
.Contains(ScreenToClient(::wxGetMousePosition())) )
2380 // Return parent's tab traversal flag.
2381 // See ShowPopup for notes.
2382 if ( m_iFlags
& wxCC_IFLAG_PARENT_TAB_TRAVERSAL
)
2384 wxWindow
* parent
= GetParent();
2385 parent
->SetWindowStyle( parent
->GetWindowStyle() | wxTAB_TRAVERSAL
);
2386 m_iFlags
&= ~(wxCC_IFLAG_PARENT_TAB_TRAVERSAL
);
2389 // refresh control (necessary even if m_text)
2394 if ( generateEvent
)
2396 wxCommandEvent
event(wxEVT_COMMAND_COMBOBOX_CLOSEUP
, GetId());
2397 event
.SetEventObject(this);
2398 HandleWindowEvent(event
);
2402 void wxComboCtrlBase::HidePopup(bool generateEvent
)
2404 // Should be able to call this without popup interface
2405 if ( IsPopupWindowState(Hidden
) )
2408 // transfer value and show it in textctrl, if any
2409 if ( !IsPopupWindowState(Animating
) )
2410 SetValue( m_popupInterface
->GetStringValue() );
2414 OnPopupDismiss(generateEvent
);
2417 // ----------------------------------------------------------------------------
2418 // customization methods
2419 // ----------------------------------------------------------------------------
2421 void wxComboCtrlBase::SetButtonPosition( int width
, int height
,
2422 int side
, int spacingX
)
2427 m_btnSpacingX
= spacingX
;
2429 if ( width
> 0 || height
> 0 || spacingX
)
2430 m_iFlags
|= wxCC_IFLAG_HAS_NONSTANDARD_BUTTON
;
2435 wxSize
wxComboCtrlBase::GetButtonSize()
2437 if ( m_btnSize
.x
> 0 )
2440 wxSize
retSize(m_btnWid
,m_btnHei
);
2442 // Need to call CalculateAreas now if button size is
2443 // is not explicitly specified.
2444 if ( retSize
.x
<= 0 || retSize
.y
<= 0)
2448 retSize
= m_btnSize
;
2454 void wxComboCtrlBase::SetButtonBitmaps( const wxBitmap
& bmpNormal
,
2456 const wxBitmap
& bmpPressed
,
2457 const wxBitmap
& bmpHover
,
2458 const wxBitmap
& bmpDisabled
)
2460 m_bmpNormal
= bmpNormal
;
2461 m_blankButtonBg
= blankButtonBg
;
2463 if ( bmpPressed
.Ok() )
2464 m_bmpPressed
= bmpPressed
;
2466 m_bmpPressed
= bmpNormal
;
2468 if ( bmpHover
.Ok() )
2469 m_bmpHover
= bmpHover
;
2471 m_bmpHover
= bmpNormal
;
2473 if ( bmpDisabled
.Ok() )
2474 m_bmpDisabled
= bmpDisabled
;
2476 m_bmpDisabled
= bmpNormal
;
2481 void wxComboCtrlBase::SetCustomPaintWidth( int width
)
2485 // move textctrl accordingly
2486 wxRect r
= m_text
->GetRect();
2487 int inc
= width
- m_widthCustomPaint
;
2490 m_text
->SetSize( r
);
2493 m_widthCustomPaint
= width
;
2498 bool wxComboCtrlBase::DoSetMargins(const wxPoint
& margins
)
2500 // For general sanity's sake, we ignore top margin. Instead
2501 // we will always try to center the text vertically.
2504 if ( margins
.x
!= -1 )
2506 m_marginLeft
= margins
.x
;
2507 m_iFlags
|= wxCC_IFLAG_LEFT_MARGIN_SET
;
2511 m_marginLeft
= GetNativeTextIndent();
2512 m_iFlags
&= ~(wxCC_IFLAG_LEFT_MARGIN_SET
);
2515 if ( margins
.y
!= -1 )
2525 wxPoint
wxComboCtrlBase::DoGetMargins() const
2527 return wxPoint(m_marginLeft
, -1);
2530 #if WXWIN_COMPATIBILITY_2_8
2531 void wxComboCtrlBase::SetTextIndent( int indent
)
2535 m_marginLeft
= GetNativeTextIndent();
2536 m_iFlags
&= ~(wxCC_IFLAG_LEFT_MARGIN_SET
);
2540 m_marginLeft
= indent
;
2541 m_iFlags
|= wxCC_IFLAG_LEFT_MARGIN_SET
;
2547 wxCoord
wxComboCtrlBase::GetTextIndent() const
2549 return m_marginLeft
;
2553 wxCoord
wxComboCtrlBase::GetNativeTextIndent() const
2555 return DEFAULT_TEXT_INDENT
;
2558 void wxComboCtrlBase::SetTextCtrlStyle( int style
)
2560 m_textCtrlStyle
= style
;
2563 m_text
->SetWindowStyle(style
);
2566 // ----------------------------------------------------------------------------
2567 // methods forwarded to wxTextCtrl
2568 // ----------------------------------------------------------------------------
2570 wxString
wxComboCtrlBase::GetValue() const
2573 return m_text
->GetValue();
2574 return m_valueString
;
2577 void wxComboCtrlBase::SetValueWithEvent(const wxString
& value
, bool withEvent
)
2584 m_text
->SetValue(value
);
2586 if ( !(m_iFlags
& wxCC_NO_TEXT_AUTO_SELECT
) )
2587 m_text
->SelectAll();
2590 // Since wxComboPopup may want to paint the combo as well, we need
2591 // to set the string value here (as well as sometimes in ShowPopup).
2592 if ( m_valueString
!= value
)
2594 m_valueString
= value
;
2596 EnsurePopupControl();
2598 if (m_popupInterface
)
2599 m_popupInterface
->SetStringValue(value
);
2605 void wxComboCtrlBase::SetValue(const wxString
& value
)
2607 SetValueWithEvent(value
, false);
2610 // In this SetValue variant wxComboPopup::SetStringValue is not called
2611 void wxComboCtrlBase::SetText(const wxString
& value
)
2613 // Unlike in SetValue(), this must be called here or
2614 // the behaviour will no be consistent in readonlys.
2615 EnsurePopupControl();
2617 m_valueString
= value
;
2622 m_text
->SetValue( value
);
2628 void wxComboCtrlBase::Copy()
2634 void wxComboCtrlBase::Cut()
2640 void wxComboCtrlBase::Paste()
2646 void wxComboCtrlBase::SetInsertionPoint(long pos
)
2649 m_text
->SetInsertionPoint(pos
);
2652 void wxComboCtrlBase::SetInsertionPointEnd()
2655 m_text
->SetInsertionPointEnd();
2658 long wxComboCtrlBase::GetInsertionPoint() const
2661 return m_text
->GetInsertionPoint();
2666 long wxComboCtrlBase::GetLastPosition() const
2669 return m_text
->GetLastPosition();
2674 void wxComboCtrlBase::Replace(long from
, long to
, const wxString
& value
)
2677 m_text
->Replace(from
, to
, value
);
2680 void wxComboCtrlBase::Remove(long from
, long to
)
2683 m_text
->Remove(from
, to
);
2686 void wxComboCtrlBase::SetSelection(long from
, long to
)
2689 m_text
->SetSelection(from
, to
);
2692 void wxComboCtrlBase::Undo()
2698 bool wxComboCtrlBase::SetHint(const wxString
& hint
)
2703 res
= m_text
->SetHint(hint
);
2708 wxString
wxComboCtrlBase::GetHint() const
2713 #endif // wxUSE_COMBOCTRL