]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/tbar95.cpp
Fixed mouse handling for captured windows
[wxWidgets.git] / src / msw / tbar95.cpp
index 721124a0aaa7c7805d587c799832b6fefe815a59..c160e85885de4d19a17afdcffae224ad17cba91e 100644 (file)
@@ -262,6 +262,10 @@ bool wxToolBar::Create(wxWindow *parent,
             msflags |= TBSTYLE_FLAT | TBSTYLE_TRANSPARENT;
         }
     }
+    if (style & wxTB_NODIVIDER)
+        msflags |= CCS_NODIVIDER;
+    if (style & wxTB_NOALIGN)
+        msflags |= CCS_NOPARENTALIGN;
 
     // MSW-specific initialisation
     if ( !wxControl::MSWCreateControl(TOOLBARCLASSNAME, msflags) )
@@ -630,6 +634,8 @@ bool wxToolBar::Realize()
                             // default to be consistent with wxGTK and the menu
                             // radio items
                             button.fsState |= TBSTATE_CHECKED;
+
+                            tool->Toggle(TRUE);
                         }
 
                         isRadio = TRUE;
@@ -829,15 +835,20 @@ bool wxToolBar::MSWCommand(WXUINT WXUNUSED(cmd), WXWORD id)
 
     bool toggled = tool->IsToggled();
 
-    // OnLeftClick() can veto the button state change - for buttons which may
-    // be toggled only, of couse
-    if ( !OnLeftClick((int)id, toggled) && tool->CanBeToggled() )
+    // avoid sending the event when a radio button is released, this is not
+    // interesting
+    if ( !tool->CanBeToggled() || tool->GetKind() != wxITEM_RADIO || toggled )
     {
-        // revert back
-        toggled = !toggled;
-        tool->SetToggle(toggled);
+        // OnLeftClick() can veto the button state change - for buttons which
+        // may be toggled only, of couse
+        if ( !OnLeftClick((int)id, toggled) && tool->CanBeToggled() )
+        {
+            // revert back
+            toggled = !toggled;
+            tool->SetToggle(toggled);
 
-        ::SendMessage(GetHwnd(), TB_CHECKBUTTON, id, MAKELONG(toggled, 0));
+            ::SendMessage(GetHwnd(), TB_CHECKBUTTON, id, MAKELONG(toggled, 0));
+        }
     }
 
     return TRUE;
@@ -1137,6 +1148,13 @@ void wxToolBar::OnSysColourChanged(wxSysColourChangedEvent& event)
 
 void wxToolBar::OnMouseEvent(wxMouseEvent& event)
 {
+    if (event.Leaving() && m_pInTool)
+    {
+        OnMouseEnter( -1 );
+        event.Skip();
+        return;
+    }
+
     if (event.RightDown())
     {
         // For now, we don't have an id. Later we could
@@ -1170,11 +1188,18 @@ bool wxToolBar::HandleSize(WXWPARAM wParam, WXLPARAM lParam)
         else
         {
             w = LOWORD(lParam);
-            h = r.bottom - r.top;
+            if (HasFlag( wxTB_FLAT ))
+                h = r.bottom - r.top - 3;
+            else
+                h = r.bottom - r.top;
             if ( m_maxRows )
             {
                 // FIXME: 6 is hardcoded separator line height...
-                h += 6;
+                //h += 6;
+                if (HasFlag(wxTB_NODIVIDER))
+                    h += 3;
+                else
+                    h += 6;
                 h *= m_maxRows;
             }
         }