1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/carbon/toolbar.cpp
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
16 #include "wx/toolbar.h"
22 #include "wx/mac/uma.h"
23 #include "wx/geometry.h"
27 const short kwxMacToolBarToolDefaultWidth
= 16;
28 const short kwxMacToolBarToolDefaultHeight
= 16;
29 const short kwxMacToolBarTopMargin
= 4;
30 const short kwxMacToolBarLeftMargin
= 4;
31 const short kwxMacToolBorder
= 0;
32 const short kwxMacToolSpacing
= 6;
34 const short kwxMacToolBarToolDefaultWidth
= 24;
35 const short kwxMacToolBarToolDefaultHeight
= 22;
36 const short kwxMacToolBarTopMargin
= 2;
37 const short kwxMacToolBarLeftMargin
= 2;
38 const short kwxMacToolBorder
= 4;
39 const short kwxMacToolSpacing
= 0;
43 IMPLEMENT_DYNAMIC_CLASS(wxToolBar
, wxControl
)
45 BEGIN_EVENT_TABLE(wxToolBar
, wxToolBarBase
)
46 EVT_PAINT( wxToolBar::OnPaint
)
51 #pragma mark Tool Implementation
54 // ----------------------------------------------------------------------------
56 // ----------------------------------------------------------------------------
58 // We have a dual implementation for each tool, ControlRef and HIToolbarItemRef
60 class wxToolBarTool
: public wxToolBarToolBase
66 const wxString
& label
,
67 const wxBitmap
& bmpNormal
,
68 const wxBitmap
& bmpDisabled
,
71 const wxString
& shortHelp
,
72 const wxString
& longHelp
);
74 wxToolBarTool(wxToolBar
*tbar
, wxControl
*control
)
75 : wxToolBarToolBase(tbar
, control
)
79 SetControlHandle( (ControlRef
) control
->GetHandle() );
82 virtual ~wxToolBarTool()
86 #if wxMAC_USE_NATIVE_TOOLBAR
87 if ( m_toolbarItemRef
)
88 CFRelease( m_toolbarItemRef
);
92 WXWidget
GetControlHandle()
94 return (WXWidget
) m_controlHandle
;
97 void SetControlHandle( ControlRef handle
)
99 m_controlHandle
= handle
;
102 void SetPosition( const wxPoint
& position
);
107 if ( m_controlHandle
)
110 DisposeControl( m_controlHandle
);
113 // the embedded control is not under the responsibility of the tool
115 m_controlHandle
= NULL
;
118 #if wxMAC_USE_NATIVE_TOOLBAR
119 m_toolbarItemRef
= NULL
;
123 wxSize
GetSize() const
129 curSize
= GetControl()->GetSize();
131 else if ( IsButton() )
133 curSize
= GetToolBar()->GetToolSize();
138 curSize
= GetToolBar()->GetToolSize();
139 if ( GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
148 wxPoint
GetPosition() const
150 return wxPoint( m_x
, m_y
);
153 bool DoEnable( bool enable
);
155 void UpdateToggleImage( bool toggle
);
157 #if wxMAC_USE_NATIVE_TOOLBAR
158 void SetToolbarItemRef( HIToolbarItemRef ref
)
160 if ( m_controlHandle
)
161 HideControl( m_controlHandle
);
162 if ( m_toolbarItemRef
)
163 CFRelease( m_toolbarItemRef
);
165 m_toolbarItemRef
= ref
;
166 if ( m_toolbarItemRef
)
168 HIToolbarItemSetHelpText(
170 wxMacCFStringHolder( GetShortHelp(), GetToolBar()->GetFont().GetEncoding() ),
171 wxMacCFStringHolder( GetLongHelp(), GetToolBar()->GetFont().GetEncoding() ) );
175 HIToolbarItemRef
GetToolbarItemRef() const
177 return m_toolbarItemRef
;
180 void SetIndex( CFIndex idx
)
185 CFIndex
GetIndex() const
194 m_controlHandle
= NULL
;
196 #if wxMAC_USE_NATIVE_TOOLBAR
197 m_toolbarItemRef
= NULL
;
202 ControlRef m_controlHandle
;
206 #if wxMAC_USE_NATIVE_TOOLBAR
207 HIToolbarItemRef m_toolbarItemRef
;
208 // position in its toolbar, -1 means not inserted
213 static const EventTypeSpec eventList
[] =
215 { kEventClassControl
, kEventControlHit
},
217 { kEventClassControl
, kEventControlHitTest
},
221 static pascal OSStatus
wxMacToolBarToolControlEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
223 OSStatus result
= eventNotHandledErr
;
224 ControlRef controlRef
;
225 wxMacCarbonEvent
cEvent( event
);
227 cEvent
.GetParameter( kEventParamDirectObject
, &controlRef
);
229 switch ( GetEventKind( event
) )
231 case kEventControlHit
:
233 wxToolBarTool
*tbartool
= (wxToolBarTool
*)data
;
234 wxToolBar
*tbar
= tbartool
!= NULL
? (wxToolBar
*) (tbartool
->GetToolBar()) : NULL
;
235 if ((tbartool
!= NULL
) && tbartool
->CanBeToggled())
240 shouldToggle
= !tbartool
->IsToggled();
242 shouldToggle
= (GetControl32BitValue( (ControlRef
)(tbartool
->GetControlHandle()) ) != 0);
245 tbar
->ToggleTool( tbartool
->GetId(), shouldToggle
);
248 if (tbartool
!= NULL
)
249 tbar
->OnLeftClick( tbartool
->GetId(), tbartool
->IsToggled() );
255 case kEventControlHitTest
:
257 HIPoint pt
= cEvent
.GetParameter
<HIPoint
>(kEventParamMouseLocation
);
259 HIViewGetBounds( controlRef
, &rect
);
261 ControlPartCode pc
= kControlNoPart
;
262 if ( CGRectContainsPoint( rect
, pt
) )
263 pc
= kControlIconPart
;
264 cEvent
.SetParameter( kEventParamControlPart
, typeControlPartCode
, pc
);
277 static pascal OSStatus
wxMacToolBarToolEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
279 OSStatus result
= eventNotHandledErr
;
281 switch ( GetEventClass( event
) )
283 case kEventClassControl
:
284 result
= wxMacToolBarToolControlEventHandler( handler
, event
, data
);
294 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacToolBarToolEventHandler
)
296 #if wxMAC_USE_NATIVE_TOOLBAR
298 static const EventTypeSpec toolBarEventList
[] =
300 { kEventClassToolbarItem
, kEventToolbarItemPerformAction
},
303 static pascal OSStatus
wxMacToolBarCommandEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
305 OSStatus result
= eventNotHandledErr
;
307 switch ( GetEventKind( event
) )
309 case kEventToolbarItemPerformAction
:
311 wxToolBarTool
* tbartool
= (wxToolBarTool
*) data
;
312 if ( tbartool
!= NULL
)
314 wxToolBar
*tbar
= (wxToolBar
*)(tbartool
->GetToolBar());
315 int toolID
= tbartool
->GetId();
317 if ( tbartool
->CanBeToggled() )
320 tbar
->ToggleTool(toolID
, !tbartool
->IsToggled() );
324 tbar
->OnLeftClick( toolID
, tbartool
->IsToggled() );
337 static pascal OSStatus
wxMacToolBarEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
339 OSStatus result
= eventNotHandledErr
;
341 switch ( GetEventClass( event
) )
343 case kEventClassToolbarItem
:
344 result
= wxMacToolBarCommandEventHandler( handler
, event
, data
);
354 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacToolBarEventHandler
)
358 bool wxToolBarTool::DoEnable( bool enable
)
362 GetControl()->Enable( enable
);
364 else if ( IsButton() )
366 #if wxMAC_USE_NATIVE_TOOLBAR
367 if ( m_toolbarItemRef
!= NULL
)
368 HIToolbarItemSetEnabled( m_toolbarItemRef
, enable
);
371 if ( m_controlHandle
!= NULL
)
373 #if TARGET_API_MAC_OSX
375 EnableControl( m_controlHandle
);
377 DisableControl( m_controlHandle
);
380 ActivateControl( m_controlHandle
);
382 DeactivateControl( m_controlHandle
);
390 void wxToolBarTool::SetPosition( const wxPoint
& position
)
395 int mac_x
= position
.x
;
396 int mac_y
= position
.y
;
401 GetControlBounds( m_controlHandle
, &contrlRect
);
402 int former_mac_x
= contrlRect
.left
;
403 int former_mac_y
= contrlRect
.top
;
404 GetToolBar()->GetToolSize();
406 if ( mac_x
!= former_mac_x
|| mac_y
!= former_mac_y
)
408 UMAMoveControl( m_controlHandle
, mac_x
, mac_y
);
411 else if ( IsControl() )
413 // embedded native controls are moved by the OS
414 #if wxMAC_USE_NATIVE_TOOLBAR
415 if ( ((wxToolBar
*)GetToolBar())->MacWantsNativeToolbar() == false )
418 GetControl()->Move( position
);
426 GetControlBounds( m_controlHandle
, &contrlRect
);
427 int former_mac_x
= contrlRect
.left
;
428 int former_mac_y
= contrlRect
.top
;
430 if ( mac_x
!= former_mac_x
|| mac_y
!= former_mac_y
)
431 UMAMoveControl( m_controlHandle
, mac_x
, mac_y
);
436 void wxToolBarTool::UpdateToggleImage( bool toggle
)
441 int w
= m_bmpNormal
.GetWidth();
442 int h
= m_bmpNormal
.GetHeight();
443 wxBitmap
bmp( w
, h
);
446 dc
.SelectObject( bmp
);
447 dc
.SetPen( wxPen(*wxBLACK
) );
448 dc
.SetBrush( wxBrush( *wxLIGHT_GREY
));
449 dc
.DrawRectangle( 0, 0, w
, h
);
450 dc
.DrawBitmap( m_bmpNormal
, 0, 0, true );
451 dc
.SelectObject( wxNullBitmap
);
452 ControlButtonContentInfo info
;
453 wxMacCreateBitmapButton( &info
, bmp
);
454 SetControlData( m_controlHandle
, 0, kControlIconContentTag
, sizeof(info
), (Ptr
)&info
);
455 #if wxMAC_USE_NATIVE_TOOLBAR
456 if (m_toolbarItemRef
!= NULL
)
458 HIToolbarItemSetIconRef( m_toolbarItemRef
, info
.u
.iconRef
);
461 wxMacReleaseBitmapButton( &info
);
465 ControlButtonContentInfo info
;
466 wxMacCreateBitmapButton( &info
, m_bmpNormal
);
467 SetControlData( m_controlHandle
, 0, kControlIconContentTag
, sizeof(info
), (Ptr
)&info
);
468 #if wxMAC_USE_NATIVE_TOOLBAR
469 if (m_toolbarItemRef
!= NULL
)
471 HIToolbarItemSetIconRef( m_toolbarItemRef
, info
.u
.iconRef
);
474 wxMacReleaseBitmapButton( &info
);
477 IconTransformType transform
= toggle
? kTransformSelected
: kTransformNone
;
479 m_controlHandle
, 0, kControlIconTransformTag
,
480 sizeof(transform
), (Ptr
)&transform
);
481 HIViewSetNeedsDisplay( m_controlHandle
, true );
484 ::SetControl32BitValue( m_controlHandle
, toggle
);
488 wxToolBarTool::wxToolBarTool(
491 const wxString
& label
,
492 const wxBitmap
& bmpNormal
,
493 const wxBitmap
& bmpDisabled
,
495 wxObject
*clientData
,
496 const wxString
& shortHelp
,
497 const wxString
& longHelp
)
500 tbar
, id
, label
, bmpNormal
, bmpDisabled
, kind
,
501 clientData
, shortHelp
, longHelp
)
507 #pragma mark Toolbar Implementation
509 wxToolBarToolBase
*wxToolBar::CreateTool(
511 const wxString
& label
,
512 const wxBitmap
& bmpNormal
,
513 const wxBitmap
& bmpDisabled
,
515 wxObject
*clientData
,
516 const wxString
& shortHelp
,
517 const wxString
& longHelp
)
519 return new wxToolBarTool(
520 this, id
, label
, bmpNormal
, bmpDisabled
, kind
,
521 clientData
, shortHelp
, longHelp
);
524 wxToolBarToolBase
* wxToolBar::CreateTool( wxControl
*control
)
526 return new wxToolBarTool( this, control
);
529 void wxToolBar::Init()
533 m_defaultWidth
= kwxMacToolBarToolDefaultWidth
;
534 m_defaultHeight
= kwxMacToolBarToolDefaultHeight
;
536 #if wxMAC_USE_NATIVE_TOOLBAR
537 m_macHIToolbarRef
= NULL
;
538 m_macUsesNativeToolbar
= false;
542 #define kControlToolbarItemClassID CFSTR( "org.wxwidgets.controltoolbaritem" )
544 const EventTypeSpec kEvents
[] =
546 { kEventClassHIObject
, kEventHIObjectConstruct
},
547 { kEventClassHIObject
, kEventHIObjectInitialize
},
548 { kEventClassHIObject
, kEventHIObjectDestruct
},
550 { kEventClassToolbarItem
, kEventToolbarItemCreateCustomView
}
553 const EventTypeSpec kViewEvents
[] =
555 { kEventClassControl
, kEventControlGetSizeConstraints
}
558 struct ControlToolbarItem
560 HIToolbarItemRef toolbarItem
;
562 wxSize lastValidSize
;
565 static pascal OSStatus
ControlToolbarItemHandler( EventHandlerCallRef inCallRef
, EventRef inEvent
, void* inUserData
)
567 OSStatus result
= eventNotHandledErr
;
568 ControlToolbarItem
* object
= (ControlToolbarItem
*)inUserData
;
570 switch ( GetEventClass( inEvent
) )
572 case kEventClassHIObject
:
573 switch ( GetEventKind( inEvent
) )
575 case kEventHIObjectConstruct
:
577 HIObjectRef toolbarItem
;
578 ControlToolbarItem
* item
;
580 GetEventParameter( inEvent
, kEventParamHIObjectInstance
, typeHIObjectRef
, NULL
,
581 sizeof( HIObjectRef
), NULL
, &toolbarItem
);
583 item
= (ControlToolbarItem
*) malloc(sizeof(ControlToolbarItem
)) ;
584 item
->toolbarItem
= toolbarItem
;
585 item
->viewRef
= NULL
;
587 SetEventParameter( inEvent
, kEventParamHIObjectInstance
, typeVoidPtr
, sizeof( void * ), &item
);
593 case kEventHIObjectInitialize
:
594 result
= CallNextEventHandler( inCallRef
, inEvent
);
595 if ( result
== noErr
)
598 GetEventParameter( inEvent
, kEventParamToolbarItemConfigData
, typeCFTypeRef
, NULL
,
599 sizeof( CFTypeRef
), NULL
, &data
);
603 wxASSERT_MSG( CFDataGetLength( data
) == sizeof( viewRef
) , wxT("Illegal Data passed") ) ;
604 memcpy( &viewRef
, CFDataGetBytePtr( data
) , sizeof( viewRef
) ) ;
606 object
->viewRef
= (HIViewRef
) viewRef
;
612 case kEventHIObjectDestruct
:
619 case kEventClassToolbarItem
:
620 switch ( GetEventKind( inEvent
) )
622 case kEventToolbarItemCreateCustomView
:
624 HIViewRef viewRef
= object
->viewRef
;
626 HIViewRemoveFromSuperview( viewRef
) ;
627 HIViewSetVisible(viewRef
, true) ;
628 InstallEventHandler( GetControlEventTarget( viewRef
), ControlToolbarItemHandler
,
629 GetEventTypeCount( kViewEvents
), kViewEvents
, object
, NULL
);
631 result
= SetEventParameter( inEvent
, kEventParamControlRef
, typeControlRef
, sizeof( HIViewRef
), &viewRef
);
637 case kEventClassControl
:
638 switch ( GetEventKind( inEvent
) )
640 case kEventControlGetSizeConstraints
:
642 wxWindow
* wxwindow
= wxFindControlFromMacControl(object
->viewRef
) ;
645 wxSize sz
= wxwindow
->GetSize() ;
646 sz
.x
-= wxwindow
->MacGetLeftBorderSize() + wxwindow
->MacGetRightBorderSize();
647 sz
.y
-= wxwindow
->MacGetTopBorderSize() + wxwindow
->MacGetBottomBorderSize();
648 // during toolbar layout the native window sometimes gets negative sizes
649 // so we always keep the last valid size here, to make sure we survive the
651 if ( sz
.x
> 0 && sz
.y
> 0 )
652 object
->lastValidSize
= sz
;
654 sz
= object
->lastValidSize
;
657 min
.width
= max
.width
= sz
.x
;
658 min
.height
= max
.height
= sz
.y
;
660 result
= SetEventParameter( inEvent
, kEventParamMinimumSize
, typeHISize
,
661 sizeof( HISize
), &min
);
663 result
= SetEventParameter( inEvent
, kEventParamMaximumSize
, typeHISize
,
664 sizeof( HISize
), &max
);
676 void RegisterControlToolbarItemClass()
678 static bool sRegistered
;
682 HIObjectRegisterSubclass( kControlToolbarItemClassID
, kHIToolbarItemClassID
, 0,
683 ControlToolbarItemHandler
, GetEventTypeCount( kEvents
), kEvents
, 0, NULL
);
689 HIToolbarItemRef
CreateControlToolbarItem(CFStringRef inIdentifier
, CFTypeRef inConfigData
)
691 RegisterControlToolbarItemClass();
695 UInt32 options
= kHIToolbarItemAllowDuplicates
;
696 HIToolbarItemRef result
= NULL
;
698 err
= CreateEvent( NULL
, kEventClassHIObject
, kEventHIObjectInitialize
, GetCurrentEventTime(), 0, &event
);
699 require_noerr( err
, CantCreateEvent
);
701 SetEventParameter( event
, kEventParamAttributes
, typeUInt32
, sizeof( UInt32
), &options
);
702 SetEventParameter( event
, kEventParamToolbarItemIdentifier
, typeCFStringRef
, sizeof( CFStringRef
), &inIdentifier
);
705 SetEventParameter( event
, kEventParamToolbarItemConfigData
, typeCFTypeRef
, sizeof( CFTypeRef
), &inConfigData
);
707 err
= HIObjectCreate( kControlToolbarItemClassID
, event
, (HIObjectRef
*)&result
);
710 ReleaseEvent( event
);
715 #if wxMAC_USE_NATIVE_TOOLBAR
716 static const EventTypeSpec kToolbarEvents
[] =
718 { kEventClassToolbar
, kEventToolbarGetDefaultIdentifiers
},
719 { kEventClassToolbar
, kEventToolbarGetAllowedIdentifiers
},
720 { kEventClassToolbar
, kEventToolbarCreateItemWithIdentifier
},
723 static OSStatus
ToolbarDelegateHandler( EventHandlerCallRef inCallRef
, EventRef inEvent
, void* inUserData
)
725 OSStatus result
= eventNotHandledErr
;
727 // wxToolBar* toolbar = (wxToolBar*) inUserData ;
728 CFMutableArrayRef array
;
730 switch ( GetEventKind( inEvent
) )
732 case kEventToolbarGetDefaultIdentifiers
:
734 GetEventParameter( inEvent
, kEventParamMutableArray
, typeCFMutableArrayRef
, NULL
,
735 sizeof( CFMutableArrayRef
), NULL
, &array
);
736 // not implemented yet
737 // GetToolbarDefaultItems( array );
742 case kEventToolbarGetAllowedIdentifiers
:
744 GetEventParameter( inEvent
, kEventParamMutableArray
, typeCFMutableArrayRef
, NULL
,
745 sizeof( CFMutableArrayRef
), NULL
, &array
);
746 // not implemented yet
747 // GetToolbarAllowedItems( array );
751 case kEventToolbarCreateItemWithIdentifier
:
753 HIToolbarItemRef item
= NULL
;
754 CFTypeRef data
= NULL
;
755 CFStringRef identifier
= NULL
;
757 GetEventParameter( inEvent
, kEventParamToolbarItemIdentifier
, typeCFStringRef
, NULL
,
758 sizeof( CFStringRef
), NULL
, &identifier
);
760 GetEventParameter( inEvent
, kEventParamToolbarItemConfigData
, typeCFTypeRef
, NULL
,
761 sizeof( CFTypeRef
), NULL
, &data
);
763 if ( CFStringCompare( kControlToolbarItemClassID
, identifier
, kCFCompareBackwards
) == kCFCompareEqualTo
)
765 item
= CreateControlToolbarItem( kControlToolbarItemClassID
, data
);
768 SetEventParameter( inEvent
, kEventParamToolbarItem
, typeHIToolbarItemRef
,
769 sizeof( HIToolbarItemRef
), &item
);
779 #endif // wxMAC_USE_NATIVE_TOOLBAR
781 // also for the toolbar we have the dual implementation:
782 // only when MacInstallNativeToolbar is called is the native toolbar set as the window toolbar
784 bool wxToolBar::Create(
790 const wxString
& name
)
792 if ( !wxToolBarBase::Create( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
795 OSStatus err
= noErr
;
797 #if wxMAC_USE_NATIVE_TOOLBAR
798 wxString labelStr
= wxString::Format( wxT("%xd"), (int)this );
799 err
= HIToolbarCreate(
800 wxMacCFStringHolder( labelStr
, wxFont::GetDefaultEncoding() ), 0,
801 (HIToolbarRef
*) &m_macHIToolbarRef
);
803 if (m_macHIToolbarRef
!= NULL
)
805 InstallEventHandler( HIObjectGetEventTarget((HIToolbarRef
)m_macHIToolbarRef
), ToolbarDelegateHandler
,
806 GetEventTypeCount( kToolbarEvents
), kToolbarEvents
, this, NULL
);
808 HIToolbarDisplayMode mode
= kHIToolbarDisplayModeDefault
;
809 HIToolbarDisplaySize displaySize
= kHIToolbarDisplaySizeSmall
;
811 if ( style
& wxTB_NOICONS
)
812 mode
= kHIToolbarDisplayModeLabelOnly
;
813 else if ( style
& wxTB_TEXT
)
814 mode
= kHIToolbarDisplayModeIconAndLabel
;
816 mode
= kHIToolbarDisplayModeIconOnly
;
818 HIToolbarSetDisplayMode( (HIToolbarRef
) m_macHIToolbarRef
, mode
);
819 HIToolbarSetDisplaySize( (HIToolbarRef
) m_macHIToolbarRef
, displaySize
);
823 return (err
== noErr
);
826 wxToolBar::~wxToolBar()
828 #if wxMAC_USE_NATIVE_TOOLBAR
829 if (m_macHIToolbarRef
!= NULL
)
831 // if this is the installed toolbar, then deinstall it
832 if (m_macUsesNativeToolbar
)
833 MacInstallNativeToolbar( false );
835 CFRelease( (HIToolbarRef
)m_macHIToolbarRef
);
836 m_macHIToolbarRef
= NULL
;
841 bool wxToolBar::Show( bool show
)
843 WindowRef tlw
= MAC_WXHWND(MacGetTopLevelWindowRef());
844 bool bResult
= (tlw
!= NULL
);
848 #if wxMAC_USE_NATIVE_TOOLBAR
849 bool ownToolbarInstalled
= false;
850 MacTopLevelHasNativeToolbar( &ownToolbarInstalled
);
851 if (ownToolbarInstalled
)
853 bResult
= (IsWindowToolbarVisible( tlw
) != show
);
855 ShowHideWindowToolbar( tlw
, show
, false );
858 bResult
= wxToolBarBase::Show( show
);
861 bResult
= wxToolBarBase::Show( show
);
868 bool wxToolBar::IsShown() const
872 #if wxMAC_USE_NATIVE_TOOLBAR
873 bool ownToolbarInstalled
;
875 MacTopLevelHasNativeToolbar( &ownToolbarInstalled
);
876 if (ownToolbarInstalled
)
878 WindowRef tlw
= MAC_WXHWND(MacGetTopLevelWindowRef());
879 bResult
= IsWindowToolbarVisible( tlw
);
882 bResult
= wxToolBarBase::IsShown();
885 bResult
= wxToolBarBase::IsShown();
891 void wxToolBar::DoGetSize( int *width
, int *height
) const
893 #if wxMAC_USE_NATIVE_TOOLBAR
895 bool ownToolbarInstalled
;
897 MacTopLevelHasNativeToolbar( &ownToolbarInstalled
);
898 if ( ownToolbarInstalled
)
900 // TODO: is this really a control ?
901 GetControlBounds( (ControlRef
) m_macHIToolbarRef
, &boundsR
);
903 *width
= boundsR
.right
- boundsR
.left
;
904 if ( height
!= NULL
)
905 *height
= boundsR
.bottom
- boundsR
.top
;
908 wxToolBarBase::DoGetSize( width
, height
);
911 wxToolBarBase::DoGetSize( width
, height
);
915 wxSize
wxToolBar::DoGetBestSize() const
919 DoGetSize( &width
, &height
);
921 return wxSize( width
, height
);
924 void wxToolBar::SetWindowStyleFlag( long style
)
926 wxToolBarBase::SetWindowStyleFlag( style
);
928 #if wxMAC_USE_NATIVE_TOOLBAR
929 if (m_macHIToolbarRef
!= NULL
)
931 HIToolbarDisplayMode mode
= kHIToolbarDisplayModeDefault
;
933 if ( style
& wxTB_NOICONS
)
934 mode
= kHIToolbarDisplayModeLabelOnly
;
935 else if ( style
& wxTB_TEXT
)
936 mode
= kHIToolbarDisplayModeIconAndLabel
;
938 mode
= kHIToolbarDisplayModeIconOnly
;
940 HIToolbarSetDisplayMode( (HIToolbarRef
) m_macHIToolbarRef
, mode
);
945 #if wxMAC_USE_NATIVE_TOOLBAR
946 bool wxToolBar::MacWantsNativeToolbar()
948 return m_macUsesNativeToolbar
;
951 bool wxToolBar::MacTopLevelHasNativeToolbar(bool *ownToolbarInstalled
) const
953 bool bResultV
= false;
955 if (ownToolbarInstalled
!= NULL
)
956 *ownToolbarInstalled
= false;
958 WindowRef tlw
= MAC_WXHWND(MacGetTopLevelWindowRef());
961 HIToolbarRef curToolbarRef
= NULL
;
962 OSStatus err
= GetWindowToolbar( tlw
, &curToolbarRef
);
963 bResultV
= ((err
== noErr
) && (curToolbarRef
!= NULL
));
964 if (bResultV
&& (ownToolbarInstalled
!= NULL
))
965 *ownToolbarInstalled
= (curToolbarRef
== m_macHIToolbarRef
);
971 bool wxToolBar::MacInstallNativeToolbar(bool usesNative
)
973 bool bResult
= false;
975 if (usesNative
&& (m_macHIToolbarRef
== NULL
))
978 if (usesNative
&& ((GetWindowStyleFlag() & wxTB_VERTICAL
) != 0))
981 WindowRef tlw
= MAC_WXHWND(MacGetTopLevelWindowRef());
985 // check the existing toolbar
986 HIToolbarRef curToolbarRef
= NULL
;
987 OSStatus err
= GetWindowToolbar( tlw
, &curToolbarRef
);
989 curToolbarRef
= NULL
;
991 m_macUsesNativeToolbar
= usesNative
;
993 if (m_macUsesNativeToolbar
)
995 // only install toolbar if there isn't one installed already
996 if (curToolbarRef
== NULL
)
1000 SetWindowToolbar( tlw
, (HIToolbarRef
) m_macHIToolbarRef
);
1001 ShowHideWindowToolbar( tlw
, true, false );
1002 ChangeWindowAttributes( tlw
, kWindowToolbarButtonAttribute
, 0 );
1003 SetAutomaticControlDragTrackingEnabledForWindow( tlw
, true );
1005 Rect r
= { 0, 0, 0, 0 };
1006 m_peer
->SetRect( &r
);
1007 SetSize( wxSIZE_AUTO_WIDTH
, 0 );
1008 m_peer
->SetVisibility( false, true );
1009 wxToolBarBase::Show( false );
1014 // only deinstall toolbar if this is the installed one
1015 if (m_macHIToolbarRef
== curToolbarRef
)
1019 ShowHideWindowToolbar( tlw
, false, false );
1020 ChangeWindowAttributes( tlw
, 0, kWindowToolbarButtonAttribute
);
1021 SetWindowToolbar( tlw
, NULL
);
1023 m_peer
->SetVisibility( true, true );
1028 InvalidateBestSize();
1030 // wxLogDebug( wxT(" --> [%lx] - result [%s]"), (long)this, bResult ? wxT("T") : wxT("F") );
1035 bool wxToolBar::Realize()
1037 if (m_tools
.GetCount() == 0)
1043 int maxToolWidth
= 0;
1044 int maxToolHeight
= 0;
1046 int x
= m_xMargin
+ kwxMacToolBarLeftMargin
;
1047 int y
= m_yMargin
+ kwxMacToolBarTopMargin
;
1050 GetSize( &tw
, &th
);
1052 // find the maximum tool width and height
1053 wxToolBarTool
*tool
;
1054 wxToolBarToolsList::compatibility_iterator node
= m_tools
.GetFirst();
1055 while ( node
!= NULL
)
1057 tool
= (wxToolBarTool
*) node
->GetData();
1060 wxSize sz
= tool
->GetSize();
1062 if ( sz
.x
> maxToolWidth
)
1063 maxToolWidth
= sz
.x
;
1064 if ( sz
.y
> maxToolHeight
)
1065 maxToolHeight
= sz
.y
;
1068 node
= node
->GetNext();
1071 bool lastIsRadio
= false;
1072 bool curIsRadio
= false;
1074 #if wxMAC_USE_NATIVE_TOOLBAR
1075 CFIndex currentPosition
= 0;
1076 bool insertAll
= false;
1079 node
= m_tools
.GetFirst();
1080 while ( node
!= NULL
)
1082 tool
= (wxToolBarTool
*) node
->GetData();
1085 node
= node
->GetNext();
1089 // set tool position:
1090 // for the moment just perform a single row/column alignment
1091 wxSize cursize
= tool
->GetSize();
1092 if ( x
+ cursize
.x
> maxWidth
)
1093 maxWidth
= x
+ cursize
.x
;
1094 if ( y
+ cursize
.y
> maxHeight
)
1095 maxHeight
= y
+ cursize
.y
;
1097 if ( GetWindowStyleFlag() & wxTB_VERTICAL
)
1099 int x1
= x
+ ( maxToolWidth
- cursize
.x
) / 2;
1100 tool
->SetPosition( wxPoint(x1
, y
) );
1104 int y1
= y
+ ( maxToolHeight
- cursize
.y
) / 2;
1105 tool
->SetPosition( wxPoint(x
, y1
) );
1108 // update the item positioning state
1109 if ( GetWindowStyleFlag() & wxTB_VERTICAL
)
1110 y
+= cursize
.y
+ kwxMacToolSpacing
;
1112 x
+= cursize
.x
+ kwxMacToolSpacing
;
1114 #if wxMAC_USE_NATIVE_TOOLBAR
1115 // install in native HIToolbar
1116 if ( m_macHIToolbarRef
!= NULL
)
1118 HIToolbarItemRef hiItemRef
= tool
->GetToolbarItemRef();
1119 if ( hiItemRef
!= NULL
)
1121 if ( insertAll
|| (tool
->GetIndex() != currentPosition
) )
1123 OSStatus err
= noErr
;
1128 // if this is the first tool that gets newly inserted or repositioned
1129 // first remove all 'old' tools from here to the right, because of this
1130 // all following tools will have to be reinserted (insertAll). i = 100 because there's
1131 // no way to determine how many there are in a toolbar, so just a high number :-(
1132 for ( CFIndex i
= 100; i
>= currentPosition
; --i
)
1134 err
= HIToolbarRemoveItemAtIndex( (HIToolbarRef
) m_macHIToolbarRef
, i
);
1139 wxString errMsg
= wxString::Format( wxT("HIToolbarRemoveItemAtIndex failed [%ld]"), (long)err
);
1140 wxFAIL_MSG( errMsg
.c_str() );
1144 err
= HIToolbarInsertItemAtIndex( (HIToolbarRef
) m_macHIToolbarRef
, hiItemRef
, currentPosition
);
1147 wxString errMsg
= wxString::Format( wxT("HIToolbarInsertItemAtIndex failed [%ld]"), (long)err
);
1148 wxFAIL_MSG( errMsg
.c_str() );
1151 tool
->SetIndex( currentPosition
);
1159 // update radio button (and group) state
1160 lastIsRadio
= curIsRadio
;
1161 curIsRadio
= ( tool
->IsButton() && (tool
->GetKind() == wxITEM_RADIO
) );
1165 if ( tool
->IsToggled() )
1166 DoToggleTool( tool
, true );
1172 if ( tool
->Toggle( true ) )
1174 DoToggleTool( tool
, true );
1177 else if ( tool
->IsToggled() )
1179 if ( tool
->IsToggled() )
1180 DoToggleTool( tool
, true );
1182 wxToolBarToolsList::compatibility_iterator nodePrev
= node
->GetPrevious();
1183 while ( nodePrev
!= NULL
)
1185 wxToolBarToolBase
*toggleTool
= nodePrev
->GetData();
1186 if ( (toggleTool
== NULL
) || !toggleTool
->IsButton() || (toggleTool
->GetKind() != wxITEM_RADIO
) )
1189 if ( toggleTool
->Toggle( false ) )
1190 DoToggleTool( toggleTool
, false );
1192 nodePrev
= nodePrev
->GetPrevious();
1197 node
= node
->GetNext();
1200 if ( GetWindowStyleFlag() & wxTB_HORIZONTAL
)
1202 // if not set yet, only one row
1203 if ( m_maxRows
<= 0 )
1206 m_minWidth
= maxWidth
;
1208 maxHeight
+= m_yMargin
+ kwxMacToolBarTopMargin
;
1209 m_minHeight
= m_maxHeight
= maxHeight
;
1213 // if not set yet, have one column
1214 if ( (GetToolsCount() > 0) && (m_maxRows
<= 0) )
1215 SetRows( GetToolsCount() );
1217 m_minHeight
= maxHeight
;
1219 maxWidth
+= m_xMargin
+ kwxMacToolBarLeftMargin
;
1220 m_minWidth
= m_maxWidth
= maxWidth
;
1224 // FIXME: should this be OSX-only?
1226 bool wantNativeToolbar
, ownToolbarInstalled
;
1228 // attempt to install the native toolbar
1229 wantNativeToolbar
= ((GetWindowStyleFlag() & wxTB_VERTICAL
) == 0);
1230 MacInstallNativeToolbar( wantNativeToolbar
);
1231 (void)MacTopLevelHasNativeToolbar( &ownToolbarInstalled
);
1232 if (!ownToolbarInstalled
)
1234 SetSize( maxWidth
, maxHeight
);
1235 InvalidateBestSize();
1239 SetSize( maxWidth
, maxHeight
);
1240 InvalidateBestSize();
1243 SetBestFittingSize();
1248 void wxToolBar::SetToolBitmapSize(const wxSize
& size
)
1250 m_defaultWidth
= size
.x
+ kwxMacToolBorder
;
1251 m_defaultHeight
= size
.y
+ kwxMacToolBorder
;
1253 #if wxMAC_USE_NATIVE_TOOLBAR
1254 if (m_macHIToolbarRef
!= NULL
)
1256 int maxs
= wxMax( size
.x
, size
.y
);
1257 HIToolbarDisplaySize sizeSpec
;
1259 sizeSpec
= kHIToolbarDisplaySizeNormal
;
1260 else if ( maxs
> 24 )
1261 sizeSpec
= kHIToolbarDisplaySizeDefault
;
1263 sizeSpec
= kHIToolbarDisplaySizeSmall
;
1265 HIToolbarSetDisplaySize( (HIToolbarRef
) m_macHIToolbarRef
, sizeSpec
);
1270 // The button size is bigger than the bitmap size
1271 wxSize
wxToolBar::GetToolSize() const
1273 return wxSize(m_defaultWidth
+ kwxMacToolBorder
, m_defaultHeight
+ kwxMacToolBorder
);
1276 void wxToolBar::SetRows(int nRows
)
1278 // avoid resizing the frame uselessly
1279 if ( nRows
!= m_maxRows
)
1283 void wxToolBar::MacSuperChangedPosition()
1285 wxWindow::MacSuperChangedPosition();
1287 #if wxMAC_USE_NATIVE_TOOLBAR
1288 if (! m_macUsesNativeToolbar
)
1296 wxToolBarToolBase
*wxToolBar::FindToolForPosition(wxCoord x
, wxCoord y
) const
1298 wxToolBarTool
*tool
;
1299 wxToolBarToolsList::compatibility_iterator node
= m_tools
.GetFirst();
1300 while ( node
!= NULL
)
1302 tool
= (wxToolBarTool
*)node
->GetData();
1305 wxRect2DInt
r( tool
->GetPosition(), tool
->GetSize() );
1306 if ( r
.Contains( wxPoint( x
, y
) ) )
1310 node
= node
->GetNext();
1313 return (wxToolBarToolBase
*)NULL
;
1316 wxString
wxToolBar::MacGetToolTipString( wxPoint
&pt
)
1318 wxToolBarToolBase
*tool
= FindToolForPosition( pt
.x
, pt
.y
);
1320 return tool
->GetShortHelp();
1322 return wxEmptyString
;
1325 void wxToolBar::DoEnableTool(wxToolBarToolBase
*t
, bool enable
)
1328 ((wxToolBarTool
*)t
)->DoEnable( enable
);
1331 void wxToolBar::DoToggleTool(wxToolBarToolBase
*t
, bool toggle
)
1333 wxToolBarTool
*tool
= (wxToolBarTool
*)t
;
1334 if ( ( tool
!= NULL
) && tool
->IsButton() )
1335 tool
->UpdateToggleImage( toggle
);
1338 bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos
), wxToolBarToolBase
*toolBase
)
1340 wxToolBarTool
*tool
= wx_static_cast( wxToolBarTool
*, toolBase
);
1344 WindowRef window
= (WindowRef
) MacGetTopLevelWindowRef();
1345 wxSize toolSize
= GetToolSize();
1346 Rect toolrect
= { 0, 0, toolSize
.y
, toolSize
.x
};
1347 ControlRef controlHandle
= NULL
;
1350 switch (tool
->GetStyle())
1352 case wxTOOL_STYLE_SEPARATOR
:
1354 wxASSERT( tool
->GetControlHandle() == NULL
);
1357 if ( GetWindowStyleFlag() & wxTB_VERTICAL
)
1358 toolrect
.bottom
= toolSize
.y
;
1360 toolrect
.right
= toolSize
.x
;
1362 #ifdef __WXMAC_OSX__
1363 // in flat style we need a visual separator
1364 #if wxMAC_USE_NATIVE_TOOLBAR
1365 HIToolbarItemRef item
;
1366 err
= HIToolbarItemCreate(
1367 kHIToolbarSeparatorIdentifier
,
1368 kHIToolbarItemCantBeRemoved
| kHIToolbarItemIsSeparator
| kHIToolbarItemAllowDuplicates
,
1371 tool
->SetToolbarItemRef( item
);
1374 CreateSeparatorControl( window
, &toolrect
, &controlHandle
);
1375 tool
->SetControlHandle( controlHandle
);
1380 case wxTOOL_STYLE_BUTTON
:
1382 wxASSERT( tool
->GetControlHandle() == NULL
);
1383 ControlButtonContentInfo info
;
1384 wxMacCreateBitmapButton( &info
, tool
->GetNormalBitmap(), kControlContentIconRef
);
1386 if ( UMAGetSystemVersion() >= 0x1000)
1388 CreateIconControl( window
, &toolrect
, &info
, false, &controlHandle
);
1392 SInt16 behaviour
= kControlBehaviorOffsetContents
;
1393 if ( tool
->CanBeToggled() )
1394 behaviour
|= kControlBehaviorToggles
;
1395 err
= CreateBevelButtonControl( window
,
1396 &toolrect
, CFSTR(""), kControlBevelButtonNormalBevel
,
1397 behaviour
, &info
, 0, 0, 0, &controlHandle
);
1400 #if wxMAC_USE_NATIVE_TOOLBAR
1401 HIToolbarItemRef item
;
1402 wxString labelStr
= wxString::Format(wxT("%xd"), (int)tool
);
1403 err
= HIToolbarItemCreate(
1404 wxMacCFStringHolder(labelStr
, wxFont::GetDefaultEncoding()),
1405 kHIToolbarItemCantBeRemoved
| kHIToolbarItemAnchoredLeft
| kHIToolbarItemAllowDuplicates
, &item
);
1408 InstallEventHandler(
1409 HIObjectGetEventTarget(item
), GetwxMacToolBarEventHandlerUPP(),
1410 GetEventTypeCount(toolBarEventList
), toolBarEventList
, tool
, NULL
);
1411 HIToolbarItemSetLabel( item
, wxMacCFStringHolder(tool
->GetLabel(), m_font
.GetEncoding()) );
1412 HIToolbarItemSetIconRef( item
, info
.u
.iconRef
);
1413 HIToolbarItemSetCommandID( item
, kHIToolbarCommandPressAction
);
1414 tool
->SetToolbarItemRef( item
);
1418 wxMacReleaseBitmapButton( &info
);
1421 SetBevelButtonTextPlacement( m_controlHandle
, kControlBevelButtonPlaceBelowGraphic
);
1422 UMASetControlTitle( m_controlHandle
, label
, wxFont::GetDefaultEncoding() );
1425 InstallControlEventHandler(
1426 (ControlRef
) controlHandle
, GetwxMacToolBarToolEventHandlerUPP(),
1427 GetEventTypeCount(eventList
), eventList
, tool
, NULL
);
1429 tool
->SetControlHandle( controlHandle
);
1433 case wxTOOL_STYLE_CONTROL
:
1435 #if wxMAC_USE_NATIVE_TOOLBAR
1437 wxASSERT( tool
->GetControl() != NULL
);
1438 HIToolbarItemRef item
;
1439 HIViewRef viewRef
= (HIViewRef
) tool
->GetControl()->GetHandle() ;
1440 // as this control now is part of both the wxToolBar children and the native toolbar, we have to increase the
1441 // reference count to make sure we are not dealing with zombie controls after the native toolbar has released its views
1442 CFRetain( viewRef
) ;
1443 CFDataRef data
= CFDataCreate( kCFAllocatorDefault
, (UInt8
*) &viewRef
, sizeof(viewRef
) ) ;
1444 err
= HIToolbarCreateItemWithIdentifier((HIToolbarRef
) m_macHIToolbarRef
,kControlToolbarItemClassID
,
1449 tool
->SetToolbarItemRef( item
);
1455 // right now there's nothing to do here
1465 if ( controlHandle
)
1467 ControlRef container
= (ControlRef
) GetHandle();
1468 wxASSERT_MSG( container
!= NULL
, wxT("No valid Mac container control") );
1470 UMAShowControl( controlHandle
);
1471 ::EmbedControl( controlHandle
, container
);
1474 if ( tool
->CanBeToggled() && tool
->IsToggled() )
1475 tool
->UpdateToggleImage( true );
1477 // nothing special to do here - we relayout in Realize() later
1478 tool
->Attach( this );
1479 InvalidateBestSize();
1483 wxString errMsg
= wxString::Format( wxT("wxToolBar::DoInsertTool - failure [%ld]"), (long)err
);
1484 wxFAIL_MSG( errMsg
.c_str() );
1487 return (err
== noErr
);
1490 void wxToolBar::DoSetToggle(wxToolBarToolBase
*WXUNUSED(tool
), bool WXUNUSED(toggle
))
1492 wxFAIL_MSG( wxT("not implemented") );
1495 bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos
), wxToolBarToolBase
*toolbase
)
1497 wxToolBarTool
* tool
= wx_static_cast( wxToolBarTool
*, toolbase
);
1498 wxToolBarToolsList::compatibility_iterator node
;
1499 for ( node
= m_tools
.GetFirst(); node
; node
= node
->GetNext() )
1501 wxToolBarToolBase
*tool2
= node
->GetData();
1502 if ( tool2
== tool
)
1504 // let node point to the next node in the list
1505 node
= node
->GetNext();
1511 wxSize sz
= ((wxToolBarTool
*)tool
)->GetSize();
1515 #if wxMAC_USE_NATIVE_TOOLBAR
1516 CFIndex removeIndex
= tool
->GetIndex();
1519 switch ( tool
->GetStyle() )
1521 case wxTOOL_STYLE_CONTROL
:
1523 tool
->GetControl()->Destroy();
1524 tool
->ClearControl();
1528 case wxTOOL_STYLE_BUTTON
:
1529 case wxTOOL_STYLE_SEPARATOR
:
1530 if ( tool
->GetControlHandle() )
1532 #if wxMAC_USE_NATIVE_TOOLBAR
1533 if ( removeIndex
!= -1 && m_macHIToolbarRef
)
1535 HIToolbarRemoveItemAtIndex( (HIToolbarRef
) m_macHIToolbarRef
, removeIndex
);
1536 tool
->SetIndex( -1 );
1540 tool
->ClearControl();
1548 // and finally reposition all the controls after this one
1550 for ( /* node -> first after deleted */; node
; node
= node
->GetNext() )
1552 wxToolBarTool
*tool2
= (wxToolBarTool
*) node
->GetData();
1553 wxPoint pt
= tool2
->GetPosition();
1555 if ( GetWindowStyleFlag() & wxTB_VERTICAL
)
1560 tool2
->SetPosition( pt
);
1562 #if wxMAC_USE_NATIVE_TOOLBAR
1563 if ( removeIndex
!= -1 && tool2
->GetIndex() > removeIndex
)
1564 tool2
->SetIndex( tool2
->GetIndex() - 1 );
1568 InvalidateBestSize();
1573 void wxToolBar::OnPaint(wxPaintEvent
& event
)
1575 #if wxMAC_USE_NATIVE_TOOLBAR
1576 if ( m_macUsesNativeToolbar
)
1588 bool drawMetalTheme
= MacGetTopLevelWindow()->MacGetMetalAppearance();
1589 bool minimumUmaAvailable
= (UMAGetSystemVersion() >= 0x1030);
1591 #if wxMAC_USE_CORE_GRAPHICS && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
1592 if ( !drawMetalTheme
&& minimumUmaAvailable
)
1594 HIThemePlacardDrawInfo info
;
1595 memset( &info
, 0, sizeof(info
) );
1597 info
.state
= IsEnabled() ? kThemeStateActive
: kThemeStateInactive
;
1599 CGContextRef cgContext
= (CGContextRef
) MacGetCGContextRef();
1600 HIRect rect
= CGRectMake( 0, 0, w
, h
);
1601 HIThemeDrawPlacard( &rect
, &info
, cgContext
, kHIThemeOrientationNormal
);
1605 // leave the background as it is (striped or metal)
1610 const bool drawBorder
= true;
1614 wxMacPortSetter
helper( &dc
);
1616 if ( !drawMetalTheme
|| !minimumUmaAvailable
)
1618 Rect toolbarrect
= { dc
.YLOG2DEVMAC(0), dc
.XLOG2DEVMAC(0),
1619 dc
.YLOG2DEVMAC(h
), dc
.XLOG2DEVMAC(w
) };
1622 if ( toolbarrect
.left
< 0 )
1623 toolbarrect
.left
= 0;
1624 if ( toolbarrect
.top
< 0 )
1625 toolbarrect
.top
= 0;
1628 UMADrawThemePlacard( &toolbarrect
, IsEnabled() ? kThemeStateActive
: kThemeStateInactive
);
1632 #if TARGET_API_MAC_OSX
1633 HIRect hiToolbarrect
= CGRectMake(
1634 dc
.YLOG2DEVMAC(0), dc
.XLOG2DEVMAC(0),
1635 dc
.YLOG2DEVREL(h
), dc
.XLOG2DEVREL(w
) );
1636 CGContextRef cgContext
;
1639 GetPortBounds( (CGrafPtr
) dc
.m_macPort
, &bounds
);
1640 QDBeginCGContext( (CGrafPtr
) dc
.m_macPort
, &cgContext
);
1642 CGContextTranslateCTM( cgContext
, 0, bounds
.bottom
- bounds
.top
);
1643 CGContextScaleCTM( cgContext
, 1, -1 );
1645 HIThemeBackgroundDrawInfo drawInfo
;
1646 drawInfo
.version
= 0;
1647 drawInfo
.state
= kThemeStateActive
;
1648 drawInfo
.kind
= kThemeBackgroundMetal
;
1649 HIThemeApplyBackground( &hiToolbarrect
, &drawInfo
, cgContext
, kHIThemeOrientationNormal
);
1651 QDEndCGContext( (CGrafPtr
) dc
.m_macPort
, &cgContext
);
1660 #endif // wxUSE_TOOLBAR