bool DoEnable( bool enable );
void UpdateImages();
-
+
void UpdateToggleImage( bool toggle );
-
+
void UpdateLabel()
{
#if wxOSX_USE_NATIVE_TOOLBAR
wxCFStringRef l(labelStr, GetToolBarFontEncoding());
[m_toolbarItem setLabel:l.AsNSString()];
-
+
wxCFStringRef sh( GetShortHelp(), GetToolBarFontEncoding() );
[m_toolbarItem setToolTip:sh.AsNSString()];
}
tbar->OnLeftClick( GetId(), IsToggled() );
}
-
+
#if wxOSX_USE_NATIVE_TOOLBAR
void SetToolbarItemRef( NSToolbarItem* ref )
{
@end
-@interface wxNSToolbarDelegate : NSObject
+@interface wxNSToolbarDelegate : NSObject wxOSX_10_6_AND_LATER(<NSToolbarDelegate>)
{
}
- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag;
-
+
- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar*)toolbar;
- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar*)toolbar;
frame.origin.y = mac_y;
[m_controlHandle setFrame:frame];
}
- }
+ }
}
void wxToolBarTool::UpdateImages()
dc.DrawRectangle( 0, 0, w, h );
dc.DrawBitmap( m_bmpNormal, 0, 0, true );
dc.SelectObject( wxNullBitmap );
-
+
[(NSButton*) m_controlHandle setAlternateImage:m_alternateBitmap.GetNSImage()];
}
UpdateToggleImage( CanBeToggled() && IsToggled() );
if (parent->IsKindOf(CLASSINFO(wxFrame)) && wxSystemOptions::GetOptionInt(wxT("mac.toolbar.no-native")) != 1)
{
static wxNSToolbarDelegate* controller = nil;
-
+
if ( controller == nil )
controller = [[wxNSToolbarDelegate alloc] init];
wxString identifier = wxString::Format( wxT("%p"), this );
wxCFStringRef cfidentifier(identifier);
NSToolbar* tb = [[NSToolbar alloc] initWithIdentifier:cfidentifier.AsNSString()];
-
+
m_macToolbar = tb ;
-
+
if (m_macToolbar != NULL)
{
[tb setDelegate:controller];
-
+
NSToolbarDisplayMode mode = NSToolbarDisplayModeDefault;
NSToolbarSizeMode displaySize = NSToolbarSizeModeSmall;
}
wxToolBar::~wxToolBar()
-{
-#if wxOSX_USE_NATIVE_TOOLBAR
- if (m_macToolbar != NULL)
- {
- // if this is the installed toolbar, then deinstall it
- if (m_macUsesNativeToolbar)
- MacInstallNativeToolbar( false );
-
- [(NSToolbar*)m_macToolbar setDelegate:nil];
- [(NSToolbar*)m_macToolbar release];
- m_macToolbar = NULL;
- }
-#endif
+{
+ [(NSToolbar*)m_macToolbar setDelegate:nil];
+ [(NSToolbar*)m_macToolbar release];
+ m_macToolbar = NULL;
}
bool wxToolBar::Show( bool show )
WXWindow tlw = MacGetTopLevelWindowRef();
float toolbarHeight = 0.0;
NSRect windowFrame = NSMakeRect(0, 0, 0, 0);
-
+
if(m_macToolbar && [(NSToolbar*)m_macToolbar isVisible])
{
windowFrame = [NSWindow contentRectForFrameRect:[tlw frame]
toolbarHeight = NSHeight(windowFrame)
- NSHeight([[tlw contentView] frame]);
}
-
+
if ( width != NULL )
*width = (int)windowFrame.size.width;
if ( height != NULL )
bResult = true;
[tlw setToolbar:(NSToolbar*) m_macToolbar];
[(NSToolbar*) m_macToolbar setVisible:YES];
-
+
m_peer->Move(0,0,0,0 );
SetSize( wxSIZE_AUTO_WIDTH, 0 );
m_peer->SetVisibility( false );
{
bResult = true;
[(NSToolbar*) m_macToolbar setVisible:NO];
- [tlw setToolbar:nil];
+ MacUninstallNativeToolbar();
m_peer->SetVisibility( true );
}
}
// wxLogDebug( wxT(" --> [%lx] - result [%s]"), (long)this, bResult ? wxT("T") : wxT("F") );
return bResult;
}
+
+void wxToolBar::MacUninstallNativeToolbar()
+{
+ if (!m_macToolbar)
+ return;
+
+ WXWindow tlw = MacGetTopLevelWindowRef();
+ if (tlw)
+ [tlw setToolbar:nil];
+}
#endif
bool wxToolBar::Realize()
}
}
}
- wxString identifier = wxString::Format( wxT("%ld"), (long) tool );
- wxCFStringRef cfidentifier(identifier);
- [refTB insertItemWithItemIdentifier:cfidentifier.AsNSString() atIndex:currentPosition];
+ wxCFStringRef cfidentifier;
+ const NSString *nsItemId;
+ if (tool->GetStyle() == wxTOOL_STYLE_SEPARATOR)
+ {
+ nsItemId = tool->IsStretchable() ? NSToolbarFlexibleSpaceItemIdentifier
+ : NSToolbarSeparatorItemIdentifier;
+ }
+ else
+ {
+ cfidentifier = wxCFStringRef(wxString::Format("%ld", (long)tool));
+ nsItemId = cfidentifier.AsNSString();
+ }
+
+ [refTB insertItemWithItemIdentifier:nsItemId atIndex:currentPosition];
tool->SetIndex( currentPosition );
}
#if wxOSX_USE_NATIVE_TOOLBAR
if (m_macToolbar != NULL)
{
- NSToolbarItem* item = [[NSToolbarItem alloc] initWithItemIdentifier:NSToolbarSeparatorItemIdentifier];
+ const NSString * const
+ nsItemId = tool->IsStretchable() ? NSToolbarFlexibleSpaceItemIdentifier
+ : NSToolbarSeparatorItemIdentifier;
+ NSToolbarItem* item = [[NSToolbarItem alloc] initWithItemIdentifier:nsItemId];
tool->SetToolbarItemRef( item );
}
#endif // wxOSX_USE_NATIVE_TOOLBAR
[v setBordered:NO];
[v setButtonType: ( tool->CanBeToggled() ? NSOnOffButton : NSMomentaryPushInButton )];
[v setImplementation:tool];
-
+
controlHandle = v;
-
+
#if wxOSX_USE_NATIVE_TOOLBAR
if (m_macToolbar != NULL)
{