]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/renderer.cpp
restore some of the styles; added support for splitters without border/sash to generi...
[wxWidgets.git] / src / gtk1 / 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
62};
63
64// ============================================================================
65// implementation
66// ============================================================================
67
68/* static */
38c4cb6a 69wxRendererNative& wxRendererNative::Get()
9c7f49f5
VZ
70{
71 static wxRendererGTK s_rendererGTK;
72
73 return s_rendererGTK;
74}
75
76void
77wxRendererGTK::DrawHeaderButton(wxWindow *win,
78 wxDC& dc,
79 const wxRect& rect,
80 int flags)
81{
82 gtk_paint_box
83 (
84 win->m_wxwindow->style,
85 GTK_PIZZA(win->m_wxwindow)->bin_window,
86 flags & wxCONTROL_DISABLED ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL,
87 GTK_SHADOW_OUT,
38c4cb6a
VZ
88 (GdkRectangle*) NULL,
89 win->m_wxwindow,
9c7f49f5 90 (char *)"button", // const_cast
38c4cb6a 91 dc.XLOG2DEV(rect.x) - 1, rect.y - 1, rect.width + 2, rect.height + 2
9c7f49f5
VZ
92 );
93}
94
95#ifdef __WXGTK20__
96
97// draw a ">" or "v" button
98//
99// TODO: isn't there a GTK function to draw it?
100void
9a0b7e33
VS
101wxRendererGTK::DrawTreeItemButton(wxWindow* WXUNUSED(win),
102 wxDC& dc, const wxRect& rect, int flags)
9c7f49f5 103{
3dd570e5
VZ
104 dc.SetBrush(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT),
105 wxSOLID));
9c7f49f5
VZ
106 dc.SetPen(*wxBLACK_PEN);
107 wxPoint button[3];
108
109 const wxCoord xMiddle = rect.x + rect.width/2;
110 const wxCoord yMiddle = rect.y + rect.height/2;
111
112 if ( flags & wxCONTROL_EXPANDED )
113 {
114 button[0].x = rect.GetLeft();
115 button[0].y = yMiddle - 2;
116 button[1].x = rect.GetRight();
117 button[1].y = yMiddle - 2;
118 button[2].x = xMiddle;
119 button[2].y = yMiddle + 3;
120 }
121 else // collapsed
122 {
123 button[0].y = rect.GetBottom();
124 button[0].x = xMiddle - 2;
125 button[1].y = rect.GetTop();
126 button[1].x = xMiddle - 2;
127 button[2].y = yMiddle;
128 button[2].x = xMiddle + 3;
129 }
130
131 dc.DrawPolygon(3, button);
132}
133
134#endif // GTK 2.0
135
136