Refactor: remove wxNotebook::DoDrawBackground() in wxMSW
The code in QueryBgBitmap() and MSWPrintChild() is sufficiently different that we can't easily reuse the drawing calls between them, so don't tie ourselves in knots trying to do it, just duplicating these 2 calls in the 2 functions is not that bad and the code is more clear. No real changes.
This commit is contained in:
@@ -178,11 +178,6 @@ protected:
|
|||||||
|
|
||||||
// creates the brush to be used for drawing the tab control background
|
// creates the brush to be used for drawing the tab control background
|
||||||
void UpdateBgBrush();
|
void UpdateBgBrush();
|
||||||
|
|
||||||
// common part of QueryBgBitmap() and MSWPrintChild()
|
|
||||||
//
|
|
||||||
// if child == NULL, draw background for the entire notebook itself
|
|
||||||
bool DoDrawBackground(WXHDC hDC, wxWindow *child = NULL);
|
|
||||||
#endif // wxUSE_UXTHEME
|
#endif // wxUSE_UXTHEME
|
||||||
|
|
||||||
// these function are used for reducing flicker on notebook resize
|
// these function are used for reducing flicker on notebook resize
|
||||||
|
@@ -1102,49 +1102,6 @@ void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
|
|||||||
|
|
||||||
#if wxUSE_UXTHEME
|
#if wxUSE_UXTHEME
|
||||||
|
|
||||||
bool wxNotebook::DoDrawBackground(WXHDC hDC, wxWindow *child)
|
|
||||||
{
|
|
||||||
wxUxThemeHandle theme(child ? child : this, L"TAB");
|
|
||||||
if ( !theme )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// get the notebook client rect (we're not interested in drawing tabs
|
|
||||||
// themselves)
|
|
||||||
wxRect r = GetPageSize();
|
|
||||||
if ( r.IsEmpty() )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
RECT rc;
|
|
||||||
wxCopyRectToRECT(r, rc);
|
|
||||||
|
|
||||||
// map rect to the coords of the window we're drawing in
|
|
||||||
if ( child )
|
|
||||||
::MapWindowPoints(GetHwnd(), GetHwndOf(child), (POINT *)&rc, 2);
|
|
||||||
|
|
||||||
// we have the content area (page size), but we need to draw all of the
|
|
||||||
// background for it to be aligned correctly
|
|
||||||
wxUxThemeEngine::Get()->GetThemeBackgroundExtent
|
|
||||||
(
|
|
||||||
theme,
|
|
||||||
(HDC) hDC,
|
|
||||||
9 /* TABP_PANE */,
|
|
||||||
0,
|
|
||||||
&rc,
|
|
||||||
&rc
|
|
||||||
);
|
|
||||||
wxUxThemeEngine::Get()->DrawThemeBackground
|
|
||||||
(
|
|
||||||
theme,
|
|
||||||
(HDC) hDC,
|
|
||||||
9 /* TABP_PANE */,
|
|
||||||
0,
|
|
||||||
&rc,
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
WXHBRUSH wxNotebook::QueryBgBitmap()
|
WXHBRUSH wxNotebook::QueryBgBitmap()
|
||||||
{
|
{
|
||||||
wxRect r = GetPageSize();
|
wxRect r = GetPageSize();
|
||||||
@@ -1172,10 +1129,18 @@ WXHBRUSH wxNotebook::QueryBgBitmap()
|
|||||||
MemoryHDC hDCMem(hDC);
|
MemoryHDC hDCMem(hDC);
|
||||||
CompatibleBitmap hBmp(hDC, rc.right, rc.bottom);
|
CompatibleBitmap hBmp(hDC, rc.right, rc.bottom);
|
||||||
|
|
||||||
|
{
|
||||||
SelectInHDC selectBmp(hDCMem, hBmp);
|
SelectInHDC selectBmp(hDCMem, hBmp);
|
||||||
|
wxUxThemeEngine::Get()->DrawThemeBackground
|
||||||
if ( !DoDrawBackground((WXHDC)(HDC)hDCMem) )
|
(
|
||||||
return 0;
|
theme,
|
||||||
|
hDCMem,
|
||||||
|
9 /* TABP_PANE */,
|
||||||
|
0,
|
||||||
|
&rc,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
} // deselect bitmap from the memory HDC before using it
|
||||||
|
|
||||||
return (WXHBRUSH)::CreatePatternBrush(hBmp);
|
return (WXHBRUSH)::CreatePatternBrush(hBmp);
|
||||||
}
|
}
|
||||||
@@ -1197,15 +1162,7 @@ void wxNotebook::UpdateBgBrush()
|
|||||||
|
|
||||||
bool wxNotebook::MSWPrintChild(WXHDC hDC, wxWindow *child)
|
bool wxNotebook::MSWPrintChild(WXHDC hDC, wxWindow *child)
|
||||||
{
|
{
|
||||||
// solid background colour overrides themed background drawing
|
const wxRect r = GetPageSize();
|
||||||
if ( !UseBgCol() && DoDrawBackground(hDC, child) )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// If we're using a solid colour (for example if we've switched off
|
|
||||||
// theming for this notebook), paint it
|
|
||||||
if (UseBgCol())
|
|
||||||
{
|
|
||||||
wxRect r = GetPageSize();
|
|
||||||
if ( r.IsEmpty() )
|
if ( r.IsEmpty() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -1216,6 +1173,10 @@ bool wxNotebook::MSWPrintChild(WXHDC hDC, wxWindow *child)
|
|||||||
if ( child )
|
if ( child )
|
||||||
::MapWindowPoints(GetHwnd(), GetHwndOf(child), (POINT *)&rc, 2);
|
::MapWindowPoints(GetHwnd(), GetHwndOf(child), (POINT *)&rc, 2);
|
||||||
|
|
||||||
|
// If we're using a solid colour (for example if we've switched off
|
||||||
|
// theming for this notebook), paint it
|
||||||
|
if (UseBgCol())
|
||||||
|
{
|
||||||
wxBrush brush(GetBackgroundColour());
|
wxBrush brush(GetBackgroundColour());
|
||||||
HBRUSH hbr = GetHbrushOf(brush);
|
HBRUSH hbr = GetHbrushOf(brush);
|
||||||
|
|
||||||
@@ -1223,6 +1184,34 @@ bool wxNotebook::MSWPrintChild(WXHDC hDC, wxWindow *child)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else // No solid background colour, try to use themed background.
|
||||||
|
{
|
||||||
|
wxUxThemeHandle theme(child, L"TAB");
|
||||||
|
if ( theme )
|
||||||
|
{
|
||||||
|
// we have the content area (page size), but we need to draw all of the
|
||||||
|
// background for it to be aligned correctly
|
||||||
|
wxUxThemeEngine::Get()->GetThemeBackgroundExtent
|
||||||
|
(
|
||||||
|
theme,
|
||||||
|
(HDC) hDC,
|
||||||
|
9 /* TABP_PANE */,
|
||||||
|
0,
|
||||||
|
&rc,
|
||||||
|
&rc
|
||||||
|
);
|
||||||
|
wxUxThemeEngine::Get()->DrawThemeBackground
|
||||||
|
(
|
||||||
|
theme,
|
||||||
|
(HDC) hDC,
|
||||||
|
9 /* TABP_PANE */,
|
||||||
|
0,
|
||||||
|
&rc,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return wxNotebookBase::MSWPrintChild(hDC, child);
|
return wxNotebookBase::MSWPrintChild(hDC, child);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user