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