return wxPoint( m_x, m_y );
}
- bool DoEnable( bool enable );
+ virtual bool Enable( bool enable );
void UpdateToggleImage( bool toggle );
-#if wxOSX_USE_NATIVE_TOOLBAR
- void SetToolbarItemRef( HIToolbarItemRef ref )
+ virtual bool Toggle(bool toggle)
{
- if ( m_controlHandle )
- HideControl( m_controlHandle );
- if ( m_toolbarItemRef )
- CFRelease( m_toolbarItemRef );
-
- m_toolbarItemRef = ref;
+ if ( wxToolBarToolBase::Toggle( toggle ) == false )
+ return false;
+
+ UpdateToggleImage(toggle);
+ return true;
+ }
+
+ void UpdateHelpStrings()
+ {
+#if wxOSX_USE_NATIVE_TOOLBAR
if ( m_toolbarItemRef )
{
wxFontEncoding enc = GetToolBarFontEncoding();
wxCFStringRef( GetShortHelp(), enc ),
wxCFStringRef( GetLongHelp(), enc ) );
}
+#endif
}
-
- HIToolbarItemRef GetToolbarItemRef() const
+
+ virtual bool SetShortHelp(const wxString& help)
{
- return m_toolbarItemRef;
+ if ( wxToolBarToolBase::SetShortHelp( help ) == false )
+ return false;
+
+ UpdateHelpStrings();
+ return true;
}
-
- void SetIndex( CFIndex idx )
+
+ virtual bool SetLongHelp(const wxString& help)
{
- m_index = idx;
+ if ( wxToolBarToolBase::SetLongHelp( help ) == false )
+ return false;
+
+ UpdateHelpStrings();
+ return true;
}
- CFIndex GetIndex() const
+ virtual void SetNormalBitmap(const wxBitmap& bmp)
{
- return m_index;
+ wxToolBarToolBase::SetNormalBitmap(bmp);
+ UpdateToggleImage(CanBeToggled() && IsToggled());
}
-
+
virtual void SetLabel(const wxString& label)
{
wxToolBarToolBase::SetLabel(label);
-
+#if wxOSX_USE_NATIVE_TOOLBAR
if ( m_toolbarItemRef )
{
// strip mnemonics from the label for compatibility with the usual
m_toolbarItemRef,
wxCFStringRef(labelStr, GetToolBarFontEncoding()) );
}
+#endif
+ }
+
+#if wxOSX_USE_NATIVE_TOOLBAR
+ void SetToolbarItemRef( HIToolbarItemRef ref )
+ {
+ if ( m_controlHandle )
+ HideControl( m_controlHandle );
+ if ( m_toolbarItemRef )
+ CFRelease( m_toolbarItemRef );
+
+ m_toolbarItemRef = ref;
+ UpdateHelpStrings();
+ }
+
+ HIToolbarItemRef GetToolbarItemRef() const
+ {
+ return m_toolbarItemRef;
+ }
+
+ void SetIndex( CFIndex idx )
+ {
+ m_index = idx;
+ }
+
+ CFIndex GetIndex() const
+ {
+ return m_index;
}
#endif // wxOSX_USE_NATIVE_TOOLBAR
#endif
-bool wxToolBarTool::DoEnable( bool enable )
+bool wxToolBarTool::Enable( bool enable )
{
+ if ( wxToolBarToolBase::Enable( enable ) == false )
+ return false;
+
if ( IsControl() )
{
GetControl()->Enable( enable );
{
if ( toggle )
{
- int w = m_bmpNormal.GetWidth();
- int h = m_bmpNormal.GetHeight();
+ int w = m_bmpNormal.GetWidth() + 6;
+ int h = m_bmpNormal.GetHeight() + 6;
wxBitmap bmp( w, h );
wxMemoryDC dc;
dc.SelectObject( bmp );
- dc.SetPen( wxPen(*wxBLACK) );
- dc.SetBrush( wxBrush( *wxLIGHT_GREY ));
- dc.DrawRectangle( 0, 0, w, h );
- dc.DrawBitmap( m_bmpNormal, 0, 0, true );
+ wxColour mid_grey_75 = wxColour(128, 128, 128, 196);
+ wxColour light_grey_75 = wxColour(196, 196, 196, 196);
+ dc.GradientFillLinear( wxRect(1, 1, w - 1, h-1),
+ light_grey_75, mid_grey_75, wxNORTH);
+ wxColour black_50 = wxColour(0, 0, 0, 127);
+ dc.SetPen( wxPen(black_50) );
+ dc.DrawRoundedRectangle( 0, 0, w, h, 1.5 );
+ dc.DrawBitmap( m_bmpNormal, 3, 3, true );
dc.SelectObject( wxNullBitmap );
ControlButtonContentInfo info;
wxMacCreateBitmapButton( &info, bmp );
bResult = true;
SetWindowToolbar( tlw, (HIToolbarRef) m_macToolbar );
+
+ // ShowHideWindowToolbar will make the wxFrame grow
+ // which we don't want in this case
+ wxSize sz = GetParent()->GetSize();
ShowHideWindowToolbar( tlw, true, false );
+ // Restore the orginal size
+ GetParent()->SetSize( sz );
+
ChangeWindowAttributes( tlw, kWindowToolbarButtonAttribute, 0 );
+
SetAutomaticControlDragTrackingEnabledForWindow( tlw, true );
-
+
m_peer->Move(0,0,0,0 );
SetSize( wxSIZE_AUTO_WIDTH, 0 );
m_peer->SetVisibility( false );
{
if (m_tools.GetCount() == 0)
return false;
+
+ wxSize tlw_sz = GetParent()->GetSize();
int maxWidth = 0;
int maxHeight = 0;
{
// since setting the help texts is non-virtual we have to update
// the strings now
- HIToolbarItemSetHelpText( hiItemRef,
- wxCFStringRef( tool->GetShortHelp(), enc ),
- wxCFStringRef( tool->GetLongHelp(), enc ) );
-
if ( insertAll || (tool->GetIndex() != currentPosition) )
{
OSStatus err = noErr;
node = node->GetNext();
}
+ if (m_macUsesNativeToolbar)
+ GetParent()->SetSize( tlw_sz );
+
if ( GetWindowStyleFlag() & wxTB_HORIZONTAL )
{
// if not set yet, only one row
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 )
return wxEmptyString;
}
-void wxToolBar::DoEnableTool(wxToolBarToolBase *t, bool enable)
+void wxToolBar::DoEnableTool(wxToolBarToolBase *WXUNUSED(t), bool WXUNUSED(enable))
{
- if ( t != NULL )
- ((wxToolBarTool*)t)->DoEnable( enable );
+ // everything already done in the tool's implementation
}
void wxToolBar::DoToggleTool(wxToolBarToolBase *t, bool toggle)
{
- wxToolBarTool *tool = (wxToolBarTool *)t;
- if ( ( tool != NULL ) && tool->IsButton() )
- tool->UpdateToggleImage( toggle );
+ // everything already done in the tool's implementation
}
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;
void wxToolBar::DoSetToggle(wxToolBarToolBase *WXUNUSED(tool), bool WXUNUSED(toggle))
{
- wxFAIL_MSG( wxT("not implemented") );
+ // nothing to do
}
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() )
{