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