]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/buttonbar.cpp
missing commit
[wxWidgets.git] / src / generic / buttonbar.cpp
index 182eb9357388712520d00b82e10c5ec77317b43d..c9e1f5f5d04a45956b69459b854320b41ae0e874 100644 (file)
@@ -6,7 +6,7 @@
 // Created:     2006-04-13
 // Id:          $Id$
 // Copyright:   (c) Julian Smart, Robert Roebling, Vadim Zeitlin,
 // Created:     2006-04-13
 // Id:          $Id$
 // Copyright:   (c) Julian Smart, Robert Roebling, Vadim Zeitlin,
-//              SciTech Software, Inc. 
+//              SciTech Software, Inc.
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // Currently, only for Mac as a toolbar replacement.
 #if defined(__WXMAC__) && wxUSE_TOOLBAR && wxUSE_BMPBUTTON
 
 // Currently, only for Mac as a toolbar replacement.
 #if defined(__WXMAC__) && wxUSE_TOOLBAR && wxUSE_BMPBUTTON
 
+#include "wx/generic/buttonbar.h"
+
 #ifndef WX_PRECOMP
     #include "wx/utils.h"
     #include "wx/app.h"
 #ifndef WX_PRECOMP
     #include "wx/utils.h"
     #include "wx/app.h"
+    #include "wx/log.h"
+    #include "wx/frame.h"
+    #include "wx/dcclient.h"
+    #include "wx/settings.h"
+    #include "wx/image.h"
 #endif
 
 #endif
 
-#include "wx/generic/buttonbar.h"
-#include "wx/frame.h"
-#include "wx/image.h"
-#include "wx/log.h"
-#include "wx/settings.h"
-#include "wx/dcclient.h"
-
 // ----------------------------------------------------------------------------
 // wxButtonToolBarTool: our implementation of wxToolBarToolBase
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // wxButtonToolBarTool: our implementation of wxToolBarToolBase
 // ----------------------------------------------------------------------------
@@ -62,12 +62,14 @@ public:
         m_x = m_y = wxDefaultCoord;
         m_width =
         m_height = 0;
         m_x = m_y = wxDefaultCoord;
         m_width =
         m_height = 0;
-        
+
         m_button = NULL;
     }
 
         m_button = NULL;
     }
 
-    wxButtonToolBarTool(wxButtonToolBar *tbar, wxControl *control)
-        : wxToolBarToolBase(tbar, control)
+    wxButtonToolBarTool(wxButtonToolBar *tbar,
+                        wxControl *control,
+                        const wxString& label)
+        : wxToolBarToolBase(tbar, control, label)
     {
         m_x = m_y = wxDefaultCoord;
         m_width =
     {
         m_x = m_y = wxDefaultCoord;
         m_width =
@@ -118,8 +120,8 @@ void wxButtonToolBar::Init()
 
     m_labelMargin = 2;
     m_labelHeight = 0;
 
     m_labelMargin = 2;
     m_labelHeight = 0;
-    
-    SetMargins(8, 4);
+
+    SetMargins(8, 2);
     SetToolPacking(8);
 }
 
     SetToolPacking(8);
 }
 
