]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/toolbar.cpp
5c6aedcb0ef290ac3c59bf290fb80cbfec33efbf
[wxWidgets.git] / src / mac / carbon / toolbar.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: toolbar.cpp
3 // Purpose: wxToolBar
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: The wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "toolbar.h"
14 #endif
15
16 #include "wx/wxprec.h"
17
18 #if wxUSE_TOOLBAR
19
20 #include "wx/wx.h"
21 #include "wx/toolbar.h"
22 #include "wx/notebook.h"
23 #include "wx/tabctrl.h"
24 #include "wx/bitmap.h"
25
26 #if !USE_SHARED_LIBRARY
27 IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxControl)
28
29 BEGIN_EVENT_TABLE(wxToolBar, wxToolBarBase)
30 EVT_PAINT( wxToolBar::OnPaint )
31 END_EVENT_TABLE()
32 #endif
33
34 #include "wx/mac/uma.h"
35 #include "wx/geometry.h"
36
37 #ifdef __WXMAC_OSX__
38 const short kwxMacToolBarToolDefaultWidth = 24 ;
39 const short kwxMacToolBarToolDefaultHeight = 24 ;
40 const short kwxMacToolBarTopMargin = 4 ;
41 const short kwxMacToolBarLeftMargin = 4 ;
42 const short kwxMacToolBorder = 0 ;
43 const short kwxMacToolSpacing = 6 ;
44 #else
45 const short kwxMacToolBarToolDefaultWidth = 24 ;
46 const short kwxMacToolBarToolDefaultHeight = 22 ;
47 const short kwxMacToolBarTopMargin = 2 ;
48 const short kwxMacToolBarLeftMargin = 2 ;
49 const short kwxMacToolBorder = 4 ;
50 const short kwxMacToolSpacing = 0 ;
51 #endif
52
53 // ----------------------------------------------------------------------------
54 // private classes
55 // ----------------------------------------------------------------------------
56
57 class wxToolBarTool : public wxToolBarToolBase
58 {
59 public:
60 wxToolBarTool(wxToolBar *tbar,
61 int id,
62 const wxString& label,
63 const wxBitmap& bmpNormal,
64 const wxBitmap& bmpDisabled,
65 wxItemKind kind,
66 wxObject *clientData,
67 const wxString& shortHelp,
68 const wxString& longHelp) ;
69
70 wxToolBarTool(wxToolBar *tbar, wxControl *control)
71 : wxToolBarToolBase(tbar, control)
72 {
73 Init() ;
74 }
75
76 ~wxToolBarTool()
77 {
78 if ( m_controlHandle )
79 DisposeControl( m_controlHandle ) ;
80 }
81
82 WXWidget GetControlHandle() { return (WXWidget) m_controlHandle ; }
83 void SetControlHandle( ControlRef handle ) { m_controlHandle = handle ; }
84
85 void SetSize(const wxSize& size) ;
86 void SetPosition( const wxPoint& position ) ;
87
88 wxSize GetSize() const
89 {
90 if ( IsControl() )
91 {
92 return GetControl()->GetSize() ;
93 }
94 else if ( IsButton() )
95 {
96 return GetToolBar()->GetToolSize() ;
97 }
98 else
99 {
100 // separator size
101 wxSize sz = GetToolBar()->GetToolSize() ;
102 if ( GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL )
103 sz.y /= 4 ;
104 else
105 sz.x /= 4 ;
106 return sz ;
107 }
108 }
109 wxPoint GetPosition() const
110 {
111 return wxPoint(m_x, m_y);
112 }
113 bool DoEnable( bool enable ) ;
114
115 void UpdateToggleImage( bool toggle ) ;
116 private :
117 void Init()
118 {
119 m_controlHandle = NULL ;
120 }
121 ControlRef m_controlHandle ;
122
123 wxCoord m_x;
124 wxCoord m_y;
125 };
126
127 static const EventTypeSpec eventList[] =
128 {
129 { kEventClassControl , kEventControlHit } ,
130 #ifdef __WXMAC_OSX__
131 { kEventClassControl , kEventControlHitTest } ,
132 #endif
133 } ;
134
135 static pascal OSStatus wxMacToolBarToolControlEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
136 {
137 OSStatus result = eventNotHandledErr ;
138
139 wxMacCarbonEvent cEvent( event ) ;
140
141 ControlRef controlRef ;
142
143 cEvent.GetParameter( kEventParamDirectObject , &controlRef ) ;
144
145 switch( GetEventKind( event ) )
146 {
147 case kEventControlHit :
148 {
149 wxToolBarTool* tbartool = (wxToolBarTool*)data ;
150 if ( tbartool->CanBeToggled() )
151 {
152 #ifdef __WXMAC_OSX__
153 ((wxToolBar*)tbartool->GetToolBar())->ToggleTool(tbartool->GetId(), !tbartool->IsToggled() );
154 #else
155 ((wxToolBar*)tbartool->GetToolBar())->ToggleTool(tbartool->GetId(), GetControl32BitValue((ControlRef)tbartool->GetControlHandle()));
156 #endif
157 }
158 ((wxToolBar*)tbartool->GetToolBar())->OnLeftClick( tbartool->GetId() , tbartool -> IsToggled() ) ;
159 result = noErr;
160 }
161 break ;
162 #ifdef __WXMAC_OSX__
163 case kEventControlHitTest :
164 {
165 HIPoint pt = cEvent.GetParameter<HIPoint>(kEventParamMouseLocation) ;
166 HIRect rect ;
167 HIViewGetBounds( controlRef , &rect ) ;
168
169 ControlPartCode pc = kControlNoPart ;
170 if ( CGRectContainsPoint( rect , pt ) )
171 pc = kControlButtonPart ;
172 cEvent.SetParameter( kEventParamControlPart , typeControlPartCode, pc ) ;
173 result = noErr ;
174 }
175 break ;
176 #endif
177 default :
178 break ;
179 }
180 return result ;
181 }
182
183 pascal OSStatus wxMacToolBarToolEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
184 {
185 OSStatus result = eventNotHandledErr ;
186
187 switch ( GetEventClass( event ) )
188 {
189 case kEventClassControl :
190 result = wxMacToolBarToolControlEventHandler( handler, event, data ) ;
191 break ;
192 default :
193 break ;
194 }
195 return result ;
196 }
197
198 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacToolBarToolEventHandler )
199
200 // ============================================================================
201 // implementation
202 // ============================================================================
203
204 // ----------------------------------------------------------------------------
205 // wxToolBarTool
206 // ----------------------------------------------------------------------------
207
208 bool wxToolBarTool::DoEnable(bool enable)
209 {
210 if ( IsControl() )
211 {
212 GetControl()->Enable( enable ) ;
213 }
214 else if ( IsButton() )
215 {
216 #if TARGET_API_MAC_OSX
217 if ( enable )
218 EnableControl( m_controlHandle ) ;
219 else
220 DisableControl( m_controlHandle ) ;
221 #else
222 if ( enable )
223 ActivateControl( m_controlHandle ) ;
224 else
225 DeactivateControl( m_controlHandle ) ;
226 #endif
227 }
228 return true ;
229 }
230 void wxToolBarTool::SetSize(const wxSize& size)
231 {
232 if ( IsControl() )
233 {
234 GetControl()->SetSize( size ) ;
235 }
236 }
237
238 void wxToolBarTool::SetPosition(const wxPoint& position)
239 {
240 m_x = position.x;
241 m_y = position.y;
242
243 int x , y ;
244 x = y = 0 ;
245 int mac_x = position.x ;
246 int mac_y = position.y ;
247
248 if ( ! GetToolBar()->MacGetTopLevelWindow()->MacUsesCompositing() )
249 {
250 WindowRef rootwindow = (WindowRef) GetToolBar()->MacGetTopLevelWindowRef() ;
251 GetToolBar()->MacWindowToRootWindow( &x , &y ) ;
252 mac_x += x;
253 mac_y += y;
254 }
255
256 if ( IsButton() )
257 {
258 Rect contrlRect ;
259 GetControlBounds( m_controlHandle , &contrlRect ) ;
260 int former_mac_x = contrlRect.left ;
261 int former_mac_y = contrlRect.top ;
262 GetToolBar()->GetToolSize() ;
263
264 if ( mac_x != former_mac_x || mac_y != former_mac_y )
265 {
266 UMAMoveControl( m_controlHandle , mac_x , mac_y ) ;
267 }
268 }
269 else if ( IsControl() )
270 {
271 GetControl()->Move( position ) ;
272 }
273 else
274 {
275 // separator
276 #ifdef __WXMAC_OSX__
277 Rect contrlRect ;
278 GetControlBounds( m_controlHandle , &contrlRect ) ;
279 int former_mac_x = contrlRect.left ;
280 int former_mac_y = contrlRect.top ;
281
282 if ( mac_x != former_mac_x || mac_y != former_mac_y )
283 {
284 UMAMoveControl( m_controlHandle , mac_x , mac_y ) ;
285 }
286 #endif
287 }
288 }
289
290 void wxToolBarTool::UpdateToggleImage( bool toggle )
291 {
292 #ifdef __WXMAC_OSX__
293 if ( toggle )
294 {
295 int w = m_bmpNormal.GetWidth() ;
296 int h = m_bmpNormal.GetHeight() ;
297 wxBitmap bmp( w , h ) ;
298 wxMemoryDC dc ;
299 dc.SelectObject( bmp ) ;
300 dc.SetPen( wxNullPen ) ;
301 dc.SetBackground( *wxWHITE ) ;
302 dc.DrawRectangle( 0 , 0 , w , h ) ;
303 dc.DrawBitmap( m_bmpNormal , 0 , 0 , true) ;
304 dc.SelectObject( wxNullBitmap ) ;
305 ControlButtonContentInfo info ;
306 wxMacCreateBitmapButton( &info , bmp ) ;
307 SetControlData( m_controlHandle , 0, kControlIconContentTag, sizeof( info ),
308 (Ptr)&info );
309 wxMacReleaseBitmapButton( &info ) ;
310 }
311 else
312 {
313 ControlButtonContentInfo info ;
314 wxMacCreateBitmapButton( &info , m_bmpNormal ) ;
315 SetControlData( m_controlHandle , 0, kControlIconContentTag, sizeof( info ),
316 (Ptr)&info );
317 wxMacReleaseBitmapButton( &info ) ;
318 }
319
320 IconTransformType transform = toggle ? kTransformSelected : kTransformNone ;
321 SetControlData( m_controlHandle, 0, kControlIconTransformTag, sizeof( transform ),
322 (Ptr)&transform );
323 HIViewSetNeedsDisplay( m_controlHandle , true ) ;
324
325 #else
326 ::SetControl32BitValue( m_controlHandle , toggle ) ;
327 #endif
328 }
329
330 wxToolBarTool::wxToolBarTool(wxToolBar *tbar,
331 int id,
332 const wxString& label,
333 const wxBitmap& bmpNormal,
334 const wxBitmap& bmpDisabled,
335 wxItemKind kind,
336 wxObject *clientData,
337 const wxString& shortHelp,
338 const wxString& longHelp)
339 : wxToolBarToolBase(tbar, id, label, bmpNormal, bmpDisabled, kind,
340 clientData, shortHelp, longHelp)
341 {
342 Init();
343
344 WindowRef window = (WindowRef) tbar->MacGetTopLevelWindowRef() ;
345 wxSize toolSize = tbar->GetToolSize() ;
346 Rect toolrect = { 0, 0 , toolSize.y , toolSize.x } ;
347
348 if ( id == wxID_SEPARATOR )
349 {
350 toolSize.x /= 4 ;
351 toolSize.y /= 4 ;
352 if ( GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL )
353 {
354 toolrect.bottom = toolSize.y ;
355 }
356 else
357 {
358 toolrect.right = toolSize.x ;
359 }
360 #ifdef __WXMAC_OSX__
361 // in flat style we need a visual separator
362 CreateSeparatorControl( window , &toolrect , &m_controlHandle ) ;
363 #endif
364 }
365 else
366 {
367 ControlButtonContentInfo info ;
368 wxMacCreateBitmapButton( &info , GetNormalBitmap() , kControlContentIconRef ) ;
369
370 #ifdef __WXMAC_OSX__
371 CreateIconControl( window , &toolrect , &info , false , &m_controlHandle ) ;
372 #else
373 SInt16 behaviour = kControlBehaviorOffsetContents ;
374 if ( CanBeToggled() )
375 behaviour += kControlBehaviorToggles ;
376 CreateBevelButtonControl( window , &toolrect , CFSTR("") , kControlBevelButtonNormalBevel , behaviour , &info ,
377 0 , 0 , 0 , &m_controlHandle ) ;
378 #endif
379
380 wxMacReleaseBitmapButton( &info ) ;
381 /*
382 SetBevelButtonTextPlacement( m_controlHandle , kControlBevelButtonPlaceBelowGraphic ) ;
383 UMASetControlTitle( m_controlHandle , label , wxFont::GetDefaultEncoding() ) ;
384 */
385
386 InstallControlEventHandler( (ControlRef) m_controlHandle, GetwxMacToolBarToolEventHandlerUPP(),
387 GetEventTypeCount(eventList), eventList, this,NULL);
388
389 }
390 ControlRef container = (ControlRef) tbar->GetHandle() ;
391 wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ;
392 if ( m_controlHandle )
393 {
394 UMAShowControl( m_controlHandle ) ;
395 ::EmbedControl( m_controlHandle , container ) ;
396 }
397 if ( CanBeToggled() && IsToggled() )
398 {
399 UpdateToggleImage( true ) ;
400 }
401 }
402
403
404 wxToolBarToolBase *wxToolBar::CreateTool(int id,
405 const wxString& label,
406 const wxBitmap& bmpNormal,
407 const wxBitmap& bmpDisabled,
408 wxItemKind kind,
409 wxObject *clientData,
410 const wxString& shortHelp,
411 const wxString& longHelp)
412 {
413 return new wxToolBarTool(this, id, label, bmpNormal, bmpDisabled, kind,
414 clientData, shortHelp, longHelp);
415 }
416
417 wxToolBarToolBase *wxToolBar::CreateTool(wxControl *control)
418 {
419 return new wxToolBarTool(this, control);
420 }
421
422 void wxToolBar::Init()
423 {
424 m_maxWidth = -1;
425 m_maxHeight = -1;
426 m_defaultWidth = kwxMacToolBarToolDefaultWidth;
427 m_defaultHeight = kwxMacToolBarToolDefaultHeight;
428 }
429
430 bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
431 long style, const wxString& name)
432 {
433
434 if ( !wxToolBarBase::Create( parent , id , pos , size , style ) )
435 return FALSE ;
436
437 return TRUE;
438 }
439
440 wxToolBar::~wxToolBar()
441 {
442 // we must refresh the frame size when the toolbar is deleted but the frame
443 // is not - otherwise toolbar leaves a hole in the place it used to occupy
444 }
445
446 bool wxToolBar::Realize()
447 {
448 if (m_tools.GetCount() == 0)
449 return FALSE;
450
451 int x = m_xMargin + kwxMacToolBarLeftMargin ;
452 int y = m_yMargin + kwxMacToolBarTopMargin ;
453
454 int tw, th;
455 GetSize(& tw, & th);
456
457 int maxWidth = 0 ;
458 int maxHeight = 0 ;
459
460 int maxToolWidth = 0;
461 int maxToolHeight = 0;
462
463 // Find the maximum tool width and height
464 wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst();
465 while ( node )
466 {
467 wxToolBarTool *tool = (wxToolBarTool *)node->GetData();
468 wxSize sz = tool->GetSize() ;
469
470 if ( sz.x > maxToolWidth )
471 maxToolWidth = sz.x ;
472 if (sz.y> maxToolHeight)
473 maxToolHeight = sz.y;
474
475 node = node->GetNext();
476 }
477
478 bool lastWasRadio = FALSE;
479 node = m_tools.GetFirst();
480 while (node)
481 {
482 wxToolBarTool *tool = (wxToolBarTool *)node->GetData();
483 wxSize cursize = tool->GetSize() ;
484
485 bool isRadio = FALSE;
486
487 if ( tool->IsButton() && tool->GetKind() == wxITEM_RADIO )
488 {
489 if ( !lastWasRadio )
490 {
491 if (tool->Toggle(true))
492 {
493 DoToggleTool(tool, true);
494 }
495 }
496 isRadio = TRUE;
497 }
498 else
499 {
500 isRadio = FALSE;
501 }
502 lastWasRadio = isRadio;
503
504 // for the moment we just do a single row/column alignement
505 if ( x + cursize.x > maxWidth )
506 maxWidth = x + cursize.x ;
507 if ( y + cursize.y > maxHeight )
508 maxHeight = y + cursize.y ;
509
510 if ( GetWindowStyleFlag() & wxTB_VERTICAL )
511 {
512 int x1 = x + (maxToolWidth - cursize.x)/2 ;
513 tool->SetPosition( wxPoint( x1 , y ) ) ;
514 }
515 else
516 {
517 int y1 = y + (maxToolHeight - cursize.y)/2 ;
518 tool->SetPosition( wxPoint( x , y1 ) ) ;
519 }
520 if ( GetWindowStyleFlag() & wxTB_VERTICAL )
521 {
522 y += cursize.y ;
523 y += kwxMacToolSpacing ;
524 }
525 else
526 {
527 x += cursize.x ;
528 x += kwxMacToolSpacing ;
529 }
530
531 node = node->GetNext();
532 }
533
534 if ( GetWindowStyleFlag() & wxTB_HORIZONTAL )
535 {
536 if ( m_maxRows == 0 )
537 {
538 // if not set yet, only one row
539 SetRows(1);
540 }
541 m_minWidth = maxWidth;
542 maxWidth = tw ;
543 maxHeight += m_yMargin + kwxMacToolBarTopMargin;
544 m_minHeight = m_maxHeight = maxHeight ;
545 }
546 else
547 {
548 if ( GetToolsCount() > 0 && m_maxRows == 0 )
549 {
550 // if not set yet, have one column
551 SetRows(GetToolsCount());
552 }
553 m_minHeight = maxHeight;
554 maxHeight = th ;
555 maxWidth += m_xMargin + kwxMacToolBarLeftMargin;
556 m_minWidth = m_maxWidth = maxWidth ;
557 }
558
559 SetSize( maxWidth, maxHeight );
560 InvalidateBestSize();
561
562 return TRUE;
563 }
564
565 void wxToolBar::SetToolBitmapSize(const wxSize& size)
566 {
567 m_defaultWidth = size.x+kwxMacToolBorder; m_defaultHeight = size.y+kwxMacToolBorder;
568 }
569
570 // The button size is bigger than the bitmap size
571 wxSize wxToolBar::GetToolSize() const
572 {
573 return wxSize(m_defaultWidth + kwxMacToolBorder, m_defaultHeight + kwxMacToolBorder);
574 }
575
576 void wxToolBar::SetRows(int nRows)
577 {
578 if ( nRows == m_maxRows )
579 {
580 // avoid resizing the frame uselessly
581 return;
582 }
583
584 m_maxRows = nRows;
585 }
586
587 void wxToolBar::MacSuperChangedPosition()
588 {
589 wxWindow::MacSuperChangedPosition() ;
590 Realize() ;
591 }
592
593 wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord x, wxCoord y) const
594 {
595 wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst();
596 while (node)
597 {
598 wxToolBarTool *tool = (wxToolBarTool *)node->GetData() ;
599 wxRect2DInt r( tool->GetPosition() , tool->GetSize() ) ;
600 if ( r.Contains( wxPoint( x , y ) ) )
601 {
602 return tool;
603 }
604
605 node = node->GetNext();
606 }
607
608 return (wxToolBarToolBase *)NULL;
609 }
610
611 wxString wxToolBar::MacGetToolTipString( wxPoint &pt )
612 {
613 wxToolBarToolBase* tool = FindToolForPosition( pt.x , pt.y ) ;
614 if ( tool )
615 {
616 return tool->GetShortHelp() ;
617 }
618 return wxEmptyString ;
619 }
620
621 void wxToolBar::DoEnableTool(wxToolBarToolBase *t, bool enable)
622 {
623 ((wxToolBarTool*)t)->DoEnable( enable ) ;
624 }
625
626 void wxToolBar::DoToggleTool(wxToolBarToolBase *t, bool toggle)
627 {
628 wxToolBarTool *tool = (wxToolBarTool *)t;
629 if ( tool->IsButton() )
630 {
631 tool->UpdateToggleImage( toggle ) ;
632 }
633 }
634
635 bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos),
636 wxToolBarToolBase *tool)
637 {
638 // nothing special to do here - we relayout in Realize() later
639 tool->Attach(this);
640 InvalidateBestSize();
641
642 return TRUE;
643 }
644
645 void wxToolBar::DoSetToggle(wxToolBarToolBase *WXUNUSED(tool), bool WXUNUSED(toggle))
646 {
647 wxFAIL_MSG( _T("not implemented") );
648 }
649
650 bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos), wxToolBarToolBase *tool)
651 {
652 wxToolBarToolsList::compatibility_iterator node;
653 for ( node = m_tools.GetFirst(); node; node = node->GetNext() )
654 {
655 wxToolBarToolBase *tool2 = node->GetData();
656 if ( tool2 == tool )
657 {
658 // let node point to the next node in the list
659 node = node->GetNext();
660
661 break;
662 }
663 }
664
665 wxSize sz = ((wxToolBarTool*)tool)->GetSize() ;
666
667 tool->Detach();
668
669 // and finally reposition all the controls after this one
670
671 for ( /* node -> first after deleted */ ; node; node = node->GetNext() )
672 {
673 wxToolBarTool *tool2 = (wxToolBarTool*) node->GetData();
674 wxPoint pt = tool2->GetPosition() ;
675
676 if ( GetWindowStyleFlag() & wxTB_VERTICAL )
677 {
678 pt.y -= sz.y ;
679 }
680 else
681 {
682 pt.x -= sz.x ;
683 }
684 tool2->SetPosition( pt ) ;
685 }
686
687 InvalidateBestSize();
688 return TRUE ;
689 }
690
691 void wxToolBar::OnPaint(wxPaintEvent& event)
692 {
693 wxPaintDC dc(this) ;
694 #if wxMAC_USE_CORE_GRAPHICS
695 // leave the background as it is (striped or metal)
696 #else
697 wxMacPortSetter helper(&dc) ;
698 int w, h ;
699 GetSize( &w , &h ) ;
700
701 Rect toolbarrect = { dc.YLOG2DEVMAC(0) , dc.XLOG2DEVMAC(0) ,
702 dc.YLOG2DEVMAC(h) , dc.XLOG2DEVMAC(w) } ;
703 /*
704 if( toolbarrect.left < 0 )
705 toolbarrect.left = 0 ;
706 if ( toolbarrect.top < 0 )
707 toolbarrect.top = 0 ;
708 */
709 if ( !MacGetTopLevelWindow()->MacGetMetalAppearance() )
710 {
711 UMADrawThemePlacard( &toolbarrect , IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
712 }
713 else
714 {
715 #if TARGET_API_MAC_OSX
716 #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
717 if ( UMAGetSystemVersion() >= 0x1030 )
718 {
719 HIRect hiToolbarrect = CGRectMake( dc.YLOG2DEVMAC(0) , dc.XLOG2DEVMAC(0) ,
720 dc.YLOG2DEVREL(h) , dc.XLOG2DEVREL(w) );
721 CGContextRef cgContext ;
722 Rect bounds ;
723 GetPortBounds( (CGrafPtr) dc.m_macPort , &bounds ) ;
724 QDBeginCGContext( (CGrafPtr) dc.m_macPort , &cgContext ) ;
725 CGContextTranslateCTM( cgContext , 0 , bounds.bottom - bounds.top ) ;
726 CGContextScaleCTM( cgContext , 1 , -1 ) ;
727
728 {
729 HIThemeBackgroundDrawInfo drawInfo ;
730 drawInfo.version = 0 ;
731 drawInfo.state = kThemeStateActive ;
732 drawInfo.kind = kThemeBackgroundMetal ;
733 HIThemeApplyBackground( &hiToolbarrect, &drawInfo , cgContext,kHIThemeOrientationNormal) ;
734 }
735 QDEndCGContext( (CGrafPtr) dc.m_macPort , &cgContext ) ;
736 }
737 else
738 #endif
739 {
740 UMADrawThemePlacard( &toolbarrect , IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
741 }
742 #endif
743 }
744 #endif
745
746 event.Skip() ;
747 }
748
749 #endif // wxUSE_TOOLBAR
750