]>
Commit | Line | Data |
---|---|---|
3c3ead1d PC |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: src/ribbon/art_msw.cpp | |
3 | // Purpose: MSW style art provider for ribbon interface | |
4 | // Author: Peter Cawley | |
5 | // Modified by: | |
6 | // Created: 2009-05-25 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (C) Peter Cawley | |
9 | // Licence: wxWindows licence | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #include "wx/wxprec.h" | |
13 | ||
14 | #ifdef __BORLANDC__ | |
15 | #pragma hdrstop | |
16 | #endif | |
17 | ||
3c3ead1d PC |
18 | #if wxUSE_RIBBON |
19 | ||
4cf018e1 | 20 | #include "wx/ribbon/art.h" |
3c3ead1d PC |
21 | #include "wx/ribbon/art_internal.h" |
22 | #include "wx/ribbon/bar.h" | |
23 | #include "wx/ribbon/buttonbar.h" | |
24 | #include "wx/ribbon/gallery.h" | |
25 | #include "wx/ribbon/toolbar.h" | |
26 | ||
27 | #ifndef WX_PRECOMP | |
4cf018e1 | 28 | #include "wx/dcmemory.h" |
3c3ead1d PC |
29 | #endif |
30 | ||
31 | #ifdef __WXMSW__ | |
32 | #include "wx/msw/private.h" | |
33 | #endif | |
34 | ||
35 | static const char* const gallery_up_xpm[] = { | |
36 | "5 5 2 1", | |
37 | " c None", | |
38 | "x c #FF00FF", | |
39 | " ", | |
40 | " x ", | |
41 | " xxx ", | |
42 | "xxxxx", | |
43 | " "}; | |
44 | ||
45 | static const char* const gallery_down_xpm[] = { | |
46 | "5 5 2 1", | |
47 | " c None", | |
48 | "x c #FF00FF", | |
49 | " ", | |
50 | "xxxxx", | |
51 | " xxx ", | |
52 | " x ", | |
53 | " "}; | |
54 | ||
55 | static const char* const gallery_left_xpm[] = { | |
56 | "5 5 2 1", | |
57 | " c None", | |
58 | "x c #FF00FF", | |
59 | " x ", | |
60 | " xx ", | |
61 | " xxx ", | |
62 | " xx ", | |
63 | " x "}; | |
64 | ||
65 | static const char* const gallery_right_xpm[] = { | |
66 | "5 5 2 1", | |
67 | " c None", | |
68 | "x c #FF00FF", | |
69 | " x ", | |
70 | " xx ", | |
71 | " xxx ", | |
72 | " xx ", | |
73 | " x "}; | |
74 | ||
75 | static const char* const gallery_extension_xpm[] = { | |
76 | "5 5 2 1", | |
77 | " c None", | |
78 | "x c #FF00FF", | |
79 | "xxxxx", | |
80 | " ", | |
81 | "xxxxx", | |
82 | " xxx ", | |
83 | " x "}; | |
84 | ||
0a7ee6e0 VZ |
85 | static const char* const panel_extension_xpm[] = { |
86 | "7 7 2 1", | |
87 | " c None", | |
88 | "x c #FF00FF", | |
89 | "xxxxxx ", | |
90 | "x ", | |
91 | "x ", | |
92 | "x x x", | |
93 | "x xxx", | |
94 | "x xxx", | |
95 | " xxxx"}; | |
96 | ||
3c3ead1d PC |
97 | wxRibbonMSWArtProvider::wxRibbonMSWArtProvider(bool set_colour_scheme) |
98 | { | |
99 | m_flags = 0; | |
7d8c1fbc | 100 | m_tab_label_font = *wxNORMAL_FONT; |
3c3ead1d PC |
101 | m_button_bar_label_font = m_tab_label_font; |
102 | m_panel_label_font = m_tab_label_font; | |
103 | ||
104 | if(set_colour_scheme) | |
105 | { | |
106 | SetColourScheme( | |
107 | wxColour(194, 216, 241), | |
108 | wxColour(255, 223, 114), | |
109 | wxColour( 0, 0, 0)); | |
110 | } | |
111 | ||
112 | m_cached_tab_separator_visibility = -10.0; // valid visibilities are in range [0, 1] | |
113 | m_tab_separation_size = 3; | |
114 | m_page_border_left = 2; | |
115 | m_page_border_top = 1; | |
116 | m_page_border_right = 2; | |
117 | m_page_border_bottom = 3; | |
118 | m_panel_x_separation_size = 1; | |
119 | m_panel_y_separation_size = 1; | |
120 | m_tool_group_separation_size = 3; | |
121 | m_gallery_bitmap_padding_left_size = 4; | |
122 | m_gallery_bitmap_padding_right_size = 4; | |
123 | m_gallery_bitmap_padding_top_size = 4; | |
124 | m_gallery_bitmap_padding_bottom_size = 4; | |
125 | } | |
126 | ||
127 | wxRibbonMSWArtProvider::~wxRibbonMSWArtProvider() | |
128 | { | |
129 | } | |
130 | ||
131 | void wxRibbonMSWArtProvider::GetColourScheme( | |
132 | wxColour* primary, | |
133 | wxColour* secondary, | |
134 | wxColour* tertiary) const | |
135 | { | |
136 | if(primary != NULL) | |
137 | *primary = m_primary_scheme_colour; | |
138 | if(secondary != NULL) | |
139 | *secondary = m_secondary_scheme_colour; | |
140 | if(tertiary != NULL) | |
141 | *tertiary = m_tertiary_scheme_colour; | |
142 | } | |
143 | ||
144 | void wxRibbonMSWArtProvider::SetColourScheme( | |
145 | const wxColour& primary, | |
146 | const wxColour& secondary, | |
147 | const wxColour& tertiary) | |
148 | { | |
149 | m_primary_scheme_colour = primary; | |
150 | m_secondary_scheme_colour = secondary; | |
151 | m_tertiary_scheme_colour = tertiary; | |
152 | ||
153 | wxRibbonHSLColour primary_hsl(primary); | |
154 | wxRibbonHSLColour secondary_hsl(secondary); | |
155 | // tertiary not used for anything | |
156 | ||
157 | // Map primary saturation from [0, 1] to [.25, .75] | |
1edd6079 | 158 | bool primary_is_gray = false; |
4082ff84 | 159 | static const double gray_saturation_threshold = 0.01; |
1edd6079 PC |
160 | if(primary_hsl.saturation <= gray_saturation_threshold) |
161 | primary_is_gray = true; | |
162 | else | |
163 | { | |
164 | primary_hsl.saturation = cos(primary_hsl.saturation * M_PI) | |
165 | * -0.25 + 0.5; | |
166 | } | |
3c3ead1d PC |
167 | |
168 | // Map primary luminance from [0, 1] to [.23, .83] | |
169 | primary_hsl.luminance = cos(primary_hsl.luminance * M_PI) * -0.3 + 0.53; | |
170 | ||
171 | // Map secondary saturation from [0, 1] to [0.16, 0.84] | |
1edd6079 PC |
172 | bool secondary_is_gray = false; |
173 | if(secondary_hsl.saturation <= gray_saturation_threshold) | |
174 | secondary_is_gray = true; | |
175 | else | |
176 | { | |
177 | secondary_hsl.saturation = cos(secondary_hsl.saturation * M_PI) | |
178 | * -0.34 + 0.5; | |
179 | } | |
3c3ead1d PC |
180 | |
181 | // Map secondary luminance from [0, 1] to [0.1, 0.9] | |
182 | secondary_hsl.luminance = cos(secondary_hsl.luminance * M_PI) * -0.4 + 0.5; | |
183 | ||
184 | #define LikePrimary(h, s, l) \ | |
1edd6079 PC |
185 | primary_hsl.ShiftHue(h ## f).Saturated(primary_is_gray ? 0 : s ## f) \ |
186 | .Lighter(l ## f).ToRGB() | |
3c3ead1d | 187 | #define LikeSecondary(h, s, l) \ |
1edd6079 PC |
188 | secondary_hsl.ShiftHue(h ## f).Saturated(secondary_is_gray ? 0 : s ## f) \ |
189 | .Lighter(l ## f).ToRGB() | |
3c3ead1d PC |
190 | |
191 | m_page_border_pen = LikePrimary(1.4, 0.00, -0.08); | |
192 | ||
193 | m_page_background_top_colour = LikePrimary(-0.1, -0.03, 0.12); | |
194 | m_page_hover_background_top_colour = LikePrimary(-2.8, 0.27, 0.17); | |
195 | m_page_background_top_gradient_colour = LikePrimary(0.1, -0.10, 0.08); | |
196 | m_page_hover_background_top_gradient_colour = LikePrimary(3.2, 0.16, 0.13); | |
197 | m_page_background_colour = LikePrimary(0.4, -0.09, 0.05); | |
198 | m_page_hover_background_colour = LikePrimary(0.1, 0.19, 0.10); | |
199 | m_page_background_gradient_colour = LikePrimary(-3.2, 0.27, 0.10); | |
200 | m_page_hover_background_gradient_colour = LikePrimary(1.8, 0.01, 0.15); | |
201 | ||
202 | m_tab_active_background_colour = LikePrimary(-0.1, -0.31, 0.16); | |
203 | m_tab_active_background_gradient_colour = LikePrimary(-0.1, -0.03, 0.12); | |
204 | m_tab_separator_colour = LikePrimary(0.9, 0.24, 0.05); | |
205 | m_tab_ctrl_background_brush = LikePrimary(1.0, 0.39, 0.07); | |
206 | m_tab_hover_background_colour = LikePrimary(1.3, 0.15, 0.10); | |
207 | m_tab_hover_background_top_colour = LikePrimary(1.4, 0.36, 0.08); | |
ce00f59b | 208 | m_tab_border_pen = LikePrimary(1.4, 0.03, -0.05); |
3c3ead1d | 209 | m_tab_separator_gradient_colour = LikePrimary(1.7, -0.15, -0.18); |
ce00f59b | 210 | m_tab_hover_background_top_gradient_colour = LikePrimary(1.8, 0.34, 0.13); |
3c3ead1d PC |
211 | m_tab_label_colour = LikePrimary(4.3, 0.13, -0.49); |
212 | m_tab_hover_background_gradient_colour = LikeSecondary(-1.5, -0.34, 0.01); | |
213 | ||
214 | m_panel_minimised_border_gradient_pen = LikePrimary(-6.9, -0.17, -0.09); | |
215 | m_panel_minimised_border_pen = LikePrimary(-5.3, -0.24, -0.06); | |
216 | m_panel_border_gradient_pen = LikePrimary(-5.2, -0.15, -0.06); | |
217 | m_panel_border_pen = LikePrimary(-2.8, -0.32, 0.02); | |
218 | m_panel_label_background_brush = LikePrimary(-1.5, 0.03, 0.05); | |
219 | m_panel_active_background_gradient_colour = LikePrimary(0.5, 0.34, 0.05); | |
220 | m_panel_hover_label_background_brush = LikePrimary(1.0, 0.30, 0.09); | |
221 | m_panel_active_background_top_gradient_colour = LikePrimary(1.4, -0.17, -0.13); | |
222 | m_panel_active_background_colour = LikePrimary(1.6, -0.18, -0.18); | |
223 | m_panel_active_background_top_colour = LikePrimary(1.7, -0.20, -0.03); | |
224 | m_panel_label_colour = LikePrimary(2.8, -0.14, -0.35); | |
225 | m_panel_hover_label_colour = m_panel_label_colour; | |
226 | m_panel_minimised_label_colour = m_tab_label_colour; | |
0a7ee6e0 VZ |
227 | m_panel_hover_button_background_brush = LikeSecondary(-0.9, 0.16, -0.07); |
228 | m_panel_hover_button_border_pen = LikeSecondary(-3.9, -0.16, -0.14); | |
229 | SetColour(wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR, LikePrimary(1.4, -0.21, -0.23)); | |
230 | SetColour(wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR, LikePrimary(1.5, -0.24, -0.29)); | |
3c3ead1d PC |
231 | |
232 | m_gallery_button_disabled_background_colour = LikePrimary(-2.8, -0.46, 0.09); | |
ce00f59b | 233 | m_gallery_button_disabled_background_top_brush = LikePrimary(-2.8, -0.36, 0.15); |
3c3ead1d PC |
234 | m_gallery_hover_background_brush = LikePrimary(-0.8, 0.05, 0.15); |
235 | m_gallery_border_pen = LikePrimary(0.7, -0.02, 0.03); | |
236 | m_gallery_button_background_top_brush = LikePrimary(0.8, 0.34, 0.13); | |
237 | m_gallery_button_background_colour = LikePrimary(1.3, 0.10, 0.08); | |
238 | // SetColour used so that the relevant bitmaps are generated | |
239 | SetColour(wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR, LikePrimary(1.4, -0.21, -0.23)); | |
240 | SetColour(wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR, LikePrimary(1.5, -0.24, -0.29)); | |
241 | SetColour(wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR, LikePrimary(1.5, -0.24, -0.29)); | |
242 | SetColour(wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR, LikePrimary(0.0, -1.0, 0.0)); | |
243 | m_gallery_button_disabled_background_gradient_colour = LikePrimary(1.5, -0.43, 0.12); | |
244 | m_gallery_button_background_gradient_colour = LikePrimary(1.7, 0.11, 0.09); | |
245 | m_gallery_item_border_pen = LikeSecondary(-3.9, -0.16, -0.14); | |
246 | m_gallery_button_hover_background_colour = LikeSecondary(-0.9, 0.16, -0.07); | |
247 | m_gallery_button_hover_background_gradient_colour = LikeSecondary(0.1, 0.12, 0.03); | |
248 | m_gallery_button_hover_background_top_brush = LikeSecondary(4.3, 0.16, 0.17); | |
249 | ||
250 | m_gallery_button_active_background_colour = LikeSecondary(-9.9, 0.03, -0.22); | |
251 | m_gallery_button_active_background_gradient_colour = LikeSecondary(-9.5, 0.14, -0.11); | |
252 | m_gallery_button_active_background_top_brush = LikeSecondary(-9.0, 0.15, -0.08); | |
ce00f59b | 253 | |
3c3ead1d PC |
254 | m_button_bar_label_colour = m_tab_label_colour; |
255 | m_button_bar_hover_border_pen = LikeSecondary(-6.2, -0.47, -0.14); | |
256 | m_button_bar_hover_background_gradient_colour = LikeSecondary(-0.6, 0.16, 0.04); | |
257 | m_button_bar_hover_background_colour = LikeSecondary(-0.2, 0.16, -0.10); | |
258 | m_button_bar_hover_background_top_gradient_colour = LikeSecondary(0.2, 0.16, 0.03); | |
259 | m_button_bar_hover_background_top_colour = LikeSecondary(8.8, 0.16, 0.17); | |
260 | m_button_bar_active_border_pen = LikeSecondary(-6.2, -0.47, -0.25); | |
261 | m_button_bar_active_background_top_colour = LikeSecondary(-8.4, 0.08, 0.06); | |
262 | m_button_bar_active_background_top_gradient_colour = LikeSecondary(-9.7, 0.13, -0.07); | |
263 | m_button_bar_active_background_colour = LikeSecondary(-9.9, 0.14, -0.14); | |
264 | m_button_bar_active_background_gradient_colour = LikeSecondary(-8.7, 0.17, -0.03); | |
265 | ||
266 | m_toolbar_border_pen = LikePrimary(1.4, -0.21, -0.16); | |
267 | SetColour(wxRIBBON_ART_TOOLBAR_FACE_COLOUR, LikePrimary(1.4, -0.17, -0.22)); | |
268 | m_tool_background_top_colour = LikePrimary(-1.9, -0.07, 0.06); | |
269 | m_tool_background_top_gradient_colour = LikePrimary(1.4, 0.12, 0.08); | |
270 | m_tool_background_colour = LikePrimary(1.4, -0.09, 0.03); | |
271 | m_tool_background_gradient_colour = LikePrimary(1.9, 0.11, 0.09); | |
272 | m_tool_hover_background_top_colour = LikeSecondary(3.4, 0.11, 0.16); | |
273 | m_tool_hover_background_top_gradient_colour = LikeSecondary(-1.4, 0.04, 0.08); | |
274 | m_tool_hover_background_colour = LikeSecondary(-1.8, 0.16, -0.12); | |
275 | m_tool_hover_background_gradient_colour = LikeSecondary(-2.6, 0.16, 0.05); | |
276 | m_tool_active_background_top_colour = LikeSecondary(-9.9, -0.12, -0.09); | |
277 | m_tool_active_background_top_gradient_colour = LikeSecondary(-8.5, 0.16, -0.12); | |
278 | m_tool_active_background_colour = LikeSecondary(-7.9, 0.16, -0.20); | |
279 | m_tool_active_background_gradient_colour = LikeSecondary(-6.6, 0.16, -0.10); | |
280 | ||
281 | #undef LikePrimary | |
282 | #undef LikeSecondary | |
283 | ||
284 | // Invalidate cached tab separator | |
285 | m_cached_tab_separator_visibility = -1.0; | |
286 | } | |
287 | ||
288 | wxRibbonArtProvider* wxRibbonMSWArtProvider::Clone() const | |
289 | { | |
290 | wxRibbonMSWArtProvider *copy = new wxRibbonMSWArtProvider; | |
291 | CloneTo(copy); | |
292 | return copy; | |
293 | } | |
294 | ||
295 | void wxRibbonMSWArtProvider::CloneTo(wxRibbonMSWArtProvider* copy) const | |
296 | { | |
59c9dd5c JS |
297 | int i; |
298 | for(i = 0; i < 4; ++i) | |
3c3ead1d PC |
299 | { |
300 | copy->m_gallery_up_bitmap[i] = m_gallery_up_bitmap[i]; | |
301 | copy->m_gallery_down_bitmap[i] = m_gallery_down_bitmap[i]; | |
302 | copy->m_gallery_extension_bitmap[i] = m_gallery_extension_bitmap[i]; | |
303 | } | |
59c9dd5c | 304 | for(i = 0; i < 2; ++i) |
0a7ee6e0 VZ |
305 | { |
306 | copy->m_panel_extension_bitmap[i] = m_panel_extension_bitmap[i]; | |
307 | } | |
3c3ead1d PC |
308 | copy->m_toolbar_drop_bitmap = m_toolbar_drop_bitmap; |
309 | ||
310 | copy->m_primary_scheme_colour = m_primary_scheme_colour; | |
311 | copy->m_secondary_scheme_colour = m_secondary_scheme_colour; | |
312 | copy->m_tertiary_scheme_colour = m_tertiary_scheme_colour; | |
313 | ||
314 | copy->m_button_bar_label_colour = m_button_bar_label_colour; | |
315 | copy->m_tab_label_colour = m_tab_label_colour; | |
316 | copy->m_tab_separator_colour = m_tab_separator_colour; | |
317 | copy->m_tab_separator_gradient_colour = m_tab_separator_gradient_colour; | |
318 | copy->m_tab_active_background_colour = m_tab_hover_background_colour; | |
319 | copy->m_tab_active_background_gradient_colour = m_tab_hover_background_gradient_colour; | |
320 | copy->m_tab_hover_background_colour = m_tab_hover_background_colour; | |
321 | copy->m_tab_hover_background_gradient_colour = m_tab_hover_background_gradient_colour; | |
322 | copy->m_tab_hover_background_top_colour = m_tab_hover_background_top_colour; | |
323 | copy->m_tab_hover_background_top_gradient_colour = m_tab_hover_background_top_gradient_colour; | |
324 | copy->m_panel_label_colour = m_panel_label_colour; | |
325 | copy->m_panel_hover_label_colour = m_panel_hover_label_colour; | |
326 | copy->m_panel_minimised_label_colour = m_panel_minimised_label_colour; | |
0a7ee6e0 VZ |
327 | copy->m_panel_button_face_colour = m_panel_button_face_colour; |
328 | copy->m_panel_button_hover_face_colour = m_panel_button_hover_face_colour; | |
3c3ead1d PC |
329 | copy->m_panel_active_background_colour = m_panel_active_background_colour; |
330 | copy->m_panel_active_background_gradient_colour = m_panel_active_background_gradient_colour; | |
331 | copy->m_panel_active_background_top_colour = m_panel_active_background_top_colour; | |
332 | copy->m_panel_active_background_top_gradient_colour = m_panel_active_background_top_gradient_colour; | |
333 | copy->m_page_background_colour = m_page_background_colour; | |
334 | copy->m_page_background_gradient_colour = m_page_background_gradient_colour; | |
335 | copy->m_page_background_top_colour = m_page_background_top_colour; | |
336 | copy->m_page_background_top_gradient_colour = m_page_background_top_gradient_colour; | |
337 | copy->m_page_hover_background_colour = m_page_hover_background_colour; | |
338 | copy->m_page_hover_background_gradient_colour = m_page_hover_background_gradient_colour; | |
339 | copy->m_page_hover_background_top_colour = m_page_hover_background_top_colour; | |
340 | copy->m_page_hover_background_top_gradient_colour = m_page_hover_background_top_gradient_colour; | |
341 | copy->m_button_bar_hover_background_colour = m_button_bar_hover_background_colour; | |
342 | copy->m_button_bar_hover_background_gradient_colour = m_button_bar_hover_background_gradient_colour; | |
343 | copy->m_button_bar_hover_background_top_colour = m_button_bar_hover_background_top_colour; | |
344 | copy->m_button_bar_hover_background_top_gradient_colour = m_button_bar_hover_background_top_gradient_colour; | |
345 | copy->m_button_bar_active_background_colour = m_button_bar_active_background_colour; | |
346 | copy->m_button_bar_active_background_gradient_colour = m_button_bar_active_background_gradient_colour; | |
347 | copy->m_button_bar_active_background_top_colour = m_button_bar_active_background_top_colour; | |
348 | copy->m_button_bar_active_background_top_gradient_colour = m_button_bar_active_background_top_gradient_colour; | |
349 | copy->m_gallery_button_background_colour = m_gallery_button_background_colour; | |
ce00f59b | 350 | copy->m_gallery_button_background_gradient_colour = m_gallery_button_background_gradient_colour; |
3c3ead1d PC |
351 | copy->m_gallery_button_hover_background_colour = m_gallery_button_hover_background_colour; |
352 | copy->m_gallery_button_hover_background_gradient_colour = m_gallery_button_hover_background_gradient_colour; | |
353 | copy->m_gallery_button_active_background_colour = m_gallery_button_active_background_colour; | |
354 | copy->m_gallery_button_active_background_gradient_colour = m_gallery_button_active_background_gradient_colour; | |
355 | copy->m_gallery_button_disabled_background_colour = m_gallery_button_disabled_background_colour; | |
356 | copy->m_gallery_button_disabled_background_gradient_colour = m_gallery_button_disabled_background_gradient_colour; | |
357 | copy->m_gallery_button_face_colour = m_gallery_button_face_colour; | |
358 | copy->m_gallery_button_hover_face_colour = m_gallery_button_hover_face_colour; | |
359 | copy->m_gallery_button_active_face_colour = m_gallery_button_active_face_colour; | |
360 | copy->m_gallery_button_disabled_face_colour = m_gallery_button_disabled_face_colour; | |
361 | ||
362 | copy->m_tab_ctrl_background_brush = m_tab_ctrl_background_brush; | |
363 | copy->m_panel_label_background_brush = m_panel_label_background_brush; | |
364 | copy->m_panel_hover_label_background_brush = m_panel_hover_label_background_brush; | |
0a7ee6e0 | 365 | copy->m_panel_hover_button_background_brush = m_panel_hover_button_background_brush; |
3c3ead1d PC |
366 | copy->m_gallery_hover_background_brush = m_gallery_hover_background_brush; |
367 | copy->m_gallery_button_background_top_brush = m_gallery_button_background_top_brush; | |
368 | copy->m_gallery_button_hover_background_top_brush = m_gallery_button_hover_background_top_brush; | |
369 | copy->m_gallery_button_active_background_top_brush = m_gallery_button_active_background_top_brush; | |
370 | copy->m_gallery_button_disabled_background_top_brush = m_gallery_button_disabled_background_top_brush; | |
371 | ||
372 | copy->m_tab_label_font = m_tab_label_font; | |
373 | copy->m_button_bar_label_font = m_button_bar_label_font; | |
374 | copy->m_panel_label_font = m_panel_label_font; | |
375 | ||
376 | copy->m_page_border_pen = m_page_border_pen; | |
377 | copy->m_panel_border_pen = m_panel_border_pen; | |
378 | copy->m_panel_border_gradient_pen = m_panel_border_gradient_pen; | |
379 | copy->m_panel_minimised_border_pen = m_panel_minimised_border_pen; | |
380 | copy->m_panel_minimised_border_gradient_pen = m_panel_minimised_border_gradient_pen; | |
0a7ee6e0 | 381 | copy->m_panel_hover_button_border_pen = m_panel_hover_button_border_pen; |
3c3ead1d PC |
382 | copy->m_tab_border_pen = m_tab_border_pen; |
383 | copy->m_gallery_border_pen = m_gallery_border_pen; | |
384 | copy->m_button_bar_hover_border_pen = m_button_bar_hover_border_pen; | |
385 | copy->m_button_bar_active_border_pen = m_button_bar_active_border_pen; | |
386 | copy->m_gallery_item_border_pen = m_gallery_item_border_pen; | |
387 | copy->m_toolbar_border_pen = m_toolbar_border_pen; | |
388 | ||
389 | copy->m_flags = m_flags; | |
390 | copy->m_tab_separation_size = m_tab_separation_size; | |
391 | copy->m_page_border_left = m_page_border_left; | |
392 | copy->m_page_border_top = m_page_border_top; | |
393 | copy->m_page_border_right = m_page_border_right; | |
394 | copy->m_page_border_bottom = m_page_border_bottom; | |
395 | copy->m_panel_x_separation_size = m_panel_x_separation_size; | |
396 | copy->m_panel_y_separation_size = m_panel_y_separation_size; | |
397 | copy->m_gallery_bitmap_padding_left_size = m_gallery_bitmap_padding_left_size; | |
398 | copy->m_gallery_bitmap_padding_right_size = m_gallery_bitmap_padding_right_size; | |
399 | copy->m_gallery_bitmap_padding_top_size = m_gallery_bitmap_padding_top_size; | |
400 | copy->m_gallery_bitmap_padding_bottom_size = m_gallery_bitmap_padding_bottom_size; | |
401 | } | |
402 | ||
403 | long wxRibbonMSWArtProvider::GetFlags() const | |
404 | { | |
405 | return m_flags; | |
406 | } | |
407 | ||
408 | void wxRibbonMSWArtProvider::SetFlags(long flags) | |
409 | { | |
410 | if((flags ^ m_flags) & wxRIBBON_BAR_FLOW_VERTICAL) | |
411 | { | |
412 | if(flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
413 | { | |
414 | m_page_border_left++; | |
415 | m_page_border_right++; | |
416 | m_page_border_top--; | |
417 | m_page_border_bottom--; | |
418 | } | |
419 | else | |
420 | { | |
421 | m_page_border_left--; | |
422 | m_page_border_right--; | |
423 | m_page_border_top++; | |
424 | m_page_border_bottom++; | |
425 | } | |
426 | } | |
427 | m_flags = flags; | |
428 | ||
429 | // Need to reload some bitmaps when flags change | |
430 | #define Reload(setting) SetColour(setting, GetColour(setting)) | |
431 | Reload(wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR); | |
432 | Reload(wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR); | |
433 | Reload(wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR); | |
434 | Reload(wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR); | |
0a7ee6e0 VZ |
435 | Reload(wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR); |
436 | Reload(wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR); | |
3c3ead1d PC |
437 | #undef Reload |
438 | } | |
439 | ||
440 | int wxRibbonMSWArtProvider::GetMetric(int id) const | |
441 | { | |
442 | switch(id) | |
443 | { | |
444 | case wxRIBBON_ART_TAB_SEPARATION_SIZE: | |
445 | return m_tab_separation_size; | |
446 | case wxRIBBON_ART_PAGE_BORDER_LEFT_SIZE: | |
447 | return m_page_border_left; | |
448 | case wxRIBBON_ART_PAGE_BORDER_TOP_SIZE: | |
449 | return m_page_border_top; | |
450 | case wxRIBBON_ART_PAGE_BORDER_RIGHT_SIZE: | |
451 | return m_page_border_right; | |
452 | case wxRIBBON_ART_PAGE_BORDER_BOTTOM_SIZE: | |
453 | return m_page_border_bottom; | |
454 | case wxRIBBON_ART_PANEL_X_SEPARATION_SIZE: | |
455 | return m_panel_x_separation_size; | |
456 | case wxRIBBON_ART_PANEL_Y_SEPARATION_SIZE: | |
457 | return m_panel_y_separation_size; | |
458 | case wxRIBBON_ART_TOOL_GROUP_SEPARATION_SIZE: | |
459 | return m_tool_group_separation_size; | |
460 | case wxRIBBON_ART_GALLERY_BITMAP_PADDING_LEFT_SIZE: | |
461 | return m_gallery_bitmap_padding_left_size; | |
462 | case wxRIBBON_ART_GALLERY_BITMAP_PADDING_RIGHT_SIZE: | |
463 | return m_gallery_bitmap_padding_right_size; | |
464 | case wxRIBBON_ART_GALLERY_BITMAP_PADDING_TOP_SIZE: | |
465 | return m_gallery_bitmap_padding_top_size; | |
466 | case wxRIBBON_ART_GALLERY_BITMAP_PADDING_BOTTOM_SIZE: | |
467 | return m_gallery_bitmap_padding_bottom_size; | |
468 | default: | |
469 | wxFAIL_MSG(wxT("Invalid Metric Ordinal")); | |
470 | break; | |
471 | } | |
472 | ||
473 | return 0; | |
474 | } | |
475 | ||
476 | void wxRibbonMSWArtProvider::SetMetric(int id, int new_val) | |
477 | { | |
478 | switch(id) | |
479 | { | |
480 | case wxRIBBON_ART_TAB_SEPARATION_SIZE: | |
481 | m_tab_separation_size = new_val; | |
482 | break; | |
483 | case wxRIBBON_ART_PAGE_BORDER_LEFT_SIZE: | |
484 | m_page_border_left = new_val; | |
485 | break; | |
486 | case wxRIBBON_ART_PAGE_BORDER_TOP_SIZE: | |
487 | m_page_border_top = new_val; | |
488 | break; | |
489 | case wxRIBBON_ART_PAGE_BORDER_RIGHT_SIZE: | |
490 | m_page_border_right = new_val; | |
491 | break; | |
492 | case wxRIBBON_ART_PAGE_BORDER_BOTTOM_SIZE: | |
493 | m_page_border_bottom = new_val; | |
494 | break; | |
495 | case wxRIBBON_ART_PANEL_X_SEPARATION_SIZE: | |
496 | m_panel_x_separation_size = new_val; | |
497 | break; | |
498 | case wxRIBBON_ART_PANEL_Y_SEPARATION_SIZE: | |
499 | m_panel_y_separation_size = new_val; | |
500 | break; | |
501 | case wxRIBBON_ART_TOOL_GROUP_SEPARATION_SIZE: | |
502 | m_tool_group_separation_size = new_val; | |
503 | break; | |
504 | case wxRIBBON_ART_GALLERY_BITMAP_PADDING_LEFT_SIZE: | |
505 | m_gallery_bitmap_padding_left_size = new_val; | |
506 | break; | |
507 | case wxRIBBON_ART_GALLERY_BITMAP_PADDING_RIGHT_SIZE: | |
508 | m_gallery_bitmap_padding_right_size = new_val; | |
509 | break; | |
510 | case wxRIBBON_ART_GALLERY_BITMAP_PADDING_TOP_SIZE: | |
511 | m_gallery_bitmap_padding_top_size = new_val; | |
512 | break; | |
513 | case wxRIBBON_ART_GALLERY_BITMAP_PADDING_BOTTOM_SIZE: | |
514 | m_gallery_bitmap_padding_bottom_size = new_val; | |
515 | break; | |
516 | default: | |
517 | wxFAIL_MSG(wxT("Invalid Metric Ordinal")); | |
518 | break; | |
519 | } | |
520 | } | |
521 | ||
522 | void wxRibbonMSWArtProvider::SetFont(int id, const wxFont& font) | |
523 | { | |
524 | switch(id) | |
525 | { | |
526 | case wxRIBBON_ART_TAB_LABEL_FONT: | |
527 | m_tab_label_font = font; | |
528 | break; | |
529 | case wxRIBBON_ART_BUTTON_BAR_LABEL_FONT: | |
530 | m_button_bar_label_font = font; | |
531 | break; | |
532 | case wxRIBBON_ART_PANEL_LABEL_FONT: | |
533 | m_panel_label_font = font; | |
534 | break; | |
535 | default: | |
536 | wxFAIL_MSG(wxT("Invalid Metric Ordinal")); | |
537 | break; | |
538 | } | |
539 | } | |
540 | ||
541 | wxFont wxRibbonMSWArtProvider::GetFont(int id) const | |
542 | { | |
543 | switch(id) | |
544 | { | |
545 | case wxRIBBON_ART_TAB_LABEL_FONT: | |
546 | return m_tab_label_font; | |
547 | case wxRIBBON_ART_BUTTON_BAR_LABEL_FONT: | |
548 | return m_button_bar_label_font; | |
549 | case wxRIBBON_ART_PANEL_LABEL_FONT: | |
550 | return m_panel_label_font; | |
551 | default: | |
552 | wxFAIL_MSG(wxT("Invalid Metric Ordinal")); | |
553 | break; | |
554 | } | |
555 | ||
556 | return wxNullFont; | |
557 | } | |
558 | ||
559 | wxColour wxRibbonMSWArtProvider::GetColour(int id) const | |
560 | { | |
561 | switch(id) | |
562 | { | |
563 | case wxRIBBON_ART_BUTTON_BAR_LABEL_COLOUR: | |
564 | return m_button_bar_label_colour; | |
565 | case wxRIBBON_ART_BUTTON_BAR_HOVER_BORDER_COLOUR: | |
566 | return m_button_bar_hover_border_pen.GetColour(); | |
567 | case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_COLOUR: | |
568 | return m_button_bar_hover_background_top_colour; | |
569 | case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR: | |
570 | return m_button_bar_hover_background_top_gradient_colour; | |
571 | case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_COLOUR: | |
572 | return m_button_bar_hover_background_colour; | |
573 | case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_GRADIENT_COLOUR: | |
574 | return m_button_bar_hover_background_gradient_colour; | |
575 | case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BORDER_COLOUR: | |
576 | return m_button_bar_active_border_pen.GetColour(); | |
577 | case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_COLOUR: | |
578 | return m_button_bar_active_background_top_colour; | |
579 | case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR: | |
580 | return m_button_bar_active_background_top_gradient_colour; | |
581 | case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_COLOUR: | |
582 | return m_button_bar_active_background_colour; | |
583 | case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_GRADIENT_COLOUR: | |
584 | return m_button_bar_active_background_gradient_colour; | |
585 | case wxRIBBON_ART_GALLERY_BORDER_COLOUR: | |
586 | return m_gallery_border_pen.GetColour(); | |
587 | case wxRIBBON_ART_GALLERY_HOVER_BACKGROUND_COLOUR: | |
588 | return m_gallery_hover_background_brush.GetColour(); | |
589 | case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_COLOUR: | |
590 | return m_gallery_button_background_colour; | |
591 | case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_GRADIENT_COLOUR: | |
592 | return m_gallery_button_background_gradient_colour; | |
593 | case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_TOP_COLOUR: | |
594 | return m_gallery_button_background_top_brush.GetColour(); | |
595 | case wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR: | |
596 | return m_gallery_button_face_colour; | |
597 | case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_COLOUR: | |
598 | return m_gallery_button_hover_background_colour; | |
599 | case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_GRADIENT_COLOUR: | |
600 | return m_gallery_button_hover_background_gradient_colour; | |
601 | case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_TOP_COLOUR: | |
602 | return m_gallery_button_hover_background_top_brush.GetColour(); | |
603 | case wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR: | |
604 | return m_gallery_button_face_colour; | |
605 | case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_COLOUR: | |
606 | return m_gallery_button_active_background_colour; | |
607 | case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_GRADIENT_COLOUR: | |
608 | return m_gallery_button_active_background_gradient_colour; | |
609 | case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_TOP_COLOUR: | |
610 | return m_gallery_button_background_top_brush.GetColour(); | |
611 | case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR: | |
612 | return m_gallery_button_active_face_colour; | |
613 | case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_COLOUR: | |
614 | return m_gallery_button_disabled_background_colour; | |
615 | case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_GRADIENT_COLOUR: | |
616 | return m_gallery_button_disabled_background_gradient_colour; | |
617 | case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_TOP_COLOUR: | |
618 | return m_gallery_button_disabled_background_top_brush.GetColour(); | |
619 | case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR: | |
620 | return m_gallery_button_disabled_face_colour; | |
621 | case wxRIBBON_ART_GALLERY_ITEM_BORDER_COLOUR: | |
622 | return m_gallery_item_border_pen.GetColour(); | |
623 | case wxRIBBON_ART_TAB_CTRL_BACKGROUND_COLOUR: | |
624 | case wxRIBBON_ART_TAB_CTRL_BACKGROUND_GRADIENT_COLOUR: | |
625 | return m_tab_ctrl_background_brush.GetColour(); | |
626 | case wxRIBBON_ART_TAB_LABEL_COLOUR: | |
627 | return m_tab_label_colour; | |
628 | case wxRIBBON_ART_TAB_SEPARATOR_COLOUR: | |
629 | return m_tab_separator_colour; | |
630 | case wxRIBBON_ART_TAB_SEPARATOR_GRADIENT_COLOUR: | |
631 | return m_tab_separator_gradient_colour; | |
632 | case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_COLOUR: | |
633 | case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR: | |
634 | return wxColour(0, 0, 0); | |
635 | case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_COLOUR: | |
636 | return m_tab_active_background_colour; | |
637 | case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_GRADIENT_COLOUR: | |
638 | return m_tab_active_background_gradient_colour; | |
639 | case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_COLOUR: | |
640 | return m_tab_hover_background_top_colour; | |
641 | case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR: | |
642 | return m_tab_hover_background_top_gradient_colour; | |
643 | case wxRIBBON_ART_TAB_HOVER_BACKGROUND_COLOUR: | |
644 | return m_tab_hover_background_colour; | |
645 | case wxRIBBON_ART_TAB_HOVER_BACKGROUND_GRADIENT_COLOUR: | |
646 | return m_tab_hover_background_gradient_colour; | |
647 | case wxRIBBON_ART_TAB_BORDER_COLOUR: | |
648 | return m_tab_border_pen.GetColour(); | |
649 | case wxRIBBON_ART_PANEL_BORDER_COLOUR: | |
650 | return m_panel_border_pen.GetColour(); | |
651 | case wxRIBBON_ART_PANEL_BORDER_GRADIENT_COLOUR: | |
652 | return m_panel_border_gradient_pen.GetColour(); | |
653 | case wxRIBBON_ART_PANEL_MINIMISED_BORDER_COLOUR: | |
654 | return m_panel_minimised_border_pen.GetColour(); | |
655 | case wxRIBBON_ART_PANEL_MINIMISED_BORDER_GRADIENT_COLOUR: | |
656 | return m_panel_minimised_border_gradient_pen.GetColour(); | |
657 | case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_COLOUR: | |
658 | case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_GRADIENT_COLOUR: | |
659 | return m_panel_label_background_brush.GetColour(); | |
660 | case wxRIBBON_ART_PANEL_LABEL_COLOUR: | |
661 | return m_panel_label_colour; | |
662 | case wxRIBBON_ART_PANEL_MINIMISED_LABEL_COLOUR: | |
663 | return m_panel_minimised_label_colour; | |
664 | case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_COLOUR: | |
665 | case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_GRADIENT_COLOUR: | |
666 | return m_panel_hover_label_background_brush.GetColour(); | |
667 | case wxRIBBON_ART_PANEL_HOVER_LABEL_COLOUR: | |
668 | return m_panel_hover_label_colour; | |
669 | case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_COLOUR: | |
670 | return m_panel_active_background_top_colour; | |
671 | case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR: | |
672 | return m_panel_active_background_top_gradient_colour; | |
673 | case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_COLOUR: | |
674 | return m_panel_active_background_colour; | |
675 | case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_GRADIENT_COLOUR: | |
676 | return m_panel_active_background_gradient_colour; | |
0a7ee6e0 VZ |
677 | case wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR: |
678 | return m_panel_button_face_colour; | |
679 | case wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR: | |
680 | return m_panel_button_hover_face_colour; | |
3c3ead1d PC |
681 | case wxRIBBON_ART_PAGE_BORDER_COLOUR: |
682 | return m_page_border_pen.GetColour(); | |
683 | case wxRIBBON_ART_PAGE_BACKGROUND_TOP_COLOUR: | |
684 | return m_page_background_top_colour; | |
685 | case wxRIBBON_ART_PAGE_BACKGROUND_TOP_GRADIENT_COLOUR: | |
686 | return m_page_background_top_gradient_colour; | |
687 | case wxRIBBON_ART_PAGE_BACKGROUND_COLOUR: | |
688 | return m_page_background_colour; | |
689 | case wxRIBBON_ART_PAGE_BACKGROUND_GRADIENT_COLOUR: | |
690 | return m_page_background_gradient_colour; | |
691 | case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_COLOUR: | |
692 | return m_page_hover_background_top_colour; | |
693 | case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR: | |
694 | return m_page_hover_background_top_gradient_colour; | |
695 | case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_COLOUR: | |
696 | return m_page_hover_background_colour; | |
697 | case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_GRADIENT_COLOUR: | |
698 | return m_page_hover_background_gradient_colour; | |
699 | case wxRIBBON_ART_TOOLBAR_BORDER_COLOUR: | |
700 | case wxRIBBON_ART_TOOLBAR_HOVER_BORDER_COLOUR: | |
701 | return m_toolbar_border_pen.GetColour(); | |
702 | case wxRIBBON_ART_TOOLBAR_FACE_COLOUR: | |
703 | return m_tool_face_colour; | |
704 | default: | |
705 | wxFAIL_MSG(wxT("Invalid Metric Ordinal")); | |
706 | break; | |
707 | } | |
708 | ||
709 | return wxColour(); | |
710 | } | |
711 | ||
712 | void wxRibbonMSWArtProvider::SetColour(int id, const wxColor& colour) | |
713 | { | |
714 | switch(id) | |
715 | { | |
716 | case wxRIBBON_ART_BUTTON_BAR_LABEL_COLOUR: | |
717 | m_button_bar_label_colour = colour; | |
718 | break; | |
719 | case wxRIBBON_ART_BUTTON_BAR_HOVER_BORDER_COLOUR: | |
720 | m_button_bar_hover_border_pen.SetColour(colour); | |
721 | break; | |
722 | case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_COLOUR: | |
723 | m_button_bar_hover_background_top_colour = colour; | |
724 | break; | |
725 | case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR: | |
726 | m_button_bar_hover_background_top_gradient_colour = colour; | |
727 | break; | |
728 | case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_COLOUR: | |
729 | m_button_bar_hover_background_colour = colour; | |
730 | break; | |
731 | case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_GRADIENT_COLOUR: | |
732 | m_button_bar_hover_background_gradient_colour = colour; | |
733 | break; | |
734 | case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BORDER_COLOUR: | |
735 | m_button_bar_active_border_pen.SetColour(colour); | |
736 | break; | |
737 | case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_COLOUR: | |
738 | m_button_bar_active_background_top_colour = colour; | |
739 | break; | |
740 | case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR: | |
741 | m_button_bar_active_background_top_gradient_colour = colour; | |
742 | break; | |
743 | case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_COLOUR: | |
744 | m_button_bar_active_background_colour = colour; | |
745 | break; | |
746 | case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_GRADIENT_COLOUR: | |
747 | m_button_bar_active_background_gradient_colour = colour; | |
748 | break; | |
749 | case wxRIBBON_ART_GALLERY_BORDER_COLOUR: | |
750 | m_gallery_border_pen.SetColour(colour); | |
751 | break; | |
752 | case wxRIBBON_ART_GALLERY_HOVER_BACKGROUND_COLOUR: | |
753 | m_gallery_hover_background_brush.SetColour(colour); | |
754 | break; | |
755 | case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_COLOUR: | |
756 | m_gallery_button_background_colour = colour; | |
757 | break; | |
758 | case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_GRADIENT_COLOUR: | |
759 | m_gallery_button_background_gradient_colour = colour; | |
760 | break; | |
761 | case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_TOP_COLOUR: | |
762 | m_gallery_button_background_top_brush.SetColour(colour); | |
763 | break; | |
764 | case wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR: | |
765 | m_gallery_button_face_colour = colour; | |
766 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
767 | { | |
768 | m_gallery_up_bitmap[0] = wxRibbonLoadPixmap(gallery_left_xpm, colour); | |
769 | m_gallery_down_bitmap[0] = wxRibbonLoadPixmap(gallery_right_xpm, colour); | |
770 | } | |
771 | else | |
772 | { | |
773 | m_gallery_up_bitmap[0] = wxRibbonLoadPixmap(gallery_up_xpm, colour); | |
774 | m_gallery_down_bitmap[0] = wxRibbonLoadPixmap(gallery_down_xpm, colour); | |
775 | } | |
776 | m_gallery_extension_bitmap[0] = wxRibbonLoadPixmap(gallery_extension_xpm, colour); | |
777 | break; | |
778 | case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_COLOUR: | |
779 | m_gallery_button_hover_background_colour = colour; | |
780 | break; | |
781 | case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_GRADIENT_COLOUR: | |
782 | m_gallery_button_hover_background_gradient_colour = colour; | |
783 | break; | |
784 | case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_TOP_COLOUR: | |
785 | m_gallery_button_hover_background_top_brush.SetColour(colour); | |
786 | break; | |
787 | case wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR: | |
788 | m_gallery_button_hover_face_colour = colour; | |
789 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
790 | { | |
791 | m_gallery_up_bitmap[1] = wxRibbonLoadPixmap(gallery_left_xpm, colour); | |
792 | m_gallery_down_bitmap[1] = wxRibbonLoadPixmap(gallery_right_xpm, colour); | |
793 | } | |
794 | else | |
795 | { | |
796 | m_gallery_up_bitmap[1] = wxRibbonLoadPixmap(gallery_up_xpm, colour); | |
797 | m_gallery_down_bitmap[1] = wxRibbonLoadPixmap(gallery_down_xpm, colour); | |
798 | } | |
799 | m_gallery_extension_bitmap[1] = wxRibbonLoadPixmap(gallery_extension_xpm, colour); | |
800 | break; | |
801 | case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_COLOUR: | |
802 | m_gallery_button_active_background_colour = colour; | |
803 | break; | |
804 | case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_GRADIENT_COLOUR: | |
805 | m_gallery_button_active_background_gradient_colour = colour; | |
806 | break; | |
807 | case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_TOP_COLOUR: | |
808 | m_gallery_button_background_top_brush.SetColour(colour); | |
809 | break; | |
810 | case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR: | |
811 | m_gallery_button_active_face_colour = colour; | |
812 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
813 | { | |
814 | m_gallery_up_bitmap[2] = wxRibbonLoadPixmap(gallery_left_xpm, colour); | |
815 | m_gallery_down_bitmap[2] = wxRibbonLoadPixmap(gallery_right_xpm, colour); | |
816 | } | |
817 | else | |
818 | { | |
819 | m_gallery_up_bitmap[2] = wxRibbonLoadPixmap(gallery_up_xpm, colour); | |
820 | m_gallery_down_bitmap[2] = wxRibbonLoadPixmap(gallery_down_xpm, colour); | |
821 | } | |
822 | m_gallery_extension_bitmap[2] = wxRibbonLoadPixmap(gallery_extension_xpm, colour); | |
823 | break; | |
824 | case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_COLOUR: | |
825 | m_gallery_button_disabled_background_colour = colour; | |
826 | break; | |
827 | case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_GRADIENT_COLOUR: | |
828 | m_gallery_button_disabled_background_gradient_colour = colour; | |
829 | break; | |
830 | case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_TOP_COLOUR: | |
831 | m_gallery_button_disabled_background_top_brush.SetColour(colour); | |
832 | break; | |
833 | case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR: | |
834 | m_gallery_button_disabled_face_colour = colour; | |
835 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
836 | { | |
837 | m_gallery_up_bitmap[3] = wxRibbonLoadPixmap(gallery_left_xpm, colour); | |
838 | m_gallery_down_bitmap[3] = wxRibbonLoadPixmap(gallery_right_xpm, colour); | |
839 | } | |
840 | else | |
841 | { | |
842 | m_gallery_up_bitmap[3] = wxRibbonLoadPixmap(gallery_up_xpm, colour); | |
843 | m_gallery_down_bitmap[3] = wxRibbonLoadPixmap(gallery_down_xpm, colour); | |
844 | } | |
845 | m_gallery_extension_bitmap[3] = wxRibbonLoadPixmap(gallery_extension_xpm, colour); | |
846 | break; | |
847 | case wxRIBBON_ART_GALLERY_ITEM_BORDER_COLOUR: | |
848 | m_gallery_item_border_pen.SetColour(colour); | |
849 | break; | |
850 | case wxRIBBON_ART_TAB_CTRL_BACKGROUND_COLOUR: | |
851 | case wxRIBBON_ART_TAB_CTRL_BACKGROUND_GRADIENT_COLOUR: | |
852 | m_tab_ctrl_background_brush.SetColour(colour); | |
853 | m_cached_tab_separator_visibility = -1.0; | |
854 | break; | |
855 | case wxRIBBON_ART_TAB_LABEL_COLOUR: | |
856 | m_tab_label_colour = colour; | |
857 | break; | |
858 | case wxRIBBON_ART_TAB_SEPARATOR_COLOUR: | |
859 | m_tab_separator_colour = colour; | |
860 | m_cached_tab_separator_visibility = -1.0; | |
861 | break; | |
862 | case wxRIBBON_ART_TAB_SEPARATOR_GRADIENT_COLOUR: | |
863 | m_tab_separator_gradient_colour = colour; | |
864 | m_cached_tab_separator_visibility = -1.0; | |
865 | break; | |
866 | case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_COLOUR: | |
867 | case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR: | |
868 | break; | |
869 | case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_COLOUR: | |
870 | m_tab_active_background_colour = colour; | |
871 | break; | |
872 | case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_GRADIENT_COLOUR: | |
873 | m_tab_active_background_gradient_colour = colour; | |
874 | break; | |
875 | case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_COLOUR: | |
876 | m_tab_hover_background_top_colour = colour; | |
877 | break; | |
878 | case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR: | |
879 | m_tab_hover_background_top_gradient_colour = colour; | |
880 | break; | |
881 | case wxRIBBON_ART_TAB_HOVER_BACKGROUND_COLOUR: | |
882 | m_tab_hover_background_colour = colour; | |
883 | break; | |
884 | case wxRIBBON_ART_TAB_HOVER_BACKGROUND_GRADIENT_COLOUR: | |
885 | m_tab_hover_background_gradient_colour = colour; | |
886 | break; | |
887 | case wxRIBBON_ART_TAB_BORDER_COLOUR: | |
888 | m_tab_border_pen.SetColour(colour); | |
889 | break; | |
890 | case wxRIBBON_ART_PANEL_BORDER_COLOUR: | |
891 | m_panel_border_pen.SetColour(colour); | |
892 | break; | |
893 | case wxRIBBON_ART_PANEL_BORDER_GRADIENT_COLOUR: | |
894 | m_panel_border_gradient_pen.SetColour(colour); | |
895 | break; | |
896 | case wxRIBBON_ART_PANEL_MINIMISED_BORDER_COLOUR: | |
897 | m_panel_minimised_border_pen.SetColour(colour); | |
898 | break; | |
899 | case wxRIBBON_ART_PANEL_MINIMISED_BORDER_GRADIENT_COLOUR: | |
900 | m_panel_minimised_border_gradient_pen.SetColour(colour); | |
901 | break; | |
902 | case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_COLOUR: | |
903 | case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_GRADIENT_COLOUR: | |
904 | m_panel_label_background_brush.SetColour(colour); | |
905 | break; | |
906 | case wxRIBBON_ART_PANEL_LABEL_COLOUR: | |
907 | m_panel_label_colour = colour; | |
908 | break; | |
909 | case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_COLOUR: | |
910 | case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_GRADIENT_COLOUR: | |
911 | m_panel_hover_label_background_brush.SetColour(colour); | |
912 | break; | |
913 | case wxRIBBON_ART_PANEL_HOVER_LABEL_COLOUR: | |
914 | m_panel_hover_label_colour = colour; | |
915 | break; | |
916 | case wxRIBBON_ART_PANEL_MINIMISED_LABEL_COLOUR: | |
917 | m_panel_minimised_label_colour = colour; | |
918 | break; | |
919 | case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_COLOUR: | |
920 | m_panel_active_background_top_colour = colour; | |
921 | break; | |
922 | case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR: | |
923 | m_panel_active_background_top_gradient_colour = colour; | |
924 | break; | |
925 | case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_COLOUR: | |
926 | m_panel_active_background_colour = colour; | |
927 | break; | |
928 | case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_GRADIENT_COLOUR: | |
929 | m_panel_active_background_gradient_colour = colour; | |
930 | break; | |
0a7ee6e0 VZ |
931 | case wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR: |
932 | m_panel_button_face_colour = colour; | |
933 | m_panel_extension_bitmap[0] = wxRibbonLoadPixmap(panel_extension_xpm, colour); | |
934 | break; | |
935 | case wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR: | |
936 | m_panel_button_hover_face_colour = colour; | |
937 | m_panel_extension_bitmap[1] = wxRibbonLoadPixmap(panel_extension_xpm, colour); | |
938 | break; | |
3c3ead1d PC |
939 | case wxRIBBON_ART_PAGE_BORDER_COLOUR: |
940 | m_page_border_pen.SetColour(colour); | |
941 | break; | |
942 | case wxRIBBON_ART_PAGE_BACKGROUND_TOP_COLOUR: | |
943 | m_page_background_top_colour = colour; | |
944 | break; | |
945 | case wxRIBBON_ART_PAGE_BACKGROUND_TOP_GRADIENT_COLOUR: | |
946 | m_page_background_top_gradient_colour = colour; | |
947 | break; | |
948 | case wxRIBBON_ART_PAGE_BACKGROUND_COLOUR: | |
949 | m_page_background_colour = colour; | |
950 | break; | |
951 | case wxRIBBON_ART_PAGE_BACKGROUND_GRADIENT_COLOUR: | |
952 | m_page_background_gradient_colour = colour; | |
953 | break; | |
954 | case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_COLOUR: | |
955 | m_page_hover_background_top_colour = colour; | |
956 | break; | |
957 | case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR: | |
958 | m_page_hover_background_top_gradient_colour = colour; | |
959 | break; | |
960 | case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_COLOUR: | |
961 | m_page_hover_background_colour = colour; | |
962 | break; | |
963 | case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_GRADIENT_COLOUR: | |
964 | m_page_hover_background_gradient_colour = colour; | |
965 | break; | |
966 | case wxRIBBON_ART_TOOLBAR_BORDER_COLOUR: | |
967 | case wxRIBBON_ART_TOOLBAR_HOVER_BORDER_COLOUR: | |
968 | m_toolbar_border_pen.SetColour(colour); | |
969 | break; | |
970 | case wxRIBBON_ART_TOOLBAR_FACE_COLOUR: | |
971 | m_tool_face_colour = colour; | |
972 | m_toolbar_drop_bitmap = wxRibbonLoadPixmap(gallery_down_xpm, colour); | |
973 | break; | |
974 | default: | |
975 | wxFAIL_MSG(wxT("Invalid Metric Ordinal")); | |
976 | break; | |
977 | } | |
978 | } | |
979 | ||
980 | void wxRibbonMSWArtProvider::DrawTabCtrlBackground( | |
981 | wxDC& dc, | |
982 | wxWindow* WXUNUSED(wnd), | |
983 | const wxRect& rect) | |
984 | { | |
985 | dc.SetPen(*wxTRANSPARENT_PEN); | |
986 | dc.SetBrush(m_tab_ctrl_background_brush); | |
987 | dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height); | |
988 | ||
989 | dc.SetPen(m_page_border_pen); | |
990 | if(rect.width > 6) | |
991 | { | |
992 | dc.DrawLine(rect.x + 3, rect.y + rect.height - 1, rect.x + rect.width - 3, rect.y + rect.height - 1); | |
993 | } | |
994 | else | |
995 | { | |
996 | dc.DrawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width, rect.y + rect.height - 1); | |
997 | } | |
998 | } | |
999 | ||
1000 | void wxRibbonMSWArtProvider::DrawTab( | |
1001 | wxDC& dc, | |
1002 | wxWindow* WXUNUSED(wnd), | |
1003 | const wxRibbonPageTabInfo& tab) | |
1004 | { | |
1005 | if(tab.rect.height <= 2) | |
1006 | return; | |
1007 | ||
1008 | if(tab.active || tab.hovered) | |
1009 | { | |
1010 | if(tab.active) | |
1011 | { | |
1012 | wxRect background(tab.rect); | |
1013 | ||
1014 | background.x += 2; | |
1015 | background.y += 2; | |
1016 | background.width -= 4; | |
1017 | background.height -= 2; | |
1018 | ||
1019 | dc.GradientFillLinear(background, m_tab_active_background_colour, | |
1020 | m_tab_active_background_gradient_colour, wxSOUTH); | |
1021 | ||
1022 | // TODO: active and hovered | |
1023 | } | |
1024 | else if(tab.hovered) | |
1025 | { | |
1026 | wxRect background(tab.rect); | |
1027 | ||
1028 | background.x += 2; | |
1029 | background.y += 2; | |
1030 | background.width -= 4; | |
1031 | background.height -= 3; | |
1032 | int h = background.height; | |
1033 | background.height /= 2; | |
1034 | dc.GradientFillLinear(background, | |
1035 | m_tab_hover_background_top_colour, | |
1036 | m_tab_hover_background_top_gradient_colour, wxSOUTH); | |
1037 | ||
1038 | background.y += background.height; | |
1039 | background.height = h - background.height; | |
1040 | dc.GradientFillLinear(background, m_tab_hover_background_colour, | |
1041 | m_tab_hover_background_gradient_colour, wxSOUTH); | |
1042 | } | |
1043 | ||
1044 | wxPoint border_points[6]; | |
1045 | border_points[0] = wxPoint(1, tab.rect.height - 2); | |
1046 | border_points[1] = wxPoint(1, 3); | |
1047 | border_points[2] = wxPoint(3, 1); | |
1048 | border_points[3] = wxPoint(tab.rect.width - 4, 1); | |
1049 | border_points[4] = wxPoint(tab.rect.width - 2, 3); | |
1050 | border_points[5] = wxPoint(tab.rect.width - 2, tab.rect.height - 1); | |
1051 | ||
1052 | dc.SetPen(m_tab_border_pen); | |
1053 | dc.DrawLines(sizeof(border_points)/sizeof(wxPoint), border_points, tab.rect.x, tab.rect.y); | |
1054 | ||
1055 | if(tab.active) | |
1056 | { | |
1057 | // Give the tab a curved outward border at the bottom | |
1058 | dc.DrawPoint(tab.rect.x, tab.rect.y + tab.rect.height - 2); | |
1059 | dc.DrawPoint(tab.rect.x + tab.rect.width - 1, tab.rect.y + tab.rect.height - 2); | |
1060 | ||
1061 | wxPen p(m_tab_active_background_gradient_colour); | |
1062 | dc.SetPen(p); | |
1063 | ||
1064 | // Technically the first two points are the wrong colour, but they're near enough | |
1065 | dc.DrawPoint(tab.rect.x + 1, tab.rect.y + tab.rect.height - 2); | |
1066 | dc.DrawPoint(tab.rect.x + tab.rect.width - 2, tab.rect.y + tab.rect.height - 2); | |
1067 | dc.DrawPoint(tab.rect.x + 1, tab.rect.y + tab.rect.height - 1); | |
1068 | dc.DrawPoint(tab.rect.x, tab.rect.y + tab.rect.height - 1); | |
1069 | dc.DrawPoint(tab.rect.x + tab.rect.width - 2, tab.rect.y + tab.rect.height - 1); | |
1070 | dc.DrawPoint(tab.rect.x + tab.rect.width - 1, tab.rect.y + tab.rect.height - 1); | |
1071 | } | |
1072 | } | |
1073 | ||
1074 | if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS) | |
1075 | { | |
1076 | wxBitmap icon = tab.page->GetIcon(); | |
f6ac1f4b RR |
1077 | if(icon.IsOk()) |
1078 | { | |
3c3ead1d PC |
1079 | int x = tab.rect.x + 4; |
1080 | if((m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) == 0) | |
1081 | x = tab.rect.x + (tab.rect.width - icon.GetWidth()) / 2; | |
1082 | dc.DrawBitmap(icon, x, tab.rect.y + 1 + (tab.rect.height - 1 - | |
1083 | icon.GetHeight()) / 2, true); | |
f6ac1f4b | 1084 | } |
3c3ead1d PC |
1085 | } |
1086 | if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) | |
1087 | { | |
1088 | wxString label = tab.page->GetLabel(); | |
1089 | if(!label.IsEmpty()) | |
1090 | { | |
1091 | dc.SetFont(m_tab_label_font); | |
1092 | dc.SetTextForeground(m_tab_label_colour); | |
1093 | dc.SetBackgroundMode(wxTRANSPARENT); | |
1094 | ||
1095 | int text_height; | |
1096 | int text_width; | |
1097 | dc.GetTextExtent(label, &text_width, &text_height); | |
1098 | int width = tab.rect.width - 5; | |
1099 | int x = tab.rect.x + 3; | |
1100 | if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS) | |
1101 | { | |
1102 | x += 3 + tab.page->GetIcon().GetWidth(); | |
1103 | width -= 3 + tab.page->GetIcon().GetWidth(); | |
1104 | } | |
1105 | int y = tab.rect.y + (tab.rect.height - text_height) / 2; | |
1106 | ||
1107 | if(width <= text_width) | |
1108 | { | |
1109 | dc.SetClippingRegion(x, tab.rect.y, width, tab.rect.height); | |
1110 | dc.DrawText(label, x, y); | |
1111 | } | |
1112 | else | |
1113 | { | |
1114 | dc.DrawText(label, x + (width - text_width) / 2 + 1, y); | |
1115 | } | |
1116 | } | |
1117 | } | |
1118 | } | |
1119 | ||
1120 | void wxRibbonMSWArtProvider::DrawTabSeparator( | |
1121 | wxDC& dc, | |
1122 | wxWindow* wnd, | |
1123 | const wxRect& rect, | |
1124 | double visibility) | |
1125 | { | |
1126 | if(visibility <= 0.0) | |
1127 | { | |
1128 | return; | |
1129 | } | |
1130 | if(visibility > 1.0) | |
1131 | { | |
1132 | visibility = 1.0; | |
1133 | } | |
1134 | ||
1135 | // The tab separator is relatively expensive to draw (for its size), and is | |
1136 | // usually drawn multiple times sequentially (in different positions), so it | |
1137 | // makes sense to draw it once and cache it. | |
1138 | if(!m_cached_tab_separator.IsOk() || m_cached_tab_separator.GetSize() != rect.GetSize() || visibility != m_cached_tab_separator_visibility) | |
1139 | { | |
1140 | wxRect size(rect.GetSize()); | |
1141 | ReallyDrawTabSeparator(wnd, size, visibility); | |
1142 | } | |
1143 | dc.DrawBitmap(m_cached_tab_separator, rect.x, rect.y, false); | |
1144 | } | |
1145 | ||
1146 | void wxRibbonMSWArtProvider::ReallyDrawTabSeparator(wxWindow* wnd, const wxRect& rect, double visibility) | |
1147 | { | |
1148 | if(!m_cached_tab_separator.IsOk() || m_cached_tab_separator.GetSize() != rect.GetSize()) | |
1149 | { | |
1150 | m_cached_tab_separator = wxBitmap(rect.GetSize()); | |
1151 | } | |
1152 | ||
1153 | wxMemoryDC dc(m_cached_tab_separator); | |
1154 | DrawTabCtrlBackground(dc, wnd, rect); | |
1155 | ||
1156 | wxCoord x = rect.x + rect.width / 2; | |
1157 | double h = (double)(rect.height - 1); | |
1158 | ||
1159 | double r1 = m_tab_ctrl_background_brush.GetColour().Red() * (1.0 - visibility) + 0.5; | |
1160 | double g1 = m_tab_ctrl_background_brush.GetColour().Green() * (1.0 - visibility) + 0.5; | |
1161 | double b1 = m_tab_ctrl_background_brush.GetColour().Blue() * (1.0 - visibility) + 0.5; | |
1162 | double r2 = m_tab_separator_colour.Red(); | |
1163 | double g2 = m_tab_separator_colour.Green(); | |
1164 | double b2 = m_tab_separator_colour.Blue(); | |
1165 | double r3 = m_tab_separator_gradient_colour.Red(); | |
1166 | double g3 = m_tab_separator_gradient_colour.Green(); | |
1167 | double b3 = m_tab_separator_gradient_colour.Blue(); | |
1168 | ||
1169 | for(int i = 0; i < rect.height - 1; ++i) | |
1170 | { | |
1171 | double p = ((double)i)/h; | |
1172 | ||
1173 | double r = (p * r3 + (1.0 - p) * r2) * visibility + r1; | |
1174 | double g = (p * g3 + (1.0 - p) * g2) * visibility + g1; | |
1175 | double b = (p * b3 + (1.0 - p) * b2) * visibility + b1; | |
1176 | ||
1177 | wxPen P(wxColour((unsigned char)r, (unsigned char)g, (unsigned char)b)); | |
1178 | dc.SetPen(P); | |
1179 | dc.DrawPoint(x, rect.y + i); | |
1180 | } | |
1181 | ||
1182 | m_cached_tab_separator_visibility = visibility; | |
1183 | } | |
1184 | ||
1185 | void wxRibbonMSWArtProvider::DrawPartialPageBackground(wxDC& dc, | |
140091e5 | 1186 | wxWindow* wnd, const wxRect& rect, wxRibbonPage* page, |
3c3ead1d PC |
1187 | wxPoint offset, bool hovered) |
1188 | { | |
140091e5 PC |
1189 | wxRect background; |
1190 | // Expanded panels need a background - the expanded panel at | |
59c9dd5c | 1191 | // best size may have a greater Y dimension higher than when |
140091e5 PC |
1192 | // on the bar if it has a sizer. AUI art provider does not need this |
1193 | // because it paints the panel without reference to its parent's size. | |
59c9dd5c | 1194 | // Expanded panels use a wxFrame as parent (not a wxRibbonPage). |
140091e5 PC |
1195 | |
1196 | if(wnd->GetSizer() && wnd->GetParent() != page) | |
1197 | { | |
1198 | background = wnd->GetParent()->GetSize(); | |
1199 | offset = wxPoint(0,0); | |
1200 | } | |
1201 | else | |
1202 | { | |
1203 | background = page->GetSize(); | |
1204 | page->AdjustRectToIncludeScrollButtons(&background); | |
1205 | background.height -= 2; | |
1206 | } | |
3c3ead1d PC |
1207 | // Page background isn't dependant upon the width of the page |
1208 | // (at least not the part of it intended to be painted by this | |
1209 | // function). Set to wider than the page itself for when externally | |
1210 | // expanded panels need a background - the expanded panel can be wider | |
1211 | // than the bar. | |
1212 | background.x = 0; | |
1213 | background.width = INT_MAX; | |
1214 | ||
1215 | // upper_rect, lower_rect, paint_rect are all in page co-ordinates | |
1216 | wxRect upper_rect(background); | |
1217 | upper_rect.height /= 5; | |
1218 | ||
1219 | wxRect lower_rect(background); | |
1220 | lower_rect.y += upper_rect.height; | |
1221 | lower_rect.height -= upper_rect.height; | |
1222 | ||
1223 | wxRect paint_rect(rect); | |
1224 | paint_rect.x += offset.x; | |
1225 | paint_rect.y += offset.y; | |
1226 | ||
1227 | wxColour bg_top, bg_top_grad, bg_btm, bg_btm_grad; | |
1228 | if(hovered) | |
1229 | { | |
1230 | bg_top = m_page_hover_background_top_colour; | |
1231 | bg_top_grad = m_page_hover_background_top_gradient_colour; | |
1232 | bg_btm = m_page_hover_background_colour; | |
1233 | bg_btm_grad = m_page_hover_background_gradient_colour; | |
1234 | } | |
1235 | else | |
1236 | { | |
1237 | bg_top = m_page_background_top_colour; | |
1238 | bg_top_grad = m_page_background_top_gradient_colour; | |
1239 | bg_btm = m_page_background_colour; | |
1240 | bg_btm_grad = m_page_background_gradient_colour; | |
1241 | } | |
1242 | ||
1243 | if(paint_rect.Intersects(upper_rect)) | |
1244 | { | |
1245 | wxRect rect(upper_rect); | |
1246 | rect.Intersect(paint_rect); | |
1247 | rect.x -= offset.x; | |
1248 | rect.y -= offset.y; | |
1249 | wxColour starting_colour(wxRibbonInterpolateColour(bg_top, bg_top_grad, | |
1250 | paint_rect.y, upper_rect.y, upper_rect.y + upper_rect.height)); | |
1251 | wxColour ending_colour(wxRibbonInterpolateColour(bg_top, bg_top_grad, | |
1252 | paint_rect.y + paint_rect.height, upper_rect.y, | |
1253 | upper_rect.y + upper_rect.height)); | |
1254 | dc.GradientFillLinear(rect, starting_colour, ending_colour, wxSOUTH); | |
1255 | } | |
1256 | ||
1257 | if(paint_rect.Intersects(lower_rect)) | |
1258 | { | |
1259 | wxRect rect(lower_rect); | |
1260 | rect.Intersect(paint_rect); | |
1261 | rect.x -= offset.x; | |
1262 | rect.y -= offset.y; | |
1263 | wxColour starting_colour(wxRibbonInterpolateColour(bg_btm, bg_btm_grad, | |
1264 | paint_rect.y, lower_rect.y, lower_rect.y + lower_rect.height)); | |
1265 | wxColour ending_colour(wxRibbonInterpolateColour(bg_btm, bg_btm_grad, | |
1266 | paint_rect.y + paint_rect.height, | |
1267 | lower_rect.y, lower_rect.y + lower_rect.height)); | |
1268 | dc.GradientFillLinear(rect, starting_colour, ending_colour, wxSOUTH); | |
1269 | } | |
1270 | } | |
1271 | ||
1272 | void wxRibbonMSWArtProvider::DrawPageBackground( | |
1273 | wxDC& dc, | |
1274 | wxWindow* WXUNUSED(wnd), | |
1275 | const wxRect& rect) | |
1276 | { | |
1277 | dc.SetPen(*wxTRANSPARENT_PEN); | |
1278 | dc.SetBrush(m_tab_ctrl_background_brush); | |
1279 | ||
1280 | { | |
1281 | wxRect edge(rect); | |
1282 | ||
1283 | edge.width = 2; | |
1284 | dc.DrawRectangle(edge.x, edge.y, edge.width, edge.height); | |
1285 | ||
1286 | edge.x += rect.width - 2; | |
1287 | dc.DrawRectangle(edge.x, edge.y, edge.width, edge.height); | |
1288 | ||
1289 | edge = rect; | |
1290 | edge.height = 2; | |
1291 | edge.y += (rect.height - edge.height); | |
1292 | dc.DrawRectangle(edge.x, edge.y, edge.width, edge.height); | |
1293 | } | |
1294 | ||
1295 | { | |
1296 | wxRect background(rect); | |
1297 | background.x += 2; | |
1298 | background.width -= 4; | |
1299 | background.height -= 2; | |
1300 | ||
1301 | background.height /= 5; | |
1302 | dc.GradientFillLinear(background, m_page_background_top_colour, | |
1303 | m_page_background_top_gradient_colour, wxSOUTH); | |
1304 | ||
1305 | background.y += background.height; | |
1306 | background.height = rect.height - 2 - background.height; | |
1307 | dc.GradientFillLinear(background, m_page_background_colour, | |
1308 | m_page_background_gradient_colour, wxSOUTH); | |
1309 | } | |
1310 | ||
1311 | { | |
1312 | wxPoint border_points[8]; | |
1313 | border_points[0] = wxPoint(2, 0); | |
1314 | border_points[1] = wxPoint(1, 1); | |
1315 | border_points[2] = wxPoint(1, rect.height - 4); | |
1316 | border_points[3] = wxPoint(3, rect.height - 2); | |
1317 | border_points[4] = wxPoint(rect.width - 4, rect.height - 2); | |
1318 | border_points[5] = wxPoint(rect.width - 2, rect.height - 4); | |
1319 | border_points[6] = wxPoint(rect.width - 2, 1); | |
1320 | border_points[7] = wxPoint(rect.width - 4, -1); | |
1321 | ||
1322 | dc.SetPen(m_page_border_pen); | |
1323 | dc.DrawLines(sizeof(border_points)/sizeof(wxPoint), border_points, rect.x, rect.y); | |
1324 | } | |
1325 | } | |
1326 | ||
1327 | void wxRibbonMSWArtProvider::DrawScrollButton( | |
1328 | wxDC& dc, | |
1329 | wxWindow* WXUNUSED(wnd), | |
1330 | const wxRect& rect_, | |
1331 | long style) | |
1332 | { | |
1333 | wxRect rect(rect_); | |
1334 | ||
1335 | if((style & wxRIBBON_SCROLL_BTN_FOR_MASK) == wxRIBBON_SCROLL_BTN_FOR_PAGE) | |
1336 | { | |
1337 | // Page scroll buttons do not have the luxury of rendering on top of anything | |
1338 | // else, and their size includes some padding, hence the background painting | |
1339 | // and size adjustment. | |
1340 | dc.SetPen(*wxTRANSPARENT_PEN); | |
1341 | dc.SetBrush(m_tab_ctrl_background_brush); | |
1342 | dc.DrawRectangle(rect); | |
1343 | dc.SetClippingRegion(rect); | |
1344 | switch(style & wxRIBBON_SCROLL_BTN_DIRECTION_MASK) | |
1345 | { | |
1346 | case wxRIBBON_SCROLL_BTN_LEFT: | |
1347 | rect.x++; | |
1348 | case wxRIBBON_SCROLL_BTN_RIGHT: | |
1349 | rect.y--; | |
1350 | rect.width--; | |
1351 | break; | |
1352 | case wxRIBBON_SCROLL_BTN_UP: | |
1353 | rect.x++; | |
1354 | rect.y--; | |
1355 | rect.width -= 2; | |
1356 | rect.height++; | |
1357 | break; | |
1358 | case wxRIBBON_SCROLL_BTN_DOWN: | |
1359 | rect.x++; | |
1360 | rect.width -= 2; | |
1361 | rect.height--; | |
1362 | break; | |
1363 | } | |
1364 | } | |
1365 | ||
1366 | { | |
1367 | wxRect background(rect); | |
1368 | background.x++; | |
1369 | background.y++; | |
1370 | background.width -= 2; | |
1371 | background.height -= 2; | |
1372 | ||
1373 | if(style & wxRIBBON_SCROLL_BTN_UP) | |
1374 | background.height /= 2; | |
1375 | else | |
1376 | background.height /= 5; | |
1377 | dc.GradientFillLinear(background, m_page_background_top_colour, | |
1378 | m_page_background_top_gradient_colour, wxSOUTH); | |
1379 | ||
1380 | background.y += background.height; | |
1381 | background.height = rect.height - 2 - background.height; | |
1382 | dc.GradientFillLinear(background, m_page_background_colour, | |
1383 | m_page_background_gradient_colour, wxSOUTH); | |
1384 | } | |
1385 | ||
1386 | { | |
1387 | wxPoint border_points[7]; | |
1388 | switch(style & wxRIBBON_SCROLL_BTN_DIRECTION_MASK) | |
1389 | { | |
1390 | case wxRIBBON_SCROLL_BTN_LEFT: | |
1391 | border_points[0] = wxPoint(2, 0); | |
1392 | border_points[1] = wxPoint(rect.width - 1, 0); | |
1393 | border_points[2] = wxPoint(rect.width - 1, rect.height - 1); | |
1394 | border_points[3] = wxPoint(2, rect.height - 1); | |
1395 | border_points[4] = wxPoint(0, rect.height - 3); | |
1396 | border_points[5] = wxPoint(0, 2); | |
1397 | break; | |
1398 | case wxRIBBON_SCROLL_BTN_RIGHT: | |
1399 | border_points[0] = wxPoint(0, 0); | |
1400 | border_points[1] = wxPoint(rect.width - 3, 0); | |
1401 | border_points[2] = wxPoint(rect.width - 1, 2); | |
1402 | border_points[3] = wxPoint(rect.width - 1, rect.height - 3); | |
1403 | border_points[4] = wxPoint(rect.width - 3, rect.height - 1); | |
1404 | border_points[5] = wxPoint(0, rect.height - 1); | |
1405 | break; | |
1406 | case wxRIBBON_SCROLL_BTN_UP: | |
1407 | border_points[0] = wxPoint(2, 0); | |
1408 | border_points[1] = wxPoint(rect.width - 3, 0); | |
1409 | border_points[2] = wxPoint(rect.width - 1, 2); | |
1410 | border_points[3] = wxPoint(rect.width - 1, rect.height - 1); | |
1411 | border_points[4] = wxPoint(0, rect.height - 1); | |
1412 | border_points[5] = wxPoint(0, 2); | |
1413 | break; | |
1414 | case wxRIBBON_SCROLL_BTN_DOWN: | |
1415 | border_points[0] = wxPoint(0, 0); | |
1416 | border_points[1] = wxPoint(rect.width - 1, 0); | |
1417 | border_points[2] = wxPoint(rect.width - 1, rect.height - 3); | |
1418 | border_points[3] = wxPoint(rect.width - 3, rect.height - 1); | |
1419 | border_points[4] = wxPoint(2, rect.height - 1); | |
1420 | border_points[5] = wxPoint(0, rect.height - 3); | |
1421 | break; | |
1422 | } | |
1423 | border_points[6] = border_points[0]; | |
1424 | ||
1425 | dc.SetPen(m_page_border_pen); | |
1426 | dc.DrawLines(sizeof(border_points)/sizeof(wxPoint), border_points, rect.x, rect.y); | |
1427 | } | |
1428 | ||
1429 | { | |
1430 | // NB: Code for handling hovered/active state is temporary | |
1431 | wxPoint arrow_points[3]; | |
1432 | switch(style & wxRIBBON_SCROLL_BTN_DIRECTION_MASK) | |
1433 | { | |
1434 | case wxRIBBON_SCROLL_BTN_LEFT: | |
1435 | arrow_points[0] = wxPoint(rect.width / 2 - 2, rect.height / 2); | |
1436 | if(style & wxRIBBON_SCROLL_BTN_ACTIVE) | |
1437 | arrow_points[0].y += 1; | |
1438 | arrow_points[1] = arrow_points[0] + wxPoint(3, -3); | |
1439 | arrow_points[2] = arrow_points[0] + wxPoint(3, 3); | |
1440 | break; | |
1441 | case wxRIBBON_SCROLL_BTN_RIGHT: | |
1442 | arrow_points[0] = wxPoint(rect.width / 2 + 2, rect.height / 2); | |
1443 | if(style & wxRIBBON_SCROLL_BTN_ACTIVE) | |
1444 | arrow_points[0].y += 1; | |
1445 | arrow_points[1] = arrow_points[0] - wxPoint(3, 3); | |
1446 | arrow_points[2] = arrow_points[0] - wxPoint(3, -3); | |
1447 | break; | |
1448 | case wxRIBBON_SCROLL_BTN_UP: | |
1449 | arrow_points[0] = wxPoint(rect.width / 2, rect.height / 2 - 2); | |
1450 | if(style & wxRIBBON_SCROLL_BTN_ACTIVE) | |
1451 | arrow_points[0].y += 1; | |
1452 | arrow_points[1] = arrow_points[0] + wxPoint( 3, 3); | |
1453 | arrow_points[2] = arrow_points[0] + wxPoint(-3, 3); | |
1454 | break; | |
1455 | case wxRIBBON_SCROLL_BTN_DOWN: | |
1456 | arrow_points[0] = wxPoint(rect.width / 2, rect.height / 2 + 2); | |
1457 | if(style & wxRIBBON_SCROLL_BTN_ACTIVE) | |
1458 | arrow_points[0].y += 1; | |
1459 | arrow_points[1] = arrow_points[0] - wxPoint( 3, 3); | |
1460 | arrow_points[2] = arrow_points[0] - wxPoint(-3, 3); | |
1461 | break; | |
1462 | } | |
1463 | ||
1464 | dc.SetPen(*wxTRANSPARENT_PEN); | |
1465 | wxBrush B(style & wxRIBBON_SCROLL_BTN_HOVERED ? m_tab_active_background_colour : m_tab_label_colour); | |
1466 | dc.SetBrush(B); | |
1467 | dc.DrawPolygon(sizeof(arrow_points)/sizeof(wxPoint), arrow_points, rect.x, rect.y); | |
1468 | } | |
1469 | } | |
1470 | ||
1471 | void wxRibbonMSWArtProvider::DrawDropdownArrow(wxDC& dc, int x, int y, const wxColour& colour) | |
1472 | { | |
1473 | wxPoint arrow_points[3]; | |
1474 | wxBrush brush(colour); | |
1475 | arrow_points[0] = wxPoint(1, 2); | |
1476 | arrow_points[1] = arrow_points[0] + wxPoint(-3, -3); | |
1477 | arrow_points[2] = arrow_points[0] + wxPoint( 3, -3); | |
1478 | dc.SetPen(*wxTRANSPARENT_PEN); | |
1479 | dc.SetBrush(brush); | |
1480 | dc.DrawPolygon(sizeof(arrow_points)/sizeof(wxPoint), arrow_points, x, y); | |
1481 | } | |
1482 | ||
1483 | void wxRibbonMSWArtProvider::RemovePanelPadding(wxRect* rect) | |
1484 | { | |
1485 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
1486 | { | |
1487 | rect->y += 1; | |
1488 | rect->height -= 2; | |
1489 | } | |
1490 | else | |
1491 | { | |
1492 | rect->x += 1; | |
1493 | rect->width -= 2; | |
1494 | } | |
1495 | } | |
1496 | ||
1497 | void wxRibbonMSWArtProvider::DrawPanelBackground( | |
1498 | wxDC& dc, | |
1499 | wxRibbonPanel* wnd, | |
1500 | const wxRect& rect) | |
1501 | { | |
1502 | DrawPartialPageBackground(dc, wnd, rect, false); | |
1503 | ||
1504 | wxRect true_rect(rect); | |
1505 | RemovePanelPadding(&true_rect); | |
0a7ee6e0 | 1506 | bool has_ext_button = wnd->HasExtButton(); |
3c3ead1d PC |
1507 | |
1508 | int label_height; | |
1509 | { | |
1510 | dc.SetFont(m_panel_label_font); | |
1511 | dc.SetPen(*wxTRANSPARENT_PEN); | |
1512 | if(wnd->IsHovered()) | |
1513 | { | |
1514 | dc.SetBrush(m_panel_hover_label_background_brush); | |
1515 | dc.SetTextForeground(m_panel_hover_label_colour); | |
1516 | } | |
1517 | else | |
1518 | { | |
1519 | dc.SetBrush(m_panel_label_background_brush); | |
1520 | dc.SetTextForeground(m_panel_label_colour); | |
1521 | } | |
1522 | ||
1523 | wxRect label_rect(true_rect); | |
1524 | wxString label = wnd->GetLabel(); | |
1525 | bool clip_label = false; | |
1526 | wxSize label_size(dc.GetTextExtent(label)); | |
1527 | ||
1528 | label_rect.SetX(label_rect.GetX() + 1); | |
1529 | label_rect.SetWidth(label_rect.GetWidth() - 2); | |
1530 | label_rect.SetHeight(label_size.GetHeight() + 2); | |
1531 | label_rect.SetY(true_rect.GetBottom() - label_rect.GetHeight()); | |
1532 | label_height = label_rect.GetHeight(); | |
1533 | ||
0a7ee6e0 VZ |
1534 | wxRect label_bg_rect = label_rect; |
1535 | ||
1536 | if(has_ext_button) | |
1537 | label_rect.SetWidth(label_rect.GetWidth() - 13); | |
1538 | ||
3c3ead1d PC |
1539 | if(label_size.GetWidth() > label_rect.GetWidth()) |
1540 | { | |
1541 | // Test if there is enough length for 3 letters and ... | |
1542 | wxString new_label = label.Mid(0, 3) + wxT("..."); | |
1543 | label_size = dc.GetTextExtent(new_label); | |
1544 | if(label_size.GetWidth() > label_rect.GetWidth()) | |
1545 | { | |
1546 | // Not enough room for three characters and ... | |
1547 | // Display the entire label and just crop it | |
1548 | clip_label = true; | |
1549 | } | |
1550 | else | |
1551 | { | |
1552 | // Room for some characters and ... | |
1553 | // Display as many characters as possible and append ... | |
1554 | for(size_t len = label.Len() - 1; len >= 3; --len) | |
1555 | { | |
1556 | new_label = label.Mid(0, len) + wxT("..."); | |
1557 | label_size = dc.GetTextExtent(new_label); | |
1558 | if(label_size.GetWidth() <= label_rect.GetWidth()) | |
1559 | { | |
1560 | label = new_label; | |
1561 | break; | |
1562 | } | |
1563 | } | |
1564 | } | |
1565 | } | |
1566 | ||
0a7ee6e0 | 1567 | dc.DrawRectangle(label_bg_rect); |
3c3ead1d PC |
1568 | if(clip_label) |
1569 | { | |
1570 | wxDCClipper clip(dc, label_rect); | |
1571 | dc.DrawText(label, label_rect.x, label_rect.y + | |
1572 | (label_rect.GetHeight() - label_size.GetHeight()) / 2); | |
1573 | } | |
1574 | else | |
1575 | { | |
1576 | dc.DrawText(label, label_rect.x + | |
1577 | (label_rect.GetWidth() - label_size.GetWidth()) / 2, | |
1578 | label_rect.y + | |
1579 | (label_rect.GetHeight() - label_size.GetHeight()) / 2); | |
1580 | } | |
0a7ee6e0 VZ |
1581 | |
1582 | if(has_ext_button) | |
1583 | { | |
1584 | if(wnd->IsExtButtonHovered()) | |
1585 | { | |
1586 | dc.SetPen(m_panel_hover_button_border_pen); | |
1587 | dc.SetBrush(m_panel_hover_button_background_brush); | |
1588 | dc.DrawRoundedRectangle(label_rect.GetRight(), label_rect.GetBottom() - 13, 13, 13, 1.0); | |
1589 | dc.DrawBitmap(m_panel_extension_bitmap[1], label_rect.GetRight() + 3, label_rect.GetBottom() - 10, true); | |
1590 | } | |
1591 | else | |
1592 | dc.DrawBitmap(m_panel_extension_bitmap[0], label_rect.GetRight() + 3, label_rect.GetBottom() - 10, true); | |
1593 | } | |
3c3ead1d PC |
1594 | } |
1595 | ||
1596 | if(wnd->IsHovered()) | |
1597 | { | |
1598 | wxRect client_rect(true_rect); | |
1599 | client_rect.x++; | |
1600 | client_rect.width -= 2; | |
1601 | client_rect.y++; | |
1602 | client_rect.height -= 2 + label_height; | |
1603 | DrawPartialPageBackground(dc, wnd, client_rect, true); | |
1604 | } | |
1605 | ||
1606 | DrawPanelBorder(dc, true_rect, m_panel_border_pen, m_panel_border_gradient_pen); | |
1607 | } | |
1608 | ||
0a7ee6e0 VZ |
1609 | wxRect wxRibbonMSWArtProvider::GetPanelExtButtonArea(wxDC& WXUNUSED(dc), |
1610 | const wxRibbonPanel* WXUNUSED(wnd), | |
1611 | wxRect rect) | |
1612 | { | |
1613 | RemovePanelPadding(&rect); | |
1614 | rect = wxRect(rect.GetRight()-13, rect.GetBottom()-13, 13, 13); | |
1615 | return rect; | |
1616 | } | |
1617 | ||
3c3ead1d PC |
1618 | void wxRibbonMSWArtProvider::DrawGalleryBackground( |
1619 | wxDC& dc, | |
1620 | wxRibbonGallery* wnd, | |
1621 | const wxRect& rect) | |
1622 | { | |
1623 | DrawPartialPageBackground(dc, wnd, rect); | |
1624 | ||
1625 | if(wnd->IsHovered()) | |
1626 | { | |
1627 | dc.SetPen(*wxTRANSPARENT_PEN); | |
1628 | dc.SetBrush(m_gallery_hover_background_brush); | |
1629 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
1630 | { | |
1631 | dc.DrawRectangle(rect.x + 1, rect.y + 1, rect.width - 2, | |
1632 | rect.height - 16); | |
1633 | } | |
1634 | else | |
1635 | { | |
1636 | dc.DrawRectangle(rect.x + 1, rect.y + 1, rect.width - 16, | |
1637 | rect.height - 2); | |
1638 | } | |
1639 | } | |
1640 | ||
1641 | dc.SetPen(m_gallery_border_pen); | |
1642 | // Outline | |
1643 | dc.DrawLine(rect.x + 1, rect.y, rect.x + rect.width - 1, rect.y); | |
1644 | dc.DrawLine(rect.x, rect.y + 1, rect.x, rect.y + rect.height - 1); | |
1645 | dc.DrawLine(rect.x + 1, rect.y + rect.height - 1, rect.x + rect.width - 1, | |
1646 | rect.y + rect.height - 1); | |
1647 | dc.DrawLine(rect.x + rect.width - 1, rect.y + 1, rect.x + rect.width - 1, | |
1648 | rect.y + rect.height - 1); | |
1649 | ||
1650 | DrawGalleryBackgroundCommon(dc, wnd, rect); | |
1651 | } | |
1652 | ||
1653 | void wxRibbonMSWArtProvider::DrawGalleryBackgroundCommon(wxDC& dc, | |
1654 | wxRibbonGallery* wnd, | |
1655 | const wxRect& rect) | |
1656 | { | |
1657 | wxRect up_btn, down_btn, ext_btn; | |
1658 | ||
1659 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
1660 | { | |
1661 | // Divider between items and buttons | |
1662 | dc.DrawLine(rect.x, rect.y + rect.height - 15, rect.x + rect.width, | |
1663 | rect.y + rect.height - 15); | |
1664 | ||
1665 | up_btn = wxRect(rect.x, rect.y + rect.height - 15, rect.width / 3, 15); | |
1666 | ||
1667 | down_btn = wxRect(up_btn.GetRight() + 1, up_btn.GetTop(), | |
1668 | up_btn.GetWidth(), up_btn.GetHeight()); | |
1669 | dc.DrawLine(down_btn.GetLeft(), down_btn.GetTop(), down_btn.GetLeft(), | |
1670 | down_btn.GetBottom()); | |
1671 | ||
1672 | ext_btn = wxRect(down_btn.GetRight() + 1, up_btn.GetTop(), rect.width - | |
1673 | up_btn.GetWidth() - down_btn.GetWidth() - 1, up_btn.GetHeight()); | |
1674 | dc.DrawLine(ext_btn.GetLeft(), ext_btn.GetTop(), ext_btn.GetLeft(), | |
1675 | ext_btn.GetBottom()); | |
1676 | } | |
1677 | else | |
1678 | { | |
1679 | // Divider between items and buttons | |
1680 | dc.DrawLine(rect.x + rect.width - 15, rect.y, rect.x + rect.width - 15, | |
1681 | rect.y + rect.height); | |
1682 | ||
1683 | up_btn = wxRect(rect.x + rect.width - 15, rect.y, 15, rect.height / 3); | |
1684 | ||
1685 | down_btn = wxRect(up_btn.GetLeft(), up_btn.GetBottom() + 1, | |
1686 | up_btn.GetWidth(), up_btn.GetHeight()); | |
1687 | dc.DrawLine(down_btn.GetLeft(), down_btn.GetTop(), down_btn.GetRight(), | |
1688 | down_btn.GetTop()); | |
1689 | ||
1690 | ext_btn = wxRect(up_btn.GetLeft(), down_btn.GetBottom() + 1, up_btn.GetWidth(), | |
1691 | rect.height - up_btn.GetHeight() - down_btn.GetHeight() - 1); | |
1692 | dc.DrawLine(ext_btn.GetLeft(), ext_btn.GetTop(), ext_btn.GetRight(), | |
1693 | ext_btn.GetTop()); | |
1694 | } | |
1695 | ||
1696 | DrawGalleryButton(dc, up_btn, wnd->GetUpButtonState(), | |
1697 | m_gallery_up_bitmap); | |
1698 | DrawGalleryButton(dc, down_btn, wnd->GetDownButtonState(), | |
1699 | m_gallery_down_bitmap); | |
1700 | DrawGalleryButton(dc, ext_btn, wnd->GetExtensionButtonState(), | |
1701 | m_gallery_extension_bitmap); | |
1702 | } | |
1703 | ||
1704 | void wxRibbonMSWArtProvider::DrawGalleryButton(wxDC& dc, | |
1705 | wxRect rect, | |
1706 | wxRibbonGalleryButtonState state, | |
1707 | wxBitmap* bitmaps) | |
1708 | { | |
1709 | wxBitmap btn_bitmap; | |
1710 | wxBrush btn_top_brush; | |
1711 | wxColour btn_colour; | |
1712 | wxColour btn_grad_colour; | |
1713 | switch(state) | |
1714 | { | |
1715 | case wxRIBBON_GALLERY_BUTTON_NORMAL: | |
1716 | btn_top_brush = m_gallery_button_background_top_brush; | |
1717 | btn_colour = m_gallery_button_background_colour; | |
1718 | btn_grad_colour = m_gallery_button_background_gradient_colour; | |
1719 | btn_bitmap = bitmaps[0]; | |
1720 | break; | |
1721 | case wxRIBBON_GALLERY_BUTTON_HOVERED: | |
1722 | btn_top_brush = m_gallery_button_hover_background_top_brush; | |
1723 | btn_colour = m_gallery_button_hover_background_colour; | |
1724 | btn_grad_colour = m_gallery_button_hover_background_gradient_colour; | |
1725 | btn_bitmap = bitmaps[1]; | |
1726 | break; | |
1727 | case wxRIBBON_GALLERY_BUTTON_ACTIVE: | |
1728 | btn_top_brush = m_gallery_button_active_background_top_brush; | |
1729 | btn_colour = m_gallery_button_active_background_colour; | |
1730 | btn_grad_colour = m_gallery_button_active_background_gradient_colour; | |
1731 | btn_bitmap = bitmaps[2]; | |
1732 | break; | |
1733 | case wxRIBBON_GALLERY_BUTTON_DISABLED: | |
1734 | btn_top_brush = m_gallery_button_disabled_background_top_brush; | |
1735 | btn_colour = m_gallery_button_disabled_background_colour; | |
1736 | btn_grad_colour = m_gallery_button_disabled_background_gradient_colour; | |
1737 | btn_bitmap = bitmaps[3]; | |
1738 | break; | |
1739 | } | |
1740 | ||
1741 | rect.x++; | |
1742 | rect.y++; | |
1743 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
1744 | { | |
1745 | rect.width--;; | |
1746 | rect.height -= 2; | |
1747 | } | |
1748 | else | |
1749 | { | |
1750 | rect.width -= 2; | |
1751 | rect.height--; | |
1752 | } | |
1753 | ||
1754 | dc.SetPen(*wxTRANSPARENT_PEN); | |
1755 | dc.SetBrush(btn_top_brush); | |
1756 | dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height / 2); | |
1757 | ||
1758 | wxRect lower(rect); | |
1759 | lower.height = (lower.height + 1) / 2; | |
1760 | lower.y += rect.height - lower.height; | |
1761 | dc.GradientFillLinear(lower, btn_colour, btn_grad_colour, wxSOUTH); | |
1762 | ||
1763 | dc.DrawBitmap(btn_bitmap, rect.x + rect.width / 2 - 2, lower.y - 2, true); | |
1764 | } | |
1765 | ||
1766 | void wxRibbonMSWArtProvider::DrawGalleryItemBackground( | |
1767 | wxDC& dc, | |
1768 | wxRibbonGallery* wnd, | |
1769 | const wxRect& rect, | |
1770 | wxRibbonGalleryItem* item) | |
1771 | { | |
1772 | if(wnd->GetHoveredItem() != item && wnd->GetActiveItem() != item && | |
1773 | wnd->GetSelection() != item) | |
1774 | return; | |
1775 | ||
1776 | dc.SetPen(m_gallery_item_border_pen); | |
1777 | dc.DrawLine(rect.x + 1, rect.y, rect.x + rect.width - 1, rect.y); | |
1778 | dc.DrawLine(rect.x, rect.y + 1, rect.x, rect.y + rect.height - 1); | |
1779 | dc.DrawLine(rect.x + 1, rect.y + rect.height - 1, rect.x + rect.width - 1, | |
1780 | rect.y + rect.height - 1); | |
1781 | dc.DrawLine(rect.x + rect.width - 1, rect.y + 1, rect.x + rect.width - 1, | |
1782 | rect.y + rect.height - 1); | |
1783 | ||
1784 | wxBrush top_brush; | |
1785 | wxColour bg_colour; | |
1786 | wxColour bg_gradient_colour; | |
1787 | ||
1788 | if(wnd->GetActiveItem() == item || wnd->GetSelection() == item) | |
1789 | { | |
1790 | top_brush = m_gallery_button_active_background_top_brush; | |
1791 | bg_colour = m_gallery_button_active_background_colour; | |
1792 | bg_gradient_colour = m_gallery_button_active_background_gradient_colour; | |
1793 | } | |
1794 | else | |
1795 | { | |
1796 | top_brush = m_gallery_button_hover_background_top_brush; | |
1797 | bg_colour = m_gallery_button_hover_background_colour; | |
1798 | bg_gradient_colour = m_gallery_button_hover_background_gradient_colour; | |
1799 | } | |
1800 | ||
1801 | wxRect upper(rect); | |
1802 | upper.x += 1; | |
1803 | upper.width -= 2; | |
1804 | upper.y += 1; | |
1805 | upper.height /= 3; | |
1806 | dc.SetPen(*wxTRANSPARENT_PEN); | |
1807 | dc.SetBrush(top_brush); | |
1808 | dc.DrawRectangle(upper.x, upper.y, upper.width, upper.height); | |
1809 | ||
1810 | wxRect lower(upper); | |
1811 | lower.y += lower.height; | |
1812 | lower.height = rect.height - 2 - lower.height; | |
1813 | dc.GradientFillLinear(lower, bg_colour, bg_gradient_colour, wxSOUTH); | |
1814 | } | |
1815 | ||
1816 | void wxRibbonMSWArtProvider::DrawPanelBorder(wxDC& dc, const wxRect& rect, | |
1817 | wxPen& primary_colour, | |
1818 | wxPen& secondary_colour) | |
1819 | { | |
1820 | wxPoint border_points[9]; | |
1821 | border_points[0] = wxPoint(2, 0); | |
1822 | border_points[1] = wxPoint(rect.width - 3, 0); | |
1823 | border_points[2] = wxPoint(rect.width - 1, 2); | |
1824 | border_points[3] = wxPoint(rect.width - 1, rect.height - 3); | |
1825 | border_points[4] = wxPoint(rect.width - 3, rect.height - 1); | |
1826 | border_points[5] = wxPoint(2, rect.height - 1); | |
1827 | border_points[6] = wxPoint(0, rect.height - 3); | |
1828 | border_points[7] = wxPoint(0, 2); | |
1829 | ||
1830 | if(primary_colour.GetColour() == secondary_colour.GetColour()) | |
1831 | { | |
1832 | border_points[8] = border_points[0]; | |
1833 | dc.SetPen(primary_colour); | |
1834 | dc.DrawLines(sizeof(border_points)/sizeof(wxPoint), border_points, rect.x, rect.y); | |
1835 | } | |
1836 | else | |
1837 | { | |
1838 | dc.SetPen(primary_colour); | |
1839 | dc.DrawLines(3, border_points, rect.x, rect.y); | |
1840 | ||
1841 | #define SingleLine(start, finish) \ | |
1842 | dc.DrawLine(start.x + rect.x, start.y + rect.y, finish.x + rect.x, finish.y + rect.y) | |
1843 | ||
1844 | SingleLine(border_points[0], border_points[7]); | |
1845 | dc.SetPen(secondary_colour); | |
1846 | dc.DrawLines(3, border_points + 4, rect.x, rect.y); | |
1847 | SingleLine(border_points[4], border_points[3]); | |
1848 | ||
1849 | #undef SingleLine | |
1850 | ||
1851 | border_points[6] = border_points[2]; | |
1852 | wxRibbonDrawParallelGradientLines(dc, 2, border_points + 6, 0, 1, | |
1853 | border_points[3].y - border_points[2].y + 1, rect.x, rect.y, | |
1854 | primary_colour.GetColour(), secondary_colour.GetColour()); | |
1855 | } | |
1856 | } | |
1857 | ||
1858 | void wxRibbonMSWArtProvider::DrawMinimisedPanel( | |
1859 | wxDC& dc, | |
1860 | wxRibbonPanel* wnd, | |
1861 | const wxRect& rect, | |
1862 | wxBitmap& bitmap) | |
1863 | { | |
1864 | DrawPartialPageBackground(dc, wnd, rect, false); | |
1865 | ||
1866 | wxRect true_rect(rect); | |
1867 | RemovePanelPadding(&true_rect); | |
1868 | ||
1869 | if(wnd->GetExpandedPanel() != NULL) | |
1870 | { | |
1871 | wxRect client_rect(true_rect); | |
1872 | client_rect.x++; | |
1873 | client_rect.width -= 2; | |
1874 | client_rect.y++; | |
1875 | client_rect.height = (rect.y + rect.height / 5) - client_rect.x; | |
ce00f59b | 1876 | dc.GradientFillLinear(client_rect, |
3c3ead1d PC |
1877 | m_panel_active_background_top_colour, |
1878 | m_panel_active_background_top_gradient_colour, wxSOUTH); | |
1879 | ||
1880 | client_rect.y += client_rect.height; | |
1881 | client_rect.height = (true_rect.y + true_rect.height) - client_rect.y; | |
ce00f59b | 1882 | dc.GradientFillLinear(client_rect, |
3c3ead1d PC |
1883 | m_panel_active_background_colour, |
1884 | m_panel_active_background_gradient_colour, wxSOUTH); | |
1885 | } | |
1886 | else if(wnd->IsHovered()) | |
1887 | { | |
1888 | wxRect client_rect(true_rect); | |
1889 | client_rect.x++; | |
1890 | client_rect.width -= 2; | |
1891 | client_rect.y++; | |
1892 | client_rect.height -= 2; | |
1893 | DrawPartialPageBackground(dc, wnd, client_rect, true); | |
1894 | } | |
1895 | ||
1896 | wxRect preview; | |
1897 | DrawMinimisedPanelCommon(dc, wnd, true_rect, &preview); | |
1898 | ||
1899 | dc.SetBrush(m_panel_hover_label_background_brush); | |
1900 | dc.SetPen(*wxTRANSPARENT_PEN); | |
1901 | dc.DrawRectangle(preview.x + 1, preview.y + preview.height - 8, | |
1902 | preview.width - 2, 7); | |
1903 | ||
1904 | int mid_pos = rect.y + rect.height / 5 - preview.y; | |
1905 | if(mid_pos < 0 || mid_pos >= preview.height) | |
1906 | { | |
1907 | wxRect full_rect(preview); | |
1908 | full_rect.x += 1; | |
1909 | full_rect.y += 1; | |
1910 | full_rect.width -= 2; | |
1911 | full_rect.height -= 9; | |
1912 | if(mid_pos < 0) | |
1913 | { | |
1914 | dc.GradientFillLinear(full_rect, | |
1915 | m_page_hover_background_colour, | |
1916 | m_page_hover_background_gradient_colour, wxSOUTH); | |
1917 | } | |
1918 | else | |
1919 | { | |
1920 | dc.GradientFillLinear(full_rect, | |
1921 | m_page_hover_background_top_colour, | |
1922 | m_page_hover_background_top_gradient_colour, wxSOUTH); | |
1923 | } | |
1924 | } | |
1925 | else | |
1926 | { | |
1927 | wxRect top_rect(preview); | |
1928 | top_rect.x += 1; | |
1929 | top_rect.y += 1; | |
1930 | top_rect.width -= 2; | |
1931 | top_rect.height = mid_pos; | |
1932 | dc.GradientFillLinear(top_rect, | |
1933 | m_page_hover_background_top_colour, | |
1934 | m_page_hover_background_top_gradient_colour, wxSOUTH); | |
1935 | ||
1936 | wxRect btm_rect(top_rect); | |
1937 | btm_rect.y = preview.y + mid_pos; | |
1938 | btm_rect.height = preview.y + preview.height - 7 - btm_rect.y; | |
1939 | dc.GradientFillLinear(btm_rect, | |
1940 | m_page_hover_background_colour, | |
1941 | m_page_hover_background_gradient_colour, wxSOUTH); | |
1942 | } | |
1943 | ||
1944 | if(bitmap.IsOk()) | |
1945 | { | |
1946 | dc.DrawBitmap(bitmap, preview.x + (preview.width - bitmap.GetWidth()) / 2, | |
1947 | preview.y + (preview.height - 7 - bitmap.GetHeight()) / 2, true); | |
1948 | } | |
1949 | ||
1950 | DrawPanelBorder(dc, preview, m_panel_border_pen, m_panel_border_gradient_pen); | |
1951 | ||
1952 | DrawPanelBorder(dc, true_rect, m_panel_minimised_border_pen, | |
1953 | m_panel_minimised_border_gradient_pen); | |
1954 | } | |
1955 | ||
1956 | void wxRibbonMSWArtProvider::DrawMinimisedPanelCommon( | |
1957 | wxDC& dc, | |
1958 | wxRibbonPanel* wnd, | |
1959 | const wxRect& true_rect, | |
1960 | wxRect* preview_rect) | |
1961 | { | |
1962 | wxRect preview(0, 0, 32, 32); | |
1963 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
1964 | { | |
1965 | preview.x = true_rect.x + 4; | |
1966 | preview.y = true_rect.y + (true_rect.height - preview.height) / 2; | |
1967 | } | |
1968 | else | |
1969 | { | |
1970 | preview.x = true_rect.x + (true_rect.width - preview.width) / 2; | |
1971 | preview.y = true_rect.y + 4; | |
1972 | } | |
1973 | if(preview_rect) | |
1974 | *preview_rect = preview; | |
1975 | ||
1976 | wxCoord label_width, label_height; | |
1977 | dc.SetFont(m_panel_label_font); | |
1978 | dc.GetTextExtent(wnd->GetLabel(), &label_width, &label_height); | |
1979 | ||
1980 | int xpos = true_rect.x + (true_rect.width - label_width + 1) / 2; | |
1981 | int ypos = preview.y + preview.height + 5; | |
1982 | ||
1983 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
1984 | { | |
1985 | xpos = preview.x + preview.width + 5; | |
1986 | ypos = true_rect.y + (true_rect.height - label_height) / 2; | |
1987 | } | |
1988 | ||
1989 | dc.SetTextForeground(m_panel_minimised_label_colour); | |
1990 | dc.DrawText(wnd->GetLabel(), xpos, ypos); | |
ce00f59b | 1991 | |
3c3ead1d PC |
1992 | |
1993 | wxPoint arrow_points[3]; | |
1994 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
1995 | { | |
1996 | xpos += label_width; | |
1997 | arrow_points[0] = wxPoint(xpos + 5, ypos + label_height / 2); | |
1998 | arrow_points[1] = arrow_points[0] + wxPoint(-3, 3); | |
1999 | arrow_points[2] = arrow_points[0] + wxPoint(-3, -3); | |
2000 | } | |
2001 | else | |
2002 | { | |
2003 | ypos += label_height; | |
2004 | arrow_points[0] = wxPoint(true_rect.width / 2, ypos + 5); | |
2005 | arrow_points[1] = arrow_points[0] + wxPoint(-3, -3); | |
2006 | arrow_points[2] = arrow_points[0] + wxPoint( 3, -3); | |
2007 | } | |
2008 | ||
2009 | dc.SetPen(*wxTRANSPARENT_PEN); | |
2010 | wxBrush B(m_panel_minimised_label_colour); | |
2011 | dc.SetBrush(B); | |
2012 | dc.DrawPolygon(sizeof(arrow_points)/sizeof(wxPoint), arrow_points, | |
2013 | true_rect.x, true_rect.y); | |
2014 | } | |
2015 | ||
2016 | void wxRibbonMSWArtProvider::DrawButtonBarBackground( | |
2017 | wxDC& dc, | |
2018 | wxWindow* wnd, | |
2019 | const wxRect& rect) | |
2020 | { | |
2021 | DrawPartialPageBackground(dc, wnd, rect, true); | |
2022 | } | |
2023 | ||
2024 | void wxRibbonMSWArtProvider::DrawPartialPageBackground( | |
2025 | wxDC& dc, | |
2026 | wxWindow* wnd, | |
2027 | const wxRect& rect, | |
2028 | bool allow_hovered) | |
2029 | { | |
2030 | // Assume the window is a child of a ribbon page, and also check for a | |
2031 | // hovered panel somewhere between the window and the page, as it causes | |
2032 | // the background to change. | |
2033 | wxPoint offset(wnd->GetPosition()); | |
2034 | wxRibbonPage* page = NULL; | |
2035 | wxWindow* parent = wnd->GetParent(); | |
00491f99 | 2036 | wxRibbonPanel* panel = wxDynamicCast(wnd, wxRibbonPanel); |
3c3ead1d PC |
2037 | bool hovered = false; |
2038 | ||
3c3ead1d PC |
2039 | if(panel != NULL) |
2040 | { | |
2041 | hovered = allow_hovered && panel->IsHovered(); | |
2042 | if(panel->GetExpandedDummy() != NULL) | |
2043 | { | |
2044 | offset = panel->GetExpandedDummy()->GetPosition(); | |
2045 | parent = panel->GetExpandedDummy()->GetParent(); | |
2046 | } | |
2047 | } | |
2048 | for(; parent; parent = parent->GetParent()) | |
2049 | { | |
2050 | if(panel == NULL) | |
2051 | { | |
2052 | panel = wxDynamicCast(parent, wxRibbonPanel); | |
2053 | if(panel != NULL) | |
2054 | { | |
2055 | hovered = allow_hovered && panel->IsHovered(); | |
2056 | if(panel->GetExpandedDummy() != NULL) | |
2057 | { | |
2058 | parent = panel->GetExpandedDummy(); | |
2059 | } | |
2060 | } | |
2061 | } | |
2062 | page = wxDynamicCast(parent, wxRibbonPage); | |
2063 | if(page != NULL) | |
2064 | { | |
2065 | break; | |
2066 | } | |
2067 | offset += parent->GetPosition(); | |
2068 | } | |
2069 | if(page != NULL) | |
2070 | { | |
2071 | DrawPartialPageBackground(dc, wnd, rect, page, offset, hovered); | |
2072 | return; | |
2073 | } | |
2074 | ||
2075 | // No page found - fallback to painting with a stock brush | |
2076 | dc.SetBrush(*wxWHITE_BRUSH); | |
2077 | dc.SetPen(*wxTRANSPARENT_PEN); | |
2078 | dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height); | |
2079 | } | |
2080 | ||
2081 | void wxRibbonMSWArtProvider::DrawButtonBarButton( | |
2082 | wxDC& dc, | |
2083 | wxWindow* WXUNUSED(wnd), | |
2084 | const wxRect& rect, | |
2085 | wxRibbonButtonKind kind, | |
2086 | long state, | |
2087 | const wxString& label, | |
2088 | const wxBitmap& bitmap_large, | |
2089 | const wxBitmap& bitmap_small) | |
2090 | { | |
955bad41 PC |
2091 | if(kind == wxRIBBON_BUTTON_TOGGLE) |
2092 | { | |
2093 | kind = wxRIBBON_BUTTON_NORMAL; | |
2094 | if(state & wxRIBBON_BUTTONBAR_BUTTON_TOGGLED) | |
2095 | state ^= wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK; | |
2096 | } | |
2097 | ||
3c3ead1d PC |
2098 | if(state & (wxRIBBON_BUTTONBAR_BUTTON_HOVER_MASK | |
2099 | wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK)) | |
2100 | { | |
2101 | if(state & wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK) | |
2102 | dc.SetPen(m_button_bar_active_border_pen); | |
2103 | else | |
2104 | dc.SetPen(m_button_bar_hover_border_pen); | |
2105 | ||
2106 | wxRect bg_rect(rect); | |
2107 | bg_rect.x++; | |
2108 | bg_rect.y++; | |
2109 | bg_rect.width -= 2; | |
2110 | bg_rect.height -= 2; | |
2111 | ||
2112 | wxRect bg_rect_top(bg_rect); | |
2113 | bg_rect_top.height /= 3; | |
2114 | bg_rect.y += bg_rect_top.height; | |
2115 | bg_rect.height -= bg_rect_top.height; | |
2116 | ||
2117 | if(kind == wxRIBBON_BUTTON_HYBRID) | |
2118 | { | |
2119 | switch(state & wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK) | |
2120 | { | |
2121 | case wxRIBBON_BUTTONBAR_BUTTON_LARGE: | |
2122 | { | |
2123 | int iYBorder = rect.y + bitmap_large.GetHeight() + 4; | |
2124 | wxRect partial_bg(rect); | |
2125 | if(state & wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED) | |
2126 | { | |
2127 | partial_bg.SetBottom(iYBorder - 1); | |
2128 | } | |
2129 | else | |
2130 | { | |
2131 | partial_bg.height -= (iYBorder - partial_bg.y + 1); | |
2132 | partial_bg.y = iYBorder + 1; | |
2133 | } | |
2134 | dc.DrawLine(rect.x, iYBorder, rect.x + rect.width, iYBorder); | |
2135 | bg_rect.Intersect(partial_bg); | |
2136 | bg_rect_top.Intersect(partial_bg); | |
2137 | } | |
2138 | break; | |
2139 | case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM: | |
2140 | { | |
2141 | int iArrowWidth = 9; | |
2142 | if(state & wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED) | |
2143 | { | |
2144 | bg_rect.width -= iArrowWidth; | |
2145 | bg_rect_top.width -= iArrowWidth; | |
2146 | dc.DrawLine(bg_rect_top.x + bg_rect_top.width, | |
2147 | rect.y, bg_rect_top.x + bg_rect_top.width, | |
2148 | rect.y + rect.height); | |
2149 | } | |
2150 | else | |
2151 | { | |
2152 | --iArrowWidth; | |
2153 | bg_rect.x += bg_rect.width - iArrowWidth; | |
2154 | bg_rect_top.x += bg_rect_top.width - iArrowWidth; | |
2155 | bg_rect.width = iArrowWidth; | |
2156 | bg_rect_top.width = iArrowWidth; | |
2157 | dc.DrawLine(bg_rect_top.x - 1, rect.y, | |
2158 | bg_rect_top.x - 1, rect.y + rect.height); | |
2159 | } | |
2160 | } | |
2161 | break; | |
2162 | case wxRIBBON_BUTTONBAR_BUTTON_SMALL: | |
2163 | break; | |
2164 | } | |
2165 | } | |
2166 | ||
2167 | if(state & wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK) | |
2168 | { | |
2169 | dc.GradientFillLinear(bg_rect_top, | |
2170 | m_button_bar_active_background_top_colour, | |
2171 | m_button_bar_active_background_top_gradient_colour, wxSOUTH); | |
2172 | dc.GradientFillLinear(bg_rect, | |
2173 | m_button_bar_active_background_colour, | |
2174 | m_button_bar_active_background_gradient_colour, wxSOUTH); | |
2175 | } | |
2176 | else | |
2177 | { | |
2178 | dc.GradientFillLinear(bg_rect_top, | |
2179 | m_button_bar_hover_background_top_colour, | |
2180 | m_button_bar_hover_background_top_gradient_colour, wxSOUTH); | |
2181 | dc.GradientFillLinear(bg_rect, | |
2182 | m_button_bar_hover_background_colour, | |
2183 | m_button_bar_hover_background_gradient_colour, wxSOUTH); | |
2184 | } | |
2185 | ||
2186 | wxPoint border_points[9]; | |
2187 | border_points[0] = wxPoint(2, 0); | |
2188 | border_points[1] = wxPoint(rect.width - 3, 0); | |
2189 | border_points[2] = wxPoint(rect.width - 1, 2); | |
2190 | border_points[3] = wxPoint(rect.width - 1, rect.height - 3); | |
2191 | border_points[4] = wxPoint(rect.width - 3, rect.height - 1); | |
2192 | border_points[5] = wxPoint(2, rect.height - 1); | |
2193 | border_points[6] = wxPoint(0, rect.height - 3); | |
2194 | border_points[7] = wxPoint(0, 2); | |
2195 | border_points[8] = border_points[0]; | |
2196 | ||
2197 | dc.DrawLines(sizeof(border_points)/sizeof(wxPoint), border_points, | |
2198 | rect.x, rect.y); | |
2199 | } | |
2200 | ||
2201 | dc.SetFont(m_button_bar_label_font); | |
2202 | dc.SetTextForeground(m_button_bar_label_colour); | |
2203 | DrawButtonBarButtonForeground(dc, rect, kind, state, label, bitmap_large, | |
2204 | bitmap_small); | |
2205 | } | |
2206 | ||
2207 | void wxRibbonMSWArtProvider::DrawButtonBarButtonForeground( | |
2208 | wxDC& dc, | |
2209 | const wxRect& rect, | |
2210 | wxRibbonButtonKind kind, | |
2211 | long state, | |
2212 | const wxString& label, | |
2213 | const wxBitmap& bitmap_large, | |
2214 | const wxBitmap& bitmap_small) | |
2215 | { | |
2216 | switch(state & wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK) | |
2217 | { | |
2218 | case wxRIBBON_BUTTONBAR_BUTTON_LARGE: | |
2219 | { | |
2220 | const int padding = 2; | |
2221 | dc.DrawBitmap(bitmap_large, | |
2222 | rect.x + (rect.width - bitmap_large.GetWidth()) / 2, | |
2223 | rect.y + padding, true); | |
2224 | int ypos = rect.y + padding + bitmap_large.GetHeight() + padding; | |
2225 | int arrow_width = kind == wxRIBBON_BUTTON_NORMAL ? 0 : 8; | |
2226 | wxCoord label_w, label_h; | |
2227 | dc.GetTextExtent(label, &label_w, &label_h); | |
2228 | if(label_w + 2 * padding <= rect.width) | |
2229 | { | |
2230 | dc.DrawText(label, rect.x + (rect.width - label_w) / 2, ypos); | |
2231 | if(arrow_width != 0) | |
2232 | { | |
2233 | DrawDropdownArrow(dc, rect.x + rect.width / 2, | |
2234 | ypos + (label_h * 3) / 2, | |
2235 | m_button_bar_label_colour); | |
2236 | } | |
2237 | } | |
2238 | else | |
2239 | { | |
2240 | size_t breaki = label.Len(); | |
2241 | do | |
2242 | { | |
2243 | --breaki; | |
2244 | if(wxRibbonCanLabelBreakAtPosition(label, breaki)) | |
2245 | { | |
2246 | wxString label_top = label.Mid(0, breaki); | |
2247 | dc.GetTextExtent(label_top, &label_w, &label_h); | |
2248 | if(label_w + 2 * padding <= rect.width) | |
2249 | { | |
2250 | dc.DrawText(label_top, | |
2251 | rect.x + (rect.width - label_w) / 2, ypos); | |
2252 | ypos += label_h; | |
2253 | wxString label_bottom = label.Mid(breaki + 1); | |
2254 | dc.GetTextExtent(label_bottom, &label_w, &label_h); | |
2255 | label_w += arrow_width; | |
2256 | int iX = rect.x + (rect.width - label_w) / 2; | |
2257 | dc.DrawText(label_bottom, iX, ypos); | |
2258 | if(arrow_width != 0) | |
2259 | { | |
ce00f59b | 2260 | DrawDropdownArrow(dc, |
3c3ead1d PC |
2261 | iX + 2 +label_w - arrow_width, |
2262 | ypos + label_h / 2 + 1, | |
2263 | m_button_bar_label_colour); | |
2264 | } | |
2265 | break; | |
2266 | } | |
2267 | } | |
2268 | } while(breaki > 0); | |
2269 | } | |
2270 | } | |
2271 | break; | |
2272 | case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM: | |
2273 | { | |
2274 | int x_cursor = rect.x + 2; | |
2275 | dc.DrawBitmap(bitmap_small, x_cursor, | |
2276 | rect.y + (rect.height - bitmap_small.GetHeight())/2, true); | |
2277 | x_cursor += bitmap_small.GetWidth() + 2; | |
2278 | wxCoord label_w, label_h; | |
2279 | dc.GetTextExtent(label, &label_w, &label_h); | |
2280 | dc.DrawText(label, x_cursor, | |
2281 | rect.y + (rect.height - label_h) / 2); | |
2282 | x_cursor += label_w + 3; | |
2283 | if(kind != wxRIBBON_BUTTON_NORMAL) | |
2284 | { | |
2285 | DrawDropdownArrow(dc, x_cursor, rect.y + rect.height / 2, | |
2286 | m_button_bar_label_colour); | |
2287 | } | |
2288 | break; | |
2289 | } | |
2290 | default: | |
2291 | // TODO | |
2292 | break; | |
2293 | } | |
2294 | } | |
2295 | ||
2296 | void wxRibbonMSWArtProvider::DrawToolBarBackground( | |
2297 | wxDC& dc, | |
2298 | wxWindow* wnd, | |
2299 | const wxRect& rect) | |
2300 | { | |
2301 | DrawPartialPageBackground(dc, wnd, rect); | |
2302 | } | |
2303 | ||
2304 | void wxRibbonMSWArtProvider::DrawToolGroupBackground( | |
2305 | wxDC& dc, | |
2306 | wxWindow* WXUNUSED(wnd), | |
2307 | const wxRect& rect) | |
2308 | { | |
2309 | dc.SetPen(m_toolbar_border_pen); | |
2310 | wxPoint outline[9]; | |
2311 | outline[0] = wxPoint(2, 0); | |
2312 | outline[1] = wxPoint(rect.width - 3, 0); | |
2313 | outline[2] = wxPoint(rect.width - 1, 2); | |
2314 | outline[3] = wxPoint(rect.width - 1, rect.height - 3); | |
2315 | outline[4] = wxPoint(rect.width - 3, rect.height - 1); | |
2316 | outline[5] = wxPoint(2, rect.height - 1); | |
2317 | outline[6] = wxPoint(0, rect.height - 3); | |
2318 | outline[7] = wxPoint(0, 2); | |
2319 | outline[8] = outline[0]; | |
2320 | ||
2321 | dc.DrawLines(sizeof(outline)/sizeof(wxPoint), outline, rect.x, rect.y); | |
2322 | } | |
2323 | ||
2324 | void wxRibbonMSWArtProvider::DrawTool( | |
2325 | wxDC& dc, | |
2326 | wxWindow* WXUNUSED(wnd), | |
2327 | const wxRect& rect, | |
2328 | const wxBitmap& bitmap, | |
2329 | wxRibbonButtonKind kind, | |
2330 | long state) | |
2331 | { | |
d1bf0be0 VZ |
2332 | if(kind == wxRIBBON_BUTTON_TOGGLE) |
2333 | { | |
2334 | if(state & wxRIBBON_TOOLBAR_TOOL_TOGGLED) | |
2335 | state ^= wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK; | |
2336 | } | |
2337 | ||
3c3ead1d PC |
2338 | wxRect bg_rect(rect); |
2339 | bg_rect.Deflate(1); | |
2340 | if((state & wxRIBBON_TOOLBAR_TOOL_LAST) == 0) | |
2341 | bg_rect.width++; | |
2342 | bool is_split_hybrid = (kind == wxRIBBON_BUTTON_HYBRID && (state & | |
2343 | (wxRIBBON_TOOLBAR_TOOL_HOVER_MASK | wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK))); | |
2344 | ||
2345 | // Background | |
2346 | wxRect bg_rect_top(bg_rect); | |
2347 | bg_rect_top.height = (bg_rect_top.height * 2) / 5; | |
2348 | wxRect bg_rect_btm(bg_rect); | |
2349 | bg_rect_btm.y += bg_rect_top.height; | |
2350 | bg_rect_btm.height -= bg_rect_top.height; | |
2351 | wxColour bg_top_colour = m_tool_background_top_colour; | |
2352 | wxColour bg_top_grad_colour = m_tool_background_top_gradient_colour; | |
2353 | wxColour bg_colour = m_tool_background_colour; | |
2354 | wxColour bg_grad_colour = m_tool_background_gradient_colour; | |
2355 | if(state & wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK) | |
2356 | { | |
2357 | bg_top_colour = m_tool_active_background_top_colour; | |
2358 | bg_top_grad_colour = m_tool_active_background_top_gradient_colour; | |
2359 | bg_colour = m_tool_active_background_colour; | |
2360 | bg_grad_colour = m_tool_active_background_gradient_colour; | |
2361 | } | |
2362 | else if(state & wxRIBBON_TOOLBAR_TOOL_HOVER_MASK) | |
2363 | { | |
2364 | bg_top_colour = m_tool_hover_background_top_colour; | |
2365 | bg_top_grad_colour = m_tool_hover_background_top_gradient_colour; | |
2366 | bg_colour = m_tool_hover_background_colour; | |
2367 | bg_grad_colour = m_tool_hover_background_gradient_colour; | |
2368 | } | |
2369 | dc.GradientFillLinear(bg_rect_top, bg_top_colour, bg_top_grad_colour, wxSOUTH); | |
2370 | dc.GradientFillLinear(bg_rect_btm, bg_colour, bg_grad_colour, wxSOUTH); | |
2371 | if(is_split_hybrid) | |
2372 | { | |
2373 | wxRect nonrect(bg_rect); | |
2374 | if(state & (wxRIBBON_TOOLBAR_TOOL_DROPDOWN_HOVERED | | |
2375 | wxRIBBON_TOOLBAR_TOOL_DROPDOWN_ACTIVE)) | |
2376 | { | |
2377 | nonrect.width -= 8; | |
2378 | } | |
2379 | else | |
2380 | { | |
2381 | nonrect.x += nonrect.width - 8; | |
2382 | nonrect.width = 8; | |
2383 | } | |
2384 | wxBrush B(m_tool_hover_background_top_colour); | |
2385 | dc.SetPen(*wxTRANSPARENT_PEN); | |
2386 | dc.SetBrush(B); | |
2387 | dc.DrawRectangle(nonrect.x, nonrect.y, nonrect.width, nonrect.height); | |
2388 | } | |
ce00f59b | 2389 | |
3c3ead1d PC |
2390 | // Border |
2391 | dc.SetPen(m_toolbar_border_pen); | |
2392 | if(state & wxRIBBON_TOOLBAR_TOOL_FIRST) | |
2393 | { | |
2394 | dc.DrawPoint(rect.x + 1, rect.y + 1); | |
2395 | dc.DrawPoint(rect.x + 1, rect.y + rect.height - 2); | |
2396 | } | |
2397 | else | |
ce00f59b | 2398 | dc.DrawLine(rect.x, rect.y + 1, rect.x, rect.y + rect.height - 1); |
3c3ead1d PC |
2399 | |
2400 | if(state & wxRIBBON_TOOLBAR_TOOL_LAST) | |
2401 | { | |
2402 | dc.DrawPoint(rect.x + rect.width - 2, rect.y + 1); | |
2403 | dc.DrawPoint(rect.x + rect.width - 2, rect.y + rect.height - 2); | |
2404 | } | |
2405 | ||
2406 | // Foreground | |
2407 | int avail_width = bg_rect.GetWidth(); | |
d1bf0be0 | 2408 | if(kind & wxRIBBON_BUTTON_DROPDOWN) |
3c3ead1d PC |
2409 | { |
2410 | avail_width -= 8; | |
2411 | if(is_split_hybrid) | |
2412 | { | |
ce00f59b | 2413 | dc.DrawLine(rect.x + avail_width + 1, rect.y, |
3c3ead1d PC |
2414 | rect.x + avail_width + 1, rect.y + rect.height); |
2415 | } | |
2416 | dc.DrawBitmap(m_toolbar_drop_bitmap, bg_rect.x + avail_width + 2, | |
2417 | bg_rect.y + (bg_rect.height / 2) - 2, true); | |
2418 | } | |
2419 | dc.DrawBitmap(bitmap, bg_rect.x + (avail_width - bitmap.GetWidth()) / 2, | |
2420 | bg_rect.y + (bg_rect.height - bitmap.GetHeight()) / 2, true); | |
2421 | } | |
2422 | ||
2423 | void wxRibbonMSWArtProvider::GetBarTabWidth( | |
2424 | wxDC& dc, | |
2425 | wxWindow* WXUNUSED(wnd), | |
2426 | const wxString& label, | |
2427 | const wxBitmap& bitmap, | |
2428 | int* ideal, | |
2429 | int* small_begin_need_separator, | |
2430 | int* small_must_have_separator, | |
2431 | int* minimum) | |
2432 | { | |
2433 | int width = 0; | |
2434 | int min = 0; | |
2435 | if((m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) && !label.IsEmpty()) | |
2436 | { | |
2437 | dc.SetFont(m_tab_label_font); | |
2438 | width += dc.GetTextExtent(label).GetWidth(); | |
2439 | min += wxMin(25, width); // enough for a few chars | |
2440 | if(bitmap.IsOk()) | |
2441 | { | |
2442 | // gap between label and bitmap | |
2443 | width += 4; | |
2444 | min += 2; | |
2445 | } | |
2446 | } | |
2447 | if((m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS) && bitmap.IsOk()) | |
2448 | { | |
2449 | width += bitmap.GetWidth(); | |
2450 | min += bitmap.GetWidth(); | |
2451 | } | |
2452 | ||
2453 | if(ideal != NULL) | |
2454 | { | |
2455 | *ideal = width + 30; | |
2456 | } | |
2457 | if(small_begin_need_separator != NULL) | |
2458 | { | |
2459 | *small_begin_need_separator = width + 20; | |
2460 | } | |
2461 | if(small_must_have_separator != NULL) | |
2462 | { | |
2463 | *small_must_have_separator = width + 10; | |
2464 | } | |
2465 | if(minimum != NULL) | |
2466 | { | |
2467 | *minimum = min; | |
2468 | } | |
2469 | } | |
2470 | ||
2471 | int wxRibbonMSWArtProvider::GetTabCtrlHeight( | |
2472 | wxDC& dc, | |
2473 | wxWindow* WXUNUSED(wnd), | |
2474 | const wxRibbonPageTabInfoArray& pages) | |
2475 | { | |
2476 | int text_height = 0; | |
2477 | int icon_height = 0; | |
2478 | ||
2479 | if(pages.GetCount() <= 1 && (m_flags & wxRIBBON_BAR_ALWAYS_SHOW_TABS) == 0) | |
2480 | { | |
2481 | // To preserve space, a single tab need not be displayed. We still need | |
2482 | // two pixels of border / padding though. | |
2483 | return 2; | |
2484 | } | |
2485 | ||
2486 | if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) | |
2487 | { | |
2488 | dc.SetFont(m_tab_label_font); | |
2489 | text_height = dc.GetTextExtent(wxT("ABCDEFXj")).GetHeight() + 10; | |
2490 | } | |
2491 | if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS) | |
2492 | { | |
2493 | size_t numpages = pages.GetCount(); | |
2494 | for(size_t i = 0; i < numpages; ++i) | |
2495 | { | |
2496 | const wxRibbonPageTabInfo& info = pages.Item(i); | |
2497 | if(info.page->GetIcon().IsOk()) | |
2498 | { | |
2499 | icon_height = wxMax(icon_height, info.page->GetIcon().GetHeight() + 4); | |
2500 | } | |
2501 | } | |
2502 | } | |
2503 | ||
2504 | return wxMax(text_height, icon_height); | |
2505 | } | |
2506 | ||
2507 | wxSize wxRibbonMSWArtProvider::GetScrollButtonMinimumSize( | |
2508 | wxDC& WXUNUSED(dc), | |
2509 | wxWindow* WXUNUSED(wnd), | |
2510 | long WXUNUSED(style)) | |
2511 | { | |
2512 | return wxSize(12, 12); | |
2513 | } | |
2514 | ||
2515 | wxSize wxRibbonMSWArtProvider::GetPanelSize( | |
2516 | wxDC& dc, | |
2517 | const wxRibbonPanel* wnd, | |
2518 | wxSize client_size, | |
2519 | wxPoint* client_offset) | |
2520 | { | |
2521 | dc.SetFont(m_panel_label_font); | |
2522 | wxSize label_size = dc.GetTextExtent(wnd->GetLabel()); | |
2523 | ||
2524 | client_size.IncBy(0, label_size.GetHeight()); | |
2525 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
2526 | client_size.IncBy(4, 8); | |
2527 | else | |
2528 | client_size.IncBy(6, 6); | |
2529 | ||
2530 | if(client_offset != NULL) | |
2531 | { | |
2532 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
2533 | *client_offset = wxPoint(2, 3); | |
2534 | else | |
2535 | *client_offset = wxPoint(3, 2); | |
2536 | } | |
2537 | ||
2538 | return client_size; | |
2539 | } | |
2540 | ||
2541 | wxSize wxRibbonMSWArtProvider::GetPanelClientSize( | |
2542 | wxDC& dc, | |
2543 | const wxRibbonPanel* wnd, | |
2544 | wxSize size, | |
2545 | wxPoint* client_offset) | |
2546 | { | |
2547 | dc.SetFont(m_panel_label_font); | |
2548 | wxSize label_size = dc.GetTextExtent(wnd->GetLabel()); | |
2549 | ||
2550 | size.DecBy(0, label_size.GetHeight()); | |
2551 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
2552 | size.DecBy(4, 8); | |
2553 | else | |
2554 | size.DecBy(6, 6); | |
2555 | ||
2556 | if(client_offset != NULL) | |
2557 | { | |
2558 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
2559 | *client_offset = wxPoint(2, 3); | |
2560 | else | |
2561 | *client_offset = wxPoint(3, 2); | |
2562 | } | |
16eac072 PC |
2563 | if (size.x < 0) size.x = 0; |
2564 | if (size.y < 0) size.y = 0; | |
3c3ead1d PC |
2565 | |
2566 | return size; | |
2567 | } | |
2568 | ||
2569 | wxSize wxRibbonMSWArtProvider::GetGallerySize( | |
2570 | wxDC& WXUNUSED(dc), | |
2571 | const wxRibbonGallery* WXUNUSED(wnd), | |
2572 | wxSize client_size) | |
2573 | { | |
2574 | client_size.IncBy( 2, 1); // Left / top padding | |
2575 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
2576 | client_size.IncBy(1, 16); // Right / bottom padding | |
2577 | else | |
2578 | client_size.IncBy(16, 1); // Right / bottom padding | |
2579 | return client_size; | |
2580 | } | |
2581 | ||
2582 | wxSize wxRibbonMSWArtProvider::GetGalleryClientSize( | |
2583 | wxDC& WXUNUSED(dc), | |
2584 | const wxRibbonGallery* WXUNUSED(wnd), | |
2585 | wxSize size, | |
2586 | wxPoint* client_offset, | |
2587 | wxRect* scroll_up_button, | |
2588 | wxRect* scroll_down_button, | |
2589 | wxRect* extension_button) | |
2590 | { | |
2591 | wxRect scroll_up; | |
2592 | wxRect scroll_down; | |
2593 | wxRect extension; | |
2594 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
2595 | { | |
2596 | // Flow is vertical - put buttons on bottom | |
2597 | scroll_up.y = size.GetHeight() - 15; | |
2598 | scroll_up.height = 15; | |
2599 | scroll_up.x = 0; | |
2600 | scroll_up.width = (size.GetWidth() + 2) / 3; | |
2601 | scroll_down.y = scroll_up.y; | |
2602 | scroll_down.height = scroll_up.height; | |
2603 | scroll_down.x = scroll_up.x + scroll_up.width; | |
ce00f59b | 2604 | scroll_down.width = scroll_up.width; |
3c3ead1d PC |
2605 | extension.y = scroll_down.y; |
2606 | extension.height = scroll_down.height; | |
2607 | extension.x = scroll_down.x + scroll_down.width; | |
2608 | extension.width = size.GetWidth() - scroll_up.width - scroll_down.width; | |
2609 | size.DecBy(1, 16); | |
2610 | size.DecBy( 2, 1); | |
2611 | } | |
2612 | else | |
2613 | { | |
2614 | // Flow is horizontal - put buttons on right | |
2615 | scroll_up.x = size.GetWidth() - 15; | |
2616 | scroll_up.width = 15; | |
2617 | scroll_up.y = 0; | |
2618 | scroll_up.height = (size.GetHeight() + 2) / 3; | |
2619 | scroll_down.x = scroll_up.x; | |
2620 | scroll_down.width = scroll_up.width; | |
2621 | scroll_down.y = scroll_up.y + scroll_up.height; | |
ce00f59b | 2622 | scroll_down.height = scroll_up.height; |
3c3ead1d PC |
2623 | extension.x = scroll_down.x; |
2624 | extension.width = scroll_down.width; | |
2625 | extension.y = scroll_down.y + scroll_down.height; | |
2626 | extension.height = size.GetHeight() - scroll_up.height - scroll_down.height; | |
2627 | size.DecBy(16, 1); | |
2628 | size.DecBy( 2, 1); | |
2629 | } | |
ce00f59b | 2630 | |
3c3ead1d PC |
2631 | if(client_offset != NULL) |
2632 | *client_offset = wxPoint(2, 1); | |
2633 | if(scroll_up_button != NULL) | |
2634 | *scroll_up_button = scroll_up; | |
2635 | if(scroll_down_button != NULL) | |
2636 | *scroll_down_button = scroll_down; | |
2637 | if(extension_button != NULL) | |
2638 | *extension_button = extension; | |
2639 | ||
2640 | return size; | |
2641 | } | |
2642 | ||
2643 | wxRect wxRibbonMSWArtProvider::GetPageBackgroundRedrawArea( | |
2644 | wxDC& WXUNUSED(dc), | |
2645 | const wxRibbonPage* WXUNUSED(wnd), | |
2646 | wxSize page_old_size, | |
2647 | wxSize page_new_size) | |
2648 | { | |
2649 | wxRect new_rect, old_rect; | |
2650 | ||
2651 | if(page_new_size.GetWidth() != page_old_size.GetWidth()) | |
2652 | { | |
2653 | if(page_new_size.GetHeight() != page_old_size.GetHeight()) | |
2654 | { | |
2655 | // Width and height both changed - redraw everything | |
2656 | return wxRect(page_new_size); | |
2657 | } | |
2658 | else | |
2659 | { | |
2660 | // Only width changed - redraw right hand side | |
2661 | const int right_edge_width = 4; | |
2662 | ||
2663 | new_rect = wxRect(page_new_size.GetWidth() - right_edge_width, 0, right_edge_width, page_new_size.GetHeight()); | |
2664 | old_rect = wxRect(page_old_size.GetWidth() - right_edge_width, 0, right_edge_width, page_old_size.GetHeight()); | |
2665 | } | |
2666 | } | |
2667 | else | |
2668 | { | |
2669 | if(page_new_size.GetHeight() == page_old_size.GetHeight()) | |
2670 | { | |
2671 | // Nothing changed (should never happen) - redraw nothing | |
2672 | return wxRect(0, 0, 0, 0); | |
2673 | } | |
2674 | else | |
2675 | { | |
2676 | // Height changed - need to redraw everything (as the background | |
2677 | // gradient is done vertically). | |
2678 | return page_new_size; | |
2679 | } | |
2680 | } | |
2681 | ||
2682 | new_rect.Union(old_rect); | |
2683 | new_rect.Intersect(wxRect(page_new_size)); | |
2684 | return new_rect; | |
2685 | } | |
2686 | ||
2687 | bool wxRibbonMSWArtProvider::GetButtonBarButtonSize( | |
2688 | wxDC& dc, | |
2689 | wxWindow* wnd, | |
2690 | wxRibbonButtonKind kind, | |
2691 | wxRibbonButtonBarButtonState size, | |
2692 | const wxString& label, | |
2693 | wxSize bitmap_size_large, | |
2694 | wxSize bitmap_size_small, | |
2695 | wxSize* button_size, | |
2696 | wxRect* normal_region, | |
2697 | wxRect* dropdown_region) | |
2698 | { | |
2699 | const int drop_button_width = 8; | |
2700 | ||
2701 | dc.SetFont(m_button_bar_label_font); | |
2702 | switch(size & wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK) | |
2703 | { | |
2704 | case wxRIBBON_BUTTONBAR_BUTTON_SMALL: | |
2705 | // Small bitmap, no label | |
2706 | *button_size = bitmap_size_small + wxSize(6, 4); | |
2707 | switch(kind) | |
2708 | { | |
2709 | case wxRIBBON_BUTTON_NORMAL: | |
955bad41 | 2710 | case wxRIBBON_BUTTON_TOGGLE: |
3c3ead1d PC |
2711 | *normal_region = wxRect(*button_size); |
2712 | *dropdown_region = wxRect(0, 0, 0, 0); | |
2713 | break; | |
2714 | case wxRIBBON_BUTTON_DROPDOWN: | |
2715 | *button_size += wxSize(drop_button_width, 0); | |
2716 | *dropdown_region = wxRect(*button_size); | |
2717 | *normal_region = wxRect(0, 0, 0, 0); | |
2718 | break; | |
2719 | case wxRIBBON_BUTTON_HYBRID: | |
2720 | *normal_region = wxRect(*button_size); | |
2721 | *dropdown_region = wxRect(button_size->GetWidth(), 0, | |
2722 | drop_button_width, button_size->GetHeight()); | |
2723 | *button_size += wxSize(drop_button_width, 0); | |
2724 | break; | |
2725 | } | |
2726 | break; | |
2727 | case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM: | |
2728 | // Small bitmap, with label to the right | |
2729 | { | |
2730 | GetButtonBarButtonSize(dc, wnd, kind, wxRIBBON_BUTTONBAR_BUTTON_SMALL, | |
2731 | label, bitmap_size_large, bitmap_size_small, button_size, | |
2732 | normal_region, dropdown_region); | |
2733 | int text_size = dc.GetTextExtent(label).GetWidth(); | |
2734 | button_size->SetWidth(button_size->GetWidth() + text_size); | |
2735 | switch(kind) | |
2736 | { | |
2737 | case wxRIBBON_BUTTON_DROPDOWN: | |
2738 | dropdown_region->SetWidth(dropdown_region->GetWidth() + text_size); | |
2739 | break; | |
2740 | case wxRIBBON_BUTTON_HYBRID: | |
2741 | dropdown_region->SetX(dropdown_region->GetX() + text_size); | |
2742 | // no break | |
2743 | case wxRIBBON_BUTTON_NORMAL: | |
955bad41 | 2744 | case wxRIBBON_BUTTON_TOGGLE: |
3c3ead1d PC |
2745 | normal_region->SetWidth(normal_region->GetWidth() + text_size); |
2746 | break; | |
2747 | } | |
2748 | break; | |
2749 | } | |
2750 | case wxRIBBON_BUTTONBAR_BUTTON_LARGE: | |
2751 | // Large bitmap, with label below (possibly split over 2 lines) | |
2752 | { | |
2753 | wxSize icon_size(bitmap_size_large); | |
2754 | icon_size += wxSize(4, 4); | |
2755 | wxCoord label_height; | |
2756 | wxCoord best_width; | |
2757 | dc.GetTextExtent(label, &best_width, &label_height); | |
3c3ead1d | 2758 | int last_line_extra_width = 0; |
955bad41 | 2759 | if(kind != wxRIBBON_BUTTON_NORMAL && kind != wxRIBBON_BUTTON_TOGGLE) |
3c3ead1d PC |
2760 | { |
2761 | last_line_extra_width += 8; | |
3c3ead1d PC |
2762 | } |
2763 | size_t i; | |
2764 | for(i = 0; i < label.Len(); ++i) | |
2765 | { | |
2766 | if(wxRibbonCanLabelBreakAtPosition(label, i)) | |
2767 | { | |
2768 | int width = wxMax( | |
2769 | dc.GetTextExtent(label.Mid(0, i - 1)).GetWidth(), | |
2770 | dc.GetTextExtent(label.Mid(i + 1)).GetWidth() + last_line_extra_width); | |
2771 | if(width < best_width) | |
2772 | { | |
2773 | best_width = width; | |
3c3ead1d PC |
2774 | } |
2775 | } | |
2776 | } | |
2777 | label_height *= 2; // Assume two lines even when only one is used | |
2778 | // (to give all buttons a consistent height) | |
2779 | icon_size.SetWidth(wxMax(icon_size.GetWidth(), best_width) + 6); | |
2780 | icon_size.SetHeight(icon_size.GetHeight() + label_height); | |
2781 | *button_size = icon_size; | |
2782 | switch(kind) | |
2783 | { | |
2784 | case wxRIBBON_BUTTON_DROPDOWN: | |
2785 | *dropdown_region = wxRect(icon_size); | |
2786 | break; | |
2787 | case wxRIBBON_BUTTON_HYBRID: | |
2788 | *normal_region = wxRect(icon_size); | |
2789 | normal_region->height -= 2 + label_height; | |
2790 | dropdown_region->x = 0; | |
2791 | dropdown_region->y = normal_region->height; | |
2792 | dropdown_region->width = icon_size.GetWidth(); | |
2793 | dropdown_region->height = icon_size.GetHeight() - normal_region->height; | |
2794 | break; | |
2795 | case wxRIBBON_BUTTON_NORMAL: | |
955bad41 | 2796 | case wxRIBBON_BUTTON_TOGGLE: |
3c3ead1d PC |
2797 | *normal_region = wxRect(icon_size); |
2798 | break; | |
2799 | } | |
2800 | break; | |
2801 | } | |
2802 | }; | |
2803 | return true; | |
2804 | } | |
2805 | ||
2806 | wxSize wxRibbonMSWArtProvider::GetMinimisedPanelMinimumSize( | |
2807 | wxDC& dc, | |
2808 | const wxRibbonPanel* wnd, | |
2809 | wxSize* desired_bitmap_size, | |
2810 | wxDirection* expanded_panel_direction) | |
2811 | { | |
2812 | if(desired_bitmap_size != NULL) | |
2813 | { | |
2814 | *desired_bitmap_size = wxSize(16, 16); | |
2815 | } | |
2816 | if(expanded_panel_direction != NULL) | |
2817 | { | |
2818 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
2819 | *expanded_panel_direction = wxEAST; | |
2820 | else | |
2821 | *expanded_panel_direction = wxSOUTH; | |
2822 | } | |
2823 | wxSize base_size(42, 42); | |
2824 | ||
2825 | dc.SetFont(m_panel_label_font); | |
2826 | wxSize label_size(dc.GetTextExtent(wnd->GetLabel())); | |
2827 | label_size.IncBy(2, 2); // Allow for differences between this DC and a paint DC | |
2828 | label_size.IncBy(6, 0); // Padding | |
2829 | label_size.y *= 2; // Second line for dropdown button | |
2830 | ||
2831 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
2832 | { | |
2833 | // Label alongside icon | |
2834 | return wxSize(base_size.x + label_size.x, | |
2835 | wxMax(base_size.y, label_size.y)); | |
2836 | } | |
2837 | else | |
2838 | { | |
2839 | // Label beneath icon | |
2840 | return wxSize(wxMax(base_size.x, label_size.x), | |
2841 | base_size.y + label_size.y); | |
2842 | } | |
2843 | } | |
2844 | ||
2845 | wxSize wxRibbonMSWArtProvider::GetToolSize( | |
2846 | wxDC& WXUNUSED(dc), | |
2847 | wxWindow* WXUNUSED(wnd), | |
2848 | wxSize bitmap_size, | |
2849 | wxRibbonButtonKind kind, | |
2850 | bool WXUNUSED(is_first), | |
2851 | bool is_last, | |
2852 | wxRect* dropdown_region) | |
2853 | { | |
2854 | wxSize size(bitmap_size); | |
2855 | size.IncBy(7, 6); | |
2856 | if(is_last) | |
2857 | size.IncBy(1, 0); | |
d1bf0be0 | 2858 | if(kind & wxRIBBON_BUTTON_DROPDOWN) |
3c3ead1d PC |
2859 | { |
2860 | size.IncBy(8, 0); | |
2861 | if(dropdown_region) | |
2862 | { | |
2863 | if(kind == wxRIBBON_BUTTON_DROPDOWN) | |
2864 | *dropdown_region = size; | |
2865 | else | |
2866 | *dropdown_region = wxRect(size.GetWidth() - 8, 0, 8, size.GetHeight()); | |
2867 | } | |
2868 | } | |
2869 | else | |
2870 | { | |
2871 | if(dropdown_region) | |
2872 | *dropdown_region = wxRect(0, 0, 0, 0); | |
2873 | } | |
2874 | return size; | |
2875 | } | |
2876 | ||
2877 | #endif // wxUSE_RIBBON |