1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxComboControlBase
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"
26 #if wxUSE_COMBOCONTROL
31 #include "wx/combobox.h"
32 #include "wx/dcclient.h"
33 #include "wx/settings.h"
34 #include "wx/dialog.h"
37 #include "wx/dcbuffer.h"
38 #include "wx/tooltip.h"
46 // ----------------------------------------------------------------------------
48 // Milliseconds to wait for two mouse-ups after focus inorder
49 // to trigger a double-click.
50 #define DOUBLE_CLICK_CONVERSION_TRESHOLD 500
52 #define DEFAULT_DROPBUTTON_WIDTH 19
54 #define BMP_BUTTON_MARGIN 4
56 #define DEFAULT_POPUP_HEIGHT 200
58 #define DEFAULT_TEXT_INDENT 3
60 #define COMBO_MARGIN 2 // spacing right of wxTextCtrl
63 #if defined(__WXMSW__)
65 #define USE_TRANSIENT_POPUP 1 // Use wxPopupWindowTransient (preferred, if it works properly on platform)
67 //#undef wxUSE_POPUPWIN
68 //#define wxUSE_POPUPWIN 0
70 #elif defined(__WXGTK__)
72 #define USE_TRANSIENT_POPUP 1 // Use wxPopupWindowTransient (preferred, if it works properly on platform)
74 #elif defined(__WXMAC__)
76 #define USE_TRANSIENT_POPUP 0 // Use wxPopupWindowTransient (preferred, if it works properly on platform)
80 #define USE_TRANSIENT_POPUP 0 // Use wxPopupWindowTransient (preferred, if it works properly on platform)
85 // Popupwin is really only supported on wxMSW (not WINCE) and wxGTK, regardless
86 // what the wxUSE_POPUPWIN says.
87 // FIXME: Why isn't wxUSE_POPUPWIN reliable any longer? (it was in wxW2.6.2)
88 #if (!defined(__WXMSW__) && !defined(__WXGTK__)) || defined(__WXWINCE__)
90 #define wxUSE_POPUPWIN 0
95 #include "wx/popupwin.h"
97 #undef USE_TRANSIENT_POPUP
98 #define USE_TRANSIENT_POPUP 0
102 #if USE_TRANSIENT_POPUP
104 #define wxComboPopupWindowBase wxPopupTransientWindow
105 #define INSTALL_TOPLEV_HANDLER 0
109 #define wxComboPopupWindowBase wxPopupWindow
110 #define INSTALL_TOPLEV_HANDLER 1
114 #define wxComboPopupWindowBase wxDialog
115 #define INSTALL_TOPLEV_HANDLER 0 // Doesn't need since can monitor active event
123 // * wxComboPopupWindow for external use (ie. replace old wxUniv wxPopupComboWindow)
127 // ----------------------------------------------------------------------------
128 // wxComboFrameEventHandler takes care of hiding the popup when events happen
129 // in its top level parent.
130 // ----------------------------------------------------------------------------
132 #if INSTALL_TOPLEV_HANDLER
135 // This will no longer be necessary after wxTransientPopupWindow
136 // works well on all platforms.
139 class wxComboFrameEventHandler
: public wxEvtHandler
142 wxComboFrameEventHandler( wxComboControlBase
* pCb
);
143 ~wxComboFrameEventHandler();
147 void OnIdle( wxIdleEvent
& event
);
148 void OnMouseEvent( wxMouseEvent
& event
);
149 void OnActivate( wxActivateEvent
& event
);
150 void OnResize( wxSizeEvent
& event
);
151 void OnMove( wxMoveEvent
& event
);
152 void OnMenuEvent( wxMenuEvent
& event
);
153 void OnClose( wxCloseEvent
& event
);
156 wxWindow
* m_focusStart
;
157 wxComboControlBase
* m_combo
;
160 DECLARE_EVENT_TABLE()
163 BEGIN_EVENT_TABLE(wxComboFrameEventHandler
, wxEvtHandler
)
164 EVT_IDLE(wxComboFrameEventHandler::OnIdle
)
165 EVT_LEFT_DOWN(wxComboFrameEventHandler::OnMouseEvent
)
166 EVT_RIGHT_DOWN(wxComboFrameEventHandler::OnMouseEvent
)
167 EVT_SIZE(wxComboFrameEventHandler::OnResize
)
168 EVT_MOVE(wxComboFrameEventHandler::OnMove
)
169 EVT_MENU_HIGHLIGHT(wxID_ANY
,wxComboFrameEventHandler::OnMenuEvent
)
170 EVT_MENU_OPEN(wxComboFrameEventHandler::OnMenuEvent
)
171 EVT_ACTIVATE(wxComboFrameEventHandler::OnActivate
)
172 EVT_CLOSE(wxComboFrameEventHandler::OnClose
)
175 wxComboFrameEventHandler::wxComboFrameEventHandler( wxComboControlBase
* combo
)
181 wxComboFrameEventHandler::~wxComboFrameEventHandler()
185 void wxComboFrameEventHandler::OnPopup()
187 m_focusStart
= ::wxWindow::FindFocus();
190 void wxComboFrameEventHandler::OnIdle( wxIdleEvent
& event
)
192 wxWindow
* winFocused
= ::wxWindow::FindFocus();
194 wxWindow
* popup
= m_combo
->GetPopupControl();
195 wxWindow
* winpopup
= m_combo
->GetPopupWindow();
198 winFocused
!= m_focusStart
&&
199 winFocused
!= popup
&&
200 winFocused
->GetParent() != popup
&&
201 winFocused
!= winpopup
&&
202 winFocused
->GetParent() != winpopup
&&
203 winFocused
!= m_combo
&&
204 winFocused
!= m_combo
->GetButton() // GTK (atleast) requires this
207 m_combo
->HidePopup();
213 void wxComboFrameEventHandler::OnMenuEvent( wxMenuEvent
& event
)
215 m_combo
->HidePopup();
219 void wxComboFrameEventHandler::OnMouseEvent( wxMouseEvent
& event
)
221 m_combo
->HidePopup();
225 void wxComboFrameEventHandler::OnClose( wxCloseEvent
& event
)
227 m_combo
->HidePopup();
231 void wxComboFrameEventHandler::OnActivate( wxActivateEvent
& event
)
233 m_combo
->HidePopup();
237 void wxComboFrameEventHandler::OnResize( wxSizeEvent
& event
)
239 m_combo
->HidePopup();
243 void wxComboFrameEventHandler::OnMove( wxMoveEvent
& event
)
245 m_combo
->HidePopup();
249 #endif // INSTALL_TOPLEV_HANDLER
251 // ----------------------------------------------------------------------------
252 // wxComboPopupWindow is wxPopupWindow customized for
254 // ----------------------------------------------------------------------------
256 class wxComboPopupWindow
: public wxComboPopupWindowBase
260 wxComboPopupWindow( wxComboControlBase
*parent
, int style
= wxBORDER_NONE
);
262 #if USE_TRANSIENT_POPUP
263 virtual bool ProcessLeftDown(wxMouseEvent
& event
);
266 void OnKeyEvent(wxKeyEvent
& event
);
268 void OnMouseEvent( wxMouseEvent
& event
);
270 void OnActivate( wxActivateEvent
& event
);
275 #if USE_TRANSIENT_POPUP
276 virtual void OnDismiss();
280 DECLARE_EVENT_TABLE()
284 BEGIN_EVENT_TABLE(wxComboPopupWindow
, wxComboPopupWindowBase
)
285 EVT_MOUSE_EVENTS(wxComboPopupWindow::OnMouseEvent
)
287 EVT_ACTIVATE(wxComboPopupWindow::OnActivate
)
289 EVT_KEY_DOWN(wxComboPopupWindow::OnKeyEvent
)
290 EVT_KEY_UP(wxComboPopupWindow::OnKeyEvent
)
294 wxComboPopupWindow::wxComboPopupWindow( wxComboControlBase
*parent
,
297 : wxComboPopupWindowBase(parent
,style
)
299 : wxComboPopupWindowBase(parent
,
309 void wxComboPopupWindow::OnKeyEvent( wxKeyEvent
& event
)
311 // Relay keyboard event to the main child controls
312 // (just skipping may just cause the popup to close)
313 wxWindowList children
= GetChildren();
314 wxWindowList::iterator node
= children
.begin();
315 wxWindow
* child
= (wxWindow
*)*node
;
316 child
->AddPendingEvent(event
);
319 void wxComboPopupWindow::OnMouseEvent( wxMouseEvent
& event
)
325 void wxComboPopupWindow::OnActivate( wxActivateEvent
& event
)
327 if ( !event
.GetActive() )
329 // Tell combo control that we are dismissed.
330 wxComboControl
* combo
= (wxComboControl
*) GetParent();
332 wxASSERT( combo
->IsKindOf(CLASSINFO(wxComboControl
)) );
341 #if USE_TRANSIENT_POPUP
342 bool wxComboPopupWindow::ProcessLeftDown(wxMouseEvent
& event
)
344 return wxComboPopupWindowBase::ProcessLeftDown(event
);
348 #if USE_TRANSIENT_POPUP
349 // First thing that happens when a transient popup closes is that this method gets called.
350 void wxComboPopupWindow::OnDismiss()
352 wxComboControlBase
* combo
= (wxComboControlBase
*) GetParent();
353 wxASSERT_MSG( combo
->IsKindOf(CLASSINFO(wxComboControlBase
)),
354 wxT("parent might not be wxComboControl, but check IMPLEMENT_DYNAMIC_CLASS(2) macro for correctness") );
356 combo
->OnPopupDismiss();
360 // ----------------------------------------------------------------------------
363 // ----------------------------------------------------------------------------
365 wxComboPopup::~wxComboPopup()
369 void wxComboPopup::OnPopup()
373 void wxComboPopup::OnDismiss()
377 wxSize
wxComboPopup::GetAdjustedSize( int minWidth
,
379 int WXUNUSED(maxHeight
) )
381 return wxSize(minWidth
,prefHeight
);
384 void wxComboPopup::PaintComboControl( wxDC
& dc
, const wxRect
& rect
)
386 if ( m_combo
->GetWindowStyle() & wxCB_READONLY
) // ie. no textctrl
388 m_combo
->DrawFocusBackground(dc
,rect
,0);
390 dc
.DrawText( GetStringValue(),
391 rect
.x
+ m_combo
->GetTextIndent(),
392 (rect
.height
-dc
.GetCharHeight())/2 + m_combo
->m_widthCustomBorder
);
396 void wxComboPopup::OnComboKeyEvent( wxKeyEvent
& event
)
401 void wxComboPopup::OnComboDoubleClick()
405 void wxComboPopup::SetStringValue( const wxString
& WXUNUSED(value
) )
409 bool wxComboPopup::LazyCreate()
414 void wxComboPopup::Dismiss()
416 m_combo
->HidePopup();
419 // ----------------------------------------------------------------------------
421 // ----------------------------------------------------------------------------
424 // This is pushed to the event handler queue of either combo box
425 // or its textctrl (latter if not readonly combo).
427 class wxComboBoxExtraInputHandler
: public wxEvtHandler
431 wxComboBoxExtraInputHandler( wxComboControlBase
* combo
)
436 ~wxComboBoxExtraInputHandler() { }
437 void OnKey(wxKeyEvent
& event
);
438 void OnFocus(wxFocusEvent
& event
);
441 wxComboControlBase
* m_combo
;
444 DECLARE_EVENT_TABLE()
448 BEGIN_EVENT_TABLE(wxComboBoxExtraInputHandler
, wxEvtHandler
)
449 EVT_KEY_DOWN(wxComboBoxExtraInputHandler::OnKey
)
450 EVT_SET_FOCUS(wxComboBoxExtraInputHandler::OnFocus
)
454 void wxComboBoxExtraInputHandler::OnKey(wxKeyEvent
& event
)
456 int keycode
= event
.GetKeyCode();
458 if ( keycode
== WXK_TAB
)
460 wxNavigationKeyEvent evt
;
461 evt
.SetFlags(wxNavigationKeyEvent::FromTab
|
462 (!event
.ShiftDown()?wxNavigationKeyEvent::IsForward
:
463 wxNavigationKeyEvent::IsBackward
));
464 evt
.SetEventObject(m_combo
);
465 m_combo
->GetParent()->GetEventHandler()->AddPendingEvent(evt
);
469 if ( m_combo
->IsPopupShown() )
471 // pass it to the popped up control
472 m_combo
->GetPopupControl()->AddPendingEvent(event
);
476 int comboStyle
= m_combo
->GetWindowStyle();
477 wxComboPopup
* popupInterface
= m_combo
->GetPopup();
479 if ( !popupInterface
)
485 if ( (comboStyle
& wxCB_READONLY
) ||
486 ( keycode
!= WXK_RIGHT
&& keycode
!= WXK_LEFT
)
489 // Alternate keys: UP and DOWN show the popup instead of cycling
490 if ( (comboStyle
& wxCC_ALT_KEYS
) )
492 if ( keycode
== WXK_UP
|| keycode
== WXK_DOWN
)
494 m_combo
->OnButtonClick();
499 popupInterface
->OnComboKeyEvent(event
);
507 void wxComboBoxExtraInputHandler::OnFocus(wxFocusEvent
& event
)
509 // FIXME: This code does run when control is clicked,
510 // yet on Windows it doesn't select all the text.
511 if ( !(m_combo
->GetInternalFlags() & wxCC_NO_TEXT_AUTO_SELECT
) )
513 if ( m_combo
->GetTextCtrl() )
514 m_combo
->GetTextCtrl()->SelectAll();
516 m_combo
->SetSelection(-1,-1);
524 // This is pushed to the event handler queue of the control in popup.
527 class wxComboPopupExtraEventHandler
: public wxEvtHandler
531 wxComboPopupExtraEventHandler( wxComboControlBase
* combo
)
535 m_beenInside
= false;
537 ~wxComboPopupExtraEventHandler() { }
539 void OnMouseEvent( wxMouseEvent
& event
);
541 // Called from wxPGComboControlBase::OnPopupDismiss
542 void OnPopupDismiss()
544 m_beenInside
= false;
548 wxComboControlBase
* m_combo
;
553 DECLARE_EVENT_TABLE()
557 BEGIN_EVENT_TABLE(wxComboPopupExtraEventHandler
, wxEvtHandler
)
558 EVT_MOUSE_EVENTS(wxComboPopupExtraEventHandler::OnMouseEvent
)
562 void wxComboPopupExtraEventHandler::OnMouseEvent( wxMouseEvent
& event
)
564 wxPoint pt
= event
.GetPosition();
565 wxSize sz
= m_combo
->GetPopupControl()->GetClientSize();
566 int evtType
= event
.GetEventType();
567 bool isInside
= pt
.x
>= 0 && pt
.y
>= 0 && pt
.x
< sz
.x
&& pt
.y
< sz
.y
;
569 if ( evtType
== wxEVT_MOTION
||
570 evtType
== wxEVT_LEFT_DOWN
||
571 evtType
== wxEVT_RIGHT_DOWN
)
573 // Block motion and click events outside the popup
580 else if ( evtType
== wxEVT_LEFT_UP
)
582 // Don't let left-down events in if outside
583 if ( evtType
== wxEVT_LEFT_DOWN
)
598 // Some mouse events to popup that happen outside it, before cursor
599 // has been inside the popu, need to be ignored by it but relayed to
602 wxWindow
* btn
= m_combo
->GetButton();
604 btn
->GetEventHandler()->AddPendingEvent(event
);
606 m_combo
->GetEventHandler()->AddPendingEvent(event
);
618 // ----------------------------------------------------------------------------
619 // wxComboControlBase
620 // ----------------------------------------------------------------------------
623 BEGIN_EVENT_TABLE(wxComboControlBase
, wxControl
)
624 EVT_TEXT(wxID_ANY
,wxComboControlBase::OnTextCtrlEvent
)
625 EVT_SIZE(wxComboControlBase::OnSizeEvent
)
626 EVT_SET_FOCUS(wxComboControlBase::OnFocusEvent
)
627 EVT_KILL_FOCUS(wxComboControlBase::OnFocusEvent
)
628 //EVT_BUTTON(wxID_ANY,wxComboControlBase::OnButtonClickEvent)
629 EVT_TEXT_ENTER(wxID_ANY
,wxComboControlBase::OnTextCtrlEvent
)
630 EVT_SYS_COLOUR_CHANGED(wxComboControlBase::OnSysColourChanged
)
634 IMPLEMENT_ABSTRACT_CLASS(wxComboControlBase
, wxControl
)
636 // Have global double buffer - should be enough for multiple combos
637 static wxBitmap
* gs_doubleBuffer
= (wxBitmap
*) NULL
;
639 void wxComboControlBase::Init()
641 m_winPopup
= (wxWindow
*)NULL
;
642 m_popup
= (wxWindow
*)NULL
;
643 m_isPopupShown
= false;
644 m_btn
= (wxWindow
*) NULL
;
645 m_text
= (wxTextCtrl
*) NULL
;
646 m_popupInterface
= (wxComboPopup
*) NULL
;
648 m_extraEvtHandler
= (wxEvtHandler
*) NULL
;
649 m_popupExtraHandler
= (wxEvtHandler
*) NULL
;
650 m_textEvtHandler
= (wxEvtHandler
*) NULL
;
652 #if INSTALL_TOPLEV_HANDLER
653 m_toplevEvtHandler
= (wxEvtHandler
*) NULL
;
657 m_widthMinPopup
= -1;
659 m_widthCustomPaint
= 0;
660 m_widthCustomBorder
= 0;
664 m_blankButtonBg
= false;
665 m_btnWid
= m_btnHei
= 0;
673 m_downReceived
= false;
674 m_timeCanAcceptClick
= 0;
677 bool wxComboControlBase::Create(wxWindow
*parent
,
679 const wxString
& value
,
683 const wxValidator
& validator
,
684 const wxString
& name
)
686 if ( !wxControl::Create(parent
,
690 style
| wxWANTS_CHARS
,
695 m_valueString
= value
;
699 m_absIndent
= GetNativeTextIndent();
704 void wxComboControlBase::InstallInputHandlers( bool alsoTextCtrl
)
706 if ( m_text
&& alsoTextCtrl
)
708 m_textEvtHandler
= new wxComboBoxExtraInputHandler(this);
709 m_text
->PushEventHandler(m_textEvtHandler
);
712 wxComboBoxExtraInputHandler
* inputHandler
= new wxComboBoxExtraInputHandler(this);
713 PushEventHandler(inputHandler
);
714 m_extraEvtHandler
= inputHandler
;
717 void wxComboControlBase::CreateTextCtrl( int extraStyle
, const wxValidator
& validator
)
719 if ( !(m_windowStyle
& wxCB_READONLY
) )
721 m_text
= new wxTextCtrl(this,
726 // wxTE_PROCESS_TAB is needed because on Windows, wxTAB_TRAVERSAL is
727 // not used by the wxPropertyGrid and therefore the tab is
728 // processed by looking at ancestors to see if they have
729 // wxTAB_TRAVERSAL. The navigation event is then sent to
735 // This is required for some platforms (GTK+ atleast)
736 m_text
->SetSizeHints(2,4);
740 void wxComboControlBase::OnThemeChange()
742 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW
));
745 wxComboControlBase::~wxComboControlBase()
750 delete gs_doubleBuffer
;
751 gs_doubleBuffer
= (wxBitmap
*) NULL
;
753 #if INSTALL_TOPLEV_HANDLER
754 delete ((wxComboFrameEventHandler
*)m_toplevEvtHandler
);
755 m_toplevEvtHandler
= (wxEvtHandler
*) NULL
;
759 m_popup
->RemoveEventHandler(m_popupExtraHandler
);
761 delete m_popupExtraHandler
;
765 delete m_popupInterface
;
768 RemoveEventHandler(m_extraEvtHandler
);
771 m_text
->RemoveEventHandler(m_textEvtHandler
);
773 delete m_textEvtHandler
;
774 delete m_extraEvtHandler
;
778 // ----------------------------------------------------------------------------
780 // ----------------------------------------------------------------------------
782 // Recalculates button and textctrl areas
783 void wxComboControlBase::CalculateAreas( int btnWidth
)
785 wxSize sz
= GetClientSize();
786 int customBorder
= m_widthCustomBorder
;
788 int btnBorder
; // border for button only
790 if ( ( (m_iFlags
& wxCC_BUTTON_OUTSIDE_BORDER
) || m_blankButtonBg
) &&
791 m_btnSpacingX
== 0 && m_btnWid
== 0 && m_btnHei
== 0 &&
792 (!m_bmpNormal
.Ok() || m_blankButtonBg
) )
794 buttonOutside
= true;
795 m_iFlags
|= wxCC_IFLAG_BUTTON_OUTSIDE
;
800 buttonOutside
= false;
801 m_iFlags
&= ~(wxCC_IFLAG_BUTTON_OUTSIDE
);
802 btnBorder
= customBorder
;
805 // Defaul indentation
806 if ( m_absIndent
< 0 )
807 m_absIndent
= GetNativeTextIndent();
809 int butWidth
= btnWidth
;
812 butWidth
= m_btnWidDefault
;
814 m_btnWidDefault
= butWidth
;
819 // Adjust button width
821 butWidth
+= m_btnWid
;
822 else if ( m_btnWid
> 0 )
825 int butHeight
= sz
.y
;
827 butHeight
-= btnBorder
*2;
829 // Adjust button height
831 butHeight
+= m_btnHei
;
832 else if ( m_btnHei
> 0 )
833 butHeight
= m_btnHei
;
835 // Use size of normal bitmap if...
838 // button width is set to default and blank button bg is not drawn
839 if ( m_bmpNormal
.Ok() )
841 int bmpReqWidth
= m_bmpNormal
.GetWidth();
842 int bmpReqHeight
= m_bmpNormal
.GetHeight();
844 // If drawing blank button background, we need to add some margin.
845 if ( m_blankButtonBg
)
847 bmpReqWidth
+= BMP_BUTTON_MARGIN
*2;
848 bmpReqHeight
+= BMP_BUTTON_MARGIN
*2;
851 if ( butWidth
< bmpReqWidth
|| ( m_btnWid
== 0 && !m_blankButtonBg
) )
852 butWidth
= bmpReqWidth
;
853 if ( butHeight
< bmpReqHeight
|| ( m_btnHei
== 0 && !m_blankButtonBg
) )
854 butHeight
= bmpReqHeight
;
856 // Need to fix height?
857 if ( (sz
.y
-(customBorder
*2)) < butHeight
&& btnWidth
== 0 )
859 int newY
= butHeight
+(customBorder
*2);
860 SetClientSize(-1,newY
);
865 int butAreaWid
= butWidth
+ (m_btnSpacingX
*2);
867 m_btnSize
.x
= butWidth
;
868 m_btnSize
.y
= butHeight
;
870 m_btnArea
.x
= ( m_btnSide
==wxRIGHT
? sz
.x
- butAreaWid
- btnBorder
: btnBorder
);
871 m_btnArea
.y
= btnBorder
;
872 m_btnArea
.width
= butAreaWid
;
873 m_btnArea
.height
= sz
.y
- (btnBorder
*2);
875 m_tcArea
.x
= ( m_btnSide
==wxRIGHT
? 0 : butAreaWid
) + customBorder
;
876 m_tcArea
.y
= customBorder
;
877 m_tcArea
.width
= sz
.x
- butAreaWid
- (customBorder
*2);
878 m_tcArea
.height
= sz
.y
- (customBorder
*2);
883 ::wxMessageBox(wxString::Format(wxT("ButtonArea (%i,%i,%i,%i)\n"),m_btnArea.x,m_btnArea.y,m_btnArea.width,m_btnArea.height) +
884 wxString::Format(wxT("TextCtrlArea (%i,%i,%i,%i)"),m_tcArea.x,m_tcArea.y,m_tcArea.width,m_tcArea.height));
889 void wxComboControlBase::PositionTextCtrl( int textCtrlXAdjust
, int textCtrlYAdjust
)
894 wxSize sz
= GetClientSize();
895 int customBorder
= m_widthCustomBorder
;
897 if ( (m_text
->GetWindowStyleFlag() & wxBORDER_MASK
) == wxNO_BORDER
)
900 int tcSizeY
= m_text
->GetBestSize().y
;
901 int diff
= sz
.y
- tcSizeY
;
902 int y
= textCtrlYAdjust
+ (diff
/2);
904 if ( y
< customBorder
)
907 m_text
->SetSize( m_tcArea
.x
+ m_widthCustomPaint
+ m_absIndent
+ textCtrlXAdjust
,
909 m_tcArea
.width
- COMBO_MARGIN
-
910 (textCtrlXAdjust
+ m_widthCustomPaint
+ m_absIndent
),
913 // Make sure textctrl doesn't exceed the bottom custom border
914 wxSize tsz
= m_text
->GetSize();
915 diff
= (y
+ tsz
.y
) - (sz
.y
- customBorder
);
918 tsz
.y
= tsz
.y
- diff
- 1;
919 m_text
->SetSize(tsz
);
924 m_text
->SetSize( m_tcArea
.x
,
926 sz
.x
- m_btnArea
.x
- m_widthCustomPaint
- customBorder
,
931 wxSize
wxComboControlBase::DoGetBestSize() const
933 wxSize
sizeText(150,0);
936 sizeText
= m_text
->GetBestSize();
938 // TODO: Better method to calculate close-to-native control height.
942 fhei
= (m_font
.GetPointSize()*2) + 5;
943 else if ( wxNORMAL_FONT
->Ok() )
944 fhei
= (wxNORMAL_FONT
->GetPointSize()*2) + 5;
946 fhei
= sizeText
.y
+ 4;
948 // Need to force height to accomodate bitmap?
949 int btnSizeY
= m_btnSize
.y
;
950 if ( m_bmpNormal
.Ok() && fhei
< btnSizeY
)
953 // Control height doesn't depend on border
956 int border = m_windowStyle & wxBORDER_MASK;
957 if ( border == wxSIMPLE_BORDER )
959 else if ( border == wxNO_BORDER )
960 fhei += (m_widthCustomBorder*2);
971 wxSize
ret(sizeText
.x
+ COMBO_MARGIN
+ DEFAULT_DROPBUTTON_WIDTH
,
978 void wxComboControlBase::DoMoveWindow(int x
, int y
, int width
, int height
)
980 // SetSize is called last in create, so it marks the end of creation
981 m_iFlags
|= wxCC_IFLAG_CREATED
;
983 wxControl::DoMoveWindow(x
, y
, width
, height
);
986 void wxComboControlBase::OnSizeEvent( wxSizeEvent
& event
)
991 // defined by actual wxComboControls
997 // ----------------------------------------------------------------------------
998 // standard operations
999 // ----------------------------------------------------------------------------
1001 bool wxComboControlBase::Enable(bool enable
)
1003 if ( !wxControl::Enable(enable
) )
1007 m_btn
->Enable(enable
);
1009 m_text
->Enable(enable
);
1014 bool wxComboControlBase::Show(bool show
)
1016 if ( !wxControl::Show(show
) )
1028 bool wxComboControlBase::SetFont ( const wxFont
& font
)
1030 if ( !wxControl::SetFont(font
) )
1034 m_text
->SetFont(font
);
1040 void wxComboControlBase::DoSetToolTip(wxToolTip
*tooltip
)
1042 wxControl::DoSetToolTip(tooltip
);
1044 // Set tool tip for button and text box
1047 const wxString
&tip
= tooltip
->GetTip();
1048 if ( m_text
) m_text
->SetToolTip(tip
);
1049 if ( m_btn
) m_btn
->SetToolTip(tip
);
1053 if ( m_text
) m_text
->SetToolTip( (wxToolTip
*) NULL
);
1054 if ( m_btn
) m_btn
->SetToolTip( (wxToolTip
*) NULL
);
1057 #endif // wxUSE_TOOLTIPS
1059 // ----------------------------------------------------------------------------
1061 // ----------------------------------------------------------------------------
1063 // draw focus background on area in a way typical on platform
1064 void wxComboControlBase::DrawFocusBackground( wxDC
& dc
, const wxRect
& rect
, int flags
)
1066 wxSize sz
= GetClientSize();
1068 bool isFocused
; // also selected
1070 // For smaller size control (and for disabled background) use less spacing
1074 if ( !(flags
& wxCONTROL_ISSUBMENU
) )
1077 isEnabled
= IsEnabled();
1078 isFocused
= ShouldDrawFocus();
1080 // Windows-style: for smaller size control (and for disabled background) use less spacing
1081 focusSpacingX
= isEnabled
? 2 : 1;
1082 focusSpacingY
= sz
.y
> (GetCharHeight()+2) && isEnabled
? 2 : 1;
1086 // Drawing a list item
1087 isEnabled
= true; // they are never disabled
1088 isFocused
= flags
& wxCONTROL_SELECTED
? true : false;
1094 // Set the background sub-rectangle for selection, disabled etc
1095 wxRect
selRect(rect
);
1096 selRect
.y
+= focusSpacingY
;
1097 selRect
.height
-= (focusSpacingY
*2);
1098 selRect
.x
+= m_widthCustomPaint
+ focusSpacingX
;
1099 selRect
.width
-= m_widthCustomPaint
+ (focusSpacingX
*2);
1105 // If popup is hidden and this control is focused,
1106 // then draw the focus-indicator (selbgcolor background etc.).
1109 dc
.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT
) );
1110 bgCol
= wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT
);
1114 dc
.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
) );
1115 bgCol
= GetBackgroundColour();
1120 dc
.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT
) );
1121 bgCol
= GetBackgroundColour();
1124 dc
.SetBrush( bgCol
);
1126 dc
.DrawRectangle( selRect
);
1129 void wxComboControlBase::DrawButton( wxDC
& dc
, const wxRect
& rect
, bool paintBg
)
1131 int drawState
= m_btnState
;
1134 if ( m_isPopupShown
)
1135 drawState
|= wxCONTROL_PRESSED
;
1138 wxRect
drawRect(rect
.x
+m_btnSpacingX
,
1139 rect
.y
+((rect
.height
-m_btnSize
.y
)/2),
1143 // Make sure area is not larger than the control
1144 if ( drawRect
.y
< rect
.y
)
1145 drawRect
.y
= rect
.y
;
1146 if ( drawRect
.height
> rect
.height
)
1147 drawRect
.height
= rect
.height
;
1149 bool enabled
= IsEnabled();
1152 drawState
|= wxCONTROL_DISABLED
;
1154 if ( !m_bmpNormal
.Ok() )
1156 // Need to clear button background even if m_btn is present
1157 // (assume non-button background was cleared just before this call so brushes are good)
1159 dc
.DrawRectangle(rect
);
1161 // Draw standard button
1162 wxRendererNative::Get().DrawComboBoxDropButton(this,
1174 pBmp
= &m_bmpDisabled
;
1175 else if ( m_btnState
& wxCONTROL_PRESSED
)
1176 pBmp
= &m_bmpPressed
;
1177 else if ( m_btnState
& wxCONTROL_CURRENT
)
1180 pBmp
= &m_bmpNormal
;
1182 if ( m_blankButtonBg
)
1184 // If using blank button background, we need to clear its background
1185 // with button face colour instead of colour for rest of the control.
1188 wxColour bgCol
= GetParent()->GetBackgroundColour(); //wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE);
1189 //wxColour bgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
1192 dc
.DrawRectangle(rect
);
1195 wxRendererNative::Get().DrawPushButton(this,
1204 // Need to clear button background even if m_btn is present
1205 // (assume non-button background was cleared just before this call so brushes are good)
1207 dc
.DrawRectangle(rect
);
1210 // Draw bitmap centered in drawRect
1211 dc
.DrawBitmap(*pBmp
,
1212 drawRect
.x
+ (drawRect
.width
-pBmp
->GetWidth())/2,
1213 drawRect
.y
+ (drawRect
.height
-pBmp
->GetHeight())/2,
1218 void wxComboControlBase::RecalcAndRefresh()
1222 wxSizeEvent
evt(GetSize(),GetId());
1223 GetEventHandler()->ProcessEvent(evt
);
1228 wxBitmap
& wxComboControlBase::GetBufferBitmap( const wxSize
& sz
) const
1230 // If size is larger, recalculate double buffer bitmap
1231 if ( !gs_doubleBuffer
||
1232 sz
.x
> gs_doubleBuffer
->GetWidth() ||
1233 sz
.y
> gs_doubleBuffer
->GetHeight() )
1235 delete gs_doubleBuffer
;
1236 gs_doubleBuffer
= new wxBitmap(sz
.x
+25,sz
.y
);
1238 return *gs_doubleBuffer
;
1242 bool wxComboControlBase::OnDrawListItem( wxDC
& WXUNUSED(dc
),
1243 const wxRect
& WXUNUSED(rect
),
1245 int WXUNUSED(flags
) )
1247 return false; // signals caller to make default drawing
1250 wxCoord
wxComboControlBase::OnMeasureListItem( int WXUNUSED(item
) )
1252 return -1; // signals caller to use default
1255 wxCoord
wxComboControlBase::OnMeasureListItemWidth( int WXUNUSED(item
) )
1257 return -1; // signals caller to use default
1260 // ----------------------------------------------------------------------------
1261 // miscellaneous event handlers
1262 // ----------------------------------------------------------------------------
1264 void wxComboControlBase::OnTextCtrlEvent(wxCommandEvent
& event
)
1266 // Change event id and relay it forward
1267 event
.SetId(GetId());
1271 // call if cursor is on button area or mouse is captured for the button
1272 bool wxComboControlBase::HandleButtonMouseEvent( wxMouseEvent
& event
,
1275 int type
= event
.GetEventType();
1277 if ( type
== wxEVT_MOTION
)
1279 if ( flags
& wxCC_MF_ON_BUTTON
)
1281 if ( !(m_btnState
& wxCONTROL_CURRENT
) )
1283 // Mouse hover begins
1284 m_btnState
|= wxCONTROL_CURRENT
;
1285 if ( HasCapture() ) // Retain pressed state.
1286 m_btnState
|= wxCONTROL_PRESSED
;
1290 else if ( (m_btnState
& wxCONTROL_CURRENT
) )
1293 m_btnState
&= ~(wxCONTROL_CURRENT
|wxCONTROL_PRESSED
);
1297 else if ( type
== wxEVT_LEFT_DOWN
)
1299 // Only accept event if it wasn't right after popup dismiss
1300 //if ( ::wxGetLocalTimeMillis() > m_timeCanClick )
1302 // Need to test this, because it might be outside.
1303 if ( flags
& wxCC_MF_ON_BUTTON
)
1305 m_btnState
|= wxCONTROL_PRESSED
;
1308 if ( !(m_iFlags
& wxCC_POPUP_ON_MOUSE_UP
) )
1311 // If showing popup now, do not capture mouse or there will be interference
1320 else if ( type
== wxEVT_LEFT_UP
)
1323 // Only accept event if mouse was left-press was previously accepted
1327 if ( m_btnState
& wxCONTROL_PRESSED
)
1329 // If mouse was inside, fire the click event.
1330 if ( m_iFlags
& wxCC_POPUP_ON_MOUSE_UP
)
1332 if ( flags
& wxCC_MF_ON_BUTTON
)
1336 m_btnState
&= ~(wxCONTROL_PRESSED
);
1340 else if ( type
== wxEVT_LEAVE_WINDOW
)
1342 if ( m_btnState
& (wxCONTROL_CURRENT
|wxCONTROL_PRESSED
) )
1344 m_btnState
&= ~(wxCONTROL_CURRENT
);
1347 if ( !m_isPopupShown
)
1349 m_btnState
&= ~(wxCONTROL_PRESSED
);
1360 // Conversion to double-clicks and some basic filtering
1361 // returns true if event was consumed or filtered
1362 //bool wxComboControlBase::PreprocessMouseEvent( wxMouseEvent& event, bool isOnButtonArea )
1363 bool wxComboControlBase::PreprocessMouseEvent( wxMouseEvent
& event
,
1366 wxLongLong t
= ::wxGetLocalTimeMillis();
1367 int evtType
= event
.GetEventType();
1370 // Generate our own double-clicks
1371 // (to allow on-focus dc-event on double-clicks instead of triple-clicks)
1372 if ( (m_windowStyle
& wxCC_SPECIAL_DCLICK
) &&
1374 //!(handlerFlags & wxCC_MF_ON_BUTTON) )
1375 !(flags
& wxCC_MF_ON_BUTTON
) )
1377 if ( evtType
== wxEVT_LEFT_DOWN
)
1379 // Set value to avoid up-events without corresponding downs
1380 m_downReceived
= true;
1382 else if ( evtType
== wxEVT_LEFT_DCLICK
)
1384 // We'll make our own double-clicks
1386 event
.SetEventType(0);
1389 else if ( evtType
== wxEVT_LEFT_UP
)
1391 if ( m_downReceived
|| m_timeLastMouseUp
== 1 )
1393 wxLongLong timeFromLastUp
= (t
-m_timeLastMouseUp
);
1395 if ( timeFromLastUp
< DOUBLE_CLICK_CONVERSION_TRESHOLD
)
1397 //type = wxEVT_LEFT_DCLICK;
1398 event
.SetEventType(wxEVT_LEFT_DCLICK
);
1399 m_timeLastMouseUp
= 1;
1403 m_timeLastMouseUp
= t
;
1406 //m_downReceived = false;
1411 // Filter out clicks on button immediately after popup dismiss (Windows like behaviour)
1412 if ( evtType
== wxEVT_LEFT_DOWN
&& t
< m_timeCanAcceptClick
)
1414 event
.SetEventType(0);
1421 void wxComboControlBase::HandleNormalMouseEvent( wxMouseEvent
& event
)
1423 int evtType
= event
.GetEventType();
1425 if ( (evtType
== wxEVT_LEFT_DOWN
|| evtType
== wxEVT_LEFT_DCLICK
) &&
1426 (m_windowStyle
& wxCB_READONLY
) )
1428 if ( m_isPopupShown
)
1431 // Normally do nothing - evt handler should close it for us
1432 #elif !USE_TRANSIENT_POPUP
1433 // Click here always hides the popup.
1439 if ( !(m_windowStyle
& wxCC_SPECIAL_DCLICK
) )
1441 // In read-only mode, clicking the text is the
1442 // same as clicking the button.
1445 else if ( /*evtType == wxEVT_LEFT_UP || */evtType
== wxEVT_LEFT_DCLICK
)
1447 //if ( m_popupInterface->CycleValue() )
1449 if ( m_popupInterface
)
1450 m_popupInterface
->OnComboDoubleClick();
1455 if ( m_isPopupShown
)
1457 // relay (some) mouse events to the popup
1458 if ( evtType
== wxEVT_MOUSEWHEEL
)
1459 m_popup
->AddPendingEvent(event
);
1465 void wxComboControlBase::OnFocusEvent( wxFocusEvent
& )
1467 // First click is the first part of double-click
1468 // Some platforms don't generate down-less mouse up-event
1469 // (Windows does, GTK+2 doesn't), so that's why we have
1471 m_timeLastMouseUp
= ::wxGetLocalTimeMillis();
1478 // no need to check for m_widthCustomPaint - that
1479 // area never gets special handling when selected
1480 // (in writable mode, that is)
1484 void wxComboControlBase::OnSysColourChanged(wxSysColourChangedEvent
& WXUNUSED(event
))
1487 // indentation may also have changed
1488 if ( !(m_iFlags
& wxCC_IFLAG_INDENT_SET
) )
1489 m_absIndent
= GetNativeTextIndent();
1493 // ----------------------------------------------------------------------------
1495 // ----------------------------------------------------------------------------
1497 // Create popup window and the child control
1498 void wxComboControlBase::CreatePopup()
1500 wxComboPopup
* popupInterface
= m_popupInterface
;
1504 m_winPopup
= new wxComboPopupWindow( this, wxNO_BORDER
);
1506 popupInterface
->Create(m_winPopup
);
1507 m_popup
= popup
= popupInterface
->GetControl();
1509 m_popupExtraHandler
= new wxComboPopupExtraEventHandler(this);
1510 popup
->PushEventHandler( m_popupExtraHandler
);
1512 // This may be helpful on some platforms
1513 // (eg. it bypasses a wxGTK popupwindow bug where
1514 // window is not initially hidden when it should be)
1517 popupInterface
->m_iFlags
|= wxCP_IFLAG_CREATED
;
1520 void wxComboControlBase::SetPopupControl( wxComboPopup
* iface
)
1522 delete m_popupInterface
;
1525 m_popupInterface
= iface
;
1527 if ( !iface
->LazyCreate() || m_winPopup
)
1533 m_popup
= (wxWindow
*) NULL
;
1536 // This must be after creation
1537 if ( m_valueString
)
1538 iface
->SetStringValue(m_valueString
);
1542 void wxComboControlBase::OnButtonClick()
1544 // Derived classes can override this method for totally custom
1549 void wxComboControlBase::ShowPopup()
1551 wxCHECK_RET( m_popupInterface
, wxT("no popup interface set for wxComboControl") );
1552 wxCHECK_RET( !IsPopupShown(), wxT("popup window already shown") );
1556 // Space above and below
1562 wxSize ctrlSz
= GetSize();
1564 screenHeight
= wxSystemSettings::GetMetric( wxSYS_SCREEN_Y
);
1565 scrPos
= GetParent()->ClientToScreen(GetPosition());
1567 spaceAbove
= scrPos
.y
;
1568 spaceBelow
= screenHeight
- spaceAbove
- ctrlSz
.y
;
1570 maxHeightPopup
= spaceBelow
;
1571 if ( spaceAbove
> spaceBelow
)
1572 maxHeightPopup
= spaceAbove
;
1575 int widthPopup
= ctrlSz
.x
+ m_extLeft
+ m_extRight
;
1577 if ( widthPopup
< m_widthMinPopup
)
1578 widthPopup
= m_widthMinPopup
;
1580 wxWindow
* winPopup
= m_winPopup
;
1583 // Need to disable tab traversal of parent
1585 // NB: This is to fix a bug in wxMSW. In theory it could also be fixed
1586 // by, for instance, adding check to window.cpp:wxWindowMSW::MSWProcessMessage
1587 // that if transient popup is open, then tab traversal is to be ignored.
1588 // However, I think this code would still be needed for cases where
1589 // transient popup doesn't work yet (wxWinCE?).
1590 wxWindow
* parent
= GetParent();
1591 int parentFlags
= parent
->GetWindowStyle();
1592 if ( parentFlags
& wxTAB_TRAVERSAL
)
1594 parent
->SetWindowStyle( parentFlags
& ~(wxTAB_TRAVERSAL
) );
1595 m_iFlags
|= wxCC_IFLAG_PARENT_TAB_TRAVERSAL
;
1601 winPopup
= m_winPopup
;
1609 wxASSERT( !m_popup
|| m_popup
== popup
); // Consistency check.
1611 wxSize adjustedSize
= m_popupInterface
->GetAdjustedSize(widthPopup
,
1612 m_heightPopup
<=0?DEFAULT_POPUP_HEIGHT
:m_heightPopup
,
1615 popup
->SetSize(adjustedSize
);
1617 m_popupInterface
->OnPopup();
1620 // Reposition and resize popup window
1623 wxSize szp
= popup
->GetSize();
1626 int popupY
= scrPos
.y
+ ctrlSz
.y
;
1628 int anchorSide
= m_anchorSide
;
1630 anchorSide
= m_btnSide
;
1632 // Anchor popup to the side the dropbutton is on
1633 if ( anchorSide
== wxRIGHT
)
1634 popupX
= scrPos
.x
+ ctrlSz
.x
+ m_extRight
- szp
.x
;
1636 popupX
= scrPos
.x
- m_extLeft
;
1638 if ( spaceBelow
< szp
.y
)
1640 popupY
= scrPos
.y
- szp
.y
;
1644 //wxLogDebug(wxT("popup scheduled position1: %i,%i"),ptp.x,ptp.y);
1645 //wxLogDebug(wxT("popup position1: %i,%i"),winPopup->GetPosition().x,winPopup->GetPosition().y);
1647 // Some platforms (GTK) may need these two to be separate
1648 winPopup
->SetSize( szp
.x
, szp
.y
);
1649 winPopup
->Move( popupX
, popupY
);
1651 //wxLogDebug(wxT("popup position2: %i,%i"),winPopup->GetPosition().x,winPopup->GetPosition().y);
1655 // Set string selection (must be this way instead of SetStringSelection)
1658 if ( !(m_iFlags
& wxCC_NO_TEXT_AUTO_SELECT
) )
1659 m_text
->SelectAll();
1661 m_popupInterface
->SetStringValue( m_text
->GetValue() );
1665 // This is neede since focus/selection indication may change when popup is shown
1666 // FIXME: But in that case, would m_isPopupShown need to go before this?
1670 // This must be after SetStringValue
1671 m_isPopupShown
= true;
1674 #if USE_TRANSIENT_POPUP
1675 ((wxPopupTransientWindow
*)winPopup
)->Popup(popup
);
1680 #if INSTALL_TOPLEV_HANDLER
1681 // Put top level window event handler into place
1682 if ( !m_toplevEvtHandler
)
1683 m_toplevEvtHandler
= new wxComboFrameEventHandler(this);
1685 wxWindow
* toplev
= ::wxGetTopLevelParent( this );
1687 ((wxComboFrameEventHandler
*)m_toplevEvtHandler
)->OnPopup();
1688 toplev
->PushEventHandler( m_toplevEvtHandler
);
1693 void wxComboControlBase::OnPopupDismiss()
1695 // Just in case, avoid double dismiss
1696 if ( !m_isPopupShown
)
1699 // *Must* set this before focus etc.
1700 m_isPopupShown
= false;
1702 // Inform popup control itself
1703 m_popupInterface
->OnDismiss();
1705 if ( m_popupExtraHandler
)
1706 ((wxComboPopupExtraEventHandler
*)m_popupExtraHandler
)->OnPopupDismiss();
1708 #if INSTALL_TOPLEV_HANDLER
1709 // Remove top level window event handler
1710 if ( m_toplevEvtHandler
)
1712 wxWindow
* toplev
= ::wxGetTopLevelParent( this );
1714 toplev
->RemoveEventHandler( m_toplevEvtHandler
);
1718 m_timeCanAcceptClick
= ::wxGetLocalTimeMillis() + 150;
1720 // If cursor not on dropdown button, then clear its state
1721 // (technically not required by all ports, but do it for all just in case)
1722 if ( !m_btnArea
.Inside(ScreenToClient(::wxGetMousePosition())) )
1725 // Return parent's tab traversal flag.
1726 // See ShowPopup for notes.
1727 if ( m_iFlags
& wxCC_IFLAG_PARENT_TAB_TRAVERSAL
)
1729 wxWindow
* parent
= GetParent();
1730 parent
->SetWindowStyle( parent
->GetWindowStyle() | wxTAB_TRAVERSAL
);
1731 m_iFlags
&= ~(wxCC_IFLAG_PARENT_TAB_TRAVERSAL
);
1734 // refresh control (necessary even if m_text)
1743 void wxComboControlBase::HidePopup()
1745 // Should be able to call this without popup interface
1746 //wxCHECK_RET( m_popupInterface, _T("no popup interface") );
1747 if ( !m_isPopupShown
)
1750 // transfer value and show it in textctrl, if any
1751 SetValue( m_popupInterface
->GetStringValue() );
1753 #if USE_TRANSIENT_POPUP
1754 ((wxPopupTransientWindow
*)m_winPopup
)->Dismiss();
1762 // ----------------------------------------------------------------------------
1763 // customization methods
1764 // ----------------------------------------------------------------------------
1766 void wxComboControlBase::SetButtonPosition( int width
, int height
,
1767 int side
, int spacingX
)
1772 m_btnSpacingX
= spacingX
;
1777 void wxComboControlBase::SetButtonBitmaps( const wxBitmap
& bmpNormal
,
1779 const wxBitmap
& bmpPressed
,
1780 const wxBitmap
& bmpHover
,
1781 const wxBitmap
& bmpDisabled
)
1783 m_bmpNormal
= bmpNormal
;
1784 m_blankButtonBg
= blankButtonBg
;
1786 if ( bmpPressed
.Ok() )
1787 m_bmpPressed
= bmpPressed
;
1789 m_bmpPressed
= bmpNormal
;
1791 if ( bmpHover
.Ok() )
1792 m_bmpHover
= bmpHover
;
1794 m_bmpHover
= bmpNormal
;
1796 if ( bmpDisabled
.Ok() )
1797 m_bmpDisabled
= bmpDisabled
;
1799 m_bmpDisabled
= bmpNormal
;
1804 void wxComboControlBase::SetCustomPaintWidth( int width
)
1808 // move textctrl accordingly
1809 wxRect r
= m_text
->GetRect();
1810 int inc
= width
- m_widthCustomPaint
;
1813 m_text
->SetSize( r
);
1816 m_widthCustomPaint
= width
;
1821 void wxComboControlBase::SetTextIndent( int indent
)
1825 m_absIndent
= GetNativeTextIndent();
1826 m_iFlags
&= ~(wxCC_IFLAG_INDENT_SET
);
1830 m_absIndent
= indent
;
1831 m_iFlags
|= wxCC_IFLAG_INDENT_SET
;
1837 wxCoord
wxComboControlBase::GetNativeTextIndent() const
1839 return DEFAULT_TEXT_INDENT
;
1842 // ----------------------------------------------------------------------------
1843 // methods forwarded to wxTextCtrl
1844 // ----------------------------------------------------------------------------
1846 wxString
wxComboControlBase::GetValue() const
1849 return m_text
->GetValue();
1850 return m_valueString
;
1853 void wxComboControlBase::SetValue(const wxString
& value
)
1857 m_text
->SetValue(value
);
1858 if ( !(m_iFlags
& wxCC_NO_TEXT_AUTO_SELECT
) )
1859 m_text
->SelectAll();
1862 // Since wxComboPopup may want to paint the combo as well, we need
1863 // to set the string value here (as well as sometimes in ShowPopup).
1864 if ( m_valueString
!= value
&& m_popupInterface
)
1866 m_popupInterface
->SetStringValue(value
);
1869 m_valueString
= value
;
1874 void wxComboControlBase::Copy()
1880 void wxComboControlBase::Cut()
1886 void wxComboControlBase::Paste()
1892 void wxComboControlBase::SetInsertionPoint(long pos
)
1895 m_text
->SetInsertionPoint(pos
);
1898 void wxComboControlBase::SetInsertionPointEnd()
1901 m_text
->SetInsertionPointEnd();
1904 long wxComboControlBase::GetInsertionPoint() const
1907 return m_text
->GetInsertionPoint();
1912 long wxComboControlBase::GetLastPosition() const
1915 return m_text
->GetLastPosition();
1920 void wxComboControlBase::Replace(long from
, long to
, const wxString
& value
)
1923 m_text
->Replace(from
, to
, value
);
1926 void wxComboControlBase::Remove(long from
, long to
)
1929 m_text
->Remove(from
, to
);
1932 void wxComboControlBase::SetSelection(long from
, long to
)
1935 m_text
->SetSelection(from
, to
);
1938 void wxComboControlBase::Undo()
1944 #endif // wxUSE_COMBOCONTROL