Attempt to make wxWindows play better with XP themes

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20852 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2003-06-02 10:27:03 +00:00
parent 73bab6b44d
commit 85b43fbf7a
17 changed files with 291 additions and 82 deletions

View File

@@ -50,6 +50,23 @@
#include <commctrl.h>
#endif
#include "wx/msw/winundef.h"
#if wxUSE_UXTHEME
#include "wx/msw/uxtheme.h"
#include "wx/radiobut.h"
#include "wx/radiobox.h"
#include "wx/checkbox.h"
#include "wx/bmpbuttn.h"
#include "wx/statline.h"
#include "wx/statbox.h"
#include "wx/stattext.h"
#include "wx/slider.h"
#include "wx/scrolwin.h"
#include "wx/panel.h"
#endif
// ----------------------------------------------------------------------------
// macros
// ----------------------------------------------------------------------------
@@ -439,6 +456,17 @@ bool wxNotebook::InsertPage(int nPage,
wxASSERT_MSG( pPage->GetParent() == this,
_T("notebook pages must have notebook as parent") );
#if wxUSE_UXTHEME && wxUSE_UXTHEME_AUTO
// Automatically apply the theme background,
// changing the colour of the panel to match the
// tab page colour. This won't work well with all
// themes but it's a start.
if (wxUxThemeEngine::Get() && pPage->IsKindOf(CLASSINFO(wxPanel)))
{
ApplyThemeBackground(pPage, GetThemeBackgroundColour());
}
#endif
// add a new tab to the control
// ----------------------------
@@ -719,4 +747,67 @@ bool wxNotebook::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM* result)
return processed;
}
// Windows only: attempts to get colour for UX theme page background
wxColour wxNotebook::GetThemeBackgroundColour()
{
#if wxUSE_UXTHEME
if (wxUxThemeEngine::Get())
{
WXHTHEME hTheme = wxUxThemeEngine::Get()->m_pfnOpenThemeData(GetHWND(), L"TAB");
if (hTheme)
{
// This is total guesswork.
// See PlatformSDK\Include\Tmschema.h for values
COLORREF themeColor;
wxUxThemeEngine::Get()->
m_pfnGetThemeColor(hTheme,
10 /* TABP_BODY */,
1 /* NORMAL */,
3821, /* FILLCOLORHINT */
& themeColor);
wxUxThemeEngine::Get()->m_pfnCloseThemeData(hTheme);
wxColour colour(GetRValue(themeColor), GetGValue(themeColor), GetBValue(themeColor));
return colour;
}
}
#endif
return GetBackgroundColour();
}
// Windows only: attempts to apply the UX theme page background to this page
void wxNotebook::ApplyThemeBackground(wxWindow* window, const wxColour& colour)
{
#if wxUSE_UXTHEME
// Don't set the background for buttons since this will
// switch it into ownerdraw mode
if (window->IsKindOf(CLASSINFO(wxButton)) && !window->IsKindOf(CLASSINFO(wxBitmapButton)))
// This is essential, otherwise you'll see dark grey
// corners in the buttons.
((wxButton*)window)->wxControl::SetBackgroundColour(colour);
else if (window->IsKindOf(CLASSINFO(wxStaticText)) ||
window->IsKindOf(CLASSINFO(wxStaticBox)) ||
window->IsKindOf(CLASSINFO(wxStaticLine)) ||
window->IsKindOf(CLASSINFO(wxRadioButton)) ||
window->IsKindOf(CLASSINFO(wxRadioBox)) ||
window->IsKindOf(CLASSINFO(wxCheckBox)) ||
window->IsKindOf(CLASSINFO(wxBitmapButton)) ||
window->IsKindOf(CLASSINFO(wxSlider)) ||
window->IsKindOf(CLASSINFO(wxPanel)) ||
(window->IsKindOf(CLASSINFO(wxNotebook)) && (window != this)) ||
window->IsKindOf(CLASSINFO(wxScrolledWindow))
)
{
window->SetBackgroundColour(colour);
}
for ( wxWindowList::Node *node = window->GetChildren().GetFirst(); node; node = node->GetNext() )
{
wxWindow *child = node->GetData();
ApplyThemeBackground(child, colour);
}
#endif
}
#endif // wxUSE_NOTEBOOK