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