1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: generic/renderg.cpp
3 // Purpose: generic implementation of wxRendererBase (for any platform)
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 // wxRendererGeneric: our wxRendererBase implementation
35 // ----------------------------------------------------------------------------
37 class WXDLLEXPORT wxRendererGeneric
: public wxRendererBase
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
,
53 // ============================================================================
55 // ============================================================================
57 // ----------------------------------------------------------------------------
58 // wxRendererGeneric creation
59 // ----------------------------------------------------------------------------
62 wxRendererNative
*wxRendererGeneric::GetGeneric()
64 static wxRendererGeneric s_rendererGeneric
;
66 return s_rendererGeneric
;
69 // some platforms have their own renderers
70 #if !defined(__WXMSW__) && !defined(__WXMAC__) && !defined(__WXGTK__)
73 wxRendererNative
& wxRendererGeneric::Get()
78 #endif // platforms using their own renderers
80 // ----------------------------------------------------------------------------
81 // wxRendererGeneric drawing functions
82 // ----------------------------------------------------------------------------
85 wxRendererGeneric::DrawHeaderButton(wxWindow
*win
,
90 const int m_corner
= 1;
92 dc
->SetBrush( *wxTRANSPARENT_BRUSH
);
94 dc
->SetPen( *wxBLACK_PEN
);
95 dc
->DrawLine( x
+w
-m_corner
+1, y
, x
+w
, y
+h
); // right (outer)
96 dc
->DrawRectangle( x
, y
+h
, w
+1, 1 ); // bottom (outer)
98 wxPen
pen( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNSHADOW
), 1, wxSOLID
);
101 dc
->DrawLine( x
+w
-m_corner
, y
, x
+w
-1, y
+h
); // right (inner)
102 dc
->DrawRectangle( x
+1, y
+h
-1, w
-2, 1 ); // bottom (inner)
104 dc
->SetPen( *wxWHITE_PEN
);
105 dc
->DrawRectangle( x
, y
, w
-m_corner
+1, 1 ); // top (outer)
106 dc
->DrawRectangle( x
, y
, 1, h
); // left (outer)
107 dc
->DrawLine( x
, y
+h
-1, x
+1, y
+h
-1 );
108 dc
->DrawLine( x
+w
-1, y
, x
+w
-1, y
+1 );
111 // draw the plus or minus sign
113 wxRendererGeneric::DrawTreeItemButton(wxWindow
*win
,
119 dc
.SetPen(*wxGREY_PEN
);
120 dc
.SetBrush(*wxWHITE_BRUSH
);
121 dc
.DrawRectangle(rect
.Deflate(1, 2));
124 const wxCoord xMiddle
= rect
.x
+ rect
.width
/2;
125 const wxCoord yMiddle
= rect
.y
+ rect
.height
/2;
127 dc
.SetPen(*wxBLACK_PEN
);
128 dc
.DrawLine(xMiddle
- 2, yMiddle
, xMiddle
+ 3, yMiddle
);
129 if ( !item
->IsExpanded() )
132 dc
.DrawLine(xMiddle
, yMiddle
- 2, xMiddle
, yMiddle
+ 3);