]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/tbar95.cpp
do use the font in DoGetTextExtent()
[wxWidgets.git] / src / msw / tbar95.cpp
index 48e70146585ff59670428760cbc6f3388e907f0b..cb2c515656fd2c7d76280488f588e7f2b7c34510 100644 (file)
@@ -40,6 +40,7 @@
     #include "wx/control.h"
     #include "wx/app.h"         // for GetComCtl32Version
     #include "wx/image.h"
+    #include "wx/stattext.h"
 #endif
 
 #include "wx/sysopt.h"
@@ -257,7 +258,7 @@ void wxToolBar::Init()
     m_defaultWidth = DEFAULTBITMAPX;
     m_defaultHeight = DEFAULTBITMAPY;
 
-    m_pInTool = 0;
+    m_pInTool = NULL;
 }
 
 bool wxToolBar::Create(wxWindow *parent,
@@ -302,6 +303,9 @@ bool wxToolBar::MSWCreateToolbar(const wxPoint& pos, const wxSize& size)
     // toolbar-specific post initialisation
     ::SendMessage(GetHwnd(), TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
 
+    if ( wxApp::GetComCtl32Version() >= 471 )
+        ::SendMessage(GetHwnd(), TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_DRAWDDARROWS);
+
     return true;
 }
 
@@ -399,6 +403,9 @@ wxSize wxToolBar::DoGetBestSize() const
         sizeBest.y = size.cy;
     }
 
+    if (!IsVertical() && !(GetWindowStyle() & wxTB_NODIVIDER))
+        sizeBest.y += 1;
+
     CacheBestSize(sizeBest);
 
     return sizeBest;
@@ -954,6 +961,10 @@ bool wxToolBar::Realize()
                         button.fsStyle = TBSTYLE_BUTTON;
                         break;
 
+                   case wxITEM_DROPDOWN:
+                        button.fsStyle = TBSTYLE_DROPDOWN;
+                        break;
+
                     default:
                         wxFAIL_MSG( _T("unexpected toolbar button kind") );
                         button.fsStyle = TBSTYLE_BUTTON;
@@ -1196,11 +1207,38 @@ bool wxToolBar::MSWOnNotify(int WXUNUSED(idCtrl),
                             WXLPARAM lParam,
                             WXLPARAM *WXUNUSED(result))
 {
+    LPNMHDR hdr = (LPNMHDR)lParam;
+    if ( hdr->code == TBN_DROPDOWN )
+    {
+        LPNMTOOLBAR tbhdr = (LPNMTOOLBAR)lParam;
+
+        wxCommandEvent evt(wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED, tbhdr->iItem);
+        if ( GetEventHandler()->ProcessEvent(evt) )
+        {
+            // Event got handled, don't display default popup menu
+            return false;
+        }
+
+        const wxToolBarToolBase * const tool = FindById(tbhdr->iItem);
+        wxCHECK_MSG( tool, false, _T("drop down message for unknown tool") );
+
+        wxMenu * const menu = tool->GetDropdownMenu();
+        if ( !menu )
+            return false;
+
+        // Display popup menu below button
+        RECT r;
+        if (::SendMessage(GetHwnd(), TB_GETITEMRECT, GetToolPos(tbhdr->iItem), (LPARAM)&r))
+            PopupMenu(menu, r.left, r.bottom);
+
+        return true;
+    }
+
+
     if( !HasFlag(wxTB_NO_TOOLTIPS) )
     {
 #if wxUSE_TOOLTIPS
         // First check if this applies to us
-        NMHDR *hdr = (NMHDR *)lParam;
 
         // the tooltips control created by the toolbar is sometimes Unicode, even
         // in an ANSI application - this seems to be a bug in comctl32.dll v5
@@ -1451,9 +1489,14 @@ void wxToolBar::OnSysColourChanged(wxSysColourChangedEvent& event)
 
 void wxToolBar::OnMouseEvent(wxMouseEvent& event)
 {
-    if (event.Leaving() && m_pInTool)
+    if ( event.Leaving() )
     {
-        OnMouseEnter( -1 );
+        if ( m_pInTool )
+        {
+            OnMouseEnter(wxID_ANY);
+            m_pInTool = NULL;
+        }
+
         event.Skip();
         return;
     }
@@ -1684,18 +1727,11 @@ void wxToolBar::HandleMouseMove(WXWPARAM WXUNUSED(wParam), WXLPARAM lParam)
             y = GET_Y_LPARAM(lParam);
     wxToolBarToolBase* tool = FindToolForPosition( x, y );
 
-    // cursor left current tool
-    if ( tool != m_pInTool && !tool )
-    {
-        m_pInTool = 0;
-        OnMouseEnter( -1 );
-    }
-
-    // cursor entered a tool
-    if ( tool != m_pInTool && tool )
+    // has the current tool changed?
+    if ( tool != m_pInTool )
     {
         m_pInTool = tool;
-        OnMouseEnter( tool->GetId() );
+        OnMouseEnter(tool ? tool->GetId() : wxID_ANY);
     }
 }