]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/renderer.cpp
Added missing include
[wxWidgets.git] / src / mac / carbon / renderer.cpp
CommitLineData
9c7f49f5 1///////////////////////////////////////////////////////////////////////////////
7af14d71 2// Name: src/mac/carbon/renderer.cpp
38c4cb6a 3// Purpose: implementation of wxRendererNative for Mac
9c7f49f5
VZ
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 20.07.2003
7// RCS-ID: $Id$
8// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
65571936 9// License: wxWindows licence
9c7f49f5
VZ
10///////////////////////////////////////////////////////////////////////////////
11
9c7f49f5
VZ
12// for compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
15#ifdef __BORLANDC__
16 #pragma hdrstop
17#endif
18
19#ifndef WX_PRECOMP
20 #include "wx/string.h"
4c948343
VZ
21 #include "wx/dc.h"
22 #include "wx/bitmap.h"
23 #include "wx/settings.h"
ed4b0fdc 24 #include "wx/dcclient.h"
1832043f 25 #include "wx/toplevel.h"
7af14d71 26#endif
9c7f49f5
VZ
27
28#include "wx/renderer.h"
8acd14d1 29#include "wx/graphics.h"
547aafd2 30#include "wx/mac/uma.h"
9c7f49f5 31
9c7f49f5 32
5cb80ad2 33class WXDLLEXPORT wxRendererMac : public wxDelegateRendererNative
9c7f49f5
VZ
34{
35public:
36 // draw the header control button (used by wxListCtrl)
c97c9952 37 virtual int DrawHeaderButton( wxWindow *win,
7af14d71
DS
38 wxDC& dc,
39 const wxRect& rect,
4b94ddc4 40 int flags = 0,
80752b57 41 wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
4b94ddc4 42 wxHeaderButtonParams* params = NULL );
9c7f49f5 43
4b94ddc4 44 virtual int GetHeaderButtonHeight(wxWindow *win);
a61c9122 45
9c7f49f5 46 // draw the expanded/collapsed icon for a tree control item
7af14d71
DS
47 virtual void DrawTreeItemButton( wxWindow *win,
48 wxDC& dc,
49 const wxRect& rect,
50 int flags = 0 );
9c7f49f5 51
b3208e11 52 // draw a (vertical) sash
7af14d71
DS
53 virtual void DrawSplitterSash( wxWindow *win,
54 wxDC& dc,
55 const wxSize& size,
56 wxCoord position,
57 wxOrientation orient,
58 int flags = 0 );
cf511e87 59
6239ee05
SC
60 virtual void DrawCheckBox(wxWindow *win,
61 wxDC& dc,
62 const wxRect& rect,
63 int flags = 0);
64
cf511e87
RD
65 virtual void DrawComboBoxDropButton(wxWindow *win,
66 wxDC& dc,
67 const wxRect& rect,
68 int flags = 0);
a61c9122 69
cf511e87
RD
70 virtual void DrawPushButton(wxWindow *win,
71 wxDC& dc,
72 const wxRect& rect,
73 int flags = 0);
a61c9122 74
a4609ab8
KO
75 virtual void DrawItemSelectionRect(wxWindow *win,
76 wxDC& dc,
77 const wxRect& rect,
78 int flags = 0);
b3208e11 79
688a201a
JS
80 virtual void DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect, int flags = 0);
81
9c7f49f5 82private:
cf511e87
RD
83 void DrawMacThemeButton(wxWindow *win,
84 wxDC& dc,
85 const wxRect& rect,
86 int flags,
87 int kind,
88 int adornment);
a61c9122 89
9c7f49f5 90 // the tree buttons
7af14d71
DS
91 wxBitmap m_bmpTreeExpanded;
92 wxBitmap m_bmpTreeCollapsed;
9c7f49f5
VZ
93};
94
9c7f49f5
VZ
95// ============================================================================
96// implementation
97// ============================================================================
98
7af14d71 99// static
f0244295 100wxRendererNative& wxRendererNative::GetDefault()
9c7f49f5
VZ
101{
102 static wxRendererMac s_rendererMac;
103
104 return s_rendererMac;
105}
106
c97c9952 107int wxRendererMac::DrawHeaderButton( wxWindow *win,
7af14d71
DS
108 wxDC& dc,
109 const wxRect& rect,
4b94ddc4 110 int flags,
80752b57 111 wxHeaderSortIconType sortArrow,
4b94ddc4 112 wxHeaderButtonParams* params )
9c7f49f5 113{
2185a8a3 114#if !wxMAC_USE_CORE_GRAPHICS
1c5decd0
SC
115 const wxCoord x = dc.LogicalToDeviceX(rect.x);
116 const wxCoord y = dc.LogicalToDeviceY(rect.y);
977d15a6
SC
117 const wxCoord w = dc.LogicalToDeviceXRel(rect.width);
118 const wxCoord h = dc.LogicalToDeviceYRel(rect.height);
1c5decd0
SC
119#else
120 // now the wxGCDC is using native transformations
121 const wxCoord x = rect.x;
122 const wxCoord y = rect.y;
123 const wxCoord w = rect.width;
124 const wxCoord h = rect.height;
125#endif
7af14d71 126
11d1adbf 127 dc.SetBrush( *wxTRANSPARENT_BRUSH );
9c7f49f5 128
a62f32af
SC
129 HIRect headerRect = CGRectMake( x, y, w, h );
130 if ( !dc.IsKindOf( CLASSINFO( wxPaintDC ) ) )
2480cf88 131 {
a62f32af 132 Rect r =
2480cf88 133 {
a62f32af
SC
134 (short) headerRect.origin.y, (short) headerRect.origin.x,
135 (short) (headerRect.origin.y + headerRect.size.height),
136 (short) (headerRect.origin.x + headerRect.size.width)
137 };
138
139 RgnHandle updateRgn = NewRgn();
140 RectRgn( updateRgn, &r );
141 HIViewSetNeedsDisplayInRegion( (HIViewRef) win->GetHandle(), updateRgn, true );
142 DisposeRgn( updateRgn );
143 }
144 else
145 {
146 CGContextRef cgContext;
7af14d71 147
2480cf88 148#if wxMAC_USE_CORE_GRAPHICS
be01a403 149 cgContext = (CGContextRef) dc.GetGraphicsContext()->GetNativeContext();
2480cf88 150#else
a62f32af 151 Rect bounds;
7af14d71 152
a62f32af
SC
153 GetPortBounds( (CGrafPtr) dc.m_macPort, &bounds );
154 QDBeginCGContext( (CGrafPtr) dc.m_macPort, &cgContext );
7af14d71 155
a62f32af
SC
156 CGContextTranslateCTM( cgContext, 0, bounds.bottom - bounds.top );
157 CGContextScaleCTM( cgContext, 1, -1 );
7af14d71 158
6239ee05
SC
159 HIShapeRef shape = HIShapeCreateWithQDRgn( (RgnHandle) dc.m_macCurrentClipRgn );
160 if ( shape != 0 )
161 {
162 HIShapeReplacePathInCGContext( shape , cgContext );
163 CFRelease( shape );
164 CGContextClip( cgContext );
165 }
a62f32af 166 HIViewConvertRect( &headerRect, (HIViewRef) win->GetHandle(), (HIViewRef) win->MacGetTopLevelWindow()->GetHandle() );
2480cf88 167#endif
7af14d71 168
a62f32af
SC
169 {
170 HIThemeButtonDrawInfo drawInfo;
171 HIRect labelRect;
7af14d71 172
a62f32af
SC
173 memset( &drawInfo, 0, sizeof(drawInfo) );
174 drawInfo.version = 0;
a62f32af 175 drawInfo.kind = kThemeListHeaderButton;
4b94ddc4
RD
176 drawInfo.state = (flags & wxCONTROL_DISABLED) ? kThemeStateInactive : kThemeStateActive;
177 drawInfo.value = (flags & wxCONTROL_SELECTED) ? kThemeButtonOn : kThemeButtonOff;
a62f32af 178 drawInfo.adornment = kThemeAdornmentNone;
4b94ddc4
RD
179
180 // The down arrow is drawn automatically, change it to an up arrow if needed.
80752b57 181 if ( sortArrow == wxHDR_SORT_ICON_UP )
4b94ddc4 182 drawInfo.adornment = kThemeAdornmentHeaderButtonSortUp;
a61c9122 183
a62f32af 184 HIThemeDrawButton( &headerRect, &drawInfo, cgContext, kHIThemeOrientationNormal, &labelRect );
4b94ddc4
RD
185
186 // If we don't want any arrows we need to draw over the one already there
80752b57 187 if ( (flags & wxCONTROL_SELECTED) && (sortArrow == wxHDR_SORT_ICON_NONE) )
4b94ddc4
RD
188 {
189 // clip to the header rectangle
190 CGContextSaveGState( cgContext );
191 CGContextClipToRect( cgContext, headerRect );
192 // but draw bigger than that so the arrow will get clipped off
193 headerRect.size.width += 25;
194 HIThemeDrawButton( &headerRect, &drawInfo, cgContext, kHIThemeOrientationNormal, &labelRect );
195 CGContextRestoreGState( cgContext );
a61c9122 196 }
a62f32af 197 }
7af14d71 198
2480cf88
SC
199#if wxMAC_USE_CORE_GRAPHICS
200#else
a62f32af 201 QDEndCGContext( (CGrafPtr) dc.m_macPort, &cgContext );
2480cf88 202#endif
11d1adbf 203 }
4b94ddc4
RD
204
205 // Reserve room for the arrows before writing the label, and turn off the
206 // flags we've already handled
207 wxRect newRect(rect);
80752b57 208 if ( (flags & wxCONTROL_SELECTED) && (sortArrow != wxHDR_SORT_ICON_NONE) )
4b94ddc4
RD
209 {
210 newRect.width -= 12;
80752b57 211 sortArrow = wxHDR_SORT_ICON_NONE;
4b94ddc4 212 }
80752b57 213 flags &= ~wxCONTROL_SELECTED;
4b94ddc4 214
c97c9952 215 return DrawHeaderButtonContents(win, dc, newRect, flags, sortArrow, params);
4b94ddc4
RD
216}
217
218
219int wxRendererMac::GetHeaderButtonHeight(wxWindow* WXUNUSED(win))
220{
688a201a
JS
221 SInt32 standardHeight;
222 OSStatus errStatus;
4b94ddc4
RD
223
224 errStatus = GetThemeMetric( kThemeMetricListHeaderHeight, &standardHeight );
225 if (errStatus == noErr)
226 {
227 return standardHeight;
228 }
229 return -1;
9c7f49f5
VZ
230}
231
7af14d71
DS
232void wxRendererMac::DrawTreeItemButton( wxWindow *win,
233 wxDC& dc,
234 const wxRect& rect,
235 int flags )
9c7f49f5 236{
1c5decd0
SC
237#if !wxMAC_USE_CORE_GRAPHICS
238 const wxCoord x = dc.LogicalToDeviceX(rect.x);
239 const wxCoord y = dc.LogicalToDeviceY(rect.y);
46b59ead
KO
240 const wxCoord w = dc.LogicalToDeviceXRel(rect.width);
241 const wxCoord h = dc.LogicalToDeviceYRel(rect.height);
f3d0a750 242#else
1c5decd0 243 // now the wxGCDC is using native transformations
f3d0a750
RD
244 const wxCoord x = rect.x;
245 const wxCoord y = rect.y;
246 const wxCoord w = rect.width;
247 const wxCoord h = rect.height;
a61c9122 248#endif
1c5decd0 249
46b59ead
KO
250 dc.SetBrush( *wxTRANSPARENT_BRUSH );
251
252 HIRect headerRect = CGRectMake( x, y, w, h );
253 if ( !dc.IsKindOf( CLASSINFO( wxPaintDC ) ) )
254 {
255 Rect r =
9c7f49f5 256 {
46b59ead
KO
257 (short) headerRect.origin.y, (short) headerRect.origin.x,
258 (short) (headerRect.origin.y + headerRect.size.height),
259 (short) (headerRect.origin.x + headerRect.size.width)
260 };
261
262 RgnHandle updateRgn = NewRgn();
263 RectRgn( updateRgn, &r );
264 HIViewSetNeedsDisplayInRegion( (HIViewRef) win->GetHandle(), updateRgn, true );
265 DisposeRgn( updateRgn );
9c7f49f5 266 }
46b59ead
KO
267 else
268 {
269 CGContextRef cgContext;
9c7f49f5 270
46b59ead
KO
271#if wxMAC_USE_CORE_GRAPHICS
272 cgContext = (CGContextRef) dc.GetGraphicsContext()->GetNativeContext();
273#else
274 Rect bounds;
9c7f49f5 275
46b59ead
KO
276 GetPortBounds( (CGrafPtr) dc.m_macPort, &bounds );
277 QDBeginCGContext( (CGrafPtr) dc.m_macPort, &cgContext );
7af14d71 278
46b59ead
KO
279 CGContextTranslateCTM( cgContext, 0, bounds.bottom - bounds.top );
280 CGContextScaleCTM( cgContext, 1, -1 );
281
282 HIShapeReplacePathInCGContext( HIShapeCreateWithQDRgn( (RgnHandle) dc.m_macCurrentClipRgn ), cgContext );
283 CGContextClip( cgContext );
284 HIViewConvertRect( &headerRect, (HIViewRef) win->GetHandle(), (HIViewRef) win->MacGetTopLevelWindow()->GetHandle() );
285#endif
7af14d71 286
7af14d71 287 {
46b59ead
KO
288 HIThemeButtonDrawInfo drawInfo;
289 HIRect labelRect;
290
291 memset( &drawInfo, 0, sizeof(drawInfo) );
292 drawInfo.version = 0;
293 drawInfo.kind = kThemeDisclosureButton;
294 drawInfo.state = (flags & wxCONTROL_DISABLED) ? kThemeStateInactive : kThemeStateActive;
295 // Apple mailing list posts say to use the arrow adornment constants, but those don't work.
296 // We need to set the value using the 'old' DrawThemeButton constants instead.
297 drawInfo.value = (flags & wxCONTROL_EXPANDED) ? kThemeDisclosureDown : kThemeDisclosureRight;
a61c9122 298 drawInfo.adornment = kThemeAdornmentNone;
46b59ead
KO
299
300 HIThemeDrawButton( &headerRect, &drawInfo, cgContext, kHIThemeOrientationNormal, &labelRect );
a61c9122 301
46b59ead
KO
302 }
303
304#if wxMAC_USE_CORE_GRAPHICS
305#else
306 QDEndCGContext( (CGrafPtr) dc.m_macPort, &cgContext );
7af14d71 307#endif
46b59ead 308 }
9c7f49f5
VZ
309}
310
7af14d71
DS
311void wxRendererMac::DrawSplitterSash( wxWindow *win,
312 wxDC& dc,
313 const wxSize& size,
314 wxCoord position,
315 wxOrientation orient,
316 int WXUNUSED(flags) )
b3208e11 317{
a62f32af
SC
318 bool hasMetal = win->MacGetTopLevelWindow()->MacGetMetalAppearance();
319 SInt32 height;
320 GetThemeMetric( kThemeMetricSmallPaneSplitterHeight, &height );
321 HIRect splitterRect;
322 if (orient == wxVERTICAL)
323 splitterRect = CGRectMake( position, 0, height, size.y );
324 else
325 splitterRect = CGRectMake( 0, position, size.x, height );
7af14d71 326
2480cf88 327#if !wxMAC_USE_CORE_GRAPHICS
a62f32af
SC
328 HIViewConvertRect(
329 &splitterRect,
330 (HIViewRef) win->GetHandle(),
331 (HIViewRef) win->MacGetTopLevelWindow()->GetHandle() );
2480cf88 332#endif
547aafd2 333
a62f32af
SC
334 // under compositing we should only draw when called by the OS, otherwise just issue a redraw command
335 // strange redraw errors occur if we don't do this
547aafd2 336
a62f32af
SC
337 if ( !dc.IsKindOf( CLASSINFO( wxPaintDC ) ) )
338 {
339 Rect r =
547aafd2 340 {
a62f32af
SC
341 (short) splitterRect.origin.y,
342 (short) splitterRect.origin.x,
343 (short) (splitterRect.origin.y + splitterRect.size.height),
344 (short) (splitterRect.origin.x + splitterRect.size.width)
345 };
346
347 RgnHandle updateRgn = NewRgn();
348 RectRgn( updateRgn, &r );
349 HIViewSetNeedsDisplayInRegion( (HIViewRef) win->GetHandle(), updateRgn, true );
350 DisposeRgn( updateRgn );
351 }
352 else
353 {
354 CGContextRef cgContext;
7af14d71 355
20b69855 356#if wxMAC_USE_CORE_GRAPHICS
be01a403 357 cgContext = (CGContextRef) dc.GetGraphicsContext()->GetNativeContext();
20b69855 358#else
a62f32af
SC
359 Rect bounds;
360 GetPortBounds( (CGrafPtr) dc.m_macPort, &bounds );
361 QDBeginCGContext( (CGrafPtr) dc.m_macPort, &cgContext );
362 CGContextTranslateCTM( cgContext, 0, bounds.bottom - bounds.top );
363 CGContextScaleCTM( cgContext, 1, -1 );
2480cf88 364#endif
547aafd2 365
a62f32af
SC
366 HIThemeSplitterDrawInfo drawInfo;
367 drawInfo.version = 0;
368 drawInfo.state = kThemeStateActive;
369 drawInfo.adornment = hasMetal ? kHIThemeSplitterAdornmentMetal : kHIThemeSplitterAdornmentNone;
370 HIThemeDrawPaneSplitter( &splitterRect, &drawInfo, cgContext, kHIThemeOrientationNormal );
2480cf88
SC
371
372#if wxMAC_USE_CORE_GRAPHICS
373#else
a62f32af 374 QDEndCGContext( (CGrafPtr) dc.m_macPort, &cgContext );
20b69855 375#endif
547aafd2 376 }
b3208e11 377}
a4609ab8
KO
378
379void
380wxRendererMac::DrawItemSelectionRect(wxWindow *win,
381 wxDC& dc,
382 const wxRect& rect,
383 int flags )
384{
055de350
VZ
385 if ( !(flags & wxCONTROL_SELECTED) )
386 return;
ce0cf2b8
RR
387
388 if (flags & wxCONTROL_FOCUSED)
389 {
390 if (!IsControlActive( (ControlRef)win->GetHandle() ))
391 flags = wxCONTROL_SELECTED;
392 }
055de350 393
a61c9122 394 RGBColor selColor;
055de350
VZ
395 GetThemeBrushAsColor(flags & wxCONTROL_FOCUSED
396 ? kThemeBrushAlternatePrimaryHighlightColor
397 : kThemeBrushSecondaryHighlightColor,
398 32, true, &selColor);
a61c9122 399
055de350 400 wxBrush selBrush(selColor);
a4609ab8
KO
401
402 dc.SetPen( *wxTRANSPARENT_PEN );
403 dc.SetBrush( selBrush );
404 dc.DrawRectangle( rect );
405}
cf511e87
RD
406
407
408void
409wxRendererMac::DrawMacThemeButton(wxWindow *win,
410 wxDC& dc,
411 const wxRect& rect,
412 int flags,
413 int kind,
414 int adornment)
415{
416#if !wxMAC_USE_CORE_GRAPHICS
417 const wxCoord x = dc.LogicalToDeviceX(rect.x);
418 const wxCoord y = dc.LogicalToDeviceY(rect.y);
419 const wxCoord w = dc.LogicalToDeviceXRel(rect.width);
420 const wxCoord h = dc.LogicalToDeviceYRel(rect.height);
421#else
422 // now the wxGCDC is using native transformations
423 const wxCoord x = rect.x;
424 const wxCoord y = rect.y;
425 const wxCoord w = rect.width;
426 const wxCoord h = rect.height;
427#endif
428
429 dc.SetBrush( *wxTRANSPARENT_BRUSH );
430
431 HIRect headerRect = CGRectMake( x, y, w, h );
432 if ( !dc.IsKindOf( CLASSINFO( wxPaintDC ) ) )
433 {
434 Rect r =
435 {
436 (short) headerRect.origin.y, (short) headerRect.origin.x,
437 (short) (headerRect.origin.y + headerRect.size.height),
438 (short) (headerRect.origin.x + headerRect.size.width)
439 };
440
441 RgnHandle updateRgn = NewRgn();
442 RectRgn( updateRgn, &r );
443 HIViewSetNeedsDisplayInRegion( (HIViewRef) win->GetHandle(), updateRgn, true );
444 DisposeRgn( updateRgn );
445 }
446 else
447 {
448 CGContextRef cgContext;
449
450#if wxMAC_USE_CORE_GRAPHICS
451 cgContext = (CGContextRef) dc.GetGraphicsContext()->GetNativeContext();
452#else
453 Rect bounds;
454
455 GetPortBounds( (CGrafPtr) dc.m_macPort, &bounds );
456 QDBeginCGContext( (CGrafPtr) dc.m_macPort, &cgContext );
457
458 CGContextTranslateCTM( cgContext, 0, bounds.bottom - bounds.top );
459 CGContextScaleCTM( cgContext, 1, -1 );
460
461 HIShapeReplacePathInCGContext( HIShapeCreateWithQDRgn( (RgnHandle) dc.m_macCurrentClipRgn ), cgContext );
462 CGContextClip( cgContext );
463 HIViewConvertRect( &headerRect, (HIViewRef) win->GetHandle(), (HIViewRef) win->MacGetTopLevelWindow()->GetHandle() );
464#endif
465
466 {
467 HIThemeButtonDrawInfo drawInfo;
468 HIRect labelRect;
469
470 memset( &drawInfo, 0, sizeof(drawInfo) );
471 drawInfo.version = 0;
472 drawInfo.kind = kind;
473 drawInfo.state = (flags & wxCONTROL_DISABLED) ? kThemeStateInactive : kThemeStateActive;
474 drawInfo.value = (flags & wxCONTROL_SELECTED) ? kThemeButtonOn : kThemeButtonOff;
6239ee05
SC
475 if (flags & wxCONTROL_UNDETERMINED)
476 drawInfo.value = kThemeButtonMixed;
cf511e87
RD
477 drawInfo.adornment = adornment;
478
479 HIThemeDrawButton( &headerRect, &drawInfo, cgContext, kHIThemeOrientationNormal, &labelRect );
480 }
481
482#if wxMAC_USE_CORE_GRAPHICS
483#else
484 QDEndCGContext( (CGrafPtr) dc.m_macPort, &cgContext );
485#endif
486 }
487}
488
6239ee05
SC
489void
490wxRendererMac::DrawCheckBox(wxWindow *win,
491 wxDC& dc,
492 const wxRect& rect,
493 int flags)
494{
495 if (flags & wxCONTROL_CHECKED)
496 flags |= wxCONTROL_SELECTED;
497
498 DrawMacThemeButton(win, dc, rect, flags,
499 kThemeCheckBox, kThemeAdornmentNone);
500}
cf511e87
RD
501
502void
503wxRendererMac::DrawComboBoxDropButton(wxWindow *win,
504 wxDC& dc,
505 const wxRect& rect,
506 int flags)
507{
f8e1a81f 508 int kind;
a61c9122 509 if (win->GetWindowVariant() == wxWINDOW_VARIANT_SMALL || (win->GetParent() && win->GetParent()->GetWindowVariant() == wxWINDOW_VARIANT_SMALL))
f8e1a81f 510 kind = kThemeArrowButtonSmall;
a61c9122 511 else if (win->GetWindowVariant() == wxWINDOW_VARIANT_MINI || (win->GetParent() && win->GetParent()->GetWindowVariant() == wxWINDOW_VARIANT_MINI))
f8e1a81f
JS
512 kind = kThemeArrowButtonMini;
513 else
514 kind = kThemeArrowButton;
a61c9122 515
cf511e87 516 DrawMacThemeButton(win, dc, rect, flags,
f8e1a81f 517 kind, kThemeAdornmentArrowDownArrow);
cf511e87 518}
a61c9122 519
cf511e87
RD
520void
521wxRendererMac::DrawPushButton(wxWindow *win,
522 wxDC& dc,
523 const wxRect& rect,
524 int flags)
525{
f8e1a81f 526 int kind;
a61c9122
JS
527 if (win->GetWindowVariant() == wxWINDOW_VARIANT_SMALL || (win->GetParent() && win->GetParent()->GetWindowVariant() == wxWINDOW_VARIANT_SMALL))
528 kind = kThemeBevelButtonSmall;
529 // There is no kThemeBevelButtonMini, but in this case, use Small
530 else if (win->GetWindowVariant() == wxWINDOW_VARIANT_MINI || (win->GetParent() && win->GetParent()->GetWindowVariant() == wxWINDOW_VARIANT_MINI))
f8e1a81f
JS
531 kind = kThemeBevelButtonSmall;
532 else
533 kind = kThemeBevelButton;
534
cf511e87 535 DrawMacThemeButton(win, dc, rect, flags,
f8e1a81f 536 kind, kThemeAdornmentNone);
cf511e87 537}
a61c9122 538
688a201a
JS
539void
540wxRendererMac::DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect, int flags)
541{
542 if (!win)
543 {
544 wxDelegateRendererNative::DrawFocusRect(win, dc, rect, flags);
545 return;
546 }
547
548#if wxMAC_USE_CORE_GRAPHICS
549 {
550 CGRect cgrect = CGRectMake( rect.x , rect.y , rect.width, rect.height ) ;
551
552 HIThemeFrameDrawInfo info ;
553 memset( &info, 0 , sizeof(info) ) ;
554
555 info.version = 0 ;
556 info.kind = 0 ;
557 info.state = kThemeStateActive;
558 info.isFocused = true ;
559
560 CGContextRef cgContext = (CGContextRef) win->MacGetCGContextRef() ;
561 wxASSERT( cgContext ) ;
562
563 HIThemeDrawFocusRect( &cgrect , true , cgContext , kHIThemeOrientationNormal ) ;
564 }
565#else
566 // FIXME: not yet working for !wxMAC_USE_CORE_GRAPHICS
567 {
568 Rect r;
569 r.left = rect.x; r.top = rect.y; r.right = rect.GetRight(); r.bottom = rect.GetBottom();
570 wxTopLevelWindowMac* top = win->MacGetTopLevelWindow();
571 if ( top )
572 {
573 wxPoint pt(0, 0) ;
574 wxMacControl::Convert( &pt , win->GetPeer() , top->GetPeer() ) ;
575 OffsetRect( &r , pt.x , pt.y ) ;
576 }
577
578 DrawThemeFocusRect( &r , true ) ;
579 }
580#endif
581}
582