adjust the rectangle before calling DrawThemeBackground() (patch 1158282)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33005 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -202,13 +202,8 @@ protected:
|
|||||||
void AdjustPageSize(wxNotebookPage *page);
|
void AdjustPageSize(wxNotebookPage *page);
|
||||||
|
|
||||||
#if wxUSE_UXTHEME
|
#if wxUSE_UXTHEME
|
||||||
// this is a slightly ugly function which gets the bitmap of notebook
|
// gets the bitmap of notebook background and returns a brush from it
|
||||||
// background and either returns the colour under the specified window in it
|
WXHBRUSH QueryBgBitmap();
|
||||||
// or creates a brush from it
|
|
||||||
//
|
|
||||||
// so if win == NULL, a brush is created and returned
|
|
||||||
// win != NULL, returns COLORREF of the pixel under its top left corner
|
|
||||||
WXHANDLE QueryBgBitmap(wxWindow *win = NULL);
|
|
||||||
|
|
||||||
// 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();
|
||||||
|
@@ -180,6 +180,23 @@ IMPLEMENT_DYNAMIC_CLASS(wxNotebookPageInfo, wxObject )
|
|||||||
#endif
|
#endif
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent)
|
IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent)
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// local functions
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// apparently DrawThemeBackground() modifies the rect passed to it and if we
|
||||||
|
// don't call this function there are some drawing artifacts which are only
|
||||||
|
// visible with some non default themes; so modify the rect here so that it
|
||||||
|
// still paints the correct area
|
||||||
|
static void AdjustRectForThemeBg(RECT& rc)
|
||||||
|
{
|
||||||
|
// magic numbers needed to compensate for DrawThemeBackground()
|
||||||
|
rc.left -= 2;
|
||||||
|
rc.top -= 2;
|
||||||
|
rc.right += 4;
|
||||||
|
rc.bottom += 5;
|
||||||
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// implementation
|
// implementation
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -945,33 +962,37 @@ void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
|
|||||||
|
|
||||||
#if wxUSE_UXTHEME
|
#if wxUSE_UXTHEME
|
||||||
|
|
||||||
WXHANDLE wxNotebook::QueryBgBitmap(wxWindow *win)
|
WXHBRUSH wxNotebook::QueryBgBitmap()
|
||||||
{
|
{
|
||||||
RECT rc;
|
RECT rc;
|
||||||
GetWindowRect(GetHwnd(), &rc);
|
::GetClientRect(GetHwnd(), &rc);
|
||||||
|
|
||||||
|
// adjust position
|
||||||
|
TabCtrl_AdjustRect(GetHwnd(), false, &rc);
|
||||||
|
|
||||||
WindowHDC hDC(GetHwnd());
|
WindowHDC hDC(GetHwnd());
|
||||||
MemoryHDC hDCMem(hDC);
|
MemoryHDC hDCMem(hDC);
|
||||||
CompatibleBitmap hBmp(hDC, rc.right - rc.left, rc.bottom - rc.top);
|
CompatibleBitmap hBmp(hDC, rc.right, rc.bottom);
|
||||||
|
|
||||||
SelectInHDC selectBmp(hDCMem, hBmp);
|
SelectInHDC selectBmp(hDCMem, hBmp);
|
||||||
|
|
||||||
::SendMessage(GetHwnd(), WM_PRINTCLIENT,
|
wxUxThemeHandle theme(this, L"TAB");
|
||||||
(WPARAM)(HDC)hDCMem,
|
if ( theme )
|
||||||
PRF_ERASEBKGND | PRF_CLIENT | PRF_NONCLIENT);
|
|
||||||
|
|
||||||
if ( win )
|
|
||||||
{
|
{
|
||||||
RECT rc2;
|
AdjustRectForThemeBg(rc);
|
||||||
::GetWindowRect(GetHwndOf(win), &rc2);
|
|
||||||
|
|
||||||
COLORREF c = ::GetPixel(hDCMem, rc2.left - rc.left, rc2.top - rc.top);
|
wxUxThemeEngine::Get()->DrawThemeBackground
|
||||||
|
(
|
||||||
return (WXHANDLE)c;
|
theme,
|
||||||
|
(WXHDC)hDCMem,
|
||||||
|
9 /* TABP_PANE */,
|
||||||
|
0,
|
||||||
|
&rc,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
}
|
}
|
||||||
//else: we are asked to create the brush
|
|
||||||
|
|
||||||
return (WXHANDLE)::CreatePatternBrush(hBmp);
|
return (WXHBRUSH)::CreatePatternBrush(hBmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxNotebook::UpdateBgBrush()
|
void wxNotebook::UpdateBgBrush()
|
||||||
@@ -981,7 +1002,7 @@ void wxNotebook::UpdateBgBrush()
|
|||||||
|
|
||||||
if ( !m_hasBgCol && wxUxThemeEngine::GetIfActive() )
|
if ( !m_hasBgCol && wxUxThemeEngine::GetIfActive() )
|
||||||
{
|
{
|
||||||
m_hbrBackground = (WXHBRUSH)QueryBgBitmap();
|
m_hbrBackground = QueryBgBitmap();
|
||||||
}
|
}
|
||||||
else // no themes
|
else // no themes
|
||||||
{
|
{
|
||||||
@@ -1011,7 +1032,7 @@ WXHBRUSH wxNotebook::MSWGetBgBrushForChild(WXHDC hDC, wxWindow *win)
|
|||||||
return wxNotebookBase::MSWGetBgBrushForChild(hDC, win);
|
return wxNotebookBase::MSWGetBgBrushForChild(hDC, win);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxColour wxNotebook::MSWGetBgColourForChild(wxWindow *win)
|
wxColour wxNotebook::MSWGetBgColourForChild(wxWindow *WXUNUSED(win))
|
||||||
{
|
{
|
||||||
if ( m_hasBgCol )
|
if ( m_hasBgCol )
|
||||||
return GetBackgroundColour();
|
return GetBackgroundColour();
|
||||||
@@ -1030,9 +1051,7 @@ wxColour wxNotebook::MSWGetBgColourForChild(wxWindow *win)
|
|||||||
if ( !wxUxThemeEngine::GetIfActive() )
|
if ( !wxUxThemeEngine::GetIfActive() )
|
||||||
return wxNullColour;
|
return wxNullColour;
|
||||||
|
|
||||||
COLORREF c = (COLORREF)QueryBgBitmap(win);
|
return GetThemeBackgroundColour();
|
||||||
|
|
||||||
return c == CLR_INVALID ? wxNullColour : wxRGBToColour(c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -1040,20 +1059,28 @@ wxNotebook::MSWPrintChild(wxWindow *win,
|
|||||||
WXWPARAM wParam,
|
WXWPARAM wParam,
|
||||||
WXLPARAM WXUNUSED(lParam))
|
WXLPARAM WXUNUSED(lParam))
|
||||||
{
|
{
|
||||||
// Don't paint the theme for the child if we have a solid
|
// Don't paint the theme for the child if we have a solid background
|
||||||
// background
|
if ( m_hasBgCol ||
|
||||||
if (m_hasBgCol || HasFlag(wxNB_NOPAGETHEME) || (wxSystemOptions::HasOption(wxT("msw.notebook.themed-background")) &&
|
wxSystemOptions::IsFalse(wxT("msw.notebook.themed-background")) ||
|
||||||
wxSystemOptions::GetOptionInt(wxT("msw.notebook.themed-background")) == 0))
|
HasFlag(wxNB_NOPAGETHEME) )
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
RECT rc;
|
RECT rc;
|
||||||
::GetClientRect(GetHwnd(), &rc);
|
::GetClientRect(GetHwnd(), &rc);
|
||||||
TabCtrl_AdjustRect(GetHwnd(), true, &rc);
|
|
||||||
::MapWindowPoints(GetHwnd(), GetHwndOf(win), (POINT *)&rc, 2);
|
// adjust position
|
||||||
|
TabCtrl_AdjustRect(GetHwnd(), false, &rc);
|
||||||
|
|
||||||
wxUxThemeHandle theme(win, L"TAB");
|
wxUxThemeHandle theme(win, L"TAB");
|
||||||
if ( theme )
|
if ( theme )
|
||||||
{
|
{
|
||||||
|
// map from this client to win client coords
|
||||||
|
::MapWindowPoints(GetHwnd(), GetHwndOf(win), (POINT *)&rc, 2);
|
||||||
|
|
||||||
|
AdjustRectForThemeBg(rc);
|
||||||
wxUxThemeEngine::Get()->DrawThemeBackground
|
wxUxThemeEngine::Get()->DrawThemeBackground
|
||||||
(
|
(
|
||||||
theme,
|
theme,
|
||||||
|
Reference in New Issue
Block a user