X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fac6eaec24736932770d26367b93c376a3f6d050..0bd2681966523df88ad5cf8e505b532843e58d74:/src/generic/buttonbar.cpp diff --git a/src/generic/buttonbar.cpp b/src/generic/buttonbar.cpp index 182eb93573..512352bf79 100644 --- a/src/generic/buttonbar.cpp +++ b/src/generic/buttonbar.cpp @@ -6,7 +6,7 @@ // Created: 2006-04-13 // Id: $Id$ // Copyright: (c) Julian Smart, Robert Roebling, Vadim Zeitlin, -// SciTech Software, Inc. +// SciTech Software, Inc. // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -28,18 +28,18 @@ // 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" + #include "wx/log.h" + #include "wx/frame.h" + #include "wx/dcclient.h" + #include "wx/settings.h" + #include "wx/image.h" #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 // ---------------------------------------------------------------------------- @@ -62,12 +62,14 @@ public: m_x = m_y = wxDefaultCoord; m_width = m_height = 0; - + 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 = @@ -118,8 +120,8 @@ void wxButtonToolBar::Init() m_labelMargin = 2; m_labelHeight = 0; - - SetMargins(8, 4); + + SetMargins(8, 2); SetToolPacking(8); } @@ -271,9 +273,10 @@ wxToolBarToolBase *wxButtonToolBar::CreateTool(int id, 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); } // ---------------------------------------------------------------------------- @@ -347,11 +350,11 @@ bool wxButtonToolBar::Realize() { if ( !wxToolBarBase::Realize() ) return false; - + m_needsLayout = true; DoLayout(); - - SetBestSize(wxSize(m_maxWidth, m_maxHeight)); + + SetInitialSize(wxSize(m_maxWidth, m_maxHeight)); return true; } @@ -378,23 +381,23 @@ void wxButtonToolBar::DoLayout() 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->GetShortHelp().IsEmpty()) + if (!tool->GetShortHelp().empty()) bmpButton->SetLabel(tool->GetShortHelp()); - + tool->SetButton(bmpButton); } else { tool->GetButton()->Move(wxPoint(tool->m_x, tool->m_y)); } - + int w = widthTool; if (tool->GetButton()) { @@ -405,7 +408,7 @@ void wxButtonToolBar::DoLayout() { sz.y += (m_labelHeight + m_labelMargin); - if (!tool->GetShortHelp().IsEmpty()) + if (!tool->GetShortHelp().empty()) { wxClientDC dc(this); dc.SetFont(GetFont()); @@ -514,7 +517,7 @@ void wxButtonToolBar::OnPaint(wxPaintEvent& event) 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); @@ -546,11 +549,10 @@ void wxButtonToolBar::OnLeftUp(wxMouseEvent& event) { wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, tool->GetId()); event.SetEventObject(tool->GetButton()); - if (!ProcessEvent(event)) + if (!GetEventHandler()->ProcessEvent(event)) event.Skip(); } } } #endif // wxUSE_TOOLBAR && wxUSE_BMPBUTTON -