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 #include "wx/gtk/private.h"
90 // NB: Let's not be afraid to use wxGTK's wxPopupTransientWindow as a
91 // 'perfect' popup, as it can succesfully host child controls even in
92 // popups that are shown in modal dialogs.
94 #define USE_TRANSIENT_POPUP 1 // Use wxPopupWindowTransient (preferred, if it works properly on platform)
95 #define TRANSIENT_POPUPWIN_IS_PERFECT 1 // wxPopupTransientWindow works, its child can have focus, and common
96 // native controls work on it like normal.
97 #define POPUPWIN_IS_PERFECT 1 // Same, but for non-transient popup window.
98 #define TEXTCTRL_TEXT_CENTERED 1 // 1 if text in textctrl is vertically centered
99 #define FOCUS_RING 0 // No focus ring on wxGTK
101 #elif defined(__WXMAC__)
103 #include "wx/nonownedwnd.h"
104 #define wxCC_GENERIC_TLW_IS_NONOWNEDWINDOW
105 #define wxComboCtrlGenericTLW wxNonOwnedWindow
107 #define USE_TRANSIENT_POPUP 1 // Use wxPopupWindowTransient (preferred, if it works properly on platform)
108 #define TRANSIENT_POPUPWIN_IS_PERFECT 1 // wxPopupTransientWindow works, its child can have focus, and common
109 // native controls work on it like normal.
110 #define POPUPWIN_IS_PERFECT 1 // Same, but for non-transient popup window.
111 #define TEXTCTRL_TEXT_CENTERED 1 // 1 if text in textctrl is vertically centered
112 #define FOCUS_RING 3 // Reserve room for the textctrl's focus ring to display
114 #undef DEFAULT_DROPBUTTON_WIDTH
115 #define DEFAULT_DROPBUTTON_WIDTH 22
117 #define COMBO_MARGIN FOCUS_RING
121 #include "wx/dialog.h"
122 #define wxCC_GENERIC_TLW_IS_DIALOG
123 #define wxComboCtrlGenericTLW wxDialog
125 #define USE_TRANSIENT_POPUP 0 // Use wxPopupWindowTransient (preferred, if it works properly on platform)
126 #define TRANSIENT_POPUPWIN_IS_PERFECT 0 // wxPopupTransientWindow works, its child can have focus, and common
127 // native controls work on it like normal.
128 #define POPUPWIN_IS_PERFECT 0 // Same, but for non-transient popup window.
129 #define TEXTCTRL_TEXT_CENTERED 1 // 1 if text in textctrl is vertically centered
135 // Popupwin is really only supported on wxMSW (not WINCE) and wxGTK, regardless
136 // what the wxUSE_POPUPWIN says.
137 // FIXME: Why isn't wxUSE_POPUPWIN reliable any longer? (it was in wxW2.6.2)
138 #if (!defined(__WXMSW__) && !defined(__WXGTK__) && !defined(__WXMAC__)) || defined(__WXWINCE__)
139 #undef wxUSE_POPUPWIN
140 #define wxUSE_POPUPWIN 0
145 #include "wx/popupwin.h"
147 #undef USE_TRANSIENT_POPUP
148 #define USE_TRANSIENT_POPUP 0
152 // Define different types of popup windows
156 POPUPWIN_WXPOPUPTRANSIENTWINDOW
= 1,
157 POPUPWIN_WXPOPUPWINDOW
= 2,
158 POPUPWIN_GENERICTLW
= 3
162 #if USE_TRANSIENT_POPUP
163 // wxPopupTransientWindow is implemented
165 #define wxComboPopupWindowBase wxPopupTransientWindow
166 #define PRIMARY_POPUP_TYPE POPUPWIN_WXPOPUPTRANSIENTWINDOW
167 #define USES_WXPOPUPTRANSIENTWINDOW 1
169 #if TRANSIENT_POPUPWIN_IS_PERFECT
171 #elif POPUPWIN_IS_PERFECT
172 #define wxComboPopupWindowBase2 wxPopupWindow
173 #define SECONDARY_POPUP_TYPE POPUPWIN_WXPOPUPWINDOW
174 #define USES_WXPOPUPWINDOW 1
176 #define wxComboPopupWindowBase2 wxComboCtrlGenericTLW
177 #define SECONDARY_POPUP_TYPE POPUPWIN_GENERICTLW
178 #define USES_GENERICTLW 1
182 // wxPopupWindow (but not wxPopupTransientWindow) is properly implemented
184 #define wxComboPopupWindowBase wxPopupWindow
185 #define PRIMARY_POPUP_TYPE POPUPWIN_WXPOPUPWINDOW
186 #define USES_WXPOPUPWINDOW 1
188 #if !POPUPWIN_IS_PERFECT
189 #define wxComboPopupWindowBase2 wxComboCtrlGenericTLW
190 #define SECONDARY_POPUP_TYPE POPUPWIN_GENERICTLW
191 #define USES_GENERICTLW 1
195 // wxPopupWindow is not implemented
197 #define wxComboPopupWindowBase wxComboCtrlGenericTLW
198 #define PRIMARY_POPUP_TYPE POPUPWIN_GENERICTLW
199 #define USES_GENERICTLW 1
204 #ifndef USES_WXPOPUPTRANSIENTWINDOW
205 #define USES_WXPOPUPTRANSIENTWINDOW 0
208 #ifndef USES_WXPOPUPWINDOW
209 #define USES_WXPOPUPWINDOW 0
212 #ifndef USES_GENERICTLW
213 #define USES_GENERICTLW 0
217 #if USES_WXPOPUPWINDOW
218 #define INSTALL_TOPLEV_HANDLER 1
220 #define INSTALL_TOPLEV_HANDLER 0
224 // Returns true if given popup window type can be classified as perfect
226 static inline bool IsPopupWinTypePerfect( wxByte popupWinType
)
228 #if POPUPWIN_IS_PERFECT && TRANSIENT_POPUPWIN_IS_PERFECT
229 wxUnusedVar(popupWinType
);
232 return ( popupWinType
== POPUPWIN_GENERICTLW
233 #if POPUPWIN_IS_PERFECT
234 || popupWinType
== POPUPWIN_WXPOPUPWINDOW
236 #if TRANSIENT_POPUPWIN_IS_PERFECT
237 || popupWinType
== POPUPWIN_WXPOPUPTRANSIENTWINDOW
246 // * wxComboPopupWindow for external use (ie. replace old wxUniv wxPopupComboWindow)
250 // ----------------------------------------------------------------------------
251 // wxComboFrameEventHandler takes care of hiding the popup when events happen
252 // in its top level parent.
253 // ----------------------------------------------------------------------------
255 #if INSTALL_TOPLEV_HANDLER
258 // This will no longer be necessary after wxTransientPopupWindow
259 // works well on all platforms.
262 class wxComboFrameEventHandler
: public wxEvtHandler
265 wxComboFrameEventHandler( wxComboCtrlBase
* pCb
);
266 virtual ~wxComboFrameEventHandler();
270 void OnIdle( wxIdleEvent
& event
);
271 void OnMouseEvent( wxMouseEvent
& event
);
272 void OnActivate( wxActivateEvent
& event
);
273 void OnResize( wxSizeEvent
& event
);
274 void OnMove( wxMoveEvent
& event
);
275 void OnMenuEvent( wxMenuEvent
& event
);
276 void OnClose( wxCloseEvent
& event
);
279 wxWindow
* m_focusStart
;
280 wxComboCtrlBase
* m_combo
;
283 DECLARE_EVENT_TABLE()
286 BEGIN_EVENT_TABLE(wxComboFrameEventHandler
, wxEvtHandler
)
287 EVT_IDLE(wxComboFrameEventHandler::OnIdle
)
288 EVT_LEFT_DOWN(wxComboFrameEventHandler::OnMouseEvent
)
289 EVT_RIGHT_DOWN(wxComboFrameEventHandler::OnMouseEvent
)
290 EVT_SIZE(wxComboFrameEventHandler::OnResize
)
291 EVT_MOVE(wxComboFrameEventHandler::OnMove
)
292 EVT_MENU_HIGHLIGHT(wxID_ANY
,wxComboFrameEventHandler::OnMenuEvent
)
293 EVT_MENU_OPEN(wxComboFrameEventHandler::OnMenuEvent
)
294 EVT_ACTIVATE(wxComboFrameEventHandler::OnActivate
)
295 EVT_CLOSE(wxComboFrameEventHandler::OnClose
)
298 wxComboFrameEventHandler::wxComboFrameEventHandler( wxComboCtrlBase
* combo
)
304 wxComboFrameEventHandler::~wxComboFrameEventHandler()
308 void wxComboFrameEventHandler::OnPopup()
310 m_focusStart
= ::wxWindow::FindFocus();
313 void wxComboFrameEventHandler::OnIdle( wxIdleEvent
& event
)
315 wxWindow
* winFocused
= ::wxWindow::FindFocus();
317 wxWindow
* popup
= m_combo
->GetPopupControl()->GetControl();
318 wxWindow
* winpopup
= m_combo
->GetPopupWindow();
321 winFocused
!= m_focusStart
&&
322 winFocused
!= popup
&&
323 winFocused
->GetParent() != popup
&&
324 winFocused
!= winpopup
&&
325 winFocused
->GetParent() != winpopup
&&
326 winFocused
!= m_combo
&&
327 winFocused
!= m_combo
->GetButton() // GTK (atleast) requires this
330 m_combo
->HidePopup(true);
336 void wxComboFrameEventHandler::OnMenuEvent( wxMenuEvent
& event
)
338 m_combo
->HidePopup(true);
342 void wxComboFrameEventHandler::OnMouseEvent( wxMouseEvent
& event
)
344 m_combo
->HidePopup(true);
348 void wxComboFrameEventHandler::OnClose( wxCloseEvent
& event
)
350 m_combo
->HidePopup(true);
354 void wxComboFrameEventHandler::OnActivate( wxActivateEvent
& event
)
356 m_combo
->HidePopup(true);
360 void wxComboFrameEventHandler::OnResize( wxSizeEvent
& event
)
362 m_combo
->HidePopup(true);
366 void wxComboFrameEventHandler::OnMove( wxMoveEvent
& event
)
368 m_combo
->HidePopup(true);
372 #endif // INSTALL_TOPLEV_HANDLER
374 // ----------------------------------------------------------------------------
375 // wxComboPopupWindow is, in essence, wxPopupWindow customized for
377 // ----------------------------------------------------------------------------
379 class wxComboPopupWindow
: public wxComboPopupWindowBase
383 wxComboPopupWindow( wxComboCtrlBase
*parent
,
385 #if USES_WXPOPUPWINDOW || USES_WXPOPUPTRANSIENTWINDOW
386 : wxComboPopupWindowBase(parent
,style
)
388 : wxComboPopupWindowBase(parent
,
399 #if USES_WXPOPUPTRANSIENTWINDOW
400 virtual bool Show( bool show
);
401 virtual bool ProcessLeftDown(wxMouseEvent
& event
);
403 virtual void OnDismiss();
411 #if USES_WXPOPUPTRANSIENTWINDOW
412 bool wxComboPopupWindow::Show( bool show
)
414 // Guard against recursion
416 return wxComboPopupWindowBase::Show(show
);
420 wxASSERT( IsKindOf(CLASSINFO(wxPopupTransientWindow
)) );
422 wxPopupTransientWindow
* ptw
= (wxPopupTransientWindow
*) this;
424 if ( show
!= ptw
->IsShown() )
427 // We used to do wxPopupTransientWindow::Popup here,
428 // but this would hide normal Show, which we are
429 // also going to need.
440 bool wxComboPopupWindow::ProcessLeftDown(wxMouseEvent
& event
)
442 return wxPopupTransientWindow::ProcessLeftDown(event
);
445 // First thing that happens when a transient popup closes is that this method gets called.
446 void wxComboPopupWindow::OnDismiss()
448 wxComboCtrlBase
* combo
= (wxComboCtrlBase
*) GetParent();
449 wxASSERT_MSG( combo
->IsKindOf(CLASSINFO(wxComboCtrlBase
)),
450 wxT("parent might not be wxComboCtrl, but check IMPLEMENT_DYNAMIC_CLASS(2) macro for correctness") );
452 combo
->OnPopupDismiss(true);
454 #endif // USES_WXPOPUPTRANSIENTWINDOW
457 // ----------------------------------------------------------------------------
458 // wxComboPopupWindowEvtHandler does bulk of the custom event handling
459 // of a popup window. It is separate so we can have different types
461 // ----------------------------------------------------------------------------
463 class wxComboPopupWindowEvtHandler
: public wxEvtHandler
467 wxComboPopupWindowEvtHandler( wxComboCtrlBase
*parent
)
472 void OnSizeEvent( wxSizeEvent
& event
);
473 void OnKeyEvent(wxKeyEvent
& event
);
475 void OnActivate( wxActivateEvent
& event
);
479 wxComboCtrlBase
* m_combo
;
481 DECLARE_EVENT_TABLE()
485 BEGIN_EVENT_TABLE(wxComboPopupWindowEvtHandler
, wxEvtHandler
)
486 EVT_KEY_DOWN(wxComboPopupWindowEvtHandler::OnKeyEvent
)
487 EVT_KEY_UP(wxComboPopupWindowEvtHandler::OnKeyEvent
)
488 EVT_CHAR(wxComboPopupWindowEvtHandler::OnKeyEvent
)
490 EVT_ACTIVATE(wxComboPopupWindowEvtHandler::OnActivate
)
492 EVT_SIZE(wxComboPopupWindowEvtHandler::OnSizeEvent
)
496 void wxComboPopupWindowEvtHandler::OnSizeEvent( wxSizeEvent
& WXUNUSED(event
) )
498 // Block the event so that the popup control does not get auto-resized.
501 void wxComboPopupWindowEvtHandler::OnKeyEvent( wxKeyEvent
& event
)
503 // Relay keyboard event to the main child controls
504 wxWindowList children
= m_combo
->GetPopupWindow()->GetChildren();
505 wxWindowList::iterator node
= children
.begin();
506 wxWindow
* child
= (wxWindow
*)*node
;
507 child
->GetEventHandler()->ProcessEvent(event
);
511 void wxComboPopupWindowEvtHandler::OnActivate( wxActivateEvent
& event
)
513 if ( !event
.GetActive() )
515 // Tell combo control that we are dismissed.
516 m_combo
->HidePopup(true);
524 // ----------------------------------------------------------------------------
527 // ----------------------------------------------------------------------------
529 wxComboPopup::~wxComboPopup()
533 void wxComboPopup::OnPopup()
537 void wxComboPopup::OnDismiss()
541 wxComboCtrl
* wxComboPopup::GetComboCtrl() const
543 return wxStaticCast(m_combo
, wxComboCtrl
);
546 wxSize
wxComboPopup::GetAdjustedSize( int minWidth
,
548 int WXUNUSED(maxHeight
) )
550 return wxSize(minWidth
,prefHeight
);
553 void wxComboPopup::DefaultPaintComboControl( wxComboCtrlBase
* combo
,
554 wxDC
& dc
, const wxRect
& rect
)
556 if ( combo
->GetWindowStyle() & wxCB_READONLY
) // ie. no textctrl
558 combo
->PrepareBackground(dc
,rect
,0);
560 dc
.DrawText( combo
->GetValue(),
561 rect
.x
+ combo
->m_marginLeft
,
562 (rect
.height
-dc
.GetCharHeight())/2 + rect
.y
);
566 void wxComboPopup::PaintComboControl( wxDC
& dc
, const wxRect
& rect
)
568 DefaultPaintComboControl(m_combo
,dc
,rect
);
571 void wxComboPopup::OnComboKeyEvent( wxKeyEvent
& event
)
576 void wxComboPopup::OnComboCharEvent( wxKeyEvent
& event
)
581 void wxComboPopup::OnComboDoubleClick()
585 void wxComboPopup::SetStringValue( const wxString
& WXUNUSED(value
) )
589 bool wxComboPopup::LazyCreate()
594 void wxComboPopup::Dismiss()
596 m_combo
->HidePopup(true);
599 // ----------------------------------------------------------------------------
601 // ----------------------------------------------------------------------------
604 // This is pushed to the event handler queue of the child textctrl.
606 class wxComboBoxExtraInputHandler
: public wxEvtHandler
610 wxComboBoxExtraInputHandler( wxComboCtrlBase
* combo
)
615 virtual ~wxComboBoxExtraInputHandler() { }
616 void OnKey(wxKeyEvent
& event
);
617 void OnFocus(wxFocusEvent
& event
);
620 wxComboCtrlBase
* m_combo
;
623 DECLARE_EVENT_TABLE()
627 BEGIN_EVENT_TABLE(wxComboBoxExtraInputHandler
, wxEvtHandler
)
628 EVT_KEY_DOWN(wxComboBoxExtraInputHandler::OnKey
)
629 EVT_KEY_UP(wxComboBoxExtraInputHandler::OnKey
)
630 EVT_CHAR(wxComboBoxExtraInputHandler::OnKey
)
631 EVT_SET_FOCUS(wxComboBoxExtraInputHandler::OnFocus
)
632 EVT_KILL_FOCUS(wxComboBoxExtraInputHandler::OnFocus
)
636 void wxComboBoxExtraInputHandler::OnKey(wxKeyEvent
& event
)
638 // Let the wxComboCtrl event handler have a go first.
639 wxComboCtrlBase
* combo
= m_combo
;
641 wxKeyEvent
redirectedEvent(event
);
642 redirectedEvent
.SetId(combo
->GetId());
643 redirectedEvent
.SetEventObject(combo
);
645 if ( !combo
->GetEventHandler()->ProcessEvent(redirectedEvent
) )
647 // Don't let TAB through to the text ctrl - looks ugly
648 if ( event
.GetKeyCode() != WXK_TAB
)
653 void wxComboBoxExtraInputHandler::OnFocus(wxFocusEvent
& event
)
655 // FIXME: This code does run when control is clicked,
656 // yet on Windows it doesn't select all the text.
657 if ( event
.GetEventType() == wxEVT_SET_FOCUS
&&
658 !(m_combo
->GetInternalFlags() & wxCC_NO_TEXT_AUTO_SELECT
) )
660 if ( m_combo
->GetTextCtrl() )
661 m_combo
->GetTextCtrl()->SelectAll();
663 m_combo
->SetSelection(-1,-1);
666 // Send focus indication to parent.
667 // NB: This is needed for cases where the textctrl gets focus
668 // instead of its parent. While this may trigger multiple
669 // wxEVT_SET_FOCUSes (since m_text->SetFocus is called
670 // from combo's focus event handler), they should be quite
672 wxFocusEvent
evt2(event
.GetEventType(),m_combo
->GetId());
673 evt2
.SetEventObject(m_combo
);
674 m_combo
->GetEventHandler()->ProcessEvent(evt2
);
681 // This is pushed to the event handler queue of the control in popup.
684 class wxComboPopupEvtHandler
: public wxEvtHandler
688 wxComboPopupEvtHandler( wxComboCtrlBase
* combo
)
692 m_beenInside
= false;
694 // Let's make it so that the popup control will not receive mouse
695 // events until mouse left button has been up.
696 m_blockEventsToPopup
= true;
698 virtual ~wxComboPopupEvtHandler() { }
700 void OnMouseEvent( wxMouseEvent
& event
);
702 // Called from wxComboCtrlBase::OnPopupDismiss
703 void OnPopupDismiss()
705 m_beenInside
= false;
706 m_blockEventsToPopup
= true;
710 wxComboCtrlBase
* m_combo
;
713 bool m_blockEventsToPopup
;
716 DECLARE_EVENT_TABLE()
720 BEGIN_EVENT_TABLE(wxComboPopupEvtHandler
, wxEvtHandler
)
721 EVT_MOUSE_EVENTS(wxComboPopupEvtHandler::OnMouseEvent
)
725 void wxComboPopupEvtHandler::OnMouseEvent( wxMouseEvent
& event
)
727 wxPoint pt
= event
.GetPosition();
728 wxSize sz
= m_combo
->GetPopupControl()->GetControl()->GetClientSize();
729 int evtType
= event
.GetEventType();
730 bool isInside
= pt
.x
>= 0 && pt
.y
>= 0 && pt
.x
< sz
.x
&& pt
.y
< sz
.y
;
731 bool relayToButton
= false;
735 if ( !isInside
|| !m_combo
->IsPopupShown() )
737 // Mouse is outside the popup or popup is not actually shown (yet)
739 if ( evtType
== wxEVT_MOTION
||
740 evtType
== wxEVT_LEFT_DOWN
||
741 evtType
== wxEVT_LEFT_UP
||
742 evtType
== wxEVT_RIGHT_DOWN
)
744 // Block motion and click events outside the popup
750 // Mouse is inside the popup, which is fully shown
754 // Do not let the popup control respond to mouse events until
755 // mouse press used to display the popup has been lifted. This
756 // is important for users with slower mouse fingers or mouse
757 // drivers. Note that we have some redundancy here, just in
758 // case the popup is some native control that does not emit all
759 // mouse event types.
760 if ( evtType
== wxEVT_MOTION
)
762 if ( m_blockEventsToPopup
)
764 if ( event
.LeftIsDown() )
767 m_blockEventsToPopup
= false;
770 else if ( evtType
== wxEVT_LEFT_DOWN
)
772 if ( m_blockEventsToPopup
)
773 m_blockEventsToPopup
= false;
775 else if ( evtType
== wxEVT_LEFT_UP
)
777 if ( m_blockEventsToPopup
)
779 // On first left up, stop blocking mouse events (but still
781 m_blockEventsToPopup
= false;
784 // Also, this button press was (probably) used to display
785 // the popup, so relay it back to the drop-down button
786 // (which supposedly originated it). This is necessary to
787 // refresh it properly.
788 relayToButton
= true;
791 else if ( m_blockEventsToPopup
)
798 // Some mouse events to popup that happen outside it, before cursor
799 // has been inside the popup, need to be ignored by it but relayed to
802 if ( evtType
== wxEVT_LEFT_UP
)
804 if ( !m_combo
->IsPopupShown() )
807 relayToButton
= true;
809 else if ( !isInside
&& !m_beenInside
)
811 // Popup is shown but the cursor is not inside, nor it has been
812 relayToButton
= true;
818 wxWindow
* btn
= m_combo
->GetButton();
820 btn
->GetEventHandler()->ProcessEvent(event
);
822 // Bypass the event handling mechanism. Using it would be
823 // confusing for the platform-specific wxComboCtrl
825 m_combo
->HandleButtonMouseEvent(event
, 0);
829 // ----------------------------------------------------------------------------
830 // wxComboCtrlTextCtrl
831 // ----------------------------------------------------------------------------
833 class wxComboCtrlTextCtrl
: public wxTextCtrl
836 wxComboCtrlTextCtrl() : wxTextCtrl() { }
837 virtual ~wxComboCtrlTextCtrl() { }
839 virtual wxWindow
*GetMainWindowOfCompositeControl()
841 wxComboCtrl
* combo
= (wxComboCtrl
*) GetParent();
843 // Returning this instead of just 'parent' lets FindFocus work
844 // correctly even when parent control is a child of a composite
845 // generic control (as is case with wxGenericDatePickerCtrl).
846 return combo
->GetMainWindowOfCompositeControl();
850 // ----------------------------------------------------------------------------
852 // ----------------------------------------------------------------------------
855 BEGIN_EVENT_TABLE(wxComboCtrlBase
, wxControl
)
856 EVT_TEXT(wxID_ANY
,wxComboCtrlBase::OnTextCtrlEvent
)
857 EVT_SIZE(wxComboCtrlBase::OnSizeEvent
)
858 EVT_SET_FOCUS(wxComboCtrlBase::OnFocusEvent
)
859 EVT_KILL_FOCUS(wxComboCtrlBase::OnFocusEvent
)
860 EVT_IDLE(wxComboCtrlBase::OnIdleEvent
)
861 //EVT_BUTTON(wxID_ANY,wxComboCtrlBase::OnButtonClickEvent)
862 EVT_KEY_DOWN(wxComboCtrlBase::OnKeyEvent
)
863 EVT_CHAR(wxComboCtrlBase::OnCharEvent
)
864 EVT_TEXT_ENTER(wxID_ANY
,wxComboCtrlBase::OnTextCtrlEvent
)
865 EVT_SYS_COLOUR_CHANGED(wxComboCtrlBase::OnSysColourChanged
)
869 IMPLEMENT_ABSTRACT_CLASS(wxComboCtrlBase
, wxControl
)
871 void wxComboCtrlBase::Init()
875 m_popupWinState
= Hidden
;
878 m_popupInterface
= NULL
;
880 m_popupEvtHandler
= NULL
;
881 m_textEvtHandler
= NULL
;
883 #if INSTALL_TOPLEV_HANDLER
884 m_toplevEvtHandler
= NULL
;
887 m_mainCtrlWnd
= this;
890 m_widthMinPopup
= -1;
892 m_widthCustomPaint
= 0;
893 m_widthCustomBorder
= 0;
897 m_blankButtonBg
= false;
899 m_popupWinType
= POPUPWIN_NONE
;
900 m_btnWid
= m_btnHei
= -1;
908 m_timeCanAcceptClick
= 0;
910 m_resetFocus
= false;
913 bool wxComboCtrlBase::Create(wxWindow
*parent
,
915 const wxString
& value
,
919 const wxValidator
& validator
,
920 const wxString
& name
)
922 if ( !wxControl::Create(parent
,
926 style
| wxWANTS_CHARS
,
931 m_valueString
= value
;
935 m_marginLeft
= GetNativeTextIndent();
937 m_iFlags
|= wxCC_IFLAG_CREATED
;
939 // If x and y indicate valid size, wxSizeEvent won't be
940 // emitted automatically, so we need to add artifical one.
941 if ( size
.x
> 0 && size
.y
> 0 )
943 wxSizeEvent
evt(size
,GetId());
944 GetEventHandler()->AddPendingEvent(evt
);
950 void wxComboCtrlBase::InstallInputHandlers()
954 m_textEvtHandler
= new wxComboBoxExtraInputHandler(this);
955 m_text
->PushEventHandler(m_textEvtHandler
);
960 wxComboCtrlBase::CreateTextCtrl(int style
, const wxValidator
& validator
)
962 if ( !(m_windowStyle
& wxCB_READONLY
) )
967 // wxTE_PROCESS_TAB is needed because on Windows, wxTAB_TRAVERSAL is
968 // not used by the wxPropertyGrid and therefore the tab is processed by
969 // looking at ancestors to see if they have wxTAB_TRAVERSAL. The
970 // navigation event is then sent to the wrong window.
971 style
|= wxTE_PROCESS_TAB
;
973 if ( HasFlag(wxTE_PROCESS_ENTER
) )
974 style
|= wxTE_PROCESS_ENTER
;
976 // Ignore EVT_TEXT generated by the constructor (but only
977 // if the event redirector already exists)
978 // NB: This must be " = 1" instead of "++";
979 if ( m_textEvtHandler
)
984 m_text
= new wxComboCtrlTextCtrl();
985 m_text
->Create(this, wxID_ANY
, m_valueString
,
986 wxDefaultPosition
, wxSize(10,-1),
988 m_text
->SetHint(m_hintText
);
992 void wxComboCtrlBase::OnThemeChange()
994 // Leave the default bg on the Mac so the area used by the focus ring will
995 // be the correct colour and themed brush. Instead we'll use
996 // wxSYS_COLOUR_WINDOW in the EVT_PAINT handler as needed.
998 #if defined(__WXMSW__) || defined(__WXGTK__)
999 wxVisualAttributes vattrs
= wxComboBox::GetClassDefaultAttributes();
1001 wxVisualAttributes vattrs
;
1002 vattrs
.colFg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
1003 vattrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW
);
1006 // Only change the colours if application has not specified
1010 SetOwnForegroundColour(vattrs
.colFg
);
1015 SetOwnBackgroundColour(vattrs
.colBg
);
1018 #endif // !__WXMAC__
1021 wxComboCtrlBase::~wxComboCtrlBase()
1026 #if INSTALL_TOPLEV_HANDLER
1027 delete ((wxComboFrameEventHandler
*)m_toplevEvtHandler
);
1028 m_toplevEvtHandler
= NULL
;
1034 m_text
->RemoveEventHandler(m_textEvtHandler
);
1036 delete m_textEvtHandler
;
1040 // ----------------------------------------------------------------------------
1042 // ----------------------------------------------------------------------------
1044 // Recalculates button and textctrl areas
1045 void wxComboCtrlBase::CalculateAreas( int btnWidth
)
1047 wxSize sz
= GetClientSize();
1048 int customBorder
= m_widthCustomBorder
;
1049 int btnBorder
; // border for button only
1051 // check if button should really be outside the border: we'll do it it if
1052 // its platform default or bitmap+pushbutton background is used, but not if
1053 // there is vertical size adjustment or horizontal spacing.
1054 if ( ( (m_iFlags
& wxCC_BUTTON_OUTSIDE_BORDER
) ||
1055 (m_bmpNormal
.Ok() && m_blankButtonBg
) ) &&
1056 m_btnSpacingX
== 0 &&
1059 m_iFlags
|= wxCC_IFLAG_BUTTON_OUTSIDE
;
1062 else if ( (m_iFlags
& wxCC_BUTTON_COVERS_BORDER
) &&
1063 m_btnSpacingX
== 0 && !m_bmpNormal
.Ok() )
1065 m_iFlags
&= ~(wxCC_IFLAG_BUTTON_OUTSIDE
);
1070 m_iFlags
&= ~(wxCC_IFLAG_BUTTON_OUTSIDE
);
1071 btnBorder
= customBorder
;
1074 // Defaul indentation
1075 if ( m_marginLeft
< 0 )
1076 m_marginLeft
= GetNativeTextIndent();
1078 int butWidth
= btnWidth
;
1080 if ( butWidth
<= 0 )
1081 butWidth
= m_btnWidDefault
;
1083 m_btnWidDefault
= butWidth
;
1085 if ( butWidth
<= 0 )
1088 int butHeight
= sz
.y
- btnBorder
*2;
1090 // Adjust button width
1092 butWidth
= m_btnWid
;
1095 // Adjust button width to match aspect ratio
1096 // (but only if control is smaller than best size).
1097 int bestHeight
= GetBestSize().y
;
1098 int height
= GetSize().y
;
1100 if ( height
< bestHeight
)
1102 // Make very small buttons square, as it makes
1103 // them accommodate arrow image better and still
1106 butWidth
= (height
*butWidth
)/bestHeight
;
1108 butWidth
= butHeight
;
1112 // Adjust button height
1114 butHeight
= m_btnHei
;
1116 // Use size of normal bitmap if...
1119 // button width is set to default and blank button bg is not drawn
1120 if ( m_bmpNormal
.Ok() )
1122 int bmpReqWidth
= m_bmpNormal
.GetWidth();
1123 int bmpReqHeight
= m_bmpNormal
.GetHeight();
1125 // If drawing blank button background, we need to add some margin.
1126 if ( m_blankButtonBg
)
1128 bmpReqWidth
+= BMP_BUTTON_MARGIN
*2;
1129 bmpReqHeight
+= BMP_BUTTON_MARGIN
*2;
1132 if ( butWidth
< bmpReqWidth
|| ( m_btnWid
== 0 && !m_blankButtonBg
) )
1133 butWidth
= bmpReqWidth
;
1134 if ( butHeight
< bmpReqHeight
|| ( m_btnHei
== 0 && !m_blankButtonBg
) )
1135 butHeight
= bmpReqHeight
;
1137 // Need to fix height?
1138 if ( (sz
.y
-(customBorder
*2)) < butHeight
&& btnWidth
== 0 )
1140 int newY
= butHeight
+(customBorder
*2);
1141 SetClientSize(wxDefaultCoord
,newY
);
1142 if ( m_bmpNormal
.Ok() || m_btnArea
.width
!= butWidth
|| m_btnArea
.height
!= butHeight
)
1143 m_iFlags
|= wxCC_IFLAG_HAS_NONSTANDARD_BUTTON
;
1145 m_iFlags
&= ~wxCC_IFLAG_HAS_NONSTANDARD_BUTTON
;
1151 int butAreaWid
= butWidth
+ (m_btnSpacingX
*2);
1153 m_btnSize
.x
= butWidth
;
1154 m_btnSize
.y
= butHeight
;
1156 m_btnArea
.x
= ( m_btnSide
==wxRIGHT
? sz
.x
- butAreaWid
- btnBorder
: btnBorder
);
1157 m_btnArea
.y
= btnBorder
+ FOCUS_RING
;
1158 m_btnArea
.width
= butAreaWid
;
1159 m_btnArea
.height
= sz
.y
- ((btnBorder
+FOCUS_RING
)*2);
1161 m_tcArea
.x
= ( m_btnSide
==wxRIGHT
? 0 : butAreaWid
) + customBorder
+ FOCUS_RING
;
1162 m_tcArea
.y
= customBorder
+ FOCUS_RING
;
1163 m_tcArea
.width
= sz
.x
- butAreaWid
- (customBorder
*2) - (FOCUS_RING
*2);
1164 m_tcArea
.height
= sz
.y
- ((customBorder
+FOCUS_RING
)*2);
1169 ::wxMessageBox(wxString::Format(wxT("ButtonArea (%i,%i,%i,%i)\n"),m_btnArea.x,m_btnArea.y,m_btnArea.width,m_btnArea.height) +
1170 wxString::Format(wxT("TextCtrlArea (%i,%i,%i,%i)"),m_tcArea.x,m_tcArea.y,m_tcArea.width,m_tcArea.height));
1175 void wxComboCtrlBase::PositionTextCtrl( int textCtrlXAdjust
, int textCtrlYAdjust
)
1180 wxSize sz
= GetClientSize();
1182 int customBorder
= m_widthCustomBorder
;
1183 if ( (m_text
->GetWindowStyleFlag() & wxBORDER_MASK
) == wxNO_BORDER
)
1187 if ( !m_widthCustomPaint
)
1189 // No special custom paint area - we can use 0 left margin
1191 if ( m_text
->SetMargins(0) )
1192 textCtrlXAdjust
= 0;
1193 x
= m_tcArea
.x
+ m_marginLeft
+ textCtrlXAdjust
;
1197 // There is special custom paint area - it is better to
1198 // use some margin with the wxTextCtrl.
1199 m_text
->SetMargins(m_marginLeft
);
1200 x
= m_tcArea
.x
+ m_widthCustomPaint
+
1201 m_marginLeft
+ textCtrlXAdjust
;
1204 // Centre textctrl vertically, if needed
1205 #if !TEXTCTRL_TEXT_CENTERED
1206 int tcSizeY
= m_text
->GetBestSize().y
;
1207 int diff0
= sz
.y
- tcSizeY
;
1208 int y
= textCtrlYAdjust
+ (diff0
/2);
1210 wxUnusedVar(textCtrlYAdjust
);
1214 if ( y
< customBorder
)
1219 m_tcArea
.width
- m_tcArea
.x
- x
,
1222 // Make sure textctrl doesn't exceed the bottom custom border
1223 wxSize tsz
= m_text
->GetSize();
1224 int diff1
= (y
+ tsz
.y
) - (sz
.y
- customBorder
);
1227 tsz
.y
= tsz
.y
- diff1
- 1;
1228 m_text
->SetSize(tsz
);
1233 // If it has border, have textctrl fill the entire text field.
1234 m_text
->SetSize( m_tcArea
.x
+ m_widthCustomPaint
,
1236 m_tcArea
.width
- m_widthCustomPaint
,
1241 wxSize
wxComboCtrlBase::DoGetBestSize() const
1243 wxSize
sizeText(150,0);
1246 sizeText
= m_text
->GetBestSize();
1248 // TODO: Better method to calculate close-to-native control height.
1252 fhei
= (m_font
.GetPointSize()*2) + 5;
1253 else if ( wxNORMAL_FONT
->Ok() )
1254 fhei
= (wxNORMAL_FONT
->GetPointSize()*2) + 5;
1256 fhei
= sizeText
.y
+ 4;
1258 // Need to force height to accomodate bitmap?
1259 int btnSizeY
= m_btnSize
.y
;
1260 if ( m_bmpNormal
.Ok() && fhei
< btnSizeY
)
1263 // Control height doesn't depend on border
1266 int border = m_windowStyle & wxBORDER_MASK;
1267 if ( border == wxSIMPLE_BORDER )
1269 else if ( border == wxNO_BORDER )
1270 fhei += (m_widthCustomBorder*2);
1276 // Final adjustments
1282 // these are the numbers from the HIG:
1283 switch ( m_windowVariant
)
1285 case wxWINDOW_VARIANT_NORMAL
:
1289 case wxWINDOW_VARIANT_SMALL
:
1292 case wxWINDOW_VARIANT_MINI
:
1298 fhei
+= 2 * FOCUS_RING
;
1299 int width
= sizeText
.x
+ FOCUS_RING
+ COMBO_MARGIN
+ DEFAULT_DROPBUTTON_WIDTH
;
1301 wxSize
ret(width
, fhei
);
1306 void wxComboCtrlBase::OnSizeEvent( wxSizeEvent
& event
)
1311 // defined by actual wxComboCtrls
1317 // ----------------------------------------------------------------------------
1318 // standard operations
1319 // ----------------------------------------------------------------------------
1321 bool wxComboCtrlBase::Enable(bool enable
)
1323 if ( !wxControl::Enable(enable
) )
1327 m_btn
->Enable(enable
);
1329 m_text
->Enable(enable
);
1336 bool wxComboCtrlBase::Show(bool show
)
1338 if ( !wxControl::Show(show
) )
1350 bool wxComboCtrlBase::SetFont ( const wxFont
& font
)
1352 if ( !wxControl::SetFont(font
) )
1357 // Without hiding the wxTextCtrl there would be some
1358 // visible 'flicker' (at least on Windows XP).
1360 m_text
->SetFont(font
);
1369 void wxComboCtrlBase::DoSetToolTip(wxToolTip
*tooltip
)
1371 wxControl::DoSetToolTip(tooltip
);
1373 // Set tool tip for button and text box
1376 const wxString
&tip
= tooltip
->GetTip();
1377 if ( m_text
) m_text
->SetToolTip(tip
);
1378 if ( m_btn
) m_btn
->SetToolTip(tip
);
1382 if ( m_text
) m_text
->SetToolTip( NULL
);
1383 if ( m_btn
) m_btn
->SetToolTip( NULL
);
1386 #endif // wxUSE_TOOLTIPS
1388 #if wxUSE_VALIDATORS
1389 void wxComboCtrlBase::SetValidator(const wxValidator
& validator
)
1391 wxTextCtrl
* textCtrl
= GetTextCtrl();
1394 textCtrl
->SetValidator( validator
);
1396 wxControl::SetValidator( validator
);
1399 wxValidator
* wxComboCtrlBase::GetValidator()
1401 wxTextCtrl
* textCtrl
= GetTextCtrl();
1403 return textCtrl
? textCtrl
->GetValidator() : wxControl::GetValidator();
1405 #endif // wxUSE_VALIDATORS
1407 bool wxComboCtrlBase::SetForegroundColour(const wxColour
& colour
)
1409 if ( wxControl::SetForegroundColour(colour
) )
1412 m_text
->SetForegroundColour(colour
);
1418 bool wxComboCtrlBase::SetBackgroundColour(const wxColour
& colour
)
1420 if ( wxControl::SetBackgroundColour(colour
) )
1423 m_text
->SetBackgroundColour(colour
);
1428 // ----------------------------------------------------------------------------
1430 // ----------------------------------------------------------------------------
1432 #if (!defined(__WXMSW__)) || defined(__WXUNIVERSAL__)
1433 // prepare combo box background on area in a way typical on platform
1434 void wxComboCtrlBase::PrepareBackground( wxDC
& dc
, const wxRect
& rect
, int flags
) const
1436 wxSize sz
= GetClientSize();
1438 bool doDrawFocusRect
; // also selected
1440 // For smaller size control (and for disabled background) use less spacing
1444 if ( !(flags
& wxCONTROL_ISSUBMENU
) )
1447 isEnabled
= IsEnabled();
1448 doDrawFocusRect
= ShouldDrawFocus() && !(m_iFlags
& wxCC_FULL_BUTTON
);
1450 // Windows-style: for smaller size control (and for disabled background) use less spacing
1451 focusSpacingX
= isEnabled
? 2 : 1;
1452 focusSpacingY
= sz
.y
> (GetCharHeight()+2) && isEnabled
? 2 : 1;
1456 // Drawing a list item
1457 isEnabled
= true; // they are never disabled
1458 doDrawFocusRect
= (flags
& wxCONTROL_SELECTED
) != 0;
1464 // Set the background sub-rectangle for selection, disabled etc
1465 wxRect
selRect(rect
);
1466 selRect
.y
+= focusSpacingY
;
1467 selRect
.height
-= (focusSpacingY
*2);
1471 if ( !(flags
& wxCONTROL_ISSUBMENU
) )
1472 wcp
+= m_widthCustomPaint
;
1474 selRect
.x
+= wcp
+ focusSpacingX
;
1475 selRect
.width
-= wcp
+ (focusSpacingX
*2);
1480 bool doDrawSelRect
= true;
1482 // Determine foreground colour
1485 if ( doDrawFocusRect
)
1487 fgCol
= wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT
);
1489 else if ( m_hasFgCol
)
1491 // Honour the custom foreground colour
1492 fgCol
= GetForegroundColour();
1496 fgCol
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
1501 fgCol
= wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT
);
1504 // Determine background colour
1507 if ( doDrawFocusRect
)
1509 bgCol
= wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT
);
1511 else if ( m_hasBgCol
)
1513 // Honour the custom background colour
1514 bgCol
= GetBackgroundColour();
1518 #ifndef __WXMAC__ // see note in OnThemeChange
1519 doDrawSelRect
= false;
1520 bgCol
= GetBackgroundColour();
1522 bgCol
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW
);
1528 #ifndef __WXMAC__ // see note in OnThemeChange
1529 bgCol
= GetBackgroundColour();
1531 bgCol
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW
);
1535 dc
.SetTextForeground( fgCol
);
1536 dc
.SetBrush( bgCol
);
1537 if ( doDrawSelRect
)
1540 dc
.DrawRectangle( selRect
);
1543 // Don't clip exactly to the selection rectangle so we can draw
1544 // to the non-selected area in front of it.
1545 wxRect
clipRect(rect
.x
,rect
.y
,
1546 (selRect
.x
+selRect
.width
)-rect
.x
,rect
.height
);
1547 dc
.SetClippingRegion(clipRect
);
1550 // Save the library size a bit for platforms that re-implement this.
1551 void wxComboCtrlBase::PrepareBackground( wxDC
&, const wxRect
&, int ) const
1556 void wxComboCtrlBase::DrawButton( wxDC
& dc
, const wxRect
& rect
, int flags
)
1558 int drawState
= m_btnState
;
1560 if ( (m_iFlags
& wxCC_BUTTON_STAYS_DOWN
) &&
1561 GetPopupWindowState() >= Animating
)
1562 drawState
|= wxCONTROL_PRESSED
;
1564 wxRect
drawRect(rect
.x
+m_btnSpacingX
,
1565 rect
.y
+((rect
.height
-m_btnSize
.y
)/2),
1569 // Make sure area is not larger than the control
1570 if ( drawRect
.y
< rect
.y
)
1571 drawRect
.y
= rect
.y
;
1572 if ( drawRect
.height
> rect
.height
)
1573 drawRect
.height
= rect
.height
;
1575 bool enabled
= IsEnabled();
1578 drawState
|= wxCONTROL_DISABLED
;
1580 if ( !m_bmpNormal
.Ok() )
1582 if ( flags
& Button_BitmapOnly
)
1585 // Need to clear button background even if m_btn is present
1586 if ( flags
& Button_PaintBackground
)
1590 if ( m_iFlags
& wxCC_IFLAG_BUTTON_OUTSIDE
)
1591 bgCol
= GetParent()->GetBackgroundColour();
1593 bgCol
= GetBackgroundColour();
1597 dc
.DrawRectangle(rect
);
1600 // Draw standard button
1601 wxRendererNative::Get().DrawComboBoxDropButton(this,
1613 pBmp
= &m_bmpDisabled
;
1614 else if ( m_btnState
& wxCONTROL_PRESSED
)
1615 pBmp
= &m_bmpPressed
;
1616 else if ( m_btnState
& wxCONTROL_CURRENT
)
1619 pBmp
= &m_bmpNormal
;
1621 if ( m_blankButtonBg
)
1623 // If using blank button background, we need to clear its background
1624 // with button face colour instead of colour for rest of the control.
1625 if ( flags
& Button_PaintBackground
)
1627 wxColour bgCol
= GetParent()->GetBackgroundColour(); //wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE);
1628 //wxColour bgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
1631 dc
.DrawRectangle(rect
);
1634 if ( !(flags
& Button_BitmapOnly
) )
1636 wxRendererNative::Get().DrawPushButton(this,
1645 // Need to clear button background even if m_btn is present
1646 // (assume non-button background was cleared just before this call so brushes are good)
1647 if ( flags
& Button_PaintBackground
)
1648 dc
.DrawRectangle(rect
);
1651 // Draw bitmap centered in drawRect
1652 dc
.DrawBitmap(*pBmp
,
1653 drawRect
.x
+ (drawRect
.width
-pBmp
->GetWidth())/2,
1654 drawRect
.y
+ (drawRect
.height
-pBmp
->GetHeight())/2,
1659 void wxComboCtrlBase::RecalcAndRefresh()
1663 wxSizeEvent
evt(GetSize(),GetId());
1664 GetEventHandler()->ProcessEvent(evt
);
1669 // ----------------------------------------------------------------------------
1670 // miscellaneous event handlers
1671 // ----------------------------------------------------------------------------
1673 void wxComboCtrlBase::OnTextCtrlEvent(wxCommandEvent
& event
)
1675 if ( event
.GetEventType() == wxEVT_COMMAND_TEXT_UPDATED
)
1677 if ( m_ignoreEvtText
> 0 )
1684 // Change event id, object and string before relaying it forward
1685 event
.SetId(GetId());
1686 wxString s
= event
.GetString();
1687 event
.SetEventObject(this);
1692 // call if cursor is on button area or mouse is captured for the button
1693 bool wxComboCtrlBase::HandleButtonMouseEvent( wxMouseEvent
& event
,
1696 int type
= event
.GetEventType();
1698 if ( type
== wxEVT_MOTION
)
1700 if ( (flags
& wxCC_MF_ON_BUTTON
) &&
1701 IsPopupWindowState(Hidden
) )
1703 if ( !(m_btnState
& wxCONTROL_CURRENT
) )
1705 // Mouse hover begins
1706 m_btnState
|= wxCONTROL_CURRENT
;
1707 if ( HasCapture() ) // Retain pressed state.
1708 m_btnState
|= wxCONTROL_PRESSED
;
1712 else if ( (m_btnState
& wxCONTROL_CURRENT
) )
1715 m_btnState
&= ~(wxCONTROL_CURRENT
|wxCONTROL_PRESSED
);
1719 else if ( type
== wxEVT_LEFT_DOWN
|| type
== wxEVT_LEFT_DCLICK
)
1721 if ( flags
& (wxCC_MF_ON_CLICK_AREA
|wxCC_MF_ON_BUTTON
) )
1723 m_btnState
|= wxCONTROL_PRESSED
;
1726 if ( !(m_iFlags
& wxCC_POPUP_ON_MOUSE_UP
) )
1729 // If showing popup now, do not capture mouse or there will be interference
1733 else if ( type
== wxEVT_LEFT_UP
)
1736 // Only accept event if mouse was left-press was previously accepted
1740 if ( m_btnState
& wxCONTROL_PRESSED
)
1742 // If mouse was inside, fire the click event.
1743 if ( m_iFlags
& wxCC_POPUP_ON_MOUSE_UP
)
1745 if ( flags
& (wxCC_MF_ON_CLICK_AREA
|wxCC_MF_ON_BUTTON
) )
1749 m_btnState
&= ~(wxCONTROL_PRESSED
);
1753 else if ( type
== wxEVT_LEAVE_WINDOW
)
1755 if ( m_btnState
& (wxCONTROL_CURRENT
|wxCONTROL_PRESSED
) )
1757 m_btnState
&= ~(wxCONTROL_CURRENT
);
1760 if ( IsPopupWindowState(Hidden
) )
1762 m_btnState
&= ~(wxCONTROL_PRESSED
);
1770 // Never have 'hot' state when popup is being shown
1771 // (this is mostly needed because of the animation).
1772 if ( !IsPopupWindowState(Hidden
) )
1773 m_btnState
&= ~wxCONTROL_CURRENT
;
1778 // returns true if event was consumed or filtered
1779 bool wxComboCtrlBase::PreprocessMouseEvent( wxMouseEvent
& event
,
1780 int WXUNUSED(flags
) )
1782 wxLongLong t
= ::wxGetLocalTimeMillis();
1783 int evtType
= event
.GetEventType();
1785 #if USES_WXPOPUPWINDOW || USES_GENERICTLW
1786 if ( m_popupWinType
!= POPUPWIN_WXPOPUPTRANSIENTWINDOW
)
1788 if ( IsPopupWindowState(Visible
) &&
1789 ( evtType
== wxEVT_LEFT_DOWN
|| evtType
== wxEVT_RIGHT_DOWN
) )
1797 // Filter out clicks on button immediately after popup dismiss
1798 if ( evtType
== wxEVT_LEFT_DOWN
&& t
< m_timeCanAcceptClick
)
1800 event
.SetEventType(0);
1807 void wxComboCtrlBase::HandleNormalMouseEvent( wxMouseEvent
& event
)
1809 int evtType
= event
.GetEventType();
1811 if ( (evtType
== wxEVT_LEFT_DOWN
|| evtType
== wxEVT_LEFT_DCLICK
) &&
1812 (m_windowStyle
& wxCB_READONLY
) )
1814 if ( GetPopupWindowState() >= Animating
)
1816 #if USES_WXPOPUPWINDOW
1817 // Click here always hides the popup.
1818 if ( m_popupWinType
== POPUPWIN_WXPOPUPWINDOW
)
1824 if ( !(m_windowStyle
& wxCC_SPECIAL_DCLICK
) )
1826 // In read-only mode, clicking the text is the
1827 // same as clicking the button.
1830 else if ( /*evtType == wxEVT_LEFT_UP || */evtType
== wxEVT_LEFT_DCLICK
)
1832 //if ( m_popupInterface->CycleValue() )
1834 if ( m_popupInterface
)
1835 m_popupInterface
->OnComboDoubleClick();
1839 else if ( evtType
== wxEVT_MOUSEWHEEL
)
1841 if ( IsPopupShown() )
1843 // relay (some) mouse events to the popup
1844 m_popup
->GetEventHandler()->ProcessEvent(event
);
1846 else if ( event
.GetWheelAxis() == 0 &&
1847 event
.GetWheelRotation() != 0 &&
1848 event
.GetModifiers() == 0 )
1850 // Translate mousewheel actions into key up/down. This is
1851 // the simplest way of getting native behaviour: scrolling the
1852 // wheel moves selection up/down by one item.
1853 wxKeyEvent
kevent(wxEVT_KEY_DOWN
);
1854 kevent
.m_keyCode
= event
.GetWheelRotation() > 0
1857 GetEventHandler()->ProcessEvent(kevent
);
1870 void wxComboCtrlBase::OnKeyEvent(wxKeyEvent
& event
)
1872 if ( IsPopupShown() )
1874 // pass it to the popped up control
1875 GetPopupControl()->GetControl()->GetEventHandler()->ProcessEvent(event
);
1879 wxWindow
* mainCtrl
= GetMainWindowOfCompositeControl();
1881 if ( mainCtrl
->GetParent()->HasFlag(wxTAB_TRAVERSAL
) )
1883 if ( mainCtrl
->HandleAsNavigationKey(event
) )
1887 if ( IsKeyPopupToggle(event
) )
1893 int comboStyle
= GetWindowStyle();
1894 wxComboPopup
* popupInterface
= GetPopupControl();
1896 if ( !popupInterface
)
1902 int keycode
= event
.GetKeyCode();
1904 if ( (comboStyle
& wxCB_READONLY
) ||
1905 (keycode
!= WXK_RIGHT
&& keycode
!= WXK_LEFT
) )
1907 popupInterface
->OnComboKeyEvent(event
);
1914 void wxComboCtrlBase::OnCharEvent(wxKeyEvent
& event
)
1916 if ( IsPopupShown() )
1918 // pass it to the popped up control
1919 GetPopupControl()->GetControl()->GetEventHandler()->ProcessEvent(event
);
1923 wxComboPopup
* popupInterface
= GetPopupControl();
1924 if ( popupInterface
)
1926 popupInterface
->OnComboCharEvent(event
);
1935 void wxComboCtrlBase::OnFocusEvent( wxFocusEvent
& event
)
1937 if ( event
.GetEventType() == wxEVT_SET_FOCUS
)
1939 wxWindow
* tc
= GetTextCtrl();
1940 if ( tc
&& tc
!= DoFindFocus() )
1949 void wxComboCtrlBase::OnIdleEvent( wxIdleEvent
& WXUNUSED(event
) )
1953 m_resetFocus
= false;
1954 wxWindow
* tc
= GetTextCtrl();
1960 void wxComboCtrlBase::OnSysColourChanged(wxSysColourChangedEvent
& WXUNUSED(event
))
1963 // left margin may also have changed
1964 if ( !(m_iFlags
& wxCC_IFLAG_LEFT_MARGIN_SET
) )
1965 m_marginLeft
= GetNativeTextIndent();
1969 // ----------------------------------------------------------------------------
1971 // ----------------------------------------------------------------------------
1973 // Create popup window and the child control
1974 void wxComboCtrlBase::CreatePopup()
1976 wxComboPopup
* popupInterface
= m_popupInterface
;
1981 #ifdef wxComboPopupWindowBase2
1982 if ( m_iFlags
& wxCC_IFLAG_USE_ALT_POPUP
)
1984 #if !USES_GENERICTLW
1985 m_winPopup
= new wxComboPopupWindowBase2( this, wxNO_BORDER
);
1987 int tlwFlags
= wxNO_BORDER
;
1988 #ifdef wxCC_GENERIC_TLW_IS_FRAME
1989 tlwFlags
|= wxFRAME_NO_TASKBAR
;
1992 #ifdef wxCC_GENERIC_TLW_IS_NONOWNEDWINDOW
1993 m_winPopup
= new wxComboPopupWindowBase2( this, wxID_ANY
,
1994 wxPoint(-21,-21), wxSize(20, 20),
1997 m_winPopup
= new wxComboPopupWindowBase2( this, wxID_ANY
, wxEmptyString
,
1998 wxPoint(-21,-21), wxSize(20, 20),
2002 m_popupWinType
= SECONDARY_POPUP_TYPE
;
2005 #endif // wxComboPopupWindowBase2
2007 m_winPopup
= new wxComboPopupWindow( this, wxNO_BORDER
);
2008 m_popupWinType
= PRIMARY_POPUP_TYPE
;
2010 m_popupWinEvtHandler
= new wxComboPopupWindowEvtHandler(this);
2011 m_winPopup
->PushEventHandler(m_popupWinEvtHandler
);
2014 popupInterface
->Create(m_winPopup
);
2015 m_popup
= popup
= popupInterface
->GetControl();
2017 m_popupEvtHandler
= new wxComboPopupEvtHandler(this);
2018 popup
->PushEventHandler( m_popupEvtHandler
);
2020 // This may be helpful on some platforms
2021 // (eg. it bypasses a wxGTK popupwindow bug where
2022 // window is not initially hidden when it should be)
2025 popupInterface
->m_iFlags
|= wxCP_IFLAG_CREATED
;
2028 // Destroy popup window and the child control
2029 void wxComboCtrlBase::DestroyPopup()
2034 m_popup
->RemoveEventHandler(m_popupEvtHandler
);
2036 delete m_popupEvtHandler
;
2038 delete m_popupInterface
;
2042 m_winPopup
->RemoveEventHandler(m_popupWinEvtHandler
);
2043 delete m_popupWinEvtHandler
;
2044 m_popupWinEvtHandler
= NULL
;
2045 m_winPopup
->Destroy();
2048 m_popupEvtHandler
= NULL
;
2049 m_popupInterface
= NULL
;
2054 void wxComboCtrlBase::DoSetPopupControl(wxComboPopup
* iface
)
2056 wxCHECK_RET( iface
, wxT("no popup interface set for wxComboCtrl") );
2060 iface
->InitBase(this);
2063 m_popupInterface
= iface
;
2065 if ( !iface
->LazyCreate() )
2074 // This must be done after creation
2075 if ( m_valueString
.length() )
2077 iface
->SetStringValue(m_valueString
);
2082 // Ensures there is atleast the default popup
2083 void wxComboCtrlBase::EnsurePopupControl()
2085 if ( !m_popupInterface
)
2086 SetPopupControl(NULL
);
2089 void wxComboCtrlBase::OnButtonClick()
2091 // Derived classes can override this method for totally custom
2093 if ( !IsPopupWindowState(Visible
) )
2095 wxCommandEvent
event(wxEVT_COMMAND_COMBOBOX_DROPDOWN
, GetId());
2096 event
.SetEventObject(this);
2097 HandleWindowEvent(event
);
2107 void wxComboCtrlBase::ShowPopup()
2109 EnsurePopupControl();
2110 wxCHECK_RET( !IsPopupWindowState(Visible
), wxT("popup window already shown") );
2112 if ( IsPopupWindowState(Animating
) )
2117 // Space above and below
2123 wxSize ctrlSz
= GetSize();
2125 screenHeight
= wxSystemSettings::GetMetric( wxSYS_SCREEN_Y
);
2126 scrPos
= GetParent()->ClientToScreen(GetPosition());
2128 spaceAbove
= scrPos
.y
;
2129 spaceBelow
= screenHeight
- spaceAbove
- ctrlSz
.y
;
2131 maxHeightPopup
= spaceBelow
;
2132 if ( spaceAbove
> spaceBelow
)
2133 maxHeightPopup
= spaceAbove
;
2136 int widthPopup
= ctrlSz
.x
+ m_extLeft
+ m_extRight
;
2138 if ( widthPopup
< m_widthMinPopup
)
2139 widthPopup
= m_widthMinPopup
;
2141 wxWindow
* winPopup
= m_winPopup
;
2144 // Need to disable tab traversal of parent
2146 // NB: This is to fix a bug in wxMSW. In theory it could also be fixed
2147 // by, for instance, adding check to window.cpp:wxWindowMSW::MSWProcessMessage
2148 // that if transient popup is open, then tab traversal is to be ignored.
2149 // However, I think this code would still be needed for cases where
2150 // transient popup doesn't work yet (wxWinCE?).
2151 wxWindow
* mainCtrl
= GetMainWindowOfCompositeControl();
2152 wxWindow
* parent
= mainCtrl
->GetParent();
2153 int parentFlags
= parent
->GetWindowStyle();
2154 if ( parentFlags
& wxTAB_TRAVERSAL
)
2156 parent
->SetWindowStyle( parentFlags
& ~(wxTAB_TRAVERSAL
) );
2157 m_iFlags
|= wxCC_IFLAG_PARENT_TAB_TRAVERSAL
;
2163 winPopup
= m_winPopup
;
2173 wxASSERT( !m_popup
|| m_popup
== popup
); // Consistency check.
2175 wxSize adjustedSize
= m_popupInterface
->GetAdjustedSize(widthPopup
,
2176 m_heightPopup
<=0?DEFAULT_POPUP_HEIGHT
:m_heightPopup
,
2179 popup
->SetSize(adjustedSize
);
2181 m_popupInterface
->OnPopup();
2184 // Reposition and resize popup window
2187 wxSize szp
= popup
->GetSize();
2190 int popupY
= scrPos
.y
+ ctrlSz
.y
;
2192 // Default anchor is wxLEFT
2193 int anchorSide
= m_anchorSide
;
2195 anchorSide
= wxLEFT
;
2197 int rightX
= scrPos
.x
+ ctrlSz
.x
+ m_extRight
- szp
.x
;
2198 int leftX
= scrPos
.x
- m_extLeft
;
2200 if ( wxTheApp
->GetLayoutDirection() == wxLayout_RightToLeft
)
2203 int screenWidth
= wxSystemSettings::GetMetric( wxSYS_SCREEN_X
);
2205 // If there is not enough horizontal space, anchor on the other side.
2206 // If there is no space even then, place the popup at x 0.
2207 if ( anchorSide
== wxRIGHT
)
2211 if ( (leftX
+szp
.x
) < screenWidth
)
2212 anchorSide
= wxLEFT
;
2219 if ( (leftX
+szp
.x
) >= screenWidth
)
2222 anchorSide
= wxRIGHT
;
2228 // Select x coordinate according to the anchor side
2229 if ( anchorSide
== wxRIGHT
)
2231 else if ( anchorSide
== wxLEFT
)
2236 int showFlags
= CanDeferShow
;
2238 if ( spaceBelow
< szp
.y
)
2240 popupY
= scrPos
.y
- szp
.y
;
2241 showFlags
|= ShowAbove
;
2244 #if INSTALL_TOPLEV_HANDLER
2245 // Put top level window event handler into place
2246 if ( m_popupWinType
== POPUPWIN_WXPOPUPWINDOW
)
2248 if ( !m_toplevEvtHandler
)
2249 m_toplevEvtHandler
= new wxComboFrameEventHandler(this);
2251 wxWindow
* toplev
= ::wxGetTopLevelParent( this );
2253 ((wxComboFrameEventHandler
*)m_toplevEvtHandler
)->OnPopup();
2254 toplev
->PushEventHandler( m_toplevEvtHandler
);
2258 // Set string selection (must be this way instead of SetStringSelection)
2261 if ( !(m_iFlags
& wxCC_NO_TEXT_AUTO_SELECT
) )
2262 m_text
->SelectAll();
2264 m_popupInterface
->SetStringValue( m_text
->GetValue() );
2268 // This is neede since focus/selection indication may change when popup is shown
2272 // This must be after SetStringValue
2273 m_popupWinState
= Animating
;
2275 wxRect
popupWinRect( popupX
, popupY
, szp
.x
, szp
.y
);
2278 if ( (m_iFlags
& wxCC_IFLAG_DISABLE_POPUP_ANIM
) ||
2279 AnimateShow( popupWinRect
, showFlags
) )
2281 DoShowPopup( popupWinRect
, showFlags
);
2285 bool wxComboCtrlBase::AnimateShow( const wxRect
& WXUNUSED(rect
), int WXUNUSED(flags
) )
2290 void wxComboCtrlBase::DoShowPopup( const wxRect
& rect
, int WXUNUSED(flags
) )
2292 wxWindow
* winPopup
= m_winPopup
;
2294 if ( IsPopupWindowState(Animating
) )
2296 // Make sure the popup window is shown in the right position.
2297 // Should not matter even if animation already did this.
2299 // Some platforms (GTK) may like SetSize and Move to be separate
2300 // (though the bug was probably fixed).
2301 winPopup
->SetSize( rect
);
2303 #if USES_WXPOPUPTRANSIENTWINDOW
2304 if ( m_popupWinType
== POPUPWIN_WXPOPUPTRANSIENTWINDOW
)
2305 ((wxPopupTransientWindow
*)winPopup
)->Popup(m_popup
);
2310 m_popupWinState
= Visible
;
2312 // If popup window was a generic top-level window, or the
2313 // wxPopupWindow implemenation on this platform is classified as
2314 // perfect, then we should be able to safely set focus to the popup
2316 if ( IsPopupWinTypePerfect(m_popupWinType
) )
2317 m_popup
->SetFocus();
2319 else if ( IsPopupWindowState(Hidden
) )
2321 // Animation was aborted
2323 wxASSERT( !winPopup
->IsShown() );
2325 m_popupWinState
= Hidden
;
2331 void wxComboCtrlBase::OnPopupDismiss(bool generateEvent
)
2333 // Just in case, avoid double dismiss
2334 if ( IsPopupWindowState(Hidden
) )
2337 // This must be set before focus - otherwise there will be recursive
2338 // OnPopupDismisses.
2339 m_popupWinState
= Hidden
;
2342 m_winPopup
->Disable();
2344 // Inform popup control itself
2345 m_popupInterface
->OnDismiss();
2347 if ( m_popupEvtHandler
)
2348 ((wxComboPopupEvtHandler
*)m_popupEvtHandler
)->OnPopupDismiss();
2350 #if INSTALL_TOPLEV_HANDLER
2351 // Remove top level window event handler
2352 if ( m_toplevEvtHandler
)
2354 wxWindow
* toplev
= ::wxGetTopLevelParent( this );
2356 toplev
->RemoveEventHandler( m_toplevEvtHandler
);
2360 m_timeCanAcceptClick
= ::wxGetLocalTimeMillis();
2362 if ( m_popupWinType
== POPUPWIN_WXPOPUPTRANSIENTWINDOW
)
2363 m_timeCanAcceptClick
+= 150;
2365 // If cursor not on dropdown button, then clear its state
2366 // (technically not required by all ports, but do it for all just in case)
2367 if ( !m_btnArea
.Contains(ScreenToClient(::wxGetMousePosition())) )
2370 // Return parent's tab traversal flag.
2371 // See ShowPopup for notes.
2372 if ( m_iFlags
& wxCC_IFLAG_PARENT_TAB_TRAVERSAL
)
2374 wxWindow
* parent
= GetParent();
2375 parent
->SetWindowStyle( parent
->GetWindowStyle() | wxTAB_TRAVERSAL
);
2376 m_iFlags
&= ~(wxCC_IFLAG_PARENT_TAB_TRAVERSAL
);
2379 // refresh control (necessary even if m_text)
2384 if ( generateEvent
)
2386 wxCommandEvent
event(wxEVT_COMMAND_COMBOBOX_CLOSEUP
, GetId());
2387 event
.SetEventObject(this);
2388 HandleWindowEvent(event
);
2392 void wxComboCtrlBase::HidePopup(bool generateEvent
)
2394 // Should be able to call this without popup interface
2395 if ( IsPopupWindowState(Hidden
) )
2398 // transfer value and show it in textctrl, if any
2399 if ( !IsPopupWindowState(Animating
) )
2400 SetValue( m_popupInterface
->GetStringValue() );
2404 OnPopupDismiss(generateEvent
);
2407 // ----------------------------------------------------------------------------
2408 // customization methods
2409 // ----------------------------------------------------------------------------
2411 void wxComboCtrlBase::SetButtonPosition( int width
, int height
,
2412 int side
, int spacingX
)
2417 m_btnSpacingX
= spacingX
;
2419 if ( width
> 0 || height
> 0 || spacingX
)
2420 m_iFlags
|= wxCC_IFLAG_HAS_NONSTANDARD_BUTTON
;
2425 wxSize
wxComboCtrlBase::GetButtonSize()
2427 if ( m_btnSize
.x
> 0 )
2430 wxSize
retSize(m_btnWid
,m_btnHei
);
2432 // Need to call CalculateAreas now if button size is
2433 // is not explicitly specified.
2434 if ( retSize
.x
<= 0 || retSize
.y
<= 0)
2438 retSize
= m_btnSize
;
2444 void wxComboCtrlBase::SetButtonBitmaps( const wxBitmap
& bmpNormal
,
2446 const wxBitmap
& bmpPressed
,
2447 const wxBitmap
& bmpHover
,
2448 const wxBitmap
& bmpDisabled
)
2450 m_bmpNormal
= bmpNormal
;
2451 m_blankButtonBg
= blankButtonBg
;
2453 if ( bmpPressed
.Ok() )
2454 m_bmpPressed
= bmpPressed
;
2456 m_bmpPressed
= bmpNormal
;
2458 if ( bmpHover
.Ok() )
2459 m_bmpHover
= bmpHover
;
2461 m_bmpHover
= bmpNormal
;
2463 if ( bmpDisabled
.Ok() )
2464 m_bmpDisabled
= bmpDisabled
;
2466 m_bmpDisabled
= bmpNormal
;
2471 void wxComboCtrlBase::SetCustomPaintWidth( int width
)
2475 // move textctrl accordingly
2476 wxRect r
= m_text
->GetRect();
2477 int inc
= width
- m_widthCustomPaint
;
2480 m_text
->SetSize( r
);
2483 m_widthCustomPaint
= width
;
2488 bool wxComboCtrlBase::DoSetMargins(const wxPoint
& margins
)
2490 // For general sanity's sake, we ignore top margin. Instead
2491 // we will always try to center the text vertically.
2494 if ( margins
.x
!= -1 )
2496 m_marginLeft
= margins
.x
;
2497 m_iFlags
|= wxCC_IFLAG_LEFT_MARGIN_SET
;
2501 m_marginLeft
= GetNativeTextIndent();
2502 m_iFlags
&= ~(wxCC_IFLAG_LEFT_MARGIN_SET
);
2505 if ( margins
.y
!= -1 )
2515 wxPoint
wxComboCtrlBase::DoGetMargins() const
2517 return wxPoint(m_marginLeft
, -1);
2520 #if WXWIN_COMPATIBILITY_2_8
2521 void wxComboCtrlBase::SetTextIndent( int indent
)
2525 m_marginLeft
= GetNativeTextIndent();
2526 m_iFlags
&= ~(wxCC_IFLAG_LEFT_MARGIN_SET
);
2530 m_marginLeft
= indent
;
2531 m_iFlags
|= wxCC_IFLAG_LEFT_MARGIN_SET
;
2537 wxCoord
wxComboCtrlBase::GetTextIndent() const
2539 return m_marginLeft
;
2543 wxCoord
wxComboCtrlBase::GetNativeTextIndent() const
2545 return DEFAULT_TEXT_INDENT
;
2548 // ----------------------------------------------------------------------------
2549 // methods forwarded to wxTextCtrl
2550 // ----------------------------------------------------------------------------
2552 wxString
wxComboCtrlBase::GetValue() const
2555 return m_text
->GetValue();
2556 return m_valueString
;
2559 void wxComboCtrlBase::SetValueWithEvent(const wxString
& value
, bool withEvent
)
2566 m_text
->SetValue(value
);
2568 if ( !(m_iFlags
& wxCC_NO_TEXT_AUTO_SELECT
) )
2569 m_text
->SelectAll();
2572 // Since wxComboPopup may want to paint the combo as well, we need
2573 // to set the string value here (as well as sometimes in ShowPopup).
2574 if ( m_valueString
!= value
)
2576 m_valueString
= value
;
2578 EnsurePopupControl();
2580 if (m_popupInterface
)
2581 m_popupInterface
->SetStringValue(value
);
2587 void wxComboCtrlBase::SetValue(const wxString
& value
)
2589 SetValueWithEvent(value
, false);
2592 // In this SetValue variant wxComboPopup::SetStringValue is not called
2593 void wxComboCtrlBase::SetText(const wxString
& value
)
2595 // Unlike in SetValue(), this must be called here or
2596 // the behaviour will no be consistent in readonlys.
2597 EnsurePopupControl();
2599 m_valueString
= value
;
2604 m_text
->SetValue( value
);
2610 void wxComboCtrlBase::Copy()
2616 void wxComboCtrlBase::Cut()
2622 void wxComboCtrlBase::Paste()
2628 void wxComboCtrlBase::SetInsertionPoint(long pos
)
2631 m_text
->SetInsertionPoint(pos
);
2634 void wxComboCtrlBase::SetInsertionPointEnd()
2637 m_text
->SetInsertionPointEnd();
2640 long wxComboCtrlBase::GetInsertionPoint() const
2643 return m_text
->GetInsertionPoint();
2648 long wxComboCtrlBase::GetLastPosition() const
2651 return m_text
->GetLastPosition();
2656 void wxComboCtrlBase::Replace(long from
, long to
, const wxString
& value
)
2659 m_text
->Replace(from
, to
, value
);
2662 void wxComboCtrlBase::Remove(long from
, long to
)
2665 m_text
->Remove(from
, to
);
2668 void wxComboCtrlBase::SetSelection(long from
, long to
)
2671 m_text
->SetSelection(from
, to
);
2674 void wxComboCtrlBase::Undo()
2680 bool wxComboCtrlBase::SetHint(const wxString
& hint
)
2685 res
= m_text
->SetHint(hint
);
2690 wxString
wxComboCtrlBase::GetHint() const
2695 #endif // wxUSE_COMBOCTRL