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
)
440 #if wxMAC_USE_NATIVE_TOOLBAR
442 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_4
443 #define kHIToolbarItemSelected (1 << 7)
446 // FIXME: this should be a OSX v10.4 runtime check
447 if (m_toolbarItemRef
!= NULL
)
449 OptionBits addAttrs
, removeAttrs
;
454 addAttrs
= kHIToolbarItemSelected
;
455 removeAttrs
= kHIToolbarItemNoAttributes
;
459 addAttrs
= kHIToolbarItemNoAttributes
;
460 removeAttrs
= kHIToolbarItemSelected
;
463 result
= HIToolbarItemChangeAttributes( m_toolbarItemRef
, addAttrs
, removeAttrs
);
470 int w
= m_bmpNormal
.GetWidth();
471 int h
= m_bmpNormal
.GetHeight();
472 wxBitmap
bmp( w
, h
);
475 dc
.SelectObject( bmp
);
476 dc
.SetPen( wxNullPen
);
477 dc
.SetBackground( *wxWHITE
);
478 dc
.DrawRectangle( 0, 0, w
, h
);
479 dc
.DrawBitmap( m_bmpNormal
, 0, 0, true );
480 dc
.SelectObject( wxNullBitmap
);
481 ControlButtonContentInfo info
;
482 wxMacCreateBitmapButton( &info
, bmp
);
483 SetControlData( m_controlHandle
, 0, kControlIconContentTag
, sizeof(info
), (Ptr
)&info
);
484 wxMacReleaseBitmapButton( &info
);
488 ControlButtonContentInfo info
;
489 wxMacCreateBitmapButton( &info
, m_bmpNormal
);
490 SetControlData( m_controlHandle
, 0, kControlIconContentTag
, sizeof(info
), (Ptr
)&info
);
491 wxMacReleaseBitmapButton( &info
);
494 IconTransformType transform
= toggle
? kTransformSelected
: kTransformNone
;
496 m_controlHandle
, 0, kControlIconTransformTag
,
497 sizeof(transform
), (Ptr
)&transform
);
498 HIViewSetNeedsDisplay( m_controlHandle
, true );
501 ::SetControl32BitValue( m_controlHandle
, toggle
);
505 wxToolBarTool::wxToolBarTool(
508 const wxString
& label
,
509 const wxBitmap
& bmpNormal
,
510 const wxBitmap
& bmpDisabled
,
512 wxObject
*clientData
,
513 const wxString
& shortHelp
,
514 const wxString
& longHelp
)
517 tbar
, id
, label
, bmpNormal
, bmpDisabled
, kind
,
518 clientData
, shortHelp
, longHelp
)
524 #pragma mark Toolbar Implementation
526 wxToolBarToolBase
*wxToolBar::CreateTool(
528 const wxString
& label
,
529 const wxBitmap
& bmpNormal
,
530 const wxBitmap
& bmpDisabled
,
532 wxObject
*clientData
,
533 const wxString
& shortHelp
,
534 const wxString
& longHelp
)
536 return new wxToolBarTool(
537 this, id
, label
, bmpNormal
, bmpDisabled
, kind
,
538 clientData
, shortHelp
, longHelp
);
541 wxToolBarToolBase
* wxToolBar::CreateTool( wxControl
*control
)
543 return new wxToolBarTool( this, control
);
546 void wxToolBar::Init()
550 m_defaultWidth
= kwxMacToolBarToolDefaultWidth
;
551 m_defaultHeight
= kwxMacToolBarToolDefaultHeight
;
553 #if wxMAC_USE_NATIVE_TOOLBAR
554 m_macHIToolbarRef
= NULL
;
555 m_macUsesNativeToolbar
= false;
559 #define kControlToolbarItemClassID CFSTR( "org.wxwidgets.controltoolbaritem" )
561 const EventTypeSpec kEvents
[] =
563 { kEventClassHIObject
, kEventHIObjectConstruct
},
564 { kEventClassHIObject
, kEventHIObjectInitialize
},
565 { kEventClassHIObject
, kEventHIObjectDestruct
},
567 { kEventClassToolbarItem
, kEventToolbarItemCreateCustomView
}
570 const EventTypeSpec kViewEvents
[] =
572 { kEventClassControl
, kEventControlGetSizeConstraints
}
575 struct ControlToolbarItem
577 HIToolbarItemRef toolbarItem
;
579 wxSize lastValidSize
;
582 static pascal OSStatus
ControlToolbarItemHandler( EventHandlerCallRef inCallRef
, EventRef inEvent
, void* inUserData
)
584 OSStatus result
= eventNotHandledErr
;
585 ControlToolbarItem
* object
= (ControlToolbarItem
*)inUserData
;
587 switch ( GetEventClass( inEvent
) )
589 case kEventClassHIObject
:
590 switch ( GetEventKind( inEvent
) )
592 case kEventHIObjectConstruct
:
594 HIObjectRef toolbarItem
;
595 ControlToolbarItem
* item
;
597 GetEventParameter( inEvent
, kEventParamHIObjectInstance
, typeHIObjectRef
, NULL
,
598 sizeof( HIObjectRef
), NULL
, &toolbarItem
);
600 item
= (ControlToolbarItem
*) malloc(sizeof(ControlToolbarItem
)) ;
601 item
->toolbarItem
= toolbarItem
;
602 item
->viewRef
= NULL
;
604 SetEventParameter( inEvent
, kEventParamHIObjectInstance
, typeVoidPtr
, sizeof( void * ), &item
);
610 case kEventHIObjectInitialize
:
611 result
= CallNextEventHandler( inCallRef
, inEvent
);
612 if ( result
== noErr
)
615 GetEventParameter( inEvent
, kEventParamToolbarItemConfigData
, typeCFTypeRef
, NULL
,
616 sizeof( CFTypeRef
), NULL
, &data
);
620 wxASSERT_MSG( CFDataGetLength( data
) == sizeof( viewRef
) , wxT("Illegal Data passed") ) ;
621 memcpy( &viewRef
, CFDataGetBytePtr( data
) , sizeof( viewRef
) ) ;
623 object
->viewRef
= (HIViewRef
) viewRef
;
629 case kEventHIObjectDestruct
:
636 case kEventClassToolbarItem
:
637 switch ( GetEventKind( inEvent
) )
639 case kEventToolbarItemCreateCustomView
:
641 HIViewRef viewRef
= object
->viewRef
;
643 HIViewRemoveFromSuperview( viewRef
) ;
644 HIViewSetVisible(viewRef
, true) ;
645 InstallEventHandler( GetControlEventTarget( viewRef
), ControlToolbarItemHandler
,
646 GetEventTypeCount( kViewEvents
), kViewEvents
, object
, NULL
);
648 result
= SetEventParameter( inEvent
, kEventParamControlRef
, typeControlRef
, sizeof( HIViewRef
), &viewRef
);
654 case kEventClassControl
:
655 switch ( GetEventKind( inEvent
) )
657 case kEventControlGetSizeConstraints
:
659 wxWindow
* wxwindow
= wxFindControlFromMacControl(object
->viewRef
) ;
662 wxSize sz
= wxwindow
->GetSize() ;
663 sz
.x
-= wxwindow
->MacGetLeftBorderSize() + wxwindow
->MacGetRightBorderSize();
664 sz
.y
-= wxwindow
->MacGetTopBorderSize() + wxwindow
->MacGetBottomBorderSize();
665 // during toolbar layout the native window sometimes gets negative sizes
666 // so we always keep the last valid size here, to make sure we survive the
668 if ( sz
.x
> 0 && sz
.y
> 0 )
669 object
->lastValidSize
= sz
;
671 sz
= object
->lastValidSize
;
674 min
.width
= max
.width
= sz
.x
;
675 min
.height
= max
.height
= sz
.y
;
677 result
= SetEventParameter( inEvent
, kEventParamMinimumSize
, typeHISize
,
678 sizeof( HISize
), &min
);
680 result
= SetEventParameter( inEvent
, kEventParamMaximumSize
, typeHISize
,
681 sizeof( HISize
), &max
);
693 void RegisterControlToolbarItemClass()
695 static bool sRegistered
;
699 HIObjectRegisterSubclass( kControlToolbarItemClassID
, kHIToolbarItemClassID
, 0,
700 ControlToolbarItemHandler
, GetEventTypeCount( kEvents
), kEvents
, 0, NULL
);
706 HIToolbarItemRef
CreateControlToolbarItem(CFStringRef inIdentifier
, CFTypeRef inConfigData
)
708 RegisterControlToolbarItemClass();
712 UInt32 options
= kHIToolbarItemAllowDuplicates
;
713 HIToolbarItemRef result
= NULL
;
715 err
= CreateEvent( NULL
, kEventClassHIObject
, kEventHIObjectInitialize
, GetCurrentEventTime(), 0, &event
);
716 require_noerr( err
, CantCreateEvent
);
718 SetEventParameter( event
, kEventParamAttributes
, typeUInt32
, sizeof( UInt32
), &options
);
719 SetEventParameter( event
, kEventParamToolbarItemIdentifier
, typeCFStringRef
, sizeof( CFStringRef
), &inIdentifier
);
722 SetEventParameter( event
, kEventParamToolbarItemConfigData
, typeCFTypeRef
, sizeof( CFTypeRef
), &inConfigData
);
724 err
= HIObjectCreate( kControlToolbarItemClassID
, event
, (HIObjectRef
*)&result
);
727 ReleaseEvent( event
);
732 static const EventTypeSpec kToolbarEvents
[] =
734 { kEventClassToolbar
, kEventToolbarGetDefaultIdentifiers
},
735 { kEventClassToolbar
, kEventToolbarGetAllowedIdentifiers
},
736 { kEventClassToolbar
, kEventToolbarCreateItemWithIdentifier
},
739 static OSStatus
ToolbarDelegateHandler( EventHandlerCallRef inCallRef
, EventRef inEvent
, void* inUserData
)
741 OSStatus result
= eventNotHandledErr
;
743 // wxToolBar* toolbar = (wxToolBar*) inUserData ;
744 CFMutableArrayRef array
;
746 switch ( GetEventKind( inEvent
) )
748 case kEventToolbarGetDefaultIdentifiers
:
750 GetEventParameter( inEvent
, kEventParamMutableArray
, typeCFMutableArrayRef
, NULL
,
751 sizeof( CFMutableArrayRef
), NULL
, &array
);
752 // not implemented yet
753 // GetToolbarDefaultItems( array );
758 case kEventToolbarGetAllowedIdentifiers
:
760 GetEventParameter( inEvent
, kEventParamMutableArray
, typeCFMutableArrayRef
, NULL
,
761 sizeof( CFMutableArrayRef
), NULL
, &array
);
762 // not implemented yet
763 // GetToolbarAllowedItems( array );
767 case kEventToolbarCreateItemWithIdentifier
:
769 HIToolbarItemRef item
= NULL
;
770 CFTypeRef data
= NULL
;
771 CFStringRef identifier
= NULL
;
773 GetEventParameter( inEvent
, kEventParamToolbarItemIdentifier
, typeCFStringRef
, NULL
,
774 sizeof( CFStringRef
), NULL
, &identifier
);
776 GetEventParameter( inEvent
, kEventParamToolbarItemConfigData
, typeCFTypeRef
, NULL
,
777 sizeof( CFTypeRef
), NULL
, &data
);
779 if ( CFStringCompare( kControlToolbarItemClassID
, identifier
, kCFCompareBackwards
) == kCFCompareEqualTo
)
781 item
= CreateControlToolbarItem( kControlToolbarItemClassID
, data
);
784 SetEventParameter( inEvent
, kEventParamToolbarItem
, typeHIToolbarItemRef
,
785 sizeof( HIToolbarItemRef
), &item
);
796 // also for the toolbar we have the dual implementation:
797 // only when MacInstallNativeToolbar is called is the native toolbar set as the window toolbar
799 bool wxToolBar::Create(
805 const wxString
& name
)
807 if ( !wxToolBarBase::Create( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
810 OSStatus err
= noErr
;
812 #if wxMAC_USE_NATIVE_TOOLBAR
813 wxString labelStr
= wxString::Format( wxT("%xd"), (int)this );
814 err
= HIToolbarCreate(
815 wxMacCFStringHolder( labelStr
, wxFont::GetDefaultEncoding() ), 0,
816 (HIToolbarRef
*) &m_macHIToolbarRef
);
818 if (m_macHIToolbarRef
!= NULL
)
820 InstallEventHandler( HIObjectGetEventTarget((HIToolbarRef
)m_macHIToolbarRef
), ToolbarDelegateHandler
,
821 GetEventTypeCount( kToolbarEvents
), kToolbarEvents
, this, NULL
);
823 HIToolbarDisplayMode mode
= kHIToolbarDisplayModeDefault
;
824 HIToolbarDisplaySize displaySize
= kHIToolbarDisplaySizeSmall
;
826 if ( style
& wxTB_NOICONS
)
827 mode
= kHIToolbarDisplayModeLabelOnly
;
828 else if ( style
& wxTB_TEXT
)
829 mode
= kHIToolbarDisplayModeIconAndLabel
;
831 mode
= kHIToolbarDisplayModeIconOnly
;
833 HIToolbarSetDisplayMode( (HIToolbarRef
) m_macHIToolbarRef
, mode
);
834 HIToolbarSetDisplaySize( (HIToolbarRef
) m_macHIToolbarRef
, displaySize
);
838 return (err
== noErr
);
841 wxToolBar::~wxToolBar()
843 #if wxMAC_USE_NATIVE_TOOLBAR
844 if (m_macHIToolbarRef
!= NULL
)
846 // if this is the installed toolbar, then deinstall it
847 if (m_macUsesNativeToolbar
)
848 MacInstallNativeToolbar( false );
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;
1088 bool setChoiceInGroup
= false;
1090 #if wxMAC_USE_NATIVE_TOOLBAR
1091 CFIndex currentPosition
= 0;
1092 bool insertAll
= false;
1095 node
= m_tools
.GetFirst();
1096 while ( node
!= NULL
)
1098 tool
= (wxToolBarTool
*) node
->GetData();
1101 node
= node
->GetNext();
1105 // set tool position:
1106 // for the moment just perform a single row/column alignment
1107 wxSize cursize
= tool
->GetSize();
1108 if ( x
+ cursize
.x
> maxWidth
)
1109 maxWidth
= x
+ cursize
.x
;
1110 if ( y
+ cursize
.y
> maxHeight
)
1111 maxHeight
= y
+ cursize
.y
;
1113 if ( GetWindowStyleFlag() & wxTB_VERTICAL
)
1115 int x1
= x
+ ( maxToolWidth
- cursize
.x
) / 2;
1116 tool
->SetPosition( wxPoint(x1
, y
) );
1120 int y1
= y
+ ( maxToolHeight
- cursize
.y
) / 2;
1121 tool
->SetPosition( wxPoint(x
, y1
) );
1124 // update the item positioning state
1125 if ( GetWindowStyleFlag() & wxTB_VERTICAL
)
1126 y
+= cursize
.y
+ kwxMacToolSpacing
;
1128 x
+= cursize
.x
+ kwxMacToolSpacing
;
1130 #if wxMAC_USE_NATIVE_TOOLBAR
1131 // install in native HIToolbar
1132 if ( m_macHIToolbarRef
!= NULL
)
1134 HIToolbarItemRef hiItemRef
= tool
->GetToolbarItemRef();
1135 if ( hiItemRef
!= NULL
)
1137 if ( insertAll
|| (tool
->GetIndex() != currentPosition
) )
1139 OSStatus err
= noErr
;
1144 // if this is the first tool that gets newly inserted or repositioned
1145 // first remove all 'old' tools from here to the right, because of this
1146 // all following tools will have to be reinserted (insertAll). i = 100 because there's
1147 // no way to determine how many there are in a toolbar, so just a high number :-(
1148 for ( CFIndex i
= 100; i
>= currentPosition
; --i
)
1150 err
= HIToolbarRemoveItemAtIndex( (HIToolbarRef
) m_macHIToolbarRef
, i
);
1155 wxString errMsg
= wxString::Format( wxT("HIToolbarRemoveItemAtIndex failed [%ld]"), (long)err
);
1156 wxFAIL_MSG( errMsg
.c_str() );
1160 err
= HIToolbarInsertItemAtIndex( (HIToolbarRef
) m_macHIToolbarRef
, hiItemRef
, currentPosition
);
1163 wxString errMsg
= wxString::Format( wxT("HIToolbarInsertItemAtIndex failed [%ld]"), (long)err
);
1164 wxFAIL_MSG( errMsg
.c_str() );
1167 tool
->SetIndex( currentPosition
);
1175 // update radio button (and group) state
1176 lastIsRadio
= curIsRadio
;
1177 curIsRadio
= ( tool
->IsButton() && (tool
->GetKind() == wxITEM_RADIO
) );
1181 if ( tool
->IsToggled() )
1182 DoToggleTool( tool
, true );
1184 setChoiceInGroup
= false;
1190 if ( tool
->Toggle( true ) )
1192 DoToggleTool( tool
, true );
1193 setChoiceInGroup
= true;
1196 else if ( tool
->IsToggled() )
1198 if ( tool
->IsToggled() )
1199 DoToggleTool( tool
, true );
1201 wxToolBarToolsList::compatibility_iterator nodePrev
= node
->GetPrevious();
1202 while ( nodePrev
!= NULL
)
1204 wxToolBarToolBase
*toggleTool
= nodePrev
->GetData();
1205 if ( (toggleTool
== NULL
) || !toggleTool
->IsButton() || (toggleTool
->GetKind() != wxITEM_RADIO
) )
1208 if ( toggleTool
->Toggle( false ) )
1209 DoToggleTool( toggleTool
, false );
1211 nodePrev
= nodePrev
->GetPrevious();
1216 node
= node
->GetNext();
1219 if ( GetWindowStyleFlag() & wxTB_HORIZONTAL
)
1221 // if not set yet, only one row
1222 if ( m_maxRows
<= 0 )
1225 m_minWidth
= maxWidth
;
1227 maxHeight
+= m_yMargin
+ kwxMacToolBarTopMargin
;
1228 m_minHeight
= m_maxHeight
= maxHeight
;
1232 // if not set yet, have one column
1233 if ( (GetToolsCount() > 0) && (m_maxRows
<= 0) )
1234 SetRows( GetToolsCount() );
1236 m_minHeight
= maxHeight
;
1238 maxWidth
+= m_xMargin
+ kwxMacToolBarLeftMargin
;
1239 m_minWidth
= m_maxWidth
= maxWidth
;
1243 // FIXME: should this be OSX-only?
1245 bool wantNativeToolbar
, ownToolbarInstalled
;
1247 // attempt to install the native toolbar
1248 wantNativeToolbar
= ((GetWindowStyleFlag() & wxTB_VERTICAL
) == 0);
1249 MacInstallNativeToolbar( wantNativeToolbar
);
1250 (void)MacTopLevelHasNativeToolbar( &ownToolbarInstalled
);
1251 if (!ownToolbarInstalled
)
1253 SetSize( maxWidth
, maxHeight
);
1254 InvalidateBestSize();
1258 SetSize( maxWidth
, maxHeight
);
1259 InvalidateBestSize();
1262 SetBestFittingSize();
1267 void wxToolBar::SetToolBitmapSize(const wxSize
& size
)
1269 m_defaultWidth
= size
.x
+ kwxMacToolBorder
;
1270 m_defaultHeight
= size
.y
+ kwxMacToolBorder
;
1272 #if wxMAC_USE_NATIVE_TOOLBAR
1273 if (m_macHIToolbarRef
!= NULL
)
1275 int maxs
= wxMax( size
.x
, size
.y
);
1276 HIToolbarDisplaySize sizeSpec
;
1278 sizeSpec
= kHIToolbarDisplaySizeNormal
;
1279 else if ( maxs
> 24 )
1280 sizeSpec
= kHIToolbarDisplaySizeDefault
;
1282 sizeSpec
= kHIToolbarDisplaySizeSmall
;
1284 HIToolbarSetDisplaySize( (HIToolbarRef
) m_macHIToolbarRef
, sizeSpec
);
1289 // The button size is bigger than the bitmap size
1290 wxSize
wxToolBar::GetToolSize() const
1292 return wxSize(m_defaultWidth
+ kwxMacToolBorder
, m_defaultHeight
+ kwxMacToolBorder
);
1295 void wxToolBar::SetRows(int nRows
)
1297 // avoid resizing the frame uselessly
1298 if ( nRows
!= m_maxRows
)
1302 void wxToolBar::MacSuperChangedPosition()
1304 wxWindow::MacSuperChangedPosition();
1306 #if wxMAC_USE_NATIVE_TOOLBAR
1307 if (! m_macUsesNativeToolbar
)
1315 wxToolBarToolBase
*wxToolBar::FindToolForPosition(wxCoord x
, wxCoord y
) const
1317 wxToolBarTool
*tool
;
1318 wxToolBarToolsList::compatibility_iterator node
= m_tools
.GetFirst();
1319 while ( node
!= NULL
)
1321 tool
= (wxToolBarTool
*)node
->GetData();
1324 wxRect2DInt
r( tool
->GetPosition(), tool
->GetSize() );
1325 if ( r
.Contains( wxPoint( x
, y
) ) )
1329 node
= node
->GetNext();
1332 return (wxToolBarToolBase
*)NULL
;
1335 wxString
wxToolBar::MacGetToolTipString( wxPoint
&pt
)
1337 wxToolBarToolBase
*tool
= FindToolForPosition( pt
.x
, pt
.y
);
1339 return tool
->GetShortHelp();
1341 return wxEmptyString
;
1344 void wxToolBar::DoEnableTool(wxToolBarToolBase
*t
, bool enable
)
1347 ((wxToolBarTool
*)t
)->DoEnable( enable
);
1350 void wxToolBar::DoToggleTool(wxToolBarToolBase
*t
, bool toggle
)
1352 wxToolBarTool
*tool
= (wxToolBarTool
*)t
;
1353 if ( ( tool
!= NULL
) && tool
->IsButton() )
1354 tool
->UpdateToggleImage( toggle
);
1357 bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos
), wxToolBarToolBase
*toolBase
)
1359 wxToolBarTool
*tool
= wx_static_cast( wxToolBarTool
*, toolBase
);
1363 WindowRef window
= (WindowRef
) MacGetTopLevelWindowRef();
1364 wxSize toolSize
= GetToolSize();
1365 Rect toolrect
= { 0, 0, toolSize
.y
, toolSize
.x
};
1366 ControlRef controlHandle
= NULL
;
1369 switch (tool
->GetStyle())
1371 case wxTOOL_STYLE_SEPARATOR
:
1373 wxASSERT( tool
->GetControlHandle() == NULL
);
1376 if ( GetWindowStyleFlag() & wxTB_VERTICAL
)
1377 toolrect
.bottom
= toolSize
.y
;
1379 toolrect
.right
= toolSize
.x
;
1381 #ifdef __WXMAC_OSX__
1382 // in flat style we need a visual separator
1383 #if wxMAC_USE_NATIVE_TOOLBAR
1384 HIToolbarItemRef item
;
1385 err
= HIToolbarItemCreate(
1386 kHIToolbarSeparatorIdentifier
,
1387 kHIToolbarItemCantBeRemoved
| kHIToolbarItemIsSeparator
| kHIToolbarItemAllowDuplicates
,
1390 tool
->SetToolbarItemRef( item
);
1393 CreateSeparatorControl( window
, &toolrect
, &controlHandle
);
1394 tool
->SetControlHandle( controlHandle
);
1399 case wxTOOL_STYLE_BUTTON
:
1401 wxASSERT( tool
->GetControlHandle() == NULL
);
1402 ControlButtonContentInfo info
;
1403 wxMacCreateBitmapButton( &info
, tool
->GetNormalBitmap(), kControlContentIconRef
);
1405 if ( UMAGetSystemVersion() >= 0x1000)
1407 CreateIconControl( window
, &toolrect
, &info
, false, &controlHandle
);
1411 SInt16 behaviour
= kControlBehaviorOffsetContents
;
1412 if ( tool
->CanBeToggled() )
1413 behaviour
|= kControlBehaviorToggles
;
1414 err
= CreateBevelButtonControl( window
,
1415 &toolrect
, CFSTR(""), kControlBevelButtonNormalBevel
,
1416 behaviour
, &info
, 0, 0, 0, &controlHandle
);
1419 #if wxMAC_USE_NATIVE_TOOLBAR
1420 HIToolbarItemRef item
;
1421 wxString labelStr
= wxString::Format(wxT("%xd"), (int)tool
);
1422 err
= HIToolbarItemCreate(
1423 wxMacCFStringHolder(labelStr
, wxFont::GetDefaultEncoding()),
1424 kHIToolbarItemCantBeRemoved
| kHIToolbarItemAnchoredLeft
| kHIToolbarItemAllowDuplicates
, &item
);
1427 InstallEventHandler(
1428 HIObjectGetEventTarget(item
), GetwxMacToolBarEventHandlerUPP(),
1429 GetEventTypeCount(toolBarEventList
), toolBarEventList
, tool
, NULL
);
1430 HIToolbarItemSetLabel( item
, wxMacCFStringHolder(tool
->GetLabel(), m_font
.GetEncoding()) );
1431 HIToolbarItemSetIconRef( item
, info
.u
.iconRef
);
1432 HIToolbarItemSetCommandID( item
, kHIToolbarCommandPressAction
);
1433 tool
->SetToolbarItemRef( item
);
1437 wxMacReleaseBitmapButton( &info
);
1440 SetBevelButtonTextPlacement( m_controlHandle
, kControlBevelButtonPlaceBelowGraphic
);
1441 UMASetControlTitle( m_controlHandle
, label
, wxFont::GetDefaultEncoding() );
1444 InstallControlEventHandler(
1445 (ControlRef
) controlHandle
, GetwxMacToolBarToolEventHandlerUPP(),
1446 GetEventTypeCount(eventList
), eventList
, tool
, NULL
);
1448 tool
->SetControlHandle( controlHandle
);
1452 case wxTOOL_STYLE_CONTROL
:
1454 #if wxMAC_USE_NATIVE_TOOLBAR
1456 wxASSERT( tool
->GetControl() != NULL
);
1457 HIToolbarItemRef item
;
1458 HIViewRef viewRef
= (HIViewRef
) tool
->GetControl()->GetHandle() ;
1459 // as this control now is part of both the wxToolBar children and the native toolbar, we have to increase the
1460 // reference count to make sure we are not dealing with zombie controls after the native toolbar has released its views
1461 CFRetain( viewRef
) ;
1462 CFDataRef data
= CFDataCreate( kCFAllocatorDefault
, (UInt8
*) &viewRef
, sizeof(viewRef
) ) ;
1463 err
= HIToolbarCreateItemWithIdentifier((HIToolbarRef
) m_macHIToolbarRef
,kControlToolbarItemClassID
,
1468 tool
->SetToolbarItemRef( item
);
1474 // right now there's nothing to do here
1484 if ( controlHandle
)
1486 ControlRef container
= (ControlRef
) GetHandle();
1487 wxASSERT_MSG( container
!= NULL
, wxT("No valid Mac container control") );
1489 UMAShowControl( controlHandle
);
1490 ::EmbedControl( controlHandle
, container
);
1493 if ( tool
->CanBeToggled() && tool
->IsToggled() )
1494 tool
->UpdateToggleImage( true );
1496 // nothing special to do here - we relayout in Realize() later
1497 tool
->Attach( this );
1498 InvalidateBestSize();
1502 wxString errMsg
= wxString::Format( wxT("wxToolBar::DoInsertTool - failure [%ld]"), (long)err
);
1503 wxFAIL_MSG( errMsg
.c_str() );
1506 return (err
== noErr
);
1509 void wxToolBar::DoSetToggle(wxToolBarToolBase
*WXUNUSED(tool
), bool WXUNUSED(toggle
))
1511 wxFAIL_MSG( wxT("not implemented") );
1514 bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos
), wxToolBarToolBase
*toolbase
)
1516 wxToolBarTool
* tool
= wx_static_cast( wxToolBarTool
*, toolbase
);
1517 wxToolBarToolsList::compatibility_iterator node
;
1518 for ( node
= m_tools
.GetFirst(); node
; node
= node
->GetNext() )
1520 wxToolBarToolBase
*tool2
= node
->GetData();
1521 if ( tool2
== tool
)
1523 // let node point to the next node in the list
1524 node
= node
->GetNext();
1530 wxSize sz
= ((wxToolBarTool
*)tool
)->GetSize();
1534 #if wxMAC_USE_NATIVE_TOOLBAR
1535 CFIndex removeIndex
= tool
->GetIndex();
1538 switch ( tool
->GetStyle() )
1540 case wxTOOL_STYLE_CONTROL
:
1542 tool
->GetControl()->Destroy();
1543 tool
->ClearControl();
1547 case wxTOOL_STYLE_BUTTON
:
1548 case wxTOOL_STYLE_SEPARATOR
:
1549 if ( tool
->GetControlHandle() )
1551 #if wxMAC_USE_NATIVE_TOOLBAR
1552 if ( removeIndex
!= -1 && m_macHIToolbarRef
)
1554 HIToolbarRemoveItemAtIndex( (HIToolbarRef
) m_macHIToolbarRef
, removeIndex
);
1555 tool
->SetIndex( -1 );
1559 tool
->ClearControl();
1567 // and finally reposition all the controls after this one
1569 for ( /* node -> first after deleted */; node
; node
= node
->GetNext() )
1571 wxToolBarTool
*tool2
= (wxToolBarTool
*) node
->GetData();
1572 wxPoint pt
= tool2
->GetPosition();
1574 if ( GetWindowStyleFlag() & wxTB_VERTICAL
)
1579 tool2
->SetPosition( pt
);
1581 #if wxMAC_USE_NATIVE_TOOLBAR
1582 if ( removeIndex
!= -1 && tool2
->GetIndex() > removeIndex
)
1583 tool2
->SetIndex( tool2
->GetIndex() - 1 );
1587 InvalidateBestSize();
1592 void wxToolBar::OnPaint(wxPaintEvent
& event
)
1594 #if wxMAC_USE_NATIVE_TOOLBAR
1595 if ( m_macUsesNativeToolbar
)
1607 bool drawMetalTheme
= MacGetTopLevelWindow()->MacGetMetalAppearance();
1608 bool minimumUmaAvailable
= (UMAGetSystemVersion() >= 0x1030);
1610 #if wxMAC_USE_CORE_GRAPHICS && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
1611 if ( !drawMetalTheme
&& minimumUmaAvailable
)
1613 HIThemePlacardDrawInfo info
;
1614 memset( &info
, 0, sizeof(info
) );
1616 info
.state
= IsEnabled() ? kThemeStateActive
: kThemeStateInactive
;
1618 CGContextRef cgContext
= (CGContextRef
) MacGetCGContextRef();
1619 HIRect rect
= CGRectMake( 0, 0, w
, h
);
1620 HIThemeDrawPlacard( &rect
, &info
, cgContext
, kHIThemeOrientationNormal
);
1624 // leave the background as it is (striped or metal)
1629 const bool drawBorder
= true;
1633 wxMacPortSetter
helper( &dc
);
1635 if ( !drawMetalTheme
|| !minimumUmaAvailable
)
1637 Rect toolbarrect
= { dc
.YLOG2DEVMAC(0), dc
.XLOG2DEVMAC(0),
1638 dc
.YLOG2DEVMAC(h
), dc
.XLOG2DEVMAC(w
) };
1641 if ( toolbarrect
.left
< 0 )
1642 toolbarrect
.left
= 0;
1643 if ( toolbarrect
.top
< 0 )
1644 toolbarrect
.top
= 0;
1647 UMADrawThemePlacard( &toolbarrect
, IsEnabled() ? kThemeStateActive
: kThemeStateInactive
);
1651 #if TARGET_API_MAC_OSX
1652 HIRect hiToolbarrect
= CGRectMake(
1653 dc
.YLOG2DEVMAC(0), dc
.XLOG2DEVMAC(0),
1654 dc
.YLOG2DEVREL(h
), dc
.XLOG2DEVREL(w
) );
1655 CGContextRef cgContext
;
1658 GetPortBounds( (CGrafPtr
) dc
.m_macPort
, &bounds
);
1659 QDBeginCGContext( (CGrafPtr
) dc
.m_macPort
, &cgContext
);
1661 CGContextTranslateCTM( cgContext
, 0, bounds
.bottom
- bounds
.top
);
1662 CGContextScaleCTM( cgContext
, 1, -1 );
1664 HIThemeBackgroundDrawInfo drawInfo
;
1665 drawInfo
.version
= 0;
1666 drawInfo
.state
= kThemeStateActive
;
1667 drawInfo
.kind
= kThemeBackgroundMetal
;
1668 HIThemeApplyBackground( &hiToolbarrect
, &drawInfo
, cgContext
, kHIThemeOrientationNormal
);
1670 QDEndCGContext( (CGrafPtr
) dc
.m_macPort
, &cgContext
);
1679 #endif // wxUSE_TOOLBAR