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