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" 
  30     #include "wx/bitmap.h" 
  31     #include "wx/settings.h" 
  34 #include "wx/renderer.h" 
  36 // ---------------------------------------------------------------------------- 
  37 // wxRendererMac: our wxRendererNative implementation 
  38 // ---------------------------------------------------------------------------- 
  40 class WXDLLEXPORT wxRendererMac 
: public wxDelegateRendererNative
 
  43     // draw the header control button (used by wxListCtrl) 
  44     virtual void DrawHeaderButton(wxWindow 
*win
, 
  49     // draw the expanded/collapsed icon for a tree control item 
  50     virtual void DrawTreeItemButton(wxWindow 
*win
, 
  55     // draw a (vertical) sash 
  56     virtual void DrawSplitterSash(wxWindow 
*win
, 
  65     wxBitmap m_bmpTreeExpanded
, 
  69 // ---------------------------------------------------------------------------- 
  71 // ---------------------------------------------------------------------------- 
  74 static const char *aqua_arrow_right_xpm
[] = { 
  75 /* columns rows colors chars-per-pixel */ 
  96 static const char *aqua_arrow_down_xpm
[] = { 
  97 /* columns rows colors chars-per-pixel */ 
 117 // ============================================================================ 
 119 // ============================================================================ 
 122 wxRendererNative
& wxRendererNative::GetDefault() 
 124     static wxRendererMac s_rendererMac
; 
 126     return s_rendererMac
; 
 130 wxRendererMac::DrawHeaderButton(wxWindow 
*win
, 
 135     const int CORNER 
= 1; 
 137     const wxCoord x 
= rect
.x
, 
 142     dc
.SetBrush( *wxTRANSPARENT_BRUSH 
); 
 144     dc
.SetPen( wxPen( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNSHADOW 
) , 1 , wxSOLID 
) ); 
 145     dc
.DrawLine( x
+w
-CORNER
+1, y
, x
+w
, y
+h 
);       // right (outer) 
 146     dc
.DrawRectangle( x
, y
+h
, w
+1, 1 );             // bottom (outer) 
 148     wxPen 
pen( wxColour( 0x88 , 0x88 , 0x88 ), 1, wxSOLID 
); 
 151     dc
.DrawLine( x
+w
-CORNER
, y
, x
+w
-1, y
+h 
);       // right (inner) 
 152     dc
.DrawRectangle( x
+1, y
+h
-1, w
-2, 1 );         // bottom (inner) 
 154     dc
.SetPen( *wxWHITE_PEN 
); 
 155     dc
.DrawRectangle( x
, y
, w
-CORNER
+1, 1 );        // top (outer) 
 156     dc
.DrawRectangle( x
, y
, 1, h 
);                 // left (outer) 
 157     dc
.DrawLine( x
, y
+h
-1, x
+1, y
+h
-1 ); 
 158     dc
.DrawLine( x
+w
-1, y
, x
+w
-1, y
+1 ); 
 162 wxRendererMac::DrawTreeItemButton(wxWindow 
*win
, 
 167     // init the buttons on demand 
 168     if ( !m_bmpTreeExpanded
.Ok() ) 
 170         m_bmpTreeExpanded 
= wxBitmap(aqua_arrow_down_xpm
); 
 171         m_bmpTreeCollapsed 
= wxBitmap(aqua_arrow_right_xpm
); 
 176     // VZ: this is the old code from treectlg.cpp which apparently doesn't work 
 177     //     but I kept it here just in case it is needed -- if not, please 
 179 #if 0 // def __WXMAC__ 
 180     wxMacPortSetter 
helper(&dc
) ; 
 181     wxMacWindowClipper 
clipper(this) ; 
 182     wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ; 
 185     int loc_y 
= y_mid 
- 6 ; 
 186     MacWindowToRootWindow( & loc_x 
, & loc_y 
) ; 
 187     Rect bounds 
= { loc_y 
, loc_x 
, loc_y 
+ 18 , loc_x 
+ 12 } ; 
 188     ThemeButtonDrawInfo info 
= { kThemeStateActive 
, item
->IsExpanded() ? kThemeDisclosureDown 
: kThemeDisclosureRight 
, 
 189         kThemeAdornmentNone 
};  
 190     DrawThemeButton( &bounds
, kThemeDisclosureButton 
,  
 191         &info 
, NULL 
, NULL 
, NULL 
, NULL 
) ; 
 193     dc
.DrawBitmap(flags 
& wxCONTROL_EXPANDED 
? m_bmpTreeExpanded
 
 194                                              : m_bmpTreeCollapsed
, 
 195                   rect
.x
, rect
.y
, true /* use mask */); 
 200 wxRendererMac::DrawSplitterSash(wxWindow 
*win
, 
 204                                 wxOrientation orient
, 
 207     // VZ: we have to somehow determine if we're drawing a normal sash or 
 208     //     a brushed metal one as they look quite differently... this is 
 209     //     completely bogus anyhow, of course (TODO) 
 211     dc
.SetPen(*wxLIGHT_GREY_PEN
); 
 212     dc
.SetBrush(*wxWHITE_BRUSH
); 
 213     if ( orient 
== wxVERTICAL 
) 
 214         dc
.DrawRectangle(position
, 0, 7, size
.y
); 
 216         dc
.DrawRectangle(0, position
, size
.x
, 7);