summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
06336f5)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37617
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
class wxToolBarTool : public wxToolBarToolBase
{
public:
class wxToolBarTool : public wxToolBarToolBase
{
public:
- wxToolBarTool( wxToolBar *tbar,
- int id,
- const wxString& label,
- const wxBitmap& bmpNormal,
- const wxBitmap& bmpDisabled,
- wxItemKind kind,
- wxObject *clientData,
- const wxString& shortHelp,
- const wxString& longHelp );
+ wxToolBarTool(
+ wxToolBar *tbar,
+ int id,
+ const wxString& label,
+ const wxBitmap& bmpNormal,
+ const wxBitmap& bmpDisabled,
+ wxItemKind kind,
+ wxObject *clientData,
+ const wxString& shortHelp,
+ const wxString& longHelp );
wxToolBarTool(wxToolBar *tbar, wxControl *control)
: wxToolBarToolBase(tbar, control)
wxToolBarTool(wxToolBar *tbar, wxControl *control)
: wxToolBarToolBase(tbar, control)
- return GetControl()->GetSize();
+ curSize = GetControl()->GetSize();
}
else if ( IsButton() )
{
}
else if ( IsButton() )
{
- return GetToolBar()->GetToolSize();
+ curSize = GetToolBar()->GetToolSize();
}
else
{
// separator size
}
else
{
// separator size
- wxSize sz = GetToolBar()->GetToolSize();
+ curSize = GetToolBar()->GetToolSize();
if ( GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL )
if ( GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL )
- sz.x /= 4;
-
- return sz;
}
wxPoint GetPosition() const
}
wxPoint GetPosition() const
#ifdef __WXMAC_OSX__
shouldToggle = !tbartool->IsToggled();
#else
#ifdef __WXMAC_OSX__
shouldToggle = !tbartool->IsToggled();
#else
- shouldToggle = ( GetControl32BitValue((ControlRef) tbartool->GetControlHandle()) != 0 );
+ shouldToggle = (GetControl32BitValue( (ControlRef)(tbartool->GetControlHandle()) ) != 0);
#endif
tbar->ToggleTool( tbartool->GetId(), shouldToggle );
#endif
tbar->ToggleTool( tbartool->GetId(), shouldToggle );
#if wxMAC_USE_NATIVE_TOOLBAR
#if wxMAC_USE_NATIVE_TOOLBAR
-//
-// native toolbar
-//
-
static const EventTypeSpec toolBarEventList[] =
{
{ kEventClassToolbarItem, kEventToolbarItemPerformAction },
static const EventTypeSpec toolBarEventList[] =
{
{ kEventClassToolbarItem, kEventToolbarItemPerformAction },
if ( tbartool->CanBeToggled() )
{
if ( tbartool->CanBeToggled() )
{
tbar->ToggleTool(toolID, !tbartool->IsToggled() );
}
tbar->ToggleTool(toolID, !tbartool->IsToggled() );
}
tbar->OnLeftClick( toolID, tbartool->IsToggled() );
result = noErr;
}
tbar->OnLeftClick( toolID, tbartool->IsToggled() );
result = noErr;
}
-// ============================================================================
-// implementation
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// wxToolBarTool
-// ----------------------------------------------------------------------------
-
bool wxToolBarTool::DoEnable( bool enable )
{
if ( IsControl() )
bool wxToolBarTool::DoEnable( bool enable )
{
if ( IsControl() )
else if ( IsButton() )
{
#if wxMAC_USE_NATIVE_TOOLBAR
else if ( IsButton() )
{
#if wxMAC_USE_NATIVE_TOOLBAR
- if ( m_toolbarItemRef )
+ if ( m_toolbarItemRef != NULL )
HIToolbarItemSetEnabled( m_toolbarItemRef, enable );
#endif
HIToolbarItemSetEnabled( m_toolbarItemRef, enable );
#endif
+ if ( m_controlHandle != NULL )
{
#if TARGET_API_MAC_OSX
if ( enable )
{
#if TARGET_API_MAC_OSX
if ( enable )
#if wxMAC_USE_NATIVE_TOOLBAR
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_4
#if wxMAC_USE_NATIVE_TOOLBAR
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_4
-#define kHIToolbarItemSelected (1 << 7)
+#define kHIToolbarItemSelected (1 << 7)
#endif
// FIXME: this should be a OSX v10.4 runtime check
#endif
// FIXME: this should be a OSX v10.4 runtime check
{
ControlButtonContentInfo info;
wxMacCreateBitmapButton( &info, m_bmpNormal );
{
ControlButtonContentInfo info;
wxMacCreateBitmapButton( &info, m_bmpNormal );
- SetControlData( m_controlHandle, 0, kControlIconContentTag, sizeof( info ), (Ptr)&info );
+ SetControlData( m_controlHandle, 0, kControlIconContentTag, sizeof(info), (Ptr)&info );
wxMacReleaseBitmapButton( &info );
}
IconTransformType transform = toggle ? kTransformSelected : kTransformNone;
SetControlData(
m_controlHandle, 0, kControlIconTransformTag,
wxMacReleaseBitmapButton( &info );
}
IconTransformType transform = toggle ? kTransformSelected : kTransformNone;
SetControlData(
m_controlHandle, 0, kControlIconTransformTag,
- sizeof( transform ), (Ptr)&transform );
+ sizeof(transform), (Ptr)&transform );
HIViewSetNeedsDisplay( m_controlHandle, true );
#else
HIViewSetNeedsDisplay( m_controlHandle, true );
#else
wxToolBarToolBase * wxToolBar::CreateTool( wxControl *control )
{
wxToolBarToolBase * wxToolBar::CreateTool( wxControl *control )
{
- return new wxToolBarTool(this, control);
+ return new wxToolBarTool( this, control );
wxToolBar::~wxToolBar()
{
#if wxMAC_USE_NATIVE_TOOLBAR
wxToolBar::~wxToolBar()
{
#if wxMAC_USE_NATIVE_TOOLBAR
- if ( m_macHIToolbarRef )
+ if (m_macHIToolbarRef != NULL)
{
// if this is the installed toolbar, then deinstall it
if (m_macUsesNativeToolbar)
MacInstallNativeToolbar( false );
{
// if this is the installed toolbar, then deinstall it
if (m_macUsesNativeToolbar)
MacInstallNativeToolbar( false );
- CFRelease( (HIToolbarRef) m_macHIToolbarRef );
+ CFRelease( (HIToolbarRef)m_macHIToolbarRef );
m_macHIToolbarRef = NULL;
}
#endif
m_macHIToolbarRef = NULL;
}
#endif
bool wxToolBar::Show( bool show )
{
bool wxToolBar::Show( bool show )
{
WindowRef tlw = MAC_WXHWND(MacGetTopLevelWindowRef());
WindowRef tlw = MAC_WXHWND(MacGetTopLevelWindowRef());
+ bool bResult = (tlw != NULL);
- bResult = (tlw != NULL);
if (bResult)
{
#if wxMAC_USE_NATIVE_TOOLBAR
if (bResult)
{
#if wxMAC_USE_NATIVE_TOOLBAR
MacTopLevelHasNativeToolbar( &ownToolbarInstalled );
if (ownToolbarInstalled)
{
MacTopLevelHasNativeToolbar( &ownToolbarInstalled );
if (ownToolbarInstalled)
{
- bResult = ( IsWindowToolbarVisible( tlw ) != show);
+ bResult = (IsWindowToolbarVisible( tlw ) != show);
if ( bResult )
ShowHideWindowToolbar( tlw, show, false );
}
else
if ( bResult )
ShowHideWindowToolbar( tlw, show, false );
}
else
bResult = wxToolBarBase::Show( show );
bResult = wxToolBarBase::Show( show );
+#else
+
+ bResult = wxToolBarBase::Show( show );
+#endif
#if wxMAC_USE_NATIVE_TOOLBAR
bool ownToolbarInstalled;
#if wxMAC_USE_NATIVE_TOOLBAR
bool ownToolbarInstalled;
MacTopLevelHasNativeToolbar( &ownToolbarInstalled );
if (ownToolbarInstalled)
{
MacTopLevelHasNativeToolbar( &ownToolbarInstalled );
if (ownToolbarInstalled)
{
bResult = IsWindowToolbarVisible( tlw );
}
else
bResult = IsWindowToolbarVisible( tlw );
}
else
bResult = wxToolBarBase::IsShown();
bResult = wxToolBarBase::IsShown();
+#else
+
+ bResult = wxToolBarBase::IsShown();
+#endif
*height = boundsR.bottom - boundsR.top;
}
else
*height = boundsR.bottom - boundsR.top;
}
else
wxToolBarBase::DoGetSize( width, height );
wxToolBarBase::DoGetSize( width, height );
+
+#else
+ wxToolBarBase::DoGetSize( width, height );
+#endif
}
wxSize wxToolBar::DoGetBestSize() const
}
wxSize wxToolBar::DoGetBestSize() const
{
HIToolbarRef curToolbarRef = NULL;
OSStatus err = GetWindowToolbar( tlw, &curToolbarRef );
{
HIToolbarRef curToolbarRef = NULL;
OSStatus err = GetWindowToolbar( tlw, &curToolbarRef );
- bResultV = ((err == 0) && (curToolbarRef != NULL));
+ bResultV = ((err == noErr) && (curToolbarRef != NULL));
if (bResultV && (ownToolbarInstalled != NULL))
*ownToolbarInstalled = (curToolbarRef == m_macHIToolbarRef);
}
if (bResultV && (ownToolbarInstalled != NULL))
*ownToolbarInstalled = (curToolbarRef == m_macHIToolbarRef);
}
- WindowRef tlw = MAC_WXHWND(MacGetTopLevelWindowRef());
- if (tlw == NULL)
- return bResult;
-
if (usesNative && (m_macHIToolbarRef == NULL))
return bResult;
if (usesNative && ((GetWindowStyleFlag() & wxTB_VERTICAL) != 0))
return bResult;
if (usesNative && (m_macHIToolbarRef == NULL))
return bResult;
if (usesNative && ((GetWindowStyleFlag() & wxTB_VERTICAL) != 0))
return bResult;
+ WindowRef tlw = MAC_WXHWND(MacGetTopLevelWindowRef());
+ if (tlw == NULL)
+ return bResult;
+
// check the existing toolbar
HIToolbarRef curToolbarRef = NULL;
OSStatus err = GetWindowToolbar( tlw, &curToolbarRef );
// check the existing toolbar
HIToolbarRef curToolbarRef = NULL;
OSStatus err = GetWindowToolbar( tlw, &curToolbarRef );
GetSize( &tw, &th );
// find the maximum tool width and height
GetSize( &tw, &th );
// find the maximum tool width and height
- wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst();
+ wxToolBarTool *tool;
+ wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst();
- wxToolBarTool *tool = (wxToolBarTool *) node->GetData();
-
+ tool = (wxToolBarTool *) node->GetData();
if ( tool != NULL )
{
wxSize sz = tool->GetSize();
if ( tool != NULL )
{
wxSize sz = tool->GetSize();
node = m_tools.GetFirst();
while ( node != NULL )
{
node = m_tools.GetFirst();
while ( node != NULL )
{
- wxToolBarTool *tool = (wxToolBarTool *) node->GetData();
-
+ tool = (wxToolBarTool*) node->GetData();
if ( tool == NULL )
{
node = node->GetNext();
if ( tool == NULL )
{
node = node->GetNext();
if (! m_macUsesNativeToolbar )
Realize();
#else
if (! m_macUsesNativeToolbar )
Realize();
#else
Realize();
#endif
}
wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord x, wxCoord y) const
{
Realize();
#endif
}
wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord x, wxCoord y) const
{
wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst();
while ( node != NULL )
{
wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst();
while ( node != NULL )
{
- wxToolBarTool *tool = (wxToolBarTool *)node->GetData();
-
+ tool = (wxToolBarTool *)node->GetData();
if (tool != NULL)
{
wxRect2DInt r( tool->GetPosition(), tool->GetSize() );
if (tool != NULL)
{
wxRect2DInt r( tool->GetPosition(), tool->GetSize() );
node = node->GetNext();
}
node = node->GetNext();
}
- return (wxToolBarToolBase *)NULL;
+ return (wxToolBarToolBase*)NULL;
}
wxString wxToolBar::MacGetToolTipString( wxPoint &pt )
}
wxString wxToolBar::MacGetToolTipString( wxPoint &pt )
kHIToolbarItemCantBeRemoved | kHIToolbarItemAnchoredLeft | kHIToolbarItemAllowDuplicates, &item );
if (err == noErr)
{
kHIToolbarItemCantBeRemoved | kHIToolbarItemAnchoredLeft | kHIToolbarItemAllowDuplicates, &item );
if (err == noErr)
{
- InstallEventHandler( HIObjectGetEventTarget(item), GetwxMacToolBarEventHandlerUPP(),
- GetEventTypeCount(toolBarEventList), toolBarEventList, tool, NULL );
+ InstallEventHandler(
+ HIObjectGetEventTarget(item), GetwxMacToolBarEventHandlerUPP(),
+ GetEventTypeCount(toolBarEventList), toolBarEventList, tool, NULL );
HIToolbarItemSetLabel( item, wxMacCFStringHolder(tool->GetLabel(), m_font.GetEncoding()) );
HIToolbarItemSetIconRef( item, info.u.iconRef );
HIToolbarItemSetCommandID( item, kHIToolbarCommandPressAction );
HIToolbarItemSetLabel( item, wxMacCFStringHolder(tool->GetLabel(), m_font.GetEncoding()) );
HIToolbarItemSetIconRef( item, info.u.iconRef );
HIToolbarItemSetCommandID( item, kHIToolbarCommandPressAction );
#endif
wxMacReleaseBitmapButton( &info );
#endif
wxMacReleaseBitmapButton( &info );
#if 0
SetBevelButtonTextPlacement( m_controlHandle, kControlBevelButtonPlaceBelowGraphic );
UMASetControlTitle( m_controlHandle, label, wxFont::GetDefaultEncoding() );
#if 0
SetBevelButtonTextPlacement( m_controlHandle, kControlBevelButtonPlaceBelowGraphic );
UMASetControlTitle( m_controlHandle, label, wxFont::GetDefaultEncoding() );