@@ -138,7 +140,10 @@ bool wxButtonToolBar::Create(wxWindow *parent,
 
     // wxColour lightBackground(244, 244, 244);
 
 
     // wxColour lightBackground(244, 244, 244);
 
-    wxFont font(wxSMALL_FONT->GetPointSize(), wxNORMAL_FONT->GetFamily(), wxNORMAL_FONT->GetStyle(), wxNORMAL);
+    wxFont font(wxSMALL_FONT->GetPointSize(),
+                wxNORMAL_FONT->GetFamily(),
+                wxNORMAL_FONT->GetStyle(),
+                wxFONTWEIGHT_NORMAL);
     SetFont(font);
 
     // Calculate the label height if necessary
     SetFont(font);
 
     // Calculate the label height if necessary
@@ -205,7 +210,7 @@ void wxButtonToolBar::GetRectLimits(const wxRect& rect,
                               wxCoord *start,
                               wxCoord *end) const
 {
                               wxCoord *start,
                               wxCoord *end) const
 {
-    wxCHECK_RET( start && end, _T("NULL pointer in GetRectLimits") );
+    wxCHECK_RET( start && end, wxT("NULL pointer in GetRectLimits") );
 
     if ( IsVertical() )
     {
 
     if ( IsVertical() )
     {
@@ -224,7 +229,7 @@ void wxButtonToolBar::SetToolShortHelp(int id, const wxString& help)
 {
     wxToolBarToolBase *tool = FindById(id);
 
 {
     wxToolBarToolBase *tool = FindById(id);
 
-    wxCHECK_RET( tool, _T("SetToolShortHelp: no such tool") );
+    wxCHECK_RET( tool, wxT("SetToolShortHelp: no such tool") );
 
     // TODO: set tooltip/short help
     tool->SetShortHelp(help);
 
     // TODO: set tooltip/short help
     tool->SetShortHelp(help);
@@ -271,9 +276,10 @@ wxToolBarToolBase *wxButtonToolBar::CreateTool(int id,
                              clientData, shortHelp, longHelp);
 }
 
                              clientData, shortHelp, longHelp);
 }
 
-wxToolBarToolBase *wxButtonToolBar::CreateTool(wxControl *control)
+wxToolBarToolBase *wxButtonToolBar::CreateTool(wxControl *control,
+                                               const wxString& label)
 {
 {
-    return new wxButtonToolBarTool(this, control);
+    return new wxButtonToolBarTool(this, control, label);
 }
 
 // ----------------------------------------------------------------------------
 }
 
 // ----------------------------------------------------------------------------
@@ -286,7 +292,7 @@ wxRect wxButtonToolBar::GetToolRect(wxToolBarToolBase *toolBase) const
 
     wxRect rect;
 
 
     wxRect rect;
 
-    wxCHECK_MSG( tool, rect, _T("GetToolRect: NULL tool") );
+    wxCHECK_MSG( tool, rect, wxT("GetToolRect: NULL tool") );
 
     // ensure that we always have the valid tool position
     if ( m_needsLayout )
 
     // ensure that we always have the valid tool position
     if ( m_needsLayout )
@@ -347,11 +353,11 @@ bool wxButtonToolBar::Realize()
 {
     if ( !wxToolBarBase::Realize() )
         return false;
 {
     if ( !wxToolBarBase::Realize() )
         return false;
-    
+
     m_needsLayout = true;
     DoLayout();
     m_needsLayout = true;
     DoLayout();
-    
-    SetBestSize(wxSize(m_maxWidth, m_maxHeight));
+
+    SetInitialSize(wxSize(m_maxWidth, m_maxHeight));
 
     return true;
 }
 
     return true;
 }
@@ -378,23 +384,23 @@ void wxButtonToolBar::DoLayout()
 
         tool->m_x = x;
         tool->m_y = y;
 
         tool->m_x = x;
         tool->m_y = y;
-        
+
         if (tool->IsButton())
         {
             if (!tool->GetButton())
             {
                 wxBitmapButton* bmpButton = new wxBitmapButton(this, tool->GetId(), tool->GetNormalBitmap(), wxPoint(tool->m_x, tool->m_y), wxDefaultSize,
                                                                wxBU_AUTODRAW|wxBORDER_NONE);
         if (tool->IsButton())
         {
             if (!tool->GetButton())
             {
                 wxBitmapButton* bmpButton = new wxBitmapButton(this, tool->GetId(), tool->GetNormalBitmap(), wxPoint(tool->m_x, tool->m_y), wxDefaultSize,
                                                                wxBU_AUTODRAW|wxBORDER_NONE);
-                if (!tool->GetShortHelp().IsEmpty())
+                if (!tool->GetShortHelp().empty())
                     bmpButton->SetLabel(tool->GetShortHelp());
                     bmpButton->SetLabel(tool->GetShortHelp());
-                
+
                 tool->SetButton(bmpButton);
             }
             else
             {
                 tool->GetButton()->Move(wxPoint(tool->m_x, tool->m_y));
             }
                 tool->SetButton(bmpButton);
             }
             else
             {
                 tool->GetButton()->Move(wxPoint(tool->m_x, tool->m_y));
             }
-            
+
             int w = widthTool;
             if (tool->GetButton())
             {
             int w = widthTool;
             if (tool->GetButton())
             {
@@ -405,7 +411,7 @@ void wxButtonToolBar::DoLayout()
                 {
                     sz.y += (m_labelHeight + m_labelMargin);
 
                 {
                     sz.y += (m_labelHeight + m_labelMargin);
 
-                    if (!tool->GetShortHelp().IsEmpty())
+                    if (!tool->GetShortHelp().empty())
                     {
                         wxClientDC dc(this);
                         dc.SetFont(GetFont());
                     {
                         wxClientDC dc(this);
                         dc.SetFont(GetFont());
@@ -490,7 +496,7 @@ void wxButtonToolBar::OnCommand(wxCommandEvent& event)
 }
 
 // paints a border
 }
 
 // paints a border
-void wxButtonToolBar::OnPaint(wxPaintEvent& event)
+void wxButtonToolBar::OnPaint(wxPaintEvent& WXUNUSED(event))
 {
     wxPaintDC dc(this);
 
 {
     wxPaintDC dc(this);
 
@@ -514,7 +520,7 @@ void wxButtonToolBar::OnPaint(wxPaintEvent& event)
             dc.DrawRectangle(backgroundRect);
         }
 
             dc.DrawRectangle(backgroundRect);
         }
 
-        if (m_labelHeight > 0 && !tool->GetShortHelp().IsEmpty())
+        if (m_labelHeight > 0 && !tool->GetShortHelp().empty())
         {
             int tw, th;
             dc.GetTextExtent(tool->GetShortHelp(), & tw, & th);
         {
             int tw, th;
             dc.GetTextExtent(tool->GetShortHelp(), & tw, & th);
@@ -544,13 +550,12 @@ void wxButtonToolBar::OnLeftUp(wxMouseEvent& event)
         wxButtonToolBarTool* tool = (wxButtonToolBarTool*) FindToolForPosition(event.GetX(), event.GetY());
         if (tool && tool->GetButton() && (event.GetY() > (tool->m_y + tool->GetButton()->GetSize().y)))
         {
         wxButtonToolBarTool* tool = (wxButtonToolBarTool*) FindToolForPosition(event.GetX(), event.GetY());
         if (tool && tool->GetButton() && (event.GetY() > (tool->m_y + tool->GetButton()->GetSize().y)))
         {
-            wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, tool->GetId());
+            wxCommandEvent event(wxEVT_BUTTON, tool->GetId());
             event.SetEventObject(tool->GetButton());
             event.SetEventObject(tool->GetButton());
-            if (!ProcessEvent(event))
+            if (!GetEventHandler()->ProcessEvent(event))
                 event.Skip();
         }
     }
 }
 
 #endif // wxUSE_TOOLBAR && wxUSE_BMPBUTTON
                 event.Skip();
         }
     }
 }
 
 #endif // wxUSE_TOOLBAR && wxUSE_BMPBUTTON
-