virtual wxString GetString(unsigned int n) const;
virtual void SetString(unsigned int n, const wxString& s);
+ virtual wxVisualAttributes GetDefaultAttributes() const
+ {
+ return GetClassDefaultAttributes(GetWindowVariant());
+ }
+
+ static wxVisualAttributes
+ GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+
// MSW only
virtual bool MSWCommand(WXUINT param, WXWORD id);
WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
// customization
virtual void OnResize();
virtual wxCoord GetNativeTextIndent() const;
- virtual void OnThemeChange();
// event handlers
void OnPaintEvent( wxPaintEvent& event );
// be the correct colour and themed brush. Instead we'll use
// wxSYS_COLOUR_WINDOW in the EVT_PAINT handler as needed.
#ifndef __WXMAC__
+ #if defined(__WXMSW__) || defined(__WXGTK__)
+ wxVisualAttributes vattrs = wxComboBox::GetClassDefaultAttributes();
+ #else
+ wxVisualAttributes vattrs;
+ vattrs.colFg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
+ vattrs.colBg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
+ #endif
+
+ // Only change the colours if application has not specified
+ // custom ones.
+ if ( !m_hasFgCol )
+ {
+ SetOwnForegroundColour(vattrs.colFg);
+ m_hasFgCol = false;
+ }
if ( !m_hasBgCol )
{
- wxColour bgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
- SetOwnBackgroundColour(bgCol);
+ SetOwnBackgroundColour(vattrs.colBg);
m_hasBgCol = false;
}
-#endif
+#endif // !__WXMAC__
}
wxComboCtrlBase::~wxComboCtrlBase()
#ifndef WX_PRECOMP
#include "wx/utils.h"
+ #include "wx/app.h"
#include "wx/log.h"
#include "wx/brush.h"
#include "wx/settings.h"
return msStyle;
}
+#ifndef EP_EDITTEXT
+ #define EP_EDITTEXT 1
+ #define ETS_NORMAL 1
+#endif
+
+wxVisualAttributes
+wxChoice::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+ // it is important to return valid values for all attributes from here,
+ // GetXXX() below rely on this
+ wxVisualAttributes attrs;
+
+ // FIXME: Use better dummy window?
+ wxWindow* wnd = wxTheApp->GetTopWindow();
+
+ attrs.font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
+
+ // there doesn't seem to be any way to get the text colour using themes
+ // API: TMT_TEXTCOLOR doesn't work neither for EDIT nor COMBOBOX
+ attrs.colFg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
+
+ // NB: use EDIT, not COMBOBOX (the latter works in XP but not Vista)
+ attrs.colBg = wnd->MSWGetThemeColour(L"EDIT",
+ EP_EDITTEXT,
+ ETS_NORMAL,
+ ThemeColourBackground,
+ wxSYS_COLOUR_WINDOW);
+
+ return attrs;
+}
+
wxChoice::~wxChoice()
{
Clear();
{
}
-void wxComboCtrl::OnThemeChange()
-{
- // there doesn't seem to be any way to get the text colour using themes
- // API: TMT_TEXTCOLOR doesn't work neither for EDIT nor COMBOBOX
- if ( !m_hasFgCol )
- {
- wxColour fgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
- SetForegroundColour(fgCol);
- m_hasFgCol = false;
- }
-
- // NB: use EDIT, not COMBOBOX (the latter works in XP but not Vista)
- wxColour bgCol = MSWGetThemeColour(L"EDIT",
- EP_EDITTEXT,
- ETS_NORMAL,
- ThemeColourBackground,
- wxSYS_COLOUR_WINDOW);
-
- if ( !m_hasBgCol )
- {
- SetBackgroundColour(bgCol);
- m_hasBgCol = false;
- }
-}
-
void wxComboCtrl::OnResize()
{
//