]>
Commit | Line | Data |
---|---|---|
ffecfa5a JS |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: palmos/renderer.cpp | |
3 | // Purpose: implementation of wxRendererNative for Palm OS | |
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 licence | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | // ============================================================================ | |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
20 | // Palm OS doesn't really have a theme engine, so this is not needed. | |
21 | #ifndef __PALMOS__ | |
22 | ||
23 | // for compilers that support precompilation, includes "wx.h". | |
24 | #include "wx/wxprec.h" | |
25 | ||
26 | #ifdef __BORLANDC__ | |
27 | #pragma hdrstop | |
28 | #endif | |
29 | ||
30 | #ifndef WX_PRECOMP | |
31 | #include "wx/string.h" | |
32 | #include "wx/window.h" | |
33 | #include "wx/dc.h" | |
34 | #endif //WX_PRECOMP | |
35 | ||
36 | #include "wx/splitter.h" | |
37 | #include "wx/renderer.h" | |
38 | ||
39 | #include "wx/palmos/uxtheme.h" | |
40 | ||
41 | // ---------------------------------------------------------------------------- | |
42 | // wxRendererMSW: wxRendererNative implementation for "old" Win32 systems | |
43 | // ---------------------------------------------------------------------------- | |
44 | ||
45 | class WXDLLEXPORT wxRendererMSW : public wxDelegateRendererNative | |
46 | { | |
47 | public: | |
48 | wxRendererMSW() { } | |
49 | ||
50 | static wxRendererNative& Get(); | |
51 | ||
52 | private: | |
53 | DECLARE_NO_COPY_CLASS(wxRendererMSW) | |
54 | }; | |
55 | ||
56 | // ---------------------------------------------------------------------------- | |
57 | // wxRendererXP: wxRendererNative implementation for Windows XP and later | |
58 | // ---------------------------------------------------------------------------- | |
59 | ||
60 | class WXDLLEXPORT wxRendererXP : public wxDelegateRendererNative | |
61 | { | |
62 | public: | |
63 | wxRendererXP() : wxDelegateRendererNative(wxRendererMSW::Get()) { } | |
64 | ||
65 | static wxRendererNative& Get(); | |
66 | ||
67 | virtual void DrawSplitterBorder(wxWindow *win, | |
68 | wxDC& dc, | |
69 | const wxRect& rect, | |
70 | int flags = 0); | |
71 | virtual void DrawSplitterSash(wxWindow *win, | |
72 | wxDC& dc, | |
73 | const wxSize& size, | |
74 | wxCoord position, | |
75 | wxOrientation orient, | |
76 | int flags = 0); | |
77 | virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win); | |
78 | ||
79 | private: | |
80 | DECLARE_NO_COPY_CLASS(wxRendererXP) | |
81 | }; | |
82 | ||
83 | // ============================================================================ | |
84 | // wxRendererNative and wxRendererMSW implementation | |
85 | // ============================================================================ | |
86 | ||
87 | /* static */ | |
88 | wxRendererNative& wxRendererNative::GetDefault() | |
89 | { | |
90 | wxUxThemeEngine *themeEngine = wxUxThemeEngine::Get(); | |
91 | return themeEngine && themeEngine->IsAppThemed() ? wxRendererXP::Get() | |
92 | : wxRendererMSW::Get(); | |
93 | } | |
94 | ||
95 | /* static */ | |
96 | wxRendererNative& wxRendererMSW::Get() | |
97 | { | |
98 | static wxRendererMSW s_rendererMSW; | |
99 | ||
100 | return s_rendererMSW; | |
101 | } | |
102 | ||
103 | // ============================================================================ | |
104 | // wxRendererXP implementation | |
105 | // ============================================================================ | |
106 | ||
107 | /* static */ | |
108 | wxRendererNative& wxRendererXP::Get() | |
109 | { | |
110 | static wxRendererXP s_rendererXP; | |
111 | ||
112 | return s_rendererXP; | |
113 | } | |
114 | ||
115 | // ---------------------------------------------------------------------------- | |
116 | // splitter drawing | |
117 | // ---------------------------------------------------------------------------- | |
118 | ||
119 | // the width of the sash: this is the same as used by Explorer... | |
120 | static const wxCoord SASH_WIDTH = 4; | |
121 | ||
122 | wxSplitterRenderParams | |
123 | wxRendererXP::GetSplitterParams(const wxWindow * win) | |
124 | { | |
125 | if (win->GetWindowStyle() & wxSP_NO_XP_THEME) | |
126 | return m_rendererNative.GetSplitterParams(win); | |
127 | else | |
128 | return wxSplitterRenderParams(SASH_WIDTH, 0, false); | |
129 | } | |
130 | ||
131 | void | |
132 | wxRendererXP::DrawSplitterBorder(wxWindow * win, | |
133 | wxDC& dc, | |
134 | const wxRect& rect, | |
135 | int flags) | |
136 | { | |
137 | if (win->GetWindowStyle() & wxSP_NO_XP_THEME) | |
138 | { | |
139 | m_rendererNative.DrawSplitterBorder(win, dc, rect, flags); | |
140 | } | |
141 | } | |
142 | ||
143 | void | |
144 | wxRendererXP::DrawSplitterSash(wxWindow *win, | |
145 | wxDC& dc, | |
146 | const wxSize& size, | |
147 | wxCoord position, | |
148 | wxOrientation orient, | |
149 | int flags) | |
150 | { | |
151 | if (win->GetWindowStyle() & wxSP_NO_XP_THEME) | |
152 | { | |
153 | m_rendererNative.DrawSplitterSash( | |
154 | win, dc, size, position, orient, flags); | |
155 | return; | |
156 | } | |
157 | ||
158 | // I don't know if it is correct to use the rebar background for the | |
159 | // splitter but it least this works ok in the default theme | |
160 | wxUxThemeHandle hTheme(win, L"REBAR"); | |
161 | if ( hTheme ) | |
162 | { | |
163 | RECT rect; | |
164 | if ( orient == wxVERTICAL ) | |
165 | { | |
166 | rect.left = position; | |
167 | rect.right = position + SASH_WIDTH; | |
168 | rect.top = 0; | |
169 | rect.bottom = size.y; | |
170 | } | |
171 | else // wxHORIZONTAL | |
172 | { | |
173 | rect.left = 0; | |
174 | rect.right = size.x; | |
175 | rect.top = position; | |
176 | rect.bottom = position + SASH_WIDTH; | |
177 | } | |
178 | ||
179 | wxUxThemeEngine::Get()->DrawThemeBackground | |
180 | ( | |
181 | (WXHTHEME)hTheme, | |
182 | dc.GetHDC(), | |
183 | 3 /* RP_BAND */, | |
184 | 0 /* no state */ , | |
185 | &rect, | |
186 | NULL | |
187 | ); | |
188 | } | |
189 | } | |
190 | ||
191 | #endif |