]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/notebook.cpp
reset m_selectionOld when the selection is programatically changed
[wxWidgets.git] / src / msw / notebook.cpp
index b060534c716803328ece5b8f626bf0020f8be6e3..f4614c1267df3133e92cc9bdd35448244deb220e 100644 (file)
@@ -33,7 +33,6 @@
 #include  "wx/event.h"
 #include  "wx/control.h"
 #include  "wx/notebook.h"
-#include  "wx/sysopt.h"
 #include  "wx/app.h"
 
 #include  "wx/msw/private.h"
@@ -244,21 +243,18 @@ bool wxNotebook::Create(wxWindow *parent,
                         long style,
                         const wxString& name)
 {
-    // some versions of comctl32.dll 6.0 included with Windows XP don't
-    // support non-top tabs (the control is simply not rendered correctly) but
-    // we can't detect which ones, so be pessimistic by default and disable non
-    // top tabs under XP but allow the user to override this by using a special
-    // system option
-    bool nonTopTabsOk = wxSystemOptions::GetOptionInt(_T("msw.xp-tab-ok")) != 0;
-    if ( !nonTopTabsOk )
+    // 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 )
     {
-        int verComCtl32 = wxApp::GetComCtl32Version();
-        nonTopTabsOk = verComCtl32 < 470 || verComCtl32 >= 600;
-    }
-
-    if ( !nonTopTabsOk )
-    {
-        style &= ~(wxNB_BOTTOM | wxNB_LEFT | 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,
@@ -866,26 +862,44 @@ void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
 
 #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
     {
@@ -893,7 +907,7 @@ void wxNotebook::UpdateBgBrush()
     }
 }
 
-WXHBRUSH wxNotebook::GetThemeBackgroundBrush(WXHDC hDC, wxWindow *win) const
+WXHBRUSH wxNotebook::MSWGetBgBrushForChild(WXHDC hDC, wxWindow *win)
 {
     if ( m_hbrBackground )
     {
@@ -908,30 +922,24 @@ WXHBRUSH wxNotebook::GetThemeBackgroundBrush(WXHDC hDC, wxWindow *win) const
         {
             wxLogLastError(_T("SetBrushOrgEx(notebook bg brush)"));
         }
+
+        return m_hbrBackground;
     }
 
-    return m_hbrBackground;
+    return wxNotebookBase::MSWGetBgBrushForChild(hDC, win);
 }
 
-void wxNotebook::DoEraseBackground(wxEraseEvent& event)
+wxColour wxNotebook::MSWGetBgColourForChild(wxWindow *win)
 {
-    DoEraseBackground((wxWindow *)event.GetEventObject(),
-                      (WXHDC)GetHdcOf(*event.GetDC()));
-}
+    if ( m_hasBgCol )
+        return GetBackgroundColour();
 
-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)hDC, &rectClient, (HBRUSH)hbr);
-    }
+    if ( !wxUxThemeEngine::GetIfActive() )
+        return wxNullColour;
+
+    COLORREF c = (COLORREF)QueryBgBitmap(win);
+
+    return c == CLR_INVALID ? wxNullColour : wxRGBToColour(c);
 }
 
 #endif // wxUSE_UXTHEME