diff --git a/docs/changes.txt b/docs/changes.txt index be4c96f4bf..225685dbc2 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -130,6 +130,7 @@ wxMSW: - Support MSVC auto-linking when using monolithic build too (PB). - Implement wxFontDialog::SetTitle() (Vitaly Stakhovsky). - Fix build in ANSI (non-Unicode) mode. +- Improve wxNotebook themed background drawing (Arrigo Marchiori). wxOSX: diff --git a/include/wx/msw/notebook.h b/include/wx/msw/notebook.h index 8920b936bd..316f1d0338 100644 --- a/include/wx/msw/notebook.h +++ b/include/wx/msw/notebook.h @@ -170,10 +170,17 @@ protected: void AdjustPageSize(wxNotebookPage *page); #if wxUSE_UXTHEME + virtual void MSWAdjustBrushOrg(int *xOrg, int* yOrg) const wxOVERRIDE + { + *xOrg -= m_bgBrushAdj.x; + *yOrg -= m_bgBrushAdj.y; + } + // return the themed brush for painting our children virtual WXHBRUSH MSWGetCustomBgBrush() wxOVERRIDE { return m_hbrBackground; } - // gets the bitmap of notebook background and returns a brush from it + // gets the bitmap of notebook background and returns a brush from it and + // sets m_bgBrushAdj WXHBRUSH QueryBgBitmap(); // creates the brush to be used for drawing the tab control background @@ -190,6 +197,9 @@ protected: #if wxUSE_UXTHEME // background brush used to paint the tab control WXHBRUSH m_hbrBackground; + + // offset for MSWAdjustBrushOrg() + wxPoint m_bgBrushAdj; #endif // wxUSE_UXTHEME diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index 21d3f7ab69..7f0565225b 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -1095,30 +1095,40 @@ void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event) WXHBRUSH wxNotebook::QueryBgBitmap() { - wxRect r = GetPageSize(); - if ( r.IsEmpty() ) + RECT rc; + ::GetClientRect(GetHwnd(), &rc); + if ( ::IsRectEmpty(&rc) ) return 0; wxUxThemeHandle theme(this, L"TAB"); if ( !theme ) return 0; - RECT rc; - wxCopyRectToRECT(r, rc); - WindowHDC hDC(GetHwnd()); + + RECT rcBg; + ::GetThemeBackgroundContentRect(theme, + (HDC) hDC, + 9, /* TABP_PANE */ + 0, + &rc, + &rcBg); + + m_bgBrushAdj = wxPoint(rcBg.left, rcBg.top); + ::OffsetRect(&rcBg, -rcBg.left, -rcBg.top); + ::GetThemeBackgroundExtent ( theme, (HDC) hDC, 9 /* TABP_PANE */, 0, - &rc, + &rcBg, &rc ); MemoryHDC hDCMem(hDC); - CompatibleBitmap hBmp(hDC, rc.right, rc.bottom); + CompatibleBitmap hBmp(hDC, rcBg.right, rcBg.bottom); { SelectInHDC selectBmp(hDCMem, hBmp);