]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/renderer.cpp
fixed completely broken CheckForTransparency()
[wxWidgets.git] / src / gtk / renderer.cpp
CommitLineData
9c7f49f5
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: gtk/renderer.cpp
38c4cb6a 3// Purpose: implementation of wxRendererNative for wxGTK
9c7f49f5
VZ
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
38c4cb6a
VZ
33#include "wx/window.h"
34#include "wx/dc.h"
9c7f49f5
VZ
35#include "wx/renderer.h"
36
3dd570e5
VZ
37#ifdef __WXGTK20__
38 #include "wx/settings.h"
39#endif // GTK 2.0
40
9c7f49f5 41// ----------------------------------------------------------------------------
38c4cb6a 42// wxRendererGTK: our wxRendererNative implementation
9c7f49f5
VZ
43// ----------------------------------------------------------------------------
44
38c4cb6a 45class WXDLLEXPORT wxRendererGTK : public wxDelegateRendererNative
9c7f49f5
VZ
46{
47public:
48 // draw the header control button (used by wxListCtrl)
49 virtual void DrawHeaderButton(wxWindow *win,
50 wxDC& dc,
51 const wxRect& rect,
52 int flags = 0);
53
54#ifdef __WXGTK20__
55 // draw the expanded/collapsed icon for a tree control item
56 virtual void DrawTreeItemButton(wxWindow *win,
57 wxDC& dc,
58 const wxRect& rect,
59 int flags = 0);
60#endif // GTK 2.0
61
95155e75
VZ
62 // draw a (vertical) sash
63 //
64 // VZ: doesn't work -- nothing is shown on screen, why?
65#if 0
66 virtual void DrawSplitterSash(wxWindow *win,
67 wxDC& dc,
68 const wxSize& size,
69 wxCoord position);
70#endif // 0
9c7f49f5
VZ
71};
72
73// ============================================================================
74// implementation
75// ============================================================================
76
77/* static */
38c4cb6a 78wxRendererNative& wxRendererNative::Get()
9c7f49f5
VZ
79{
80 static wxRendererGTK s_rendererGTK;
81
82 return s_rendererGTK;
83}
84
85void
86wxRendererGTK::DrawHeaderButton(wxWindow *win,
87 wxDC& dc,
88 const wxRect& rect,
89 int flags)
90{
91 gtk_paint_box
92 (
93 win->m_wxwindow->style,
94 GTK_PIZZA(win->m_wxwindow)->bin_window,
95 flags & wxCONTROL_DISABLED ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL,
96 GTK_SHADOW_OUT,
38c4cb6a
VZ
97 (GdkRectangle*) NULL,
98 win->m_wxwindow,
9c7f49f5 99 (char *)"button", // const_cast
38c4cb6a 100 dc.XLOG2DEV(rect.x) - 1, rect.y - 1, rect.width + 2, rect.height + 2
9c7f49f5
VZ
101 );
102}
103
104#ifdef __WXGTK20__
105
106// draw a ">" or "v" button
107//
108// TODO: isn't there a GTK function to draw it?
109void
9a0b7e33
VS
110wxRendererGTK::DrawTreeItemButton(wxWindow* WXUNUSED(win),
111 wxDC& dc, const wxRect& rect, int flags)
9c7f49f5 112{
3dd570e5
VZ
113 dc.SetBrush(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT),
114 wxSOLID));
9c7f49f5
VZ
115 dc.SetPen(*wxBLACK_PEN);
116 wxPoint button[3];
117
118 const wxCoord xMiddle = rect.x + rect.width/2;
119 const wxCoord yMiddle = rect.y + rect.height/2;
120
121 if ( flags & wxCONTROL_EXPANDED )
122 {
123 button[0].x = rect.GetLeft();
124 button[0].y = yMiddle - 2;
125 button[1].x = rect.GetRight();
126 button[1].y = yMiddle - 2;
127 button[2].x = xMiddle;
128 button[2].y = yMiddle + 3;
129 }
130 else // collapsed
131 {
132 button[0].y = rect.GetBottom();
133 button[0].x = xMiddle - 2;
134 button[1].y = rect.GetTop();
135 button[1].x = xMiddle - 2;
136 button[2].y = yMiddle;
137 button[2].x = xMiddle + 3;
138 }
139
140 dc.DrawPolygon(3, button);
141}
142
143#endif // GTK 2.0
144
95155e75
VZ
145#if 0
146
147// draw a (vertical) sash
148void
149wxRendererGTK::DrawSplitterSash(wxWindow *win,
150 wxDC& dc,
151 const wxSize& size,
152 wxCoord position)
153{
154 if ( !win->m_wxwindow->window )
155 {
156 // VZ: this happens on startup -- why?
157 return;
158 }
159
160 gtk_paint_vline
161 (
162 win->m_wxwindow->style,
163 win->m_wxwindow->window,
164 GTK_STATE_NORMAL,
165 (GdkRectangle *)NULL,
166 win->m_wxwindow,
167 (char *)"vpaned", // const_cast
168 0, size.y, position + 3
169 );
170
171 gtk_paint_box
172 (
173 win->m_wxwindow->style,
174 win->m_wxwindow->window,
175 GTK_STATE_NORMAL,
176 GTK_SHADOW_OUT,
177 (GdkRectangle *)NULL,
178 win->m_wxwindow,
179 (char *)"paned", // const_cast
180 position, 5, 10, 10
181 );
182}
183
184#endif // 0
9c7f49f5 185