]> git.saurik.com Git - wxWidgets.git/blob - src/osx/carbon/renderer.cpp
Update version to 2.9.4 in version.bkl too and rebake everything.
[wxWidgets.git] / src / osx / carbon / renderer.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/carbon/renderer.cpp
3 // Purpose: implementation of wxRendererNative for Mac
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>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // for compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #if wxOSX_USE_COCOA_OR_CARBON
16
17 #ifdef __BORLANDC__
18 #pragma hdrstop
19 #endif
20
21 #ifndef WX_PRECOMP
22 #include "wx/string.h"
23 #include "wx/dc.h"
24 #include "wx/bitmap.h"
25 #include "wx/settings.h"
26 #include "wx/dcclient.h"
27 #include "wx/dcmemory.h"
28 #include "wx/toplevel.h"
29 #endif
30
31 #include "wx/renderer.h"
32 #include "wx/graphics.h"
33 #include "wx/dcgraph.h"
34 #include "wx/osx/private.h"
35
36 #ifdef wxHAS_DRAW_TITLE_BAR_BITMAP
37 #include "wx/image.h"
38 #include "wx/mstream.h"
39 #endif // wxHAS_DRAW_TITLE_BAR_BITMAP
40
41
42 // check if we're having a CGContext we can draw into
43 inline bool wxHasCGContext(wxWindow* WXUNUSED(win), wxDC& dc)
44 {
45 wxGCDCImpl* gcdc = wxDynamicCast( dc.GetImpl() , wxGCDCImpl);
46
47 if ( gcdc )
48 {
49 if ( gcdc->GetGraphicsContext()->GetNativeContext() )
50 return true;
51 }
52 return false;
53 }
54
55
56
57 class WXDLLEXPORT wxRendererMac : public wxDelegateRendererNative
58 {
59 public:
60 // draw the header control button (used by wxListCtrl)
61 virtual int DrawHeaderButton( wxWindow *win,
62 wxDC& dc,
63 const wxRect& rect,
64 int flags = 0,
65 wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
66 wxHeaderButtonParams* params = NULL );
67
68 virtual int GetHeaderButtonHeight(wxWindow *win);
69
70 virtual int GetHeaderButtonMargin(wxWindow *win);
71
72 // draw the expanded/collapsed icon for a tree control item
73 virtual void DrawTreeItemButton( wxWindow *win,
74 wxDC& dc,
75 const wxRect& rect,
76 int flags = 0 );
77
78 // draw a (vertical) sash
79 virtual void DrawSplitterSash( wxWindow *win,
80 wxDC& dc,
81 const wxSize& size,
82 wxCoord position,
83 wxOrientation orient,
84 int flags = 0 );
85
86 virtual void DrawCheckBox(wxWindow *win,
87 wxDC& dc,
88 const wxRect& rect,
89 int flags = 0);
90
91 virtual wxSize GetCheckBoxSize(wxWindow* win);
92
93 virtual void DrawComboBoxDropButton(wxWindow *win,
94 wxDC& dc,
95 const wxRect& rect,
96 int flags = 0);
97
98 virtual void DrawPushButton(wxWindow *win,
99 wxDC& dc,
100 const wxRect& rect,
101 int flags = 0);
102
103 virtual void DrawItemSelectionRect(wxWindow *win,
104 wxDC& dc,
105 const wxRect& rect,
106 int flags = 0);
107
108 virtual void DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect, int flags = 0);
109
110 virtual void DrawChoice(wxWindow* win, wxDC& dc, const wxRect& rect, int flags=0);
111
112 virtual void DrawComboBox(wxWindow* win, wxDC& dc, const wxRect& rect, int flags=0);
113
114 virtual void DrawTextCtrl(wxWindow* win, wxDC& dc, const wxRect& rect, int flags=0);
115
116 virtual void DrawRadioBitmap(wxWindow* win, wxDC& dc, const wxRect& rect, int flags=0);
117
118 #ifdef wxHAS_DRAW_TITLE_BAR_BITMAP
119 virtual void DrawTitleBarBitmap(wxWindow *win,
120 wxDC& dc,
121 const wxRect& rect,
122 wxTitleBarButton button,
123 int flags = 0);
124 #endif // wxHAS_DRAW_TITLE_BAR_BITMAP
125
126 private:
127 void DrawMacThemeButton(wxWindow *win,
128 wxDC& dc,
129 const wxRect& rect,
130 int flags,
131 int kind,
132 int adornment);
133
134 // the tree buttons
135 wxBitmap m_bmpTreeExpanded;
136 wxBitmap m_bmpTreeCollapsed;
137 };
138
139 // ============================================================================
140 // implementation
141 // ============================================================================
142
143 // static
144 wxRendererNative& wxRendererNative::GetDefault()
145 {
146 static wxRendererMac s_rendererMac;
147
148 return s_rendererMac;
149 }
150
151 int wxRendererMac::DrawHeaderButton( wxWindow *win,
152 wxDC& dc,
153 const wxRect& rect,
154 int flags,
155 wxHeaderSortIconType sortArrow,
156 wxHeaderButtonParams* params )
157 {
158 const wxCoord x = rect.x;
159 const wxCoord y = rect.y;
160 const wxCoord w = rect.width;
161 const wxCoord h = rect.height;
162
163 dc.SetBrush( *wxTRANSPARENT_BRUSH );
164
165 HIRect headerRect = CGRectMake( x, y, w, h );
166 if ( !wxHasCGContext(win, dc) )
167 {
168 win->Refresh( &rect );
169 }
170 else
171 {
172 CGContextRef cgContext;
173 wxGCDCImpl *impl = (wxGCDCImpl*) dc.GetImpl();
174
175 cgContext = (CGContextRef) impl->GetGraphicsContext()->GetNativeContext();
176
177 {
178 HIThemeButtonDrawInfo drawInfo;
179 HIRect labelRect;
180
181 memset( &drawInfo, 0, sizeof(drawInfo) );
182 drawInfo.version = 0;
183 drawInfo.kind = kThemeListHeaderButton;
184 drawInfo.state = (flags & wxCONTROL_DISABLED) ? kThemeStateInactive : kThemeStateActive;
185 drawInfo.value = (flags & wxCONTROL_SELECTED) ? kThemeButtonOn : kThemeButtonOff;
186 drawInfo.adornment = kThemeAdornmentNone;
187
188 // The down arrow is drawn automatically, change it to an up arrow if needed.
189 if ( sortArrow == wxHDR_SORT_ICON_UP )
190 drawInfo.adornment = kThemeAdornmentHeaderButtonSortUp;
191
192 HIThemeDrawButton( &headerRect, &drawInfo, cgContext, kHIThemeOrientationNormal, &labelRect );
193
194 // If we don't want any arrows we need to draw over the one already there
195 if ( (flags & wxCONTROL_SELECTED) && (sortArrow == wxHDR_SORT_ICON_NONE) )
196 {
197 // clip to the header rectangle
198 CGContextSaveGState( cgContext );
199 CGContextClipToRect( cgContext, headerRect );
200 // but draw bigger than that so the arrow will get clipped off
201 headerRect.size.width += 25;
202 HIThemeDrawButton( &headerRect, &drawInfo, cgContext, kHIThemeOrientationNormal, &labelRect );
203 CGContextRestoreGState( cgContext );
204 }
205 }
206 }
207
208 // Reserve room for the arrows before writing the label, and turn off the
209 // flags we've already handled
210 wxRect newRect(rect);
211 if ( (flags & wxCONTROL_SELECTED) && (sortArrow != wxHDR_SORT_ICON_NONE) )
212 {
213 newRect.width -= 12;
214 sortArrow = wxHDR_SORT_ICON_NONE;
215 }
216 flags &= ~wxCONTROL_SELECTED;
217
218 return DrawHeaderButtonContents(win, dc, newRect, flags, sortArrow, params);
219 }
220
221
222 int wxRendererMac::GetHeaderButtonHeight(wxWindow* WXUNUSED(win))
223 {
224 SInt32 standardHeight;
225 OSStatus errStatus;
226
227 errStatus = GetThemeMetric( kThemeMetricListHeaderHeight, &standardHeight );
228 if (errStatus == noErr)
229 {
230 return standardHeight;
231 }
232 return -1;
233 }
234
235 int wxRendererMac::GetHeaderButtonMargin(wxWindow *WXUNUSED(win))
236 {
237 wxFAIL_MSG( "GetHeaderButtonMargin() not implemented" );
238 return -1;
239 }
240
241 void wxRendererMac::DrawTreeItemButton( wxWindow *win,
242 wxDC& dc,
243 const wxRect& rect,
244 int flags )
245 {
246 // now the wxGCDC is using native transformations
247 const wxCoord x = rect.x;
248 const wxCoord y = rect.y;
249 const wxCoord w = rect.width;
250 const wxCoord h = rect.height;
251
252 dc.SetBrush( *wxTRANSPARENT_BRUSH );
253
254 HIRect headerRect = CGRectMake( x, y, w, h );
255 if ( !wxHasCGContext(win, dc) )
256 {
257 win->Refresh( &rect );
258 }
259 else
260 {
261 CGContextRef cgContext;
262
263 wxGCDCImpl *impl = (wxGCDCImpl*) dc.GetImpl();
264 cgContext = (CGContextRef) impl->GetGraphicsContext()->GetNativeContext();
265
266 HIThemeButtonDrawInfo drawInfo;
267 HIRect labelRect;
268
269 memset( &drawInfo, 0, sizeof(drawInfo) );
270 drawInfo.version = 0;
271 drawInfo.kind = kThemeDisclosureButton;
272 drawInfo.state = (flags & wxCONTROL_DISABLED) ? kThemeStateInactive : kThemeStateActive;
273 // Apple mailing list posts say to use the arrow adornment constants, but those don't work.
274 // We need to set the value using the 'old' DrawThemeButton constants instead.
275 drawInfo.value = (flags & wxCONTROL_EXPANDED) ? kThemeDisclosureDown : kThemeDisclosureRight;
276 drawInfo.adornment = kThemeAdornmentNone;
277
278 HIThemeDrawButton( &headerRect, &drawInfo, cgContext, kHIThemeOrientationNormal, &labelRect );
279 }
280 }
281
282 void wxRendererMac::DrawSplitterSash( wxWindow *win,
283 wxDC& dc,
284 const wxSize& size,
285 wxCoord position,
286 wxOrientation orient,
287 int WXUNUSED(flags) )
288 {
289 bool hasMetal = win->MacGetTopLevelWindow()->GetExtraStyle() & wxFRAME_EX_METAL;
290 SInt32 height;
291 GetThemeMetric( kThemeMetricSmallPaneSplitterHeight, &height );
292 HIRect splitterRect;
293 if (orient == wxVERTICAL)
294 splitterRect = CGRectMake( position, 0, height, size.y );
295 else
296 splitterRect = CGRectMake( 0, position, size.x, height );
297
298 // under compositing we should only draw when called by the OS, otherwise just issue a redraw command
299 // strange redraw errors occur if we don't do this
300
301 if ( !wxHasCGContext(win, dc) )
302 {
303 wxRect rect( (int) splitterRect.origin.x, (int) splitterRect.origin.y, (int) splitterRect.size.width,
304 (int) splitterRect.size.height );
305 win->RefreshRect( rect );
306 }
307 else
308 {
309 CGContextRef cgContext;
310 wxGCDCImpl *impl = (wxGCDCImpl*) dc.GetImpl();
311 cgContext = (CGContextRef) impl->GetGraphicsContext()->GetNativeContext();
312
313 HIThemeBackgroundDrawInfo bgdrawInfo;
314 bgdrawInfo.version = 0;
315 bgdrawInfo.state = kThemeStateActive;
316 bgdrawInfo.kind = hasMetal ? kThemeBackgroundMetal : kThemeBackgroundPlacard;
317
318 if ( hasMetal )
319 HIThemeDrawBackground(&splitterRect, &bgdrawInfo, cgContext, kHIThemeOrientationNormal);
320 else
321 {
322 CGContextSetFillColorWithColor(cgContext,win->GetBackgroundColour().GetCGColor());
323 CGContextFillRect(cgContext,splitterRect);
324 }
325
326 HIThemeSplitterDrawInfo drawInfo;
327 drawInfo.version = 0;
328 drawInfo.state = kThemeStateActive;
329 drawInfo.adornment = hasMetal ? kHIThemeSplitterAdornmentMetal : kHIThemeSplitterAdornmentNone;
330 HIThemeDrawPaneSplitter( &splitterRect, &drawInfo, cgContext, kHIThemeOrientationNormal );
331 }
332 }
333
334 void
335 wxRendererMac::DrawItemSelectionRect(wxWindow * WXUNUSED(win),
336 wxDC& dc,
337 const wxRect& rect,
338 int flags)
339 {
340 if ( !(flags & wxCONTROL_SELECTED) )
341 return;
342
343 wxColour col( wxMacCreateCGColorFromHITheme( (flags & wxCONTROL_FOCUSED) ?
344 kThemeBrushAlternatePrimaryHighlightColor
345 : kThemeBrushSecondaryHighlightColor ) );
346 wxBrush selBrush( col );
347
348 dc.SetPen( *wxTRANSPARENT_PEN );
349 dc.SetBrush( selBrush );
350 dc.DrawRectangle( rect );
351 }
352
353
354 void
355 wxRendererMac::DrawMacThemeButton(wxWindow *win,
356 wxDC& dc,
357 const wxRect& rect,
358 int flags,
359 int kind,
360 int adornment)
361 {
362 // now the wxGCDC is using native transformations
363 const wxCoord x = rect.x;
364 const wxCoord y = rect.y;
365 const wxCoord w = rect.width;
366 const wxCoord h = rect.height;
367
368 dc.SetBrush( *wxTRANSPARENT_BRUSH );
369
370 HIRect headerRect = CGRectMake( x, y, w, h );
371 if ( !wxHasCGContext(win, dc) )
372 {
373 win->Refresh( &rect );
374 }
375 else
376 {
377 wxGCDCImpl *impl = (wxGCDCImpl*) dc.GetImpl();
378 CGContextRef cgContext;
379 cgContext = (CGContextRef) impl->GetGraphicsContext()->GetNativeContext();
380
381 HIThemeButtonDrawInfo drawInfo;
382 HIRect labelRect;
383
384 memset( &drawInfo, 0, sizeof(drawInfo) );
385 drawInfo.version = 0;
386 drawInfo.kind = kind;
387 drawInfo.state = (flags & wxCONTROL_DISABLED) ? kThemeStateInactive : kThemeStateActive;
388 drawInfo.value = (flags & wxCONTROL_SELECTED) ? kThemeButtonOn : kThemeButtonOff;
389 if (flags & wxCONTROL_UNDETERMINED)
390 drawInfo.value = kThemeButtonMixed;
391 drawInfo.adornment = adornment;
392 if (flags & wxCONTROL_FOCUSED)
393 drawInfo.adornment |= kThemeAdornmentFocus;
394
395 HIThemeDrawButton( &headerRect, &drawInfo, cgContext, kHIThemeOrientationNormal, &labelRect );
396 }
397 }
398
399 void
400 wxRendererMac::DrawCheckBox(wxWindow *win,
401 wxDC& dc,
402 const wxRect& rect,
403 int flags)
404 {
405 if (flags & wxCONTROL_CHECKED)
406 flags |= wxCONTROL_SELECTED;
407
408 int kind;
409
410 if (win->GetWindowVariant() == wxWINDOW_VARIANT_SMALL ||
411 (win->GetParent() && win->GetParent()->GetWindowVariant() == wxWINDOW_VARIANT_SMALL))
412 kind = kThemeCheckBoxSmall;
413 else if (win->GetWindowVariant() == wxWINDOW_VARIANT_MINI ||
414 (win->GetParent() && win->GetParent()->GetWindowVariant() == wxWINDOW_VARIANT_MINI))
415 kind = kThemeCheckBoxMini;
416 else
417 kind = kThemeCheckBox;
418
419
420 DrawMacThemeButton(win, dc, rect, flags,
421 kind, kThemeAdornmentNone);
422 }
423
424 wxSize wxRendererMac::GetCheckBoxSize(wxWindow* WXUNUSED(win))
425 {
426 wxSize size;
427 SInt32 width, height;
428 OSStatus errStatus;
429
430 errStatus = GetThemeMetric(kThemeMetricCheckBoxWidth, &width);
431 if (errStatus == noErr)
432 {
433 size.SetWidth(width);
434 }
435
436 errStatus = GetThemeMetric(kThemeMetricCheckBoxHeight, &height);
437 if (errStatus == noErr)
438 {
439 size.SetHeight(height);
440 }
441
442 return size;
443 }
444
445 void
446 wxRendererMac::DrawComboBoxDropButton(wxWindow *win,
447 wxDC& dc,
448 const wxRect& rect,
449 int flags)
450 {
451 int kind;
452 if (win->GetWindowVariant() == wxWINDOW_VARIANT_SMALL || (win->GetParent() && win->GetParent()->GetWindowVariant() == wxWINDOW_VARIANT_SMALL))
453 kind = kThemeArrowButtonSmall;
454 else if (win->GetWindowVariant() == wxWINDOW_VARIANT_MINI || (win->GetParent() && win->GetParent()->GetWindowVariant() == wxWINDOW_VARIANT_MINI))
455 kind = kThemeArrowButtonMini;
456 else
457 kind = kThemeArrowButton;
458
459 DrawMacThemeButton(win, dc, rect, flags,
460 kind, kThemeAdornmentArrowDownArrow);
461 }
462
463 void
464 wxRendererMac::DrawPushButton(wxWindow *win,
465 wxDC& dc,
466 const wxRect& rect,
467 int flags)
468 {
469 int kind;
470 if (win->GetWindowVariant() == wxWINDOW_VARIANT_SMALL || (win->GetParent() && win->GetParent()->GetWindowVariant() == wxWINDOW_VARIANT_SMALL))
471 kind = kThemeBevelButtonSmall;
472 // There is no kThemeBevelButtonMini, but in this case, use Small
473 else if (win->GetWindowVariant() == wxWINDOW_VARIANT_MINI || (win->GetParent() && win->GetParent()->GetWindowVariant() == wxWINDOW_VARIANT_MINI))
474 kind = kThemeBevelButtonSmall;
475 else
476 kind = kThemeBevelButton;
477
478 DrawMacThemeButton(win, dc, rect, flags,
479 kind, kThemeAdornmentNone);
480 }
481
482 void
483 wxRendererMac::DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect, int flags)
484 {
485 if (!win)
486 {
487 wxDelegateRendererNative::DrawFocusRect(win, dc, rect, flags);
488 return;
489 }
490
491 CGRect cgrect = CGRectMake( rect.x , rect.y , rect.width, rect.height ) ;
492
493 HIThemeFrameDrawInfo info ;
494
495 memset( &info, 0 , sizeof(info) ) ;
496
497 info.version = 0 ;
498 info.kind = 0 ;
499 info.state = kThemeStateActive;
500 info.isFocused = true ;
501
502 CGContextRef cgContext = (CGContextRef) win->MacGetCGContextRef() ;
503 wxASSERT( cgContext ) ;
504
505 HIThemeDrawFocusRect( &cgrect , true , cgContext , kHIThemeOrientationNormal ) ;
506 }
507
508 void wxRendererMac::DrawChoice(wxWindow* win, wxDC& dc,
509 const wxRect& rect, int flags)
510 {
511 int kind;
512
513 if (win->GetWindowVariant() == wxWINDOW_VARIANT_SMALL ||
514 (win->GetParent() && win->GetParent()->GetWindowVariant() == wxWINDOW_VARIANT_SMALL))
515 kind = kThemePopupButtonSmall;
516 else if (win->GetWindowVariant() == wxWINDOW_VARIANT_MINI ||
517 (win->GetParent() && win->GetParent()->GetWindowVariant() == wxWINDOW_VARIANT_MINI))
518 kind = kThemePopupButtonMini;
519 else
520 kind = kThemePopupButton;
521
522 DrawMacThemeButton(win, dc, rect, flags, kind, kThemeAdornmentNone);
523 }
524
525
526 void wxRendererMac::DrawComboBox(wxWindow* win, wxDC& dc,
527 const wxRect& rect, int flags)
528 {
529 int kind;
530
531 if (win->GetWindowVariant() == wxWINDOW_VARIANT_SMALL ||
532 (win->GetParent() && win->GetParent()->GetWindowVariant() == wxWINDOW_VARIANT_SMALL))
533 kind = kThemeComboBoxSmall;
534 else if (win->GetWindowVariant() == wxWINDOW_VARIANT_MINI ||
535 (win->GetParent() && win->GetParent()->GetWindowVariant() == wxWINDOW_VARIANT_MINI))
536 kind = kThemeComboBoxMini;
537 else
538 kind = kThemeComboBox;
539
540 DrawMacThemeButton(win, dc, rect, flags, kind, kThemeAdornmentNone);
541 }
542
543 void wxRendererMac::DrawRadioBitmap(wxWindow* win, wxDC& dc,
544 const wxRect& rect, int flags)
545 {
546 int kind;
547
548 if (win->GetWindowVariant() == wxWINDOW_VARIANT_SMALL ||
549 (win->GetParent() && win->GetParent()->GetWindowVariant() == wxWINDOW_VARIANT_SMALL))
550 kind = kThemeRadioButtonSmall;
551 else if (win->GetWindowVariant() == wxWINDOW_VARIANT_MINI ||
552 (win->GetParent() && win->GetParent()->GetWindowVariant() == wxWINDOW_VARIANT_MINI))
553 kind = kThemeRadioButtonMini;
554 else
555 kind = kThemeRadioButton;
556
557 if (flags & wxCONTROL_CHECKED)
558 flags |= wxCONTROL_SELECTED;
559
560 DrawMacThemeButton(win, dc, rect, flags,
561 kind, kThemeAdornmentNone);
562 }
563
564 void wxRendererMac::DrawTextCtrl(wxWindow* win, wxDC& dc,
565 const wxRect& rect, int flags)
566 {
567 const wxCoord x = rect.x;
568 const wxCoord y = rect.y;
569 const wxCoord w = rect.width;
570 const wxCoord h = rect.height;
571
572 dc.SetBrush( *wxWHITE_BRUSH );
573 dc.SetPen( *wxTRANSPARENT_PEN );
574 dc.DrawRectangle(rect);
575
576 dc.SetBrush( *wxTRANSPARENT_BRUSH );
577
578 HIRect hiRect = CGRectMake( x, y, w, h );
579 if ( !wxHasCGContext(win, dc) )
580 {
581 win->Refresh( &rect );
582 }
583 else
584 {
585 CGContextRef cgContext;
586
587 cgContext = (CGContextRef) static_cast<wxGCDCImpl*>(dc.GetImpl())->GetGraphicsContext()->GetNativeContext();
588
589 {
590 HIThemeFrameDrawInfo drawInfo;
591
592 memset( &drawInfo, 0, sizeof(drawInfo) );
593 drawInfo.version = 0;
594 drawInfo.kind = kHIThemeFrameTextFieldSquare;
595 drawInfo.state = (flags & wxCONTROL_DISABLED) ? kThemeStateInactive : kThemeStateActive;
596 if (flags & wxCONTROL_FOCUSED)
597 drawInfo.isFocused = true;
598
599 HIThemeDrawFrame( &hiRect, &drawInfo, cgContext, kHIThemeOrientationNormal);
600 }
601 }
602 }
603
604 #ifdef wxHAS_DRAW_TITLE_BAR_BITMAP
605
606 void wxRendererMac::DrawTitleBarBitmap(wxWindow *win,
607 wxDC& dc,
608 const wxRect& rect,
609 wxTitleBarButton button,
610 int flags)
611 {
612 // the files below were converted from the originals in art/osx/close*.png
613 // using misc/scripts/png2c.py script -- we must use PNG and not XPM for
614 // them because they use transparency and don't look right without it
615
616 /* close.png - 400 bytes */
617 static const unsigned char close_png[] = {
618 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
619 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
620 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0e,
621 0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0x48, 0x2d,
622 0xd1, 0x00, 0x00, 0x00, 0x06, 0x62, 0x4b, 0x47,
623 0x44, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xa0,
624 0xbd, 0xa7, 0x93, 0x00, 0x00, 0x00, 0x09, 0x70,
625 0x48, 0x59, 0x73, 0x00, 0x00, 0x0b, 0x12, 0x00,
626 0x00, 0x0b, 0x12, 0x01, 0xd2, 0xdd, 0x7e, 0xfc,
627 0x00, 0x00, 0x00, 0x09, 0x76, 0x70, 0x41, 0x67,
628 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0e,
629 0x00, 0xb1, 0x5b, 0xf1, 0xf7, 0x00, 0x00, 0x00,
630 0xef, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0xa5,
631 0xd2, 0x31, 0x4a, 0x03, 0x41, 0x18, 0xc5, 0xf1,
632 0xdf, 0xc6, 0x55, 0x02, 0xb2, 0x18, 0xb0, 0x33,
633 0x8d, 0xd8, 0x6e, 0x8a, 0x14, 0xa6, 0xb2, 0xc9,
634 0x21, 0x72, 0x0b, 0xdb, 0x5c, 0x45, 0x98, 0x3b,
635 0x24, 0xc7, 0x99, 0x6d, 0x2d, 0x04, 0xd3, 0x09,
636 0x42, 0x48, 0x65, 0x60, 0x6c, 0x76, 0x65, 0x1c,
637 0x14, 0x45, 0x5f, 0x35, 0xfc, 0xe7, 0x3d, 0xe6,
638 0x9b, 0x8f, 0x57, 0xf9, 0xac, 0x06, 0x97, 0x98,
639 0xe0, 0xbc, 0x67, 0x07, 0xbc, 0xe2, 0x05, 0xfb,
640 0xc1, 0x58, 0x65, 0xa1, 0x2b, 0x4c, 0xb3, 0x40,
641 0xa9, 0x03, 0x9e, 0xb1, 0x83, 0x93, 0x2c, 0x74,
642 0x83, 0xb1, 0xef, 0x75, 0x86, 0x0b, 0x1c, 0xb1,
643 0x1f, 0xf5, 0xe3, 0x4d, 0x51, 0x43, 0x08, 0xe1,
644 0xb6, 0x4c, 0x64, 0xac, 0xee, 0xbd, 0x0d, 0x5c,
645 0x63, 0x89, 0x65, 0x08, 0x61, 0x9d, 0x52, 0x4a,
646 0x31, 0xc6, 0xcd, 0xc0, 0x62, 0x8c, 0x9b, 0x94,
647 0x52, 0x0a, 0x21, 0xac, 0x07, 0xd6, 0x67, 0xcc,
648 0x33, 0xf0, 0x61, 0x8c, 0x31, 0x6e, 0xf2, 0x73,
649 0xee, 0xc1, 0xbc, 0xc2, 0x1d, 0x4e, 0xf3, 0xd1,
650 0x62, 0x8c, 0xf7, 0x6d, 0xdb, 0xae, 0xa0, 0xeb,
651 0xba, 0xed, 0x6c, 0x36, 0x7b, 0x28, 0xa6, 0x7f,
652 0x1b, 0xf9, 0xa3, 0xea, 0x7e, 0xcd, 0x93, 0xf2,
653 0xb5, 0xae, 0xeb, 0xb6, 0xd0, 0xb6, 0xed, 0x2a,
654 0xc6, 0xa8, 0x78, 0xf5, 0xf0, 0xaf, 0xe5, 0x34,
655 0x58, 0xe4, 0xe1, 0x62, 0x11, 0x25, 0x5b, 0xa0,
656 0x19, 0x9a, 0x33, 0x14, 0xa0, 0xfe, 0xe1, 0x6b,
657 0x47, 0x3c, 0x62, 0x37, 0x34, 0x67, 0xdf, 0xc3,
658 0x71, 0xdf, 0x90, 0xaf, 0x74, 0xc0, 0x93, 0xbe,
659 0x72, 0x55, 0x71, 0xf9, 0xeb, 0x92, 0xbf, 0x03,
660 0x70, 0x33, 0x76, 0x58, 0xe5, 0x41, 0xfb, 0x6d,
661 0x00, 0x00, 0x00, 0x20, 0x7a, 0x54, 0x58, 0x74,
662 0x74, 0x69, 0x66, 0x66, 0x3a, 0x72, 0x6f, 0x77,
663 0x73, 0x2d, 0x70, 0x65, 0x72, 0x2d, 0x73, 0x74,
664 0x72, 0x69, 0x70, 0x00, 0x00, 0x78, 0xda, 0x33,
665 0xb5, 0x30, 0x05, 0x00, 0x01, 0x47, 0x00, 0xa3,
666 0x38, 0xda, 0x77, 0x3b, 0x00, 0x00, 0x00, 0x00,
667 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
668 };
669
670 /* close_current.png - 421 bytes */
671 static const unsigned char close_current_png[] = {
672 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
673 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
674 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0e,
675 0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0x48, 0x2d,
676 0xd1, 0x00, 0x00, 0x00, 0x06, 0x62, 0x4b, 0x47,
677 0x44, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xa0,
678 0xbd, 0xa7, 0x93, 0x00, 0x00, 0x00, 0x09, 0x70,
679 0x48, 0x59, 0x73, 0x00, 0x00, 0x0b, 0x12, 0x00,
680 0x00, 0x0b, 0x12, 0x01, 0xd2, 0xdd, 0x7e, 0xfc,
681 0x00, 0x00, 0x00, 0x09, 0x76, 0x70, 0x41, 0x67,
682 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0e,
683 0x00, 0xb1, 0x5b, 0xf1, 0xf7, 0x00, 0x00, 0x01,
684 0x04, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0x9d,
685 0xd2, 0xbd, 0x4a, 0x43, 0x31, 0x00, 0xc5, 0xf1,
686 0xdf, 0x8d, 0x56, 0x44, 0x04, 0x45, 0xd0, 0xc5,
687 0x55, 0xdc, 0x0a, 0x8e, 0xed, 0xec, 0xe4, 0xec,
688 0x24, 0xd4, 0x67, 0x29, 0x59, 0xfa, 0x16, 0x9d,
689 0x7c, 0x07, 0x1d, 0x5c, 0xba, 0xa5, 0xa3, 0x28,
690 0x22, 0x94, 0xae, 0x2e, 0x1d, 0x4a, 0x5d, 0x55,
691 0xb8, 0x2e, 0x09, 0x5c, 0x4b, 0xfd, 0xa0, 0x67,
692 0x0a, 0x27, 0x39, 0xc9, 0x49, 0xf2, 0xaf, 0x7c,
693 0xd7, 0x01, 0x8e, 0x71, 0x84, 0xfd, 0xec, 0x2d,
694 0x30, 0xc3, 0x2b, 0xe6, 0x65, 0x61, 0xd5, 0x08,
695 0x9d, 0xe0, 0x14, 0x7b, 0x56, 0xeb, 0x0d, 0x13,
696 0x4c, 0x61, 0xa3, 0x11, 0x3a, 0xc3, 0x8e, 0x9f,
697 0xb5, 0x9d, 0x9b, 0xbc, 0x63, 0x1e, 0x72, 0xbd,
698 0x53, 0xb4, 0x20, 0xc6, 0xd8, 0x5e, 0x4e, 0x34,
699 0xbc, 0x56, 0x5e, 0x7b, 0x00, 0x6d, 0x5c, 0xe1,
700 0x2a, 0xc6, 0x38, 0xa8, 0xeb, 0xba, 0x4e, 0x29,
701 0xdd, 0x16, 0x2f, 0xa5, 0x74, 0x5b, 0xd7, 0x75,
702 0x1d, 0x63, 0x1c, 0x14, 0x0f, 0xed, 0x0a, 0xe7,
703 0xb9, 0x02, 0x48, 0x29, 0x5d, 0x77, 0x3a, 0x9d,
704 0x8b, 0xf1, 0x78, 0x7c, 0x07, 0x65, 0xdc, 0xed,
705 0x76, 0x6f, 0x1a, 0x25, 0x66, 0x15, 0x2e, 0xb1,
706 0xd5, 0xac, 0x56, 0xc2, 0xb0, 0x22, 0x04, 0xef,
707 0xc1, 0x9a, 0xda, 0xcc, 0xff, 0xf4, 0x6b, 0xd5,
708 0x94, 0x92, 0xa5, 0x53, 0x17, 0x6b, 0x3f, 0xce,
709 0x06, 0x3e, 0x71, 0x88, 0xed, 0xd1, 0x68, 0x34,
710 0x0b, 0x21, 0x4c, 0x7a, 0xbd, 0xde, 0x7d, 0xd9,
711 0x7a, 0x38, 0x1c, 0x3e, 0x86, 0x10, 0x26, 0xfd,
712 0x7e, 0xff, 0xa9, 0x01, 0xc2, 0x4b, 0x21, 0xa7,
713 0x00, 0xd0, 0xfa, 0xe3, 0x6a, 0x1f, 0x78, 0xc0,
714 0xb4, 0x90, 0x33, 0xcf, 0x44, 0xec, 0x66, 0x42,
715 0x56, 0xe9, 0x0d, 0xcf, 0x32, 0x72, 0xd5, 0xd2,
716 0xe4, 0xbf, 0x21, 0xff, 0x02, 0x4d, 0xb5, 0x74,
717 0x79, 0x60, 0x9f, 0x78, 0x78, 0x00, 0x00, 0x00,
718 0x20, 0x7a, 0x54, 0x58, 0x74, 0x74, 0x69, 0x66,
719 0x66, 0x3a, 0x72, 0x6f, 0x77, 0x73, 0x2d, 0x70,
720 0x65, 0x72, 0x2d, 0x73, 0x74, 0x72, 0x69, 0x70,
721 0x00, 0x00, 0x78, 0xda, 0x33, 0xb5, 0x30, 0x05,
722 0x00, 0x01, 0x47, 0x00, 0xa3, 0x38, 0xda, 0x77,
723 0x3b, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e,
724 0x44, 0xae, 0x42, 0x60, 0x82};
725
726 /* close_pressed.png - 458 bytes */
727 static const unsigned char close_pressed_png[] = {
728 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
729 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
730 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0e,
731 0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0x48, 0x2d,
732 0xd1, 0x00, 0x00, 0x00, 0x06, 0x62, 0x4b, 0x47,
733 0x44, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xa0,
734 0xbd, 0xa7, 0x93, 0x00, 0x00, 0x00, 0x09, 0x70,
735 0x48, 0x59, 0x73, 0x00, 0x00, 0x0b, 0x12, 0x00,
736 0x00, 0x0b, 0x12, 0x01, 0xd2, 0xdd, 0x7e, 0xfc,
737 0x00, 0x00, 0x00, 0x09, 0x76, 0x70, 0x41, 0x67,
738 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0e,
739 0x00, 0xb1, 0x5b, 0xf1, 0xf7, 0x00, 0x00, 0x01,
740 0x29, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0x9d,
741 0x92, 0x31, 0x6a, 0xc3, 0x40, 0x14, 0x44, 0x9f,
742 0x2c, 0xe1, 0xc2, 0x10, 0x08, 0xc4, 0xe0, 0x22,
743 0x76, 0x21, 0x04, 0x29, 0x13, 0xf0, 0x05, 0x54,
744 0xa5, 0x8a, 0x0f, 0xb2, 0x8d, 0x0e, 0xa0, 0x23,
745 0xa8, 0x56, 0xa3, 0x03, 0xe8, 0x08, 0xba, 0x80,
746 0xba, 0xb0, 0x45, 0x0a, 0x97, 0x02, 0x23, 0x58,
747 0x83, 0x40, 0x60, 0x61, 0x08, 0x11, 0x04, 0x57,
748 0x69, 0xf6, 0xc3, 0x46, 0x38, 0x24, 0x64, 0xca,
749 0xd9, 0x19, 0xe6, 0xff, 0xfd, 0xe3, 0xf1, 0x1d,
750 0x2b, 0x20, 0x02, 0x36, 0xc0, 0xd2, 0x72, 0x27,
751 0xe0, 0x08, 0x1c, 0x80, 0x5e, 0x84, 0x9e, 0x63,
752 0x7a, 0x04, 0xb6, 0xc0, 0x1d, 0xd7, 0x31, 0x00,
753 0x6f, 0xc0, 0x1e, 0xc0, 0x77, 0x4c, 0x31, 0x70,
754 0xc3, 0xcf, 0x58, 0xd8, 0x49, 0x3e, 0x81, 0x7e,
755 0x66, 0xc7, 0xdb, 0x02, 0x73, 0x80, 0xdd, 0x6e,
756 0xb7, 0x9a, 0x3a, 0x1c, 0x6e, 0x6e, 0xb5, 0x2b,
757 0x1f, 0x78, 0x02, 0x1e, 0x44, 0x90, 0x65, 0xd9,
758 0x8b, 0xef, 0xfb, 0xef, 0x5a, 0xeb, 0x33, 0x40,
759 0x92, 0x24, 0x51, 0x9a, 0xa6, 0xcf, 0xc6, 0x98,
760 0xae, 0x69, 0x9a, 0xd1, 0x26, 0x8f, 0x81, 0x8d,
761 0x07, 0xa0, 0xaa, 0xaa, 0x3e, 0x0c, 0xc3, 0x5a,
762 0x29, 0x15, 0x0b, 0xa7, 0x94, 0x8a, 0x8b, 0xa2,
763 0xa8, 0xab, 0xaa, 0xea, 0x9d, 0x21, 0x36, 0x81,
764 0xf3, 0x7b, 0x00, 0xe4, 0x79, 0x7e, 0x10, 0x03,
765 0x40, 0x51, 0x14, 0xb5, 0x70, 0x0e, 0x96, 0x33,
766 0xfe, 0x89, 0xc0, 0xde, 0x69, 0x2d, 0x44, 0x92,
767 0x24, 0x91, 0x8c, 0xe7, 0x26, 0x4f, 0x52, 0x4f,
768 0x81, 0x3d, 0xee, 0x5a, 0x3e, 0x47, 0x4c, 0xae,
769 0x50, 0x29, 0x15, 0xb7, 0x6d, 0xfb, 0xe1, 0xec,
770 0x79, 0xf4, 0x81, 0x0b, 0x70, 0x0f, 0x2c, 0x9a,
771 0xa6, 0x19, 0x8d, 0x31, 0x5d, 0x59, 0x96, 0x47,
772 0x31, 0x69, 0xad, 0xcf, 0xc6, 0x98, 0xce, 0x31,
773 0x0d, 0x80, 0x96, 0xe6, 0x48, 0x01, 0xe6, 0xbf,
774 0xac, 0x76, 0x01, 0x6a, 0x60, 0x2f, 0xcd, 0xe9,
775 0x6d, 0x23, 0x6e, 0xed, 0x9d, 0xae, 0x61, 0x00,
776 0x5e, 0xb1, 0x95, 0xf3, 0x26, 0x8f, 0x7f, 0x2e,
777 0xf9, 0x17, 0x50, 0x59, 0x74, 0x13, 0x34, 0x41,
778 0x04, 0x5a, 0x00, 0x00, 0x00, 0x20, 0x7a, 0x54,
779 0x58, 0x74, 0x74, 0x69, 0x66, 0x66, 0x3a, 0x72,
780 0x6f, 0x77, 0x73, 0x2d, 0x70, 0x65, 0x72, 0x2d,
781 0x73, 0x74, 0x72, 0x69, 0x70, 0x00, 0x00, 0x78,
782 0xda, 0x33, 0xb5, 0x30, 0x05, 0x00, 0x01, 0x47,
783 0x00, 0xa3, 0x38, 0xda, 0x77, 0x3b, 0x00, 0x00,
784 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42,
785 0x60, 0x82};
786
787 // currently we only support the close bitmap here
788 if ( button != wxTITLEBAR_BUTTON_CLOSE )
789 {
790 m_rendererNative.DrawTitleBarBitmap(win, dc, rect, button, flags);
791 return;
792 }
793
794 // choose the correct image depending on flags
795 const void *data;
796 size_t len;
797
798 if ( flags & wxCONTROL_PRESSED )
799 {
800 data = close_pressed_png;
801 len = WXSIZEOF(close_pressed_png);
802 }
803 else if ( flags & wxCONTROL_CURRENT )
804 {
805 data = close_current_png;
806 len = WXSIZEOF(close_current_png);
807 }
808 else
809 {
810 data = close_png;
811 len = WXSIZEOF(close_png);
812 }
813
814 // load it
815 wxMemoryInputStream mis(data, len);
816 wxImage image(mis, wxBITMAP_TYPE_PNG);
817 wxBitmap bmp(image);
818 wxASSERT_MSG( bmp.IsOk(), "failed to load embedded PNG image?" );
819
820 // and draw it centering it in the provided rectangle: we don't scale the
821 // image because this is really not going to look good for such a small
822 // (14*14) bitmap
823 dc.DrawBitmap(bmp, wxRect(bmp.GetSize()).CenterIn(rect).GetPosition());
824 }
825
826 #endif // wxHAS_DRAW_TITLE_BAR_BITMAP
827
828 #endif