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