]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/tbar95.cpp
wx_gtk_vmsjackets.c seems to not be used by anything these days. Delete on both wxGTK...
[wxWidgets.git] / src / msw / tbar95.cpp
index a65d6202db6aa05bd7413268d73447b798634d75..1dd377605c37604e58d946397e8937ca024e938b 100644 (file)
@@ -234,10 +234,6 @@ bool wxToolBar::Create(wxWindow *parent,
 
     wxSetCCUnicodeFormat(GetHwnd());
 
-    // set up the colors and fonts
-    SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
-    SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
-
     // workaround for flat toolbar on Windows XP classic style: we have to set
     // the style after creating the control; doing it at creation time doesn't work
 #if wxUSE_UXTHEME
@@ -459,6 +455,7 @@ bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool)
     {
         nButtonsToDelete = ((wxToolBarTool *)tool)->GetSeparatorsCount();
         width *= nButtonsToDelete;
+        tool->GetControl()->Destroy();
     }
 
     // do delete all buttons
@@ -1328,7 +1325,7 @@ void wxToolBar::OnMouseEvent(wxMouseEvent& event)
     if ( event.RightDown() )
     {
         // find the tool under the mouse
-        wxCoord x,y;
+        wxCoord x = 0, y = 0;
         event.GetPosition(&x, &y);
 
         wxToolBarToolBase *tool = FindToolForPosition(x, y);
@@ -1344,27 +1341,48 @@ void wxToolBar::OnMouseEvent(wxMouseEvent& event)
 // colour: for example, when it must blend in with a notebook page.
 void wxToolBar::OnEraseBackground(wxEraseEvent& event)
 {
-    if ( !UseBgCol() )
-    {
-        event.Skip();
-        return;
-    }
-
-    wxColour bgCol = GetBackgroundColour();
-
-    // notice that this 'dumb' implementation may cause flicker for some of the
-    // controls in which case they should intercept wxEraseEvent and process it
-    // themselves somehow
-
     RECT rect = wxGetClientRect(GetHwnd());
-
-    AutoHBRUSH hBrush(wxColourToRGB(bgCol));
-
     HDC hdc = GetHdcOf((*event.GetDC()));
 
-    wxCHANGE_HDC_MAP_MODE(hdc, MM_TEXT);
+    if ( UseBgCol() )
+    {
+        // do draw our background
+        //
+        // notice that this 'dumb' implementation may cause flicker for some of
+        // the controls in which case they should intercept wxEraseEvent and
+        // process it themselves somehow
+        AutoHBRUSH hBrush(wxColourToRGB(GetBackgroundColour()));
+
+        wxCHANGE_HDC_MAP_MODE(hdc, MM_TEXT);
+        ::FillRect(hdc, &rect, hBrush);
+    }
+    else // we have no non default background colour
+    {
+#if wxUSE_UXTHEME
+        // we may need to draw themed colour so that we appear correctly on
+        // e.g. notebook page under XP with themes but only do it if the parent
+        // draws themed background itself
+        if ( !GetParent()->UseBgCol() )
+        {
+            wxUxThemeEngine *theme = wxUxThemeEngine::GetIfActive();
+            if ( theme )
+            {
+                HRESULT
+                    hr = theme->DrawThemeParentBackground(GetHwnd(), hdc, &rect);
+                if ( hr == S_OK )
+                    return;
+
+                // it can also return S_FALSE which seems to simply say that it
+                // didn't draw anything but no error really occurred
+                if ( FAILED(hr) )
+                    wxLogApiError(_T("DrawThemeParentBackground(toolbar)"), hr);
+            }
+        }
+#endif // wxUSE_UXTHEME
 
-    ::FillRect(hdc, &rect, hBrush);
+        event.Skip();
+        return;
+    }
 }
 
 bool wxToolBar::HandleSize(WXWPARAM WXUNUSED(wParam), WXLPARAM lParam)