X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e2eafeff03e55e8af173168ec4d4378f5c9d4630..76e7cfab8fdb0c7862fd07e427af54181717fc62:/src/cocoa/toolbar.mm diff --git a/src/cocoa/toolbar.mm b/src/cocoa/toolbar.mm index 3688f0e7b3..79f5c02473 100644 --- a/src/cocoa/toolbar.mm +++ b/src/cocoa/toolbar.mm @@ -4,9 +4,8 @@ // Author: David Elliott // Modified by: // Created: 2003/08/17 -// RCS-ID: $Id$ // Copyright: (c) 2003 David Elliott -// Licence: wxWidgets licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -21,8 +20,10 @@ #include "wx/wxprec.h" #if wxUSE_TOOLBAR_NATIVE + +#include "wx/toolbar.h" + #ifndef WX_PRECOMP - #include "wx/toolbar.h" #include "wx/frame.h" #include "wx/log.h" #endif // WX_PRECOMP @@ -58,8 +59,8 @@ public: CreateButtonCell(); } - wxToolBarTool(wxToolBar *tbar, wxControl *control) - : wxToolBarToolBase(tbar, control) + wxToolBarTool(wxToolBar *tbar, wxControl *control, const wxString& label) + : wxToolBarToolBase(tbar, control, label) { Init(); } @@ -98,7 +99,7 @@ void wxToolBarTool::Init() void wxToolBar::CocoaToolClickEnded() { wxASSERT(m_mouseDownTool); - wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, m_mouseDownTool->GetId()); + wxCommandEvent event(wxEVT_MENU, m_mouseDownTool->GetId()); InitCommandEvent(event); Command(event); } @@ -184,7 +185,13 @@ bool wxToolBar::Create( wxWindow *parent, const wxString& name ) { // Call wxControl::Create so we get a wxNonControlNSControl - return wxToolBarBase::Create(parent,winid,pos,size,style,wxDefaultValidator,name); + if ( !wxToolBarBase::Create(parent, winid, pos, size, style, + wxDefaultValidator, name) ) + return false; + + FixupStyle(); + + return true; } wxToolBarToolBase *wxToolBar::CreateTool(int toolid, @@ -200,9 +207,10 @@ wxToolBarToolBase *wxToolBar::CreateTool(int toolid, clientData, shortHelpString, longHelpString); } -wxToolBarToolBase *wxToolBar::CreateTool(wxControl *control) +wxToolBarToolBase * +wxToolBar::CreateTool(wxControl *control, const wxString& label) { - return new wxToolBarTool(this, control); + return new wxToolBarTool(this, control, label); } void wxToolBar::SetWindowStyleFlag( long style ) @@ -221,6 +229,11 @@ bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos), wxToolBarToolBase *toolBase) return true; } +bool wxToolBar::Cocoa_acceptsFirstMouse(bool &acceptsFirstMouse, WX_NSEvent theEvent) +{ + acceptsFirstMouse = true; return true; +} + bool wxToolBar::Cocoa_drawRect(const NSRect &rect) { wxToolBarToolsList::compatibility_iterator node; @@ -253,6 +266,7 @@ bool wxToolBar::Cocoa_mouseDragged(WX_NSEvent theEvent) NSButtonCell *buttonCell = m_mouseDownTool->GetNSButtonCell(); if(buttonCell) { + [buttonCell retain]; [buttonCell setHighlighted: YES]; if([buttonCell trackMouse: theEvent inRect:AddToolPadding(m_mouseDownTool->GetFrameRect()) ofView:m_cocoaNSView @@ -263,6 +277,7 @@ bool wxToolBar::Cocoa_mouseDragged(WX_NSEvent theEvent) wxLogTrace(wxTRACE_COCOA,wxT("Button was clicked after drag!")); } [buttonCell setHighlighted: NO]; + [buttonCell release]; } } return wxToolBarBase::Cocoa_mouseDragged(theEvent); @@ -276,6 +291,7 @@ bool wxToolBar::Cocoa_mouseDown(WX_NSEvent theEvent) NSButtonCell *buttonCell = tool->GetNSButtonCell(); if(buttonCell) { + [buttonCell retain]; m_mouseDownTool = tool; [buttonCell setHighlighted: YES]; if([buttonCell trackMouse: theEvent @@ -287,6 +303,7 @@ bool wxToolBar::Cocoa_mouseDown(WX_NSEvent theEvent) wxLogTrace(wxTRACE_COCOA,wxT("Button was clicked!")); } [buttonCell setHighlighted: NO]; + [buttonCell release]; } } return wxToolBarBase::Cocoa_mouseDown(theEvent);