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()
87 WXWidget
GetControlHandle()
89 return (WXWidget
) m_controlHandle
;
92 void SetControlHandle( ControlRef handle
)
94 m_controlHandle
= handle
;
97 void SetPosition( const wxPoint
& position
);
102 if ( m_controlHandle
)
105 DisposeControl( m_controlHandle
);
108 // the embedded control is not under the responsibility of the tool
110 m_controlHandle
= NULL
;
113 #if wxMAC_USE_NATIVE_TOOLBAR
114 if ( m_toolbarItemRef
)
116 CFIndex count
= CFGetRetainCount( m_toolbarItemRef
) ;
117 wxASSERT_MSG( count
== 1 , wxT("Reference Count of native tool was not 1 in wxToolBarTool destructor") );
118 CFRelease( m_toolbarItemRef
);
119 m_toolbarItemRef
= NULL
;
124 wxSize
GetSize() const
130 curSize
= GetControl()->GetSize();
132 else if ( IsButton() )
134 curSize
= GetToolBar()->GetToolSize();
139 curSize
= GetToolBar()->GetToolSize();
140 if ( GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
149 wxPoint
GetPosition() const
151 return wxPoint( m_x
, m_y
);
154 bool DoEnable( bool enable
);
156 void UpdateToggleImage( bool toggle
);
158 #if wxMAC_USE_NATIVE_TOOLBAR
159 void SetToolbarItemRef( HIToolbarItemRef ref
)
161 if ( m_controlHandle
)
162 HideControl( m_controlHandle
);
163 if ( m_toolbarItemRef
)
164 CFRelease( m_toolbarItemRef
);
166 m_toolbarItemRef
= ref
;
167 if ( m_toolbarItemRef
)
169 HIToolbarItemSetHelpText(
171 wxMacCFStringHolder( GetShortHelp(), GetToolBar()->GetFont().GetEncoding() ),
172 wxMacCFStringHolder( GetLongHelp(), GetToolBar()->GetFont().GetEncoding() ) );
176 HIToolbarItemRef
GetToolbarItemRef() const
178 return m_toolbarItemRef
;
181 void SetIndex( CFIndex idx
)
186 CFIndex
GetIndex() const
195 m_controlHandle
= NULL
;
197 #if wxMAC_USE_NATIVE_TOOLBAR
198 m_toolbarItemRef
= NULL
;
203 ControlRef m_controlHandle
;
207 #if wxMAC_USE_NATIVE_TOOLBAR
208 HIToolbarItemRef m_toolbarItemRef
;
209 // position in its toolbar, -1 means not inserted
214 static const EventTypeSpec eventList
[] =
216 { kEventClassControl
, kEventControlHit
},
218 { kEventClassControl
, kEventControlHitTest
},
222 static pascal OSStatus
wxMacToolBarToolControlEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
224 OSStatus result
= eventNotHandledErr
;
225 ControlRef controlRef
;
226 wxMacCarbonEvent
cEvent( event
);
228 cEvent
.GetParameter( kEventParamDirectObject
, &controlRef
);
230 switch ( GetEventKind( event
) )
232 case kEventControlHit
:
234 wxToolBarTool
*tbartool
= (wxToolBarTool
*)data
;
235 wxToolBar
*tbar
= tbartool
!= NULL
? (wxToolBar
*) (tbartool
->GetToolBar()) : NULL
;
236 if ((tbartool
!= NULL
) && tbartool
->CanBeToggled())
241 shouldToggle
= !tbartool
->IsToggled();
243 shouldToggle
= (GetControl32BitValue( (ControlRef
)(tbartool
->GetControlHandle()) ) != 0);
246 tbar
->ToggleTool( tbartool
->GetId(), shouldToggle
);
249 if (tbartool
!= NULL
)
250 tbar
->OnLeftClick( tbartool
->GetId(), tbartool
->IsToggled() );
256 case kEventControlHitTest
:
258 HIPoint pt
= cEvent
.GetParameter
<HIPoint
>(kEventParamMouseLocation
);
260 HIViewGetBounds( controlRef
, &rect
);
262 ControlPartCode pc
= kControlNoPart
;
263 if ( CGRectContainsPoint( rect
, pt
) )
264 pc
= kControlIconPart
;
265 cEvent
.SetParameter( kEventParamControlPart
, typeControlPartCode
, pc
);
278 static pascal OSStatus
wxMacToolBarToolEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
280 OSStatus result
= eventNotHandledErr
;
282 switch ( GetEventClass( event
) )
284 case kEventClassControl
:
285 result
= wxMacToolBarToolControlEventHandler( handler
, event
, data
);
295 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacToolBarToolEventHandler
)
297 #if wxMAC_USE_NATIVE_TOOLBAR
299 static const EventTypeSpec toolBarEventList
[] =
301 { kEventClassToolbarItem
, kEventToolbarItemPerformAction
},
304 static pascal OSStatus
wxMacToolBarCommandEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
306 OSStatus result
= eventNotHandledErr
;
308 switch ( GetEventKind( event
) )
310 case kEventToolbarItemPerformAction
:
312 wxToolBarTool
* tbartool
= (wxToolBarTool
*) data
;
313 if ( tbartool
!= NULL
)
315 wxToolBar
*tbar
= (wxToolBar
*)(tbartool
->GetToolBar());
316 int toolID
= tbartool
->GetId();
318 if ( tbartool
->CanBeToggled() )
321 tbar
->ToggleTool(toolID
, !tbartool
->IsToggled() );
325 tbar
->OnLeftClick( toolID
, tbartool
->IsToggled() );
338 static pascal OSStatus
wxMacToolBarEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
340 OSStatus result
= eventNotHandledErr
;
342 switch ( GetEventClass( event
) )
344 case kEventClassToolbarItem
:
345 result
= wxMacToolBarCommandEventHandler( handler
, event
, data
);
355 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacToolBarEventHandler
)
359 bool wxToolBarTool::DoEnable( bool enable
)
363 GetControl()->Enable( enable
);
365 else if ( IsButton() )
367 #if wxMAC_USE_NATIVE_TOOLBAR
368 if ( m_toolbarItemRef
!= NULL
)
369 HIToolbarItemSetEnabled( m_toolbarItemRef
, enable
);
372 if ( m_controlHandle
!= NULL
)
374 #if TARGET_API_MAC_OSX
376 EnableControl( m_controlHandle
);
378 DisableControl( m_controlHandle
);
381 ActivateControl( m_controlHandle
);
383 DeactivateControl( m_controlHandle
);
391 void wxToolBarTool::SetPosition( const wxPoint
& position
)
396 int mac_x
= position
.x
;
397 int mac_y
= position
.y
;
402 GetControlBounds( m_controlHandle
, &contrlRect
);
403 int former_mac_x
= contrlRect
.left
;
404 int former_mac_y
= contrlRect
.top
;
405 GetToolBar()->GetToolSize();
407 if ( mac_x
!= former_mac_x
|| mac_y
!= former_mac_y
)
409 UMAMoveControl( m_controlHandle
, mac_x
, mac_y
);
412 else if ( IsControl() )
414 // embedded native controls are moved by the OS
415 #if wxMAC_USE_NATIVE_TOOLBAR
416 if ( ((wxToolBar
*)GetToolBar())->MacWantsNativeToolbar() == false )
419 GetControl()->Move( position
);
427 GetControlBounds( m_controlHandle
, &contrlRect
);
428 int former_mac_x
= contrlRect
.left
;
429 int former_mac_y
= contrlRect
.top
;
431 if ( mac_x
!= former_mac_x
|| mac_y
!= former_mac_y
)
432 UMAMoveControl( m_controlHandle
, mac_x
, mac_y
);
437 void wxToolBarTool::UpdateToggleImage( bool toggle
)
442 int w
= m_bmpNormal
.GetWidth();
443 int h
= m_bmpNormal
.GetHeight();
444 wxBitmap
bmp( w
, h
);
447 dc
.SelectObject( bmp
);
448 dc
.SetPen( wxPen(*wxBLACK
) );
449 dc
.SetBrush( wxBrush( *wxLIGHT_GREY
));
450 dc
.DrawRectangle( 0, 0, w
, h
);
451 dc
.DrawBitmap( m_bmpNormal
, 0, 0, true );
452 dc
.SelectObject( wxNullBitmap
);
453 ControlButtonContentInfo info
;
454 wxMacCreateBitmapButton( &info
, bmp
);
455 SetControlData( m_controlHandle
, 0, kControlIconContentTag
, sizeof(info
), (Ptr
)&info
);
456 #if wxMAC_USE_NATIVE_TOOLBAR
457 if (m_toolbarItemRef
!= NULL
)
459 HIToolbarItemSetIconRef( m_toolbarItemRef
, info
.u
.iconRef
);
462 wxMacReleaseBitmapButton( &info
);
466 ControlButtonContentInfo info
;
467 wxMacCreateBitmapButton( &info
, m_bmpNormal
);
468 SetControlData( m_controlHandle
, 0, kControlIconContentTag
, sizeof(info
), (Ptr
)&info
);
469 #if wxMAC_USE_NATIVE_TOOLBAR
470 if (m_toolbarItemRef
!= NULL
)
472 HIToolbarItemSetIconRef( m_toolbarItemRef
, info
.u
.iconRef
);
475 wxMacReleaseBitmapButton( &info
);
478 IconTransformType transform
= toggle
? kTransformSelected
: kTransformNone
;
480 m_controlHandle
, 0, kControlIconTransformTag
,
481 sizeof(transform
), (Ptr
)&transform
);
482 HIViewSetNeedsDisplay( m_controlHandle
, true );
485 ::SetControl32BitValue( m_controlHandle
, toggle
);
489 wxToolBarTool::wxToolBarTool(
492 const wxString
& label
,
493 const wxBitmap
& bmpNormal
,
494 const wxBitmap
& bmpDisabled
,
496 wxObject
*clientData
,
497 const wxString
& shortHelp
,
498 const wxString
& longHelp
)
501 tbar
, id
, label
, bmpNormal
, bmpDisabled
, kind
,
502 clientData
, shortHelp
, longHelp
)
508 #pragma mark Toolbar Implementation
510 wxToolBarToolBase
*wxToolBar::CreateTool(
512 const wxString
& label
,
513 const wxBitmap
& bmpNormal
,
514 const wxBitmap
& bmpDisabled
,
516 wxObject
*clientData
,
517 const wxString
& shortHelp
,
518 const wxString
& longHelp
)
520 return new wxToolBarTool(
521 this, id
, label
, bmpNormal
, bmpDisabled
, kind
,
522 clientData
, shortHelp
, longHelp
);
525 wxToolBarToolBase
* wxToolBar::CreateTool( wxControl
*control
)
527 return new wxToolBarTool( this, control
);
530 void wxToolBar::Init()
534 m_defaultWidth
= kwxMacToolBarToolDefaultWidth
;
535 m_defaultHeight
= kwxMacToolBarToolDefaultHeight
;
537 #if wxMAC_USE_NATIVE_TOOLBAR
538 m_macHIToolbarRef
= NULL
;
539 m_macUsesNativeToolbar
= false;
543 #define kControlToolbarItemClassID CFSTR( "org.wxwidgets.controltoolbaritem" )
545 const EventTypeSpec kEvents
[] =
547 { kEventClassHIObject
, kEventHIObjectConstruct
},
548 { kEventClassHIObject
, kEventHIObjectInitialize
},
549 { kEventClassHIObject
, kEventHIObjectDestruct
},
551 { kEventClassToolbarItem
, kEventToolbarItemCreateCustomView
}
554 const EventTypeSpec kViewEvents
[] =
556 { kEventClassControl
, kEventControlGetSizeConstraints
}
559 struct ControlToolbarItem
561 HIToolbarItemRef toolbarItem
;
563 wxSize lastValidSize
;
566 static pascal OSStatus
ControlToolbarItemHandler( EventHandlerCallRef inCallRef
, EventRef inEvent
, void* inUserData
)
568 OSStatus result
= eventNotHandledErr
;
569 ControlToolbarItem
* object
= (ControlToolbarItem
*)inUserData
;
571 switch ( GetEventClass( inEvent
) )
573 case kEventClassHIObject
:
574 switch ( GetEventKind( inEvent
) )
576 case kEventHIObjectConstruct
:
578 HIObjectRef toolbarItem
;
579 ControlToolbarItem
* item
;
581 GetEventParameter( inEvent
, kEventParamHIObjectInstance
, typeHIObjectRef
, NULL
,
582 sizeof( HIObjectRef
), NULL
, &toolbarItem
);
584 item
= (ControlToolbarItem
*) malloc(sizeof(ControlToolbarItem
)) ;
585 item
->toolbarItem
= toolbarItem
;
586 item
->viewRef
= NULL
;
588 SetEventParameter( inEvent
, kEventParamHIObjectInstance
, typeVoidPtr
, sizeof( void * ), &item
);
594 case kEventHIObjectInitialize
:
595 result
= CallNextEventHandler( inCallRef
, inEvent
);
596 if ( result
== noErr
)
599 GetEventParameter( inEvent
, kEventParamToolbarItemConfigData
, typeCFTypeRef
, NULL
,
600 sizeof( CFTypeRef
), NULL
, &data
);
604 wxASSERT_MSG( CFDataGetLength( data
) == sizeof( viewRef
) , wxT("Illegal Data passed") ) ;
605 memcpy( &viewRef
, CFDataGetBytePtr( data
) , sizeof( viewRef
) ) ;
607 object
->viewRef
= (HIViewRef
) viewRef
;
613 case kEventHIObjectDestruct
:
615 // we've increased the ref count when creating this, so we decrease manually again in case
616 // it was never really installed and deinstalled
617 HIViewRef viewRef
= object
->viewRef
;
618 if( viewRef
&& CFGetRetainCount( viewRef
) > 1 )
620 CFRelease( viewRef
) ;
629 case kEventClassToolbarItem
:
630 switch ( GetEventKind( inEvent
) )
632 case kEventToolbarItemCreateCustomView
:
634 HIViewRef viewRef
= object
->viewRef
;
636 HIViewRemoveFromSuperview( viewRef
) ;
637 HIViewSetVisible(viewRef
, true) ;
638 InstallEventHandler( GetControlEventTarget( viewRef
), ControlToolbarItemHandler
,
639 GetEventTypeCount( kViewEvents
), kViewEvents
, object
, NULL
);
641 result
= SetEventParameter( inEvent
, kEventParamControlRef
, typeControlRef
, sizeof( HIViewRef
), &viewRef
);
647 case kEventClassControl
:
648 switch ( GetEventKind( inEvent
) )
650 case kEventControlGetSizeConstraints
:
652 wxWindow
* wxwindow
= wxFindControlFromMacControl(object
->viewRef
) ;
655 wxSize sz
= wxwindow
->GetSize() ;
656 sz
.x
-= wxwindow
->MacGetLeftBorderSize() + wxwindow
->MacGetRightBorderSize();
657 sz
.y
-= wxwindow
->MacGetTopBorderSize() + wxwindow
->MacGetBottomBorderSize();
658 // during toolbar layout the native window sometimes gets negative sizes
659 // so we always keep the last valid size here, to make sure we survive the
661 if ( sz
.x
> 0 && sz
.y
> 0 )
662 object
->lastValidSize
= sz
;
664 sz
= object
->lastValidSize
;
667 min
.width
= max
.width
= sz
.x
;
668 min
.height
= max
.height
= sz
.y
;
670 result
= SetEventParameter( inEvent
, kEventParamMinimumSize
, typeHISize
,
671 sizeof( HISize
), &min
);
673 result
= SetEventParameter( inEvent
, kEventParamMaximumSize
, typeHISize
,
674 sizeof( HISize
), &max
);
686 void RegisterControlToolbarItemClass()
688 static bool sRegistered
;
692 HIObjectRegisterSubclass( kControlToolbarItemClassID
, kHIToolbarItemClassID
, 0,
693 ControlToolbarItemHandler
, GetEventTypeCount( kEvents
), kEvents
, 0, NULL
);
699 HIToolbarItemRef
CreateControlToolbarItem(CFStringRef inIdentifier
, CFTypeRef inConfigData
)
701 RegisterControlToolbarItemClass();
705 UInt32 options
= kHIToolbarItemAllowDuplicates
;
706 HIToolbarItemRef result
= NULL
;
708 err
= CreateEvent( NULL
, kEventClassHIObject
, kEventHIObjectInitialize
, GetCurrentEventTime(), 0, &event
);
709 require_noerr( err
, CantCreateEvent
);
711 SetEventParameter( event
, kEventParamAttributes
, typeUInt32
, sizeof( UInt32
), &options
);
712 SetEventParameter( event
, kEventParamToolbarItemIdentifier
, typeCFStringRef
, sizeof( CFStringRef
), &inIdentifier
);
715 SetEventParameter( event
, kEventParamToolbarItemConfigData
, typeCFTypeRef
, sizeof( CFTypeRef
), &inConfigData
);
717 err
= HIObjectCreate( kControlToolbarItemClassID
, event
, (HIObjectRef
*)&result
);
720 ReleaseEvent( event
);
725 #if wxMAC_USE_NATIVE_TOOLBAR
726 static const EventTypeSpec kToolbarEvents
[] =
728 { kEventClassToolbar
, kEventToolbarGetDefaultIdentifiers
},
729 { kEventClassToolbar
, kEventToolbarGetAllowedIdentifiers
},
730 { kEventClassToolbar
, kEventToolbarCreateItemWithIdentifier
},
733 static OSStatus
ToolbarDelegateHandler( EventHandlerCallRef inCallRef
, EventRef inEvent
, void* inUserData
)
735 OSStatus result
= eventNotHandledErr
;
737 // wxToolBar* toolbar = (wxToolBar*) inUserData ;
738 CFMutableArrayRef array
;
740 switch ( GetEventKind( inEvent
) )
742 case kEventToolbarGetDefaultIdentifiers
:
744 GetEventParameter( inEvent
, kEventParamMutableArray
, typeCFMutableArrayRef
, NULL
,
745 sizeof( CFMutableArrayRef
), NULL
, &array
);
746 // not implemented yet
747 // GetToolbarDefaultItems( array );
752 case kEventToolbarGetAllowedIdentifiers
:
754 GetEventParameter( inEvent
, kEventParamMutableArray
, typeCFMutableArrayRef
, NULL
,
755 sizeof( CFMutableArrayRef
), NULL
, &array
);
756 // not implemented yet
757 // GetToolbarAllowedItems( array );
761 case kEventToolbarCreateItemWithIdentifier
:
763 HIToolbarItemRef item
= NULL
;
764 CFTypeRef data
= NULL
;
765 CFStringRef identifier
= NULL
;
767 GetEventParameter( inEvent
, kEventParamToolbarItemIdentifier
, typeCFStringRef
, NULL
,
768 sizeof( CFStringRef
), NULL
, &identifier
);
770 GetEventParameter( inEvent
, kEventParamToolbarItemConfigData
, typeCFTypeRef
, NULL
,
771 sizeof( CFTypeRef
), NULL
, &data
);
773 if ( CFStringCompare( kControlToolbarItemClassID
, identifier
, kCFCompareBackwards
) == kCFCompareEqualTo
)
775 item
= CreateControlToolbarItem( kControlToolbarItemClassID
, data
);
778 SetEventParameter( inEvent
, kEventParamToolbarItem
, typeHIToolbarItemRef
,
779 sizeof( HIToolbarItemRef
), &item
);
789 #endif // wxMAC_USE_NATIVE_TOOLBAR
791 // also for the toolbar we have the dual implementation:
792 // only when MacInstallNativeToolbar is called is the native toolbar set as the window toolbar
794 bool wxToolBar::Create(
800 const wxString
& name
)
802 if ( !wxToolBarBase::Create( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
807 OSStatus err
= noErr
;
809 #if wxMAC_USE_NATIVE_TOOLBAR
810 wxString labelStr
= wxString::Format( wxT("%xd"), (int)this );
811 err
= HIToolbarCreate(
812 wxMacCFStringHolder( labelStr
, wxFont::GetDefaultEncoding() ), 0,
813 (HIToolbarRef
*) &m_macHIToolbarRef
);
815 if (m_macHIToolbarRef
!= NULL
)
817 InstallEventHandler( HIObjectGetEventTarget((HIToolbarRef
)m_macHIToolbarRef
), ToolbarDelegateHandler
,
818 GetEventTypeCount( kToolbarEvents
), kToolbarEvents
, this, NULL
);
820 HIToolbarDisplayMode mode
= kHIToolbarDisplayModeDefault
;
821 HIToolbarDisplaySize displaySize
= kHIToolbarDisplaySizeSmall
;
823 if ( style
& wxTB_NOICONS
)
824 mode
= kHIToolbarDisplayModeLabelOnly
;
825 else if ( style
& wxTB_TEXT
)
826 mode
= kHIToolbarDisplayModeIconAndLabel
;
828 mode
= kHIToolbarDisplayModeIconOnly
;
830 HIToolbarSetDisplayMode( (HIToolbarRef
) m_macHIToolbarRef
, mode
);
831 HIToolbarSetDisplaySize( (HIToolbarRef
) m_macHIToolbarRef
, displaySize
);
835 return (err
== noErr
);
838 wxToolBar::~wxToolBar()
840 #if wxMAC_USE_NATIVE_TOOLBAR
841 if (m_macHIToolbarRef
!= NULL
)
843 // if this is the installed toolbar, then deinstall it
844 if (m_macUsesNativeToolbar
)
845 MacInstallNativeToolbar( false );
847 CFIndex count
= CFGetRetainCount( m_macHIToolbarRef
) ;
848 wxASSERT_MSG( count
== 1 , wxT("Reference Count of native control was not 1 in wxToolBar destructor") );
850 CFRelease( (HIToolbarRef
)m_macHIToolbarRef
);
851 m_macHIToolbarRef
= NULL
;
856 bool wxToolBar::Show( bool show
)
858 WindowRef tlw
= MAC_WXHWND(MacGetTopLevelWindowRef());
859 bool bResult
= (tlw
!= NULL
);
863 #if wxMAC_USE_NATIVE_TOOLBAR
864 bool ownToolbarInstalled
= false;
865 MacTopLevelHasNativeToolbar( &ownToolbarInstalled
);
866 if (ownToolbarInstalled
)
868 bResult
= (IsWindowToolbarVisible( tlw
) != show
);
870 ShowHideWindowToolbar( tlw
, show
, false );
873 bResult
= wxToolBarBase::Show( show
);
876 bResult
= wxToolBarBase::Show( show
);
883 bool wxToolBar::IsShown() const
887 #if wxMAC_USE_NATIVE_TOOLBAR
888 bool ownToolbarInstalled
;
890 MacTopLevelHasNativeToolbar( &ownToolbarInstalled
);
891 if (ownToolbarInstalled
)
893 WindowRef tlw
= MAC_WXHWND(MacGetTopLevelWindowRef());
894 bResult
= IsWindowToolbarVisible( tlw
);
897 bResult
= wxToolBarBase::IsShown();
900 bResult
= wxToolBarBase::IsShown();
906 void wxToolBar::DoGetSize( int *width
, int *height
) const
908 #if wxMAC_USE_NATIVE_TOOLBAR
910 bool ownToolbarInstalled
;
912 MacTopLevelHasNativeToolbar( &ownToolbarInstalled
);
913 if ( ownToolbarInstalled
)
915 // TODO: is this really a control ?
916 GetControlBounds( (ControlRef
) m_macHIToolbarRef
, &boundsR
);
918 *width
= boundsR
.right
- boundsR
.left
;
919 if ( height
!= NULL
)
920 *height
= boundsR
.bottom
- boundsR
.top
;
923 wxToolBarBase::DoGetSize( width
, height
);
926 wxToolBarBase::DoGetSize( width
, height
);
930 wxSize
wxToolBar::DoGetBestSize() const
934 DoGetSize( &width
, &height
);
936 return wxSize( width
, height
);
939 void wxToolBar::SetWindowStyleFlag( long style
)
941 wxToolBarBase::SetWindowStyleFlag( style
);
943 #if wxMAC_USE_NATIVE_TOOLBAR
944 if (m_macHIToolbarRef
!= NULL
)
946 HIToolbarDisplayMode mode
= kHIToolbarDisplayModeDefault
;
948 if ( style
& wxTB_NOICONS
)
949 mode
= kHIToolbarDisplayModeLabelOnly
;
950 else if ( style
& wxTB_TEXT
)
951 mode
= kHIToolbarDisplayModeIconAndLabel
;
953 mode
= kHIToolbarDisplayModeIconOnly
;
955 HIToolbarSetDisplayMode( (HIToolbarRef
) m_macHIToolbarRef
, mode
);
960 #if wxMAC_USE_NATIVE_TOOLBAR
961 bool wxToolBar::MacWantsNativeToolbar()
963 return m_macUsesNativeToolbar
;
966 bool wxToolBar::MacTopLevelHasNativeToolbar(bool *ownToolbarInstalled
) const
968 bool bResultV
= false;
970 if (ownToolbarInstalled
!= NULL
)
971 *ownToolbarInstalled
= false;
973 WindowRef tlw
= MAC_WXHWND(MacGetTopLevelWindowRef());
976 HIToolbarRef curToolbarRef
= NULL
;
977 OSStatus err
= GetWindowToolbar( tlw
, &curToolbarRef
);
978 bResultV
= ((err
== noErr
) && (curToolbarRef
!= NULL
));
979 if (bResultV
&& (ownToolbarInstalled
!= NULL
))
980 *ownToolbarInstalled
= (curToolbarRef
== m_macHIToolbarRef
);
986 bool wxToolBar::MacInstallNativeToolbar(bool usesNative
)
988 bool bResult
= false;
990 if (usesNative
&& (m_macHIToolbarRef
== NULL
))
993 if (usesNative
&& ((GetWindowStyleFlag() & wxTB_VERTICAL
) != 0))
996 WindowRef tlw
= MAC_WXHWND(MacGetTopLevelWindowRef());
1000 // check the existing toolbar
1001 HIToolbarRef curToolbarRef
= NULL
;
1002 OSStatus err
= GetWindowToolbar( tlw
, &curToolbarRef
);
1004 curToolbarRef
= NULL
;
1006 m_macUsesNativeToolbar
= usesNative
;
1008 if (m_macUsesNativeToolbar
)
1010 // only install toolbar if there isn't one installed already
1011 if (curToolbarRef
== NULL
)
1015 SetWindowToolbar( tlw
, (HIToolbarRef
) m_macHIToolbarRef
);
1016 ShowHideWindowToolbar( tlw
, true, false );
1017 ChangeWindowAttributes( tlw
, kWindowToolbarButtonAttribute
, 0 );
1018 SetAutomaticControlDragTrackingEnabledForWindow( tlw
, true );
1020 Rect r
= { 0, 0, 0, 0 };
1021 m_peer
->SetRect( &r
);
1022 SetSize( wxSIZE_AUTO_WIDTH
, 0 );
1023 m_peer
->SetVisibility( false, true );
1024 wxToolBarBase::Show( false );
1029 // only deinstall toolbar if this is the installed one
1030 if (m_macHIToolbarRef
== curToolbarRef
)
1034 ShowHideWindowToolbar( tlw
, false, false );
1035 ChangeWindowAttributes( tlw
, 0, kWindowToolbarButtonAttribute
);
1036 SetWindowToolbar( tlw
, NULL
);
1038 m_peer
->SetVisibility( true, true );
1043 InvalidateBestSize();
1045 // wxLogDebug( wxT(" --> [%lx] - result [%s]"), (long)this, bResult ? wxT("T") : wxT("F") );
1050 bool wxToolBar::Realize()
1052 if (m_tools
.GetCount() == 0)
1058 int maxToolWidth
= 0;
1059 int maxToolHeight
= 0;
1061 int x
= m_xMargin
+ kwxMacToolBarLeftMargin
;
1062 int y
= m_yMargin
+ kwxMacToolBarTopMargin
;
1065 GetSize( &tw
, &th
);
1067 // find the maximum tool width and height
1068 wxToolBarTool
*tool
;
1069 wxToolBarToolsList::compatibility_iterator node
= m_tools
.GetFirst();
1070 while ( node
!= NULL
)
1072 tool
= (wxToolBarTool
*) node
->GetData();
1075 wxSize sz
= tool
->GetSize();
1077 if ( sz
.x
> maxToolWidth
)
1078 maxToolWidth
= sz
.x
;
1079 if ( sz
.y
> maxToolHeight
)
1080 maxToolHeight
= sz
.y
;
1083 node
= node
->GetNext();
1086 bool lastIsRadio
= false;
1087 bool curIsRadio
= false;
1089 #if wxMAC_USE_NATIVE_TOOLBAR
1090 CFIndex currentPosition
= 0;
1091 bool insertAll
= false;
1094 node
= m_tools
.GetFirst();
1095 while ( node
!= NULL
)
1097 tool
= (wxToolBarTool
*) node
->GetData();
1100 node
= node
->GetNext();
1104 // set tool position:
1105 // for the moment just perform a single row/column alignment
1106 wxSize cursize
= tool
->GetSize();
1107 if ( x
+ cursize
.x
> maxWidth
)
1108 maxWidth
= x
+ cursize
.x
;
1109 if ( y
+ cursize
.y
> maxHeight
)
1110 maxHeight
= y
+ cursize
.y
;
1112 if ( GetWindowStyleFlag() & wxTB_VERTICAL
)
1114 int x1
= x
+ ( maxToolWidth
- cursize
.x
) / 2;
1115 tool
->SetPosition( wxPoint(x1
, y
) );
1119 int y1
= y
+ ( maxToolHeight
- cursize
.y
) / 2;
1120 tool
->SetPosition( wxPoint(x
, y1
) );
1123 // update the item positioning state
1124 if ( GetWindowStyleFlag() & wxTB_VERTICAL
)
1125 y
+= cursize
.y
+ kwxMacToolSpacing
;
1127 x
+= cursize
.x
+ kwxMacToolSpacing
;
1129 #if wxMAC_USE_NATIVE_TOOLBAR
1130 // install in native HIToolbar
1131 if ( m_macHIToolbarRef
!= NULL
)
1133 HIToolbarItemRef hiItemRef
= tool
->GetToolbarItemRef();
1134 if ( hiItemRef
!= NULL
)
1136 if ( insertAll
|| (tool
->GetIndex() != currentPosition
) )
1138 OSStatus err
= noErr
;
1143 // if this is the first tool that gets newly inserted or repositioned
1144 // first remove all 'old' tools from here to the right, because of this
1145 // all following tools will have to be reinserted (insertAll). i = 100 because there's
1146 // no way to determine how many there are in a toolbar, so just a high number :-(
1147 for ( CFIndex i
= 100; i
>= currentPosition
; --i
)
1149 err
= HIToolbarRemoveItemAtIndex( (HIToolbarRef
) m_macHIToolbarRef
, i
);
1154 wxString errMsg
= wxString::Format( wxT("HIToolbarRemoveItemAtIndex failed [%ld]"), (long)err
);
1155 wxFAIL_MSG( errMsg
.c_str() );
1159 err
= HIToolbarInsertItemAtIndex( (HIToolbarRef
) m_macHIToolbarRef
, hiItemRef
, currentPosition
);
1162 wxString errMsg
= wxString::Format( wxT("HIToolbarInsertItemAtIndex failed [%ld]"), (long)err
);
1163 wxFAIL_MSG( errMsg
.c_str() );
1166 tool
->SetIndex( currentPosition
);
1174 // update radio button (and group) state
1175 lastIsRadio
= curIsRadio
;
1176 curIsRadio
= ( tool
->IsButton() && (tool
->GetKind() == wxITEM_RADIO
) );
1180 if ( tool
->IsToggled() )
1181 DoToggleTool( tool
, true );
1187 if ( tool
->Toggle( true ) )
1189 DoToggleTool( tool
, true );
1192 else if ( tool
->IsToggled() )
1194 if ( tool
->IsToggled() )
1195 DoToggleTool( tool
, true );
1197 wxToolBarToolsList::compatibility_iterator nodePrev
= node
->GetPrevious();
1198 while ( nodePrev
!= NULL
)
1200 wxToolBarToolBase
*toggleTool
= nodePrev
->GetData();
1201 if ( (toggleTool
== NULL
) || !toggleTool
->IsButton() || (toggleTool
->GetKind() != wxITEM_RADIO
) )
1204 if ( toggleTool
->Toggle( false ) )
1205 DoToggleTool( toggleTool
, false );
1207 nodePrev
= nodePrev
->GetPrevious();
1212 node
= node
->GetNext();
1215 if ( GetWindowStyleFlag() & wxTB_HORIZONTAL
)
1217 // if not set yet, only one row
1218 if ( m_maxRows
<= 0 )
1221 m_minWidth
= maxWidth
;
1223 maxHeight
+= m_yMargin
+ kwxMacToolBarTopMargin
;
1224 m_minHeight
= m_maxHeight
= maxHeight
;
1228 // if not set yet, have one column
1229 if ( (GetToolsCount() > 0) && (m_maxRows
<= 0) )
1230 SetRows( GetToolsCount() );
1232 m_minHeight
= maxHeight
;
1234 maxWidth
+= m_xMargin
+ kwxMacToolBarLeftMargin
;
1235 m_minWidth
= m_maxWidth
= maxWidth
;
1239 // FIXME: should this be OSX-only?
1241 bool wantNativeToolbar
, ownToolbarInstalled
;
1243 // attempt to install the native toolbar
1244 wantNativeToolbar
= ((GetWindowStyleFlag() & wxTB_VERTICAL
) == 0);
1245 MacInstallNativeToolbar( wantNativeToolbar
);
1246 (void)MacTopLevelHasNativeToolbar( &ownToolbarInstalled
);
1247 if (!ownToolbarInstalled
)
1249 SetSize( maxWidth
, maxHeight
);
1250 InvalidateBestSize();
1254 SetSize( maxWidth
, maxHeight
);
1255 InvalidateBestSize();
1263 void wxToolBar::SetToolBitmapSize(const wxSize
& size
)
1265 m_defaultWidth
= size
.x
+ kwxMacToolBorder
;
1266 m_defaultHeight
= size
.y
+ kwxMacToolBorder
;
1268 #if wxMAC_USE_NATIVE_TOOLBAR
1269 if (m_macHIToolbarRef
!= NULL
)
1271 int maxs
= wxMax( size
.x
, size
.y
);
1272 HIToolbarDisplaySize sizeSpec
;
1274 sizeSpec
= kHIToolbarDisplaySizeNormal
;
1275 else if ( maxs
> 24 )
1276 sizeSpec
= kHIToolbarDisplaySizeDefault
;
1278 sizeSpec
= kHIToolbarDisplaySizeSmall
;
1280 HIToolbarSetDisplaySize( (HIToolbarRef
) m_macHIToolbarRef
, sizeSpec
);
1285 // The button size is bigger than the bitmap size
1286 wxSize
wxToolBar::GetToolSize() const
1288 return wxSize(m_defaultWidth
+ kwxMacToolBorder
, m_defaultHeight
+ kwxMacToolBorder
);
1291 void wxToolBar::SetRows(int nRows
)
1293 // avoid resizing the frame uselessly
1294 if ( nRows
!= m_maxRows
)
1298 void wxToolBar::MacSuperChangedPosition()
1300 wxWindow::MacSuperChangedPosition();
1302 #if wxMAC_USE_NATIVE_TOOLBAR
1303 if (! m_macUsesNativeToolbar
)
1311 wxToolBarToolBase
*wxToolBar::FindToolForPosition(wxCoord x
, wxCoord y
) const
1313 wxToolBarTool
*tool
;
1314 wxToolBarToolsList::compatibility_iterator node
= m_tools
.GetFirst();
1315 while ( node
!= NULL
)
1317 tool
= (wxToolBarTool
*)node
->GetData();
1320 wxRect2DInt
r( tool
->GetPosition(), tool
->GetSize() );
1321 if ( r
.Contains( wxPoint( x
, y
) ) )
1325 node
= node
->GetNext();
1328 return (wxToolBarToolBase
*)NULL
;
1331 wxString
wxToolBar::MacGetToolTipString( wxPoint
&pt
)
1333 wxToolBarToolBase
*tool
= FindToolForPosition( pt
.x
, pt
.y
);
1335 return tool
->GetShortHelp();
1337 return wxEmptyString
;
1340 void wxToolBar::DoEnableTool(wxToolBarToolBase
*t
, bool enable
)
1343 ((wxToolBarTool
*)t
)->DoEnable( enable
);
1346 void wxToolBar::DoToggleTool(wxToolBarToolBase
*t
, bool toggle
)
1348 wxToolBarTool
*tool
= (wxToolBarTool
*)t
;
1349 if ( ( tool
!= NULL
) && tool
->IsButton() )
1350 tool
->UpdateToggleImage( toggle
);
1353 bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos
), wxToolBarToolBase
*toolBase
)
1355 wxToolBarTool
*tool
= wx_static_cast( wxToolBarTool
*, toolBase
);
1359 WindowRef window
= (WindowRef
) MacGetTopLevelWindowRef();
1360 wxSize toolSize
= GetToolSize();
1361 Rect toolrect
= { 0, 0, toolSize
.y
, toolSize
.x
};
1362 ControlRef controlHandle
= NULL
;
1365 switch (tool
->GetStyle())
1367 case wxTOOL_STYLE_SEPARATOR
:
1369 wxASSERT( tool
->GetControlHandle() == NULL
);
1372 if ( GetWindowStyleFlag() & wxTB_VERTICAL
)
1373 toolrect
.bottom
= toolSize
.y
;
1375 toolrect
.right
= toolSize
.x
;
1377 #ifdef __WXMAC_OSX__
1378 // in flat style we need a visual separator
1379 #if wxMAC_USE_NATIVE_TOOLBAR
1380 HIToolbarItemRef item
;
1381 err
= HIToolbarItemCreate(
1382 kHIToolbarSeparatorIdentifier
,
1383 kHIToolbarItemCantBeRemoved
| kHIToolbarItemIsSeparator
| kHIToolbarItemAllowDuplicates
,
1386 tool
->SetToolbarItemRef( item
);
1389 CreateSeparatorControl( window
, &toolrect
, &controlHandle
);
1390 tool
->SetControlHandle( controlHandle
);
1395 case wxTOOL_STYLE_BUTTON
:
1397 wxASSERT( tool
->GetControlHandle() == NULL
);
1398 ControlButtonContentInfo info
;
1399 wxMacCreateBitmapButton( &info
, tool
->GetNormalBitmap(), kControlContentIconRef
);
1401 if ( UMAGetSystemVersion() >= 0x1000)
1403 CreateIconControl( window
, &toolrect
, &info
, false, &controlHandle
);
1407 SInt16 behaviour
= kControlBehaviorOffsetContents
;
1408 if ( tool
->CanBeToggled() )
1409 behaviour
|= kControlBehaviorToggles
;
1410 err
= CreateBevelButtonControl( window
,
1411 &toolrect
, CFSTR(""), kControlBevelButtonNormalBevel
,
1412 behaviour
, &info
, 0, 0, 0, &controlHandle
);
1415 #if wxMAC_USE_NATIVE_TOOLBAR
1416 HIToolbarItemRef item
;
1417 wxString labelStr
= wxString::Format(wxT("%xd"), (int)tool
);
1418 err
= HIToolbarItemCreate(
1419 wxMacCFStringHolder(labelStr
, wxFont::GetDefaultEncoding()),
1420 kHIToolbarItemCantBeRemoved
| kHIToolbarItemAnchoredLeft
| kHIToolbarItemAllowDuplicates
, &item
);
1423 InstallEventHandler(
1424 HIObjectGetEventTarget(item
), GetwxMacToolBarEventHandlerUPP(),
1425 GetEventTypeCount(toolBarEventList
), toolBarEventList
, tool
, NULL
);
1426 HIToolbarItemSetLabel( item
, wxMacCFStringHolder(tool
->GetLabel(), m_font
.GetEncoding()) );
1427 HIToolbarItemSetIconRef( item
, info
.u
.iconRef
);
1428 HIToolbarItemSetCommandID( item
, kHIToolbarCommandPressAction
);
1429 tool
->SetToolbarItemRef( item
);
1433 wxMacReleaseBitmapButton( &info
);
1436 SetBevelButtonTextPlacement( m_controlHandle
, kControlBevelButtonPlaceBelowGraphic
);
1437 UMASetControlTitle( m_controlHandle
, label
, wxFont::GetDefaultEncoding() );
1440 InstallControlEventHandler(
1441 (ControlRef
) controlHandle
, GetwxMacToolBarToolEventHandlerUPP(),
1442 GetEventTypeCount(eventList
), eventList
, tool
, NULL
);
1444 tool
->SetControlHandle( controlHandle
);
1448 case wxTOOL_STYLE_CONTROL
:
1450 #if wxMAC_USE_NATIVE_TOOLBAR
1452 wxASSERT( tool
->GetControl() != NULL
);
1453 HIToolbarItemRef item
;
1454 HIViewRef viewRef
= (HIViewRef
) tool
->GetControl()->GetHandle() ;
1455 // as this control now is part of both the wxToolBar children and the native toolbar, we have to increase the
1456 // reference count to make sure we are not dealing with zombie controls after the native toolbar has released its views
1457 CFRetain( viewRef
) ;
1458 CFDataRef data
= CFDataCreate( kCFAllocatorDefault
, (UInt8
*) &viewRef
, sizeof(viewRef
) ) ;
1459 err
= HIToolbarCreateItemWithIdentifier((HIToolbarRef
) m_macHIToolbarRef
,kControlToolbarItemClassID
,
1464 tool
->SetToolbarItemRef( item
);
1470 // right now there's nothing to do here
1480 if ( controlHandle
)
1482 ControlRef container
= (ControlRef
) GetHandle();
1483 wxASSERT_MSG( container
!= NULL
, wxT("No valid Mac container control") );
1485 UMAShowControl( controlHandle
);
1486 ::EmbedControl( controlHandle
, container
);
1489 if ( tool
->CanBeToggled() && tool
->IsToggled() )
1490 tool
->UpdateToggleImage( true );
1492 // nothing special to do here - we relayout in Realize() later
1493 tool
->Attach( this );
1494 InvalidateBestSize();
1498 wxString errMsg
= wxString::Format( wxT("wxToolBar::DoInsertTool - failure [%ld]"), (long)err
);
1499 wxFAIL_MSG( errMsg
.c_str() );
1502 return (err
== noErr
);
1505 void wxToolBar::DoSetToggle(wxToolBarToolBase
*WXUNUSED(tool
), bool WXUNUSED(toggle
))
1507 wxFAIL_MSG( wxT("not implemented") );
1510 bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos
), wxToolBarToolBase
*toolbase
)
1512 wxToolBarTool
* tool
= wx_static_cast( wxToolBarTool
*, toolbase
);
1513 wxToolBarToolsList::compatibility_iterator node
;
1514 for ( node
= m_tools
.GetFirst(); node
; node
= node
->GetNext() )
1516 wxToolBarToolBase
*tool2
= node
->GetData();
1517 if ( tool2
== tool
)
1519 // let node point to the next node in the list
1520 node
= node
->GetNext();
1526 wxSize sz
= ((wxToolBarTool
*)tool
)->GetSize();
1530 #if wxMAC_USE_NATIVE_TOOLBAR
1531 CFIndex removeIndex
= tool
->GetIndex();
1534 #if wxMAC_USE_NATIVE_TOOLBAR
1535 if ( removeIndex
!= -1 && m_macHIToolbarRef
)
1537 HIToolbarRemoveItemAtIndex( (HIToolbarRef
) m_macHIToolbarRef
, removeIndex
);
1538 tool
->SetIndex( -1 );
1541 switch ( tool
->GetStyle() )
1543 case wxTOOL_STYLE_CONTROL
:
1544 if ( tool
->GetControl() )
1545 tool
->GetControl()->Destroy();
1548 case wxTOOL_STYLE_BUTTON
:
1549 case wxTOOL_STYLE_SEPARATOR
:
1556 tool
->ClearControl();
1558 // and finally reposition all the controls after this one
1560 for ( /* node -> first after deleted */; node
; node
= node
->GetNext() )
1562 wxToolBarTool
*tool2
= (wxToolBarTool
*) node
->GetData();
1563 wxPoint pt
= tool2
->GetPosition();
1565 if ( GetWindowStyleFlag() & wxTB_VERTICAL
)
1570 tool2
->SetPosition( pt
);
1572 #if wxMAC_USE_NATIVE_TOOLBAR
1573 if ( removeIndex
!= -1 && tool2
->GetIndex() > removeIndex
)
1574 tool2
->SetIndex( tool2
->GetIndex() - 1 );
1578 InvalidateBestSize();
1583 void wxToolBar::OnPaint(wxPaintEvent
& event
)
1585 #if wxMAC_USE_NATIVE_TOOLBAR
1586 if ( m_macUsesNativeToolbar
)
1598 bool drawMetalTheme
= MacGetTopLevelWindow()->MacGetMetalAppearance();
1599 bool minimumUmaAvailable
= (UMAGetSystemVersion() >= 0x1030);
1601 #if wxMAC_USE_CORE_GRAPHICS && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
1602 if ( !drawMetalTheme
&& minimumUmaAvailable
)
1604 HIThemePlacardDrawInfo info
;
1605 memset( &info
, 0, sizeof(info
) );
1607 info
.state
= IsEnabled() ? kThemeStateActive
: kThemeStateInactive
;
1609 CGContextRef cgContext
= (CGContextRef
) MacGetCGContextRef();
1610 HIRect rect
= CGRectMake( 0, 0, w
, h
);
1611 HIThemeDrawPlacard( &rect
, &info
, cgContext
, kHIThemeOrientationNormal
);
1615 // leave the background as it is (striped or metal)
1620 const bool drawBorder
= true;
1624 wxMacPortSetter
helper( &dc
);
1626 if ( !drawMetalTheme
|| !minimumUmaAvailable
)
1628 Rect toolbarrect
= { dc
.YLOG2DEVMAC(0), dc
.XLOG2DEVMAC(0),
1629 dc
.YLOG2DEVMAC(h
), dc
.XLOG2DEVMAC(w
) };
1632 if ( toolbarrect
.left
< 0 )
1633 toolbarrect
.left
= 0;
1634 if ( toolbarrect
.top
< 0 )
1635 toolbarrect
.top
= 0;
1638 UMADrawThemePlacard( &toolbarrect
, IsEnabled() ? kThemeStateActive
: kThemeStateInactive
);
1642 #if TARGET_API_MAC_OSX
1643 HIRect hiToolbarrect
= CGRectMake(
1644 dc
.YLOG2DEVMAC(0), dc
.XLOG2DEVMAC(0),
1645 dc
.YLOG2DEVREL(h
), dc
.XLOG2DEVREL(w
) );
1646 CGContextRef cgContext
;
1649 GetPortBounds( (CGrafPtr
) dc
.m_macPort
, &bounds
);
1650 QDBeginCGContext( (CGrafPtr
) dc
.m_macPort
, &cgContext
);
1652 CGContextTranslateCTM( cgContext
, 0, bounds
.bottom
- bounds
.top
);
1653 CGContextScaleCTM( cgContext
, 1, -1 );
1655 HIThemeBackgroundDrawInfo drawInfo
;
1656 drawInfo
.version
= 0;
1657 drawInfo
.state
= kThemeStateActive
;
1658 drawInfo
.kind
= kThemeBackgroundMetal
;
1659 HIThemeApplyBackground( &hiToolbarrect
, &drawInfo
, cgContext
, kHIThemeOrientationNormal
);
1662 QDEndCGContext( (CGrafPtr
) dc
.m_macPort
, &cgContext
);
1672 #endif // wxUSE_TOOLBAR