Set colours and fonts for all elements of the generic wxSearchCtrl.
Derive generic wxSearchCtrl from wxCompositeWindow<> to ensure that calls to its Set{Fore,Back}groundColour() are propagated to all its children, otherwise they applied only to the composite control itself but not e.g. its text part. Also update the bitmaps when the background colour changes to ensure that it appears as transparent. Closes #13428. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68911 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -191,6 +191,7 @@ public:
|
|||||||
|
|
||||||
// wxWindow overrides
|
// wxWindow overrides
|
||||||
virtual bool SetFont(const wxFont& font);
|
virtual bool SetFont(const wxFont& font);
|
||||||
|
virtual bool SetBackgroundColour(const wxColour& colour);
|
||||||
|
|
||||||
// search control generic only
|
// search control generic only
|
||||||
void SetSearchBitmap( const wxBitmap& bitmap );
|
void SetSearchBitmap( const wxBitmap& bitmap );
|
||||||
@@ -235,6 +236,9 @@ protected:
|
|||||||
private:
|
private:
|
||||||
friend class wxSearchButton;
|
friend class wxSearchButton;
|
||||||
|
|
||||||
|
// Implement pure virtual function inherited from wxCompositeWindow.
|
||||||
|
virtual wxWindowList GetCompositeWindowParts() const;
|
||||||
|
|
||||||
#if wxUSE_MENUS
|
#if wxUSE_MENUS
|
||||||
void PopupSearchMenu();
|
void PopupSearchMenu();
|
||||||
#endif // wxUSE_MENUS
|
#endif // wxUSE_MENUS
|
||||||
|
@@ -26,10 +26,11 @@
|
|||||||
// no native version, use the generic one
|
// no native version, use the generic one
|
||||||
#define wxUSE_NATIVE_SEARCH_CONTROL 0
|
#define wxUSE_NATIVE_SEARCH_CONTROL 0
|
||||||
|
|
||||||
|
#include "wx/compositewin.h"
|
||||||
#include "wx/containr.h"
|
#include "wx/containr.h"
|
||||||
|
|
||||||
class WXDLLIMPEXP_CORE wxSearchCtrlBaseBaseClass
|
class WXDLLIMPEXP_CORE wxSearchCtrlBaseBaseClass
|
||||||
: public wxNavigationEnabled<wxControl>,
|
: public wxCompositeWindow< wxNavigationEnabled<wxControl> >,
|
||||||
public wxTextCtrlIface
|
public wxTextCtrlIface
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
@@ -296,12 +296,7 @@ bool wxSearchCtrl::Create(wxWindow *parent, wxWindowID id,
|
|||||||
m_cancelBitmap);
|
m_cancelBitmap);
|
||||||
|
|
||||||
SetForegroundColour( m_text->GetForegroundColour() );
|
SetForegroundColour( m_text->GetForegroundColour() );
|
||||||
m_searchButton->SetForegroundColour( m_text->GetForegroundColour() );
|
|
||||||
m_cancelButton->SetForegroundColour( m_text->GetForegroundColour() );
|
|
||||||
|
|
||||||
SetBackgroundColour( m_text->GetBackgroundColour() );
|
SetBackgroundColour( m_text->GetBackgroundColour() );
|
||||||
m_searchButton->SetBackgroundColour( m_text->GetBackgroundColour() );
|
|
||||||
m_cancelButton->SetBackgroundColour( m_text->GetBackgroundColour() );
|
|
||||||
|
|
||||||
RecalcBitmaps();
|
RecalcBitmaps();
|
||||||
|
|
||||||
@@ -500,6 +495,14 @@ void wxSearchCtrl::LayoutControls(int x, int y, int width, int height)
|
|||||||
y + ICON_OFFSET - 1, sizeCancel.x, height);
|
y + ICON_OFFSET - 1, sizeCancel.x, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxWindowList wxSearchCtrl::GetCompositeWindowParts() const
|
||||||
|
{
|
||||||
|
wxWindowList parts;
|
||||||
|
parts.push_back(m_text);
|
||||||
|
parts.push_back(m_searchButton);
|
||||||
|
parts.push_back(m_cancelButton);
|
||||||
|
return parts;
|
||||||
|
}
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
// ---------
|
// ---------
|
||||||
@@ -750,13 +753,25 @@ void wxSearchCtrl::SetEditable(bool editable)
|
|||||||
|
|
||||||
bool wxSearchCtrl::SetFont(const wxFont& font)
|
bool wxSearchCtrl::SetFont(const wxFont& font)
|
||||||
{
|
{
|
||||||
bool result = wxSearchCtrlBase::SetFont(font);
|
if ( !wxSearchCtrlBase::SetFont(font) )
|
||||||
if ( result && m_text )
|
return false;
|
||||||
{
|
|
||||||
result = m_text->SetFont(font);
|
// Recreate the bitmaps as their size may have changed.
|
||||||
}
|
|
||||||
RecalcBitmaps();
|
RecalcBitmaps();
|
||||||
return result;
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxSearchCtrl::SetBackgroundColour(const wxColour& colour)
|
||||||
|
{
|
||||||
|
if ( !wxSearchCtrlBase::SetBackgroundColour(colour) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// When the background changes, re-render the bitmaps so that the correct
|
||||||
|
// colour shows in their "transparent" area.
|
||||||
|
RecalcBitmaps();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// search control generic only
|
// search control generic only
|
||||||
|
Reference in New Issue
Block a user