]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/toolbar.cpp
Compilation fir for VC6 after r73124.
[wxWidgets.git] / src / msw / toolbar.cpp
index 4866b30c54c0c2b7f0e65010a8f7428915f91608..7eaea5ca0fb3817774432d851b5d8222348de8f3 100644 (file)
@@ -127,6 +127,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxControl)
 BEGIN_EVENT_TABLE(wxToolBar, wxToolBarBase)
     EVT_MOUSE_EVENTS(wxToolBar::OnMouseEvent)
     EVT_SYS_COLOUR_CHANGED(wxToolBar::OnSysColourChanged)
+    EVT_ERASE_BACKGROUND(wxToolBar::OnEraseBackground)
 END_EVENT_TABLE()
 
 // ----------------------------------------------------------------------------
@@ -340,7 +341,10 @@ bool wxToolBar::Create(wxWindow *parent,
     // in WM_ERASEBKGND too (by default this won't be done but if the toolbar
     // has a non default background colour, then it would be used in both
     // places resulting in flicker)
-    SetBackgroundStyle(wxBG_STYLE_PAINT);
+    if (wxApp::GetComCtl32Version() >= 600)
+    {
+        SetBackgroundStyle(wxBG_STYLE_PAINT);
+    }
 
     return true;
 }
@@ -981,7 +985,7 @@ bool wxToolBar::Realize()
                 {
                     const wxString& label = tool->GetLabel();
                     if ( !label.empty() )
-                        button.iString = (INT_PTR)label.wx_str();
+                        button.iString = (INT_PTR) wxMSW_CONV_LPCTSTR(label);
                 }
 
                 button.idCommand = tool->GetId();
@@ -1049,6 +1053,14 @@ bool wxToolBar::Realize()
                         break;
                 }
 
+                // Instead of using fixed widths for all buttons, size them
+                // automatically according to the size of their bitmap and text
+                // label, if present. This particularly matters for toolbars
+                // with the wxTB_HORZ_LAYOUT style: they look hideously ugly
+                // without autosizing when the labels have even slightly
+                // different lengths.
+                button.fsStyle |= TBSTYLE_AUTOSIZE;
+
                 bitmapId++;
                 break;
         }
@@ -1679,6 +1691,13 @@ void wxToolBar::OnMouseEvent(wxMouseEvent& event)
     }
 }
 
+// This handler is needed to fix problems with painting the background of
+// toolbar icons with comctl32.dll < 6.0.
+void wxToolBar::OnEraseBackground(wxEraseEvent& event)
+{
+    MSWDoEraseBackground(event.GetDC()->GetHDC());
+}
+
 bool wxToolBar::HandleSize(WXWPARAM WXUNUSED(wParam), WXLPARAM lParam)
 {
     // wait until we have some tools