1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/ribbon/art_msw.cpp
3 // Purpose: MSW style art provider for ribbon interface
4 // Author: Peter Cawley
8 // Copyright: (C) Peter Cawley
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
20 #include "wx/ribbon/art.h"
21 #include "wx/ribbon/art_internal.h"
22 #include "wx/ribbon/buttonbar.h"
23 #include "wx/ribbon/gallery.h"
24 #include "wx/ribbon/toolbar.h"
27 #include "wx/dcmemory.h"
31 #include "wx/msw/private.h"
34 static const char* const gallery_up_xpm
[] = {
44 static const char* const gallery_down_xpm
[] = {
54 static const char* const gallery_left_xpm
[] = {
64 static const char* const gallery_right_xpm
[] = {
74 static const char* const gallery_extension_xpm
[] = {
84 static const char* const panel_extension_xpm
[] = {
96 static const char* const panel_toggle_down_xpm
[] = {
110 static const char* const panel_toggle_up_xpm
[] = {
124 static const char* const ribbon_toggle_pin_xpm
[] = {
140 static const char * const ribbon_help_button_xpm
[] = {
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."
269 wxRibbonMSWArtProvider::wxRibbonMSWArtProvider(bool set_colour_scheme
)
272 #if defined( __WXMAC__ )
273 m_tab_label_font
= *wxSMALL_FONT
;
275 m_tab_label_font
= *wxNORMAL_FONT
;
277 m_button_bar_label_font
= m_tab_label_font
;
278 m_panel_label_font
= m_tab_label_font
;
280 if(set_colour_scheme
)
283 wxColour(194, 216, 241),
284 wxColour(255, 223, 114),
288 m_cached_tab_separator_visibility
= -10.0; // valid visibilities are in range [0, 1]
289 m_tab_separation_size
= 3;
290 m_page_border_left
= 2;
291 m_page_border_top
= 1;
292 m_page_border_right
= 2;
293 m_page_border_bottom
= 3;
294 m_panel_x_separation_size
= 1;
295 m_panel_y_separation_size
= 1;
296 m_tool_group_separation_size
= 3;
297 m_gallery_bitmap_padding_left_size
= 4;
298 m_gallery_bitmap_padding_right_size
= 4;
299 m_gallery_bitmap_padding_top_size
= 4;
300 m_gallery_bitmap_padding_bottom_size
= 4;
301 m_toggle_button_offset
= 22;
302 m_help_button_offset
= 22;
305 wxRibbonMSWArtProvider::~wxRibbonMSWArtProvider()
309 void wxRibbonMSWArtProvider::GetColourScheme(
312 wxColour
* tertiary
) const
315 *primary
= m_primary_scheme_colour
;
316 if(secondary
!= NULL
)
317 *secondary
= m_secondary_scheme_colour
;
319 *tertiary
= m_tertiary_scheme_colour
;
322 void wxRibbonMSWArtProvider::SetColourScheme(
323 const wxColour
& primary
,
324 const wxColour
& secondary
,
325 const wxColour
& tertiary
)
327 m_primary_scheme_colour
= primary
;
328 m_secondary_scheme_colour
= secondary
;
329 m_tertiary_scheme_colour
= tertiary
;
331 wxRibbonHSLColour
primary_hsl(primary
);
332 wxRibbonHSLColour
secondary_hsl(secondary
);
333 // tertiary not used for anything
335 // Map primary saturation from [0, 1] to [.25, .75]
336 bool primary_is_gray
= false;
337 static const double gray_saturation_threshold
= 0.01;
338 if(primary_hsl
.saturation
<= gray_saturation_threshold
)
339 primary_is_gray
= true;
342 primary_hsl
.saturation
= cos(primary_hsl
.saturation
* M_PI
)
346 // Map primary luminance from [0, 1] to [.23, .83]
347 primary_hsl
.luminance
= cos(primary_hsl
.luminance
* M_PI
) * -0.3 + 0.53;
349 // Map secondary saturation from [0, 1] to [0.16, 0.84]
350 bool secondary_is_gray
= false;
351 if(secondary_hsl
.saturation
<= gray_saturation_threshold
)
352 secondary_is_gray
= true;
355 secondary_hsl
.saturation
= cos(secondary_hsl
.saturation
* M_PI
)
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;
362 #define LikePrimary(h, s, l) \
363 primary_hsl.ShiftHue(h ## f).Saturated(primary_is_gray ? 0 : s ## f) \
364 .Lighter(l ## f).ToRGB()
365 #define LikeSecondary(h, s, l) \
366 secondary_hsl.ShiftHue(h ## f).Saturated(secondary_is_gray ? 0 : s ## f) \
367 .Lighter(l ## f).ToRGB()
369 m_page_border_pen
= LikePrimary(1.4, 0.00, -0.08);
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);
380 m_tab_active_background_colour
= LikePrimary(-0.1, -0.31, 0.16);
381 m_tab_active_background_gradient_colour
= LikePrimary(-0.1, -0.03, 0.12);
382 m_tab_separator_colour
= LikePrimary(0.9, 0.24, 0.05);
383 m_tab_ctrl_background_brush
= LikePrimary(1.0, 0.39, 0.07);
384 m_tab_hover_background_colour
= LikePrimary(1.3, 0.15, 0.10);
385 m_tab_hover_background_top_colour
= LikePrimary(1.4, 0.36, 0.08);
386 m_tab_border_pen
= LikePrimary(1.4, 0.03, -0.05);
387 m_tab_separator_gradient_colour
= LikePrimary(1.7, -0.15, -0.18);
388 m_tab_hover_background_top_gradient_colour
= LikePrimary(1.8, 0.34, 0.13);
389 m_tab_label_colour
= LikePrimary(4.3, 0.13, -0.49);
390 m_tab_hover_background_gradient_colour
= LikeSecondary(-1.5, -0.34, 0.01);
392 m_panel_minimised_border_gradient_pen
= LikePrimary(-6.9, -0.17, -0.09);
393 m_panel_minimised_border_pen
= LikePrimary(-5.3, -0.24, -0.06);
394 m_panel_border_gradient_pen
= LikePrimary(-5.2, -0.15, -0.06);
395 m_panel_border_pen
= LikePrimary(-2.8, -0.32, 0.02);
396 m_panel_label_background_brush
= LikePrimary(-1.5, 0.03, 0.05);
397 m_panel_active_background_gradient_colour
= LikePrimary(0.5, 0.34, 0.05);
398 m_panel_hover_label_background_brush
= LikePrimary(1.0, 0.30, 0.09);
399 m_panel_active_background_top_gradient_colour
= LikePrimary(1.4, -0.17, -0.13);
400 m_panel_active_background_colour
= LikePrimary(1.6, -0.18, -0.18);
401 m_panel_active_background_top_colour
= LikePrimary(1.7, -0.20, -0.03);
402 m_panel_label_colour
= LikePrimary(2.8, -0.14, -0.35);
403 m_panel_hover_label_colour
= m_panel_label_colour
;
404 m_panel_minimised_label_colour
= m_tab_label_colour
;
405 m_panel_hover_button_background_brush
= LikeSecondary(-0.9, 0.16, -0.07);
406 m_panel_hover_button_border_pen
= LikeSecondary(-3.9, -0.16, -0.14);
407 SetColour(wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR
, LikePrimary(1.4, -0.21, -0.23));
408 SetColour(wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR
, LikePrimary(1.5, -0.24, -0.29));
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));
415 m_gallery_button_disabled_background_colour
= LikePrimary(-2.8, -0.46, 0.09);
416 m_gallery_button_disabled_background_top_brush
= LikePrimary(-2.8, -0.36, 0.15);
417 m_gallery_hover_background_brush
= LikePrimary(-0.8, 0.05, 0.15);
418 m_gallery_border_pen
= LikePrimary(0.7, -0.02, 0.03);
419 m_gallery_button_background_top_brush
= LikePrimary(0.8, 0.34, 0.13);
420 m_gallery_button_background_colour
= LikePrimary(1.3, 0.10, 0.08);
421 // SetColour used so that the relevant bitmaps are generated
422 SetColour(wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR
, LikePrimary(1.4, -0.21, -0.23));
423 SetColour(wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR
, LikePrimary(1.5, -0.24, -0.29));
424 SetColour(wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR
, LikePrimary(1.5, -0.24, -0.29));
425 SetColour(wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR
, LikePrimary(0.0, -1.0, 0.0));
426 m_gallery_button_disabled_background_gradient_colour
= LikePrimary(1.5, -0.43, 0.12);
427 m_gallery_button_background_gradient_colour
= LikePrimary(1.7, 0.11, 0.09);
428 m_gallery_item_border_pen
= LikeSecondary(-3.9, -0.16, -0.14);
429 m_gallery_button_hover_background_colour
= LikeSecondary(-0.9, 0.16, -0.07);
430 m_gallery_button_hover_background_gradient_colour
= LikeSecondary(0.1, 0.12, 0.03);
431 m_gallery_button_hover_background_top_brush
= LikeSecondary(4.3, 0.16, 0.17);
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);
437 m_button_bar_label_colour
= m_tab_label_colour
;
438 m_button_bar_label_disabled_colour
= m_tab_label_colour
;
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);
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);
469 // Invalidate cached tab separator
470 m_cached_tab_separator_visibility
= -1.0;
473 wxRibbonArtProvider
* wxRibbonMSWArtProvider::Clone() const
475 wxRibbonMSWArtProvider
*copy
= new wxRibbonMSWArtProvider
;
480 void wxRibbonMSWArtProvider::CloneTo(wxRibbonMSWArtProvider
* copy
) const
483 for(i
= 0; i
< 4; ++i
)
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
];
489 for(i
= 0; i
< 2; ++i
)
491 copy
->m_panel_extension_bitmap
[i
] = m_panel_extension_bitmap
[i
];
492 copy
->m_ribbon_toggle_up_bitmap
[i
] = m_ribbon_toggle_up_bitmap
[i
];
493 copy
->m_ribbon_toggle_down_bitmap
[i
] = m_ribbon_toggle_down_bitmap
[i
];
494 copy
->m_ribbon_toggle_pin_bitmap
[i
] = m_ribbon_toggle_pin_bitmap
[i
];
495 copy
->m_ribbon_bar_help_button_bitmap
[i
] = m_ribbon_bar_help_button_bitmap
[i
];
497 copy
->m_toolbar_drop_bitmap
= m_toolbar_drop_bitmap
;
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
;
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
;
506 copy
->m_button_bar_label_colour
= m_button_bar_label_colour
;
507 copy
->m_button_bar_label_disabled_colour
= m_button_bar_label_disabled_colour
;
508 copy
->m_tab_label_colour
= m_tab_label_colour
;
509 copy
->m_tab_separator_colour
= m_tab_separator_colour
;
510 copy
->m_tab_separator_gradient_colour
= m_tab_separator_gradient_colour
;
511 copy
->m_tab_active_background_colour
= m_tab_hover_background_colour
;
512 copy
->m_tab_active_background_gradient_colour
= m_tab_hover_background_gradient_colour
;
513 copy
->m_tab_hover_background_colour
= m_tab_hover_background_colour
;
514 copy
->m_tab_hover_background_gradient_colour
= m_tab_hover_background_gradient_colour
;
515 copy
->m_tab_hover_background_top_colour
= m_tab_hover_background_top_colour
;
516 copy
->m_tab_hover_background_top_gradient_colour
= m_tab_hover_background_top_gradient_colour
;
517 copy
->m_panel_label_colour
= m_panel_label_colour
;
518 copy
->m_panel_hover_label_colour
= m_panel_hover_label_colour
;
519 copy
->m_panel_minimised_label_colour
= m_panel_minimised_label_colour
;
520 copy
->m_panel_button_face_colour
= m_panel_button_face_colour
;
521 copy
->m_panel_button_hover_face_colour
= m_panel_button_hover_face_colour
;
522 copy
->m_panel_active_background_colour
= m_panel_active_background_colour
;
523 copy
->m_panel_active_background_gradient_colour
= m_panel_active_background_gradient_colour
;
524 copy
->m_panel_active_background_top_colour
= m_panel_active_background_top_colour
;
525 copy
->m_panel_active_background_top_gradient_colour
= m_panel_active_background_top_gradient_colour
;
526 copy
->m_page_background_colour
= m_page_background_colour
;
527 copy
->m_page_background_gradient_colour
= m_page_background_gradient_colour
;
528 copy
->m_page_background_top_colour
= m_page_background_top_colour
;
529 copy
->m_page_background_top_gradient_colour
= m_page_background_top_gradient_colour
;
530 copy
->m_page_hover_background_colour
= m_page_hover_background_colour
;
531 copy
->m_page_hover_background_gradient_colour
= m_page_hover_background_gradient_colour
;
532 copy
->m_page_hover_background_top_colour
= m_page_hover_background_top_colour
;
533 copy
->m_page_hover_background_top_gradient_colour
= m_page_hover_background_top_gradient_colour
;
534 copy
->m_button_bar_hover_background_colour
= m_button_bar_hover_background_colour
;
535 copy
->m_button_bar_hover_background_gradient_colour
= m_button_bar_hover_background_gradient_colour
;
536 copy
->m_button_bar_hover_background_top_colour
= m_button_bar_hover_background_top_colour
;
537 copy
->m_button_bar_hover_background_top_gradient_colour
= m_button_bar_hover_background_top_gradient_colour
;
538 copy
->m_button_bar_active_background_colour
= m_button_bar_active_background_colour
;
539 copy
->m_button_bar_active_background_gradient_colour
= m_button_bar_active_background_gradient_colour
;
540 copy
->m_button_bar_active_background_top_colour
= m_button_bar_active_background_top_colour
;
541 copy
->m_button_bar_active_background_top_gradient_colour
= m_button_bar_active_background_top_gradient_colour
;
542 copy
->m_gallery_button_background_colour
= m_gallery_button_background_colour
;
543 copy
->m_gallery_button_background_gradient_colour
= m_gallery_button_background_gradient_colour
;
544 copy
->m_gallery_button_hover_background_colour
= m_gallery_button_hover_background_colour
;
545 copy
->m_gallery_button_hover_background_gradient_colour
= m_gallery_button_hover_background_gradient_colour
;
546 copy
->m_gallery_button_active_background_colour
= m_gallery_button_active_background_colour
;
547 copy
->m_gallery_button_active_background_gradient_colour
= m_gallery_button_active_background_gradient_colour
;
548 copy
->m_gallery_button_disabled_background_colour
= m_gallery_button_disabled_background_colour
;
549 copy
->m_gallery_button_disabled_background_gradient_colour
= m_gallery_button_disabled_background_gradient_colour
;
550 copy
->m_gallery_button_face_colour
= m_gallery_button_face_colour
;
551 copy
->m_gallery_button_hover_face_colour
= m_gallery_button_hover_face_colour
;
552 copy
->m_gallery_button_active_face_colour
= m_gallery_button_active_face_colour
;
553 copy
->m_gallery_button_disabled_face_colour
= m_gallery_button_disabled_face_colour
;
555 copy
->m_tab_ctrl_background_brush
= m_tab_ctrl_background_brush
;
556 copy
->m_panel_label_background_brush
= m_panel_label_background_brush
;
557 copy
->m_panel_hover_label_background_brush
= m_panel_hover_label_background_brush
;
558 copy
->m_panel_hover_button_background_brush
= m_panel_hover_button_background_brush
;
559 copy
->m_gallery_hover_background_brush
= m_gallery_hover_background_brush
;
560 copy
->m_gallery_button_background_top_brush
= m_gallery_button_background_top_brush
;
561 copy
->m_gallery_button_hover_background_top_brush
= m_gallery_button_hover_background_top_brush
;
562 copy
->m_gallery_button_active_background_top_brush
= m_gallery_button_active_background_top_brush
;
563 copy
->m_gallery_button_disabled_background_top_brush
= m_gallery_button_disabled_background_top_brush
;
564 copy
->m_ribbon_toggle_brush
= m_ribbon_toggle_brush
;
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
;
570 copy
->m_page_border_pen
= m_page_border_pen
;
571 copy
->m_panel_border_pen
= m_panel_border_pen
;
572 copy
->m_panel_border_gradient_pen
= m_panel_border_gradient_pen
;
573 copy
->m_panel_minimised_border_pen
= m_panel_minimised_border_pen
;
574 copy
->m_panel_minimised_border_gradient_pen
= m_panel_minimised_border_gradient_pen
;
575 copy
->m_panel_hover_button_border_pen
= m_panel_hover_button_border_pen
;
576 copy
->m_tab_border_pen
= m_tab_border_pen
;
577 copy
->m_gallery_border_pen
= m_gallery_border_pen
;
578 copy
->m_button_bar_hover_border_pen
= m_button_bar_hover_border_pen
;
579 copy
->m_button_bar_active_border_pen
= m_button_bar_active_border_pen
;
580 copy
->m_gallery_item_border_pen
= m_gallery_item_border_pen
;
581 copy
->m_toolbar_border_pen
= m_toolbar_border_pen
;
582 copy
->m_ribbon_toggle_pen
= m_ribbon_toggle_pen
;
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
;
598 long wxRibbonMSWArtProvider::GetFlags() const
603 void wxRibbonMSWArtProvider::SetFlags(long flags
)
605 if((flags
^ m_flags
) & wxRIBBON_BAR_FLOW_VERTICAL
)
607 if(flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
609 m_page_border_left
++;
610 m_page_border_right
++;
612 m_page_border_bottom
--;
616 m_page_border_left
--;
617 m_page_border_right
--;
619 m_page_border_bottom
++;
624 // Need to reload some bitmaps when flags change
625 #define Reload(setting) SetColour(setting, GetColour(setting))
626 Reload(wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR
);
627 Reload(wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR
);
628 Reload(wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR
);
629 Reload(wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR
);
630 Reload(wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR
);
631 Reload(wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR
);
635 int wxRibbonMSWArtProvider::GetMetric(int id
) const
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
;
664 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
671 void wxRibbonMSWArtProvider::SetMetric(int id
, int new_val
)
675 case wxRIBBON_ART_TAB_SEPARATION_SIZE
:
676 m_tab_separation_size
= new_val
;
678 case wxRIBBON_ART_PAGE_BORDER_LEFT_SIZE
:
679 m_page_border_left
= new_val
;
681 case wxRIBBON_ART_PAGE_BORDER_TOP_SIZE
:
682 m_page_border_top
= new_val
;
684 case wxRIBBON_ART_PAGE_BORDER_RIGHT_SIZE
:
685 m_page_border_right
= new_val
;
687 case wxRIBBON_ART_PAGE_BORDER_BOTTOM_SIZE
:
688 m_page_border_bottom
= new_val
;
690 case wxRIBBON_ART_PANEL_X_SEPARATION_SIZE
:
691 m_panel_x_separation_size
= new_val
;
693 case wxRIBBON_ART_PANEL_Y_SEPARATION_SIZE
:
694 m_panel_y_separation_size
= new_val
;
696 case wxRIBBON_ART_TOOL_GROUP_SEPARATION_SIZE
:
697 m_tool_group_separation_size
= new_val
;
699 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_LEFT_SIZE
:
700 m_gallery_bitmap_padding_left_size
= new_val
;
702 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_RIGHT_SIZE
:
703 m_gallery_bitmap_padding_right_size
= new_val
;
705 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_TOP_SIZE
:
706 m_gallery_bitmap_padding_top_size
= new_val
;
708 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_BOTTOM_SIZE
:
709 m_gallery_bitmap_padding_bottom_size
= new_val
;
712 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
717 void wxRibbonMSWArtProvider::SetFont(int id
, const wxFont
& font
)
721 case wxRIBBON_ART_TAB_LABEL_FONT
:
722 m_tab_label_font
= font
;
724 case wxRIBBON_ART_BUTTON_BAR_LABEL_FONT
:
725 m_button_bar_label_font
= font
;
727 case wxRIBBON_ART_PANEL_LABEL_FONT
:
728 m_panel_label_font
= font
;
731 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
736 wxFont
wxRibbonMSWArtProvider::GetFont(int id
) const
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
;
747 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
754 wxColour
wxRibbonMSWArtProvider::GetColour(int id
) const
758 case wxRIBBON_ART_BUTTON_BAR_LABEL_COLOUR
:
759 return m_button_bar_label_colour
;
760 case wxRIBBON_ART_BUTTON_BAR_LABEL_DISABLED_COLOUR
:
761 return m_button_bar_label_disabled_colour
;
762 case wxRIBBON_ART_BUTTON_BAR_HOVER_BORDER_COLOUR
:
763 return m_button_bar_hover_border_pen
.GetColour();
764 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_COLOUR
:
765 return m_button_bar_hover_background_top_colour
;
766 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
767 return m_button_bar_hover_background_top_gradient_colour
;
768 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_COLOUR
:
769 return m_button_bar_hover_background_colour
;
770 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_GRADIENT_COLOUR
:
771 return m_button_bar_hover_background_gradient_colour
;
772 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BORDER_COLOUR
:
773 return m_button_bar_active_border_pen
.GetColour();
774 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_COLOUR
:
775 return m_button_bar_active_background_top_colour
;
776 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
777 return m_button_bar_active_background_top_gradient_colour
;
778 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_COLOUR
:
779 return m_button_bar_active_background_colour
;
780 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
781 return m_button_bar_active_background_gradient_colour
;
782 case wxRIBBON_ART_GALLERY_BORDER_COLOUR
:
783 return m_gallery_border_pen
.GetColour();
784 case wxRIBBON_ART_GALLERY_HOVER_BACKGROUND_COLOUR
:
785 return m_gallery_hover_background_brush
.GetColour();
786 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_COLOUR
:
787 return m_gallery_button_background_colour
;
788 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_GRADIENT_COLOUR
:
789 return m_gallery_button_background_gradient_colour
;
790 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_TOP_COLOUR
:
791 return m_gallery_button_background_top_brush
.GetColour();
792 case wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR
:
793 return m_gallery_button_face_colour
;
794 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_COLOUR
:
795 return m_gallery_button_hover_background_colour
;
796 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_GRADIENT_COLOUR
:
797 return m_gallery_button_hover_background_gradient_colour
;
798 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_TOP_COLOUR
:
799 return m_gallery_button_hover_background_top_brush
.GetColour();
800 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR
:
801 return m_gallery_button_face_colour
;
802 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_COLOUR
:
803 return m_gallery_button_active_background_colour
;
804 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
805 return m_gallery_button_active_background_gradient_colour
;
806 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_TOP_COLOUR
:
807 return m_gallery_button_background_top_brush
.GetColour();
808 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR
:
809 return m_gallery_button_active_face_colour
;
810 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_COLOUR
:
811 return m_gallery_button_disabled_background_colour
;
812 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_GRADIENT_COLOUR
:
813 return m_gallery_button_disabled_background_gradient_colour
;
814 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_TOP_COLOUR
:
815 return m_gallery_button_disabled_background_top_brush
.GetColour();
816 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR
:
817 return m_gallery_button_disabled_face_colour
;
818 case wxRIBBON_ART_GALLERY_ITEM_BORDER_COLOUR
:
819 return m_gallery_item_border_pen
.GetColour();
820 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_COLOUR
:
821 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_GRADIENT_COLOUR
:
822 return m_tab_ctrl_background_brush
.GetColour();
823 case wxRIBBON_ART_TAB_LABEL_COLOUR
:
824 return m_tab_label_colour
;
825 case wxRIBBON_ART_TAB_SEPARATOR_COLOUR
:
826 return m_tab_separator_colour
;
827 case wxRIBBON_ART_TAB_SEPARATOR_GRADIENT_COLOUR
:
828 return m_tab_separator_gradient_colour
;
829 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_COLOUR
:
830 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
831 return wxColour(0, 0, 0);
832 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_COLOUR
:
833 return m_tab_active_background_colour
;
834 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
835 return m_tab_active_background_gradient_colour
;
836 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_COLOUR
:
837 return m_tab_hover_background_top_colour
;
838 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
839 return m_tab_hover_background_top_gradient_colour
;
840 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_COLOUR
:
841 return m_tab_hover_background_colour
;
842 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_GRADIENT_COLOUR
:
843 return m_tab_hover_background_gradient_colour
;
844 case wxRIBBON_ART_TAB_BORDER_COLOUR
:
845 return m_tab_border_pen
.GetColour();
846 case wxRIBBON_ART_PANEL_BORDER_COLOUR
:
847 return m_panel_border_pen
.GetColour();
848 case wxRIBBON_ART_PANEL_BORDER_GRADIENT_COLOUR
:
849 return m_panel_border_gradient_pen
.GetColour();
850 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_COLOUR
:
851 return m_panel_minimised_border_pen
.GetColour();
852 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_GRADIENT_COLOUR
:
853 return m_panel_minimised_border_gradient_pen
.GetColour();
854 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_COLOUR
:
855 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_GRADIENT_COLOUR
:
856 return m_panel_label_background_brush
.GetColour();
857 case wxRIBBON_ART_PANEL_LABEL_COLOUR
:
858 return m_panel_label_colour
;
859 case wxRIBBON_ART_PANEL_MINIMISED_LABEL_COLOUR
:
860 return m_panel_minimised_label_colour
;
861 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_COLOUR
:
862 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_GRADIENT_COLOUR
:
863 return m_panel_hover_label_background_brush
.GetColour();
864 case wxRIBBON_ART_PANEL_HOVER_LABEL_COLOUR
:
865 return m_panel_hover_label_colour
;
866 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_COLOUR
:
867 return m_panel_active_background_top_colour
;
868 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
869 return m_panel_active_background_top_gradient_colour
;
870 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_COLOUR
:
871 return m_panel_active_background_colour
;
872 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
873 return m_panel_active_background_gradient_colour
;
874 case wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR
:
875 return m_panel_button_face_colour
;
876 case wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR
:
877 return m_panel_button_hover_face_colour
;
878 case wxRIBBON_ART_PAGE_BORDER_COLOUR
:
879 return m_page_border_pen
.GetColour();
880 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_COLOUR
:
881 return m_page_background_top_colour
;
882 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_GRADIENT_COLOUR
:
883 return m_page_background_top_gradient_colour
;
884 case wxRIBBON_ART_PAGE_BACKGROUND_COLOUR
:
885 return m_page_background_colour
;
886 case wxRIBBON_ART_PAGE_BACKGROUND_GRADIENT_COLOUR
:
887 return m_page_background_gradient_colour
;
888 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_COLOUR
:
889 return m_page_hover_background_top_colour
;
890 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
891 return m_page_hover_background_top_gradient_colour
;
892 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_COLOUR
:
893 return m_page_hover_background_colour
;
894 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_GRADIENT_COLOUR
:
895 return m_page_hover_background_gradient_colour
;
896 case wxRIBBON_ART_TOOLBAR_BORDER_COLOUR
:
897 case wxRIBBON_ART_TOOLBAR_HOVER_BORDER_COLOUR
:
898 return m_toolbar_border_pen
.GetColour();
899 case wxRIBBON_ART_TOOLBAR_FACE_COLOUR
:
900 return m_tool_face_colour
;
901 case wxRIBBON_ART_PAGE_TOGGLE_FACE_COLOUR
:
902 return m_page_toggle_face_colour
;
903 case wxRIBBON_ART_PAGE_TOGGLE_HOVER_FACE_COLOUR
:
904 return m_page_toggle_hover_face_colour
;
906 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
913 void wxRibbonMSWArtProvider::SetColour(int id
, const wxColor
& colour
)
917 case wxRIBBON_ART_BUTTON_BAR_LABEL_COLOUR
:
918 m_button_bar_label_colour
= colour
;
920 case wxRIBBON_ART_BUTTON_BAR_LABEL_DISABLED_COLOUR
:
921 m_button_bar_label_disabled_colour
= colour
;
923 case wxRIBBON_ART_BUTTON_BAR_HOVER_BORDER_COLOUR
:
924 m_button_bar_hover_border_pen
.SetColour(colour
);
926 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_COLOUR
:
927 m_button_bar_hover_background_top_colour
= colour
;
929 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
930 m_button_bar_hover_background_top_gradient_colour
= colour
;
932 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_COLOUR
:
933 m_button_bar_hover_background_colour
= colour
;
935 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_GRADIENT_COLOUR
:
936 m_button_bar_hover_background_gradient_colour
= colour
;
938 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BORDER_COLOUR
:
939 m_button_bar_active_border_pen
.SetColour(colour
);
941 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_COLOUR
:
942 m_button_bar_active_background_top_colour
= colour
;
944 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
945 m_button_bar_active_background_top_gradient_colour
= colour
;
947 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_COLOUR
:
948 m_button_bar_active_background_colour
= colour
;
950 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
951 m_button_bar_active_background_gradient_colour
= colour
;
953 case wxRIBBON_ART_GALLERY_BORDER_COLOUR
:
954 m_gallery_border_pen
.SetColour(colour
);
956 case wxRIBBON_ART_GALLERY_HOVER_BACKGROUND_COLOUR
:
957 m_gallery_hover_background_brush
.SetColour(colour
);
959 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_COLOUR
:
960 m_gallery_button_background_colour
= colour
;
962 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_GRADIENT_COLOUR
:
963 m_gallery_button_background_gradient_colour
= colour
;
965 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_TOP_COLOUR
:
966 m_gallery_button_background_top_brush
.SetColour(colour
);
968 case wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR
:
969 m_gallery_button_face_colour
= colour
;
970 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
972 m_gallery_up_bitmap
[0] = wxRibbonLoadPixmap(gallery_left_xpm
, colour
);
973 m_gallery_down_bitmap
[0] = wxRibbonLoadPixmap(gallery_right_xpm
, colour
);
977 m_gallery_up_bitmap
[0] = wxRibbonLoadPixmap(gallery_up_xpm
, colour
);
978 m_gallery_down_bitmap
[0] = wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
980 m_gallery_extension_bitmap
[0] = wxRibbonLoadPixmap(gallery_extension_xpm
, colour
);
982 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_COLOUR
:
983 m_gallery_button_hover_background_colour
= colour
;
985 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_GRADIENT_COLOUR
:
986 m_gallery_button_hover_background_gradient_colour
= colour
;
988 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_TOP_COLOUR
:
989 m_gallery_button_hover_background_top_brush
.SetColour(colour
);
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
)
995 m_gallery_up_bitmap
[1] = wxRibbonLoadPixmap(gallery_left_xpm
, colour
);
996 m_gallery_down_bitmap
[1] = wxRibbonLoadPixmap(gallery_right_xpm
, colour
);
1000 m_gallery_up_bitmap
[1] = wxRibbonLoadPixmap(gallery_up_xpm
, colour
);
1001 m_gallery_down_bitmap
[1] = wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
1003 m_gallery_extension_bitmap
[1] = wxRibbonLoadPixmap(gallery_extension_xpm
, colour
);
1005 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_COLOUR
:
1006 m_gallery_button_active_background_colour
= colour
;
1008 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
1009 m_gallery_button_active_background_gradient_colour
= colour
;
1011 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_TOP_COLOUR
:
1012 m_gallery_button_background_top_brush
.SetColour(colour
);
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
)
1018 m_gallery_up_bitmap
[2] = wxRibbonLoadPixmap(gallery_left_xpm
, colour
);
1019 m_gallery_down_bitmap
[2] = wxRibbonLoadPixmap(gallery_right_xpm
, colour
);
1023 m_gallery_up_bitmap
[2] = wxRibbonLoadPixmap(gallery_up_xpm
, colour
);
1024 m_gallery_down_bitmap
[2] = wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
1026 m_gallery_extension_bitmap
[2] = wxRibbonLoadPixmap(gallery_extension_xpm
, colour
);
1028 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_COLOUR
:
1029 m_gallery_button_disabled_background_colour
= colour
;
1031 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_GRADIENT_COLOUR
:
1032 m_gallery_button_disabled_background_gradient_colour
= colour
;
1034 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_TOP_COLOUR
:
1035 m_gallery_button_disabled_background_top_brush
.SetColour(colour
);
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
)
1041 m_gallery_up_bitmap
[3] = wxRibbonLoadPixmap(gallery_left_xpm
, colour
);
1042 m_gallery_down_bitmap
[3] = wxRibbonLoadPixmap(gallery_right_xpm
, colour
);
1046 m_gallery_up_bitmap
[3] = wxRibbonLoadPixmap(gallery_up_xpm
, colour
);
1047 m_gallery_down_bitmap
[3] = wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
1049 m_gallery_extension_bitmap
[3] = wxRibbonLoadPixmap(gallery_extension_xpm
, colour
);
1051 case wxRIBBON_ART_GALLERY_ITEM_BORDER_COLOUR
:
1052 m_gallery_item_border_pen
.SetColour(colour
);
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;
1059 case wxRIBBON_ART_TAB_LABEL_COLOUR
:
1060 m_tab_label_colour
= colour
;
1062 case wxRIBBON_ART_TAB_SEPARATOR_COLOUR
:
1063 m_tab_separator_colour
= colour
;
1064 m_cached_tab_separator_visibility
= -1.0;
1066 case wxRIBBON_ART_TAB_SEPARATOR_GRADIENT_COLOUR
:
1067 m_tab_separator_gradient_colour
= colour
;
1068 m_cached_tab_separator_visibility
= -1.0;
1070 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_COLOUR
:
1071 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
1073 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_COLOUR
:
1074 m_tab_active_background_colour
= colour
;
1076 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
1077 m_tab_active_background_gradient_colour
= colour
;
1079 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_COLOUR
:
1080 m_tab_hover_background_top_colour
= colour
;
1082 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
1083 m_tab_hover_background_top_gradient_colour
= colour
;
1085 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_COLOUR
:
1086 m_tab_hover_background_colour
= colour
;
1088 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_GRADIENT_COLOUR
:
1089 m_tab_hover_background_gradient_colour
= colour
;
1091 case wxRIBBON_ART_TAB_BORDER_COLOUR
:
1092 m_tab_border_pen
.SetColour(colour
);
1094 case wxRIBBON_ART_PANEL_BORDER_COLOUR
:
1095 m_panel_border_pen
.SetColour(colour
);
1097 case wxRIBBON_ART_PANEL_BORDER_GRADIENT_COLOUR
:
1098 m_panel_border_gradient_pen
.SetColour(colour
);
1100 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_COLOUR
:
1101 m_panel_minimised_border_pen
.SetColour(colour
);
1103 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_GRADIENT_COLOUR
:
1104 m_panel_minimised_border_gradient_pen
.SetColour(colour
);
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
);
1110 case wxRIBBON_ART_PANEL_LABEL_COLOUR
:
1111 m_panel_label_colour
= colour
;
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
);
1117 case wxRIBBON_ART_PANEL_HOVER_LABEL_COLOUR
:
1118 m_panel_hover_label_colour
= colour
;
1120 case wxRIBBON_ART_PANEL_MINIMISED_LABEL_COLOUR
:
1121 m_panel_minimised_label_colour
= colour
;
1123 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_COLOUR
:
1124 m_panel_active_background_top_colour
= colour
;
1126 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
1127 m_panel_active_background_top_gradient_colour
= colour
;
1129 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_COLOUR
:
1130 m_panel_active_background_colour
= colour
;
1132 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
1133 m_panel_active_background_gradient_colour
= colour
;
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
);
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
);
1143 case wxRIBBON_ART_PAGE_BORDER_COLOUR
:
1144 m_page_border_pen
.SetColour(colour
);
1146 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_COLOUR
:
1147 m_page_background_top_colour
= colour
;
1149 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_GRADIENT_COLOUR
:
1150 m_page_background_top_gradient_colour
= colour
;
1152 case wxRIBBON_ART_PAGE_BACKGROUND_COLOUR
:
1153 m_page_background_colour
= colour
;
1155 case wxRIBBON_ART_PAGE_BACKGROUND_GRADIENT_COLOUR
:
1156 m_page_background_gradient_colour
= colour
;
1158 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_COLOUR
:
1159 m_page_hover_background_top_colour
= colour
;
1161 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
1162 m_page_hover_background_top_gradient_colour
= colour
;
1164 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_COLOUR
:
1165 m_page_hover_background_colour
= colour
;
1167 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_GRADIENT_COLOUR
:
1168 m_page_hover_background_gradient_colour
= colour
;
1170 case wxRIBBON_ART_TOOLBAR_BORDER_COLOUR
:
1171 case wxRIBBON_ART_TOOLBAR_HOVER_BORDER_COLOUR
:
1172 m_toolbar_border_pen
.SetColour(colour
);
1174 case wxRIBBON_ART_TOOLBAR_FACE_COLOUR
:
1175 m_tool_face_colour
= colour
;
1176 m_toolbar_drop_bitmap
= wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
1178 case wxRIBBON_ART_PAGE_TOGGLE_FACE_COLOUR
:
1179 m_page_toggle_face_colour
= colour
;
1180 m_ribbon_toggle_down_bitmap
[0] = wxRibbonLoadPixmap(panel_toggle_down_xpm
, colour
);
1181 m_ribbon_toggle_up_bitmap
[0] = wxRibbonLoadPixmap(panel_toggle_up_xpm
, colour
);
1182 m_ribbon_toggle_pin_bitmap
[0] = wxRibbonLoadPixmap(ribbon_toggle_pin_xpm
, colour
);
1183 m_ribbon_bar_help_button_bitmap
[0] = wxRibbonLoadPixmap(ribbon_help_button_xpm
, colour
);
1185 case wxRIBBON_ART_PAGE_TOGGLE_HOVER_FACE_COLOUR
:
1186 m_page_toggle_hover_face_colour
= colour
;
1187 m_ribbon_toggle_down_bitmap
[1] = wxRibbonLoadPixmap(panel_toggle_down_xpm
, colour
);
1188 m_ribbon_toggle_up_bitmap
[1] = wxRibbonLoadPixmap(panel_toggle_up_xpm
, colour
);
1189 m_ribbon_toggle_pin_bitmap
[1] = wxRibbonLoadPixmap(ribbon_toggle_pin_xpm
, colour
);
1190 m_ribbon_bar_help_button_bitmap
[1] = wxRibbonLoadPixmap(ribbon_help_button_xpm
, colour
);
1193 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
1198 void wxRibbonMSWArtProvider::DrawTabCtrlBackground(
1200 wxWindow
* WXUNUSED(wnd
),
1203 dc
.SetPen(*wxTRANSPARENT_PEN
);
1204 dc
.SetBrush(m_tab_ctrl_background_brush
);
1205 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
1207 dc
.SetPen(m_page_border_pen
);
1210 dc
.DrawLine(rect
.x
+ 3, rect
.y
+ rect
.height
- 1, rect
.x
+ rect
.width
- 3, rect
.y
+ rect
.height
- 1);
1214 dc
.DrawLine(rect
.x
, rect
.y
+ rect
.height
- 1, rect
.x
+ rect
.width
, rect
.y
+ rect
.height
- 1);
1218 void wxRibbonMSWArtProvider::DrawTab(
1220 wxWindow
* WXUNUSED(wnd
),
1221 const wxRibbonPageTabInfo
& tab
)
1223 if(tab
.rect
.height
<= 2)
1226 if(tab
.active
|| tab
.hovered
|| tab
.highlight
)
1230 wxRect
background(tab
.rect
);
1234 background
.width
-= 4;
1235 background
.height
-= 2;
1237 dc
.GradientFillLinear(background
, m_tab_active_background_colour
,
1238 m_tab_active_background_gradient_colour
, wxSOUTH
);
1240 // TODO: active and hovered
1242 else if(tab
.hovered
)
1244 wxRect
background(tab
.rect
);
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
);
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
);
1261 else if(tab
.highlight
)
1263 wxRect
background(tab
.rect
);
1267 background
.width
-= 4;
1268 background
.height
-= 3;
1269 int h
= background
.height
;
1270 background
.height
/= 2;
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);
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);
1281 dc
.GradientFillLinear(background
, top_colour1
, bottom_colour1
, wxSOUTH
);
1283 background
.y
+= background
.height
;
1284 background
.height
= h
- background
.height
;
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);
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);
1294 dc
.GradientFillLinear(background
, top_colour2
, bottom_colour2
, wxSOUTH
);
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);
1305 dc
.SetPen(m_tab_border_pen
);
1306 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
, tab
.rect
.x
, tab
.rect
.y
);
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);
1314 wxPen
p(m_tab_active_background_gradient_colour
);
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);
1327 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_ICONS
)
1329 wxBitmap icon
= tab
.page
->GetIcon();
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);
1339 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
)
1341 wxString label
= tab
.page
->GetLabel();
1342 if(!label
.IsEmpty())
1344 dc
.SetFont(m_tab_label_font
);
1345 dc
.SetTextForeground(m_tab_label_colour
);
1346 dc
.SetBackgroundMode(wxTRANSPARENT
);
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
)
1355 x
+= 3 + tab
.page
->GetIcon().GetWidth();
1356 width
-= 3 + tab
.page
->GetIcon().GetWidth();
1358 int y
= tab
.rect
.y
+ (tab
.rect
.height
- text_height
) / 2;
1360 if(width
<= text_width
)
1362 dc
.SetClippingRegion(x
, tab
.rect
.y
, width
, tab
.rect
.height
);
1363 dc
.DrawText(label
, x
, y
);
1367 dc
.DrawText(label
, x
+ (width
- text_width
) / 2 + 1, y
);
1373 void wxRibbonMSWArtProvider::DrawTabSeparator(
1379 if(visibility
<= 0.0)
1383 if(visibility
> 1.0)
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
)
1393 wxRect
size(rect
.GetSize());
1394 ReallyDrawTabSeparator(wnd
, size
, visibility
);
1396 dc
.DrawBitmap(m_cached_tab_separator
, rect
.x
, rect
.y
, false);
1399 void wxRibbonMSWArtProvider::ReallyDrawTabSeparator(wxWindow
* wnd
, const wxRect
& rect
, double visibility
)
1401 if(!m_cached_tab_separator
.IsOk() || m_cached_tab_separator
.GetSize() != rect
.GetSize())
1403 m_cached_tab_separator
= wxBitmap(rect
.GetSize());
1406 wxMemoryDC
dc(m_cached_tab_separator
);
1407 DrawTabCtrlBackground(dc
, wnd
, rect
);
1409 wxCoord x
= rect
.x
+ rect
.width
/ 2;
1410 double h
= (double)(rect
.height
- 1);
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();
1422 for(int i
= 0; i
< rect
.height
- 1; ++i
)
1424 double p
= ((double)i
)/h
;
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
;
1430 wxPen
P(wxColour((unsigned char)r
, (unsigned char)g
, (unsigned char)b
));
1432 dc
.DrawPoint(x
, rect
.y
+ i
);
1435 m_cached_tab_separator_visibility
= visibility
;
1438 void wxRibbonMSWArtProvider::DrawPartialPageBackground(wxDC
& dc
,
1439 wxWindow
* wnd
, const wxRect
& r
, wxRibbonPage
* page
,
1440 wxPoint offset
, bool hovered
)
1443 // Expanded panels need a background - the expanded panel at
1444 // best size may have a greater Y dimension higher than when
1445 // on the bar if it has a sizer. AUI art provider does not need this
1446 // because it paints the panel without reference to its parent's size.
1447 // Expanded panels use a wxFrame as parent (not a wxRibbonPage).
1449 if(wnd
->GetSizer() && wnd
->GetParent() != page
)
1451 background
= wnd
->GetParent()->GetSize();
1452 offset
= wxPoint(0,0);
1456 background
= page
->GetSize();
1457 page
->AdjustRectToIncludeScrollButtons(&background
);
1458 background
.height
-= 2;
1460 // Page background isn't dependent 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
1466 background
.width
= INT_MAX
;
1468 // upper_rect, lower_rect, paint_rect are all in page co-ordinates
1469 wxRect
upper_rect(background
);
1470 upper_rect
.height
/= 5;
1472 wxRect
lower_rect(background
);
1473 lower_rect
.y
+= upper_rect
.height
;
1474 lower_rect
.height
-= upper_rect
.height
;
1476 wxRect
paint_rect(r
);
1477 paint_rect
.x
+= offset
.x
;
1478 paint_rect
.y
+= offset
.y
;
1480 wxColour bg_top
, bg_top_grad
, bg_btm
, bg_btm_grad
;
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
;
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
;
1496 if(paint_rect
.Intersects(upper_rect
))
1498 wxRect
rect(upper_rect
);
1499 rect
.Intersect(paint_rect
);
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
);
1510 if(paint_rect
.Intersects(lower_rect
))
1512 wxRect
rect(lower_rect
);
1513 rect
.Intersect(paint_rect
);
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
);
1525 void wxRibbonMSWArtProvider::DrawPageBackground(
1527 wxWindow
* WXUNUSED(wnd
),
1530 dc
.SetPen(*wxTRANSPARENT_PEN
);
1531 dc
.SetBrush(m_tab_ctrl_background_brush
);
1537 dc
.DrawRectangle(edge
.x
, edge
.y
, edge
.width
, edge
.height
);
1539 edge
.x
+= rect
.width
- 2;
1540 dc
.DrawRectangle(edge
.x
, edge
.y
, edge
.width
, edge
.height
);
1544 edge
.y
+= (rect
.height
- edge
.height
);
1545 dc
.DrawRectangle(edge
.x
, edge
.y
, edge
.width
, edge
.height
);
1549 wxRect
background(rect
);
1551 background
.width
-= 4;
1552 background
.height
-= 2;
1554 background
.height
/= 5;
1555 dc
.GradientFillLinear(background
, m_page_background_top_colour
,
1556 m_page_background_top_gradient_colour
, wxSOUTH
);
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
);
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);
1575 dc
.SetPen(m_page_border_pen
);
1576 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
, rect
.x
, rect
.y
);
1580 void wxRibbonMSWArtProvider::DrawScrollButton(
1582 wxWindow
* WXUNUSED(wnd
),
1583 const wxRect
& rect_
,
1588 if((style
& wxRIBBON_SCROLL_BTN_FOR_MASK
) == wxRIBBON_SCROLL_BTN_FOR_PAGE
)
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
)
1599 case wxRIBBON_SCROLL_BTN_LEFT
:
1601 case wxRIBBON_SCROLL_BTN_RIGHT
:
1605 case wxRIBBON_SCROLL_BTN_UP
:
1611 case wxRIBBON_SCROLL_BTN_DOWN
:
1620 wxRect
background(rect
);
1623 background
.width
-= 2;
1624 background
.height
-= 2;
1626 if(style
& wxRIBBON_SCROLL_BTN_UP
)
1627 background
.height
/= 2;
1629 background
.height
/= 5;
1630 dc
.GradientFillLinear(background
, m_page_background_top_colour
,
1631 m_page_background_top_gradient_colour
, wxSOUTH
);
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
);
1640 wxPoint border_points
[7];
1641 switch(style
& wxRIBBON_SCROLL_BTN_DIRECTION_MASK
)
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);
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);
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);
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);
1676 border_points
[6] = border_points
[0];
1678 dc
.SetPen(m_page_border_pen
);
1679 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
, rect
.x
, rect
.y
);
1683 // NB: Code for handling hovered/active state is temporary
1684 wxPoint arrow_points
[3];
1685 switch(style
& wxRIBBON_SCROLL_BTN_DIRECTION_MASK
)
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);
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);
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);
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);
1717 dc
.SetPen(*wxTRANSPARENT_PEN
);
1718 wxBrush
B(style
& wxRIBBON_SCROLL_BTN_HOVERED
? m_tab_active_background_colour
: m_tab_label_colour
);
1720 dc
.DrawPolygon(sizeof(arrow_points
)/sizeof(wxPoint
), arrow_points
, rect
.x
, rect
.y
);
1724 void wxRibbonMSWArtProvider::DrawDropdownArrow(wxDC
& dc
, int x
, int y
, const wxColour
& colour
)
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
);
1733 dc
.DrawPolygon(sizeof(arrow_points
)/sizeof(wxPoint
), arrow_points
, x
, y
);
1736 void wxRibbonMSWArtProvider::RemovePanelPadding(wxRect
* rect
)
1738 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1750 void wxRibbonMSWArtProvider::DrawPanelBackground(
1755 DrawPartialPageBackground(dc
, wnd
, rect
, false);
1757 wxRect
true_rect(rect
);
1758 RemovePanelPadding(&true_rect
);
1759 bool has_ext_button
= wnd
->HasExtButton();
1763 dc
.SetFont(m_panel_label_font
);
1764 dc
.SetPen(*wxTRANSPARENT_PEN
);
1765 if(wnd
->IsHovered())
1767 dc
.SetBrush(m_panel_hover_label_background_brush
);
1768 dc
.SetTextForeground(m_panel_hover_label_colour
);
1772 dc
.SetBrush(m_panel_label_background_brush
);
1773 dc
.SetTextForeground(m_panel_label_colour
);
1776 wxRect
label_rect(true_rect
);
1777 wxString label
= wnd
->GetLabel();
1778 bool clip_label
= false;
1779 wxSize
label_size(dc
.GetTextExtent(label
));
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();
1787 wxRect label_bg_rect
= label_rect
;
1790 label_rect
.SetWidth(label_rect
.GetWidth() - 13);
1792 if(label_size
.GetWidth() > label_rect
.GetWidth())
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())
1799 // Not enough room for three characters and ...
1800 // Display the entire label and just crop it
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
)
1809 new_label
= label
.Mid(0, len
) + wxT("...");
1810 label_size
= dc
.GetTextExtent(new_label
);
1811 if(label_size
.GetWidth() <= label_rect
.GetWidth())
1820 dc
.DrawRectangle(label_bg_rect
);
1823 wxDCClipper
clip(dc
, label_rect
);
1824 dc
.DrawText(label
, label_rect
.x
, label_rect
.y
+
1825 (label_rect
.GetHeight() - label_size
.GetHeight()) / 2);
1829 dc
.DrawText(label
, label_rect
.x
+
1830 (label_rect
.GetWidth() - label_size
.GetWidth()) / 2,
1832 (label_rect
.GetHeight() - label_size
.GetHeight()) / 2);
1837 if(wnd
->IsExtButtonHovered())
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);
1845 dc
.DrawBitmap(m_panel_extension_bitmap
[0], label_rect
.GetRight() + 3, label_rect
.GetBottom() - 10, true);
1849 if(wnd
->IsHovered())
1851 wxRect
client_rect(true_rect
);
1853 client_rect
.width
-= 2;
1855 client_rect
.height
-= 2 + label_height
;
1856 DrawPartialPageBackground(dc
, wnd
, client_rect
, true);
1859 DrawPanelBorder(dc
, true_rect
, m_panel_border_pen
, m_panel_border_gradient_pen
);
1862 wxRect
wxRibbonMSWArtProvider::GetPanelExtButtonArea(wxDC
& WXUNUSED(dc
),
1863 const wxRibbonPanel
* WXUNUSED(wnd
),
1866 RemovePanelPadding(&rect
);
1867 rect
= wxRect(rect
.GetRight()-13, rect
.GetBottom()-13, 13, 13);
1871 void wxRibbonMSWArtProvider::DrawGalleryBackground(
1873 wxRibbonGallery
* wnd
,
1876 DrawPartialPageBackground(dc
, wnd
, rect
);
1878 if(wnd
->IsHovered())
1880 dc
.SetPen(*wxTRANSPARENT_PEN
);
1881 dc
.SetBrush(m_gallery_hover_background_brush
);
1882 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1884 dc
.DrawRectangle(rect
.x
+ 1, rect
.y
+ 1, rect
.width
- 2,
1889 dc
.DrawRectangle(rect
.x
+ 1, rect
.y
+ 1, rect
.width
- 16,
1894 dc
.SetPen(m_gallery_border_pen
);
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);
1903 DrawGalleryBackgroundCommon(dc
, wnd
, rect
);
1906 void wxRibbonMSWArtProvider::DrawGalleryBackgroundCommon(wxDC
& dc
,
1907 wxRibbonGallery
* wnd
,
1910 wxRect up_btn
, down_btn
, ext_btn
;
1912 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
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);
1918 up_btn
= wxRect(rect
.x
, rect
.y
+ rect
.height
- 15, rect
.width
/ 3, 15);
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());
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());
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
);
1936 up_btn
= wxRect(rect
.x
+ rect
.width
- 15, rect
.y
, 15, rect
.height
/ 3);
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(),
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(),
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
);
1957 void wxRibbonMSWArtProvider::DrawGalleryButton(wxDC
& dc
,
1959 wxRibbonGalleryButtonState state
,
1962 wxBitmap btn_bitmap
;
1963 wxBrush btn_top_brush
;
1964 wxColour btn_colour
;
1965 wxColour btn_grad_colour
;
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];
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];
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];
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];
1996 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2007 dc
.SetPen(*wxTRANSPARENT_PEN
);
2008 dc
.SetBrush(btn_top_brush
);
2009 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
/ 2);
2012 lower
.height
= (lower
.height
+ 1) / 2;
2013 lower
.y
+= rect
.height
- lower
.height
;
2014 dc
.GradientFillLinear(lower
, btn_colour
, btn_grad_colour
, wxSOUTH
);
2016 dc
.DrawBitmap(btn_bitmap
, rect
.x
+ rect
.width
/ 2 - 2, lower
.y
- 2, true);
2019 void wxRibbonMSWArtProvider::DrawGalleryItemBackground(
2021 wxRibbonGallery
* wnd
,
2023 wxRibbonGalleryItem
* item
)
2025 if(wnd
->GetHoveredItem() != item
&& wnd
->GetActiveItem() != item
&&
2026 wnd
->GetSelection() != item
)
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);
2039 wxColour bg_gradient_colour
;
2041 if(wnd
->GetActiveItem() == item
|| wnd
->GetSelection() == item
)
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
;
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
;
2059 dc
.SetPen(*wxTRANSPARENT_PEN
);
2060 dc
.SetBrush(top_brush
);
2061 dc
.DrawRectangle(upper
.x
, upper
.y
, upper
.width
, upper
.height
);
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
);
2069 void wxRibbonMSWArtProvider::DrawPanelBorder(wxDC
& dc
, const wxRect
& rect
,
2070 wxPen
& primary_colour
,
2071 wxPen
& secondary_colour
)
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);
2083 if(primary_colour
.GetColour() == secondary_colour
.GetColour())
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
);
2091 dc
.SetPen(primary_colour
);
2092 dc
.DrawLines(3, border_points
, rect
.x
, rect
.y
);
2094 #define SingleLine(start, finish) \
2095 dc.DrawLine(start.x + rect.x, start.y + rect.y, finish.x + rect.x, finish.y + rect.y)
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]);
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());
2111 void wxRibbonMSWArtProvider::DrawMinimisedPanel(
2117 DrawPartialPageBackground(dc
, wnd
, rect
, false);
2119 wxRect
true_rect(rect
);
2120 RemovePanelPadding(&true_rect
);
2122 if(wnd
->GetExpandedPanel() != NULL
)
2124 wxRect
client_rect(true_rect
);
2126 client_rect
.width
-= 2;
2128 client_rect
.height
= (rect
.y
+ rect
.height
/ 5) - client_rect
.x
;
2129 dc
.GradientFillLinear(client_rect
,
2130 m_panel_active_background_top_colour
,
2131 m_panel_active_background_top_gradient_colour
, wxSOUTH
);
2133 client_rect
.y
+= client_rect
.height
;
2134 client_rect
.height
= (true_rect
.y
+ true_rect
.height
) - client_rect
.y
;
2135 dc
.GradientFillLinear(client_rect
,
2136 m_panel_active_background_colour
,
2137 m_panel_active_background_gradient_colour
, wxSOUTH
);
2139 else if(wnd
->IsHovered())
2141 wxRect
client_rect(true_rect
);
2143 client_rect
.width
-= 2;
2145 client_rect
.height
-= 2;
2146 DrawPartialPageBackground(dc
, wnd
, client_rect
, true);
2150 DrawMinimisedPanelCommon(dc
, wnd
, true_rect
, &preview
);
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);
2157 int mid_pos
= rect
.y
+ rect
.height
/ 5 - preview
.y
;
2158 if(mid_pos
< 0 || mid_pos
>= preview
.height
)
2160 wxRect
full_rect(preview
);
2163 full_rect
.width
-= 2;
2164 full_rect
.height
-= 9;
2167 dc
.GradientFillLinear(full_rect
,
2168 m_page_hover_background_colour
,
2169 m_page_hover_background_gradient_colour
, wxSOUTH
);
2173 dc
.GradientFillLinear(full_rect
,
2174 m_page_hover_background_top_colour
,
2175 m_page_hover_background_top_gradient_colour
, wxSOUTH
);
2180 wxRect
top_rect(preview
);
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
);
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
);
2199 dc
.DrawBitmap(bitmap
, preview
.x
+ (preview
.width
- bitmap
.GetWidth()) / 2,
2200 preview
.y
+ (preview
.height
- 7 - bitmap
.GetHeight()) / 2, true);
2203 DrawPanelBorder(dc
, preview
, m_panel_border_pen
, m_panel_border_gradient_pen
);
2205 DrawPanelBorder(dc
, true_rect
, m_panel_minimised_border_pen
,
2206 m_panel_minimised_border_gradient_pen
);
2209 void wxRibbonMSWArtProvider::DrawMinimisedPanelCommon(
2212 const wxRect
& true_rect
,
2213 wxRect
* preview_rect
)
2215 wxRect
preview(0, 0, 32, 32);
2216 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2218 preview
.x
= true_rect
.x
+ 4;
2219 preview
.y
= true_rect
.y
+ (true_rect
.height
- preview
.height
) / 2;
2223 preview
.x
= true_rect
.x
+ (true_rect
.width
- preview
.width
) / 2;
2224 preview
.y
= true_rect
.y
+ 4;
2227 *preview_rect
= preview
;
2229 wxCoord label_width
, label_height
;
2230 dc
.SetFont(m_panel_label_font
);
2231 dc
.GetTextExtent(wnd
->GetLabel(), &label_width
, &label_height
);
2233 int xpos
= true_rect
.x
+ (true_rect
.width
- label_width
+ 1) / 2;
2234 int ypos
= preview
.y
+ preview
.height
+ 5;
2236 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2238 xpos
= preview
.x
+ preview
.width
+ 5;
2239 ypos
= true_rect
.y
+ (true_rect
.height
- label_height
) / 2;
2242 dc
.SetTextForeground(m_panel_minimised_label_colour
);
2243 dc
.DrawText(wnd
->GetLabel(), xpos
, ypos
);
2246 wxPoint arrow_points
[3];
2247 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
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);
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);
2262 dc
.SetPen(*wxTRANSPARENT_PEN
);
2263 wxBrush
B(m_panel_minimised_label_colour
);
2265 dc
.DrawPolygon(sizeof(arrow_points
)/sizeof(wxPoint
), arrow_points
,
2266 true_rect
.x
, true_rect
.y
);
2269 void wxRibbonMSWArtProvider::DrawButtonBarBackground(
2274 DrawPartialPageBackground(dc
, wnd
, rect
, true);
2277 void wxRibbonMSWArtProvider::DrawPartialPageBackground(
2283 // Assume the window is a child of a ribbon page, and also check for a
2284 // hovered panel somewhere between the window and the page, as it causes
2285 // the background to change.
2286 wxPoint
offset(wnd
->GetPosition());
2287 wxRibbonPage
* page
= NULL
;
2288 wxWindow
* parent
= wnd
->GetParent();
2289 wxRibbonPanel
* panel
= wxDynamicCast(wnd
, wxRibbonPanel
);
2290 bool hovered
= false;
2294 hovered
= allow_hovered
&& panel
->IsHovered();
2295 if(panel
->GetExpandedDummy() != NULL
)
2297 offset
= panel
->GetExpandedDummy()->GetPosition();
2298 parent
= panel
->GetExpandedDummy()->GetParent();
2301 for(; parent
; parent
= parent
->GetParent())
2305 panel
= wxDynamicCast(parent
, wxRibbonPanel
);
2308 hovered
= allow_hovered
&& panel
->IsHovered();
2309 if(panel
->GetExpandedDummy() != NULL
)
2311 parent
= panel
->GetExpandedDummy();
2315 page
= wxDynamicCast(parent
, wxRibbonPage
);
2320 offset
+= parent
->GetPosition();
2324 DrawPartialPageBackground(dc
, wnd
, rect
, page
, offset
, hovered
);
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
);
2334 void wxRibbonMSWArtProvider::DrawButtonBarButton(
2336 wxWindow
* WXUNUSED(wnd
),
2338 wxRibbonButtonKind kind
,
2340 const wxString
& label
,
2341 const wxBitmap
& bitmap_large
,
2342 const wxBitmap
& bitmap_small
)
2344 if(kind
== wxRIBBON_BUTTON_TOGGLE
)
2346 kind
= wxRIBBON_BUTTON_NORMAL
;
2347 if(state
& wxRIBBON_BUTTONBAR_BUTTON_TOGGLED
)
2348 state
^= wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK
;
2351 if(state
& (wxRIBBON_BUTTONBAR_BUTTON_HOVER_MASK
|
2352 wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK
))
2354 if(state
& wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK
)
2355 dc
.SetPen(m_button_bar_active_border_pen
);
2357 dc
.SetPen(m_button_bar_hover_border_pen
);
2359 wxRect
bg_rect(rect
);
2363 bg_rect
.height
-= 2;
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
;
2370 if(kind
== wxRIBBON_BUTTON_HYBRID
)
2372 switch(state
& wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK
)
2374 case wxRIBBON_BUTTONBAR_BUTTON_LARGE
:
2376 int iYBorder
= rect
.y
+ bitmap_large
.GetHeight() + 4;
2377 wxRect
partial_bg(rect
);
2378 if(state
& wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED
)
2380 partial_bg
.SetBottom(iYBorder
- 1);
2384 partial_bg
.height
-= (iYBorder
- partial_bg
.y
+ 1);
2385 partial_bg
.y
= iYBorder
+ 1;
2387 dc
.DrawLine(rect
.x
, iYBorder
, rect
.x
+ rect
.width
, iYBorder
);
2388 bg_rect
.Intersect(partial_bg
);
2389 bg_rect_top
.Intersect(partial_bg
);
2392 case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM
:
2394 int iArrowWidth
= 9;
2395 if(state
& wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED
)
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
);
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
);
2415 case wxRIBBON_BUTTONBAR_BUTTON_SMALL
:
2420 if(state
& wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK
)
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
);
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
);
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];
2450 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
,
2454 dc
.SetFont(m_button_bar_label_font
);
2455 dc
.SetTextForeground(state
& wxRIBBON_BUTTONBAR_BUTTON_DISABLED
2456 ? m_button_bar_label_disabled_colour
2457 : m_button_bar_label_colour
);
2458 DrawButtonBarButtonForeground(dc
, rect
, kind
, state
, label
, bitmap_large
,
2462 void wxRibbonMSWArtProvider::DrawButtonBarButtonForeground(
2465 wxRibbonButtonKind kind
,
2467 const wxString
& label
,
2468 const wxBitmap
& bitmap_large
,
2469 const wxBitmap
& bitmap_small
)
2472 arrowColour(state
& wxRIBBON_BUTTONBAR_BUTTON_DISABLED
2473 ? m_button_bar_label_disabled_colour
2474 : m_button_bar_label_colour
);
2476 switch(state
& wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK
)
2478 case wxRIBBON_BUTTONBAR_BUTTON_LARGE
:
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
)
2490 dc
.DrawText(label
, rect
.x
+ (rect
.width
- label_w
) / 2, ypos
);
2491 if(arrow_width
!= 0)
2493 DrawDropdownArrow(dc
, rect
.x
+ rect
.width
/ 2,
2494 ypos
+ (label_h
* 3) / 2,
2500 size_t breaki
= label
.Len();
2504 if(wxRibbonCanLabelBreakAtPosition(label
, breaki
))
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
)
2510 dc
.DrawText(label_top
,
2511 rect
.x
+ (rect
.width
- label_w
) / 2, ypos
);
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)
2520 DrawDropdownArrow(dc
,
2521 iX
+ 2 +label_w
- arrow_width
,
2522 ypos
+ label_h
/ 2 + 1,
2528 } while(breaki
> 0);
2532 case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM
:
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
)
2545 DrawDropdownArrow(dc
, x_cursor
, rect
.y
+ rect
.height
/ 2, arrowColour
);
2555 void wxRibbonMSWArtProvider::DrawToolBarBackground(
2560 DrawPartialPageBackground(dc
, wnd
, rect
);
2563 void wxRibbonMSWArtProvider::DrawToolGroupBackground(
2565 wxWindow
* WXUNUSED(wnd
),
2568 dc
.SetPen(m_toolbar_border_pen
);
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];
2580 dc
.DrawLines(sizeof(outline
)/sizeof(wxPoint
), outline
, rect
.x
, rect
.y
);
2583 void wxRibbonMSWArtProvider::DrawTool(
2585 wxWindow
* WXUNUSED(wnd
),
2587 const wxBitmap
& bitmap
,
2588 wxRibbonButtonKind kind
,
2591 if(kind
== wxRIBBON_BUTTON_TOGGLE
)
2593 if(state
& wxRIBBON_TOOLBAR_TOOL_TOGGLED
)
2594 state
^= wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK
;
2597 wxRect
bg_rect(rect
);
2599 if((state
& wxRIBBON_TOOLBAR_TOOL_LAST
) == 0)
2601 bool is_split_hybrid
= (kind
== wxRIBBON_BUTTON_HYBRID
&& (state
&
2602 (wxRIBBON_TOOLBAR_TOOL_HOVER_MASK
| wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK
)));
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
)
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
;
2621 else if(state
& wxRIBBON_TOOLBAR_TOOL_HOVER_MASK
)
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
;
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
);
2632 wxRect
nonrect(bg_rect
);
2633 if(state
& (wxRIBBON_TOOLBAR_TOOL_DROPDOWN_HOVERED
|
2634 wxRIBBON_TOOLBAR_TOOL_DROPDOWN_ACTIVE
))
2640 nonrect
.x
+= nonrect
.width
- 8;
2643 wxBrush
B(m_tool_hover_background_top_colour
);
2644 dc
.SetPen(*wxTRANSPARENT_PEN
);
2646 dc
.DrawRectangle(nonrect
.x
, nonrect
.y
, nonrect
.width
, nonrect
.height
);
2650 dc
.SetPen(m_toolbar_border_pen
);
2651 if(state
& wxRIBBON_TOOLBAR_TOOL_FIRST
)
2653 dc
.DrawPoint(rect
.x
+ 1, rect
.y
+ 1);
2654 dc
.DrawPoint(rect
.x
+ 1, rect
.y
+ rect
.height
- 2);
2657 dc
.DrawLine(rect
.x
, rect
.y
+ 1, rect
.x
, rect
.y
+ rect
.height
- 1);
2659 if(state
& wxRIBBON_TOOLBAR_TOOL_LAST
)
2661 dc
.DrawPoint(rect
.x
+ rect
.width
- 2, rect
.y
+ 1);
2662 dc
.DrawPoint(rect
.x
+ rect
.width
- 2, rect
.y
+ rect
.height
- 2);
2666 int avail_width
= bg_rect
.GetWidth();
2667 if(kind
& wxRIBBON_BUTTON_DROPDOWN
)
2672 dc
.DrawLine(rect
.x
+ avail_width
+ 1, rect
.y
,
2673 rect
.x
+ avail_width
+ 1, rect
.y
+ rect
.height
);
2675 dc
.DrawBitmap(m_toolbar_drop_bitmap
, bg_rect
.x
+ avail_width
+ 2,
2676 bg_rect
.y
+ (bg_rect
.height
/ 2) - 2, true);
2678 dc
.DrawBitmap(bitmap
, bg_rect
.x
+ (avail_width
- bitmap
.GetWidth()) / 2,
2679 bg_rect
.y
+ (bg_rect
.height
- bitmap
.GetHeight()) / 2, true);
2683 wxRibbonMSWArtProvider::DrawToggleButton(wxDC
& dc
,
2686 wxRibbonDisplayMode mode
)
2689 DrawPartialPageBackground(dc
, wnd
, rect
, false);
2691 dc
.DestroyClippingRegion();
2692 dc
.SetClippingRegion(rect
);
2694 if(wnd
->IsToggleButtonHovered())
2696 dc
.SetPen(m_ribbon_toggle_pen
);
2697 dc
.SetBrush(m_ribbon_toggle_brush
);
2698 dc
.DrawRoundedRectangle(rect
.GetX(), rect
.GetY(), 20, 20, 1.0);
2703 case wxRIBBON_BAR_PINNED
:
2704 dc
.DrawBitmap(m_ribbon_toggle_up_bitmap
[bindex
], rect
.GetX()+7, rect
.GetY()+6, true);
2706 case wxRIBBON_BAR_MINIMIZED
:
2707 dc
.DrawBitmap(m_ribbon_toggle_down_bitmap
[bindex
], rect
.GetX()+7, rect
.GetY()+6, true);
2709 case wxRIBBON_BAR_EXPANDED
:
2710 dc
.DrawBitmap(m_ribbon_toggle_pin_bitmap
[bindex
], rect
.GetX ()+4, rect
.GetY ()+5, true);
2715 void wxRibbonMSWArtProvider::DrawHelpButton(wxDC
& dc
,
2719 DrawPartialPageBackground(dc
, wnd
, rect
, false);
2721 dc
.DestroyClippingRegion();
2722 dc
.SetClippingRegion(rect
);
2724 if ( wnd
->IsHelpButtonHovered() )
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);
2733 dc
.DrawBitmap(m_ribbon_bar_help_button_bitmap
[0], rect
.GetX ()+4, rect
.GetY()+5, true);
2738 void wxRibbonMSWArtProvider::GetBarTabWidth(
2740 wxWindow
* WXUNUSED(wnd
),
2741 const wxString
& label
,
2742 const wxBitmap
& bitmap
,
2744 int* small_begin_need_separator
,
2745 int* small_must_have_separator
,
2750 if((m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
) && !label
.IsEmpty())
2752 dc
.SetFont(m_tab_label_font
);
2753 width
+= dc
.GetTextExtent(label
).GetWidth();
2754 min
+= wxMin(25, width
); // enough for a few chars
2757 // gap between label and bitmap
2762 if((m_flags
& wxRIBBON_BAR_SHOW_PAGE_ICONS
) && bitmap
.IsOk())
2764 width
+= bitmap
.GetWidth();
2765 min
+= bitmap
.GetWidth();
2770 *ideal
= width
+ 30;
2772 if(small_begin_need_separator
!= NULL
)
2774 *small_begin_need_separator
= width
+ 20;
2776 if(small_must_have_separator
!= NULL
)
2778 *small_must_have_separator
= width
+ 10;
2786 int wxRibbonMSWArtProvider::GetTabCtrlHeight(
2788 wxWindow
* WXUNUSED(wnd
),
2789 const wxRibbonPageTabInfoArray
& pages
)
2791 int text_height
= 0;
2792 int icon_height
= 0;
2794 if(pages
.GetCount() <= 1 && (m_flags
& wxRIBBON_BAR_ALWAYS_SHOW_TABS
) == 0)
2796 // To preserve space, a single tab need not be displayed. We still need
2797 // two pixels of border / padding though.
2801 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
)
2803 dc
.SetFont(m_tab_label_font
);
2804 text_height
= dc
.GetTextExtent(wxT("ABCDEFXj")).GetHeight() + 10;
2806 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_ICONS
)
2808 size_t numpages
= pages
.GetCount();
2809 for(size_t i
= 0; i
< numpages
; ++i
)
2811 const wxRibbonPageTabInfo
& info
= pages
.Item(i
);
2812 if(info
.page
->GetIcon().IsOk())
2814 icon_height
= wxMax(icon_height
, info
.page
->GetIcon().GetHeight() + 4);
2819 return wxMax(text_height
, icon_height
);
2822 wxSize
wxRibbonMSWArtProvider::GetScrollButtonMinimumSize(
2824 wxWindow
* WXUNUSED(wnd
),
2825 long WXUNUSED(style
))
2827 return wxSize(12, 12);
2830 wxSize
wxRibbonMSWArtProvider::GetPanelSize(
2832 const wxRibbonPanel
* wnd
,
2834 wxPoint
* client_offset
)
2836 dc
.SetFont(m_panel_label_font
);
2837 wxSize label_size
= dc
.GetTextExtent(wnd
->GetLabel());
2839 client_size
.IncBy(0, label_size
.GetHeight());
2840 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2841 client_size
.IncBy(4, 8);
2843 client_size
.IncBy(6, 6);
2845 if(client_offset
!= NULL
)
2847 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2848 *client_offset
= wxPoint(2, 3);
2850 *client_offset
= wxPoint(3, 2);
2856 wxSize
wxRibbonMSWArtProvider::GetPanelClientSize(
2858 const wxRibbonPanel
* wnd
,
2860 wxPoint
* client_offset
)
2862 dc
.SetFont(m_panel_label_font
);
2863 wxSize label_size
= dc
.GetTextExtent(wnd
->GetLabel());
2865 size
.DecBy(0, label_size
.GetHeight());
2866 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2871 if(client_offset
!= NULL
)
2873 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2874 *client_offset
= wxPoint(2, 3);
2876 *client_offset
= wxPoint(3, 2);
2878 if (size
.x
< 0) size
.x
= 0;
2879 if (size
.y
< 0) size
.y
= 0;
2884 wxSize
wxRibbonMSWArtProvider::GetGallerySize(
2886 const wxRibbonGallery
* WXUNUSED(wnd
),
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
2893 client_size
.IncBy(16, 1); // Right / bottom padding
2897 wxSize
wxRibbonMSWArtProvider::GetGalleryClientSize(
2899 const wxRibbonGallery
* WXUNUSED(wnd
),
2901 wxPoint
* client_offset
,
2902 wxRect
* scroll_up_button
,
2903 wxRect
* scroll_down_button
,
2904 wxRect
* extension_button
)
2909 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2911 // Flow is vertical - put buttons on bottom
2912 scroll_up
.y
= size
.GetHeight() - 15;
2913 scroll_up
.height
= 15;
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
;
2919 scroll_down
.width
= scroll_up
.width
;
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
;
2929 // Flow is horizontal - put buttons on right
2930 scroll_up
.x
= size
.GetWidth() - 15;
2931 scroll_up
.width
= 15;
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
;
2937 scroll_down
.height
= scroll_up
.height
;
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
;
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
;
2958 wxRect
wxRibbonMSWArtProvider::GetPageBackgroundRedrawArea(
2960 const wxRibbonPage
* WXUNUSED(wnd
),
2961 wxSize page_old_size
,
2962 wxSize page_new_size
)
2964 wxRect new_rect
, old_rect
;
2966 if(page_new_size
.GetWidth() != page_old_size
.GetWidth())
2968 if(page_new_size
.GetHeight() != page_old_size
.GetHeight())
2970 // Width and height both changed - redraw everything
2971 return wxRect(page_new_size
);
2975 // Only width changed - redraw right hand side
2976 const int right_edge_width
= 4;
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());
2984 if(page_new_size
.GetHeight() == page_old_size
.GetHeight())
2986 // Nothing changed (should never happen) - redraw nothing
2987 return wxRect(0, 0, 0, 0);
2991 // Height changed - need to redraw everything (as the background
2992 // gradient is done vertically).
2993 return page_new_size
;
2997 new_rect
.Union(old_rect
);
2998 new_rect
.Intersect(wxRect(page_new_size
));
3002 bool wxRibbonMSWArtProvider::GetButtonBarButtonSize(
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
)
3014 const int drop_button_width
= 8;
3016 dc
.SetFont(m_button_bar_label_font
);
3017 switch(size
& wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK
)
3019 case wxRIBBON_BUTTONBAR_BUTTON_SMALL
:
3020 // Small bitmap, no label
3021 *button_size
= bitmap_size_small
+ wxSize(6, 4);
3024 case wxRIBBON_BUTTON_NORMAL
:
3025 case wxRIBBON_BUTTON_TOGGLE
:
3026 *normal_region
= wxRect(*button_size
);
3027 *dropdown_region
= wxRect(0, 0, 0, 0);
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);
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);
3042 case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM
:
3043 // Small bitmap, with label to the right
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
);
3052 case wxRIBBON_BUTTON_DROPDOWN
:
3053 dropdown_region
->SetWidth(dropdown_region
->GetWidth() + text_size
);
3055 case wxRIBBON_BUTTON_HYBRID
:
3056 dropdown_region
->SetX(dropdown_region
->GetX() + text_size
);
3058 case wxRIBBON_BUTTON_NORMAL
:
3059 case wxRIBBON_BUTTON_TOGGLE
:
3060 normal_region
->SetWidth(normal_region
->GetWidth() + text_size
);
3065 case wxRIBBON_BUTTONBAR_BUTTON_LARGE
:
3066 // Large bitmap, with label below (possibly split over 2 lines)
3068 wxSize
icon_size(bitmap_size_large
);
3069 icon_size
+= wxSize(4, 4);
3070 wxCoord label_height
;
3072 dc
.GetTextExtent(label
, &best_width
, &label_height
);
3073 int last_line_extra_width
= 0;
3074 if(kind
!= wxRIBBON_BUTTON_NORMAL
&& kind
!= wxRIBBON_BUTTON_TOGGLE
)
3076 last_line_extra_width
+= 8;
3079 for(i
= 0; i
< label
.Len(); ++i
)
3081 if(wxRibbonCanLabelBreakAtPosition(label
, i
))
3084 dc
.GetTextExtent(label
.Left(i
)).GetWidth(),
3085 dc
.GetTextExtent(label
.Mid(i
+ 1)).GetWidth() + last_line_extra_width
);
3086 if(width
< best_width
)
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
;
3099 case wxRIBBON_BUTTON_DROPDOWN
:
3100 *dropdown_region
= wxRect(icon_size
);
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
;
3110 case wxRIBBON_BUTTON_NORMAL
:
3111 case wxRIBBON_BUTTON_TOGGLE
:
3112 *normal_region
= wxRect(icon_size
);
3121 wxSize
wxRibbonMSWArtProvider::GetMinimisedPanelMinimumSize(
3123 const wxRibbonPanel
* wnd
,
3124 wxSize
* desired_bitmap_size
,
3125 wxDirection
* expanded_panel_direction
)
3127 if(desired_bitmap_size
!= NULL
)
3129 *desired_bitmap_size
= wxSize(16, 16);
3131 if(expanded_panel_direction
!= NULL
)
3133 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
3134 *expanded_panel_direction
= wxEAST
;
3136 *expanded_panel_direction
= wxSOUTH
;
3138 wxSize
base_size(42, 42);
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
3146 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
3148 // Label alongside icon
3149 return wxSize(base_size
.x
+ label_size
.x
,
3150 wxMax(base_size
.y
, label_size
.y
));
3154 // Label beneath icon
3155 return wxSize(wxMax(base_size
.x
, label_size
.x
),
3156 base_size
.y
+ label_size
.y
);
3160 wxSize
wxRibbonMSWArtProvider::GetToolSize(
3162 wxWindow
* WXUNUSED(wnd
),
3164 wxRibbonButtonKind kind
,
3165 bool WXUNUSED(is_first
),
3167 wxRect
* dropdown_region
)
3169 wxSize
size(bitmap_size
);
3173 if(kind
& wxRIBBON_BUTTON_DROPDOWN
)
3178 if(kind
== wxRIBBON_BUTTON_DROPDOWN
)
3179 *dropdown_region
= size
;
3181 *dropdown_region
= wxRect(size
.GetWidth() - 8, 0, 8, size
.GetHeight());
3187 *dropdown_region
= wxRect(0, 0, 0, 0);
3193 wxRibbonMSWArtProvider::GetBarToggleButtonArea(const wxRect
& rect
)
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;
3202 wxRibbonMSWArtProvider::GetRibbonHelpButtonArea(const wxRect
& rect
)
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;
3210 #endif // wxUSE_RIBBON