// wxWidgets
#ifndef WX_PRECOMP
#include "wx/string.h"
+ #include "wx/dc.h"
#endif // WX_PRECOMP
#include "wx/log.h"
#include "wx/msw/private.h"
-// Windows standard headers
-#ifndef __WIN95__
- #error "wxNotebook is only supported Windows 95 and above"
-#endif //Win95
-
-#include <windowsx.h> // for SetWindowFont
+#include <windowsx.h>
#ifdef __GNUWIN32_OLD__
#include "wx/msw/gnuwin32/extra.h"
#endif
-#if defined(__WIN95__) && !(defined(__GNUWIN32_OLD__) && !defined(__CYGWIN10__))
+#if !(defined(__GNUWIN32_OLD__) && !defined(__CYGWIN10__))
#include <commctrl.h>
#endif
long style,
const wxString& name)
{
- // Does ComCtl32 support non-top tabs?
- int verComCtl32 = wxApp::GetComCtl32Version();
- if ( verComCtl32 < 470 || verComCtl32 >= 600 )
+ // comctl32.dll 6.0 doesn't support non-top tabs with visual styles (the
+ // control is simply not rendered correctly), so disable them in this case
+ const int verComCtl32 = wxApp::GetComCtl32Version();
+ if ( verComCtl32 == 600 )
{
- if (style & wxNB_BOTTOM)
- style &= ~wxNB_BOTTOM;
-
- if (style & wxNB_LEFT)
- style &= ~wxNB_LEFT;
-
- if (style & wxNB_RIGHT)
- style &= ~wxNB_RIGHT;
+ // check if we use themes at all -- if we don't, we're still ok
+#if wxUSE_UXTHEME
+ if ( wxUxThemeEngine::GetIfActive() )
+#endif
+ {
+ style &= ~(wxNB_BOTTOM | wxNB_LEFT | wxNB_RIGHT);
+ }
}
if ( !CreateControl(parent, id, pos, size, style | wxTAB_TRAVERSAL,
void wxNotebook::OnSize(wxSizeEvent& event)
{
+#if wxUSE_UXTHEME
+ UpdateBgBrush();
+#endif // wxUSE_UXTHEME
+
// fit the notebook page to the tab control's display area
RECT rc;
rc.left = rc.top = 0;
pPage->SetSize(rc.left, rc.top, width, height);
}
-#if wxUSE_UXTHEME
- UpdateBgBrush();
-#endif // wxUSE_UXTHEME
-
event.Skip();
}
#if wxUSE_UXTHEME
-void wxNotebook::UpdateBgBrush()
+WXHANDLE wxNotebook::QueryBgBitmap(wxWindow *win)
{
- if ( m_hbrBackground )
- ::DeleteObject((HBRUSH)m_hbrBackground);
+ RECT rc;
+ GetWindowRect(GetHwnd(), &rc);
+
+ WindowHDC hDC(GetHwnd());
+ MemoryHDC hDCMem(hDC);
+ CompatibleBitmap hBmp(hDC, rc.right - rc.left, rc.bottom - rc.top);
- if ( wxUxThemeEngine::GetIfActive() )
+ SelectInHDC selectBmp(hDCMem, hBmp);
+
+ ::SendMessage(GetHwnd(), WM_PRINTCLIENT,
+ (WPARAM)(HDC)hDCMem,
+ PRF_ERASEBKGND | PRF_CLIENT | PRF_NONCLIENT);
+
+ if ( win )
{
- RECT rc;
- GetWindowRect(GetHwnd(), &rc);
+ RECT rc2;
+ ::GetWindowRect(GetHwndOf(win), &rc2);
- WindowHDC hDC(GetHwnd());
- MemoryHDC hDCMem(hDC);
- CompatibleBitmap hBmp(hDC, rc.right - rc.left, rc.bottom - rc.top);
+ COLORREF c = ::GetPixel(hDCMem, rc2.left - rc.left, rc2.top - rc.top);
- SelectInHDC selectBmp(hDCMem, hBmp);
+ return (WXHANDLE)c;
+ }
+ else // we are asked to create the brush
+ {
+ return (WXHANDLE)::CreatePatternBrush(hBmp);
+ }
+}
- SendMessage(GetHwnd(), WM_PRINTCLIENT, (WPARAM)(HDC)hDCMem,
- PRF_ERASEBKGND | PRF_CLIENT | PRF_NONCLIENT);
+void wxNotebook::UpdateBgBrush()
+{
+ if ( m_hbrBackground )
+ ::DeleteObject((HBRUSH)m_hbrBackground);
- m_hbrBackground = (WXHBRUSH)::CreatePatternBrush(hBmp);
+ if ( !m_hasBgCol && wxUxThemeEngine::GetIfActive() )
+ {
+ m_hbrBackground = (WXHBRUSH)QueryBgBitmap();
}
else // no themes
{
}
}
-void wxNotebook::DoEraseBackground(wxEraseEvent& event)
+WXHBRUSH wxNotebook::MSWGetBgBrushForChild(WXHDC hDC, wxWindow *win)
{
- // we can either draw the background ourselves or let DrawThemeBackground()
- // do it, but as we already have the correct brush, let's do it ourselves
- // (note that we use the same code in wxControl::MSWControlColor(), so if
- // it breaks, it should at least break in consistent way)
if ( m_hbrBackground )
{
// before drawing with the background brush, we need to position it
// correctly
- wxWindow *win = (wxWindow *)event.GetEventObject();
-
RECT rc;
::GetWindowRect(GetHwndOf(win), &rc);
::MapWindowPoints(NULL, GetHwnd(), (POINT *)&rc, 1);
- HDC hdc = GetHdcOf(*event.GetDC());
- if ( !::SetBrushOrgEx(hdc, -rc.left, -rc.top, NULL) )
+ if ( !::SetBrushOrgEx((HDC)hDC, -rc.left, -rc.top, NULL) )
{
wxLogLastError(_T("SetBrushOrgEx(notebook bg brush)"));
}
- RECT rectClient;
- ::GetClientRect(GetHwndOf(win), &rectClient);
- ::FillRect(hdc, &rectClient, (HBRUSH)m_hbrBackground);
+ return m_hbrBackground;
}
+
+ return wxNotebookBase::MSWGetBgBrushForChild(hDC, win);
+}
+
+wxColour wxNotebook::MSWGetBgColourForChild(wxWindow *win)
+{
+ if ( m_hasBgCol )
+ return GetBackgroundColour();
+
+ if ( !wxUxThemeEngine::GetIfActive() )
+ return wxNullColour;
+
+ COLORREF c = (COLORREF)QueryBgBitmap(win);
+
+ return c == CLR_INVALID ? wxNullColour : wxRGBToColour(c);
}
#endif // wxUSE_UXTHEME