1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: mac/renderer.cpp
3 // Purpose: implementation of wxRendererNative for Mac
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
9 // License: wxWindows license
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // for compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
28 #include "wx/string.h"
31 #include "wx/renderer.h"
33 // ----------------------------------------------------------------------------
34 // wxRendererMac: our wxRendererNative implementation
35 // ----------------------------------------------------------------------------
37 class WXDLLEXPORT wxRendererMac
: public wxRendererNative
40 // draw the header control button (used by wxListCtrl)
41 virtual void DrawHeaderButton(wxWindow
*win
,
46 // draw the expanded/collapsed icon for a tree control item
47 virtual void DrawTreeItemButton(wxWindow
*win
,
54 wxBitmap m_bmpTreeExpanded
,
58 // ----------------------------------------------------------------------------
60 // ----------------------------------------------------------------------------
63 static const char *aqua_arrow_right_xpm
[] = {
64 /* columns rows colors chars-per-pixel */
85 static const char *aqua_arrow_down_xpm
[] = {
86 /* columns rows colors chars-per-pixel */
106 // ============================================================================
108 // ============================================================================
111 wxRendererNative
& wxRendererMac::Get()
113 static wxRendererMac s_rendererMac
;
115 return s_rendererMac
;
119 wxRendererMac::DrawHeaderButton(wxWindow
*win
,
124 const int CORNER
= 1;
126 const wxCoord x
= rect
.x
,
131 dc
.SetBrush( *wxTRANSPARENT_BRUSH
);
133 dc
.SetPen( wxPen( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNSHADOW
) , 1 , wxSOLID
) );
134 dc
.DrawLine( x
+w
-CORNER
+1, y
, x
+w
, y
+h
); // right (outer)
135 dc
.DrawRectangle( x
, y
+h
, w
+1, 1 ); // bottom (outer)
137 wxPen
pen( wxColour( 0x88 , 0x88 , 0x88 ), 1, wxSOLID
);
140 dc
.DrawLine( x
+w
-CORNER
, y
, x
+w
-1, y
+h
); // right (inner)
141 dc
.DrawRectangle( x
+1, y
+h
-1, w
-2, 1 ); // bottom (inner)
143 dc
.SetPen( *wxWHITE_PEN
);
144 dc
.DrawRectangle( x
, y
, w
-CORNER
+1, 1 ); // top (outer)
145 dc
.DrawRectangle( x
, y
, 1, h
); // left (outer)
146 dc
.DrawLine( x
, y
+h
-1, x
+1, y
+h
-1 );
147 dc
.DrawLine( x
+w
-1, y
, x
+w
-1, y
+1 );
151 wxRendererMac::DrawTreeItemButton(wxWindow
*win
,
156 // init the buttons on demand
157 if ( !m_bmpTreeExpanded
.Ok() )
159 m_bmpTreeExpanded
= wxBitmap(aqua_arrow_down_xpm
);
160 m_bmpTreeCollapsed
= wxBitmap(aqua_arrow_right_xpm
);
165 // VZ: this is the old code from treectlg.cpp which apparently doesn't work
166 // but I kept it here just in case it is needed -- if not, please
168 #if 0 // def __WXMAC__
169 wxMacPortSetter
helper(&dc
) ;
170 wxMacWindowClipper
clipper(this) ;
171 wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ;
174 int loc_y
= y_mid
- 6 ;
175 MacWindowToRootWindow( & loc_x
, & loc_y
) ;
176 Rect bounds
= { loc_y
, loc_x
, loc_y
+ 18 , loc_x
+ 12 } ;
177 ThemeButtonDrawInfo info
= { kThemeStateActive
, item
->IsExpanded() ? kThemeDisclosureDown
: kThemeDisclosureRight
,
178 kThemeAdornmentNone
};
179 DrawThemeButton( &bounds
, kThemeDisclosureButton
,
180 &info
, NULL
, NULL
, NULL
, NULL
) ;
182 dc
.DrawBitmap(flags
& wxCONTROL_EXPANDED
? m_bmpTreeExpanded
183 : m_bmpTreeCollapsed
,
184 rect
.x
, rect
.y
, true /* use mask */);