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
)
397 int mac_x
= position
.x
;
398 int mac_y
= position
.y
;
403 GetControlBounds( m_controlHandle
, &contrlRect
);
404 int former_mac_x
= contrlRect
.left
;
405 int former_mac_y
= contrlRect
.top
;
406 GetToolBar()->GetToolSize();
408 if ( mac_x
!= former_mac_x
|| mac_y
!= former_mac_y
)
410 UMAMoveControl( m_controlHandle
, mac_x
, mac_y
);
413 else if ( IsControl() )
415 // embedded native controls are moved by the OS
416 #if wxMAC_USE_NATIVE_TOOLBAR
417 if ( ((wxToolBar
*)GetToolBar())->MacWantsNativeToolbar() == false )
420 GetControl()->Move( position
);
428 GetControlBounds( m_controlHandle
, &contrlRect
);
429 int former_mac_x
= contrlRect
.left
;
430 int former_mac_y
= contrlRect
.top
;
432 if ( mac_x
!= former_mac_x
|| mac_y
!= former_mac_y
)
433 UMAMoveControl( m_controlHandle
, mac_x
, mac_y
);
438 void wxToolBarTool::UpdateToggleImage( bool toggle
)
443 int w
= m_bmpNormal
.GetWidth();
444 int h
= m_bmpNormal
.GetHeight();
445 wxBitmap
bmp( w
, h
);
448 dc
.SelectObject( bmp
);
449 dc
.SetPen( wxPen(*wxBLACK
) );
450 dc
.SetBrush( wxBrush( *wxLIGHT_GREY
));
451 dc
.DrawRectangle( 0, 0, w
, h
);
452 dc
.DrawBitmap( m_bmpNormal
, 0, 0, true );
453 dc
.SelectObject( wxNullBitmap
);
454 ControlButtonContentInfo info
;
455 wxMacCreateBitmapButton( &info
, bmp
);
456 SetControlData( m_controlHandle
, 0, kControlIconContentTag
, sizeof(info
), (Ptr
)&info
);
457 #if wxMAC_USE_NATIVE_TOOLBAR
458 if (m_toolbarItemRef
!= NULL
)
460 HIToolbarItemSetIconRef( m_toolbarItemRef
, info
.u
.iconRef
);
463 wxMacReleaseBitmapButton( &info
);
467 ControlButtonContentInfo info
;
468 wxMacCreateBitmapButton( &info
, m_bmpNormal
);
469 SetControlData( m_controlHandle
, 0, kControlIconContentTag
, sizeof(info
), (Ptr
)&info
);
470 #if wxMAC_USE_NATIVE_TOOLBAR
471 if (m_toolbarItemRef
!= NULL
)
473 HIToolbarItemSetIconRef( m_toolbarItemRef
, info
.u
.iconRef
);
476 wxMacReleaseBitmapButton( &info
);
479 IconTransformType transform
= toggle
? kTransformSelected
: kTransformNone
;
481 m_controlHandle
, 0, kControlIconTransformTag
,
482 sizeof(transform
), (Ptr
)&transform
);
483 HIViewSetNeedsDisplay( m_controlHandle
, true );
486 ::SetControl32BitValue( m_controlHandle
, toggle
);
490 wxToolBarTool::wxToolBarTool(
493 const wxString
& label
,
494 const wxBitmap
& bmpNormal
,
495 const wxBitmap
& bmpDisabled
,
497 wxObject
*clientData
,
498 const wxString
& shortHelp
,
499 const wxString
& longHelp
)
502 tbar
, id
, label
, bmpNormal
, bmpDisabled
, kind
,
503 clientData
, shortHelp
, longHelp
)
509 #pragma mark Toolbar Implementation
511 wxToolBarToolBase
*wxToolBar::CreateTool(
513 const wxString
& label
,
514 const wxBitmap
& bmpNormal
,
515 const wxBitmap
& bmpDisabled
,
517 wxObject
*clientData
,
518 const wxString
& shortHelp
,
519 const wxString
& longHelp
)
521 return new wxToolBarTool(
522 this, id
, label
, bmpNormal
, bmpDisabled
, kind
,
523 clientData
, shortHelp
, longHelp
);
526 wxToolBarToolBase
* wxToolBar::CreateTool( wxControl
*control
)
528 return new wxToolBarTool( this, control
);
531 void wxToolBar::Init()
535 m_defaultWidth
= kwxMacToolBarToolDefaultWidth
;
536 m_defaultHeight
= kwxMacToolBarToolDefaultHeight
;
538 #if wxMAC_USE_NATIVE_TOOLBAR
539 m_macHIToolbarRef
= NULL
;
540 m_macUsesNativeToolbar
= false;
544 #define kControlToolbarItemClassID CFSTR( "org.wxwidgets.controltoolbaritem" )
546 const EventTypeSpec kEvents
[] =
548 { kEventClassHIObject
, kEventHIObjectConstruct
},
549 { kEventClassHIObject
, kEventHIObjectInitialize
},
550 { kEventClassHIObject
, kEventHIObjectDestruct
},
552 { kEventClassToolbarItem
, kEventToolbarItemCreateCustomView
}
555 const EventTypeSpec kViewEvents
[] =
557 { kEventClassControl
, kEventControlGetSizeConstraints
}
560 struct ControlToolbarItem
562 HIToolbarItemRef toolbarItem
;
564 wxSize lastValidSize
;
567 static pascal OSStatus
ControlToolbarItemHandler( EventHandlerCallRef inCallRef
, EventRef inEvent
, void* inUserData
)
569 OSStatus result
= eventNotHandledErr
;
570 ControlToolbarItem
* object
= (ControlToolbarItem
*)inUserData
;
572 switch ( GetEventClass( inEvent
) )
574 case kEventClassHIObject
:
575 switch ( GetEventKind( inEvent
) )
577 case kEventHIObjectConstruct
:
579 HIObjectRef toolbarItem
;
580 ControlToolbarItem
* item
;
582 GetEventParameter( inEvent
, kEventParamHIObjectInstance
, typeHIObjectRef
, NULL
,
583 sizeof( HIObjectRef
), NULL
, &toolbarItem
);
585 item
= (ControlToolbarItem
*) malloc(sizeof(ControlToolbarItem
)) ;
586 item
->toolbarItem
= toolbarItem
;
587 item
->viewRef
= NULL
;
589 SetEventParameter( inEvent
, kEventParamHIObjectInstance
, typeVoidPtr
, sizeof( void * ), &item
);
595 case kEventHIObjectInitialize
:
596 result
= CallNextEventHandler( inCallRef
, inEvent
);
597 if ( result
== noErr
)
600 GetEventParameter( inEvent
, kEventParamToolbarItemConfigData
, typeCFTypeRef
, NULL
,
601 sizeof( CFTypeRef
), NULL
, &data
);
605 wxASSERT_MSG( CFDataGetLength( data
) == sizeof( viewRef
) , wxT("Illegal Data passed") ) ;
606 memcpy( &viewRef
, CFDataGetBytePtr( data
) , sizeof( viewRef
) ) ;
608 object
->viewRef
= (HIViewRef
) viewRef
;
614 case kEventHIObjectDestruct
:
621 case kEventClassToolbarItem
:
622 switch ( GetEventKind( inEvent
) )
624 case kEventToolbarItemCreateCustomView
:
626 HIViewRef viewRef
= object
->viewRef
;
628 HIViewRemoveFromSuperview( viewRef
) ;
629 HIViewSetVisible(viewRef
, true) ;
630 InstallEventHandler( GetControlEventTarget( viewRef
), ControlToolbarItemHandler
,
631 GetEventTypeCount( kViewEvents
), kViewEvents
, object
, NULL
);
633 result
= SetEventParameter( inEvent
, kEventParamControlRef
, typeControlRef
, sizeof( HIViewRef
), &viewRef
);
639 case kEventClassControl
:
640 switch ( GetEventKind( inEvent
) )
642 case kEventControlGetSizeConstraints
:
644 wxWindow
* wxwindow
= wxFindControlFromMacControl(object
->viewRef
) ;
647 wxSize sz
= wxwindow
->GetSize() ;
648 sz
.x
-= wxwindow
->MacGetLeftBorderSize() + wxwindow
->MacGetRightBorderSize();
649 sz
.y
-= wxwindow
->MacGetTopBorderSize() + wxwindow
->MacGetBottomBorderSize();
650 // during toolbar layout the native window sometimes gets negative sizes
651 // so we always keep the last valid size here, to make sure we survive the
653 if ( sz
.x
> 0 && sz
.y
> 0 )
654 object
->lastValidSize
= sz
;
656 sz
= object
->lastValidSize
;
659 min
.width
= max
.width
= sz
.x
;
660 min
.height
= max
.height
= sz
.y
;
662 result
= SetEventParameter( inEvent
, kEventParamMinimumSize
, typeHISize
,
663 sizeof( HISize
), &min
);
665 result
= SetEventParameter( inEvent
, kEventParamMaximumSize
, typeHISize
,
666 sizeof( HISize
), &max
);
678 void RegisterControlToolbarItemClass()
680 static bool sRegistered
;
684 HIObjectRegisterSubclass( kControlToolbarItemClassID
, kHIToolbarItemClassID
, 0,
685 ControlToolbarItemHandler
, GetEventTypeCount( kEvents
), kEvents
, 0, NULL
);
691 HIToolbarItemRef
CreateControlToolbarItem(CFStringRef inIdentifier
, CFTypeRef inConfigData
)
693 RegisterControlToolbarItemClass();
697 UInt32 options
= kHIToolbarItemAllowDuplicates
;
698 HIToolbarItemRef result
= NULL
;
700 err
= CreateEvent( NULL
, kEventClassHIObject
, kEventHIObjectInitialize
, GetCurrentEventTime(), 0, &event
);
701 require_noerr( err
, CantCreateEvent
);
703 SetEventParameter( event
, kEventParamAttributes
, typeUInt32
, sizeof( UInt32
), &options
);
704 SetEventParameter( event
, kEventParamToolbarItemIdentifier
, typeCFStringRef
, sizeof( CFStringRef
), &inIdentifier
);
707 SetEventParameter( event
, kEventParamToolbarItemConfigData
, typeCFTypeRef
, sizeof( CFTypeRef
), &inConfigData
);
709 err
= HIObjectCreate( kControlToolbarItemClassID
, event
, (HIObjectRef
*)&result
);
712 ReleaseEvent( event
);
717 static const EventTypeSpec kToolbarEvents
[] =
719 { kEventClassToolbar
, kEventToolbarGetDefaultIdentifiers
},
720 { kEventClassToolbar
, kEventToolbarGetAllowedIdentifiers
},
721 { kEventClassToolbar
, kEventToolbarCreateItemWithIdentifier
},
724 static OSStatus
ToolbarDelegateHandler( EventHandlerCallRef inCallRef
, EventRef inEvent
, void* inUserData
)
726 OSStatus result
= eventNotHandledErr
;
728 // wxToolBar* toolbar = (wxToolBar*) inUserData ;
729 CFMutableArrayRef array
;
731 switch ( GetEventKind( inEvent
) )
733 case kEventToolbarGetDefaultIdentifiers
:
735 GetEventParameter( inEvent
, kEventParamMutableArray
, typeCFMutableArrayRef
, NULL
,
736 sizeof( CFMutableArrayRef
), NULL
, &array
);
737 // not implemented yet
738 // GetToolbarDefaultItems( array );
743 case kEventToolbarGetAllowedIdentifiers
:
745 GetEventParameter( inEvent
, kEventParamMutableArray
, typeCFMutableArrayRef
, NULL
,
746 sizeof( CFMutableArrayRef
), NULL
, &array
);
747 // not implemented yet
748 // GetToolbarAllowedItems( array );
752 case kEventToolbarCreateItemWithIdentifier
:
754 HIToolbarItemRef item
= NULL
;
755 CFTypeRef data
= NULL
;
756 CFStringRef identifier
= NULL
;
758 GetEventParameter( inEvent
, kEventParamToolbarItemIdentifier
, typeCFStringRef
, NULL
,
759 sizeof( CFStringRef
), NULL
, &identifier
);
761 GetEventParameter( inEvent
, kEventParamToolbarItemConfigData
, typeCFTypeRef
, NULL
,
762 sizeof( CFTypeRef
), NULL
, &data
);
764 if ( CFStringCompare( kControlToolbarItemClassID
, identifier
, kCFCompareBackwards
) == kCFCompareEqualTo
)
766 item
= CreateControlToolbarItem( kControlToolbarItemClassID
, data
);
769 SetEventParameter( inEvent
, kEventParamToolbarItem
, typeHIToolbarItemRef
,
770 sizeof( HIToolbarItemRef
), &item
);
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;
1073 bool setChoiceInGroup
= false;
1075 #if wxMAC_USE_NATIVE_TOOLBAR
1076 CFIndex currentPosition
= 0;
1077 bool insertAll
= false;
1080 node
= m_tools
.GetFirst();
1081 while ( node
!= NULL
)
1083 tool
= (wxToolBarTool
*) node
->GetData();
1086 node
= node
->GetNext();
1090 // set tool position:
1091 // for the moment just perform a single row/column alignment
1092 wxSize cursize
= tool
->GetSize();
1093 if ( x
+ cursize
.x
> maxWidth
)
1094 maxWidth
= x
+ cursize
.x
;
1095 if ( y
+ cursize
.y
> maxHeight
)
1096 maxHeight
= y
+ cursize
.y
;
1098 if ( GetWindowStyleFlag() & wxTB_VERTICAL
)
1100 int x1
= x
+ ( maxToolWidth
- cursize
.x
) / 2;
1101 tool
->SetPosition( wxPoint(x1
, y
) );
1105 int y1
= y
+ ( maxToolHeight
- cursize
.y
) / 2;
1106 tool
->SetPosition( wxPoint(x
, y1
) );
1109 // update the item positioning state
1110 if ( GetWindowStyleFlag() & wxTB_VERTICAL
)
1111 y
+= cursize
.y
+ kwxMacToolSpacing
;
1113 x
+= cursize
.x
+ kwxMacToolSpacing
;
1115 #if wxMAC_USE_NATIVE_TOOLBAR
1116 // install in native HIToolbar
1117 if ( m_macHIToolbarRef
!= NULL
)
1119 HIToolbarItemRef hiItemRef
= tool
->GetToolbarItemRef();
1120 if ( hiItemRef
!= NULL
)
1122 if ( insertAll
|| (tool
->GetIndex() != currentPosition
) )
1124 OSStatus err
= noErr
;
1129 // if this is the first tool that gets newly inserted or repositioned
1130 // first remove all 'old' tools from here to the right, because of this
1131 // all following tools will have to be reinserted (insertAll). i = 100 because there's
1132 // no way to determine how many there are in a toolbar, so just a high number :-(
1133 for ( CFIndex i
= 100; i
>= currentPosition
; --i
)
1135 err
= HIToolbarRemoveItemAtIndex( (HIToolbarRef
) m_macHIToolbarRef
, i
);
1140 wxString errMsg
= wxString::Format( wxT("HIToolbarRemoveItemAtIndex failed [%ld]"), (long)err
);
1141 wxFAIL_MSG( errMsg
.c_str() );
1145 err
= HIToolbarInsertItemAtIndex( (HIToolbarRef
) m_macHIToolbarRef
, hiItemRef
, currentPosition
);
1148 wxString errMsg
= wxString::Format( wxT("HIToolbarInsertItemAtIndex failed [%ld]"), (long)err
);
1149 wxFAIL_MSG( errMsg
.c_str() );
1152 tool
->SetIndex( currentPosition
);
1160 // update radio button (and group) state
1161 lastIsRadio
= curIsRadio
;
1162 curIsRadio
= ( tool
->IsButton() && (tool
->GetKind() == wxITEM_RADIO
) );
1166 if ( tool
->IsToggled() )
1167 DoToggleTool( tool
, true );
1169 setChoiceInGroup
= false;
1175 if ( tool
->Toggle( true ) )
1177 DoToggleTool( tool
, true );
1178 setChoiceInGroup
= true;
1181 else if ( tool
->IsToggled() )
1183 if ( tool
->IsToggled() )
1184 DoToggleTool( tool
, true );
1186 wxToolBarToolsList::compatibility_iterator nodePrev
= node
->GetPrevious();
1187 while ( nodePrev
!= NULL
)
1189 wxToolBarToolBase
*toggleTool
= nodePrev
->GetData();
1190 if ( (toggleTool
== NULL
) || !toggleTool
->IsButton() || (toggleTool
->GetKind() != wxITEM_RADIO
) )
1193 if ( toggleTool
->Toggle( false ) )
1194 DoToggleTool( toggleTool
, false );
1196 nodePrev
= nodePrev
->GetPrevious();
1201 node
= node
->GetNext();
1204 if ( GetWindowStyleFlag() & wxTB_HORIZONTAL
)
1206 // if not set yet, only one row
1207 if ( m_maxRows
<= 0 )
1210 m_minWidth
= maxWidth
;
1212 maxHeight
+= m_yMargin
+ kwxMacToolBarTopMargin
;
1213 m_minHeight
= m_maxHeight
= maxHeight
;
1217 // if not set yet, have one column
1218 if ( (GetToolsCount() > 0) && (m_maxRows
<= 0) )
1219 SetRows( GetToolsCount() );
1221 m_minHeight
= maxHeight
;
1223 maxWidth
+= m_xMargin
+ kwxMacToolBarLeftMargin
;
1224 m_minWidth
= m_maxWidth
= maxWidth
;
1228 // FIXME: should this be OSX-only?
1230 bool wantNativeToolbar
, ownToolbarInstalled
;
1232 // attempt to install the native toolbar
1233 wantNativeToolbar
= ((GetWindowStyleFlag() & wxTB_VERTICAL
) == 0);
1234 MacInstallNativeToolbar( wantNativeToolbar
);
1235 (void)MacTopLevelHasNativeToolbar( &ownToolbarInstalled
);
1236 if (!ownToolbarInstalled
)
1238 SetSize( maxWidth
, maxHeight
);
1239 InvalidateBestSize();
1243 SetSize( maxWidth
, maxHeight
);
1244 InvalidateBestSize();
1247 SetBestFittingSize();
1252 void wxToolBar::SetToolBitmapSize(const wxSize
& size
)
1254 m_defaultWidth
= size
.x
+ kwxMacToolBorder
;
1255 m_defaultHeight
= size
.y
+ kwxMacToolBorder
;
1257 #if wxMAC_USE_NATIVE_TOOLBAR
1258 if (m_macHIToolbarRef
!= NULL
)
1260 int maxs
= wxMax( size
.x
, size
.y
);
1261 HIToolbarDisplaySize sizeSpec
;
1263 sizeSpec
= kHIToolbarDisplaySizeNormal
;
1264 else if ( maxs
> 24 )
1265 sizeSpec
= kHIToolbarDisplaySizeDefault
;
1267 sizeSpec
= kHIToolbarDisplaySizeSmall
;
1269 HIToolbarSetDisplaySize( (HIToolbarRef
) m_macHIToolbarRef
, sizeSpec
);
1274 // The button size is bigger than the bitmap size
1275 wxSize
wxToolBar::GetToolSize() const
1277 return wxSize(m_defaultWidth
+ kwxMacToolBorder
, m_defaultHeight
+ kwxMacToolBorder
);
1280 void wxToolBar::SetRows(int nRows
)
1282 // avoid resizing the frame uselessly
1283 if ( nRows
!= m_maxRows
)
1287 void wxToolBar::MacSuperChangedPosition()
1289 wxWindow::MacSuperChangedPosition();
1291 #if wxMAC_USE_NATIVE_TOOLBAR
1292 if (! m_macUsesNativeToolbar
)
1300 wxToolBarToolBase
*wxToolBar::FindToolForPosition(wxCoord x
, wxCoord y
) const
1302 wxToolBarTool
*tool
;
1303 wxToolBarToolsList::compatibility_iterator node
= m_tools
.GetFirst();
1304 while ( node
!= NULL
)
1306 tool
= (wxToolBarTool
*)node
->GetData();
1309 wxRect2DInt
r( tool
->GetPosition(), tool
->GetSize() );
1310 if ( r
.Contains( wxPoint( x
, y
) ) )
1314 node
= node
->GetNext();
1317 return (wxToolBarToolBase
*)NULL
;
1320 wxString
wxToolBar::MacGetToolTipString( wxPoint
&pt
)
1322 wxToolBarToolBase
*tool
= FindToolForPosition( pt
.x
, pt
.y
);
1324 return tool
->GetShortHelp();
1326 return wxEmptyString
;
1329 void wxToolBar::DoEnableTool(wxToolBarToolBase
*t
, bool enable
)
1332 ((wxToolBarTool
*)t
)->DoEnable( enable
);
1335 void wxToolBar::DoToggleTool(wxToolBarToolBase
*t
, bool toggle
)
1337 wxToolBarTool
*tool
= (wxToolBarTool
*)t
;
1338 if ( ( tool
!= NULL
) && tool
->IsButton() )
1339 tool
->UpdateToggleImage( toggle
);
1342 bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos
), wxToolBarToolBase
*toolBase
)
1344 wxToolBarTool
*tool
= wx_static_cast( wxToolBarTool
*, toolBase
);
1348 WindowRef window
= (WindowRef
) MacGetTopLevelWindowRef();
1349 wxSize toolSize
= GetToolSize();
1350 Rect toolrect
= { 0, 0, toolSize
.y
, toolSize
.x
};
1351 ControlRef controlHandle
= NULL
;
1354 switch (tool
->GetStyle())
1356 case wxTOOL_STYLE_SEPARATOR
:
1358 wxASSERT( tool
->GetControlHandle() == NULL
);
1361 if ( GetWindowStyleFlag() & wxTB_VERTICAL
)
1362 toolrect
.bottom
= toolSize
.y
;
1364 toolrect
.right
= toolSize
.x
;
1366 #ifdef __WXMAC_OSX__
1367 // in flat style we need a visual separator
1368 #if wxMAC_USE_NATIVE_TOOLBAR
1369 HIToolbarItemRef item
;
1370 err
= HIToolbarItemCreate(
1371 kHIToolbarSeparatorIdentifier
,
1372 kHIToolbarItemCantBeRemoved
| kHIToolbarItemIsSeparator
| kHIToolbarItemAllowDuplicates
,
1375 tool
->SetToolbarItemRef( item
);
1378 CreateSeparatorControl( window
, &toolrect
, &controlHandle
);
1379 tool
->SetControlHandle( controlHandle
);
1384 case wxTOOL_STYLE_BUTTON
:
1386 wxASSERT( tool
->GetControlHandle() == NULL
);
1387 ControlButtonContentInfo info
;
1388 wxMacCreateBitmapButton( &info
, tool
->GetNormalBitmap(), kControlContentIconRef
);
1390 if ( UMAGetSystemVersion() >= 0x1000)
1392 CreateIconControl( window
, &toolrect
, &info
, false, &controlHandle
);
1396 SInt16 behaviour
= kControlBehaviorOffsetContents
;
1397 if ( tool
->CanBeToggled() )
1398 behaviour
|= kControlBehaviorToggles
;
1399 err
= CreateBevelButtonControl( window
,
1400 &toolrect
, CFSTR(""), kControlBevelButtonNormalBevel
,
1401 behaviour
, &info
, 0, 0, 0, &controlHandle
);
1404 #if wxMAC_USE_NATIVE_TOOLBAR
1405 HIToolbarItemRef item
;
1406 wxString labelStr
= wxString::Format(wxT("%xd"), (int)tool
);
1407 err
= HIToolbarItemCreate(
1408 wxMacCFStringHolder(labelStr
, wxFont::GetDefaultEncoding()),
1409 kHIToolbarItemCantBeRemoved
| kHIToolbarItemAnchoredLeft
| kHIToolbarItemAllowDuplicates
, &item
);
1412 InstallEventHandler(
1413 HIObjectGetEventTarget(item
), GetwxMacToolBarEventHandlerUPP(),
1414 GetEventTypeCount(toolBarEventList
), toolBarEventList
, tool
, NULL
);
1415 HIToolbarItemSetLabel( item
, wxMacCFStringHolder(tool
->GetLabel(), m_font
.GetEncoding()) );
1416 HIToolbarItemSetIconRef( item
, info
.u
.iconRef
);
1417 HIToolbarItemSetCommandID( item
, kHIToolbarCommandPressAction
);
1418 tool
->SetToolbarItemRef( item
);
1422 wxMacReleaseBitmapButton( &info
);
1425 SetBevelButtonTextPlacement( m_controlHandle
, kControlBevelButtonPlaceBelowGraphic
);
1426 UMASetControlTitle( m_controlHandle
, label
, wxFont::GetDefaultEncoding() );
1429 InstallControlEventHandler(
1430 (ControlRef
) controlHandle
, GetwxMacToolBarToolEventHandlerUPP(),
1431 GetEventTypeCount(eventList
), eventList
, tool
, NULL
);
1433 tool
->SetControlHandle( controlHandle
);
1437 case wxTOOL_STYLE_CONTROL
:
1439 #if wxMAC_USE_NATIVE_TOOLBAR
1441 wxASSERT( tool
->GetControl() != NULL
);
1442 HIToolbarItemRef item
;
1443 HIViewRef viewRef
= (HIViewRef
) tool
->GetControl()->GetHandle() ;
1444 // as this control now is part of both the wxToolBar children and the native toolbar, we have to increase the
1445 // reference count to make sure we are not dealing with zombie controls after the native toolbar has released its views
1446 CFRetain( viewRef
) ;
1447 CFDataRef data
= CFDataCreate( kCFAllocatorDefault
, (UInt8
*) &viewRef
, sizeof(viewRef
) ) ;
1448 err
= HIToolbarCreateItemWithIdentifier((HIToolbarRef
) m_macHIToolbarRef
,kControlToolbarItemClassID
,
1453 tool
->SetToolbarItemRef( item
);
1459 // right now there's nothing to do here
1469 if ( controlHandle
)
1471 ControlRef container
= (ControlRef
) GetHandle();
1472 wxASSERT_MSG( container
!= NULL
, wxT("No valid Mac container control") );
1474 UMAShowControl( controlHandle
);
1475 ::EmbedControl( controlHandle
, container
);
1478 if ( tool
->CanBeToggled() && tool
->IsToggled() )
1479 tool
->UpdateToggleImage( true );
1481 // nothing special to do here - we relayout in Realize() later
1482 tool
->Attach( this );
1483 InvalidateBestSize();
1487 wxString errMsg
= wxString::Format( wxT("wxToolBar::DoInsertTool - failure [%ld]"), (long)err
);
1488 wxFAIL_MSG( errMsg
.c_str() );
1491 return (err
== noErr
);
1494 void wxToolBar::DoSetToggle(wxToolBarToolBase
*WXUNUSED(tool
), bool WXUNUSED(toggle
))
1496 wxFAIL_MSG( wxT("not implemented") );
1499 bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos
), wxToolBarToolBase
*toolbase
)
1501 wxToolBarTool
* tool
= wx_static_cast( wxToolBarTool
*, toolbase
);
1502 wxToolBarToolsList::compatibility_iterator node
;
1503 for ( node
= m_tools
.GetFirst(); node
; node
= node
->GetNext() )
1505 wxToolBarToolBase
*tool2
= node
->GetData();
1506 if ( tool2
== tool
)
1508 // let node point to the next node in the list
1509 node
= node
->GetNext();
1515 wxSize sz
= ((wxToolBarTool
*)tool
)->GetSize();
1519 #if wxMAC_USE_NATIVE_TOOLBAR
1520 CFIndex removeIndex
= tool
->GetIndex();
1523 switch ( tool
->GetStyle() )
1525 case wxTOOL_STYLE_CONTROL
:
1527 tool
->GetControl()->Destroy();
1528 tool
->ClearControl();
1532 case wxTOOL_STYLE_BUTTON
:
1533 case wxTOOL_STYLE_SEPARATOR
:
1534 if ( tool
->GetControlHandle() )
1536 #if wxMAC_USE_NATIVE_TOOLBAR
1537 if ( removeIndex
!= -1 && m_macHIToolbarRef
)
1539 HIToolbarRemoveItemAtIndex( (HIToolbarRef
) m_macHIToolbarRef
, removeIndex
);
1540 tool
->SetIndex( -1 );
1544 tool
->ClearControl();
1552 // and finally reposition all the controls after this one
1554 for ( /* node -> first after deleted */; node
; node
= node
->GetNext() )
1556 wxToolBarTool
*tool2
= (wxToolBarTool
*) node
->GetData();
1557 wxPoint pt
= tool2
->GetPosition();
1559 if ( GetWindowStyleFlag() & wxTB_VERTICAL
)
1564 tool2
->SetPosition( pt
);
1566 #if wxMAC_USE_NATIVE_TOOLBAR
1567 if ( removeIndex
!= -1 && tool2
->GetIndex() > removeIndex
)
1568 tool2
->SetIndex( tool2
->GetIndex() - 1 );
1572 InvalidateBestSize();
1577 void wxToolBar::OnPaint(wxPaintEvent
& event
)
1579 #if wxMAC_USE_NATIVE_TOOLBAR
1580 if ( m_macUsesNativeToolbar
)
1592 bool drawMetalTheme
= MacGetTopLevelWindow()->MacGetMetalAppearance();
1593 bool minimumUmaAvailable
= (UMAGetSystemVersion() >= 0x1030);
1595 #if wxMAC_USE_CORE_GRAPHICS && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
1596 if ( !drawMetalTheme
&& minimumUmaAvailable
)
1598 HIThemePlacardDrawInfo info
;
1599 memset( &info
, 0, sizeof(info
) );
1601 info
.state
= IsEnabled() ? kThemeStateActive
: kThemeStateInactive
;
1603 CGContextRef cgContext
= (CGContextRef
) MacGetCGContextRef();
1604 HIRect rect
= CGRectMake( 0, 0, w
, h
);
1605 HIThemeDrawPlacard( &rect
, &info
, cgContext
, kHIThemeOrientationNormal
);
1609 // leave the background as it is (striped or metal)
1614 const bool drawBorder
= true;
1618 wxMacPortSetter
helper( &dc
);
1620 if ( !drawMetalTheme
|| !minimumUmaAvailable
)
1622 Rect toolbarrect
= { dc
.YLOG2DEVMAC(0), dc
.XLOG2DEVMAC(0),
1623 dc
.YLOG2DEVMAC(h
), dc
.XLOG2DEVMAC(w
) };
1626 if ( toolbarrect
.left
< 0 )
1627 toolbarrect
.left
= 0;
1628 if ( toolbarrect
.top
< 0 )
1629 toolbarrect
.top
= 0;
1632 UMADrawThemePlacard( &toolbarrect
, IsEnabled() ? kThemeStateActive
: kThemeStateInactive
);
1636 #if TARGET_API_MAC_OSX
1637 HIRect hiToolbarrect
= CGRectMake(
1638 dc
.YLOG2DEVMAC(0), dc
.XLOG2DEVMAC(0),
1639 dc
.YLOG2DEVREL(h
), dc
.XLOG2DEVREL(w
) );
1640 CGContextRef cgContext
;
1643 GetPortBounds( (CGrafPtr
) dc
.m_macPort
, &bounds
);
1644 QDBeginCGContext( (CGrafPtr
) dc
.m_macPort
, &cgContext
);
1646 CGContextTranslateCTM( cgContext
, 0, bounds
.bottom
- bounds
.top
);
1647 CGContextScaleCTM( cgContext
, 1, -1 );
1649 HIThemeBackgroundDrawInfo drawInfo
;
1650 drawInfo
.version
= 0;
1651 drawInfo
.state
= kThemeStateActive
;
1652 drawInfo
.kind
= kThemeBackgroundMetal
;
1653 HIThemeApplyBackground( &hiToolbarrect
, &drawInfo
, cgContext
, kHIThemeOrientationNormal
);
1655 QDEndCGContext( (CGrafPtr
) dc
.m_macPort
, &cgContext
);
1664 #endif // wxUSE_TOOLBAR