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
,
52 // draw a (vertical) sash
53 virtual void DrawSplitterSash(wxWindow
*win
,
60 wxBitmap m_bmpTreeExpanded
,
64 // ----------------------------------------------------------------------------
66 // ----------------------------------------------------------------------------
69 static const char *aqua_arrow_right_xpm
[] = {
70 /* columns rows colors chars-per-pixel */
91 static const char *aqua_arrow_down_xpm
[] = {
92 /* columns rows colors chars-per-pixel */
112 // ============================================================================
114 // ============================================================================
117 wxRendererNative
& wxRendererMac::Get()
119 static wxRendererMac s_rendererMac
;
121 return s_rendererMac
;
125 wxRendererMac::DrawHeaderButton(wxWindow
*win
,
130 const int CORNER
= 1;
132 const wxCoord x
= rect
.x
,
137 dc
.SetBrush( *wxTRANSPARENT_BRUSH
);
139 dc
.SetPen( wxPen( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNSHADOW
) , 1 , wxSOLID
) );
140 dc
.DrawLine( x
+w
-CORNER
+1, y
, x
+w
, y
+h
); // right (outer)
141 dc
.DrawRectangle( x
, y
+h
, w
+1, 1 ); // bottom (outer)
143 wxPen
pen( wxColour( 0x88 , 0x88 , 0x88 ), 1, wxSOLID
);
146 dc
.DrawLine( x
+w
-CORNER
, y
, x
+w
-1, y
+h
); // right (inner)
147 dc
.DrawRectangle( x
+1, y
+h
-1, w
-2, 1 ); // bottom (inner)
149 dc
.SetPen( *wxWHITE_PEN
);
150 dc
.DrawRectangle( x
, y
, w
-CORNER
+1, 1 ); // top (outer)
151 dc
.DrawRectangle( x
, y
, 1, h
); // left (outer)
152 dc
.DrawLine( x
, y
+h
-1, x
+1, y
+h
-1 );
153 dc
.DrawLine( x
+w
-1, y
, x
+w
-1, y
+1 );
157 wxRendererMac::DrawTreeItemButton(wxWindow
*win
,
162 // init the buttons on demand
163 if ( !m_bmpTreeExpanded
.Ok() )
165 m_bmpTreeExpanded
= wxBitmap(aqua_arrow_down_xpm
);
166 m_bmpTreeCollapsed
= wxBitmap(aqua_arrow_right_xpm
);
171 // VZ: this is the old code from treectlg.cpp which apparently doesn't work
172 // but I kept it here just in case it is needed -- if not, please
174 #if 0 // def __WXMAC__
175 wxMacPortSetter
helper(&dc
) ;
176 wxMacWindowClipper
clipper(this) ;
177 wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ;
180 int loc_y
= y_mid
- 6 ;
181 MacWindowToRootWindow( & loc_x
, & loc_y
) ;
182 Rect bounds
= { loc_y
, loc_x
, loc_y
+ 18 , loc_x
+ 12 } ;
183 ThemeButtonDrawInfo info
= { kThemeStateActive
, item
->IsExpanded() ? kThemeDisclosureDown
: kThemeDisclosureRight
,
184 kThemeAdornmentNone
};
185 DrawThemeButton( &bounds
, kThemeDisclosureButton
,
186 &info
, NULL
, NULL
, NULL
, NULL
) ;
188 dc
.DrawBitmap(flags
& wxCONTROL_EXPANDED
? m_bmpTreeExpanded
189 : m_bmpTreeCollapsed
,
190 rect
.x
, rect
.y
, true /* use mask */);
195 wxRendererMac::DrawSash(wxWindow
*win
,
200 // VZ: we have to somehow determine if we're drawing a normal sash or
201 // a brushed metal one as they look quite differently... this is
202 // completely bogus anyhow, of course (TODO)
204 const wxCoord h
= size
.y
;
206 dc
.SetPen(*wxLIGHT_GREY_PEN
);
207 dc
.SetBrush(*wxWHITE_BRUSH
);
208 dc
.DrawRectangle(position
, 0, 7, h
);