allow setting window font and bg/fg color before creation

wxMSW and wxOSX don't have a problem with it, so neither should wxGTK

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73360 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Paul Cornett
2013-01-10 06:53:14 +00:00
parent b387025d5d
commit 92ef38ee6b

View File

@@ -2020,6 +2020,8 @@ void wxWindowGTK::GTKHandleRealized()
} }
#endif #endif
GTKApplyWidgetStyle();
wxWindowCreateEvent event(static_cast<wxWindow*>(this)); wxWindowCreateEvent event(static_cast<wxWindow*>(this));
event.SetEventObject( this ); event.SetEventObject( this );
GTKProcessEvent( event ); GTKProcessEvent( event );
@@ -4009,46 +4011,46 @@ void wxWindowGTK::GTKApplyToolTip(const char* tip)
bool wxWindowGTK::SetBackgroundColour( const wxColour &colour ) bool wxWindowGTK::SetBackgroundColour( const wxColour &colour )
{ {
wxCHECK_MSG( m_widget != NULL, false, wxT("invalid window") );
if (!wxWindowBase::SetBackgroundColour(colour)) if (!wxWindowBase::SetBackgroundColour(colour))
return false; return false;
#ifndef __WXGTK3__ if (m_widget)
if (colour.IsOk())
{ {
// We need the pixel value e.g. for background clearing. #ifndef __WXGTK3__
m_backgroundColour.CalcPixel(gtk_widget_get_colormap(m_widget)); if (colour.IsOk())
} {
// We need the pixel value e.g. for background clearing.
m_backgroundColour.CalcPixel(gtk_widget_get_colormap(m_widget));
}
#endif #endif
// apply style change (forceStyle=true so that new style is applied // apply style change (forceStyle=true so that new style is applied
// even if the bg colour changed from valid to wxNullColour) // even if the bg colour changed from valid to wxNullColour)
GTKApplyWidgetStyle(true); GTKApplyWidgetStyle(true);
}
return true; return true;
} }
bool wxWindowGTK::SetForegroundColour( const wxColour &colour ) bool wxWindowGTK::SetForegroundColour( const wxColour &colour )
{ {
wxCHECK_MSG( m_widget != NULL, false, wxT("invalid window") );
if (!wxWindowBase::SetForegroundColour(colour)) if (!wxWindowBase::SetForegroundColour(colour))
{
return false; return false;
}
#ifndef __WXGTK3__ if (m_widget)
if (colour.IsOk())
{ {
// We need the pixel value e.g. for background clearing. #ifndef __WXGTK3__
m_foregroundColour.CalcPixel(gtk_widget_get_colormap(m_widget)); if (colour.IsOk())
} {
// We need the pixel value e.g. for background clearing.
m_foregroundColour.CalcPixel(gtk_widget_get_colormap(m_widget));
}
#endif #endif
// apply style change (forceStyle=true so that new style is applied // apply style change (forceStyle=true so that new style is applied
// even if the bg colour changed from valid to wxNullColour): // even if the bg colour changed from valid to wxNullColour):
GTKApplyWidgetStyle(true); GTKApplyWidgetStyle(true);
}
return true; return true;
} }
@@ -4390,14 +4392,15 @@ GdkWindow *wxWindowGTK::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
bool wxWindowGTK::SetFont( const wxFont &font ) bool wxWindowGTK::SetFont( const wxFont &font )
{ {
wxCHECK_MSG( m_widget != NULL, false, wxT("invalid window") );
if (!wxWindowBase::SetFont(font)) if (!wxWindowBase::SetFont(font))
return false; return false;
// apply style change (forceStyle=true so that new style is applied if (m_widget)
// even if the font changed from valid to wxNullFont): {
GTKApplyWidgetStyle(true); // apply style change (forceStyle=true so that new style is applied
// even if the font changed from valid to wxNullFont):
GTKApplyWidgetStyle(true);
}
return true; return true;
} }