more compilation fixes
[wxWidgets.git] / src / generic / renderg.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: generic/renderg.cpp
3 // Purpose: generic implementation of wxRendererNative (for any platform)
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 20.07.2003
7 // RCS-ID: $Id$
8 // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
9 // License: wxWindows license
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 // for compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 #ifndef WX_PRECOMP
28 #include "wx/string.h"
29 #endif //WX_PRECOMP
30
31 #include "wx/gdicmn.h"
32 #include "wx/dc.h"
33
34 #include "wx/settings.h"
35
36 #include "wx/renderer.h"
37
38 // ----------------------------------------------------------------------------
39 // wxRendererGeneric: our wxRendererNative implementation
40 // ----------------------------------------------------------------------------
41
42 class WXDLLEXPORT wxRendererGeneric : public wxRendererNative
43 {
44 public:
45 // draw the header control button (used by wxListCtrl)
46 virtual void DrawHeaderButton(wxWindow *win,
47 wxDC& dc,
48 const wxRect& rect,
49 int flags = 0);
50
51 // draw the expanded/collapsed icon for a tree control item
52 virtual void DrawTreeItemButton(wxWindow *win,
53 wxDC& dc,
54 const wxRect& rect,
55 int flags = 0);
56 };
57
58 // ============================================================================
59 // implementation
60 // ============================================================================
61
62 // ----------------------------------------------------------------------------
63 // wxRendererGeneric creation
64 // ----------------------------------------------------------------------------
65
66 /* static */
67 wxRendererNative& wxRendererNative::GetGeneric()
68 {
69 static wxRendererGeneric s_rendererGeneric;
70
71 return s_rendererGeneric;
72 }
73
74 // some platforms have their own renderers
75 #if !defined(__WXMSW__) && !defined(__WXMAC__) && !defined(__WXGTK__)
76
77 /* static */
78 wxRendererNative& wxRendererNative::Get()
79 {
80 return GetGeneric();
81 }
82
83 #endif // platforms using their own renderers
84
85 // ----------------------------------------------------------------------------
86 // wxRendererGeneric drawing functions
87 // ----------------------------------------------------------------------------
88
89 void
90 wxRendererGeneric::DrawHeaderButton(wxWindow *win,
91 wxDC& dc,
92 const wxRect& rect,
93 int flags)
94 {
95 const int CORNER = 1;
96
97 const wxCoord x = rect.x,
98 y = rect.y,
99 w = rect.width,
100 h = rect.height;
101
102 dc.SetBrush( *wxTRANSPARENT_BRUSH );
103
104 dc.SetPen( *wxBLACK_PEN );
105 dc.DrawLine( x+w-CORNER+1, y, x+w, y+h ); // right (outer)
106 dc.DrawRectangle( x, y+h, w+1, 1 ); // bottom (outer)
107
108 wxPen pen( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNSHADOW ), 1, wxSOLID );
109
110 dc.SetPen( pen );
111 dc.DrawLine( x+w-CORNER, y, x+w-1, y+h ); // right (inner)
112 dc.DrawRectangle( x+1, y+h-1, w-2, 1 ); // bottom (inner)
113
114 dc.SetPen( *wxWHITE_PEN );
115 dc.DrawRectangle( x, y, w-CORNER+1, 1 ); // top (outer)
116 dc.DrawRectangle( x, y, 1, h ); // left (outer)
117 dc.DrawLine( x, y+h-1, x+1, y+h-1 );
118 dc.DrawLine( x+w-1, y, x+w-1, y+1 );
119 }
120
121 // draw the plus or minus sign
122 void
123 wxRendererGeneric::DrawTreeItemButton(wxWindow *win,
124 wxDC& dc,
125 const wxRect& rect,
126 int flags)
127 {
128 // white background
129 dc.SetPen(*wxGREY_PEN);
130 dc.SetBrush(*wxWHITE_BRUSH);
131 dc.DrawRectangle(rect.Deflate(1, 2));
132
133 // black lines
134 const wxCoord xMiddle = rect.x + rect.width/2;
135 const wxCoord yMiddle = rect.y + rect.height/2;
136
137 dc.SetPen(*wxBLACK_PEN);
138 dc.DrawLine(xMiddle - 2, yMiddle, xMiddle + 3, yMiddle);
139 if ( flags & wxCONTROL_EXPANDED )
140 {
141 // turn "-" into "+"
142 dc.DrawLine(xMiddle, yMiddle - 2, xMiddle, yMiddle + 3);
143 }
144 }
145
146