]> git.saurik.com Git - wxWidgets.git/blame - src/ribbon/art_msw.cpp
When handling accelerators in wxWebView make sure that we do not block right-alt...
[wxWidgets.git] / src / ribbon / art_msw.cpp
CommitLineData
3c3ead1d
PC
1///////////////////////////////////////////////////////////////////////////////
2// Name: src/ribbon/art_msw.cpp
3// Purpose: MSW style art provider for ribbon interface
4// Author: Peter Cawley
5// Modified by:
6// Created: 2009-05-25
7// RCS-ID: $Id$
8// Copyright: (C) Peter Cawley
9// Licence: wxWindows licence
10///////////////////////////////////////////////////////////////////////////////
11
12#include "wx/wxprec.h"
13
14#ifdef __BORLANDC__
15 #pragma hdrstop
16#endif
17
3c3ead1d
PC
18#if wxUSE_RIBBON
19
4cf018e1 20#include "wx/ribbon/art.h"
3c3ead1d 21#include "wx/ribbon/art_internal.h"
3c3ead1d
PC
22#include "wx/ribbon/buttonbar.h"
23#include "wx/ribbon/gallery.h"
24#include "wx/ribbon/toolbar.h"
25
26#ifndef WX_PRECOMP
4cf018e1 27#include "wx/dcmemory.h"
3c3ead1d
PC
28#endif
29
30#ifdef __WXMSW__
31#include "wx/msw/private.h"
32#endif
33
34static 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
44static 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
54static 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
64static 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
74static 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
0a7ee6e0
VZ
84static 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
7c70331e
VZ
96static 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
110static 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
42d73941
VZ
124static 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
140static 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
3c3ead1d
PC
269wxRibbonMSWArtProvider::wxRibbonMSWArtProvider(bool set_colour_scheme)
270{
271 m_flags = 0;
2cd819c1
JS
272#if defined( __WXMAC__ )
273 m_tab_label_font = *wxSMALL_FONT;
274#else
7d8c1fbc 275 m_tab_label_font = *wxNORMAL_FONT;
2cd819c1 276#endif
3c3ead1d
PC
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;
42d73941
VZ
301 m_toggle_button_offset = 22;
302 m_help_button_offset = 22;
3c3ead1d
PC
303}
304
305wxRibbonMSWArtProvider::~wxRibbonMSWArtProvider()
306{
307}
308
309void 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
322void 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]
1edd6079 336 bool primary_is_gray = false;
4082ff84 337 static const double gray_saturation_threshold = 0.01;
1edd6079
PC
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 }
3c3ead1d
PC
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]
1edd6079
PC
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 }
3c3ead1d
PC
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) \
1edd6079
PC
363 primary_hsl.ShiftHue(h ## f).Saturated(primary_is_gray ? 0 : s ## f) \
364 .Lighter(l ## f).ToRGB()
3c3ead1d 365#define LikeSecondary(h, s, l) \
1edd6079
PC
366 secondary_hsl.ShiftHue(h ## f).Saturated(secondary_is_gray ? 0 : s ## f) \
367 .Lighter(l ## f).ToRGB()
3c3ead1d
PC
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);
ce00f59b 386 m_tab_border_pen = LikePrimary(1.4, 0.03, -0.05);
3c3ead1d 387 m_tab_separator_gradient_colour = LikePrimary(1.7, -0.15, -0.18);
ce00f59b 388 m_tab_hover_background_top_gradient_colour = LikePrimary(1.8, 0.34, 0.13);
3c3ead1d
PC
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;
0a7ee6e0
VZ
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));
3c3ead1d 409
7c70331e
VZ
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
3c3ead1d 415 m_gallery_button_disabled_background_colour = LikePrimary(-2.8, -0.46, 0.09);
ce00f59b 416 m_gallery_button_disabled_background_top_brush = LikePrimary(-2.8, -0.36, 0.15);
3c3ead1d
PC
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);
ce00f59b 436
3c3ead1d 437 m_button_bar_label_colour = m_tab_label_colour;
94f39d81
VZ
438 m_button_bar_label_disabled_colour = m_tab_label_colour;
439
3c3ead1d
PC
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
473wxRibbonArtProvider* wxRibbonMSWArtProvider::Clone() const
474{
475 wxRibbonMSWArtProvider *copy = new wxRibbonMSWArtProvider;
476 CloneTo(copy);
477 return copy;
478}
479
480void wxRibbonMSWArtProvider::CloneTo(wxRibbonMSWArtProvider* copy) const
481{
59c9dd5c
JS
482 int i;
483 for(i = 0; i < 4; ++i)
3c3ead1d
PC
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 }
59c9dd5c 489 for(i = 0; i < 2; ++i)
0a7ee6e0
VZ
490 {
491 copy->m_panel_extension_bitmap[i] = m_panel_extension_bitmap[i];
7c70331e
VZ
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];
42d73941
VZ
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];
0a7ee6e0 496 }
3c3ead1d
PC
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
7c70331e
VZ
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
3c3ead1d 506 copy->m_button_bar_label_colour = m_button_bar_label_colour;
94f39d81 507 copy->m_button_bar_label_disabled_colour = m_button_bar_label_disabled_colour;
3c3ead1d
PC
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;
0a7ee6e0
VZ
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;
3c3ead1d
PC
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;
ce00f59b 543 copy->m_gallery_button_background_gradient_colour = m_gallery_button_background_gradient_colour;
3c3ead1d
PC
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;
0a7ee6e0 558 copy->m_panel_hover_button_background_brush = m_panel_hover_button_background_brush;
3c3ead1d
PC
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;
7c70331e 564 copy->m_ribbon_toggle_brush = m_ribbon_toggle_brush;
3c3ead1d
PC
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;
0a7ee6e0 575 copy->m_panel_hover_button_border_pen = m_panel_hover_button_border_pen;
3c3ead1d
PC
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;
7c70331e 582 copy->m_ribbon_toggle_pen = m_ribbon_toggle_pen;
3c3ead1d
PC
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
598long wxRibbonMSWArtProvider::GetFlags() const
599{
600 return m_flags;
601}
602
603void 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);
0a7ee6e0
VZ
630 Reload(wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR);
631 Reload(wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR);
3c3ead1d
PC
632#undef Reload
633}
634
635int 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
671void 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
717void 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
736wxFont 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
754wxColour 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;
94f39d81
VZ
760 case wxRIBBON_ART_BUTTON_BAR_LABEL_DISABLED_COLOUR:
761 return m_button_bar_label_disabled_colour;
3c3ead1d
PC
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;
0a7ee6e0
VZ
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;
3c3ead1d
PC
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;
7c70331e
VZ
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;
3c3ead1d
PC
905 default:
906 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
907 break;
908 }
909
910 return wxColour();
911}
912
913void 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;
94f39d81
VZ
920 case wxRIBBON_ART_BUTTON_BAR_LABEL_DISABLED_COLOUR:
921 m_button_bar_label_disabled_colour = colour;
922 break;
3c3ead1d
PC
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;
0a7ee6e0
VZ
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;
3c3ead1d
PC
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;
7c70331e
VZ
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);
42d73941
VZ
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);
7c70331e
VZ
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);
42d73941
VZ
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);
7c70331e 1191 break;
3c3ead1d
PC
1192 default:
1193 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
1194 break;
1195 }
1196}
1197
1198void 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
1218void wxRibbonMSWArtProvider::DrawTab(
1219 wxDC& dc,
1220 wxWindow* WXUNUSED(wnd),
1221 const wxRibbonPageTabInfo& tab)
1222{
1223 if(tab.rect.height <= 2)
1224 return;
1225
70f86ded 1226 if(tab.active || tab.hovered || tab.highlight)
3c3ead1d
PC
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);
70f86ded
VZ
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);
3c3ead1d
PC
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();
f6ac1f4b
RR
1330 if(icon.IsOk())
1331 {
3c3ead1d
PC
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);
f6ac1f4b 1337 }
3c3ead1d
PC
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
1373void 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
1399void 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
1438void wxRibbonMSWArtProvider::DrawPartialPageBackground(wxDC& dc,
7d1214cd 1439 wxWindow* wnd, const wxRect& r, wxRibbonPage* page,
3c3ead1d
PC
1440 wxPoint offset, bool hovered)
1441{
140091e5
PC
1442 wxRect background;
1443 // Expanded panels need a background - the expanded panel at
59c9dd5c 1444 // best size may have a greater Y dimension higher than when
140091e5
PC
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.
59c9dd5c 1447 // Expanded panels use a wxFrame as parent (not a wxRibbonPage).
140091e5
PC
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 }
3c3ead1d
PC
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
7d1214cd 1476 wxRect paint_rect(r);
3c3ead1d
PC
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
1525void 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
1580void 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
1724void 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
1736void 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
1750void 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);
0a7ee6e0 1759 bool has_ext_button = wnd->HasExtButton();
3c3ead1d
PC
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
0a7ee6e0
VZ
1787 wxRect label_bg_rect = label_rect;
1788
1789 if(has_ext_button)
1790 label_rect.SetWidth(label_rect.GetWidth() - 13);
1791
3c3ead1d
PC
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
0a7ee6e0 1820 dc.DrawRectangle(label_bg_rect);
3c3ead1d
PC
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 }
0a7ee6e0
VZ
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 }
3c3ead1d
PC
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
0a7ee6e0
VZ
1862wxRect 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
3c3ead1d
PC
1871void 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
1906void 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
1957void 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
2019void 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
2069void 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
2111void 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;
ce00f59b 2129 dc.GradientFillLinear(client_rect,
3c3ead1d
PC
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;
ce00f59b 2135 dc.GradientFillLinear(client_rect,
3c3ead1d
PC
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
2209void 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);
ce00f59b 2244
3c3ead1d
PC
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
2269void wxRibbonMSWArtProvider::DrawButtonBarBackground(
2270 wxDC& dc,
2271 wxWindow* wnd,
2272 const wxRect& rect)
2273{
2274 DrawPartialPageBackground(dc, wnd, rect, true);
2275}
2276
2277void 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();
00491f99 2289 wxRibbonPanel* panel = wxDynamicCast(wnd, wxRibbonPanel);
3c3ead1d
PC
2290 bool hovered = false;
2291
3c3ead1d
PC
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
2334void 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{
955bad41
PC
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
3c3ead1d
PC
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);
94f39d81
VZ
2455 dc.SetTextForeground(state & wxRIBBON_BUTTONBAR_BUTTON_DISABLED
2456 ? m_button_bar_label_disabled_colour
2457 : m_button_bar_label_colour);
3c3ead1d
PC
2458 DrawButtonBarButtonForeground(dc, rect, kind, state, label, bitmap_large,
2459 bitmap_small);
2460}
2461
2462void 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{
c4c87bf2
VZ
2471 const wxColour
2472 arrowColour(state & wxRIBBON_BUTTONBAR_BUTTON_DISABLED
2473 ? m_button_bar_label_disabled_colour
2474 : m_button_bar_label_colour);
2475
3c3ead1d
PC
2476 switch(state & wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK)
2477 {
2478 case wxRIBBON_BUTTONBAR_BUTTON_LARGE:
2479 {
2480 const int padding = 2;
2481 dc.DrawBitmap(bitmap_large,
2482 rect.x + (rect.width - bitmap_large.GetWidth()) / 2,
2483 rect.y + padding, true);
2484 int ypos = rect.y + padding + bitmap_large.GetHeight() + padding;
2485 int arrow_width = kind == wxRIBBON_BUTTON_NORMAL ? 0 : 8;
2486 wxCoord label_w, label_h;
2487 dc.GetTextExtent(label, &label_w, &label_h);
2488 if(label_w + 2 * padding <= rect.width)
2489 {
2490 dc.DrawText(label, rect.x + (rect.width - label_w) / 2, ypos);
2491 if(arrow_width != 0)
2492 {
2493 DrawDropdownArrow(dc, rect.x + rect.width / 2,
2494 ypos + (label_h * 3) / 2,
c4c87bf2 2495 arrowColour);
3c3ead1d
PC
2496 }
2497 }
2498 else
2499 {
2500 size_t breaki = label.Len();
2501 do
2502 {
2503 --breaki;
2504 if(wxRibbonCanLabelBreakAtPosition(label, breaki))
2505 {
2506 wxString label_top = label.Mid(0, breaki);
2507 dc.GetTextExtent(label_top, &label_w, &label_h);
2508 if(label_w + 2 * padding <= rect.width)
2509 {
2510 dc.DrawText(label_top,
2511 rect.x + (rect.width - label_w) / 2, ypos);
2512 ypos += label_h;
2513 wxString label_bottom = label.Mid(breaki + 1);
2514 dc.GetTextExtent(label_bottom, &label_w, &label_h);
2515 label_w += arrow_width;
2516 int iX = rect.x + (rect.width - label_w) / 2;
2517 dc.DrawText(label_bottom, iX, ypos);
2518 if(arrow_width != 0)
2519 {
ce00f59b 2520 DrawDropdownArrow(dc,
3c3ead1d
PC
2521 iX + 2 +label_w - arrow_width,
2522 ypos + label_h / 2 + 1,
c4c87bf2 2523 arrowColour);
3c3ead1d
PC
2524 }
2525 break;
2526 }
2527 }
2528 } while(breaki > 0);
2529 }
2530 }
2531 break;
2532 case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM:
2533 {
2534 int x_cursor = rect.x + 2;
2535 dc.DrawBitmap(bitmap_small, x_cursor,
2536 rect.y + (rect.height - bitmap_small.GetHeight())/2, true);
2537 x_cursor += bitmap_small.GetWidth() + 2;
2538 wxCoord label_w, label_h;
2539 dc.GetTextExtent(label, &label_w, &label_h);
2540 dc.DrawText(label, x_cursor,
2541 rect.y + (rect.height - label_h) / 2);
2542 x_cursor += label_w + 3;
2543 if(kind != wxRIBBON_BUTTON_NORMAL)
2544 {
c4c87bf2 2545 DrawDropdownArrow(dc, x_cursor, rect.y + rect.height / 2, arrowColour);
3c3ead1d
PC
2546 }
2547 break;
2548 }
2549 default:
2550 // TODO
2551 break;
2552 }
2553}
2554
2555void wxRibbonMSWArtProvider::DrawToolBarBackground(
2556 wxDC& dc,
2557 wxWindow* wnd,
2558 const wxRect& rect)
2559{
2560 DrawPartialPageBackground(dc, wnd, rect);
2561}
2562
2563void wxRibbonMSWArtProvider::DrawToolGroupBackground(
2564 wxDC& dc,
2565 wxWindow* WXUNUSED(wnd),
2566 const wxRect& rect)
2567{
2568 dc.SetPen(m_toolbar_border_pen);
2569 wxPoint outline[9];
2570 outline[0] = wxPoint(2, 0);
2571 outline[1] = wxPoint(rect.width - 3, 0);
2572 outline[2] = wxPoint(rect.width - 1, 2);
2573 outline[3] = wxPoint(rect.width - 1, rect.height - 3);
2574 outline[4] = wxPoint(rect.width - 3, rect.height - 1);
2575 outline[5] = wxPoint(2, rect.height - 1);
2576 outline[6] = wxPoint(0, rect.height - 3);
2577 outline[7] = wxPoint(0, 2);
2578 outline[8] = outline[0];
2579
2580 dc.DrawLines(sizeof(outline)/sizeof(wxPoint), outline, rect.x, rect.y);
2581}
2582
2583void wxRibbonMSWArtProvider::DrawTool(
2584 wxDC& dc,
2585 wxWindow* WXUNUSED(wnd),
2586 const wxRect& rect,
2587 const wxBitmap& bitmap,
2588 wxRibbonButtonKind kind,
2589 long state)
2590{
d1bf0be0
VZ
2591 if(kind == wxRIBBON_BUTTON_TOGGLE)
2592 {
2593 if(state & wxRIBBON_TOOLBAR_TOOL_TOGGLED)
2594 state ^= wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK;
2595 }
2596
3c3ead1d
PC
2597 wxRect bg_rect(rect);
2598 bg_rect.Deflate(1);
2599 if((state & wxRIBBON_TOOLBAR_TOOL_LAST) == 0)
2600 bg_rect.width++;
2601 bool is_split_hybrid = (kind == wxRIBBON_BUTTON_HYBRID && (state &
2602 (wxRIBBON_TOOLBAR_TOOL_HOVER_MASK | wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK)));
2603
2604 // Background
2605 wxRect bg_rect_top(bg_rect);
2606 bg_rect_top.height = (bg_rect_top.height * 2) / 5;
2607 wxRect bg_rect_btm(bg_rect);
2608 bg_rect_btm.y += bg_rect_top.height;
2609 bg_rect_btm.height -= bg_rect_top.height;
2610 wxColour bg_top_colour = m_tool_background_top_colour;
2611 wxColour bg_top_grad_colour = m_tool_background_top_gradient_colour;
2612 wxColour bg_colour = m_tool_background_colour;
2613 wxColour bg_grad_colour = m_tool_background_gradient_colour;
2614 if(state & wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK)
2615 {
2616 bg_top_colour = m_tool_active_background_top_colour;
2617 bg_top_grad_colour = m_tool_active_background_top_gradient_colour;
2618 bg_colour = m_tool_active_background_colour;
2619 bg_grad_colour = m_tool_active_background_gradient_colour;
2620 }
2621 else if(state & wxRIBBON_TOOLBAR_TOOL_HOVER_MASK)
2622 {
2623 bg_top_colour = m_tool_hover_background_top_colour;
2624 bg_top_grad_colour = m_tool_hover_background_top_gradient_colour;
2625 bg_colour = m_tool_hover_background_colour;
2626 bg_grad_colour = m_tool_hover_background_gradient_colour;
2627 }
2628 dc.GradientFillLinear(bg_rect_top, bg_top_colour, bg_top_grad_colour, wxSOUTH);
2629 dc.GradientFillLinear(bg_rect_btm, bg_colour, bg_grad_colour, wxSOUTH);
2630 if(is_split_hybrid)
2631 {
2632 wxRect nonrect(bg_rect);
2633 if(state & (wxRIBBON_TOOLBAR_TOOL_DROPDOWN_HOVERED |
2634 wxRIBBON_TOOLBAR_TOOL_DROPDOWN_ACTIVE))
2635 {
2636 nonrect.width -= 8;
2637 }
2638 else
2639 {
2640 nonrect.x += nonrect.width - 8;
2641 nonrect.width = 8;
2642 }
2643 wxBrush B(m_tool_hover_background_top_colour);
2644 dc.SetPen(*wxTRANSPARENT_PEN);
2645 dc.SetBrush(B);
2646 dc.DrawRectangle(nonrect.x, nonrect.y, nonrect.width, nonrect.height);
2647 }
ce00f59b 2648
3c3ead1d
PC
2649 // Border
2650 dc.SetPen(m_toolbar_border_pen);
2651 if(state & wxRIBBON_TOOLBAR_TOOL_FIRST)
2652 {
2653 dc.DrawPoint(rect.x + 1, rect.y + 1);
2654 dc.DrawPoint(rect.x + 1, rect.y + rect.height - 2);
2655 }
2656 else
ce00f59b 2657 dc.DrawLine(rect.x, rect.y + 1, rect.x, rect.y + rect.height - 1);
3c3ead1d
PC
2658
2659 if(state & wxRIBBON_TOOLBAR_TOOL_LAST)
2660 {
2661 dc.DrawPoint(rect.x + rect.width - 2, rect.y + 1);
2662 dc.DrawPoint(rect.x + rect.width - 2, rect.y + rect.height - 2);
2663 }
2664
2665 // Foreground
2666 int avail_width = bg_rect.GetWidth();
d1bf0be0 2667 if(kind & wxRIBBON_BUTTON_DROPDOWN)
3c3ead1d
PC
2668 {
2669 avail_width -= 8;
2670 if(is_split_hybrid)
2671 {
ce00f59b 2672 dc.DrawLine(rect.x + avail_width + 1, rect.y,
3c3ead1d
PC
2673 rect.x + avail_width + 1, rect.y + rect.height);
2674 }
2675 dc.DrawBitmap(m_toolbar_drop_bitmap, bg_rect.x + avail_width + 2,
2676 bg_rect.y + (bg_rect.height / 2) - 2, true);
2677 }
2678 dc.DrawBitmap(bitmap, bg_rect.x + (avail_width - bitmap.GetWidth()) / 2,
2679 bg_rect.y + (bg_rect.height - bitmap.GetHeight()) / 2, true);
2680}
2681
7c70331e
VZ
2682void
2683wxRibbonMSWArtProvider::DrawToggleButton(wxDC& dc,
2684 wxRibbonBar* wnd,
2685 const wxRect& rect,
42d73941 2686 wxRibbonDisplayMode mode)
7c70331e 2687{
42d73941 2688 int bindex = 0;
7c70331e
VZ
2689 DrawPartialPageBackground(dc, wnd, rect, false);
2690
2691 dc.DestroyClippingRegion();
2692 dc.SetClippingRegion(rect);
2693
2694 if(wnd->IsToggleButtonHovered())
2695 {
2696 dc.SetPen(m_ribbon_toggle_pen);
2697 dc.SetBrush(m_ribbon_toggle_brush);
42d73941
VZ
2698 dc.DrawRoundedRectangle(rect.GetX(), rect.GetY(), 20, 20, 1.0);
2699 bindex = 1;
2700 }
2701 switch(mode)
2702 {
2703 case wxRIBBON_BAR_PINNED:
2704 dc.DrawBitmap(m_ribbon_toggle_up_bitmap[bindex], rect.GetX()+7, rect.GetY()+6, true);
2705 break;
2706 case wxRIBBON_BAR_MINIMIZED:
2707 dc.DrawBitmap(m_ribbon_toggle_down_bitmap[bindex], rect.GetX()+7, rect.GetY()+6, true);
2708 break;
2709 case wxRIBBON_BAR_EXPANDED:
2710 dc.DrawBitmap(m_ribbon_toggle_pin_bitmap[bindex], rect.GetX ()+4, rect.GetY ()+5, true);
2711 break;
2712 }
2713}
2714
2715void wxRibbonMSWArtProvider::DrawHelpButton(wxDC& dc,
2716 wxRibbonBar* wnd,
2717 const wxRect& rect)
2718{
2719 DrawPartialPageBackground(dc, wnd, rect, false);
2720
2721 dc.DestroyClippingRegion();
2722 dc.SetClippingRegion(rect);
2723
2724 if ( wnd->IsHelpButtonHovered() )
2725 {
2726 dc.SetPen(m_ribbon_toggle_pen);
2727 dc.SetBrush(m_ribbon_toggle_brush);
2728 dc.DrawRoundedRectangle(rect.GetX(), rect.GetY(), 20, 20, 1.0);
2729 dc.DrawBitmap(m_ribbon_bar_help_button_bitmap[1], rect.GetX ()+4, rect.GetY()+5, true);
7c70331e
VZ
2730 }
2731 else
2732 {
42d73941 2733 dc.DrawBitmap(m_ribbon_bar_help_button_bitmap[0], rect.GetX ()+4, rect.GetY()+5, true);
7c70331e 2734 }
42d73941 2735
7c70331e
VZ
2736}
2737
3c3ead1d
PC
2738void wxRibbonMSWArtProvider::GetBarTabWidth(
2739 wxDC& dc,
2740 wxWindow* WXUNUSED(wnd),
2741 const wxString& label,
2742 const wxBitmap& bitmap,
2743 int* ideal,
2744 int* small_begin_need_separator,
2745 int* small_must_have_separator,
2746 int* minimum)
2747{
2748 int width = 0;
2749 int min = 0;
2750 if((m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) && !label.IsEmpty())
2751 {
2752 dc.SetFont(m_tab_label_font);
2753 width += dc.GetTextExtent(label).GetWidth();
2754 min += wxMin(25, width); // enough for a few chars
2755 if(bitmap.IsOk())
2756 {
2757 // gap between label and bitmap
2758 width += 4;
2759 min += 2;
2760 }
2761 }
2762 if((m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS) && bitmap.IsOk())
2763 {
2764 width += bitmap.GetWidth();
2765 min += bitmap.GetWidth();
2766 }
2767
2768 if(ideal != NULL)
2769 {
2770 *ideal = width + 30;
2771 }
2772 if(small_begin_need_separator != NULL)
2773 {
2774 *small_begin_need_separator = width + 20;
2775 }
2776 if(small_must_have_separator != NULL)
2777 {
2778 *small_must_have_separator = width + 10;
2779 }
2780 if(minimum != NULL)
2781 {
2782 *minimum = min;
2783 }
2784}
2785
2786int wxRibbonMSWArtProvider::GetTabCtrlHeight(
2787 wxDC& dc,
2788 wxWindow* WXUNUSED(wnd),
2789 const wxRibbonPageTabInfoArray& pages)
2790{
2791 int text_height = 0;
2792 int icon_height = 0;
2793
2794 if(pages.GetCount() <= 1 && (m_flags & wxRIBBON_BAR_ALWAYS_SHOW_TABS) == 0)
2795 {
2796 // To preserve space, a single tab need not be displayed. We still need
2797 // two pixels of border / padding though.
2798 return 2;
2799 }
2800
2801 if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS)
2802 {
2803 dc.SetFont(m_tab_label_font);
2804 text_height = dc.GetTextExtent(wxT("ABCDEFXj")).GetHeight() + 10;
2805 }
2806 if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS)
2807 {
2808 size_t numpages = pages.GetCount();
2809 for(size_t i = 0; i < numpages; ++i)
2810 {
2811 const wxRibbonPageTabInfo& info = pages.Item(i);
2812 if(info.page->GetIcon().IsOk())
2813 {
2814 icon_height = wxMax(icon_height, info.page->GetIcon().GetHeight() + 4);
2815 }
2816 }
2817 }
2818
2819 return wxMax(text_height, icon_height);
2820}
2821
2822wxSize wxRibbonMSWArtProvider::GetScrollButtonMinimumSize(
2823 wxDC& WXUNUSED(dc),
2824 wxWindow* WXUNUSED(wnd),
2825 long WXUNUSED(style))
2826{
2827 return wxSize(12, 12);
2828}
2829
2830wxSize wxRibbonMSWArtProvider::GetPanelSize(
2831 wxDC& dc,
2832 const wxRibbonPanel* wnd,
2833 wxSize client_size,
2834 wxPoint* client_offset)
2835{
2836 dc.SetFont(m_panel_label_font);
2837 wxSize label_size = dc.GetTextExtent(wnd->GetLabel());
2838
2839 client_size.IncBy(0, label_size.GetHeight());
2840 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
2841 client_size.IncBy(4, 8);
2842 else
2843 client_size.IncBy(6, 6);
2844
2845 if(client_offset != NULL)
2846 {
2847 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
2848 *client_offset = wxPoint(2, 3);
2849 else
2850 *client_offset = wxPoint(3, 2);
2851 }
2852
2853 return client_size;
2854}
2855
2856wxSize wxRibbonMSWArtProvider::GetPanelClientSize(
2857 wxDC& dc,
2858 const wxRibbonPanel* wnd,
2859 wxSize size,
2860 wxPoint* client_offset)
2861{
2862 dc.SetFont(m_panel_label_font);
2863 wxSize label_size = dc.GetTextExtent(wnd->GetLabel());
2864
2865 size.DecBy(0, label_size.GetHeight());
2866 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
2867 size.DecBy(4, 8);
2868 else
2869 size.DecBy(6, 6);
2870
2871 if(client_offset != NULL)
2872 {
2873 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
2874 *client_offset = wxPoint(2, 3);
2875 else
2876 *client_offset = wxPoint(3, 2);
2877 }
16eac072
PC
2878 if (size.x < 0) size.x = 0;
2879 if (size.y < 0) size.y = 0;
3c3ead1d
PC
2880
2881 return size;
2882}
2883
2884wxSize wxRibbonMSWArtProvider::GetGallerySize(
2885 wxDC& WXUNUSED(dc),
2886 const wxRibbonGallery* WXUNUSED(wnd),
2887 wxSize client_size)
2888{
2889 client_size.IncBy( 2, 1); // Left / top padding
2890 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
2891 client_size.IncBy(1, 16); // Right / bottom padding
2892 else
2893 client_size.IncBy(16, 1); // Right / bottom padding
2894 return client_size;
2895}
2896
2897wxSize wxRibbonMSWArtProvider::GetGalleryClientSize(
2898 wxDC& WXUNUSED(dc),
2899 const wxRibbonGallery* WXUNUSED(wnd),
2900 wxSize size,
2901 wxPoint* client_offset,
2902 wxRect* scroll_up_button,
2903 wxRect* scroll_down_button,
2904 wxRect* extension_button)
2905{
2906 wxRect scroll_up;
2907 wxRect scroll_down;
2908 wxRect extension;
2909 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
2910 {
2911 // Flow is vertical - put buttons on bottom
2912 scroll_up.y = size.GetHeight() - 15;
2913 scroll_up.height = 15;
2914 scroll_up.x = 0;
2915 scroll_up.width = (size.GetWidth() + 2) / 3;
2916 scroll_down.y = scroll_up.y;
2917 scroll_down.height = scroll_up.height;
2918 scroll_down.x = scroll_up.x + scroll_up.width;
ce00f59b 2919 scroll_down.width = scroll_up.width;
3c3ead1d
PC
2920 extension.y = scroll_down.y;
2921 extension.height = scroll_down.height;
2922 extension.x = scroll_down.x + scroll_down.width;
2923 extension.width = size.GetWidth() - scroll_up.width - scroll_down.width;
2924 size.DecBy(1, 16);
2925 size.DecBy( 2, 1);
2926 }
2927 else
2928 {
2929 // Flow is horizontal - put buttons on right
2930 scroll_up.x = size.GetWidth() - 15;
2931 scroll_up.width = 15;
2932 scroll_up.y = 0;
2933 scroll_up.height = (size.GetHeight() + 2) / 3;
2934 scroll_down.x = scroll_up.x;
2935 scroll_down.width = scroll_up.width;
2936 scroll_down.y = scroll_up.y + scroll_up.height;
ce00f59b 2937 scroll_down.height = scroll_up.height;
3c3ead1d
PC
2938 extension.x = scroll_down.x;
2939 extension.width = scroll_down.width;
2940 extension.y = scroll_down.y + scroll_down.height;
2941 extension.height = size.GetHeight() - scroll_up.height - scroll_down.height;
2942 size.DecBy(16, 1);
2943 size.DecBy( 2, 1);
2944 }
ce00f59b 2945
3c3ead1d
PC
2946 if(client_offset != NULL)
2947 *client_offset = wxPoint(2, 1);
2948 if(scroll_up_button != NULL)
2949 *scroll_up_button = scroll_up;
2950 if(scroll_down_button != NULL)
2951 *scroll_down_button = scroll_down;
2952 if(extension_button != NULL)
2953 *extension_button = extension;
2954
2955 return size;
2956}
2957
2958wxRect wxRibbonMSWArtProvider::GetPageBackgroundRedrawArea(
2959 wxDC& WXUNUSED(dc),
2960 const wxRibbonPage* WXUNUSED(wnd),
2961 wxSize page_old_size,
2962 wxSize page_new_size)
2963{
2964 wxRect new_rect, old_rect;
2965
2966 if(page_new_size.GetWidth() != page_old_size.GetWidth())
2967 {
2968 if(page_new_size.GetHeight() != page_old_size.GetHeight())
2969 {
2970 // Width and height both changed - redraw everything
2971 return wxRect(page_new_size);
2972 }
2973 else
2974 {
2975 // Only width changed - redraw right hand side
2976 const int right_edge_width = 4;
2977
2978 new_rect = wxRect(page_new_size.GetWidth() - right_edge_width, 0, right_edge_width, page_new_size.GetHeight());
2979 old_rect = wxRect(page_old_size.GetWidth() - right_edge_width, 0, right_edge_width, page_old_size.GetHeight());
2980 }
2981 }
2982 else
2983 {
2984 if(page_new_size.GetHeight() == page_old_size.GetHeight())
2985 {
2986 // Nothing changed (should never happen) - redraw nothing
2987 return wxRect(0, 0, 0, 0);
2988 }
2989 else
2990 {
2991 // Height changed - need to redraw everything (as the background
2992 // gradient is done vertically).
2993 return page_new_size;
2994 }
2995 }
2996
2997 new_rect.Union(old_rect);
2998 new_rect.Intersect(wxRect(page_new_size));
2999 return new_rect;
3000}
3001
3002bool wxRibbonMSWArtProvider::GetButtonBarButtonSize(
3003 wxDC& dc,
3004 wxWindow* wnd,
3005 wxRibbonButtonKind kind,
3006 wxRibbonButtonBarButtonState size,
3007 const wxString& label,
3008 wxSize bitmap_size_large,
3009 wxSize bitmap_size_small,
3010 wxSize* button_size,
3011 wxRect* normal_region,
3012 wxRect* dropdown_region)
3013{
3014 const int drop_button_width = 8;
3015
3016 dc.SetFont(m_button_bar_label_font);
3017 switch(size & wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK)
3018 {
3019 case wxRIBBON_BUTTONBAR_BUTTON_SMALL:
3020 // Small bitmap, no label
3021 *button_size = bitmap_size_small + wxSize(6, 4);
3022 switch(kind)
3023 {
3024 case wxRIBBON_BUTTON_NORMAL:
955bad41 3025 case wxRIBBON_BUTTON_TOGGLE:
3c3ead1d
PC
3026 *normal_region = wxRect(*button_size);
3027 *dropdown_region = wxRect(0, 0, 0, 0);
3028 break;
3029 case wxRIBBON_BUTTON_DROPDOWN:
3030 *button_size += wxSize(drop_button_width, 0);
3031 *dropdown_region = wxRect(*button_size);
3032 *normal_region = wxRect(0, 0, 0, 0);
3033 break;
3034 case wxRIBBON_BUTTON_HYBRID:
3035 *normal_region = wxRect(*button_size);
3036 *dropdown_region = wxRect(button_size->GetWidth(), 0,
3037 drop_button_width, button_size->GetHeight());
3038 *button_size += wxSize(drop_button_width, 0);
3039 break;
3040 }
3041 break;
3042 case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM:
3043 // Small bitmap, with label to the right
3044 {
3045 GetButtonBarButtonSize(dc, wnd, kind, wxRIBBON_BUTTONBAR_BUTTON_SMALL,
3046 label, bitmap_size_large, bitmap_size_small, button_size,
3047 normal_region, dropdown_region);
3048 int text_size = dc.GetTextExtent(label).GetWidth();
3049 button_size->SetWidth(button_size->GetWidth() + text_size);
3050 switch(kind)
3051 {
3052 case wxRIBBON_BUTTON_DROPDOWN:
3053 dropdown_region->SetWidth(dropdown_region->GetWidth() + text_size);
3054 break;
3055 case wxRIBBON_BUTTON_HYBRID:
3056 dropdown_region->SetX(dropdown_region->GetX() + text_size);
3057 // no break
3058 case wxRIBBON_BUTTON_NORMAL:
955bad41 3059 case wxRIBBON_BUTTON_TOGGLE:
3c3ead1d
PC
3060 normal_region->SetWidth(normal_region->GetWidth() + text_size);
3061 break;
3062 }
3063 break;
3064 }
3065 case wxRIBBON_BUTTONBAR_BUTTON_LARGE:
3066 // Large bitmap, with label below (possibly split over 2 lines)
3067 {
3068 wxSize icon_size(bitmap_size_large);
3069 icon_size += wxSize(4, 4);
3070 wxCoord label_height;
3071 wxCoord best_width;
3072 dc.GetTextExtent(label, &best_width, &label_height);
3c3ead1d 3073 int last_line_extra_width = 0;
955bad41 3074 if(kind != wxRIBBON_BUTTON_NORMAL && kind != wxRIBBON_BUTTON_TOGGLE)
3c3ead1d
PC
3075 {
3076 last_line_extra_width += 8;
3c3ead1d
PC
3077 }
3078 size_t i;
3079 for(i = 0; i < label.Len(); ++i)
3080 {
3081 if(wxRibbonCanLabelBreakAtPosition(label, i))
3082 {
3083 int width = wxMax(
083ec26f 3084 dc.GetTextExtent(label.Left(i)).GetWidth(),
3c3ead1d
PC
3085 dc.GetTextExtent(label.Mid(i + 1)).GetWidth() + last_line_extra_width);
3086 if(width < best_width)
3087 {
3088 best_width = width;
3c3ead1d
PC
3089 }
3090 }
3091 }
3092 label_height *= 2; // Assume two lines even when only one is used
3093 // (to give all buttons a consistent height)
3094 icon_size.SetWidth(wxMax(icon_size.GetWidth(), best_width) + 6);
3095 icon_size.SetHeight(icon_size.GetHeight() + label_height);
3096 *button_size = icon_size;
3097 switch(kind)
3098 {
3099 case wxRIBBON_BUTTON_DROPDOWN:
3100 *dropdown_region = wxRect(icon_size);
3101 break;
3102 case wxRIBBON_BUTTON_HYBRID:
3103 *normal_region = wxRect(icon_size);
3104 normal_region->height -= 2 + label_height;
3105 dropdown_region->x = 0;
3106 dropdown_region->y = normal_region->height;
3107 dropdown_region->width = icon_size.GetWidth();
3108 dropdown_region->height = icon_size.GetHeight() - normal_region->height;
3109 break;
3110 case wxRIBBON_BUTTON_NORMAL:
955bad41 3111 case wxRIBBON_BUTTON_TOGGLE:
3c3ead1d
PC
3112 *normal_region = wxRect(icon_size);
3113 break;
3114 }
3115 break;
3116 }
3117 };
3118 return true;
3119}
3120
3121wxSize wxRibbonMSWArtProvider::GetMinimisedPanelMinimumSize(
3122 wxDC& dc,
3123 const wxRibbonPanel* wnd,
3124 wxSize* desired_bitmap_size,
3125 wxDirection* expanded_panel_direction)
3126{
3127 if(desired_bitmap_size != NULL)
3128 {
3129 *desired_bitmap_size = wxSize(16, 16);
3130 }
3131 if(expanded_panel_direction != NULL)
3132 {
3133 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
3134 *expanded_panel_direction = wxEAST;
3135 else
3136 *expanded_panel_direction = wxSOUTH;
3137 }
3138 wxSize base_size(42, 42);
3139
3140 dc.SetFont(m_panel_label_font);
3141 wxSize label_size(dc.GetTextExtent(wnd->GetLabel()));
3142 label_size.IncBy(2, 2); // Allow for differences between this DC and a paint DC
3143 label_size.IncBy(6, 0); // Padding
3144 label_size.y *= 2; // Second line for dropdown button
3145
3146 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
3147 {
3148 // Label alongside icon
3149 return wxSize(base_size.x + label_size.x,
3150 wxMax(base_size.y, label_size.y));
3151 }
3152 else
3153 {
3154 // Label beneath icon
3155 return wxSize(wxMax(base_size.x, label_size.x),
3156 base_size.y + label_size.y);
3157 }
3158}
3159
3160wxSize wxRibbonMSWArtProvider::GetToolSize(
3161 wxDC& WXUNUSED(dc),
3162 wxWindow* WXUNUSED(wnd),
3163 wxSize bitmap_size,
3164 wxRibbonButtonKind kind,
3165 bool WXUNUSED(is_first),
3166 bool is_last,
3167 wxRect* dropdown_region)
3168{
3169 wxSize size(bitmap_size);
3170 size.IncBy(7, 6);
3171 if(is_last)
3172 size.IncBy(1, 0);
d1bf0be0 3173 if(kind & wxRIBBON_BUTTON_DROPDOWN)
3c3ead1d
PC
3174 {
3175 size.IncBy(8, 0);
3176 if(dropdown_region)
3177 {
3178 if(kind == wxRIBBON_BUTTON_DROPDOWN)
3179 *dropdown_region = size;
3180 else
3181 *dropdown_region = wxRect(size.GetWidth() - 8, 0, 8, size.GetHeight());
3182 }
3183 }
3184 else
3185 {
3186 if(dropdown_region)
3187 *dropdown_region = wxRect(0, 0, 0, 0);
3188 }
3189 return size;
3190}
3191
7c70331e 3192wxRect
42d73941 3193wxRibbonMSWArtProvider::GetBarToggleButtonArea(const wxRect& rect)
7c70331e 3194{
42d73941
VZ
3195 wxRect rectOut = wxRect(rect.GetWidth()-m_toggle_button_offset, 2, 20, 20);
3196 if ( (m_toggle_button_offset==22) && (m_help_button_offset==22) )
3197 m_help_button_offset += 22;
3198 return rectOut;
3199}
3200
3201wxRect
3202wxRibbonMSWArtProvider::GetRibbonHelpButtonArea(const wxRect& rect)
3203{
3204 wxRect rectOut = wxRect(rect.GetWidth()-m_help_button_offset, 2, 20, 20);
3205 if ( (m_toggle_button_offset==22) && (m_help_button_offset==22) )
3206 m_toggle_button_offset += 22;
3207 return rectOut;
7c70331e
VZ
3208}
3209
3c3ead1d 3210#endif // wxUSE_RIBBON