-// Windows only: attempts to get colour for UX theme page background
-wxColour wxNotebook::GetThemeBackgroundColour()
-{
-#if wxUSE_UXTHEME
- if (wxUxThemeEngine::Get())
- {
- wxUxThemeHandle hTheme(this, L"TAB");
- if (hTheme)
- {
- // This is total guesswork.
- // See PlatformSDK\Include\Tmschema.h for values
- COLORREF themeColor;
- wxUxThemeEngine::Get()->GetThemeColor(
- hTheme,
- 10 /* TABP_BODY */,
- 1 /* NORMAL */,
- 3821 /* FILLCOLORHINT */,
- &themeColor);
-
- /*
- [DS] Workaround for WindowBlinds:
- Some themes return a near black theme color using FILLCOLORHINT,
- this makes notebook pages have an ugly black background and makes
- text (usually black) unreadable. Retry again with FILLCOLOR.
-
- This workaround potentially breaks appearance of some themes,
- but in practice it already fixes some themes.
- */
- if (themeColor == 1)
- {
- wxUxThemeEngine::Get()->GetThemeColor(
- hTheme,
- 10 /* TABP_BODY */,
- 1 /* NORMAL */,
- 3802 /* FILLCOLOR */,
- &themeColor);
- }
-
- wxColour colour(GetRValue(themeColor), GetGValue(themeColor), GetBValue(themeColor));
- return colour;
- }
- }
-#endif // wxUSE_UXTHEME
-
- return GetBackgroundColour();
-}
-
-// Windows only: attempts to apply the UX theme page background to this page
-#if wxUSE_UXTHEME
-void wxNotebook::ApplyThemeBackground(wxWindow* window, const wxColour& colour)
-#else
-void wxNotebook::ApplyThemeBackground(wxWindow*, const wxColour&)
-#endif
-{
-#if wxUSE_UXTHEME
-
- window->ApplyParentThemeBackground(colour);
-
- for ( wxWindowList::compatibility_iterator node = window->GetChildren().GetFirst(); node; node = node->GetNext() )
- {
- wxWindow *child = node->GetData();
- ApplyThemeBackground(child, colour);
- }
-#endif
-}
-
-#if wxUSE_UXTHEME
-WXLRESULT wxNotebook::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
-{
- static bool g_TestedForTheme = false;
- static bool g_supportsThemes = false;
- switch ( nMsg )
- {
- case WM_ERASEBKGND:
- {
- if (!g_TestedForTheme)
- {
- int commCtrlVersion = wxTheApp->GetComCtl32Version() ;
-
- g_supportsThemes = (commCtrlVersion >= 600);
- g_TestedForTheme = true;
- }
-
- // If currently an XP theme is active, it seems we can get away
- // with not drawing a background, which reduces flicker.
- if (g_supportsThemes)
- {
- wxUxThemeEngine *p = wxUxThemeEngine::Get();
- if (p && p->IsThemeActive() )
- {
- return true;
- }
- }
- }
- }
-
- return wxControl::MSWWindowProc(nMsg, wParam, lParam);
-}
-#endif // #if wxUSE_UXTHEME
-