X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7fc1b0c7ca306b37779b9238dc992e310dded381..0a9c5e3564ed35162bb8cab5af62a98405364fb8:/src/msw/choice.cpp?ds=sidebyside diff --git a/src/msw/choice.cpp b/src/msw/choice.cpp index 5abb57a2c5..8abdba2c70 100644 --- a/src/msw/choice.cpp +++ b/src/msw/choice.cpp @@ -30,6 +30,7 @@ #ifndef WX_PRECOMP #include "wx/utils.h" + #include "wx/app.h" #include "wx/log.h" #include "wx/brush.h" #include "wx/settings.h" @@ -142,10 +143,6 @@ bool wxChoice::CreateAndInit(wxWindow *parent, return false; - // choice/combobox normally has "white" (depends on colour scheme, of - // course) background rather than inheriting the parent's background - SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); - // initialize the controls contents for ( int i = 0; i < n; i++ ) { @@ -224,6 +221,39 @@ WXDWORD wxChoice::MSWGetStyle(long style, WXDWORD *exstyle) const 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(); + if (!wnd) + return attrs; + + 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(); @@ -523,8 +553,21 @@ void wxChoice::DoSetSize(int x, int y, int width, int height, int sizeFlags) { + const int heightBest = GetBestSize().y; + // we need the real height below so get the current one if it's not given - if ( height != wxDefaultCoord && height != GetBestSize().y ) + if ( height == wxDefaultCoord ) + { + // height not specified, use the same as before + DoGetSize(NULL, &height); + } + else if ( height == heightBest ) + { + // we don't need to manually manage our height, let the system use the + // default one + m_heightOwn = wxDefaultCoord; + } + else // non-default height specified { // set our new own height but be careful not to make it too big: the // native control apparently stores it as a single byte and so setting @@ -538,10 +581,6 @@ void wxChoice::DoSetSize(int x, int y, else if ( m_heightOwn < COMBO_HEIGHT_ADJ ) m_heightOwn = COMBO_HEIGHT_ADJ; } - else // height not specified - { - DoGetSize(NULL, &height); - } // the height which we must pass to Windows should be the total height of