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_hover_border_pen
= LikeSecondary(-6.2, -0.47, -0.14);
439 m_button_bar_hover_background_gradient_colour
= LikeSecondary(-0.6, 0.16, 0.04);
440 m_button_bar_hover_background_colour
= LikeSecondary(-0.2, 0.16, -0.10);
441 m_button_bar_hover_background_top_gradient_colour
= LikeSecondary(0.2, 0.16, 0.03);
442 m_button_bar_hover_background_top_colour
= LikeSecondary(8.8, 0.16, 0.17);
443 m_button_bar_active_border_pen
= LikeSecondary(-6.2, -0.47, -0.25);
444 m_button_bar_active_background_top_colour
= LikeSecondary(-8.4, 0.08, 0.06);
445 m_button_bar_active_background_top_gradient_colour
= LikeSecondary(-9.7, 0.13, -0.07);
446 m_button_bar_active_background_colour
= LikeSecondary(-9.9, 0.14, -0.14);
447 m_button_bar_active_background_gradient_colour
= LikeSecondary(-8.7, 0.17, -0.03);
449 m_toolbar_border_pen
= LikePrimary(1.4, -0.21, -0.16);
450 SetColour(wxRIBBON_ART_TOOLBAR_FACE_COLOUR
, LikePrimary(1.4, -0.17, -0.22));
451 m_tool_background_top_colour
= LikePrimary(-1.9, -0.07, 0.06);
452 m_tool_background_top_gradient_colour
= LikePrimary(1.4, 0.12, 0.08);
453 m_tool_background_colour
= LikePrimary(1.4, -0.09, 0.03);
454 m_tool_background_gradient_colour
= LikePrimary(1.9, 0.11, 0.09);
455 m_tool_hover_background_top_colour
= LikeSecondary(3.4, 0.11, 0.16);
456 m_tool_hover_background_top_gradient_colour
= LikeSecondary(-1.4, 0.04, 0.08);
457 m_tool_hover_background_colour
= LikeSecondary(-1.8, 0.16, -0.12);
458 m_tool_hover_background_gradient_colour
= LikeSecondary(-2.6, 0.16, 0.05);
459 m_tool_active_background_top_colour
= LikeSecondary(-9.9, -0.12, -0.09);
460 m_tool_active_background_top_gradient_colour
= LikeSecondary(-8.5, 0.16, -0.12);
461 m_tool_active_background_colour
= LikeSecondary(-7.9, 0.16, -0.20);
462 m_tool_active_background_gradient_colour
= LikeSecondary(-6.6, 0.16, -0.10);
467 // Invalidate cached tab separator
468 m_cached_tab_separator_visibility
= -1.0;
471 wxRibbonArtProvider
* wxRibbonMSWArtProvider::Clone() const
473 wxRibbonMSWArtProvider
*copy
= new wxRibbonMSWArtProvider
;
478 void wxRibbonMSWArtProvider::CloneTo(wxRibbonMSWArtProvider
* copy
) const
481 for(i
= 0; i
< 4; ++i
)
483 copy
->m_gallery_up_bitmap
[i
] = m_gallery_up_bitmap
[i
];
484 copy
->m_gallery_down_bitmap
[i
] = m_gallery_down_bitmap
[i
];
485 copy
->m_gallery_extension_bitmap
[i
] = m_gallery_extension_bitmap
[i
];
487 for(i
= 0; i
< 2; ++i
)
489 copy
->m_panel_extension_bitmap
[i
] = m_panel_extension_bitmap
[i
];
490 copy
->m_ribbon_toggle_up_bitmap
[i
] = m_ribbon_toggle_up_bitmap
[i
];
491 copy
->m_ribbon_toggle_down_bitmap
[i
] = m_ribbon_toggle_down_bitmap
[i
];
492 copy
->m_ribbon_toggle_pin_bitmap
[i
] = m_ribbon_toggle_pin_bitmap
[i
];
493 copy
->m_ribbon_bar_help_button_bitmap
[i
] = m_ribbon_bar_help_button_bitmap
[i
];
495 copy
->m_toolbar_drop_bitmap
= m_toolbar_drop_bitmap
;
497 copy
->m_primary_scheme_colour
= m_primary_scheme_colour
;
498 copy
->m_secondary_scheme_colour
= m_secondary_scheme_colour
;
499 copy
->m_tertiary_scheme_colour
= m_tertiary_scheme_colour
;
501 copy
->m_page_toggle_face_colour
= m_page_toggle_face_colour
;
502 copy
->m_page_toggle_hover_face_colour
= m_page_toggle_hover_face_colour
;
504 copy
->m_button_bar_label_colour
= m_button_bar_label_colour
;
505 copy
->m_tab_label_colour
= m_tab_label_colour
;
506 copy
->m_tab_separator_colour
= m_tab_separator_colour
;
507 copy
->m_tab_separator_gradient_colour
= m_tab_separator_gradient_colour
;
508 copy
->m_tab_active_background_colour
= m_tab_hover_background_colour
;
509 copy
->m_tab_active_background_gradient_colour
= m_tab_hover_background_gradient_colour
;
510 copy
->m_tab_hover_background_colour
= m_tab_hover_background_colour
;
511 copy
->m_tab_hover_background_gradient_colour
= m_tab_hover_background_gradient_colour
;
512 copy
->m_tab_hover_background_top_colour
= m_tab_hover_background_top_colour
;
513 copy
->m_tab_hover_background_top_gradient_colour
= m_tab_hover_background_top_gradient_colour
;
514 copy
->m_panel_label_colour
= m_panel_label_colour
;
515 copy
->m_panel_hover_label_colour
= m_panel_hover_label_colour
;
516 copy
->m_panel_minimised_label_colour
= m_panel_minimised_label_colour
;
517 copy
->m_panel_button_face_colour
= m_panel_button_face_colour
;
518 copy
->m_panel_button_hover_face_colour
= m_panel_button_hover_face_colour
;
519 copy
->m_panel_active_background_colour
= m_panel_active_background_colour
;
520 copy
->m_panel_active_background_gradient_colour
= m_panel_active_background_gradient_colour
;
521 copy
->m_panel_active_background_top_colour
= m_panel_active_background_top_colour
;
522 copy
->m_panel_active_background_top_gradient_colour
= m_panel_active_background_top_gradient_colour
;
523 copy
->m_page_background_colour
= m_page_background_colour
;
524 copy
->m_page_background_gradient_colour
= m_page_background_gradient_colour
;
525 copy
->m_page_background_top_colour
= m_page_background_top_colour
;
526 copy
->m_page_background_top_gradient_colour
= m_page_background_top_gradient_colour
;
527 copy
->m_page_hover_background_colour
= m_page_hover_background_colour
;
528 copy
->m_page_hover_background_gradient_colour
= m_page_hover_background_gradient_colour
;
529 copy
->m_page_hover_background_top_colour
= m_page_hover_background_top_colour
;
530 copy
->m_page_hover_background_top_gradient_colour
= m_page_hover_background_top_gradient_colour
;
531 copy
->m_button_bar_hover_background_colour
= m_button_bar_hover_background_colour
;
532 copy
->m_button_bar_hover_background_gradient_colour
= m_button_bar_hover_background_gradient_colour
;
533 copy
->m_button_bar_hover_background_top_colour
= m_button_bar_hover_background_top_colour
;
534 copy
->m_button_bar_hover_background_top_gradient_colour
= m_button_bar_hover_background_top_gradient_colour
;
535 copy
->m_button_bar_active_background_colour
= m_button_bar_active_background_colour
;
536 copy
->m_button_bar_active_background_gradient_colour
= m_button_bar_active_background_gradient_colour
;
537 copy
->m_button_bar_active_background_top_colour
= m_button_bar_active_background_top_colour
;
538 copy
->m_button_bar_active_background_top_gradient_colour
= m_button_bar_active_background_top_gradient_colour
;
539 copy
->m_gallery_button_background_colour
= m_gallery_button_background_colour
;
540 copy
->m_gallery_button_background_gradient_colour
= m_gallery_button_background_gradient_colour
;
541 copy
->m_gallery_button_hover_background_colour
= m_gallery_button_hover_background_colour
;
542 copy
->m_gallery_button_hover_background_gradient_colour
= m_gallery_button_hover_background_gradient_colour
;
543 copy
->m_gallery_button_active_background_colour
= m_gallery_button_active_background_colour
;
544 copy
->m_gallery_button_active_background_gradient_colour
= m_gallery_button_active_background_gradient_colour
;
545 copy
->m_gallery_button_disabled_background_colour
= m_gallery_button_disabled_background_colour
;
546 copy
->m_gallery_button_disabled_background_gradient_colour
= m_gallery_button_disabled_background_gradient_colour
;
547 copy
->m_gallery_button_face_colour
= m_gallery_button_face_colour
;
548 copy
->m_gallery_button_hover_face_colour
= m_gallery_button_hover_face_colour
;
549 copy
->m_gallery_button_active_face_colour
= m_gallery_button_active_face_colour
;
550 copy
->m_gallery_button_disabled_face_colour
= m_gallery_button_disabled_face_colour
;
552 copy
->m_tab_ctrl_background_brush
= m_tab_ctrl_background_brush
;
553 copy
->m_panel_label_background_brush
= m_panel_label_background_brush
;
554 copy
->m_panel_hover_label_background_brush
= m_panel_hover_label_background_brush
;
555 copy
->m_panel_hover_button_background_brush
= m_panel_hover_button_background_brush
;
556 copy
->m_gallery_hover_background_brush
= m_gallery_hover_background_brush
;
557 copy
->m_gallery_button_background_top_brush
= m_gallery_button_background_top_brush
;
558 copy
->m_gallery_button_hover_background_top_brush
= m_gallery_button_hover_background_top_brush
;
559 copy
->m_gallery_button_active_background_top_brush
= m_gallery_button_active_background_top_brush
;
560 copy
->m_gallery_button_disabled_background_top_brush
= m_gallery_button_disabled_background_top_brush
;
561 copy
->m_ribbon_toggle_brush
= m_ribbon_toggle_brush
;
563 copy
->m_tab_label_font
= m_tab_label_font
;
564 copy
->m_button_bar_label_font
= m_button_bar_label_font
;
565 copy
->m_panel_label_font
= m_panel_label_font
;
567 copy
->m_page_border_pen
= m_page_border_pen
;
568 copy
->m_panel_border_pen
= m_panel_border_pen
;
569 copy
->m_panel_border_gradient_pen
= m_panel_border_gradient_pen
;
570 copy
->m_panel_minimised_border_pen
= m_panel_minimised_border_pen
;
571 copy
->m_panel_minimised_border_gradient_pen
= m_panel_minimised_border_gradient_pen
;
572 copy
->m_panel_hover_button_border_pen
= m_panel_hover_button_border_pen
;
573 copy
->m_tab_border_pen
= m_tab_border_pen
;
574 copy
->m_gallery_border_pen
= m_gallery_border_pen
;
575 copy
->m_button_bar_hover_border_pen
= m_button_bar_hover_border_pen
;
576 copy
->m_button_bar_active_border_pen
= m_button_bar_active_border_pen
;
577 copy
->m_gallery_item_border_pen
= m_gallery_item_border_pen
;
578 copy
->m_toolbar_border_pen
= m_toolbar_border_pen
;
579 copy
->m_ribbon_toggle_pen
= m_ribbon_toggle_pen
;
581 copy
->m_flags
= m_flags
;
582 copy
->m_tab_separation_size
= m_tab_separation_size
;
583 copy
->m_page_border_left
= m_page_border_left
;
584 copy
->m_page_border_top
= m_page_border_top
;
585 copy
->m_page_border_right
= m_page_border_right
;
586 copy
->m_page_border_bottom
= m_page_border_bottom
;
587 copy
->m_panel_x_separation_size
= m_panel_x_separation_size
;
588 copy
->m_panel_y_separation_size
= m_panel_y_separation_size
;
589 copy
->m_gallery_bitmap_padding_left_size
= m_gallery_bitmap_padding_left_size
;
590 copy
->m_gallery_bitmap_padding_right_size
= m_gallery_bitmap_padding_right_size
;
591 copy
->m_gallery_bitmap_padding_top_size
= m_gallery_bitmap_padding_top_size
;
592 copy
->m_gallery_bitmap_padding_bottom_size
= m_gallery_bitmap_padding_bottom_size
;
595 long wxRibbonMSWArtProvider::GetFlags() const
600 void wxRibbonMSWArtProvider::SetFlags(long flags
)
602 if((flags
^ m_flags
) & wxRIBBON_BAR_FLOW_VERTICAL
)
604 if(flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
606 m_page_border_left
++;
607 m_page_border_right
++;
609 m_page_border_bottom
--;
613 m_page_border_left
--;
614 m_page_border_right
--;
616 m_page_border_bottom
++;
621 // Need to reload some bitmaps when flags change
622 #define Reload(setting) SetColour(setting, GetColour(setting))
623 Reload(wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR
);
624 Reload(wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR
);
625 Reload(wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR
);
626 Reload(wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR
);
627 Reload(wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR
);
628 Reload(wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR
);
632 int wxRibbonMSWArtProvider::GetMetric(int id
) const
636 case wxRIBBON_ART_TAB_SEPARATION_SIZE
:
637 return m_tab_separation_size
;
638 case wxRIBBON_ART_PAGE_BORDER_LEFT_SIZE
:
639 return m_page_border_left
;
640 case wxRIBBON_ART_PAGE_BORDER_TOP_SIZE
:
641 return m_page_border_top
;
642 case wxRIBBON_ART_PAGE_BORDER_RIGHT_SIZE
:
643 return m_page_border_right
;
644 case wxRIBBON_ART_PAGE_BORDER_BOTTOM_SIZE
:
645 return m_page_border_bottom
;
646 case wxRIBBON_ART_PANEL_X_SEPARATION_SIZE
:
647 return m_panel_x_separation_size
;
648 case wxRIBBON_ART_PANEL_Y_SEPARATION_SIZE
:
649 return m_panel_y_separation_size
;
650 case wxRIBBON_ART_TOOL_GROUP_SEPARATION_SIZE
:
651 return m_tool_group_separation_size
;
652 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_LEFT_SIZE
:
653 return m_gallery_bitmap_padding_left_size
;
654 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_RIGHT_SIZE
:
655 return m_gallery_bitmap_padding_right_size
;
656 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_TOP_SIZE
:
657 return m_gallery_bitmap_padding_top_size
;
658 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_BOTTOM_SIZE
:
659 return m_gallery_bitmap_padding_bottom_size
;
661 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
668 void wxRibbonMSWArtProvider::SetMetric(int id
, int new_val
)
672 case wxRIBBON_ART_TAB_SEPARATION_SIZE
:
673 m_tab_separation_size
= new_val
;
675 case wxRIBBON_ART_PAGE_BORDER_LEFT_SIZE
:
676 m_page_border_left
= new_val
;
678 case wxRIBBON_ART_PAGE_BORDER_TOP_SIZE
:
679 m_page_border_top
= new_val
;
681 case wxRIBBON_ART_PAGE_BORDER_RIGHT_SIZE
:
682 m_page_border_right
= new_val
;
684 case wxRIBBON_ART_PAGE_BORDER_BOTTOM_SIZE
:
685 m_page_border_bottom
= new_val
;
687 case wxRIBBON_ART_PANEL_X_SEPARATION_SIZE
:
688 m_panel_x_separation_size
= new_val
;
690 case wxRIBBON_ART_PANEL_Y_SEPARATION_SIZE
:
691 m_panel_y_separation_size
= new_val
;
693 case wxRIBBON_ART_TOOL_GROUP_SEPARATION_SIZE
:
694 m_tool_group_separation_size
= new_val
;
696 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_LEFT_SIZE
:
697 m_gallery_bitmap_padding_left_size
= new_val
;
699 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_RIGHT_SIZE
:
700 m_gallery_bitmap_padding_right_size
= new_val
;
702 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_TOP_SIZE
:
703 m_gallery_bitmap_padding_top_size
= new_val
;
705 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_BOTTOM_SIZE
:
706 m_gallery_bitmap_padding_bottom_size
= new_val
;
709 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
714 void wxRibbonMSWArtProvider::SetFont(int id
, const wxFont
& font
)
718 case wxRIBBON_ART_TAB_LABEL_FONT
:
719 m_tab_label_font
= font
;
721 case wxRIBBON_ART_BUTTON_BAR_LABEL_FONT
:
722 m_button_bar_label_font
= font
;
724 case wxRIBBON_ART_PANEL_LABEL_FONT
:
725 m_panel_label_font
= font
;
728 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
733 wxFont
wxRibbonMSWArtProvider::GetFont(int id
) const
737 case wxRIBBON_ART_TAB_LABEL_FONT
:
738 return m_tab_label_font
;
739 case wxRIBBON_ART_BUTTON_BAR_LABEL_FONT
:
740 return m_button_bar_label_font
;
741 case wxRIBBON_ART_PANEL_LABEL_FONT
:
742 return m_panel_label_font
;
744 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
751 wxColour
wxRibbonMSWArtProvider::GetColour(int id
) const
755 case wxRIBBON_ART_BUTTON_BAR_LABEL_COLOUR
:
756 return m_button_bar_label_colour
;
757 case wxRIBBON_ART_BUTTON_BAR_HOVER_BORDER_COLOUR
:
758 return m_button_bar_hover_border_pen
.GetColour();
759 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_COLOUR
:
760 return m_button_bar_hover_background_top_colour
;
761 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
762 return m_button_bar_hover_background_top_gradient_colour
;
763 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_COLOUR
:
764 return m_button_bar_hover_background_colour
;
765 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_GRADIENT_COLOUR
:
766 return m_button_bar_hover_background_gradient_colour
;
767 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BORDER_COLOUR
:
768 return m_button_bar_active_border_pen
.GetColour();
769 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_COLOUR
:
770 return m_button_bar_active_background_top_colour
;
771 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
772 return m_button_bar_active_background_top_gradient_colour
;
773 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_COLOUR
:
774 return m_button_bar_active_background_colour
;
775 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
776 return m_button_bar_active_background_gradient_colour
;
777 case wxRIBBON_ART_GALLERY_BORDER_COLOUR
:
778 return m_gallery_border_pen
.GetColour();
779 case wxRIBBON_ART_GALLERY_HOVER_BACKGROUND_COLOUR
:
780 return m_gallery_hover_background_brush
.GetColour();
781 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_COLOUR
:
782 return m_gallery_button_background_colour
;
783 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_GRADIENT_COLOUR
:
784 return m_gallery_button_background_gradient_colour
;
785 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_TOP_COLOUR
:
786 return m_gallery_button_background_top_brush
.GetColour();
787 case wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR
:
788 return m_gallery_button_face_colour
;
789 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_COLOUR
:
790 return m_gallery_button_hover_background_colour
;
791 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_GRADIENT_COLOUR
:
792 return m_gallery_button_hover_background_gradient_colour
;
793 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_TOP_COLOUR
:
794 return m_gallery_button_hover_background_top_brush
.GetColour();
795 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR
:
796 return m_gallery_button_face_colour
;
797 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_COLOUR
:
798 return m_gallery_button_active_background_colour
;
799 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
800 return m_gallery_button_active_background_gradient_colour
;
801 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_TOP_COLOUR
:
802 return m_gallery_button_background_top_brush
.GetColour();
803 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR
:
804 return m_gallery_button_active_face_colour
;
805 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_COLOUR
:
806 return m_gallery_button_disabled_background_colour
;
807 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_GRADIENT_COLOUR
:
808 return m_gallery_button_disabled_background_gradient_colour
;
809 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_TOP_COLOUR
:
810 return m_gallery_button_disabled_background_top_brush
.GetColour();
811 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR
:
812 return m_gallery_button_disabled_face_colour
;
813 case wxRIBBON_ART_GALLERY_ITEM_BORDER_COLOUR
:
814 return m_gallery_item_border_pen
.GetColour();
815 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_COLOUR
:
816 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_GRADIENT_COLOUR
:
817 return m_tab_ctrl_background_brush
.GetColour();
818 case wxRIBBON_ART_TAB_LABEL_COLOUR
:
819 return m_tab_label_colour
;
820 case wxRIBBON_ART_TAB_SEPARATOR_COLOUR
:
821 return m_tab_separator_colour
;
822 case wxRIBBON_ART_TAB_SEPARATOR_GRADIENT_COLOUR
:
823 return m_tab_separator_gradient_colour
;
824 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_COLOUR
:
825 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
826 return wxColour(0, 0, 0);
827 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_COLOUR
:
828 return m_tab_active_background_colour
;
829 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
830 return m_tab_active_background_gradient_colour
;
831 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_COLOUR
:
832 return m_tab_hover_background_top_colour
;
833 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
834 return m_tab_hover_background_top_gradient_colour
;
835 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_COLOUR
:
836 return m_tab_hover_background_colour
;
837 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_GRADIENT_COLOUR
:
838 return m_tab_hover_background_gradient_colour
;
839 case wxRIBBON_ART_TAB_BORDER_COLOUR
:
840 return m_tab_border_pen
.GetColour();
841 case wxRIBBON_ART_PANEL_BORDER_COLOUR
:
842 return m_panel_border_pen
.GetColour();
843 case wxRIBBON_ART_PANEL_BORDER_GRADIENT_COLOUR
:
844 return m_panel_border_gradient_pen
.GetColour();
845 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_COLOUR
:
846 return m_panel_minimised_border_pen
.GetColour();
847 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_GRADIENT_COLOUR
:
848 return m_panel_minimised_border_gradient_pen
.GetColour();
849 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_COLOUR
:
850 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_GRADIENT_COLOUR
:
851 return m_panel_label_background_brush
.GetColour();
852 case wxRIBBON_ART_PANEL_LABEL_COLOUR
:
853 return m_panel_label_colour
;
854 case wxRIBBON_ART_PANEL_MINIMISED_LABEL_COLOUR
:
855 return m_panel_minimised_label_colour
;
856 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_COLOUR
:
857 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_GRADIENT_COLOUR
:
858 return m_panel_hover_label_background_brush
.GetColour();
859 case wxRIBBON_ART_PANEL_HOVER_LABEL_COLOUR
:
860 return m_panel_hover_label_colour
;
861 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_COLOUR
:
862 return m_panel_active_background_top_colour
;
863 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
864 return m_panel_active_background_top_gradient_colour
;
865 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_COLOUR
:
866 return m_panel_active_background_colour
;
867 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
868 return m_panel_active_background_gradient_colour
;
869 case wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR
:
870 return m_panel_button_face_colour
;
871 case wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR
:
872 return m_panel_button_hover_face_colour
;
873 case wxRIBBON_ART_PAGE_BORDER_COLOUR
:
874 return m_page_border_pen
.GetColour();
875 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_COLOUR
:
876 return m_page_background_top_colour
;
877 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_GRADIENT_COLOUR
:
878 return m_page_background_top_gradient_colour
;
879 case wxRIBBON_ART_PAGE_BACKGROUND_COLOUR
:
880 return m_page_background_colour
;
881 case wxRIBBON_ART_PAGE_BACKGROUND_GRADIENT_COLOUR
:
882 return m_page_background_gradient_colour
;
883 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_COLOUR
:
884 return m_page_hover_background_top_colour
;
885 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
886 return m_page_hover_background_top_gradient_colour
;
887 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_COLOUR
:
888 return m_page_hover_background_colour
;
889 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_GRADIENT_COLOUR
:
890 return m_page_hover_background_gradient_colour
;
891 case wxRIBBON_ART_TOOLBAR_BORDER_COLOUR
:
892 case wxRIBBON_ART_TOOLBAR_HOVER_BORDER_COLOUR
:
893 return m_toolbar_border_pen
.GetColour();
894 case wxRIBBON_ART_TOOLBAR_FACE_COLOUR
:
895 return m_tool_face_colour
;
896 case wxRIBBON_ART_PAGE_TOGGLE_FACE_COLOUR
:
897 return m_page_toggle_face_colour
;
898 case wxRIBBON_ART_PAGE_TOGGLE_HOVER_FACE_COLOUR
:
899 return m_page_toggle_hover_face_colour
;
901 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
908 void wxRibbonMSWArtProvider::SetColour(int id
, const wxColor
& colour
)
912 case wxRIBBON_ART_BUTTON_BAR_LABEL_COLOUR
:
913 m_button_bar_label_colour
= colour
;
915 case wxRIBBON_ART_BUTTON_BAR_HOVER_BORDER_COLOUR
:
916 m_button_bar_hover_border_pen
.SetColour(colour
);
918 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_COLOUR
:
919 m_button_bar_hover_background_top_colour
= colour
;
921 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
922 m_button_bar_hover_background_top_gradient_colour
= colour
;
924 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_COLOUR
:
925 m_button_bar_hover_background_colour
= colour
;
927 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_GRADIENT_COLOUR
:
928 m_button_bar_hover_background_gradient_colour
= colour
;
930 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BORDER_COLOUR
:
931 m_button_bar_active_border_pen
.SetColour(colour
);
933 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_COLOUR
:
934 m_button_bar_active_background_top_colour
= colour
;
936 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
937 m_button_bar_active_background_top_gradient_colour
= colour
;
939 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_COLOUR
:
940 m_button_bar_active_background_colour
= colour
;
942 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
943 m_button_bar_active_background_gradient_colour
= colour
;
945 case wxRIBBON_ART_GALLERY_BORDER_COLOUR
:
946 m_gallery_border_pen
.SetColour(colour
);
948 case wxRIBBON_ART_GALLERY_HOVER_BACKGROUND_COLOUR
:
949 m_gallery_hover_background_brush
.SetColour(colour
);
951 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_COLOUR
:
952 m_gallery_button_background_colour
= colour
;
954 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_GRADIENT_COLOUR
:
955 m_gallery_button_background_gradient_colour
= colour
;
957 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_TOP_COLOUR
:
958 m_gallery_button_background_top_brush
.SetColour(colour
);
960 case wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR
:
961 m_gallery_button_face_colour
= colour
;
962 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
964 m_gallery_up_bitmap
[0] = wxRibbonLoadPixmap(gallery_left_xpm
, colour
);
965 m_gallery_down_bitmap
[0] = wxRibbonLoadPixmap(gallery_right_xpm
, colour
);
969 m_gallery_up_bitmap
[0] = wxRibbonLoadPixmap(gallery_up_xpm
, colour
);
970 m_gallery_down_bitmap
[0] = wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
972 m_gallery_extension_bitmap
[0] = wxRibbonLoadPixmap(gallery_extension_xpm
, colour
);
974 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_COLOUR
:
975 m_gallery_button_hover_background_colour
= colour
;
977 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_GRADIENT_COLOUR
:
978 m_gallery_button_hover_background_gradient_colour
= colour
;
980 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_TOP_COLOUR
:
981 m_gallery_button_hover_background_top_brush
.SetColour(colour
);
983 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR
:
984 m_gallery_button_hover_face_colour
= colour
;
985 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
987 m_gallery_up_bitmap
[1] = wxRibbonLoadPixmap(gallery_left_xpm
, colour
);
988 m_gallery_down_bitmap
[1] = wxRibbonLoadPixmap(gallery_right_xpm
, colour
);
992 m_gallery_up_bitmap
[1] = wxRibbonLoadPixmap(gallery_up_xpm
, colour
);
993 m_gallery_down_bitmap
[1] = wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
995 m_gallery_extension_bitmap
[1] = wxRibbonLoadPixmap(gallery_extension_xpm
, colour
);
997 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_COLOUR
:
998 m_gallery_button_active_background_colour
= colour
;
1000 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
1001 m_gallery_button_active_background_gradient_colour
= colour
;
1003 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_TOP_COLOUR
:
1004 m_gallery_button_background_top_brush
.SetColour(colour
);
1006 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR
:
1007 m_gallery_button_active_face_colour
= colour
;
1008 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1010 m_gallery_up_bitmap
[2] = wxRibbonLoadPixmap(gallery_left_xpm
, colour
);
1011 m_gallery_down_bitmap
[2] = wxRibbonLoadPixmap(gallery_right_xpm
, colour
);
1015 m_gallery_up_bitmap
[2] = wxRibbonLoadPixmap(gallery_up_xpm
, colour
);
1016 m_gallery_down_bitmap
[2] = wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
1018 m_gallery_extension_bitmap
[2] = wxRibbonLoadPixmap(gallery_extension_xpm
, colour
);
1020 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_COLOUR
:
1021 m_gallery_button_disabled_background_colour
= colour
;
1023 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_GRADIENT_COLOUR
:
1024 m_gallery_button_disabled_background_gradient_colour
= colour
;
1026 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_TOP_COLOUR
:
1027 m_gallery_button_disabled_background_top_brush
.SetColour(colour
);
1029 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR
:
1030 m_gallery_button_disabled_face_colour
= colour
;
1031 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1033 m_gallery_up_bitmap
[3] = wxRibbonLoadPixmap(gallery_left_xpm
, colour
);
1034 m_gallery_down_bitmap
[3] = wxRibbonLoadPixmap(gallery_right_xpm
, colour
);
1038 m_gallery_up_bitmap
[3] = wxRibbonLoadPixmap(gallery_up_xpm
, colour
);
1039 m_gallery_down_bitmap
[3] = wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
1041 m_gallery_extension_bitmap
[3] = wxRibbonLoadPixmap(gallery_extension_xpm
, colour
);
1043 case wxRIBBON_ART_GALLERY_ITEM_BORDER_COLOUR
:
1044 m_gallery_item_border_pen
.SetColour(colour
);
1046 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_COLOUR
:
1047 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_GRADIENT_COLOUR
:
1048 m_tab_ctrl_background_brush
.SetColour(colour
);
1049 m_cached_tab_separator_visibility
= -1.0;
1051 case wxRIBBON_ART_TAB_LABEL_COLOUR
:
1052 m_tab_label_colour
= colour
;
1054 case wxRIBBON_ART_TAB_SEPARATOR_COLOUR
:
1055 m_tab_separator_colour
= colour
;
1056 m_cached_tab_separator_visibility
= -1.0;
1058 case wxRIBBON_ART_TAB_SEPARATOR_GRADIENT_COLOUR
:
1059 m_tab_separator_gradient_colour
= colour
;
1060 m_cached_tab_separator_visibility
= -1.0;
1062 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_COLOUR
:
1063 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
1065 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_COLOUR
:
1066 m_tab_active_background_colour
= colour
;
1068 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
1069 m_tab_active_background_gradient_colour
= colour
;
1071 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_COLOUR
:
1072 m_tab_hover_background_top_colour
= colour
;
1074 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
1075 m_tab_hover_background_top_gradient_colour
= colour
;
1077 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_COLOUR
:
1078 m_tab_hover_background_colour
= colour
;
1080 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_GRADIENT_COLOUR
:
1081 m_tab_hover_background_gradient_colour
= colour
;
1083 case wxRIBBON_ART_TAB_BORDER_COLOUR
:
1084 m_tab_border_pen
.SetColour(colour
);
1086 case wxRIBBON_ART_PANEL_BORDER_COLOUR
:
1087 m_panel_border_pen
.SetColour(colour
);
1089 case wxRIBBON_ART_PANEL_BORDER_GRADIENT_COLOUR
:
1090 m_panel_border_gradient_pen
.SetColour(colour
);
1092 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_COLOUR
:
1093 m_panel_minimised_border_pen
.SetColour(colour
);
1095 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_GRADIENT_COLOUR
:
1096 m_panel_minimised_border_gradient_pen
.SetColour(colour
);
1098 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_COLOUR
:
1099 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_GRADIENT_COLOUR
:
1100 m_panel_label_background_brush
.SetColour(colour
);
1102 case wxRIBBON_ART_PANEL_LABEL_COLOUR
:
1103 m_panel_label_colour
= colour
;
1105 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_COLOUR
:
1106 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_GRADIENT_COLOUR
:
1107 m_panel_hover_label_background_brush
.SetColour(colour
);
1109 case wxRIBBON_ART_PANEL_HOVER_LABEL_COLOUR
:
1110 m_panel_hover_label_colour
= colour
;
1112 case wxRIBBON_ART_PANEL_MINIMISED_LABEL_COLOUR
:
1113 m_panel_minimised_label_colour
= colour
;
1115 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_COLOUR
:
1116 m_panel_active_background_top_colour
= colour
;
1118 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
1119 m_panel_active_background_top_gradient_colour
= colour
;
1121 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_COLOUR
:
1122 m_panel_active_background_colour
= colour
;
1124 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
1125 m_panel_active_background_gradient_colour
= colour
;
1127 case wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR
:
1128 m_panel_button_face_colour
= colour
;
1129 m_panel_extension_bitmap
[0] = wxRibbonLoadPixmap(panel_extension_xpm
, colour
);
1131 case wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR
:
1132 m_panel_button_hover_face_colour
= colour
;
1133 m_panel_extension_bitmap
[1] = wxRibbonLoadPixmap(panel_extension_xpm
, colour
);
1135 case wxRIBBON_ART_PAGE_BORDER_COLOUR
:
1136 m_page_border_pen
.SetColour(colour
);
1138 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_COLOUR
:
1139 m_page_background_top_colour
= colour
;
1141 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_GRADIENT_COLOUR
:
1142 m_page_background_top_gradient_colour
= colour
;
1144 case wxRIBBON_ART_PAGE_BACKGROUND_COLOUR
:
1145 m_page_background_colour
= colour
;
1147 case wxRIBBON_ART_PAGE_BACKGROUND_GRADIENT_COLOUR
:
1148 m_page_background_gradient_colour
= colour
;
1150 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_COLOUR
:
1151 m_page_hover_background_top_colour
= colour
;
1153 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
1154 m_page_hover_background_top_gradient_colour
= colour
;
1156 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_COLOUR
:
1157 m_page_hover_background_colour
= colour
;
1159 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_GRADIENT_COLOUR
:
1160 m_page_hover_background_gradient_colour
= colour
;
1162 case wxRIBBON_ART_TOOLBAR_BORDER_COLOUR
:
1163 case wxRIBBON_ART_TOOLBAR_HOVER_BORDER_COLOUR
:
1164 m_toolbar_border_pen
.SetColour(colour
);
1166 case wxRIBBON_ART_TOOLBAR_FACE_COLOUR
:
1167 m_tool_face_colour
= colour
;
1168 m_toolbar_drop_bitmap
= wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
1170 case wxRIBBON_ART_PAGE_TOGGLE_FACE_COLOUR
:
1171 m_page_toggle_face_colour
= colour
;
1172 m_ribbon_toggle_down_bitmap
[0] = wxRibbonLoadPixmap(panel_toggle_down_xpm
, colour
);
1173 m_ribbon_toggle_up_bitmap
[0] = wxRibbonLoadPixmap(panel_toggle_up_xpm
, colour
);
1174 m_ribbon_toggle_pin_bitmap
[0] = wxRibbonLoadPixmap(ribbon_toggle_pin_xpm
, colour
);
1175 m_ribbon_bar_help_button_bitmap
[0] = wxRibbonLoadPixmap(ribbon_help_button_xpm
, colour
);
1177 case wxRIBBON_ART_PAGE_TOGGLE_HOVER_FACE_COLOUR
:
1178 m_page_toggle_hover_face_colour
= colour
;
1179 m_ribbon_toggle_down_bitmap
[1] = wxRibbonLoadPixmap(panel_toggle_down_xpm
, colour
);
1180 m_ribbon_toggle_up_bitmap
[1] = wxRibbonLoadPixmap(panel_toggle_up_xpm
, colour
);
1181 m_ribbon_toggle_pin_bitmap
[1] = wxRibbonLoadPixmap(ribbon_toggle_pin_xpm
, colour
);
1182 m_ribbon_bar_help_button_bitmap
[1] = wxRibbonLoadPixmap(ribbon_help_button_xpm
, colour
);
1185 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
1190 void wxRibbonMSWArtProvider::DrawTabCtrlBackground(
1192 wxWindow
* WXUNUSED(wnd
),
1195 dc
.SetPen(*wxTRANSPARENT_PEN
);
1196 dc
.SetBrush(m_tab_ctrl_background_brush
);
1197 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
1199 dc
.SetPen(m_page_border_pen
);
1202 dc
.DrawLine(rect
.x
+ 3, rect
.y
+ rect
.height
- 1, rect
.x
+ rect
.width
- 3, rect
.y
+ rect
.height
- 1);
1206 dc
.DrawLine(rect
.x
, rect
.y
+ rect
.height
- 1, rect
.x
+ rect
.width
, rect
.y
+ rect
.height
- 1);
1210 void wxRibbonMSWArtProvider::DrawTab(
1212 wxWindow
* WXUNUSED(wnd
),
1213 const wxRibbonPageTabInfo
& tab
)
1215 if(tab
.rect
.height
<= 2)
1218 if(tab
.active
|| tab
.hovered
|| tab
.highlight
)
1222 wxRect
background(tab
.rect
);
1226 background
.width
-= 4;
1227 background
.height
-= 2;
1229 dc
.GradientFillLinear(background
, m_tab_active_background_colour
,
1230 m_tab_active_background_gradient_colour
, wxSOUTH
);
1232 // TODO: active and hovered
1234 else if(tab
.hovered
)
1236 wxRect
background(tab
.rect
);
1240 background
.width
-= 4;
1241 background
.height
-= 3;
1242 int h
= background
.height
;
1243 background
.height
/= 2;
1244 dc
.GradientFillLinear(background
,
1245 m_tab_hover_background_top_colour
,
1246 m_tab_hover_background_top_gradient_colour
, wxSOUTH
);
1248 background
.y
+= background
.height
;
1249 background
.height
= h
- background
.height
;
1250 dc
.GradientFillLinear(background
, m_tab_hover_background_colour
,
1251 m_tab_hover_background_gradient_colour
, wxSOUTH
);
1253 else if(tab
.highlight
)
1255 wxRect
background(tab
.rect
);
1259 background
.width
-= 4;
1260 background
.height
-= 3;
1261 int h
= background
.height
;
1262 background
.height
/= 2;
1264 //For highlight pages we show a colour between the active page and for a hovered page:
1265 wxColour
top_colour1((m_tab_active_background_colour
.Red() + m_tab_hover_background_top_colour
.Red())/2,
1266 (m_tab_active_background_colour
.Green() + m_tab_hover_background_top_colour
.Green())/2,
1267 (m_tab_active_background_colour
.Blue() + m_tab_hover_background_top_colour
.Blue())/2);
1269 wxColour
bottom_colour1((m_tab_active_background_gradient_colour
.Red() + m_tab_hover_background_top_gradient_colour
.Red())/2,
1270 (m_tab_active_background_gradient_colour
.Green() + m_tab_hover_background_top_gradient_colour
.Green())/2,
1271 (m_tab_active_background_gradient_colour
.Blue() + m_tab_hover_background_top_gradient_colour
.Blue())/2);
1273 dc
.GradientFillLinear(background
, top_colour1
, bottom_colour1
, wxSOUTH
);
1275 background
.y
+= background
.height
;
1276 background
.height
= h
- background
.height
;
1278 wxColour
top_colour2((m_tab_active_background_colour
.Red() + m_tab_hover_background_colour
.Red())/2,
1279 (m_tab_active_background_colour
.Green() + m_tab_hover_background_colour
.Green())/2,
1280 (m_tab_active_background_colour
.Blue() + m_tab_hover_background_colour
.Blue())/2);
1282 wxColour
bottom_colour2((m_tab_active_background_gradient_colour
.Red() + m_tab_hover_background_gradient_colour
.Red())/2,
1283 (m_tab_active_background_gradient_colour
.Green() + m_tab_hover_background_gradient_colour
.Green())/2,
1284 (m_tab_active_background_gradient_colour
.Blue() + m_tab_hover_background_gradient_colour
.Blue())/2);
1286 dc
.GradientFillLinear(background
, top_colour2
, bottom_colour2
, wxSOUTH
);
1289 wxPoint border_points
[6];
1290 border_points
[0] = wxPoint(1, tab
.rect
.height
- 2);
1291 border_points
[1] = wxPoint(1, 3);
1292 border_points
[2] = wxPoint(3, 1);
1293 border_points
[3] = wxPoint(tab
.rect
.width
- 4, 1);
1294 border_points
[4] = wxPoint(tab
.rect
.width
- 2, 3);
1295 border_points
[5] = wxPoint(tab
.rect
.width
- 2, tab
.rect
.height
- 1);
1297 dc
.SetPen(m_tab_border_pen
);
1298 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
, tab
.rect
.x
, tab
.rect
.y
);
1302 // Give the tab a curved outward border at the bottom
1303 dc
.DrawPoint(tab
.rect
.x
, tab
.rect
.y
+ tab
.rect
.height
- 2);
1304 dc
.DrawPoint(tab
.rect
.x
+ tab
.rect
.width
- 1, tab
.rect
.y
+ tab
.rect
.height
- 2);
1306 wxPen
p(m_tab_active_background_gradient_colour
);
1309 // Technically the first two points are the wrong colour, but they're near enough
1310 dc
.DrawPoint(tab
.rect
.x
+ 1, tab
.rect
.y
+ tab
.rect
.height
- 2);
1311 dc
.DrawPoint(tab
.rect
.x
+ tab
.rect
.width
- 2, tab
.rect
.y
+ tab
.rect
.height
- 2);
1312 dc
.DrawPoint(tab
.rect
.x
+ 1, tab
.rect
.y
+ tab
.rect
.height
- 1);
1313 dc
.DrawPoint(tab
.rect
.x
, tab
.rect
.y
+ tab
.rect
.height
- 1);
1314 dc
.DrawPoint(tab
.rect
.x
+ tab
.rect
.width
- 2, tab
.rect
.y
+ tab
.rect
.height
- 1);
1315 dc
.DrawPoint(tab
.rect
.x
+ tab
.rect
.width
- 1, tab
.rect
.y
+ tab
.rect
.height
- 1);
1319 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_ICONS
)
1321 wxBitmap icon
= tab
.page
->GetIcon();
1324 int x
= tab
.rect
.x
+ 4;
1325 if((m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
) == 0)
1326 x
= tab
.rect
.x
+ (tab
.rect
.width
- icon
.GetWidth()) / 2;
1327 dc
.DrawBitmap(icon
, x
, tab
.rect
.y
+ 1 + (tab
.rect
.height
- 1 -
1328 icon
.GetHeight()) / 2, true);
1331 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
)
1333 wxString label
= tab
.page
->GetLabel();
1334 if(!label
.IsEmpty())
1336 dc
.SetFont(m_tab_label_font
);
1337 dc
.SetTextForeground(m_tab_label_colour
);
1338 dc
.SetBackgroundMode(wxTRANSPARENT
);
1342 dc
.GetTextExtent(label
, &text_width
, &text_height
);
1343 int width
= tab
.rect
.width
- 5;
1344 int x
= tab
.rect
.x
+ 3;
1345 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_ICONS
)
1347 x
+= 3 + tab
.page
->GetIcon().GetWidth();
1348 width
-= 3 + tab
.page
->GetIcon().GetWidth();
1350 int y
= tab
.rect
.y
+ (tab
.rect
.height
- text_height
) / 2;
1352 if(width
<= text_width
)
1354 dc
.SetClippingRegion(x
, tab
.rect
.y
, width
, tab
.rect
.height
);
1355 dc
.DrawText(label
, x
, y
);
1359 dc
.DrawText(label
, x
+ (width
- text_width
) / 2 + 1, y
);
1365 void wxRibbonMSWArtProvider::DrawTabSeparator(
1371 if(visibility
<= 0.0)
1375 if(visibility
> 1.0)
1380 // The tab separator is relatively expensive to draw (for its size), and is
1381 // usually drawn multiple times sequentially (in different positions), so it
1382 // makes sense to draw it once and cache it.
1383 if(!m_cached_tab_separator
.IsOk() || m_cached_tab_separator
.GetSize() != rect
.GetSize() || visibility
!= m_cached_tab_separator_visibility
)
1385 wxRect
size(rect
.GetSize());
1386 ReallyDrawTabSeparator(wnd
, size
, visibility
);
1388 dc
.DrawBitmap(m_cached_tab_separator
, rect
.x
, rect
.y
, false);
1391 void wxRibbonMSWArtProvider::ReallyDrawTabSeparator(wxWindow
* wnd
, const wxRect
& rect
, double visibility
)
1393 if(!m_cached_tab_separator
.IsOk() || m_cached_tab_separator
.GetSize() != rect
.GetSize())
1395 m_cached_tab_separator
= wxBitmap(rect
.GetSize());
1398 wxMemoryDC
dc(m_cached_tab_separator
);
1399 DrawTabCtrlBackground(dc
, wnd
, rect
);
1401 wxCoord x
= rect
.x
+ rect
.width
/ 2;
1402 double h
= (double)(rect
.height
- 1);
1404 double r1
= m_tab_ctrl_background_brush
.GetColour().Red() * (1.0 - visibility
) + 0.5;
1405 double g1
= m_tab_ctrl_background_brush
.GetColour().Green() * (1.0 - visibility
) + 0.5;
1406 double b1
= m_tab_ctrl_background_brush
.GetColour().Blue() * (1.0 - visibility
) + 0.5;
1407 double r2
= m_tab_separator_colour
.Red();
1408 double g2
= m_tab_separator_colour
.Green();
1409 double b2
= m_tab_separator_colour
.Blue();
1410 double r3
= m_tab_separator_gradient_colour
.Red();
1411 double g3
= m_tab_separator_gradient_colour
.Green();
1412 double b3
= m_tab_separator_gradient_colour
.Blue();
1414 for(int i
= 0; i
< rect
.height
- 1; ++i
)
1416 double p
= ((double)i
)/h
;
1418 double r
= (p
* r3
+ (1.0 - p
) * r2
) * visibility
+ r1
;
1419 double g
= (p
* g3
+ (1.0 - p
) * g2
) * visibility
+ g1
;
1420 double b
= (p
* b3
+ (1.0 - p
) * b2
) * visibility
+ b1
;
1422 wxPen
P(wxColour((unsigned char)r
, (unsigned char)g
, (unsigned char)b
));
1424 dc
.DrawPoint(x
, rect
.y
+ i
);
1427 m_cached_tab_separator_visibility
= visibility
;
1430 void wxRibbonMSWArtProvider::DrawPartialPageBackground(wxDC
& dc
,
1431 wxWindow
* wnd
, const wxRect
& rect
, wxRibbonPage
* page
,
1432 wxPoint offset
, bool hovered
)
1435 // Expanded panels need a background - the expanded panel at
1436 // best size may have a greater Y dimension higher than when
1437 // on the bar if it has a sizer. AUI art provider does not need this
1438 // because it paints the panel without reference to its parent's size.
1439 // Expanded panels use a wxFrame as parent (not a wxRibbonPage).
1441 if(wnd
->GetSizer() && wnd
->GetParent() != page
)
1443 background
= wnd
->GetParent()->GetSize();
1444 offset
= wxPoint(0,0);
1448 background
= page
->GetSize();
1449 page
->AdjustRectToIncludeScrollButtons(&background
);
1450 background
.height
-= 2;
1452 // Page background isn't dependant upon the width of the page
1453 // (at least not the part of it intended to be painted by this
1454 // function). Set to wider than the page itself for when externally
1455 // expanded panels need a background - the expanded panel can be wider
1458 background
.width
= INT_MAX
;
1460 // upper_rect, lower_rect, paint_rect are all in page co-ordinates
1461 wxRect
upper_rect(background
);
1462 upper_rect
.height
/= 5;
1464 wxRect
lower_rect(background
);
1465 lower_rect
.y
+= upper_rect
.height
;
1466 lower_rect
.height
-= upper_rect
.height
;
1468 wxRect
paint_rect(rect
);
1469 paint_rect
.x
+= offset
.x
;
1470 paint_rect
.y
+= offset
.y
;
1472 wxColour bg_top
, bg_top_grad
, bg_btm
, bg_btm_grad
;
1475 bg_top
= m_page_hover_background_top_colour
;
1476 bg_top_grad
= m_page_hover_background_top_gradient_colour
;
1477 bg_btm
= m_page_hover_background_colour
;
1478 bg_btm_grad
= m_page_hover_background_gradient_colour
;
1482 bg_top
= m_page_background_top_colour
;
1483 bg_top_grad
= m_page_background_top_gradient_colour
;
1484 bg_btm
= m_page_background_colour
;
1485 bg_btm_grad
= m_page_background_gradient_colour
;
1488 if(paint_rect
.Intersects(upper_rect
))
1490 wxRect
rect(upper_rect
);
1491 rect
.Intersect(paint_rect
);
1494 wxColour
starting_colour(wxRibbonInterpolateColour(bg_top
, bg_top_grad
,
1495 paint_rect
.y
, upper_rect
.y
, upper_rect
.y
+ upper_rect
.height
));
1496 wxColour
ending_colour(wxRibbonInterpolateColour(bg_top
, bg_top_grad
,
1497 paint_rect
.y
+ paint_rect
.height
, upper_rect
.y
,
1498 upper_rect
.y
+ upper_rect
.height
));
1499 dc
.GradientFillLinear(rect
, starting_colour
, ending_colour
, wxSOUTH
);
1502 if(paint_rect
.Intersects(lower_rect
))
1504 wxRect
rect(lower_rect
);
1505 rect
.Intersect(paint_rect
);
1508 wxColour
starting_colour(wxRibbonInterpolateColour(bg_btm
, bg_btm_grad
,
1509 paint_rect
.y
, lower_rect
.y
, lower_rect
.y
+ lower_rect
.height
));
1510 wxColour
ending_colour(wxRibbonInterpolateColour(bg_btm
, bg_btm_grad
,
1511 paint_rect
.y
+ paint_rect
.height
,
1512 lower_rect
.y
, lower_rect
.y
+ lower_rect
.height
));
1513 dc
.GradientFillLinear(rect
, starting_colour
, ending_colour
, wxSOUTH
);
1517 void wxRibbonMSWArtProvider::DrawPageBackground(
1519 wxWindow
* WXUNUSED(wnd
),
1522 dc
.SetPen(*wxTRANSPARENT_PEN
);
1523 dc
.SetBrush(m_tab_ctrl_background_brush
);
1529 dc
.DrawRectangle(edge
.x
, edge
.y
, edge
.width
, edge
.height
);
1531 edge
.x
+= rect
.width
- 2;
1532 dc
.DrawRectangle(edge
.x
, edge
.y
, edge
.width
, edge
.height
);
1536 edge
.y
+= (rect
.height
- edge
.height
);
1537 dc
.DrawRectangle(edge
.x
, edge
.y
, edge
.width
, edge
.height
);
1541 wxRect
background(rect
);
1543 background
.width
-= 4;
1544 background
.height
-= 2;
1546 background
.height
/= 5;
1547 dc
.GradientFillLinear(background
, m_page_background_top_colour
,
1548 m_page_background_top_gradient_colour
, wxSOUTH
);
1550 background
.y
+= background
.height
;
1551 background
.height
= rect
.height
- 2 - background
.height
;
1552 dc
.GradientFillLinear(background
, m_page_background_colour
,
1553 m_page_background_gradient_colour
, wxSOUTH
);
1557 wxPoint border_points
[8];
1558 border_points
[0] = wxPoint(2, 0);
1559 border_points
[1] = wxPoint(1, 1);
1560 border_points
[2] = wxPoint(1, rect
.height
- 4);
1561 border_points
[3] = wxPoint(3, rect
.height
- 2);
1562 border_points
[4] = wxPoint(rect
.width
- 4, rect
.height
- 2);
1563 border_points
[5] = wxPoint(rect
.width
- 2, rect
.height
- 4);
1564 border_points
[6] = wxPoint(rect
.width
- 2, 1);
1565 border_points
[7] = wxPoint(rect
.width
- 4, -1);
1567 dc
.SetPen(m_page_border_pen
);
1568 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
, rect
.x
, rect
.y
);
1572 void wxRibbonMSWArtProvider::DrawScrollButton(
1574 wxWindow
* WXUNUSED(wnd
),
1575 const wxRect
& rect_
,
1580 if((style
& wxRIBBON_SCROLL_BTN_FOR_MASK
) == wxRIBBON_SCROLL_BTN_FOR_PAGE
)
1582 // Page scroll buttons do not have the luxury of rendering on top of anything
1583 // else, and their size includes some padding, hence the background painting
1584 // and size adjustment.
1585 dc
.SetPen(*wxTRANSPARENT_PEN
);
1586 dc
.SetBrush(m_tab_ctrl_background_brush
);
1587 dc
.DrawRectangle(rect
);
1588 dc
.SetClippingRegion(rect
);
1589 switch(style
& wxRIBBON_SCROLL_BTN_DIRECTION_MASK
)
1591 case wxRIBBON_SCROLL_BTN_LEFT
:
1593 case wxRIBBON_SCROLL_BTN_RIGHT
:
1597 case wxRIBBON_SCROLL_BTN_UP
:
1603 case wxRIBBON_SCROLL_BTN_DOWN
:
1612 wxRect
background(rect
);
1615 background
.width
-= 2;
1616 background
.height
-= 2;
1618 if(style
& wxRIBBON_SCROLL_BTN_UP
)
1619 background
.height
/= 2;
1621 background
.height
/= 5;
1622 dc
.GradientFillLinear(background
, m_page_background_top_colour
,
1623 m_page_background_top_gradient_colour
, wxSOUTH
);
1625 background
.y
+= background
.height
;
1626 background
.height
= rect
.height
- 2 - background
.height
;
1627 dc
.GradientFillLinear(background
, m_page_background_colour
,
1628 m_page_background_gradient_colour
, wxSOUTH
);
1632 wxPoint border_points
[7];
1633 switch(style
& wxRIBBON_SCROLL_BTN_DIRECTION_MASK
)
1635 case wxRIBBON_SCROLL_BTN_LEFT
:
1636 border_points
[0] = wxPoint(2, 0);
1637 border_points
[1] = wxPoint(rect
.width
- 1, 0);
1638 border_points
[2] = wxPoint(rect
.width
- 1, rect
.height
- 1);
1639 border_points
[3] = wxPoint(2, rect
.height
- 1);
1640 border_points
[4] = wxPoint(0, rect
.height
- 3);
1641 border_points
[5] = wxPoint(0, 2);
1643 case wxRIBBON_SCROLL_BTN_RIGHT
:
1644 border_points
[0] = wxPoint(0, 0);
1645 border_points
[1] = wxPoint(rect
.width
- 3, 0);
1646 border_points
[2] = wxPoint(rect
.width
- 1, 2);
1647 border_points
[3] = wxPoint(rect
.width
- 1, rect
.height
- 3);
1648 border_points
[4] = wxPoint(rect
.width
- 3, rect
.height
- 1);
1649 border_points
[5] = wxPoint(0, rect
.height
- 1);
1651 case wxRIBBON_SCROLL_BTN_UP
:
1652 border_points
[0] = wxPoint(2, 0);
1653 border_points
[1] = wxPoint(rect
.width
- 3, 0);
1654 border_points
[2] = wxPoint(rect
.width
- 1, 2);
1655 border_points
[3] = wxPoint(rect
.width
- 1, rect
.height
- 1);
1656 border_points
[4] = wxPoint(0, rect
.height
- 1);
1657 border_points
[5] = wxPoint(0, 2);
1659 case wxRIBBON_SCROLL_BTN_DOWN
:
1660 border_points
[0] = wxPoint(0, 0);
1661 border_points
[1] = wxPoint(rect
.width
- 1, 0);
1662 border_points
[2] = wxPoint(rect
.width
- 1, rect
.height
- 3);
1663 border_points
[3] = wxPoint(rect
.width
- 3, rect
.height
- 1);
1664 border_points
[4] = wxPoint(2, rect
.height
- 1);
1665 border_points
[5] = wxPoint(0, rect
.height
- 3);
1668 border_points
[6] = border_points
[0];
1670 dc
.SetPen(m_page_border_pen
);
1671 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
, rect
.x
, rect
.y
);
1675 // NB: Code for handling hovered/active state is temporary
1676 wxPoint arrow_points
[3];
1677 switch(style
& wxRIBBON_SCROLL_BTN_DIRECTION_MASK
)
1679 case wxRIBBON_SCROLL_BTN_LEFT
:
1680 arrow_points
[0] = wxPoint(rect
.width
/ 2 - 2, rect
.height
/ 2);
1681 if(style
& wxRIBBON_SCROLL_BTN_ACTIVE
)
1682 arrow_points
[0].y
+= 1;
1683 arrow_points
[1] = arrow_points
[0] + wxPoint(3, -3);
1684 arrow_points
[2] = arrow_points
[0] + wxPoint(3, 3);
1686 case wxRIBBON_SCROLL_BTN_RIGHT
:
1687 arrow_points
[0] = wxPoint(rect
.width
/ 2 + 2, rect
.height
/ 2);
1688 if(style
& wxRIBBON_SCROLL_BTN_ACTIVE
)
1689 arrow_points
[0].y
+= 1;
1690 arrow_points
[1] = arrow_points
[0] - wxPoint(3, 3);
1691 arrow_points
[2] = arrow_points
[0] - wxPoint(3, -3);
1693 case wxRIBBON_SCROLL_BTN_UP
:
1694 arrow_points
[0] = wxPoint(rect
.width
/ 2, rect
.height
/ 2 - 2);
1695 if(style
& wxRIBBON_SCROLL_BTN_ACTIVE
)
1696 arrow_points
[0].y
+= 1;
1697 arrow_points
[1] = arrow_points
[0] + wxPoint( 3, 3);
1698 arrow_points
[2] = arrow_points
[0] + wxPoint(-3, 3);
1700 case wxRIBBON_SCROLL_BTN_DOWN
:
1701 arrow_points
[0] = wxPoint(rect
.width
/ 2, rect
.height
/ 2 + 2);
1702 if(style
& wxRIBBON_SCROLL_BTN_ACTIVE
)
1703 arrow_points
[0].y
+= 1;
1704 arrow_points
[1] = arrow_points
[0] - wxPoint( 3, 3);
1705 arrow_points
[2] = arrow_points
[0] - wxPoint(-3, 3);
1709 dc
.SetPen(*wxTRANSPARENT_PEN
);
1710 wxBrush
B(style
& wxRIBBON_SCROLL_BTN_HOVERED
? m_tab_active_background_colour
: m_tab_label_colour
);
1712 dc
.DrawPolygon(sizeof(arrow_points
)/sizeof(wxPoint
), arrow_points
, rect
.x
, rect
.y
);
1716 void wxRibbonMSWArtProvider::DrawDropdownArrow(wxDC
& dc
, int x
, int y
, const wxColour
& colour
)
1718 wxPoint arrow_points
[3];
1719 wxBrush
brush(colour
);
1720 arrow_points
[0] = wxPoint(1, 2);
1721 arrow_points
[1] = arrow_points
[0] + wxPoint(-3, -3);
1722 arrow_points
[2] = arrow_points
[0] + wxPoint( 3, -3);
1723 dc
.SetPen(*wxTRANSPARENT_PEN
);
1725 dc
.DrawPolygon(sizeof(arrow_points
)/sizeof(wxPoint
), arrow_points
, x
, y
);
1728 void wxRibbonMSWArtProvider::RemovePanelPadding(wxRect
* rect
)
1730 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1742 void wxRibbonMSWArtProvider::DrawPanelBackground(
1747 DrawPartialPageBackground(dc
, wnd
, rect
, false);
1749 wxRect
true_rect(rect
);
1750 RemovePanelPadding(&true_rect
);
1751 bool has_ext_button
= wnd
->HasExtButton();
1755 dc
.SetFont(m_panel_label_font
);
1756 dc
.SetPen(*wxTRANSPARENT_PEN
);
1757 if(wnd
->IsHovered())
1759 dc
.SetBrush(m_panel_hover_label_background_brush
);
1760 dc
.SetTextForeground(m_panel_hover_label_colour
);
1764 dc
.SetBrush(m_panel_label_background_brush
);
1765 dc
.SetTextForeground(m_panel_label_colour
);
1768 wxRect
label_rect(true_rect
);
1769 wxString label
= wnd
->GetLabel();
1770 bool clip_label
= false;
1771 wxSize
label_size(dc
.GetTextExtent(label
));
1773 label_rect
.SetX(label_rect
.GetX() + 1);
1774 label_rect
.SetWidth(label_rect
.GetWidth() - 2);
1775 label_rect
.SetHeight(label_size
.GetHeight() + 2);
1776 label_rect
.SetY(true_rect
.GetBottom() - label_rect
.GetHeight());
1777 label_height
= label_rect
.GetHeight();
1779 wxRect label_bg_rect
= label_rect
;
1782 label_rect
.SetWidth(label_rect
.GetWidth() - 13);
1784 if(label_size
.GetWidth() > label_rect
.GetWidth())
1786 // Test if there is enough length for 3 letters and ...
1787 wxString new_label
= label
.Mid(0, 3) + wxT("...");
1788 label_size
= dc
.GetTextExtent(new_label
);
1789 if(label_size
.GetWidth() > label_rect
.GetWidth())
1791 // Not enough room for three characters and ...
1792 // Display the entire label and just crop it
1797 // Room for some characters and ...
1798 // Display as many characters as possible and append ...
1799 for(size_t len
= label
.Len() - 1; len
>= 3; --len
)
1801 new_label
= label
.Mid(0, len
) + wxT("...");
1802 label_size
= dc
.GetTextExtent(new_label
);
1803 if(label_size
.GetWidth() <= label_rect
.GetWidth())
1812 dc
.DrawRectangle(label_bg_rect
);
1815 wxDCClipper
clip(dc
, label_rect
);
1816 dc
.DrawText(label
, label_rect
.x
, label_rect
.y
+
1817 (label_rect
.GetHeight() - label_size
.GetHeight()) / 2);
1821 dc
.DrawText(label
, label_rect
.x
+
1822 (label_rect
.GetWidth() - label_size
.GetWidth()) / 2,
1824 (label_rect
.GetHeight() - label_size
.GetHeight()) / 2);
1829 if(wnd
->IsExtButtonHovered())
1831 dc
.SetPen(m_panel_hover_button_border_pen
);
1832 dc
.SetBrush(m_panel_hover_button_background_brush
);
1833 dc
.DrawRoundedRectangle(label_rect
.GetRight(), label_rect
.GetBottom() - 13, 13, 13, 1.0);
1834 dc
.DrawBitmap(m_panel_extension_bitmap
[1], label_rect
.GetRight() + 3, label_rect
.GetBottom() - 10, true);
1837 dc
.DrawBitmap(m_panel_extension_bitmap
[0], label_rect
.GetRight() + 3, label_rect
.GetBottom() - 10, true);
1841 if(wnd
->IsHovered())
1843 wxRect
client_rect(true_rect
);
1845 client_rect
.width
-= 2;
1847 client_rect
.height
-= 2 + label_height
;
1848 DrawPartialPageBackground(dc
, wnd
, client_rect
, true);
1851 DrawPanelBorder(dc
, true_rect
, m_panel_border_pen
, m_panel_border_gradient_pen
);
1854 wxRect
wxRibbonMSWArtProvider::GetPanelExtButtonArea(wxDC
& WXUNUSED(dc
),
1855 const wxRibbonPanel
* WXUNUSED(wnd
),
1858 RemovePanelPadding(&rect
);
1859 rect
= wxRect(rect
.GetRight()-13, rect
.GetBottom()-13, 13, 13);
1863 void wxRibbonMSWArtProvider::DrawGalleryBackground(
1865 wxRibbonGallery
* wnd
,
1868 DrawPartialPageBackground(dc
, wnd
, rect
);
1870 if(wnd
->IsHovered())
1872 dc
.SetPen(*wxTRANSPARENT_PEN
);
1873 dc
.SetBrush(m_gallery_hover_background_brush
);
1874 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1876 dc
.DrawRectangle(rect
.x
+ 1, rect
.y
+ 1, rect
.width
- 2,
1881 dc
.DrawRectangle(rect
.x
+ 1, rect
.y
+ 1, rect
.width
- 16,
1886 dc
.SetPen(m_gallery_border_pen
);
1888 dc
.DrawLine(rect
.x
+ 1, rect
.y
, rect
.x
+ rect
.width
- 1, rect
.y
);
1889 dc
.DrawLine(rect
.x
, rect
.y
+ 1, rect
.x
, rect
.y
+ rect
.height
- 1);
1890 dc
.DrawLine(rect
.x
+ 1, rect
.y
+ rect
.height
- 1, rect
.x
+ rect
.width
- 1,
1891 rect
.y
+ rect
.height
- 1);
1892 dc
.DrawLine(rect
.x
+ rect
.width
- 1, rect
.y
+ 1, rect
.x
+ rect
.width
- 1,
1893 rect
.y
+ rect
.height
- 1);
1895 DrawGalleryBackgroundCommon(dc
, wnd
, rect
);
1898 void wxRibbonMSWArtProvider::DrawGalleryBackgroundCommon(wxDC
& dc
,
1899 wxRibbonGallery
* wnd
,
1902 wxRect up_btn
, down_btn
, ext_btn
;
1904 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1906 // Divider between items and buttons
1907 dc
.DrawLine(rect
.x
, rect
.y
+ rect
.height
- 15, rect
.x
+ rect
.width
,
1908 rect
.y
+ rect
.height
- 15);
1910 up_btn
= wxRect(rect
.x
, rect
.y
+ rect
.height
- 15, rect
.width
/ 3, 15);
1912 down_btn
= wxRect(up_btn
.GetRight() + 1, up_btn
.GetTop(),
1913 up_btn
.GetWidth(), up_btn
.GetHeight());
1914 dc
.DrawLine(down_btn
.GetLeft(), down_btn
.GetTop(), down_btn
.GetLeft(),
1915 down_btn
.GetBottom());
1917 ext_btn
= wxRect(down_btn
.GetRight() + 1, up_btn
.GetTop(), rect
.width
-
1918 up_btn
.GetWidth() - down_btn
.GetWidth() - 1, up_btn
.GetHeight());
1919 dc
.DrawLine(ext_btn
.GetLeft(), ext_btn
.GetTop(), ext_btn
.GetLeft(),
1920 ext_btn
.GetBottom());
1924 // Divider between items and buttons
1925 dc
.DrawLine(rect
.x
+ rect
.width
- 15, rect
.y
, rect
.x
+ rect
.width
- 15,
1926 rect
.y
+ rect
.height
);
1928 up_btn
= wxRect(rect
.x
+ rect
.width
- 15, rect
.y
, 15, rect
.height
/ 3);
1930 down_btn
= wxRect(up_btn
.GetLeft(), up_btn
.GetBottom() + 1,
1931 up_btn
.GetWidth(), up_btn
.GetHeight());
1932 dc
.DrawLine(down_btn
.GetLeft(), down_btn
.GetTop(), down_btn
.GetRight(),
1935 ext_btn
= wxRect(up_btn
.GetLeft(), down_btn
.GetBottom() + 1, up_btn
.GetWidth(),
1936 rect
.height
- up_btn
.GetHeight() - down_btn
.GetHeight() - 1);
1937 dc
.DrawLine(ext_btn
.GetLeft(), ext_btn
.GetTop(), ext_btn
.GetRight(),
1941 DrawGalleryButton(dc
, up_btn
, wnd
->GetUpButtonState(),
1942 m_gallery_up_bitmap
);
1943 DrawGalleryButton(dc
, down_btn
, wnd
->GetDownButtonState(),
1944 m_gallery_down_bitmap
);
1945 DrawGalleryButton(dc
, ext_btn
, wnd
->GetExtensionButtonState(),
1946 m_gallery_extension_bitmap
);
1949 void wxRibbonMSWArtProvider::DrawGalleryButton(wxDC
& dc
,
1951 wxRibbonGalleryButtonState state
,
1954 wxBitmap btn_bitmap
;
1955 wxBrush btn_top_brush
;
1956 wxColour btn_colour
;
1957 wxColour btn_grad_colour
;
1960 case wxRIBBON_GALLERY_BUTTON_NORMAL
:
1961 btn_top_brush
= m_gallery_button_background_top_brush
;
1962 btn_colour
= m_gallery_button_background_colour
;
1963 btn_grad_colour
= m_gallery_button_background_gradient_colour
;
1964 btn_bitmap
= bitmaps
[0];
1966 case wxRIBBON_GALLERY_BUTTON_HOVERED
:
1967 btn_top_brush
= m_gallery_button_hover_background_top_brush
;
1968 btn_colour
= m_gallery_button_hover_background_colour
;
1969 btn_grad_colour
= m_gallery_button_hover_background_gradient_colour
;
1970 btn_bitmap
= bitmaps
[1];
1972 case wxRIBBON_GALLERY_BUTTON_ACTIVE
:
1973 btn_top_brush
= m_gallery_button_active_background_top_brush
;
1974 btn_colour
= m_gallery_button_active_background_colour
;
1975 btn_grad_colour
= m_gallery_button_active_background_gradient_colour
;
1976 btn_bitmap
= bitmaps
[2];
1978 case wxRIBBON_GALLERY_BUTTON_DISABLED
:
1979 btn_top_brush
= m_gallery_button_disabled_background_top_brush
;
1980 btn_colour
= m_gallery_button_disabled_background_colour
;
1981 btn_grad_colour
= m_gallery_button_disabled_background_gradient_colour
;
1982 btn_bitmap
= bitmaps
[3];
1988 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1999 dc
.SetPen(*wxTRANSPARENT_PEN
);
2000 dc
.SetBrush(btn_top_brush
);
2001 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
/ 2);
2004 lower
.height
= (lower
.height
+ 1) / 2;
2005 lower
.y
+= rect
.height
- lower
.height
;
2006 dc
.GradientFillLinear(lower
, btn_colour
, btn_grad_colour
, wxSOUTH
);
2008 dc
.DrawBitmap(btn_bitmap
, rect
.x
+ rect
.width
/ 2 - 2, lower
.y
- 2, true);
2011 void wxRibbonMSWArtProvider::DrawGalleryItemBackground(
2013 wxRibbonGallery
* wnd
,
2015 wxRibbonGalleryItem
* item
)
2017 if(wnd
->GetHoveredItem() != item
&& wnd
->GetActiveItem() != item
&&
2018 wnd
->GetSelection() != item
)
2021 dc
.SetPen(m_gallery_item_border_pen
);
2022 dc
.DrawLine(rect
.x
+ 1, rect
.y
, rect
.x
+ rect
.width
- 1, rect
.y
);
2023 dc
.DrawLine(rect
.x
, rect
.y
+ 1, rect
.x
, rect
.y
+ rect
.height
- 1);
2024 dc
.DrawLine(rect
.x
+ 1, rect
.y
+ rect
.height
- 1, rect
.x
+ rect
.width
- 1,
2025 rect
.y
+ rect
.height
- 1);
2026 dc
.DrawLine(rect
.x
+ rect
.width
- 1, rect
.y
+ 1, rect
.x
+ rect
.width
- 1,
2027 rect
.y
+ rect
.height
- 1);
2031 wxColour bg_gradient_colour
;
2033 if(wnd
->GetActiveItem() == item
|| wnd
->GetSelection() == item
)
2035 top_brush
= m_gallery_button_active_background_top_brush
;
2036 bg_colour
= m_gallery_button_active_background_colour
;
2037 bg_gradient_colour
= m_gallery_button_active_background_gradient_colour
;
2041 top_brush
= m_gallery_button_hover_background_top_brush
;
2042 bg_colour
= m_gallery_button_hover_background_colour
;
2043 bg_gradient_colour
= m_gallery_button_hover_background_gradient_colour
;
2051 dc
.SetPen(*wxTRANSPARENT_PEN
);
2052 dc
.SetBrush(top_brush
);
2053 dc
.DrawRectangle(upper
.x
, upper
.y
, upper
.width
, upper
.height
);
2055 wxRect
lower(upper
);
2056 lower
.y
+= lower
.height
;
2057 lower
.height
= rect
.height
- 2 - lower
.height
;
2058 dc
.GradientFillLinear(lower
, bg_colour
, bg_gradient_colour
, wxSOUTH
);
2061 void wxRibbonMSWArtProvider::DrawPanelBorder(wxDC
& dc
, const wxRect
& rect
,
2062 wxPen
& primary_colour
,
2063 wxPen
& secondary_colour
)
2065 wxPoint border_points
[9];
2066 border_points
[0] = wxPoint(2, 0);
2067 border_points
[1] = wxPoint(rect
.width
- 3, 0);
2068 border_points
[2] = wxPoint(rect
.width
- 1, 2);
2069 border_points
[3] = wxPoint(rect
.width
- 1, rect
.height
- 3);
2070 border_points
[4] = wxPoint(rect
.width
- 3, rect
.height
- 1);
2071 border_points
[5] = wxPoint(2, rect
.height
- 1);
2072 border_points
[6] = wxPoint(0, rect
.height
- 3);
2073 border_points
[7] = wxPoint(0, 2);
2075 if(primary_colour
.GetColour() == secondary_colour
.GetColour())
2077 border_points
[8] = border_points
[0];
2078 dc
.SetPen(primary_colour
);
2079 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
, rect
.x
, rect
.y
);
2083 dc
.SetPen(primary_colour
);
2084 dc
.DrawLines(3, border_points
, rect
.x
, rect
.y
);
2086 #define SingleLine(start, finish) \
2087 dc.DrawLine(start.x + rect.x, start.y + rect.y, finish.x + rect.x, finish.y + rect.y)
2089 SingleLine(border_points
[0], border_points
[7]);
2090 dc
.SetPen(secondary_colour
);
2091 dc
.DrawLines(3, border_points
+ 4, rect
.x
, rect
.y
);
2092 SingleLine(border_points
[4], border_points
[3]);
2096 border_points
[6] = border_points
[2];
2097 wxRibbonDrawParallelGradientLines(dc
, 2, border_points
+ 6, 0, 1,
2098 border_points
[3].y
- border_points
[2].y
+ 1, rect
.x
, rect
.y
,
2099 primary_colour
.GetColour(), secondary_colour
.GetColour());
2103 void wxRibbonMSWArtProvider::DrawMinimisedPanel(
2109 DrawPartialPageBackground(dc
, wnd
, rect
, false);
2111 wxRect
true_rect(rect
);
2112 RemovePanelPadding(&true_rect
);
2114 if(wnd
->GetExpandedPanel() != NULL
)
2116 wxRect
client_rect(true_rect
);
2118 client_rect
.width
-= 2;
2120 client_rect
.height
= (rect
.y
+ rect
.height
/ 5) - client_rect
.x
;
2121 dc
.GradientFillLinear(client_rect
,
2122 m_panel_active_background_top_colour
,
2123 m_panel_active_background_top_gradient_colour
, wxSOUTH
);
2125 client_rect
.y
+= client_rect
.height
;
2126 client_rect
.height
= (true_rect
.y
+ true_rect
.height
) - client_rect
.y
;
2127 dc
.GradientFillLinear(client_rect
,
2128 m_panel_active_background_colour
,
2129 m_panel_active_background_gradient_colour
, wxSOUTH
);
2131 else if(wnd
->IsHovered())
2133 wxRect
client_rect(true_rect
);
2135 client_rect
.width
-= 2;
2137 client_rect
.height
-= 2;
2138 DrawPartialPageBackground(dc
, wnd
, client_rect
, true);
2142 DrawMinimisedPanelCommon(dc
, wnd
, true_rect
, &preview
);
2144 dc
.SetBrush(m_panel_hover_label_background_brush
);
2145 dc
.SetPen(*wxTRANSPARENT_PEN
);
2146 dc
.DrawRectangle(preview
.x
+ 1, preview
.y
+ preview
.height
- 8,
2147 preview
.width
- 2, 7);
2149 int mid_pos
= rect
.y
+ rect
.height
/ 5 - preview
.y
;
2150 if(mid_pos
< 0 || mid_pos
>= preview
.height
)
2152 wxRect
full_rect(preview
);
2155 full_rect
.width
-= 2;
2156 full_rect
.height
-= 9;
2159 dc
.GradientFillLinear(full_rect
,
2160 m_page_hover_background_colour
,
2161 m_page_hover_background_gradient_colour
, wxSOUTH
);
2165 dc
.GradientFillLinear(full_rect
,
2166 m_page_hover_background_top_colour
,
2167 m_page_hover_background_top_gradient_colour
, wxSOUTH
);
2172 wxRect
top_rect(preview
);
2175 top_rect
.width
-= 2;
2176 top_rect
.height
= mid_pos
;
2177 dc
.GradientFillLinear(top_rect
,
2178 m_page_hover_background_top_colour
,
2179 m_page_hover_background_top_gradient_colour
, wxSOUTH
);
2181 wxRect
btm_rect(top_rect
);
2182 btm_rect
.y
= preview
.y
+ mid_pos
;
2183 btm_rect
.height
= preview
.y
+ preview
.height
- 7 - btm_rect
.y
;
2184 dc
.GradientFillLinear(btm_rect
,
2185 m_page_hover_background_colour
,
2186 m_page_hover_background_gradient_colour
, wxSOUTH
);
2191 dc
.DrawBitmap(bitmap
, preview
.x
+ (preview
.width
- bitmap
.GetWidth()) / 2,
2192 preview
.y
+ (preview
.height
- 7 - bitmap
.GetHeight()) / 2, true);
2195 DrawPanelBorder(dc
, preview
, m_panel_border_pen
, m_panel_border_gradient_pen
);
2197 DrawPanelBorder(dc
, true_rect
, m_panel_minimised_border_pen
,
2198 m_panel_minimised_border_gradient_pen
);
2201 void wxRibbonMSWArtProvider::DrawMinimisedPanelCommon(
2204 const wxRect
& true_rect
,
2205 wxRect
* preview_rect
)
2207 wxRect
preview(0, 0, 32, 32);
2208 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2210 preview
.x
= true_rect
.x
+ 4;
2211 preview
.y
= true_rect
.y
+ (true_rect
.height
- preview
.height
) / 2;
2215 preview
.x
= true_rect
.x
+ (true_rect
.width
- preview
.width
) / 2;
2216 preview
.y
= true_rect
.y
+ 4;
2219 *preview_rect
= preview
;
2221 wxCoord label_width
, label_height
;
2222 dc
.SetFont(m_panel_label_font
);
2223 dc
.GetTextExtent(wnd
->GetLabel(), &label_width
, &label_height
);
2225 int xpos
= true_rect
.x
+ (true_rect
.width
- label_width
+ 1) / 2;
2226 int ypos
= preview
.y
+ preview
.height
+ 5;
2228 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2230 xpos
= preview
.x
+ preview
.width
+ 5;
2231 ypos
= true_rect
.y
+ (true_rect
.height
- label_height
) / 2;
2234 dc
.SetTextForeground(m_panel_minimised_label_colour
);
2235 dc
.DrawText(wnd
->GetLabel(), xpos
, ypos
);
2238 wxPoint arrow_points
[3];
2239 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2241 xpos
+= label_width
;
2242 arrow_points
[0] = wxPoint(xpos
+ 5, ypos
+ label_height
/ 2);
2243 arrow_points
[1] = arrow_points
[0] + wxPoint(-3, 3);
2244 arrow_points
[2] = arrow_points
[0] + wxPoint(-3, -3);
2248 ypos
+= label_height
;
2249 arrow_points
[0] = wxPoint(true_rect
.width
/ 2, ypos
+ 5);
2250 arrow_points
[1] = arrow_points
[0] + wxPoint(-3, -3);
2251 arrow_points
[2] = arrow_points
[0] + wxPoint( 3, -3);
2254 dc
.SetPen(*wxTRANSPARENT_PEN
);
2255 wxBrush
B(m_panel_minimised_label_colour
);
2257 dc
.DrawPolygon(sizeof(arrow_points
)/sizeof(wxPoint
), arrow_points
,
2258 true_rect
.x
, true_rect
.y
);
2261 void wxRibbonMSWArtProvider::DrawButtonBarBackground(
2266 DrawPartialPageBackground(dc
, wnd
, rect
, true);
2269 void wxRibbonMSWArtProvider::DrawPartialPageBackground(
2275 // Assume the window is a child of a ribbon page, and also check for a
2276 // hovered panel somewhere between the window and the page, as it causes
2277 // the background to change.
2278 wxPoint
offset(wnd
->GetPosition());
2279 wxRibbonPage
* page
= NULL
;
2280 wxWindow
* parent
= wnd
->GetParent();
2281 wxRibbonPanel
* panel
= wxDynamicCast(wnd
, wxRibbonPanel
);
2282 bool hovered
= false;
2286 hovered
= allow_hovered
&& panel
->IsHovered();
2287 if(panel
->GetExpandedDummy() != NULL
)
2289 offset
= panel
->GetExpandedDummy()->GetPosition();
2290 parent
= panel
->GetExpandedDummy()->GetParent();
2293 for(; parent
; parent
= parent
->GetParent())
2297 panel
= wxDynamicCast(parent
, wxRibbonPanel
);
2300 hovered
= allow_hovered
&& panel
->IsHovered();
2301 if(panel
->GetExpandedDummy() != NULL
)
2303 parent
= panel
->GetExpandedDummy();
2307 page
= wxDynamicCast(parent
, wxRibbonPage
);
2312 offset
+= parent
->GetPosition();
2316 DrawPartialPageBackground(dc
, wnd
, rect
, page
, offset
, hovered
);
2320 // No page found - fallback to painting with a stock brush
2321 dc
.SetBrush(*wxWHITE_BRUSH
);
2322 dc
.SetPen(*wxTRANSPARENT_PEN
);
2323 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
2326 void wxRibbonMSWArtProvider::DrawButtonBarButton(
2328 wxWindow
* WXUNUSED(wnd
),
2330 wxRibbonButtonKind kind
,
2332 const wxString
& label
,
2333 const wxBitmap
& bitmap_large
,
2334 const wxBitmap
& bitmap_small
)
2336 if(kind
== wxRIBBON_BUTTON_TOGGLE
)
2338 kind
= wxRIBBON_BUTTON_NORMAL
;
2339 if(state
& wxRIBBON_BUTTONBAR_BUTTON_TOGGLED
)
2340 state
^= wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK
;
2343 if(state
& (wxRIBBON_BUTTONBAR_BUTTON_HOVER_MASK
|
2344 wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK
))
2346 if(state
& wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK
)
2347 dc
.SetPen(m_button_bar_active_border_pen
);
2349 dc
.SetPen(m_button_bar_hover_border_pen
);
2351 wxRect
bg_rect(rect
);
2355 bg_rect
.height
-= 2;
2357 wxRect
bg_rect_top(bg_rect
);
2358 bg_rect_top
.height
/= 3;
2359 bg_rect
.y
+= bg_rect_top
.height
;
2360 bg_rect
.height
-= bg_rect_top
.height
;
2362 if(kind
== wxRIBBON_BUTTON_HYBRID
)
2364 switch(state
& wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK
)
2366 case wxRIBBON_BUTTONBAR_BUTTON_LARGE
:
2368 int iYBorder
= rect
.y
+ bitmap_large
.GetHeight() + 4;
2369 wxRect
partial_bg(rect
);
2370 if(state
& wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED
)
2372 partial_bg
.SetBottom(iYBorder
- 1);
2376 partial_bg
.height
-= (iYBorder
- partial_bg
.y
+ 1);
2377 partial_bg
.y
= iYBorder
+ 1;
2379 dc
.DrawLine(rect
.x
, iYBorder
, rect
.x
+ rect
.width
, iYBorder
);
2380 bg_rect
.Intersect(partial_bg
);
2381 bg_rect_top
.Intersect(partial_bg
);
2384 case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM
:
2386 int iArrowWidth
= 9;
2387 if(state
& wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED
)
2389 bg_rect
.width
-= iArrowWidth
;
2390 bg_rect_top
.width
-= iArrowWidth
;
2391 dc
.DrawLine(bg_rect_top
.x
+ bg_rect_top
.width
,
2392 rect
.y
, bg_rect_top
.x
+ bg_rect_top
.width
,
2393 rect
.y
+ rect
.height
);
2398 bg_rect
.x
+= bg_rect
.width
- iArrowWidth
;
2399 bg_rect_top
.x
+= bg_rect_top
.width
- iArrowWidth
;
2400 bg_rect
.width
= iArrowWidth
;
2401 bg_rect_top
.width
= iArrowWidth
;
2402 dc
.DrawLine(bg_rect_top
.x
- 1, rect
.y
,
2403 bg_rect_top
.x
- 1, rect
.y
+ rect
.height
);
2407 case wxRIBBON_BUTTONBAR_BUTTON_SMALL
:
2412 if(state
& wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK
)
2414 dc
.GradientFillLinear(bg_rect_top
,
2415 m_button_bar_active_background_top_colour
,
2416 m_button_bar_active_background_top_gradient_colour
, wxSOUTH
);
2417 dc
.GradientFillLinear(bg_rect
,
2418 m_button_bar_active_background_colour
,
2419 m_button_bar_active_background_gradient_colour
, wxSOUTH
);
2423 dc
.GradientFillLinear(bg_rect_top
,
2424 m_button_bar_hover_background_top_colour
,
2425 m_button_bar_hover_background_top_gradient_colour
, wxSOUTH
);
2426 dc
.GradientFillLinear(bg_rect
,
2427 m_button_bar_hover_background_colour
,
2428 m_button_bar_hover_background_gradient_colour
, wxSOUTH
);
2431 wxPoint border_points
[9];
2432 border_points
[0] = wxPoint(2, 0);
2433 border_points
[1] = wxPoint(rect
.width
- 3, 0);
2434 border_points
[2] = wxPoint(rect
.width
- 1, 2);
2435 border_points
[3] = wxPoint(rect
.width
- 1, rect
.height
- 3);
2436 border_points
[4] = wxPoint(rect
.width
- 3, rect
.height
- 1);
2437 border_points
[5] = wxPoint(2, rect
.height
- 1);
2438 border_points
[6] = wxPoint(0, rect
.height
- 3);
2439 border_points
[7] = wxPoint(0, 2);
2440 border_points
[8] = border_points
[0];
2442 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
,
2446 dc
.SetFont(m_button_bar_label_font
);
2447 dc
.SetTextForeground(m_button_bar_label_colour
);
2448 DrawButtonBarButtonForeground(dc
, rect
, kind
, state
, label
, bitmap_large
,
2452 void wxRibbonMSWArtProvider::DrawButtonBarButtonForeground(
2455 wxRibbonButtonKind kind
,
2457 const wxString
& label
,
2458 const wxBitmap
& bitmap_large
,
2459 const wxBitmap
& bitmap_small
)
2461 switch(state
& wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK
)
2463 case wxRIBBON_BUTTONBAR_BUTTON_LARGE
:
2465 const int padding
= 2;
2466 dc
.DrawBitmap(bitmap_large
,
2467 rect
.x
+ (rect
.width
- bitmap_large
.GetWidth()) / 2,
2468 rect
.y
+ padding
, true);
2469 int ypos
= rect
.y
+ padding
+ bitmap_large
.GetHeight() + padding
;
2470 int arrow_width
= kind
== wxRIBBON_BUTTON_NORMAL
? 0 : 8;
2471 wxCoord label_w
, label_h
;
2472 dc
.GetTextExtent(label
, &label_w
, &label_h
);
2473 if(label_w
+ 2 * padding
<= rect
.width
)
2475 dc
.DrawText(label
, rect
.x
+ (rect
.width
- label_w
) / 2, ypos
);
2476 if(arrow_width
!= 0)
2478 DrawDropdownArrow(dc
, rect
.x
+ rect
.width
/ 2,
2479 ypos
+ (label_h
* 3) / 2,
2480 m_button_bar_label_colour
);
2485 size_t breaki
= label
.Len();
2489 if(wxRibbonCanLabelBreakAtPosition(label
, breaki
))
2491 wxString label_top
= label
.Mid(0, breaki
);
2492 dc
.GetTextExtent(label_top
, &label_w
, &label_h
);
2493 if(label_w
+ 2 * padding
<= rect
.width
)
2495 dc
.DrawText(label_top
,
2496 rect
.x
+ (rect
.width
- label_w
) / 2, ypos
);
2498 wxString label_bottom
= label
.Mid(breaki
+ 1);
2499 dc
.GetTextExtent(label_bottom
, &label_w
, &label_h
);
2500 label_w
+= arrow_width
;
2501 int iX
= rect
.x
+ (rect
.width
- label_w
) / 2;
2502 dc
.DrawText(label_bottom
, iX
, ypos
);
2503 if(arrow_width
!= 0)
2505 DrawDropdownArrow(dc
,
2506 iX
+ 2 +label_w
- arrow_width
,
2507 ypos
+ label_h
/ 2 + 1,
2508 m_button_bar_label_colour
);
2513 } while(breaki
> 0);
2517 case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM
:
2519 int x_cursor
= rect
.x
+ 2;
2520 dc
.DrawBitmap(bitmap_small
, x_cursor
,
2521 rect
.y
+ (rect
.height
- bitmap_small
.GetHeight())/2, true);
2522 x_cursor
+= bitmap_small
.GetWidth() + 2;
2523 wxCoord label_w
, label_h
;
2524 dc
.GetTextExtent(label
, &label_w
, &label_h
);
2525 dc
.DrawText(label
, x_cursor
,
2526 rect
.y
+ (rect
.height
- label_h
) / 2);
2527 x_cursor
+= label_w
+ 3;
2528 if(kind
!= wxRIBBON_BUTTON_NORMAL
)
2530 DrawDropdownArrow(dc
, x_cursor
, rect
.y
+ rect
.height
/ 2,
2531 m_button_bar_label_colour
);
2541 void wxRibbonMSWArtProvider::DrawToolBarBackground(
2546 DrawPartialPageBackground(dc
, wnd
, rect
);
2549 void wxRibbonMSWArtProvider::DrawToolGroupBackground(
2551 wxWindow
* WXUNUSED(wnd
),
2554 dc
.SetPen(m_toolbar_border_pen
);
2556 outline
[0] = wxPoint(2, 0);
2557 outline
[1] = wxPoint(rect
.width
- 3, 0);
2558 outline
[2] = wxPoint(rect
.width
- 1, 2);
2559 outline
[3] = wxPoint(rect
.width
- 1, rect
.height
- 3);
2560 outline
[4] = wxPoint(rect
.width
- 3, rect
.height
- 1);
2561 outline
[5] = wxPoint(2, rect
.height
- 1);
2562 outline
[6] = wxPoint(0, rect
.height
- 3);
2563 outline
[7] = wxPoint(0, 2);
2564 outline
[8] = outline
[0];
2566 dc
.DrawLines(sizeof(outline
)/sizeof(wxPoint
), outline
, rect
.x
, rect
.y
);
2569 void wxRibbonMSWArtProvider::DrawTool(
2571 wxWindow
* WXUNUSED(wnd
),
2573 const wxBitmap
& bitmap
,
2574 wxRibbonButtonKind kind
,
2577 if(kind
== wxRIBBON_BUTTON_TOGGLE
)
2579 if(state
& wxRIBBON_TOOLBAR_TOOL_TOGGLED
)
2580 state
^= wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK
;
2583 wxRect
bg_rect(rect
);
2585 if((state
& wxRIBBON_TOOLBAR_TOOL_LAST
) == 0)
2587 bool is_split_hybrid
= (kind
== wxRIBBON_BUTTON_HYBRID
&& (state
&
2588 (wxRIBBON_TOOLBAR_TOOL_HOVER_MASK
| wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK
)));
2591 wxRect
bg_rect_top(bg_rect
);
2592 bg_rect_top
.height
= (bg_rect_top
.height
* 2) / 5;
2593 wxRect
bg_rect_btm(bg_rect
);
2594 bg_rect_btm
.y
+= bg_rect_top
.height
;
2595 bg_rect_btm
.height
-= bg_rect_top
.height
;
2596 wxColour bg_top_colour
= m_tool_background_top_colour
;
2597 wxColour bg_top_grad_colour
= m_tool_background_top_gradient_colour
;
2598 wxColour bg_colour
= m_tool_background_colour
;
2599 wxColour bg_grad_colour
= m_tool_background_gradient_colour
;
2600 if(state
& wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK
)
2602 bg_top_colour
= m_tool_active_background_top_colour
;
2603 bg_top_grad_colour
= m_tool_active_background_top_gradient_colour
;
2604 bg_colour
= m_tool_active_background_colour
;
2605 bg_grad_colour
= m_tool_active_background_gradient_colour
;
2607 else if(state
& wxRIBBON_TOOLBAR_TOOL_HOVER_MASK
)
2609 bg_top_colour
= m_tool_hover_background_top_colour
;
2610 bg_top_grad_colour
= m_tool_hover_background_top_gradient_colour
;
2611 bg_colour
= m_tool_hover_background_colour
;
2612 bg_grad_colour
= m_tool_hover_background_gradient_colour
;
2614 dc
.GradientFillLinear(bg_rect_top
, bg_top_colour
, bg_top_grad_colour
, wxSOUTH
);
2615 dc
.GradientFillLinear(bg_rect_btm
, bg_colour
, bg_grad_colour
, wxSOUTH
);
2618 wxRect
nonrect(bg_rect
);
2619 if(state
& (wxRIBBON_TOOLBAR_TOOL_DROPDOWN_HOVERED
|
2620 wxRIBBON_TOOLBAR_TOOL_DROPDOWN_ACTIVE
))
2626 nonrect
.x
+= nonrect
.width
- 8;
2629 wxBrush
B(m_tool_hover_background_top_colour
);
2630 dc
.SetPen(*wxTRANSPARENT_PEN
);
2632 dc
.DrawRectangle(nonrect
.x
, nonrect
.y
, nonrect
.width
, nonrect
.height
);
2636 dc
.SetPen(m_toolbar_border_pen
);
2637 if(state
& wxRIBBON_TOOLBAR_TOOL_FIRST
)
2639 dc
.DrawPoint(rect
.x
+ 1, rect
.y
+ 1);
2640 dc
.DrawPoint(rect
.x
+ 1, rect
.y
+ rect
.height
- 2);
2643 dc
.DrawLine(rect
.x
, rect
.y
+ 1, rect
.x
, rect
.y
+ rect
.height
- 1);
2645 if(state
& wxRIBBON_TOOLBAR_TOOL_LAST
)
2647 dc
.DrawPoint(rect
.x
+ rect
.width
- 2, rect
.y
+ 1);
2648 dc
.DrawPoint(rect
.x
+ rect
.width
- 2, rect
.y
+ rect
.height
- 2);
2652 int avail_width
= bg_rect
.GetWidth();
2653 if(kind
& wxRIBBON_BUTTON_DROPDOWN
)
2658 dc
.DrawLine(rect
.x
+ avail_width
+ 1, rect
.y
,
2659 rect
.x
+ avail_width
+ 1, rect
.y
+ rect
.height
);
2661 dc
.DrawBitmap(m_toolbar_drop_bitmap
, bg_rect
.x
+ avail_width
+ 2,
2662 bg_rect
.y
+ (bg_rect
.height
/ 2) - 2, true);
2664 dc
.DrawBitmap(bitmap
, bg_rect
.x
+ (avail_width
- bitmap
.GetWidth()) / 2,
2665 bg_rect
.y
+ (bg_rect
.height
- bitmap
.GetHeight()) / 2, true);
2669 wxRibbonMSWArtProvider::DrawToggleButton(wxDC
& dc
,
2672 wxRibbonDisplayMode mode
)
2675 DrawPartialPageBackground(dc
, wnd
, rect
, false);
2677 dc
.DestroyClippingRegion();
2678 dc
.SetClippingRegion(rect
);
2680 if(wnd
->IsToggleButtonHovered())
2682 dc
.SetPen(m_ribbon_toggle_pen
);
2683 dc
.SetBrush(m_ribbon_toggle_brush
);
2684 dc
.DrawRoundedRectangle(rect
.GetX(), rect
.GetY(), 20, 20, 1.0);
2689 case wxRIBBON_BAR_PINNED
:
2690 dc
.DrawBitmap(m_ribbon_toggle_up_bitmap
[bindex
], rect
.GetX()+7, rect
.GetY()+6, true);
2692 case wxRIBBON_BAR_MINIMIZED
:
2693 dc
.DrawBitmap(m_ribbon_toggle_down_bitmap
[bindex
], rect
.GetX()+7, rect
.GetY()+6, true);
2695 case wxRIBBON_BAR_EXPANDED
:
2696 dc
.DrawBitmap(m_ribbon_toggle_pin_bitmap
[bindex
], rect
.GetX ()+4, rect
.GetY ()+5, true);
2701 void wxRibbonMSWArtProvider::DrawHelpButton(wxDC
& dc
,
2705 DrawPartialPageBackground(dc
, wnd
, rect
, false);
2707 dc
.DestroyClippingRegion();
2708 dc
.SetClippingRegion(rect
);
2710 if ( wnd
->IsHelpButtonHovered() )
2712 dc
.SetPen(m_ribbon_toggle_pen
);
2713 dc
.SetBrush(m_ribbon_toggle_brush
);
2714 dc
.DrawRoundedRectangle(rect
.GetX(), rect
.GetY(), 20, 20, 1.0);
2715 dc
.DrawBitmap(m_ribbon_bar_help_button_bitmap
[1], rect
.GetX ()+4, rect
.GetY()+5, true);
2719 dc
.DrawBitmap(m_ribbon_bar_help_button_bitmap
[0], rect
.GetX ()+4, rect
.GetY()+5, true);
2724 void wxRibbonMSWArtProvider::GetBarTabWidth(
2726 wxWindow
* WXUNUSED(wnd
),
2727 const wxString
& label
,
2728 const wxBitmap
& bitmap
,
2730 int* small_begin_need_separator
,
2731 int* small_must_have_separator
,
2736 if((m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
) && !label
.IsEmpty())
2738 dc
.SetFont(m_tab_label_font
);
2739 width
+= dc
.GetTextExtent(label
).GetWidth();
2740 min
+= wxMin(25, width
); // enough for a few chars
2743 // gap between label and bitmap
2748 if((m_flags
& wxRIBBON_BAR_SHOW_PAGE_ICONS
) && bitmap
.IsOk())
2750 width
+= bitmap
.GetWidth();
2751 min
+= bitmap
.GetWidth();
2756 *ideal
= width
+ 30;
2758 if(small_begin_need_separator
!= NULL
)
2760 *small_begin_need_separator
= width
+ 20;
2762 if(small_must_have_separator
!= NULL
)
2764 *small_must_have_separator
= width
+ 10;
2772 int wxRibbonMSWArtProvider::GetTabCtrlHeight(
2774 wxWindow
* WXUNUSED(wnd
),
2775 const wxRibbonPageTabInfoArray
& pages
)
2777 int text_height
= 0;
2778 int icon_height
= 0;
2780 if(pages
.GetCount() <= 1 && (m_flags
& wxRIBBON_BAR_ALWAYS_SHOW_TABS
) == 0)
2782 // To preserve space, a single tab need not be displayed. We still need
2783 // two pixels of border / padding though.
2787 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
)
2789 dc
.SetFont(m_tab_label_font
);
2790 text_height
= dc
.GetTextExtent(wxT("ABCDEFXj")).GetHeight() + 10;
2792 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_ICONS
)
2794 size_t numpages
= pages
.GetCount();
2795 for(size_t i
= 0; i
< numpages
; ++i
)
2797 const wxRibbonPageTabInfo
& info
= pages
.Item(i
);
2798 if(info
.page
->GetIcon().IsOk())
2800 icon_height
= wxMax(icon_height
, info
.page
->GetIcon().GetHeight() + 4);
2805 return wxMax(text_height
, icon_height
);
2808 wxSize
wxRibbonMSWArtProvider::GetScrollButtonMinimumSize(
2810 wxWindow
* WXUNUSED(wnd
),
2811 long WXUNUSED(style
))
2813 return wxSize(12, 12);
2816 wxSize
wxRibbonMSWArtProvider::GetPanelSize(
2818 const wxRibbonPanel
* wnd
,
2820 wxPoint
* client_offset
)
2822 dc
.SetFont(m_panel_label_font
);
2823 wxSize label_size
= dc
.GetTextExtent(wnd
->GetLabel());
2825 client_size
.IncBy(0, label_size
.GetHeight());
2826 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2827 client_size
.IncBy(4, 8);
2829 client_size
.IncBy(6, 6);
2831 if(client_offset
!= NULL
)
2833 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2834 *client_offset
= wxPoint(2, 3);
2836 *client_offset
= wxPoint(3, 2);
2842 wxSize
wxRibbonMSWArtProvider::GetPanelClientSize(
2844 const wxRibbonPanel
* wnd
,
2846 wxPoint
* client_offset
)
2848 dc
.SetFont(m_panel_label_font
);
2849 wxSize label_size
= dc
.GetTextExtent(wnd
->GetLabel());
2851 size
.DecBy(0, label_size
.GetHeight());
2852 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2857 if(client_offset
!= NULL
)
2859 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2860 *client_offset
= wxPoint(2, 3);
2862 *client_offset
= wxPoint(3, 2);
2864 if (size
.x
< 0) size
.x
= 0;
2865 if (size
.y
< 0) size
.y
= 0;
2870 wxSize
wxRibbonMSWArtProvider::GetGallerySize(
2872 const wxRibbonGallery
* WXUNUSED(wnd
),
2875 client_size
.IncBy( 2, 1); // Left / top padding
2876 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2877 client_size
.IncBy(1, 16); // Right / bottom padding
2879 client_size
.IncBy(16, 1); // Right / bottom padding
2883 wxSize
wxRibbonMSWArtProvider::GetGalleryClientSize(
2885 const wxRibbonGallery
* WXUNUSED(wnd
),
2887 wxPoint
* client_offset
,
2888 wxRect
* scroll_up_button
,
2889 wxRect
* scroll_down_button
,
2890 wxRect
* extension_button
)
2895 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2897 // Flow is vertical - put buttons on bottom
2898 scroll_up
.y
= size
.GetHeight() - 15;
2899 scroll_up
.height
= 15;
2901 scroll_up
.width
= (size
.GetWidth() + 2) / 3;
2902 scroll_down
.y
= scroll_up
.y
;
2903 scroll_down
.height
= scroll_up
.height
;
2904 scroll_down
.x
= scroll_up
.x
+ scroll_up
.width
;
2905 scroll_down
.width
= scroll_up
.width
;
2906 extension
.y
= scroll_down
.y
;
2907 extension
.height
= scroll_down
.height
;
2908 extension
.x
= scroll_down
.x
+ scroll_down
.width
;
2909 extension
.width
= size
.GetWidth() - scroll_up
.width
- scroll_down
.width
;
2915 // Flow is horizontal - put buttons on right
2916 scroll_up
.x
= size
.GetWidth() - 15;
2917 scroll_up
.width
= 15;
2919 scroll_up
.height
= (size
.GetHeight() + 2) / 3;
2920 scroll_down
.x
= scroll_up
.x
;
2921 scroll_down
.width
= scroll_up
.width
;
2922 scroll_down
.y
= scroll_up
.y
+ scroll_up
.height
;
2923 scroll_down
.height
= scroll_up
.height
;
2924 extension
.x
= scroll_down
.x
;
2925 extension
.width
= scroll_down
.width
;
2926 extension
.y
= scroll_down
.y
+ scroll_down
.height
;
2927 extension
.height
= size
.GetHeight() - scroll_up
.height
- scroll_down
.height
;
2932 if(client_offset
!= NULL
)
2933 *client_offset
= wxPoint(2, 1);
2934 if(scroll_up_button
!= NULL
)
2935 *scroll_up_button
= scroll_up
;
2936 if(scroll_down_button
!= NULL
)
2937 *scroll_down_button
= scroll_down
;
2938 if(extension_button
!= NULL
)
2939 *extension_button
= extension
;
2944 wxRect
wxRibbonMSWArtProvider::GetPageBackgroundRedrawArea(
2946 const wxRibbonPage
* WXUNUSED(wnd
),
2947 wxSize page_old_size
,
2948 wxSize page_new_size
)
2950 wxRect new_rect
, old_rect
;
2952 if(page_new_size
.GetWidth() != page_old_size
.GetWidth())
2954 if(page_new_size
.GetHeight() != page_old_size
.GetHeight())
2956 // Width and height both changed - redraw everything
2957 return wxRect(page_new_size
);
2961 // Only width changed - redraw right hand side
2962 const int right_edge_width
= 4;
2964 new_rect
= wxRect(page_new_size
.GetWidth() - right_edge_width
, 0, right_edge_width
, page_new_size
.GetHeight());
2965 old_rect
= wxRect(page_old_size
.GetWidth() - right_edge_width
, 0, right_edge_width
, page_old_size
.GetHeight());
2970 if(page_new_size
.GetHeight() == page_old_size
.GetHeight())
2972 // Nothing changed (should never happen) - redraw nothing
2973 return wxRect(0, 0, 0, 0);
2977 // Height changed - need to redraw everything (as the background
2978 // gradient is done vertically).
2979 return page_new_size
;
2983 new_rect
.Union(old_rect
);
2984 new_rect
.Intersect(wxRect(page_new_size
));
2988 bool wxRibbonMSWArtProvider::GetButtonBarButtonSize(
2991 wxRibbonButtonKind kind
,
2992 wxRibbonButtonBarButtonState size
,
2993 const wxString
& label
,
2994 wxSize bitmap_size_large
,
2995 wxSize bitmap_size_small
,
2996 wxSize
* button_size
,
2997 wxRect
* normal_region
,
2998 wxRect
* dropdown_region
)
3000 const int drop_button_width
= 8;
3002 dc
.SetFont(m_button_bar_label_font
);
3003 switch(size
& wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK
)
3005 case wxRIBBON_BUTTONBAR_BUTTON_SMALL
:
3006 // Small bitmap, no label
3007 *button_size
= bitmap_size_small
+ wxSize(6, 4);
3010 case wxRIBBON_BUTTON_NORMAL
:
3011 case wxRIBBON_BUTTON_TOGGLE
:
3012 *normal_region
= wxRect(*button_size
);
3013 *dropdown_region
= wxRect(0, 0, 0, 0);
3015 case wxRIBBON_BUTTON_DROPDOWN
:
3016 *button_size
+= wxSize(drop_button_width
, 0);
3017 *dropdown_region
= wxRect(*button_size
);
3018 *normal_region
= wxRect(0, 0, 0, 0);
3020 case wxRIBBON_BUTTON_HYBRID
:
3021 *normal_region
= wxRect(*button_size
);
3022 *dropdown_region
= wxRect(button_size
->GetWidth(), 0,
3023 drop_button_width
, button_size
->GetHeight());
3024 *button_size
+= wxSize(drop_button_width
, 0);
3028 case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM
:
3029 // Small bitmap, with label to the right
3031 GetButtonBarButtonSize(dc
, wnd
, kind
, wxRIBBON_BUTTONBAR_BUTTON_SMALL
,
3032 label
, bitmap_size_large
, bitmap_size_small
, button_size
,
3033 normal_region
, dropdown_region
);
3034 int text_size
= dc
.GetTextExtent(label
).GetWidth();
3035 button_size
->SetWidth(button_size
->GetWidth() + text_size
);
3038 case wxRIBBON_BUTTON_DROPDOWN
:
3039 dropdown_region
->SetWidth(dropdown_region
->GetWidth() + text_size
);
3041 case wxRIBBON_BUTTON_HYBRID
:
3042 dropdown_region
->SetX(dropdown_region
->GetX() + text_size
);
3044 case wxRIBBON_BUTTON_NORMAL
:
3045 case wxRIBBON_BUTTON_TOGGLE
:
3046 normal_region
->SetWidth(normal_region
->GetWidth() + text_size
);
3051 case wxRIBBON_BUTTONBAR_BUTTON_LARGE
:
3052 // Large bitmap, with label below (possibly split over 2 lines)
3054 wxSize
icon_size(bitmap_size_large
);
3055 icon_size
+= wxSize(4, 4);
3056 wxCoord label_height
;
3058 dc
.GetTextExtent(label
, &best_width
, &label_height
);
3059 int last_line_extra_width
= 0;
3060 if(kind
!= wxRIBBON_BUTTON_NORMAL
&& kind
!= wxRIBBON_BUTTON_TOGGLE
)
3062 last_line_extra_width
+= 8;
3065 for(i
= 0; i
< label
.Len(); ++i
)
3067 if(wxRibbonCanLabelBreakAtPosition(label
, i
))
3070 dc
.GetTextExtent(label
.Left(i
)).GetWidth(),
3071 dc
.GetTextExtent(label
.Mid(i
+ 1)).GetWidth() + last_line_extra_width
);
3072 if(width
< best_width
)
3078 label_height
*= 2; // Assume two lines even when only one is used
3079 // (to give all buttons a consistent height)
3080 icon_size
.SetWidth(wxMax(icon_size
.GetWidth(), best_width
) + 6);
3081 icon_size
.SetHeight(icon_size
.GetHeight() + label_height
);
3082 *button_size
= icon_size
;
3085 case wxRIBBON_BUTTON_DROPDOWN
:
3086 *dropdown_region
= wxRect(icon_size
);
3088 case wxRIBBON_BUTTON_HYBRID
:
3089 *normal_region
= wxRect(icon_size
);
3090 normal_region
->height
-= 2 + label_height
;
3091 dropdown_region
->x
= 0;
3092 dropdown_region
->y
= normal_region
->height
;
3093 dropdown_region
->width
= icon_size
.GetWidth();
3094 dropdown_region
->height
= icon_size
.GetHeight() - normal_region
->height
;
3096 case wxRIBBON_BUTTON_NORMAL
:
3097 case wxRIBBON_BUTTON_TOGGLE
:
3098 *normal_region
= wxRect(icon_size
);
3107 wxSize
wxRibbonMSWArtProvider::GetMinimisedPanelMinimumSize(
3109 const wxRibbonPanel
* wnd
,
3110 wxSize
* desired_bitmap_size
,
3111 wxDirection
* expanded_panel_direction
)
3113 if(desired_bitmap_size
!= NULL
)
3115 *desired_bitmap_size
= wxSize(16, 16);
3117 if(expanded_panel_direction
!= NULL
)
3119 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
3120 *expanded_panel_direction
= wxEAST
;
3122 *expanded_panel_direction
= wxSOUTH
;
3124 wxSize
base_size(42, 42);
3126 dc
.SetFont(m_panel_label_font
);
3127 wxSize
label_size(dc
.GetTextExtent(wnd
->GetLabel()));
3128 label_size
.IncBy(2, 2); // Allow for differences between this DC and a paint DC
3129 label_size
.IncBy(6, 0); // Padding
3130 label_size
.y
*= 2; // Second line for dropdown button
3132 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
3134 // Label alongside icon
3135 return wxSize(base_size
.x
+ label_size
.x
,
3136 wxMax(base_size
.y
, label_size
.y
));
3140 // Label beneath icon
3141 return wxSize(wxMax(base_size
.x
, label_size
.x
),
3142 base_size
.y
+ label_size
.y
);
3146 wxSize
wxRibbonMSWArtProvider::GetToolSize(
3148 wxWindow
* WXUNUSED(wnd
),
3150 wxRibbonButtonKind kind
,
3151 bool WXUNUSED(is_first
),
3153 wxRect
* dropdown_region
)
3155 wxSize
size(bitmap_size
);
3159 if(kind
& wxRIBBON_BUTTON_DROPDOWN
)
3164 if(kind
== wxRIBBON_BUTTON_DROPDOWN
)
3165 *dropdown_region
= size
;
3167 *dropdown_region
= wxRect(size
.GetWidth() - 8, 0, 8, size
.GetHeight());
3173 *dropdown_region
= wxRect(0, 0, 0, 0);
3179 wxRibbonMSWArtProvider::GetBarToggleButtonArea(const wxRect
& rect
)
3181 wxRect rectOut
= wxRect(rect
.GetWidth()-m_toggle_button_offset
, 2, 20, 20);
3182 if ( (m_toggle_button_offset
==22) && (m_help_button_offset
==22) )
3183 m_help_button_offset
+= 22;
3188 wxRibbonMSWArtProvider::GetRibbonHelpButtonArea(const wxRect
& rect
)
3190 wxRect rectOut
= wxRect(rect
.GetWidth()-m_help_button_offset
, 2, 20, 20);
3191 if ( (m_toggle_button_offset
==22) && (m_help_button_offset
==22) )
3192 m_toggle_button_offset
+= 22;
3196 #endif // wxUSE_RIBBON