X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fc7a2a602b4bd9308be21bc07e40a680f483438e..2512ee4ef28558f2fca6409f9b48a57d2fc3c780:/src/msw/notebook.cpp diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index 1fe45847f0..cb9d37a573 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -68,6 +68,16 @@ #include "wx/panel.h" #endif +/* + notebookpage + object + object_ref + label + selected + style + usenotebooksizer +*/ + // ---------------------------------------------------------------------------- // macros // ---------------------------------------------------------------------------- @@ -112,7 +122,20 @@ BEGIN_EVENT_TABLE(wxNotebook, wxControl) EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey) END_EVENT_TABLE() +#if wxUSE_EXTENDED_RTTI +IMPLEMENT_DYNAMIC_CLASS_XTI(wxNotebook, wxControl,"wx/notebook.h") + +WX_BEGIN_PROPERTIES_TABLE(wxNotebook) +WX_END_PROPERTIES_TABLE() + +WX_BEGIN_HANDLERS_TABLE(wxNotebook) +WX_END_HANDLERS_TABLE() + +WX_CONSTRUCTOR_4( wxNotebook , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size ) + +#else IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl) +#endif IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent) // ============================================================================ @@ -424,7 +447,8 @@ wxNotebookPage *wxNotebook::DoRemovePage(int nPage) // for some unknown reason if the tab control shows the up-down // control (i.e. when there are too many pages) -- otherwise after // deleting a page nothing at all is shown - m_pages[m_nSelection]->Refresh(); + if (m_nSelection >= 0) + m_pages[m_nSelection]->Refresh(); } if ( selNew != -1 ) @@ -471,11 +495,21 @@ bool wxNotebook::InsertPage(int nPage, _T("notebook pages must have notebook as parent") ); #if wxUSE_UXTHEME && wxUSE_UXTHEME_AUTO + static bool g_TestedForTheme = FALSE; + static bool g_UseTheme = FALSE; + if (!g_TestedForTheme) + { + int commCtrlVersion = wxTheApp->GetComCtl32Version() ; + + g_UseTheme = (commCtrlVersion >= 600); + g_TestedForTheme = TRUE; + } + // 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))) + if (g_UseTheme && wxUxThemeEngine::Get() && pPage->IsKindOf(CLASSINFO(wxPanel))) { ApplyThemeBackground(pPage, GetThemeBackgroundColour()); } @@ -773,31 +807,36 @@ wxColour wxNotebook::GetThemeBackgroundColour() #if wxUSE_UXTHEME if (wxUxThemeEngine::Get()) { - WXHTHEME hTheme = wxUxThemeEngine::Get()->m_pfnOpenThemeData(GetHWND(), L"TAB"); + wxUxThemeHandle hTheme(this, 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); + wxUxThemeEngine::Get()->GetThemeColor + ( + hTheme, + 10 /* TABP_BODY */, + 1 /* NORMAL */, + 3821, /* FILLCOLORHINT */ + & themeColor + ); wxColour colour(GetRValue(themeColor), GetGValue(themeColor), GetBValue(themeColor)); return colour; } } -#endif +#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 // Don't set the background for buttons since this will @@ -827,10 +866,34 @@ void wxNotebook::ApplyThemeBackground(wxWindow* window, const wxColour& colour) wxWindow *child = node->GetData(); ApplyThemeBackground(child, colour); } -#else - window; - colour; #endif } +long wxNotebook::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) +{ + static bool g_TestedForTheme = FALSE; + static bool g_UseTheme = FALSE; + switch ( nMsg ) + { + case WM_ERASEBKGND: + { + if (!g_TestedForTheme) + { + int commCtrlVersion = wxTheApp->GetComCtl32Version() ; + + g_UseTheme = (commCtrlVersion >= 600); + g_TestedForTheme = TRUE; + } + + // If using XP themes, it seems we can get away + // with not drawing a background, which reduces flicker. + if (g_UseTheme) + return TRUE; + } + } + + return wxControl::MSWWindowProc(nMsg, wParam, lParam); +} + + #endif // wxUSE_NOTEBOOK