// wxWidgets
#ifndef WX_PRECOMP
#include "wx/string.h"
+ #include "wx/dc.h"
#endif // WX_PRECOMP
#include "wx/log.h"
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::DoEraseBackground(wxEraseEvent& event)
+WXHBRUSH wxNotebook::GetThemeBackgroundBrush(WXHDC hDC, wxWindow *win) const
{
- // 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)"));
}
+ }
+ return m_hbrBackground;
+}
+
+void wxNotebook::DoEraseBackground(wxEraseEvent& event)
+{
+ DoEraseBackground((wxWindow *)event.GetEventObject(),
+ (WXHDC)GetHdcOf(*event.GetDC()));
+}
+
+void wxNotebook::DoEraseBackground(wxWindow *win, WXHDC hDC)
+{
+ // 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)
+ WXHBRUSH hbr = GetThemeBackgroundBrush(hDC, win);
+ if ( hbr )
+ {
RECT rectClient;
::GetClientRect(GetHwndOf(win), &rectClient);
- ::FillRect(hdc, &rectClient, (HBRUSH)m_hbrBackground);
+ ::FillRect((HDC)hDC, &rectClient, (HBRUSH)hbr);
}
}