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;
909 m_timeCanAcceptClick
= 0;
911 m_resetFocus
= false;
914 bool wxComboCtrlBase::Create(wxWindow
*parent
,
916 const wxString
& value
,
920 const wxValidator
& validator
,
921 const wxString
& name
)
923 if ( !wxControl::Create(parent
,
927 style
| wxWANTS_CHARS
,
932 m_valueString
= value
;
936 m_marginLeft
= GetNativeTextIndent();
938 m_iFlags
|= wxCC_IFLAG_CREATED
;
940 // If x and y indicate valid size, wxSizeEvent won't be
941 // emitted automatically, so we need to add artifical one.
942 if ( size
.x
> 0 && size
.y
> 0 )
944 wxSizeEvent
evt(size
,GetId());
945 GetEventHandler()->AddPendingEvent(evt
);
951 void wxComboCtrlBase::InstallInputHandlers()
955 m_textEvtHandler
= new wxComboBoxExtraInputHandler(this);
956 m_text
->PushEventHandler(m_textEvtHandler
);
961 wxComboCtrlBase::CreateTextCtrl(int style
, const wxValidator
& validator
)
963 if ( !(m_windowStyle
& wxCB_READONLY
) )
968 // wxTE_PROCESS_TAB is needed because on Windows, wxTAB_TRAVERSAL is
969 // not used by the wxPropertyGrid and therefore the tab is processed by
970 // looking at ancestors to see if they have wxTAB_TRAVERSAL. The
971 // navigation event is then sent to the wrong window.
972 style
|= wxTE_PROCESS_TAB
| m_textCtrlStyle
;
974 if ( HasFlag(wxTE_PROCESS_ENTER
) )
975 style
|= wxTE_PROCESS_ENTER
;
977 // Ignore EVT_TEXT generated by the constructor (but only
978 // if the event redirector already exists)
979 // NB: This must be " = 1" instead of "++";
980 if ( m_textEvtHandler
)
985 m_text
= new wxComboCtrlTextCtrl();
986 m_text
->Create(this, wxID_ANY
, m_valueString
,
987 wxDefaultPosition
, wxSize(10,-1),
989 m_text
->SetHint(m_hintText
);
993 void wxComboCtrlBase::OnThemeChange()
995 // Leave the default bg on the Mac so the area used by the focus ring will
996 // be the correct colour and themed brush. Instead we'll use
997 // wxSYS_COLOUR_WINDOW in the EVT_PAINT handler as needed.
999 #if defined(__WXMSW__) || defined(__WXGTK__)
1000 wxVisualAttributes vattrs
= wxComboBox::GetClassDefaultAttributes();
1002 wxVisualAttributes vattrs
;
1003 vattrs
.colFg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
1004 vattrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW
);
1007 // Only change the colours if application has not specified
1011 SetOwnForegroundColour(vattrs
.colFg
);
1016 SetOwnBackgroundColour(vattrs
.colBg
);
1019 #endif // !__WXMAC__
1022 wxComboCtrlBase::~wxComboCtrlBase()
1027 #if INSTALL_TOPLEV_HANDLER
1028 delete ((wxComboFrameEventHandler
*)m_toplevEvtHandler
);
1029 m_toplevEvtHandler
= NULL
;
1035 m_text
->RemoveEventHandler(m_textEvtHandler
);
1037 delete m_textEvtHandler
;
1041 // ----------------------------------------------------------------------------
1043 // ----------------------------------------------------------------------------
1045 // Recalculates button and textctrl areas
1046 void wxComboCtrlBase::CalculateAreas( int btnWidth
)
1048 wxSize sz
= GetClientSize();
1049 int customBorder
= m_widthCustomBorder
;
1050 int btnBorder
; // border for button only
1052 // check if button should really be outside the border: we'll do it it if
1053 // its platform default or bitmap+pushbutton background is used, but not if
1054 // there is vertical size adjustment or horizontal spacing.
1055 if ( ( (m_iFlags
& wxCC_BUTTON_OUTSIDE_BORDER
) ||
1056 (m_bmpNormal
.Ok() && m_blankButtonBg
) ) &&
1057 m_btnSpacingX
== 0 &&
1060 m_iFlags
|= wxCC_IFLAG_BUTTON_OUTSIDE
;
1063 else if ( (m_iFlags
& wxCC_BUTTON_COVERS_BORDER
) &&
1064 m_btnSpacingX
== 0 && !m_bmpNormal
.Ok() )
1066 m_iFlags
&= ~(wxCC_IFLAG_BUTTON_OUTSIDE
);
1071 m_iFlags
&= ~(wxCC_IFLAG_BUTTON_OUTSIDE
);
1072 btnBorder
= customBorder
;
1075 // Defaul indentation
1076 if ( m_marginLeft
< 0 )
1077 m_marginLeft
= GetNativeTextIndent();
1079 int butWidth
= btnWidth
;
1081 if ( butWidth
<= 0 )
1082 butWidth
= m_btnWidDefault
;
1084 m_btnWidDefault
= butWidth
;
1086 if ( butWidth
<= 0 )
1089 int butHeight
= sz
.y
- btnBorder
*2;
1091 // Adjust button width
1093 butWidth
= m_btnWid
;
1096 // Adjust button width to match aspect ratio
1097 // (but only if control is smaller than best size).
1098 int bestHeight
= GetBestSize().y
;
1099 int height
= GetSize().y
;
1101 if ( height
< bestHeight
)
1103 // Make very small buttons square, as it makes
1104 // them accommodate arrow image better and still
1107 butWidth
= (height
*butWidth
)/bestHeight
;
1109 butWidth
= butHeight
;
1113 // Adjust button height
1115 butHeight
= m_btnHei
;
1117 // Use size of normal bitmap if...
1120 // button width is set to default and blank button bg is not drawn
1121 if ( m_bmpNormal
.Ok() )
1123 int bmpReqWidth
= m_bmpNormal
.GetWidth();
1124 int bmpReqHeight
= m_bmpNormal
.GetHeight();
1126 // If drawing blank button background, we need to add some margin.
1127 if ( m_blankButtonBg
)
1129 bmpReqWidth
+= BMP_BUTTON_MARGIN
*2;
1130 bmpReqHeight
+= BMP_BUTTON_MARGIN
*2;
1133 if ( butWidth
< bmpReqWidth
|| ( m_btnWid
== 0 && !m_blankButtonBg
) )
1134 butWidth
= bmpReqWidth
;
1135 if ( butHeight
< bmpReqHeight
|| ( m_btnHei
== 0 && !m_blankButtonBg
) )
1136 butHeight
= bmpReqHeight
;
1138 // Need to fix height?
1139 if ( (sz
.y
-(customBorder
*2)) < butHeight
&& btnWidth
== 0 )
1141 int newY
= butHeight
+(customBorder
*2);
1142 SetClientSize(wxDefaultCoord
,newY
);
1143 if ( m_bmpNormal
.Ok() || m_btnArea
.width
!= butWidth
|| m_btnArea
.height
!= butHeight
)
1144 m_iFlags
|= wxCC_IFLAG_HAS_NONSTANDARD_BUTTON
;
1146 m_iFlags
&= ~wxCC_IFLAG_HAS_NONSTANDARD_BUTTON
;
1152 int butAreaWid
= butWidth
+ (m_btnSpacingX
*2);
1154 m_btnSize
.x
= butWidth
;
1155 m_btnSize
.y
= butHeight
;
1157 m_btnArea
.x
= ( m_btnSide
==wxRIGHT
? sz
.x
- butAreaWid
- btnBorder
: btnBorder
);
1158 m_btnArea
.y
= btnBorder
+ FOCUS_RING
;
1159 m_btnArea
.width
= butAreaWid
;
1160 m_btnArea
.height
= sz
.y
- ((btnBorder
+FOCUS_RING
)*2);
1162 m_tcArea
.x
= ( m_btnSide
==wxRIGHT
? 0 : butAreaWid
) + customBorder
+ FOCUS_RING
;
1163 m_tcArea
.y
= customBorder
+ FOCUS_RING
;
1164 m_tcArea
.width
= sz
.x
- butAreaWid
- (customBorder
*2) - (FOCUS_RING
*2);
1165 m_tcArea
.height
= sz
.y
- ((customBorder
+FOCUS_RING
)*2);
1170 ::wxMessageBox(wxString::Format(wxT("ButtonArea (%i,%i,%i,%i)\n"),m_btnArea.x,m_btnArea.y,m_btnArea.width,m_btnArea.height) +
1171 wxString::Format(wxT("TextCtrlArea (%i,%i,%i,%i)"),m_tcArea.x,m_tcArea.y,m_tcArea.width,m_tcArea.height));
1176 void wxComboCtrlBase::PositionTextCtrl( int textCtrlXAdjust
, int textCtrlYAdjust
)
1181 wxSize sz
= GetClientSize();
1183 int customBorder
= m_widthCustomBorder
;
1184 if ( (m_text
->GetWindowStyleFlag() & wxBORDER_MASK
) == wxNO_BORDER
)
1188 if ( !m_widthCustomPaint
)
1190 // No special custom paint area - we can use 0 left margin
1192 if ( m_text
->SetMargins(0) )
1193 textCtrlXAdjust
= 0;
1194 x
= m_tcArea
.x
+ m_marginLeft
+ textCtrlXAdjust
;
1198 // There is special custom paint area - it is better to
1199 // use some margin with the wxTextCtrl.
1200 m_text
->SetMargins(m_marginLeft
);
1201 x
= m_tcArea
.x
+ m_widthCustomPaint
+
1202 m_marginLeft
+ textCtrlXAdjust
;
1205 // Centre textctrl vertically, if needed
1206 #if !TEXTCTRL_TEXT_CENTERED
1207 int tcSizeY
= m_text
->GetBestSize().y
;
1208 int diff0
= sz
.y
- tcSizeY
;
1209 int y
= textCtrlYAdjust
+ (diff0
/2);
1211 wxUnusedVar(textCtrlYAdjust
);
1215 if ( y
< customBorder
)
1220 m_tcArea
.width
- m_tcArea
.x
- x
,
1223 // Make sure textctrl doesn't exceed the bottom custom border
1224 wxSize tsz
= m_text
->GetSize();
1225 int diff1
= (y
+ tsz
.y
) - (sz
.y
- customBorder
);
1228 tsz
.y
= tsz
.y
- diff1
- 1;
1229 m_text
->SetSize(tsz
);
1234 // If it has border, have textctrl fill the entire text field.
1235 m_text
->SetSize( m_tcArea
.x
+ m_widthCustomPaint
,
1237 m_tcArea
.width
- m_widthCustomPaint
,
1242 wxSize
wxComboCtrlBase::DoGetBestSize() const
1244 wxSize
sizeText(150,0);
1247 sizeText
= m_text
->GetBestSize();
1249 // TODO: Better method to calculate close-to-native control height.
1253 fhei
= (m_font
.GetPointSize()*2) + 5;
1254 else if ( wxNORMAL_FONT
->Ok() )
1255 fhei
= (wxNORMAL_FONT
->GetPointSize()*2) + 5;
1257 fhei
= sizeText
.y
+ 4;
1259 // Need to force height to accomodate bitmap?
1260 int btnSizeY
= m_btnSize
.y
;
1261 if ( m_bmpNormal
.Ok() && fhei
< btnSizeY
)
1264 // Control height doesn't depend on border
1267 int border = m_windowStyle & wxBORDER_MASK;
1268 if ( border == wxSIMPLE_BORDER )
1270 else if ( border == wxNO_BORDER )
1271 fhei += (m_widthCustomBorder*2);
1277 // Final adjustments
1283 // these are the numbers from the HIG:
1284 switch ( m_windowVariant
)
1286 case wxWINDOW_VARIANT_NORMAL
:
1290 case wxWINDOW_VARIANT_SMALL
:
1293 case wxWINDOW_VARIANT_MINI
:
1299 fhei
+= 2 * FOCUS_RING
;
1300 int width
= sizeText
.x
+ FOCUS_RING
+ COMBO_MARGIN
+ DEFAULT_DROPBUTTON_WIDTH
;
1302 wxSize
ret(width
, fhei
);
1307 void wxComboCtrlBase::OnSizeEvent( wxSizeEvent
& event
)
1312 // defined by actual wxComboCtrls
1318 // ----------------------------------------------------------------------------
1319 // standard operations
1320 // ----------------------------------------------------------------------------
1322 bool wxComboCtrlBase::Enable(bool enable
)
1324 if ( !wxControl::Enable(enable
) )
1328 m_btn
->Enable(enable
);
1330 m_text
->Enable(enable
);
1337 bool wxComboCtrlBase::Show(bool show
)
1339 if ( !wxControl::Show(show
) )
1351 bool wxComboCtrlBase::SetFont ( const wxFont
& font
)
1353 if ( !wxControl::SetFont(font
) )
1358 // Without hiding the wxTextCtrl there would be some
1359 // visible 'flicker' (at least on Windows XP).
1361 m_text
->SetFont(font
);
1370 void wxComboCtrlBase::DoSetToolTip(wxToolTip
*tooltip
)
1372 wxControl::DoSetToolTip(tooltip
);
1374 // Set tool tip for button and text box
1377 const wxString
&tip
= tooltip
->GetTip();
1378 if ( m_text
) m_text
->SetToolTip(tip
);
1379 if ( m_btn
) m_btn
->SetToolTip(tip
);
1383 if ( m_text
) m_text
->SetToolTip( NULL
);
1384 if ( m_btn
) m_btn
->SetToolTip( NULL
);
1387 #endif // wxUSE_TOOLTIPS
1389 #if wxUSE_VALIDATORS
1390 void wxComboCtrlBase::SetValidator(const wxValidator
& validator
)
1392 wxTextCtrl
* textCtrl
= GetTextCtrl();
1395 textCtrl
->SetValidator( validator
);
1397 wxControl::SetValidator( validator
);
1400 wxValidator
* wxComboCtrlBase::GetValidator()
1402 wxTextCtrl
* textCtrl
= GetTextCtrl();
1404 return textCtrl
? textCtrl
->GetValidator() : wxControl::GetValidator();
1406 #endif // wxUSE_VALIDATORS
1408 bool wxComboCtrlBase::SetForegroundColour(const wxColour
& colour
)
1410 if ( wxControl::SetForegroundColour(colour
) )
1413 m_text
->SetForegroundColour(colour
);
1419 bool wxComboCtrlBase::SetBackgroundColour(const wxColour
& colour
)
1421 if ( wxControl::SetBackgroundColour(colour
) )
1424 m_text
->SetBackgroundColour(colour
);
1429 // ----------------------------------------------------------------------------
1431 // ----------------------------------------------------------------------------
1433 #if (!defined(__WXMSW__)) || defined(__WXUNIVERSAL__)
1434 // prepare combo box background on area in a way typical on platform
1435 void wxComboCtrlBase::PrepareBackground( wxDC
& dc
, const wxRect
& rect
, int flags
) const
1437 wxSize sz
= GetClientSize();
1439 bool doDrawFocusRect
; // also selected
1441 // For smaller size control (and for disabled background) use less spacing
1445 if ( !(flags
& wxCONTROL_ISSUBMENU
) )
1448 isEnabled
= IsEnabled();
1449 doDrawFocusRect
= ShouldDrawFocus() && !(m_iFlags
& wxCC_FULL_BUTTON
);
1451 // Windows-style: for smaller size control (and for disabled background) use less spacing
1452 focusSpacingX
= isEnabled
? 2 : 1;
1453 focusSpacingY
= sz
.y
> (GetCharHeight()+2) && isEnabled
? 2 : 1;
1457 // Drawing a list item
1458 isEnabled
= true; // they are never disabled
1459 doDrawFocusRect
= (flags
& wxCONTROL_SELECTED
) != 0;
1465 // Set the background sub-rectangle for selection, disabled etc
1466 wxRect
selRect(rect
);
1467 selRect
.y
+= focusSpacingY
;
1468 selRect
.height
-= (focusSpacingY
*2);
1472 if ( !(flags
& wxCONTROL_ISSUBMENU
) )
1473 wcp
+= m_widthCustomPaint
;
1475 selRect
.x
+= wcp
+ focusSpacingX
;
1476 selRect
.width
-= wcp
+ (focusSpacingX
*2);
1481 bool doDrawSelRect
= true;
1483 // Determine foreground colour
1486 if ( doDrawFocusRect
)
1488 fgCol
= wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT
);
1490 else if ( m_hasFgCol
)
1492 // Honour the custom foreground colour
1493 fgCol
= GetForegroundColour();
1497 fgCol
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
1502 fgCol
= wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT
);
1505 // Determine background colour
1508 if ( doDrawFocusRect
)
1510 bgCol
= wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT
);
1512 else if ( m_hasBgCol
)
1514 // Honour the custom background colour
1515 bgCol
= GetBackgroundColour();
1519 #ifndef __WXMAC__ // see note in OnThemeChange
1520 doDrawSelRect
= false;
1521 bgCol
= GetBackgroundColour();
1523 bgCol
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW
);
1529 #ifndef __WXMAC__ // see note in OnThemeChange
1530 bgCol
= GetBackgroundColour();
1532 bgCol
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW
);
1536 dc
.SetTextForeground( fgCol
);
1537 dc
.SetBrush( bgCol
);
1538 if ( doDrawSelRect
)
1541 dc
.DrawRectangle( selRect
);
1544 // Don't clip exactly to the selection rectangle so we can draw
1545 // to the non-selected area in front of it.
1546 wxRect
clipRect(rect
.x
,rect
.y
,
1547 (selRect
.x
+selRect
.width
)-rect
.x
,rect
.height
);
1548 dc
.SetClippingRegion(clipRect
);
1551 // Save the library size a bit for platforms that re-implement this.
1552 void wxComboCtrlBase::PrepareBackground( wxDC
&, const wxRect
&, int ) const
1557 void wxComboCtrlBase::DrawButton( wxDC
& dc
, const wxRect
& rect
, int flags
)
1559 int drawState
= m_btnState
;
1561 if ( (m_iFlags
& wxCC_BUTTON_STAYS_DOWN
) &&
1562 GetPopupWindowState() >= Animating
)
1563 drawState
|= wxCONTROL_PRESSED
;
1565 wxRect
drawRect(rect
.x
+m_btnSpacingX
,
1566 rect
.y
+((rect
.height
-m_btnSize
.y
)/2),
1570 // Make sure area is not larger than the control
1571 if ( drawRect
.y
< rect
.y
)
1572 drawRect
.y
= rect
.y
;
1573 if ( drawRect
.height
> rect
.height
)
1574 drawRect
.height
= rect
.height
;
1576 bool enabled
= IsEnabled();
1579 drawState
|= wxCONTROL_DISABLED
;
1581 if ( !m_bmpNormal
.Ok() )
1583 if ( flags
& Button_BitmapOnly
)
1586 // Need to clear button background even if m_btn is present
1587 if ( flags
& Button_PaintBackground
)
1591 if ( m_iFlags
& wxCC_IFLAG_BUTTON_OUTSIDE
)
1592 bgCol
= GetParent()->GetBackgroundColour();
1594 bgCol
= GetBackgroundColour();
1598 dc
.DrawRectangle(rect
);
1601 // Draw standard button
1602 wxRendererNative::Get().DrawComboBoxDropButton(this,
1614 pBmp
= &m_bmpDisabled
;
1615 else if ( m_btnState
& wxCONTROL_PRESSED
)
1616 pBmp
= &m_bmpPressed
;
1617 else if ( m_btnState
& wxCONTROL_CURRENT
)
1620 pBmp
= &m_bmpNormal
;
1622 if ( m_blankButtonBg
)
1624 // If using blank button background, we need to clear its background
1625 // with button face colour instead of colour for rest of the control.
1626 if ( flags
& Button_PaintBackground
)
1628 wxColour bgCol
= GetParent()->GetBackgroundColour(); //wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE);
1629 //wxColour bgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
1632 dc
.DrawRectangle(rect
);
1635 if ( !(flags
& Button_BitmapOnly
) )
1637 wxRendererNative::Get().DrawPushButton(this,
1646 // Need to clear button background even if m_btn is present
1647 // (assume non-button background was cleared just before this call so brushes are good)
1648 if ( flags
& Button_PaintBackground
)
1649 dc
.DrawRectangle(rect
);
1652 // Draw bitmap centered in drawRect
1653 dc
.DrawBitmap(*pBmp
,
1654 drawRect
.x
+ (drawRect
.width
-pBmp
->GetWidth())/2,
1655 drawRect
.y
+ (drawRect
.height
-pBmp
->GetHeight())/2,
1660 void wxComboCtrlBase::RecalcAndRefresh()
1664 wxSizeEvent
evt(GetSize(),GetId());
1665 GetEventHandler()->ProcessEvent(evt
);
1670 // ----------------------------------------------------------------------------
1671 // miscellaneous event handlers
1672 // ----------------------------------------------------------------------------
1674 void wxComboCtrlBase::OnTextCtrlEvent(wxCommandEvent
& event
)
1676 if ( event
.GetEventType() == wxEVT_COMMAND_TEXT_UPDATED
)
1678 if ( m_ignoreEvtText
> 0 )
1685 // Change event id, object and string before relaying it forward
1686 event
.SetId(GetId());
1687 wxString s
= event
.GetString();
1688 event
.SetEventObject(this);
1693 // call if cursor is on button area or mouse is captured for the button
1694 bool wxComboCtrlBase::HandleButtonMouseEvent( wxMouseEvent
& event
,
1697 int type
= event
.GetEventType();
1699 if ( type
== wxEVT_MOTION
)
1701 if ( (flags
& wxCC_MF_ON_BUTTON
) &&
1702 IsPopupWindowState(Hidden
) )
1704 if ( !(m_btnState
& wxCONTROL_CURRENT
) )
1706 // Mouse hover begins
1707 m_btnState
|= wxCONTROL_CURRENT
;
1708 if ( HasCapture() ) // Retain pressed state.
1709 m_btnState
|= wxCONTROL_PRESSED
;
1713 else if ( (m_btnState
& wxCONTROL_CURRENT
) )
1716 m_btnState
&= ~(wxCONTROL_CURRENT
|wxCONTROL_PRESSED
);
1720 else if ( type
== wxEVT_LEFT_DOWN
|| type
== wxEVT_LEFT_DCLICK
)
1722 if ( flags
& (wxCC_MF_ON_CLICK_AREA
|wxCC_MF_ON_BUTTON
) )
1724 m_btnState
|= wxCONTROL_PRESSED
;
1727 if ( !(m_iFlags
& wxCC_POPUP_ON_MOUSE_UP
) )
1730 // If showing popup now, do not capture mouse or there will be interference
1734 else if ( type
== wxEVT_LEFT_UP
)
1737 // Only accept event if mouse was left-press was previously accepted
1741 if ( m_btnState
& wxCONTROL_PRESSED
)
1743 // If mouse was inside, fire the click event.
1744 if ( m_iFlags
& wxCC_POPUP_ON_MOUSE_UP
)
1746 if ( flags
& (wxCC_MF_ON_CLICK_AREA
|wxCC_MF_ON_BUTTON
) )
1750 m_btnState
&= ~(wxCONTROL_PRESSED
);
1754 else if ( type
== wxEVT_LEAVE_WINDOW
)
1756 if ( m_btnState
& (wxCONTROL_CURRENT
|wxCONTROL_PRESSED
) )
1758 m_btnState
&= ~(wxCONTROL_CURRENT
);
1761 if ( IsPopupWindowState(Hidden
) )
1763 m_btnState
&= ~(wxCONTROL_PRESSED
);
1771 // Never have 'hot' state when popup is being shown
1772 // (this is mostly needed because of the animation).
1773 if ( !IsPopupWindowState(Hidden
) )
1774 m_btnState
&= ~wxCONTROL_CURRENT
;
1779 // returns true if event was consumed or filtered
1780 bool wxComboCtrlBase::PreprocessMouseEvent( wxMouseEvent
& event
,
1781 int WXUNUSED(flags
) )
1783 wxLongLong t
= ::wxGetLocalTimeMillis();
1784 int evtType
= event
.GetEventType();
1786 #if USES_WXPOPUPWINDOW || USES_GENERICTLW
1787 if ( m_popupWinType
!= POPUPWIN_WXPOPUPTRANSIENTWINDOW
)
1789 if ( IsPopupWindowState(Visible
) &&
1790 ( evtType
== wxEVT_LEFT_DOWN
|| evtType
== wxEVT_RIGHT_DOWN
) )
1798 // Filter out clicks on button immediately after popup dismiss
1799 if ( evtType
== wxEVT_LEFT_DOWN
&& t
< m_timeCanAcceptClick
)
1801 event
.SetEventType(0);
1808 void wxComboCtrlBase::HandleNormalMouseEvent( wxMouseEvent
& event
)
1810 int evtType
= event
.GetEventType();
1812 if ( (evtType
== wxEVT_LEFT_DOWN
|| evtType
== wxEVT_LEFT_DCLICK
) &&
1813 (m_windowStyle
& wxCB_READONLY
) )
1815 if ( GetPopupWindowState() >= Animating
)
1817 #if USES_WXPOPUPWINDOW
1818 // Click here always hides the popup.
1819 if ( m_popupWinType
== POPUPWIN_WXPOPUPWINDOW
)
1825 if ( !(m_windowStyle
& wxCC_SPECIAL_DCLICK
) )
1827 // In read-only mode, clicking the text is the
1828 // same as clicking the button.
1831 else if ( /*evtType == wxEVT_LEFT_UP || */evtType
== wxEVT_LEFT_DCLICK
)
1833 //if ( m_popupInterface->CycleValue() )
1835 if ( m_popupInterface
)
1836 m_popupInterface
->OnComboDoubleClick();
1840 else if ( evtType
== wxEVT_MOUSEWHEEL
)
1842 if ( IsPopupShown() )
1844 // relay (some) mouse events to the popup
1845 m_popup
->GetEventHandler()->ProcessEvent(event
);
1847 else if ( event
.GetWheelAxis() == 0 &&
1848 event
.GetWheelRotation() != 0 &&
1849 event
.GetModifiers() == 0 )
1851 // Translate mousewheel actions into key up/down. This is
1852 // the simplest way of getting native behaviour: scrolling the
1853 // wheel moves selection up/down by one item.
1854 wxKeyEvent
kevent(wxEVT_KEY_DOWN
);
1855 kevent
.m_keyCode
= event
.GetWheelRotation() > 0
1858 GetEventHandler()->ProcessEvent(kevent
);
1871 void wxComboCtrlBase::OnKeyEvent(wxKeyEvent
& event
)
1873 if ( IsPopupShown() )
1875 // pass it to the popped up control
1876 GetPopupControl()->GetControl()->GetEventHandler()->ProcessEvent(event
);
1880 wxWindow
* mainCtrl
= GetMainWindowOfCompositeControl();
1882 if ( mainCtrl
->GetParent()->HasFlag(wxTAB_TRAVERSAL
) )
1884 if ( mainCtrl
->HandleAsNavigationKey(event
) )
1888 if ( IsKeyPopupToggle(event
) )
1894 int comboStyle
= GetWindowStyle();
1895 wxComboPopup
* popupInterface
= GetPopupControl();
1897 if ( !popupInterface
)
1903 int keycode
= event
.GetKeyCode();
1905 if ( (comboStyle
& wxCB_READONLY
) ||
1906 (keycode
!= WXK_RIGHT
&& keycode
!= WXK_LEFT
) )
1908 popupInterface
->OnComboKeyEvent(event
);
1915 void wxComboCtrlBase::OnCharEvent(wxKeyEvent
& event
)
1917 if ( IsPopupShown() )
1919 // pass it to the popped up control
1920 GetPopupControl()->GetControl()->GetEventHandler()->ProcessEvent(event
);
1924 wxComboPopup
* popupInterface
= GetPopupControl();
1925 if ( popupInterface
)
1927 popupInterface
->OnComboCharEvent(event
);
1936 void wxComboCtrlBase::OnFocusEvent( wxFocusEvent
& event
)
1938 if ( event
.GetEventType() == wxEVT_SET_FOCUS
)
1940 wxWindow
* tc
= GetTextCtrl();
1941 if ( tc
&& tc
!= DoFindFocus() )
1950 void wxComboCtrlBase::OnIdleEvent( wxIdleEvent
& WXUNUSED(event
) )
1954 m_resetFocus
= false;
1955 wxWindow
* tc
= GetTextCtrl();
1961 void wxComboCtrlBase::OnSysColourChanged(wxSysColourChangedEvent
& WXUNUSED(event
))
1964 // left margin may also have changed
1965 if ( !(m_iFlags
& wxCC_IFLAG_LEFT_MARGIN_SET
) )
1966 m_marginLeft
= GetNativeTextIndent();
1970 // ----------------------------------------------------------------------------
1972 // ----------------------------------------------------------------------------
1974 // Create popup window and the child control
1975 void wxComboCtrlBase::CreatePopup()
1977 wxComboPopup
* popupInterface
= m_popupInterface
;
1982 #ifdef wxComboPopupWindowBase2
1983 if ( m_iFlags
& wxCC_IFLAG_USE_ALT_POPUP
)
1985 #if !USES_GENERICTLW
1986 m_winPopup
= new wxComboPopupWindowBase2( this, wxNO_BORDER
);
1988 int tlwFlags
= wxNO_BORDER
;
1989 #ifdef wxCC_GENERIC_TLW_IS_FRAME
1990 tlwFlags
|= wxFRAME_NO_TASKBAR
;
1993 #ifdef wxCC_GENERIC_TLW_IS_NONOWNEDWINDOW
1994 m_winPopup
= new wxComboPopupWindowBase2( this, wxID_ANY
,
1995 wxPoint(-21,-21), wxSize(20, 20),
1998 m_winPopup
= new wxComboPopupWindowBase2( this, wxID_ANY
, wxEmptyString
,
1999 wxPoint(-21,-21), wxSize(20, 20),
2003 m_popupWinType
= SECONDARY_POPUP_TYPE
;
2006 #endif // wxComboPopupWindowBase2
2008 m_winPopup
= new wxComboPopupWindow( this, wxNO_BORDER
);
2009 m_popupWinType
= PRIMARY_POPUP_TYPE
;
2011 m_popupWinEvtHandler
= new wxComboPopupWindowEvtHandler(this);
2012 m_winPopup
->PushEventHandler(m_popupWinEvtHandler
);
2015 popupInterface
->Create(m_winPopup
);
2016 m_popup
= popup
= popupInterface
->GetControl();
2018 m_popupEvtHandler
= new wxComboPopupEvtHandler(this);
2019 popup
->PushEventHandler( m_popupEvtHandler
);
2021 // This may be helpful on some platforms
2022 // (eg. it bypasses a wxGTK popupwindow bug where
2023 // window is not initially hidden when it should be)
2026 popupInterface
->m_iFlags
|= wxCP_IFLAG_CREATED
;
2029 // Destroy popup window and the child control
2030 void wxComboCtrlBase::DestroyPopup()
2035 m_popup
->RemoveEventHandler(m_popupEvtHandler
);
2037 wxDELETE(m_popupEvtHandler
);
2039 wxDELETE(m_popupInterface
);
2043 m_winPopup
->RemoveEventHandler(m_popupWinEvtHandler
);
2044 wxDELETE(m_popupWinEvtHandler
);
2045 m_winPopup
->Destroy();
2052 void wxComboCtrlBase::DoSetPopupControl(wxComboPopup
* iface
)
2054 wxCHECK_RET( iface
, wxT("no popup interface set for wxComboCtrl") );
2058 iface
->InitBase(this);
2061 m_popupInterface
= iface
;
2063 if ( !iface
->LazyCreate() )
2072 // This must be done after creation
2073 if ( m_valueString
.length() )
2075 iface
->SetStringValue(m_valueString
);
2080 // Ensures there is atleast the default popup
2081 void wxComboCtrlBase::EnsurePopupControl()
2083 if ( !m_popupInterface
)
2084 SetPopupControl(NULL
);
2087 void wxComboCtrlBase::OnButtonClick()
2089 // Derived classes can override this method for totally custom
2091 if ( !IsPopupWindowState(Visible
) )
2093 wxCommandEvent
event(wxEVT_COMMAND_COMBOBOX_DROPDOWN
, GetId());
2094 event
.SetEventObject(this);
2095 HandleWindowEvent(event
);
2105 void wxComboCtrlBase::ShowPopup()
2107 EnsurePopupControl();
2108 wxCHECK_RET( !IsPopupWindowState(Visible
), wxT("popup window already shown") );
2110 if ( IsPopupWindowState(Animating
) )
2115 // Space above and below
2121 wxSize ctrlSz
= GetSize();
2123 screenHeight
= wxSystemSettings::GetMetric( wxSYS_SCREEN_Y
);
2124 scrPos
= GetParent()->ClientToScreen(GetPosition());
2126 spaceAbove
= scrPos
.y
;
2127 spaceBelow
= screenHeight
- spaceAbove
- ctrlSz
.y
;
2129 maxHeightPopup
= spaceBelow
;
2130 if ( spaceAbove
> spaceBelow
)
2131 maxHeightPopup
= spaceAbove
;
2134 int widthPopup
= ctrlSz
.x
+ m_extLeft
+ m_extRight
;
2136 if ( widthPopup
< m_widthMinPopup
)
2137 widthPopup
= m_widthMinPopup
;
2139 wxWindow
* winPopup
= m_winPopup
;
2142 // Need to disable tab traversal of parent
2144 // NB: This is to fix a bug in wxMSW. In theory it could also be fixed
2145 // by, for instance, adding check to window.cpp:wxWindowMSW::MSWProcessMessage
2146 // that if transient popup is open, then tab traversal is to be ignored.
2147 // However, I think this code would still be needed for cases where
2148 // transient popup doesn't work yet (wxWinCE?).
2149 wxWindow
* mainCtrl
= GetMainWindowOfCompositeControl();
2150 wxWindow
* parent
= mainCtrl
->GetParent();
2151 int parentFlags
= parent
->GetWindowStyle();
2152 if ( parentFlags
& wxTAB_TRAVERSAL
)
2154 parent
->SetWindowStyle( parentFlags
& ~(wxTAB_TRAVERSAL
) );
2155 m_iFlags
|= wxCC_IFLAG_PARENT_TAB_TRAVERSAL
;
2161 winPopup
= m_winPopup
;
2171 wxASSERT( !m_popup
|| m_popup
== popup
); // Consistency check.
2173 wxSize adjustedSize
= m_popupInterface
->GetAdjustedSize(widthPopup
,
2174 m_heightPopup
<=0?DEFAULT_POPUP_HEIGHT
:m_heightPopup
,
2177 popup
->SetSize(adjustedSize
);
2179 m_popupInterface
->OnPopup();
2182 // Reposition and resize popup window
2185 wxSize szp
= popup
->GetSize();
2188 int popupY
= scrPos
.y
+ ctrlSz
.y
;
2190 // Default anchor is wxLEFT
2191 int anchorSide
= m_anchorSide
;
2193 anchorSide
= wxLEFT
;
2195 int rightX
= scrPos
.x
+ ctrlSz
.x
+ m_extRight
- szp
.x
;
2196 int leftX
= scrPos
.x
- m_extLeft
;
2198 if ( wxTheApp
->GetLayoutDirection() == wxLayout_RightToLeft
)
2201 int screenWidth
= wxSystemSettings::GetMetric( wxSYS_SCREEN_X
);
2203 // If there is not enough horizontal space, anchor on the other side.
2204 // If there is no space even then, place the popup at x 0.
2205 if ( anchorSide
== wxRIGHT
)
2209 if ( (leftX
+szp
.x
) < screenWidth
)
2210 anchorSide
= wxLEFT
;
2217 if ( (leftX
+szp
.x
) >= screenWidth
)
2220 anchorSide
= wxRIGHT
;
2226 // Select x coordinate according to the anchor side
2227 if ( anchorSide
== wxRIGHT
)
2229 else if ( anchorSide
== wxLEFT
)
2234 int showFlags
= CanDeferShow
;
2236 if ( spaceBelow
< szp
.y
)
2238 popupY
= scrPos
.y
- szp
.y
;
2239 showFlags
|= ShowAbove
;
2242 #if INSTALL_TOPLEV_HANDLER
2243 // Put top level window event handler into place
2244 if ( m_popupWinType
== POPUPWIN_WXPOPUPWINDOW
)
2246 if ( !m_toplevEvtHandler
)
2247 m_toplevEvtHandler
= new wxComboFrameEventHandler(this);
2249 wxWindow
* toplev
= ::wxGetTopLevelParent( this );
2251 ((wxComboFrameEventHandler
*)m_toplevEvtHandler
)->OnPopup();
2252 toplev
->PushEventHandler( m_toplevEvtHandler
);
2256 // Set string selection (must be this way instead of SetStringSelection)
2259 if ( !(m_iFlags
& wxCC_NO_TEXT_AUTO_SELECT
) )
2260 m_text
->SelectAll();
2262 m_popupInterface
->SetStringValue( m_text
->GetValue() );
2266 // This is neede since focus/selection indication may change when popup is shown
2270 // This must be after SetStringValue
2271 m_popupWinState
= Animating
;
2273 wxRect
popupWinRect( popupX
, popupY
, szp
.x
, szp
.y
);
2276 if ( (m_iFlags
& wxCC_IFLAG_DISABLE_POPUP_ANIM
) ||
2277 AnimateShow( popupWinRect
, showFlags
) )
2279 DoShowPopup( popupWinRect
, showFlags
);
2283 bool wxComboCtrlBase::AnimateShow( const wxRect
& WXUNUSED(rect
), int WXUNUSED(flags
) )
2288 void wxComboCtrlBase::DoShowPopup( const wxRect
& rect
, int WXUNUSED(flags
) )
2290 wxWindow
* winPopup
= m_winPopup
;
2292 if ( IsPopupWindowState(Animating
) )
2294 // Make sure the popup window is shown in the right position.
2295 // Should not matter even if animation already did this.
2297 // Some platforms (GTK) may like SetSize and Move to be separate
2298 // (though the bug was probably fixed).
2299 winPopup
->SetSize( rect
);
2301 #if USES_WXPOPUPTRANSIENTWINDOW
2302 if ( m_popupWinType
== POPUPWIN_WXPOPUPTRANSIENTWINDOW
)
2303 ((wxPopupTransientWindow
*)winPopup
)->Popup(m_popup
);
2308 m_popupWinState
= Visible
;
2310 // If popup window was a generic top-level window, or the
2311 // wxPopupWindow implemenation on this platform is classified as
2312 // perfect, then we should be able to safely set focus to the popup
2314 if ( IsPopupWinTypePerfect(m_popupWinType
) )
2315 m_popup
->SetFocus();
2317 else if ( IsPopupWindowState(Hidden
) )
2319 // Animation was aborted
2321 wxASSERT( !winPopup
->IsShown() );
2323 m_popupWinState
= Hidden
;
2329 void wxComboCtrlBase::OnPopupDismiss(bool generateEvent
)
2331 // Just in case, avoid double dismiss
2332 if ( IsPopupWindowState(Hidden
) )
2335 // This must be set before focus - otherwise there will be recursive
2336 // OnPopupDismisses.
2337 m_popupWinState
= Hidden
;
2340 m_winPopup
->Disable();
2342 // Inform popup control itself
2343 m_popupInterface
->OnDismiss();
2345 if ( m_popupEvtHandler
)
2346 ((wxComboPopupEvtHandler
*)m_popupEvtHandler
)->OnPopupDismiss();
2348 #if INSTALL_TOPLEV_HANDLER
2349 // Remove top level window event handler
2350 if ( m_toplevEvtHandler
)
2352 wxWindow
* toplev
= ::wxGetTopLevelParent( this );
2354 toplev
->RemoveEventHandler( m_toplevEvtHandler
);
2358 m_timeCanAcceptClick
= ::wxGetLocalTimeMillis();
2360 if ( m_popupWinType
== POPUPWIN_WXPOPUPTRANSIENTWINDOW
)
2361 m_timeCanAcceptClick
+= 150;
2363 // If cursor not on dropdown button, then clear its state
2364 // (technically not required by all ports, but do it for all just in case)
2365 if ( !m_btnArea
.Contains(ScreenToClient(::wxGetMousePosition())) )
2368 // Return parent's tab traversal flag.
2369 // See ShowPopup for notes.
2370 if ( m_iFlags
& wxCC_IFLAG_PARENT_TAB_TRAVERSAL
)
2372 wxWindow
* parent
= GetParent();
2373 parent
->SetWindowStyle( parent
->GetWindowStyle() | wxTAB_TRAVERSAL
);
2374 m_iFlags
&= ~(wxCC_IFLAG_PARENT_TAB_TRAVERSAL
);
2377 // refresh control (necessary even if m_text)
2382 if ( generateEvent
)
2384 wxCommandEvent
event(wxEVT_COMMAND_COMBOBOX_CLOSEUP
, GetId());
2385 event
.SetEventObject(this);
2386 HandleWindowEvent(event
);
2390 void wxComboCtrlBase::HidePopup(bool generateEvent
)
2392 // Should be able to call this without popup interface
2393 if ( IsPopupWindowState(Hidden
) )
2396 // transfer value and show it in textctrl, if any
2397 if ( !IsPopupWindowState(Animating
) )
2398 SetValue( m_popupInterface
->GetStringValue() );
2402 OnPopupDismiss(generateEvent
);
2405 // ----------------------------------------------------------------------------
2406 // customization methods
2407 // ----------------------------------------------------------------------------
2409 void wxComboCtrlBase::SetButtonPosition( int width
, int height
,
2410 int side
, int spacingX
)
2415 m_btnSpacingX
= spacingX
;
2417 if ( width
> 0 || height
> 0 || spacingX
)
2418 m_iFlags
|= wxCC_IFLAG_HAS_NONSTANDARD_BUTTON
;
2423 wxSize
wxComboCtrlBase::GetButtonSize()
2425 if ( m_btnSize
.x
> 0 )
2428 wxSize
retSize(m_btnWid
,m_btnHei
);
2430 // Need to call CalculateAreas now if button size is
2431 // is not explicitly specified.
2432 if ( retSize
.x
<= 0 || retSize
.y
<= 0)
2436 retSize
= m_btnSize
;
2442 void wxComboCtrlBase::SetButtonBitmaps( const wxBitmap
& bmpNormal
,
2444 const wxBitmap
& bmpPressed
,
2445 const wxBitmap
& bmpHover
,
2446 const wxBitmap
& bmpDisabled
)
2448 m_bmpNormal
= bmpNormal
;
2449 m_blankButtonBg
= blankButtonBg
;
2451 if ( bmpPressed
.Ok() )
2452 m_bmpPressed
= bmpPressed
;
2454 m_bmpPressed
= bmpNormal
;
2456 if ( bmpHover
.Ok() )
2457 m_bmpHover
= bmpHover
;
2459 m_bmpHover
= bmpNormal
;
2461 if ( bmpDisabled
.Ok() )
2462 m_bmpDisabled
= bmpDisabled
;
2464 m_bmpDisabled
= bmpNormal
;
2469 void wxComboCtrlBase::SetCustomPaintWidth( int width
)
2473 // move textctrl accordingly
2474 wxRect r
= m_text
->GetRect();
2475 int inc
= width
- m_widthCustomPaint
;
2478 m_text
->SetSize( r
);
2481 m_widthCustomPaint
= width
;
2486 bool wxComboCtrlBase::DoSetMargins(const wxPoint
& margins
)
2488 // For general sanity's sake, we ignore top margin. Instead
2489 // we will always try to center the text vertically.
2492 if ( margins
.x
!= -1 )
2494 m_marginLeft
= margins
.x
;
2495 m_iFlags
|= wxCC_IFLAG_LEFT_MARGIN_SET
;
2499 m_marginLeft
= GetNativeTextIndent();
2500 m_iFlags
&= ~(wxCC_IFLAG_LEFT_MARGIN_SET
);
2503 if ( margins
.y
!= -1 )
2513 wxPoint
wxComboCtrlBase::DoGetMargins() const
2515 return wxPoint(m_marginLeft
, -1);
2518 #if WXWIN_COMPATIBILITY_2_8
2519 void wxComboCtrlBase::SetTextIndent( int indent
)
2523 m_marginLeft
= GetNativeTextIndent();
2524 m_iFlags
&= ~(wxCC_IFLAG_LEFT_MARGIN_SET
);
2528 m_marginLeft
= indent
;
2529 m_iFlags
|= wxCC_IFLAG_LEFT_MARGIN_SET
;
2535 wxCoord
wxComboCtrlBase::GetTextIndent() const
2537 return m_marginLeft
;
2541 wxCoord
wxComboCtrlBase::GetNativeTextIndent() const
2543 return DEFAULT_TEXT_INDENT
;
2546 void wxComboCtrlBase::SetTextCtrlStyle( int style
)
2548 m_textCtrlStyle
= style
;
2551 m_text
->SetWindowStyle(style
);
2554 // ----------------------------------------------------------------------------
2555 // methods forwarded to wxTextCtrl
2556 // ----------------------------------------------------------------------------
2558 wxString
wxComboCtrlBase::GetValue() const
2561 return m_text
->GetValue();
2562 return m_valueString
;
2565 void wxComboCtrlBase::SetValueWithEvent(const wxString
& value
, bool withEvent
)
2572 m_text
->SetValue(value
);
2574 if ( !(m_iFlags
& wxCC_NO_TEXT_AUTO_SELECT
) )
2575 m_text
->SelectAll();
2578 // Since wxComboPopup may want to paint the combo as well, we need
2579 // to set the string value here (as well as sometimes in ShowPopup).
2580 if ( m_valueString
!= value
)
2582 m_valueString
= value
;
2584 EnsurePopupControl();
2586 if (m_popupInterface
)
2587 m_popupInterface
->SetStringValue(value
);
2593 void wxComboCtrlBase::SetValue(const wxString
& value
)
2595 SetValueWithEvent(value
, false);
2598 // In this SetValue variant wxComboPopup::SetStringValue is not called
2599 void wxComboCtrlBase::SetText(const wxString
& value
)
2601 // Unlike in SetValue(), this must be called here or
2602 // the behaviour will no be consistent in readonlys.
2603 EnsurePopupControl();
2605 m_valueString
= value
;
2610 m_text
->SetValue( value
);
2616 void wxComboCtrlBase::Copy()
2622 void wxComboCtrlBase::Cut()
2628 void wxComboCtrlBase::Paste()
2634 void wxComboCtrlBase::SetInsertionPoint(long pos
)
2637 m_text
->SetInsertionPoint(pos
);
2640 void wxComboCtrlBase::SetInsertionPointEnd()
2643 m_text
->SetInsertionPointEnd();
2646 long wxComboCtrlBase::GetInsertionPoint() const
2649 return m_text
->GetInsertionPoint();
2654 long wxComboCtrlBase::GetLastPosition() const
2657 return m_text
->GetLastPosition();
2662 void wxComboCtrlBase::Replace(long from
, long to
, const wxString
& value
)
2665 m_text
->Replace(from
, to
, value
);
2668 void wxComboCtrlBase::Remove(long from
, long to
)
2671 m_text
->Remove(from
, to
);
2674 void wxComboCtrlBase::SetSelection(long from
, long to
)
2677 m_text
->SetSelection(from
, to
);
2680 void wxComboCtrlBase::Undo()
2686 bool wxComboCtrlBase::SetHint(const wxString
& hint
)
2691 res
= m_text
->SetHint(hint
);
2696 wxString
wxComboCtrlBase::GetHint() const
2701 #endif // wxUSE_COMBOCTRL