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