compilation fixes
[wxWidgets.git] / src / gtk / renderer.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: gtk/renderer.cpp
3 // Purpose: implementation of wxRendererNative for wxGTK
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 #endif // WX_PRECOMP
29
30 #include <gtk/gtk.h>
31 #include "wx/gtk/win_gtk.h"
32
33 #include "wx/window.h"
34 #include "wx/dc.h"
35 #include "wx/renderer.h"
36
37 // ----------------------------------------------------------------------------
38 // wxRendererGTK: our wxRendererNative implementation
39 // ----------------------------------------------------------------------------
40
41 class WXDLLEXPORT wxRendererGTK : public wxDelegateRendererNative
42 {
43 public:
44 // draw the header control button (used by wxListCtrl)
45 virtual void DrawHeaderButton(wxWindow *win,
46 wxDC& dc,
47 const wxRect& rect,
48 int flags = 0);
49
50 #ifdef __WXGTK20__
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 #endif // GTK 2.0
57
58 };
59
60 // ============================================================================
61 // implementation
62 // ============================================================================
63
64 /* static */
65 wxRendererNative& wxRendererNative::Get()
66 {
67 static wxRendererGTK s_rendererGTK;
68
69 return s_rendererGTK;
70 }
71
72 void
73 wxRendererGTK::DrawHeaderButton(wxWindow *win,
74 wxDC& dc,
75 const wxRect& rect,
76 int flags)
77 {
78 gtk_paint_box
79 (
80 win->m_wxwindow->style,
81 GTK_PIZZA(win->m_wxwindow)->bin_window,
82 flags & wxCONTROL_DISABLED ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL,
83 GTK_SHADOW_OUT,
84 (GdkRectangle*) NULL,
85 win->m_wxwindow,
86 (char *)"button", // const_cast
87 dc.XLOG2DEV(rect.x) - 1, rect.y - 1, rect.width + 2, rect.height + 2
88 );
89 }
90
91 #ifdef __WXGTK20__
92
93 // draw a ">" or "v" button
94 //
95 // TODO: isn't there a GTK function to draw it?
96 void
97 wxRendererGTK::DrawTreeItemButton(wxDC& dc, const wxRect& rect, int flags)
98 {
99 dc.SetBrush(*m_hilightBrush);
100 dc.SetPen(*wxBLACK_PEN);
101 wxPoint button[3];
102
103 const wxCoord xMiddle = rect.x + rect.width/2;
104 const wxCoord yMiddle = rect.y + rect.height/2;
105
106 if ( flags & wxCONTROL_EXPANDED )
107 {
108 button[0].x = rect.GetLeft();
109 button[0].y = yMiddle - 2;
110 button[1].x = rect.GetRight();
111 button[1].y = yMiddle - 2;
112 button[2].x = xMiddle;
113 button[2].y = yMiddle + 3;
114 }
115 else // collapsed
116 {
117 button[0].y = rect.GetBottom();
118 button[0].x = xMiddle - 2;
119 button[1].y = rect.GetTop();
120 button[1].x = xMiddle - 2;
121 button[2].y = yMiddle;
122 button[2].x = xMiddle + 3;
123 }
124
125 dc.DrawPolygon(3, button);
126 }
127
128 #endif // GTK 2.0
129
130