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