X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a9a4f2295344414e2ee4e3ec27fa5292918dff27..6fc8ad6d53695012a9b20de2348c960e08b5fd52:/src/osx/cocoa/toolbar.mm diff --git a/src/osx/cocoa/toolbar.mm b/src/osx/cocoa/toolbar.mm index 8d442cd776..d5d0256f45 100644 --- a/src/osx/cocoa/toolbar.mm +++ b/src/osx/cocoa/toolbar.mm @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/osx/carbon/toolbar.cpp +// Name: src/osx/cocoa/toolbar.mm // Purpose: wxToolBar // Author: Stefan Csomor // Modified by: @@ -13,12 +13,11 @@ #if wxUSE_TOOLBAR -#include "wx/toolbar.h" - #ifndef WX_PRECOMP #include "wx/wx.h" #endif +#include "wx/toolbar.h" #include "wx/app.h" #include "wx/osx/private.h" #include "wx/geometry.h" @@ -192,6 +191,10 @@ public: if ( IsButton() ) [(NSButton*)m_controlHandle setTitle:l.AsNSString()]; + if ( m_controlHandle ) + { + [m_controlHandle setToolTip:sh.AsNSString()]; + } } void Action() @@ -324,7 +327,7 @@ private: - (id)initWithItemIdentifier: (NSString*) identifier { - [super initWithItemIdentifier:identifier]; + self = [super initWithItemIdentifier:identifier]; impl = NULL; [self setTarget: self]; [self setAction: @selector(clickedAction:)]; @@ -413,7 +416,7 @@ private: - (id)initWithFrame:(NSRect)frame { - [super initWithFrame:frame]; + self = [super initWithFrame:frame]; impl = NULL; [self setTarget: self]; [self setAction: @selector(clickedAction:)]; @@ -1100,8 +1103,15 @@ bool wxToolBar::Realize() NSString *nsItemId; if (tool->GetStyle() == wxTOOL_STYLE_SEPARATOR) { - nsItemId = tool->IsStretchable() ? NSToolbarFlexibleSpaceItemIdentifier - : NSToolbarSeparatorItemIdentifier; + if ( tool->IsStretchable() ) + nsItemId = NSToolbarFlexibleSpaceItemIdentifier; + else + { + if ( UMAGetSystemVersion() < 0x1070 ) + nsItemId = NSToolbarSeparatorItemIdentifier; + else + nsItemId = NSToolbarSpaceItemIdentifier; + } } else { @@ -1183,6 +1193,9 @@ bool wxToolBar::Realize() SetInitialSize( wxSize(m_minWidth, m_minHeight)); SendSizeEventToParent(); + wxWindow * const parent = GetParent(); + if ( parent && !parent->IsBeingDeleted() ) + parent->MacOnInternalSize(); return true; } @@ -1350,8 +1363,18 @@ bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), wxToolBarToolBase *toolBase) #if wxOSX_USE_NATIVE_TOOLBAR if (m_macToolbar != NULL) { - NSString * nsItemId = tool->IsStretchable() ? NSToolbarFlexibleSpaceItemIdentifier - : NSToolbarSeparatorItemIdentifier; + NSString * nsItemId = nil; + + if ( tool->IsStretchable() ) + nsItemId = NSToolbarFlexibleSpaceItemIdentifier; + else + { + if ( UMAGetSystemVersion() < 0x1070 ) + nsItemId = NSToolbarSeparatorItemIdentifier; + else + nsItemId = NSToolbarSpaceItemIdentifier; + } + NSToolbarItem* item = [[NSToolbarItem alloc] initWithItemIdentifier:nsItemId]; tool->SetToolbarItemRef( item ); } @@ -1375,14 +1398,6 @@ bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), wxToolBarToolBase *toolBase) [v setButtonType: ( tool->CanBeToggled() ? NSToggleButton : NSMomentaryPushInButton )]; [v setImplementation:tool]; - if ( style & wxTB_NOICONS ) - [v setImagePosition:NSNoImage]; - else if ( style & wxTB_TEXT ) - [v setImagePosition:NSImageAbove]; - else - [v setImagePosition:NSImageOnly]; - - controlHandle = v; #if wxOSX_USE_NATIVE_TOOLBAR @@ -1399,6 +1414,13 @@ bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), wxToolBarToolBase *toolBase) tool->SetControlHandle( controlHandle ); tool->UpdateImages(); tool->UpdateLabel(); + + if ( style & wxTB_NOICONS ) + [v setImagePosition:NSNoImage]; + else if ( style & wxTB_TEXT ) + [v setImagePosition:NSImageAbove]; + else + [v setImagePosition:NSImageOnly]; [v sizeToFit]; #if 0