]>
Commit | Line | Data |
---|---|---|
9c7f49f5 VZ |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/renderer.h | |
3 | // Purpose: wxRendererNative class declaration | |
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 | // Licence: wxWindows licence | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | /* | |
13 | Renderers are used in wxWindows for two similar but different things: | |
14 | (a) wxUniversal uses them to draw everything, i.e. all the control | |
15 | (b) all the native ports use them to draw generic controls only | |
16 | ||
17 | wxUniversal needs more functionality than what is included in the base class | |
18 | as it needs to draw stuff like scrollbars which are never going to be | |
19 | generic. So we put the bare minimum needed by the native ports here and the | |
20 | full wxRenderer class is declared in wx/univ/renderer.h and is only used by | |
21 | wxUniveral (although note that native ports can load wxRenderer objects from | |
22 | theme DLLs and use them as wxRendererNative ones, of course). | |
23 | */ | |
24 | ||
25 | #ifndef _WX_RENDERER_H_ | |
26 | #define _WX_RENDERER_H_ | |
27 | ||
38c4cb6a VZ |
28 | class WXDLLEXPORT wxDC; |
29 | class WXDLLEXPORT wxRect; | |
30 | class WXDLLEXPORT wxWindow; | |
31 | ||
9c7f49f5 VZ |
32 | // ---------------------------------------------------------------------------- |
33 | // constants | |
34 | // ---------------------------------------------------------------------------- | |
35 | ||
36 | // control state flags used in wxRenderer and wxColourScheme | |
37 | enum | |
38 | { | |
39 | wxCONTROL_DISABLED = 0x00000001, // control is disabled | |
40 | wxCONTROL_FOCUSED = 0x00000002, // currently has keyboard focus | |
41 | wxCONTROL_PRESSED = 0x00000004, // (button) is pressed | |
42 | wxCONTROL_ISDEFAULT = 0x00000008, // only applies to the buttons | |
43 | wxCONTROL_ISSUBMENU = wxCONTROL_ISDEFAULT, // only for menu items | |
44 | wxCONTROL_EXPANDED = wxCONTROL_ISDEFAULT, // only for the tree items | |
45 | wxCONTROL_CURRENT = 0x00000010, // mouse is currently over the control | |
46 | wxCONTROL_SELECTED = 0x00000020, // selected item in e.g. listbox | |
47 | wxCONTROL_CHECKED = 0x00000040, // (check/radio button) is checked | |
48 | wxCONTROL_CHECKABLE = 0x00000080, // (menu) item can be checked | |
49 | ||
50 | wxCONTROL_FLAGS_MASK = 0x000000ff, | |
51 | ||
52 | // this is a pseudo flag not used directly by wxRenderer but rather by some | |
53 | // controls internally | |
54 | wxCONTROL_DIRTY = 0x80000000 | |
55 | }; | |
56 | ||
57 | // ---------------------------------------------------------------------------- | |
58 | // wxRendererNative: abstracts drawing methods needed by the native controls | |
59 | // ---------------------------------------------------------------------------- | |
60 | ||
61 | class WXDLLEXPORT wxRendererNative | |
62 | { | |
63 | public: | |
64 | // drawing functions | |
65 | // ----------------- | |
66 | ||
67 | // draw the header control button (used by wxListCtrl) | |
68 | virtual void DrawHeaderButton(wxWindow *win, | |
69 | wxDC& dc, | |
70 | const wxRect& rect, | |
71 | int flags = 0) = 0; | |
72 | ||
73 | // draw the expanded/collapsed icon for a tree control item | |
74 | virtual void DrawTreeItemButton(wxWindow *win, | |
75 | wxDC& dc, | |
76 | const wxRect& rect, | |
77 | int flags = 0) = 0; | |
78 | ||
b3208e11 VZ |
79 | // draw the border for sash window: this border must be such that the sash |
80 | // drawn by DrawSash() blends into it well | |
81 | virtual void DrawSplitterBorder(wxWindow *win, | |
82 | wxDC& dc, | |
83 | const wxRect& rect) = 0; | |
84 | ||
85 | // draw a (vertical) sash | |
86 | virtual void DrawSplitterSash(wxWindow *win, | |
87 | wxDC& dc, | |
88 | const wxSize& size, | |
89 | wxCoord position) = 0; | |
90 | ||
91 | ||
92 | // geometry functions | |
93 | // ------------------ | |
94 | ||
95 | // get the splitter parameters: the x field of the returned point is the | |
96 | // sash width and the y field is the border width | |
97 | virtual wxPoint GetSplitterSashAndBorder(const wxWindow *win) = 0; | |
98 | ||
9c7f49f5 VZ |
99 | |
100 | // pseudo constructors | |
101 | // ------------------- | |
102 | ||
103 | // return the currently used renderer | |
104 | static wxRendererNative& Get(); | |
105 | ||
106 | // return the generic implementation of the renderer | |
107 | static wxRendererNative& GetGeneric(); | |
108 | }; | |
109 | ||
110 | // ---------------------------------------------------------------------------- | |
111 | // wxDelegateRendererNative: allows reuse of renderers code | |
112 | // ---------------------------------------------------------------------------- | |
113 | ||
114 | class WXDLLEXPORT wxDelegateRendererNative : public wxRendererNative | |
115 | { | |
116 | public: | |
117 | wxDelegateRendererNative() | |
118 | : m_rendererNative(GetGeneric()) { } | |
119 | ||
120 | wxDelegateRendererNative(wxRendererNative& rendererNative) | |
121 | : m_rendererNative(rendererNative) { } | |
122 | ||
123 | ||
124 | virtual void DrawHeaderButton(wxWindow *win, | |
125 | wxDC& dc, | |
126 | const wxRect& rect, | |
127 | int flags = 0) | |
128 | { m_rendererNative.DrawHeaderButton(win, dc, rect, flags); } | |
b3208e11 | 129 | |
9c7f49f5 VZ |
130 | virtual void DrawTreeItemButton(wxWindow *win, |
131 | wxDC& dc, | |
132 | const wxRect& rect, | |
133 | int flags = 0) | |
134 | { m_rendererNative.DrawTreeItemButton(win, dc, rect, flags); } | |
135 | ||
b3208e11 VZ |
136 | virtual void DrawSplitterBorder(wxWindow *win, |
137 | wxDC& dc, | |
138 | const wxRect& rect) | |
139 | { m_rendererNative.DrawSplitterBorder(win, dc, rect); } | |
140 | ||
141 | virtual void DrawSplitterSash(wxWindow *win, | |
142 | wxDC& dc, | |
143 | const wxSize& size, | |
144 | wxCoord position) | |
145 | { m_rendererNative.DrawSplitterSash(win, dc, size, position); } | |
146 | ||
147 | ||
148 | virtual wxPoint GetSplitterSashAndBorder(const wxWindow *win) | |
149 | { return m_rendererNative.GetSplitterSashAndBorder(win); } | |
150 | ||
9c7f49f5 VZ |
151 | protected: |
152 | wxRendererNative& m_rendererNative; | |
fc7a2a60 VZ |
153 | |
154 | DECLARE_NO_COPY_CLASS(wxDelegateRendererNative) | |
9c7f49f5 VZ |
155 | }; |
156 | ||
157 | #endif // _WX_RENDERER_H_ | |
158 |