+ // On Smartphone/PocketPC, wxSYS_COLOUR_WINDOW is a better reflection of
+ // the usual background colour than wxSYS_COLOUR_BTNFACE.
+ // It's a pity that wxSYS_COLOUR_WINDOW isn't always a suitable background
+ // colour on other platforms.
+
+#if defined(__WXWINCE__) && (defined(__SMARTPHONE__) || defined(__POCKETPC__))
+ attrs.colBg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
+#else
+ attrs.colBg = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE);
+#endif
+ return attrs;
+}
+
+wxColour wxWindowBase::GetBackgroundColour() const
+{
+ if ( !m_backgroundColour.Ok() )
+ {
+ wxASSERT_MSG( !m_hasBgCol, _T("we have invalid explicit bg colour?") );
+
+ // get our default background colour
+ wxColour colBg = GetDefaultAttributes().colBg;
+
+ // we must return some valid colour to avoid redoing this every time
+ // and also to avoid surprizing the applications written for older
+ // wxWidgets versions where GetBackgroundColour() always returned
+ // something -- so give them something even if it doesn't make sense
+ // for this window (e.g. it has a themed background)
+ if ( !colBg.Ok() )
+ colBg = GetClassDefaultAttributes().colBg;
+
+ return colBg;
+ }
+ else
+ return m_backgroundColour;
+}
+
+wxColour wxWindowBase::GetForegroundColour() const
+{
+ // logic is the same as above
+ if ( !m_hasFgCol && !m_foregroundColour.Ok() )
+ {
+ wxASSERT_MSG( !m_hasFgCol, _T("we have invalid explicit fg colour?") );
+
+ wxColour colFg = GetDefaultAttributes().colFg;
+
+ if ( !colFg.Ok() )
+ colFg = GetClassDefaultAttributes().colFg;
+
+ return colFg;
+ }
+ else
+ return m_foregroundColour;
+}
+
+bool wxWindowBase::SetBackgroundColour( const wxColour &colour )
+{
+ if ( colour == m_backgroundColour )
+ return false;
+
+ m_hasBgCol = colour.Ok();
+ if ( m_backgroundStyle != wxBG_STYLE_CUSTOM )
+ m_backgroundStyle = m_hasBgCol ? wxBG_STYLE_COLOUR : wxBG_STYLE_SYSTEM;
+
+ m_inheritBgCol = m_hasBgCol;
+ m_backgroundColour = colour;
+ SetThemeEnabled( !m_hasBgCol && !m_foregroundColour.Ok() );
+ return true;
+}