Implement SetForegroundColour and SetBackgroundColour for wxQt
Closes https://github.com/wxWidgets/wxWidgets/pull/1373
This commit is contained in:
committed by
Vadim Zeitlin
parent
9e35bb92c0
commit
e5ba6d9393
@@ -131,6 +131,9 @@ public:
|
|||||||
virtual bool SetTransparent(wxByte alpha) wxOVERRIDE;
|
virtual bool SetTransparent(wxByte alpha) wxOVERRIDE;
|
||||||
virtual bool CanSetTransparent() wxOVERRIDE { return true; }
|
virtual bool CanSetTransparent() wxOVERRIDE { return true; }
|
||||||
|
|
||||||
|
virtual bool SetBackgroundColour(const wxColour& colour) wxOVERRIDE;
|
||||||
|
virtual bool SetForegroundColour(const wxColour& colour) wxOVERRIDE;
|
||||||
|
|
||||||
QWidget *GetHandle() const wxOVERRIDE;
|
QWidget *GetHandle() const wxOVERRIDE;
|
||||||
|
|
||||||
#if wxUSE_DRAG_AND_DROP
|
#if wxUSE_DRAG_AND_DROP
|
||||||
|
@@ -347,8 +347,8 @@ void wxWindowQt::PostCreation(bool generic)
|
|||||||
//
|
//
|
||||||
|
|
||||||
// Set the default color so Paint Event default handler clears the DC:
|
// Set the default color so Paint Event default handler clears the DC:
|
||||||
SetBackgroundColour(wxColour(GetHandle()->palette().background().color()));
|
wxWindowBase::SetBackgroundColour(wxColour(GetHandle()->palette().background().color()));
|
||||||
SetForegroundColour(wxColour(GetHandle()->palette().foreground().color()));
|
wxWindowBase::SetForegroundColour(wxColour(GetHandle()->palette().foreground().color()));
|
||||||
|
|
||||||
GetHandle()->setFont( wxWindowBase::GetFont().GetHandle() );
|
GetHandle()->setFont( wxWindowBase::GetFont().GetHandle() );
|
||||||
|
|
||||||
@@ -1078,6 +1078,42 @@ bool wxWindowQt::SetTransparent(wxByte alpha)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
void wxQtChangeRoleColour(QPalette::ColorRole role,
|
||||||
|
QWidget* widget,
|
||||||
|
const wxColour& colour)
|
||||||
|
{
|
||||||
|
QPalette palette = widget->palette();
|
||||||
|
palette.setColor(role, colour.GetQColor());
|
||||||
|
widget->setPalette(palette);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
|
bool wxWindowQt::SetBackgroundColour(const wxColour& colour)
|
||||||
|
{
|
||||||
|
if ( !wxWindowBase::SetBackgroundColour(colour) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
QWidget *widget = GetHandle();
|
||||||
|
wxQtChangeRoleColour(widget->backgroundRole(), widget, colour);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxWindowQt::SetForegroundColour(const wxColour& colour)
|
||||||
|
{
|
||||||
|
if (!wxWindowBase::SetForegroundColour(colour))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
QWidget *widget = GetHandle();
|
||||||
|
wxQtChangeRoleColour(widget->foregroundRole(), widget, colour);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool wxWindowQt::QtHandlePaintEvent ( QWidget *handler, QPaintEvent *event )
|
bool wxWindowQt::QtHandlePaintEvent ( QWidget *handler, QPaintEvent *event )
|
||||||
{
|
{
|
||||||
/* If this window has scrollbars, only let wx handle the event if it is
|
/* If this window has scrollbars, only let wx handle the event if it is
|
||||||
|
Reference in New Issue
Block a user