X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4427c0a3ff15545c46f97a217a1dc947099d4a40..a6794ed8e99b58b6bfa736e63aa80cfa68ac3034:/src/common/combocmn.cpp diff --git a/src/common/combocmn.cpp b/src/common/combocmn.cpp index e069544404..637c30952b 100644 --- a/src/common/combocmn.cpp +++ b/src/common/combocmn.cpp @@ -828,17 +828,14 @@ wxComboCtrlBase::CreateTextCtrl(int style, const wxValidator& validator) m_ignoreEvtText = 0; m_text = new wxTextCtrl(this, wxID_ANY, m_valueString, - wxDefaultPosition, wxDefaultSize, + wxDefaultPosition, wxSize(10,-1), style, validator); - - // This is required for some platforms (GTK+ atleast) - m_text->SetSizeHints(2,4); } } void wxComboCtrlBase::OnThemeChange() { - SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); + SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); } wxComboCtrlBase::~wxComboCtrlBase() @@ -1152,6 +1149,26 @@ void wxComboCtrlBase::DoSetToolTip(wxToolTip *tooltip) } #endif // wxUSE_TOOLTIPS +#if wxUSE_VALIDATORS +void wxComboCtrlBase::SetValidator(const wxValidator& validator) +{ + wxTextCtrl* textCtrl = GetTextCtrl(); + + if ( textCtrl ) + textCtrl->SetValidator( validator ); +} + +wxValidator* wxComboCtrlBase::GetValidator() +{ + wxTextCtrl* textCtrl = GetTextCtrl(); + + if ( textCtrl ) + return textCtrl->GetValidator(); + + return wxControl::GetValidator(); +} +#endif // wxUSE_VALIDATORS + // ---------------------------------------------------------------------------- // painting // ---------------------------------------------------------------------------- @@ -1241,7 +1258,7 @@ void wxComboCtrlBase::PrepareBackground( wxDC&, const wxRect&, int ) const } #endif -void wxComboCtrlBase::DrawButton( wxDC& dc, const wxRect& rect, bool paintBg ) +void wxComboCtrlBase::DrawButton( wxDC& dc, const wxRect& rect, int paintBg ) { int drawState = m_btnState; @@ -1580,8 +1597,11 @@ void wxComboCtrlBase::OnFocusEvent( wxFocusEvent& event ) { if ( event.GetEventType() == wxEVT_SET_FOCUS ) { - if ( m_text && m_text != ::wxWindow::FindFocus() ) - m_text->SetFocus(); +#ifndef __WXMAC__ + wxWindow* tc = GetTextCtrl(); + if ( tc && tc != DoFindFocus() ) + tc->SetFocus(); +#endif } Refresh(); @@ -1775,6 +1795,8 @@ void wxComboCtrlBase::ShowPopup() popup = m_popup; } + winPopup->Enable(); + wxASSERT( !m_popup || m_popup == popup ); // Consistency check. wxSize adjustedSize = m_popupInterface->GetAdjustedSize(widthPopup, @@ -1921,20 +1943,13 @@ void wxComboCtrlBase::OnPopupDismiss() if ( IsPopupWindowState(Hidden) ) return; - // NB: Focus setting is really funny, atleast on wxMSW. First of all, - // we need to have SetFocus at the end. Otherwise wxTextCtrl may - // freeze until focus goes somewhere else. Second, wxTreeCtrl as - // popup, when dismissing, "steals" focus back to itself unless - // SetFocus is called also here, exactly before m_popupWinState - // is set to false. Which is truly weird since SetFocus is just - // wxWindowMSW method and does not call event handler or anything like - // that (ie. does not care about m_popupWinState). - - SetFocus(); - - // This should preferably be set before focus. + // This must be set before focus - otherwise there will be recursive + // OnPopupDismisses. m_popupWinState = Hidden; + //SetFocus(); + m_winPopup->Disable(); + // Inform popup control itself m_popupInterface->OnDismiss();