#pragma mark -
#pragma mark Tool Implementation
-#if wxOSX_USE_COCOA
-#define wxOSX_USE_NATIVE_TOOLBAR 1
-#endif
-
// ----------------------------------------------------------------------------
// private classes
// ----------------------------------------------------------------------------
{
// separator size
curSize = GetToolBar()->GetToolSize();
- if ( GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL )
+ if ( GetToolBar()->GetWindowStyleFlag() & (wxTB_LEFT|wxTB_RIGHT) )
curSize.y /= 4;
else
curSize.x /= 4;
void UpdateLabel()
{
+#if wxOSX_USE_NATIVE_TOOLBAR
if ( m_toolbarItem )
{
// strip mnemonics from the label for compatibility with the usual
wxCFStringRef sh( GetShortHelp(), GetToolBarFontEncoding() );
[m_toolbarItem setToolTip:sh.AsNSString()];
}
+#endif
}
void Action()
#endif
};
+#if wxOSX_USE_NATIVE_TOOLBAR
+
@interface wxNSToolbarItem : NSToolbarItem
{
wxToolBarTool* impl;
@end
+#endif
+
@interface wxNSToolBarButton : NSButton
{
@end
+#if wxOSX_USE_NATIVE_TOOLBAR
+
@implementation wxNSToolbarItem
- (id)initWithItemIdentifier: (NSString*) identifier
- (void) clickedAction: (id) sender
{
+ wxUnusedVar(sender);
if ( impl )
{
impl->Action();
- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar*)toolbar
{
+ wxUnusedVar(toolbar);
return nil;
}
- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar*)toolbar
{
+ wxUnusedVar(toolbar);
return nil;
}
- (NSArray *)toolbarSelectableItemIdentifiers:(NSToolbar *)toolbar
{
+ wxUnusedVar(toolbar);
return nil;
}
- (NSToolbarItem*) toolbar:(NSToolbar*) toolbar itemForItemIdentifier:(NSString*) itemIdentifier willBeInsertedIntoToolbar:(BOOL) flag
{
+ wxUnusedVar(toolbar);
#ifdef __LP64__
wxToolBarTool* tool = (wxToolBarTool*) [itemIdentifier longLongValue];
#else
@end
+#endif
+
@implementation wxNSToolBarButton
- (id)initWithFrame:(NSRect)frame
- (void) clickedAction: (id) sender
{
+ wxUnusedVar(sender);
if ( impl )
{
impl->Action();
if (m_macUsesNativeToolbar)
MacInstallNativeToolbar( false );
+ [(NSToolbar*)m_macToolbar setDelegate:nil];
[(NSToolbar*)m_macToolbar release];
m_macToolbar = NULL;
}
{
WXWindow tlw = MacGetTopLevelWindowRef();
float toolbarHeight = 0.0;
- NSRect windowFrame;
+ NSRect windowFrame = NSMakeRect(0, 0, 0, 0);
if(m_macToolbar && [(NSToolbar*)m_macToolbar isVisible])
{
}
if ( width != NULL )
- *width = windowFrame.size.width;
+ *width = (int)windowFrame.size.width;
if ( height != NULL )
- *height = toolbarHeight;
+ *height = (int)toolbarHeight;
}
else
wxToolBarBase::DoGetSize( width, height );
if (usesNative && (m_macToolbar == NULL))
return bResult;
- if (usesNative && ((GetWindowStyleFlag() & wxTB_VERTICAL) != 0))
+ if (usesNative && ((GetWindowStyleFlag() & (wxTB_LEFT|wxTB_RIGHT|wxTB_BOTTOM)) != 0))
return bResult;
WXWindow tlw = MacGetTopLevelWindowRef();
bool wxToolBar::Realize()
{
- if (m_tools.GetCount() == 0)
+ if ( !wxToolBarBase::Realize() )
return false;
int maxWidth = 0;
if ( y + cursize.y > maxHeight )
maxHeight = y + cursize.y;
- if ( GetWindowStyleFlag() & wxTB_VERTICAL )
+ if ( GetWindowStyleFlag() & (wxTB_LEFT|wxTB_RIGHT) )
{
int x1 = x + ( maxToolWidth - cursize.x ) / 2;
tool->SetPosition( wxPoint(x1, y) );
}
// update the item positioning state
- if ( GetWindowStyleFlag() & wxTB_VERTICAL )
+ if ( GetWindowStyleFlag() & (wxTB_LEFT|wxTB_RIGHT) )
y += cursize.y + kwxMacToolSpacing;
else
x += cursize.x + kwxMacToolSpacing;
node = node->GetNext();
}
- if ( GetWindowStyleFlag() & wxTB_HORIZONTAL )
+ if ( GetWindowStyleFlag() & (wxTB_TOP|wxTB_BOTTOM) )
{
// if not set yet, only one row
if ( m_maxRows <= 0 )
SetRows( 1 );
m_minWidth = maxWidth;
- maxWidth = tw;
+ // maxHeight = th;
maxHeight += m_yMargin + kwxMacToolBarTopMargin;
m_minHeight = m_maxHeight = maxHeight;
}
SetRows( GetToolsCount() );
m_minHeight = maxHeight;
- maxHeight = th;
+ // maxWidth = tw;
maxWidth += m_xMargin + kwxMacToolBarLeftMargin;
m_minWidth = m_maxWidth = maxWidth;
}
bool wantNativeToolbar, ownToolbarInstalled;
// attempt to install the native toolbar
- wantNativeToolbar = ((GetWindowStyleFlag() & wxTB_VERTICAL) == 0);
+ wantNativeToolbar = ((GetWindowStyleFlag() & (wxTB_LEFT|wxTB_BOTTOM|wxTB_RIGHT)) == 0);
MacInstallNativeToolbar( wantNativeToolbar );
(void)MacTopLevelHasNativeToolbar( &ownToolbarInstalled );
if (!ownToolbarInstalled)
void wxToolBar::SetToolNormalBitmap( int id, const wxBitmap& bitmap )
{
- wxToolBarTool* tool = wx_static_cast(wxToolBarTool*, FindById(id));
+ wxToolBarTool* tool = static_cast<wxToolBarTool*>(FindById(id));
if ( tool )
{
wxCHECK_RET( tool->IsButton(), wxT("Can only set bitmap on button tools."));
void wxToolBar::SetToolDisabledBitmap( int id, const wxBitmap& bitmap )
{
- wxToolBarTool* tool = wx_static_cast(wxToolBarTool*, FindById(id));
+ wxToolBarTool* tool = static_cast<wxToolBarTool*>(FindById(id));
if ( tool )
{
wxCHECK_RET( tool->IsButton(), wxT("Can only set bitmap on button tools."));
node = node->GetNext();
}
- return (wxToolBarToolBase*)NULL;
+ return NULL;
}
wxString wxToolBar::MacGetToolTipString( wxPoint &pt )
bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), wxToolBarToolBase *toolBase)
{
- wxToolBarTool *tool = wx_static_cast( wxToolBarTool*, toolBase );
+ wxToolBarTool *tool = static_cast< wxToolBarTool*>(toolBase );
if (tool == NULL)
return false;
wxASSERT( tool->GetControlHandle() == NULL );
toolSize.x /= 4;
toolSize.y /= 4;
- if ( GetWindowStyleFlag() & wxTB_VERTICAL )
+ if ( GetWindowStyleFlag() & (wxTB_LEFT|wxTB_RIGHT) )
toolrect.size.height = toolSize.y;
else
toolrect.size.width = toolSize.x;
if (m_macToolbar != NULL)
{
WXWidget view = (WXWidget) tool->GetControl()->GetHandle() ;
- wxCHECK_MSG( view, false, _T("control must be non-NULL") );
+ wxCHECK_MSG( view, false, wxT("control must be non-NULL") );
wxString identifier = wxString::Format(wxT("%ld"), (long) tool);
wxCFStringRef cfidentifier( identifier, wxFont::GetDefaultEncoding() );
bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos), wxToolBarToolBase *toolbase)
{
- wxToolBarTool* tool = wx_static_cast( wxToolBarTool*, toolbase );
+ wxToolBarTool* tool = static_cast< wxToolBarTool*>(toolbase );
wxToolBarToolsList::compatibility_iterator node;
for ( node = m_tools.GetFirst(); node; node = node->GetNext() )
{
wxToolBarTool *tool2 = (wxToolBarTool*) node->GetData();
wxPoint pt = tool2->GetPosition();
- if ( GetWindowStyleFlag() & wxTB_VERTICAL )
+ if ( GetWindowStyleFlag() & (wxTB_LEFT|wxTB_RIGHT) )
pt.y -= sz.y;
else
pt.x -= sz.x;