]> git.saurik.com Git - wxWidgets.git/blob - include/wx/renderer.h
added wxRendererNative to be used by the generic controls for rendering platfomr...
[wxWidgets.git] / include / wx / renderer.h
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
28 // ----------------------------------------------------------------------------
29 // constants
30 // ----------------------------------------------------------------------------
31
32 // control state flags used in wxRenderer and wxColourScheme
33 enum
34 {
35 wxCONTROL_DISABLED = 0x00000001, // control is disabled
36 wxCONTROL_FOCUSED = 0x00000002, // currently has keyboard focus
37 wxCONTROL_PRESSED = 0x00000004, // (button) is pressed
38 wxCONTROL_ISDEFAULT = 0x00000008, // only applies to the buttons
39 wxCONTROL_ISSUBMENU = wxCONTROL_ISDEFAULT, // only for menu items
40 wxCONTROL_EXPANDED = wxCONTROL_ISDEFAULT, // only for the tree items
41 wxCONTROL_CURRENT = 0x00000010, // mouse is currently over the control
42 wxCONTROL_SELECTED = 0x00000020, // selected item in e.g. listbox
43 wxCONTROL_CHECKED = 0x00000040, // (check/radio button) is checked
44 wxCONTROL_CHECKABLE = 0x00000080, // (menu) item can be checked
45
46 wxCONTROL_FLAGS_MASK = 0x000000ff,
47
48 // this is a pseudo flag not used directly by wxRenderer but rather by some
49 // controls internally
50 wxCONTROL_DIRTY = 0x80000000
51 };
52
53 // ----------------------------------------------------------------------------
54 // wxRendererNative: abstracts drawing methods needed by the native controls
55 // ----------------------------------------------------------------------------
56
57 class WXDLLEXPORT wxRendererNative
58 {
59 public:
60 // drawing functions
61 // -----------------
62
63 // draw the header control button (used by wxListCtrl)
64 virtual void DrawHeaderButton(wxWindow *win,
65 wxDC& dc,
66 const wxRect& rect,
67 int flags = 0) = 0;
68
69 // draw the expanded/collapsed icon for a tree control item
70 virtual void DrawTreeItemButton(wxWindow *win,
71 wxDC& dc,
72 const wxRect& rect,
73 int flags = 0) = 0;
74
75
76 // pseudo constructors
77 // -------------------
78
79 // return the currently used renderer
80 static wxRendererNative& Get();
81
82 // return the generic implementation of the renderer
83 static wxRendererNative& GetGeneric();
84 };
85
86 // ----------------------------------------------------------------------------
87 // wxDelegateRendererNative: allows reuse of renderers code
88 // ----------------------------------------------------------------------------
89
90 class WXDLLEXPORT wxDelegateRendererNative : public wxRendererNative
91 {
92 public:
93 wxDelegateRendererNative()
94 : m_rendererNative(GetGeneric()) { }
95
96 wxDelegateRendererNative(wxRendererNative& rendererNative)
97 : m_rendererNative(rendererNative) { }
98
99
100 virtual void DrawHeaderButton(wxWindow *win,
101 wxDC& dc,
102 const wxRect& rect,
103 int flags = 0)
104 { m_rendererNative.DrawHeaderButton(win, dc, rect, flags); }
105 virtual void DrawTreeItemButton(wxWindow *win,
106 wxDC& dc,
107 const wxRect& rect,
108 int flags = 0)
109 { m_rendererNative.DrawTreeItemButton(win, dc, rect, flags); }
110
111 protected:
112 wxRendererNative& m_rendererNative;
113 };
114
115 #endif // _WX_RENDERER_H_
116