// Created: 20.07.2003
// RCS-ID: $Id$
// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
-// License: wxWindows licence
+// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// for compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
+#if wxOSX_USE_COCOA_OR_CARBON
+
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/bitmap.h"
#include "wx/settings.h"
#include "wx/dcclient.h"
+ #include "wx/dcmemory.h"
#include "wx/toplevel.h"
#endif
#include "wx/dcgraph.h"
#include "wx/osx/private.h"
-#if wxOSX_USE_COCOA
-// bring in the theme headers
-#include <Carbon/Carbon.h>
-#endif
+#ifdef wxHAS_DRAW_TITLE_BAR_BITMAP
+ #include "wx/image.h"
+ #include "wx/mstream.h"
+#endif // wxHAS_DRAW_TITLE_BAR_BITMAP
+
// check if we're currently in a paint event
inline bool wxInPaintEvent(wxWindow* win, wxDC& dc)
{
- return ( win->MacGetCGContextRef() != NULL );
+ return win->MacGetCGContextRef() != NULL ||
+ // wxMemoryDC's also have a valid CGContext.
+ dc.IsKindOf( CLASSINFO(wxMemoryDC) );
}
virtual int GetHeaderButtonHeight(wxWindow *win);
+ virtual int GetHeaderButtonMargin(wxWindow *win);
+
// draw the expanded/collapsed icon for a tree control item
virtual void DrawTreeItemButton( wxWindow *win,
wxDC& dc,
virtual void DrawTextCtrl(wxWindow* win, wxDC& dc, const wxRect& rect, int flags=0);
- virtual void DrawRadioButton(wxWindow* win, wxDC& dc, const wxRect& rect, int flags=0);
+ virtual void DrawRadioBitmap(wxWindow* win, wxDC& dc, const wxRect& rect, int flags=0);
+
+#ifdef wxHAS_DRAW_TITLE_BAR_BITMAP
+ virtual void DrawTitleBarBitmap(wxWindow *win,
+ wxDC& dc,
+ const wxRect& rect,
+ wxTitleBarButton button,
+ int flags = 0);
+#endif // wxHAS_DRAW_TITLE_BAR_BITMAP
private:
void DrawMacThemeButton(wxWindow *win,
return -1;
}
+int wxRendererMac::GetHeaderButtonMargin(wxWindow *WXUNUSED(win))
+{
+ wxFAIL_MSG( "GetHeaderButtonMargin() not implemented" );
+ return -1;
+}
+
void wxRendererMac::DrawTreeItemButton( wxWindow *win,
wxDC& dc,
const wxRect& rect,
{
wxRect rect( (int) splitterRect.origin.x, (int) splitterRect.origin.y, (int) splitterRect.size.width,
(int) splitterRect.size.height );
- win->Refresh( &rect );
- }
+ win->RefreshRect( rect );
+ }
else
{
CGContextRef cgContext;
wxGCDCImpl *impl = (wxGCDCImpl*) dc.GetImpl();
cgContext = (CGContextRef) impl->GetGraphicsContext()->GetNativeContext();
+ HIThemeBackgroundDrawInfo bgdrawInfo;
+ bgdrawInfo.version = 0;
+ bgdrawInfo.state = kThemeStateActive;
+ bgdrawInfo.kind = hasMetal ? kThemeBackgroundMetal : kThemeBackgroundPlacard;
+
+ if ( hasMetal )
+ HIThemeDrawBackground(&splitterRect, &bgdrawInfo, cgContext, kHIThemeOrientationNormal);
+ else
+ {
+ CGContextSetFillColorWithColor(cgContext,win->GetBackgroundColour().GetCGColor());
+ CGContextFillRect(cgContext,splitterRect);
+ }
+
HIThemeSplitterDrawInfo drawInfo;
drawInfo.version = 0;
drawInfo.state = kThemeStateActive;
DrawMacThemeButton(win, dc, rect, flags, kind, kThemeAdornmentNone);
}
-void wxRendererMac::DrawRadioButton(wxWindow* win, wxDC& dc,
+void wxRendererMac::DrawRadioBitmap(wxWindow* win, wxDC& dc,
const wxRect& rect, int flags)
{
int kind;
}
}
+#ifdef wxHAS_DRAW_TITLE_BAR_BITMAP
+
+void wxRendererMac::DrawTitleBarBitmap(wxWindow *win,
+ wxDC& dc,
+ const wxRect& rect,
+ wxTitleBarButton button,
+ int flags)
+{
+ // the files below were converted from the originals in art/osx/close*.png
+ // using misc/scripts/png2c.py script -- we must use PNG and not XPM for
+ // them because they use transparency and don't look right without it
+
+ /* close.png - 400 bytes */
+ static const unsigned char close_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a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 0x72, 0x6f, 0x77,
+ 0x73, 0x2d, 0x70, 0x65, 0x72, 0x2d, 0x73, 0x74,
+ 0x72, 0x69, 0x70, 0x00, 0x00, 0x78, 0xda, 0x33,
+ 0xb5, 0x30, 0x05, 0x00, 0x01, 0x47, 0x00, 0xa3,
+ 0x38, 0xda, 0x77, 0x3b, 0x00, 0x00, 0x00, 0x00,
+ 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
+ };
+
+ /* close_current.png - 421 bytes */
+ static const unsigned char close_current_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
+ 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
+ 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0e,
+ 0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0x48, 0x2d,
+ 0xd1, 0x00, 0x00, 0x00, 0x06, 0x62, 0x4b, 0x47,
+ 0x44, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xa0,
+ 0xbd, 0xa7, 0x93, 0x00, 0x00, 0x00, 0x09, 0x70,
+ 0x48, 0x59, 0x73, 0x00, 0x00, 0x0b, 0x12, 0x00,
+ 0x00, 0x0b, 0x12, 0x01, 0xd2, 0xdd, 0x7e, 0xfc,
+ 0x00, 0x00, 0x00, 0x09, 0x76, 0x70, 0x41, 0x67,
+ 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0e,
+ 0x00, 0xb1, 0x5b, 0xf1, 0xf7, 0x00, 0x00, 0x01,
+ 0x04, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0x9d,
+ 0xd2, 0xbd, 0x4a, 0x43, 0x31, 0x00, 0xc5, 0xf1,
+ 0xdf, 0x8d, 0x56, 0x44, 0x04, 0x45, 0xd0, 0xc5,
+ 0x55, 0xdc, 0x0a, 0x8e, 0xed, 0xec, 0xe4, 0xec,
+ 0x24, 0xd4, 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68, 0x34,
+ 0x0b, 0x21, 0x4c, 0x7a, 0xbd, 0xde, 0x7d, 0xd9,
+ 0x7a, 0x38, 0x1c, 0x3e, 0x86, 0x10, 0x26, 0xfd,
+ 0x7e, 0xff, 0xa9, 0x01, 0xc2, 0x4b, 0x21, 0xa7,
+ 0x00, 0xd0, 0xfa, 0xe3, 0x6a, 0x1f, 0x78, 0xc0,
+ 0xb4, 0x90, 0x33, 0xcf, 0x44, 0xec, 0x66, 0x42,
+ 0x56, 0xe9, 0x0d, 0xcf, 0x32, 0x72, 0xd5, 0xd2,
+ 0xe4, 0xbf, 0x21, 0xff, 0x02, 0x4d, 0xb5, 0x74,
+ 0x79, 0x60, 0x9f, 0x78, 0x78, 0x00, 0x00, 0x00,
+ 0x20, 0x7a, 0x54, 0x58, 0x74, 0x74, 0x69, 0x66,
+ 0x66, 0x3a, 0x72, 0x6f, 0x77, 0x73, 0x2d, 0x70,
+ 0x65, 0x72, 0x2d, 0x73, 0x74, 0x72, 0x69, 0x70,
+ 0x00, 0x00, 0x78, 0xda, 0x33, 0xb5, 0x30, 0x05,
+ 0x00, 0x01, 0x47, 0x00, 0xa3, 0x38, 0xda, 0x77,
+ 0x3b, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e,
+ 0x44, 0xae, 0x42, 0x60, 0x82};
+
+ /* close_pressed.png - 458 bytes */
+ static const unsigned char close_pressed_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
+ 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
+ 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0e,
+ 0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0x48, 0x2d,
+ 0xd1, 0x00, 0x00, 0x00, 0x06, 0x62, 0x4b, 0x47,
+ 0x44, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xa0,
+ 0xbd, 0xa7, 0x93, 0x00, 0x00, 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 0x20, 0x7a, 0x54,
+ 0x58, 0x74, 0x74, 0x69, 0x66, 0x66, 0x3a, 0x72,
+ 0x6f, 0x77, 0x73, 0x2d, 0x70, 0x65, 0x72, 0x2d,
+ 0x73, 0x74, 0x72, 0x69, 0x70, 0x00, 0x00, 0x78,
+ 0xda, 0x33, 0xb5, 0x30, 0x05, 0x00, 0x01, 0x47,
+ 0x00, 0xa3, 0x38, 0xda, 0x77, 0x3b, 0x00, 0x00,
+ 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42,
+ 0x60, 0x82};
+
+ // currently we only support the close bitmap here
+ if ( button != wxTITLEBAR_BUTTON_CLOSE )
+ {
+ m_rendererNative.DrawTitleBarBitmap(win, dc, rect, button, flags);
+ return;
+ }
+
+ // choose the correct image depending on flags
+ const void *data;
+ size_t len;
+
+ if ( flags & wxCONTROL_PRESSED )
+ {
+ data = close_pressed_png;
+ len = WXSIZEOF(close_pressed_png);
+ }
+ else if ( flags & wxCONTROL_CURRENT )
+ {
+ data = close_current_png;
+ len = WXSIZEOF(close_current_png);
+ }
+ else
+ {
+ data = close_png;
+ len = WXSIZEOF(close_png);
+ }
+
+ // load it
+ wxMemoryInputStream mis(data, len);
+ wxImage image(mis, wxBITMAP_TYPE_PNG);
+ wxBitmap bmp(image);
+ wxASSERT_MSG( bmp.IsOk(), "failed to load embedded PNG image?" );
+
+ // and draw it centering it in the provided rectangle: we don't scale the
+ // image because this is really not going to look good for such a small
+ // (14*14) bitmap
+ dc.DrawBitmap(bmp, wxRect(bmp.GetSize()).CenterIn(rect).GetPosition());
+}
+
+#endif // wxHAS_DRAW_TITLE_BAR_BITMAP
+
+#endif