Skip to content

Commit

Permalink
Revert making wxComboCtrl a wxCompositeWindow
Browse files Browse the repository at this point in the history
Commit 70e9dbd has fixed #18394 but unfortunately it also caused several other issues observed e.g. in #18540. Apparently wxComboCtrl doesn't fit well to the wxCompositeWindow framework -  especially when wxCB_READONLY flag is set and there is no main editor control what is problematic for wxCompositeWindow implementation. At the moment it is more pragmatic to go back to the original wxComboCtrl concept as a plain compound control to fix the regression and try to fix #18394 in an alternative way.

Closes #18540.
See #18394.
  • Loading branch information
a-wi committed Nov 8, 2019
1 parent 79794cd commit 6b00cc8
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 15 deletions.
12 changes: 7 additions & 5 deletions include/wx/combo.h
Expand Up @@ -46,7 +46,6 @@
#include "wx/bitmap.h" // wxBitmap used by-value
#include "wx/textentry.h"
#include "wx/time.h" // needed for wxMilliClock_t
#include "wx/compositewin.h" // wxComboCtrlBase declaration

class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
class WXDLLIMPEXP_FWD_CORE wxComboPopup;
Expand Down Expand Up @@ -141,14 +140,14 @@ struct wxComboCtrlFeatures
};


class WXDLLIMPEXP_CORE wxComboCtrlBase : public wxCompositeWindow<wxControl>,
class WXDLLIMPEXP_CORE wxComboCtrlBase : public wxControl,
public wxTextEntry
{
friend class wxComboPopup;
friend class wxComboPopupEvtHandler;
public:
// ctors and such
wxComboCtrlBase() : wxCompositeWindow<wxControl>(), wxTextEntry() { Init(); }
wxComboCtrlBase() : wxControl(), wxTextEntry() { Init(); }

bool Create(wxWindow *parent,
wxWindowID id,
Expand Down Expand Up @@ -473,6 +472,7 @@ class WXDLLIMPEXP_CORE wxComboCtrlBase : public wxCompositeWindow<wxControl>,
{ return m_mainCtrlWnd; }

// also set the embedded wxTextCtrl colours
virtual bool SetForegroundColour(const wxColour& colour) wxOVERRIDE;
virtual bool SetBackgroundColour(const wxColour& colour) wxOVERRIDE;

protected:
Expand Down Expand Up @@ -598,6 +598,10 @@ class WXDLLIMPEXP_CORE wxComboCtrlBase : public wxCompositeWindow<wxControl>,
// Flags are same as for DoShowPopup.
virtual bool AnimateShow( const wxRect& rect, int flags );

#if wxUSE_TOOLTIPS
virtual void DoSetToolTip( wxToolTip *tip ) wxOVERRIDE;
#endif

// protected wxTextEntry methods
virtual void DoSetValue(const wxString& value, int flags) wxOVERRIDE;
virtual wxString DoGetValue() const wxOVERRIDE;
Expand All @@ -607,8 +611,6 @@ class WXDLLIMPEXP_CORE wxComboCtrlBase : public wxCompositeWindow<wxControl>,
virtual bool DoSetMargins(const wxPoint& pt) wxOVERRIDE;
virtual wxPoint DoGetMargins() const wxOVERRIDE;

virtual wxWindowList GetCompositeWindowParts() const wxOVERRIDE;

// This is used when m_text is hidden (readonly).
wxString m_valueString;

Expand Down
41 changes: 31 additions & 10 deletions src/common/combocmn.cpp
Expand Up @@ -1535,6 +1535,37 @@ bool wxComboCtrlBase::SetFont ( const wxFont& font )
return true;
}

#if wxUSE_TOOLTIPS
void wxComboCtrlBase::DoSetToolTip(wxToolTip *tooltip)
{
wxControl::DoSetToolTip(tooltip);

// Set tool tip for button and text box
if ( tooltip )
{
const wxString &tip = tooltip->GetTip();
if ( m_text ) m_text->SetToolTip(tip);
if ( m_btn ) m_btn->SetToolTip(tip);
}
else
{
if ( m_text ) m_text->SetToolTip( NULL );
if ( m_btn ) m_btn->SetToolTip( NULL );
}
}
#endif // wxUSE_TOOLTIPS

bool wxComboCtrlBase::SetForegroundColour(const wxColour& colour)
{
if ( wxControl::SetForegroundColour(colour) )
{
if ( m_text )
m_text->SetForegroundColour(colour);
return true;
}
return false;
}

bool wxComboCtrlBase::SetBackgroundColour(const wxColour& colour)
{
if ( m_text )
Expand Down Expand Up @@ -2717,16 +2748,6 @@ void wxComboCtrlBase::SetTextCtrlStyle( int style )
m_text->SetWindowStyle(style);
}

wxWindowList wxComboCtrlBase::GetCompositeWindowParts() const
{
wxWindowList parts;
if ( m_text )
parts.push_back(m_text);
if ( m_btn )
parts.push_back(m_btn);
return parts;
}

// ----------------------------------------------------------------------------
// wxTextEntry interface
// ----------------------------------------------------------------------------
Expand Down

0 comments on commit 6b00cc8

Please sign in to comment.