1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/ribbon/art_msw.cpp
3 // Purpose: MSW style art provider for ribbon interface
4 // Author: Peter Cawley
7 // Copyright: (C) Peter Cawley
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #include "wx/wxprec.h"
19 #include "wx/ribbon/art.h"
20 #include "wx/ribbon/art_internal.h"
21 #include "wx/ribbon/buttonbar.h"
22 #include "wx/ribbon/gallery.h"
23 #include "wx/ribbon/toolbar.h"
26 #include "wx/dcmemory.h"
30 #include "wx/msw/private.h"
33 static const char* const gallery_up_xpm
[] = {
43 static const char* const gallery_down_xpm
[] = {
53 static const char* const gallery_left_xpm
[] = {
63 static const char* const gallery_right_xpm
[] = {
73 static const char* const gallery_extension_xpm
[] = {
83 static const char* const panel_extension_xpm
[] = {
95 static const char* const panel_toggle_down_xpm
[] = {
109 static const char* const panel_toggle_up_xpm
[] = {
123 static const char* const ribbon_toggle_pin_xpm
[] = {
139 static const char * const ribbon_help_button_xpm
[] = {
254 "1.1.1.1.#./ W ~ } 1.1.1.",
255 "1.1.1.U r c b t h Q 1.1.",
256 "1.1.A 3 $.<.,.&.m w ^ 1.",
257 "1.( 0 z :.%.=.;.) e x ` ",
258 "1.n u v M * B *.R O @ P ",
259 "' i z l - 9 { | > $ # Z ",
260 "_ y l ; & [ X., 1 6 4 D ",
261 "] g 8 o : .C < 7 a s o.",
262 "1.k X % = I S 5 d G K ..",
263 "1.! . j >.-.p F H +.1.",
264 "1.1.L X + Y V 2 J O.1.1.",
265 "1.1.1.E N q f T @.1.1.1."
268 wxRibbonMSWArtProvider::wxRibbonMSWArtProvider(bool set_colour_scheme
)
271 #if defined( __WXMAC__ )
272 m_tab_label_font
= *wxSMALL_FONT
;
274 m_tab_label_font
= *wxNORMAL_FONT
;
276 m_button_bar_label_font
= m_tab_label_font
;
277 m_panel_label_font
= m_tab_label_font
;
279 if(set_colour_scheme
)
282 wxColour(194, 216, 241),
283 wxColour(255, 223, 114),
287 m_cached_tab_separator_visibility
= -10.0; // valid visibilities are in range [0, 1]
288 m_tab_separation_size
= 3;
289 m_page_border_left
= 2;
290 m_page_border_top
= 1;
291 m_page_border_right
= 2;
292 m_page_border_bottom
= 3;
293 m_panel_x_separation_size
= 1;
294 m_panel_y_separation_size
= 1;
295 m_tool_group_separation_size
= 3;
296 m_gallery_bitmap_padding_left_size
= 4;
297 m_gallery_bitmap_padding_right_size
= 4;
298 m_gallery_bitmap_padding_top_size
= 4;
299 m_gallery_bitmap_padding_bottom_size
= 4;
300 m_toggle_button_offset
= 22;
301 m_help_button_offset
= 22;
304 wxRibbonMSWArtProvider::~wxRibbonMSWArtProvider()
308 void wxRibbonMSWArtProvider::GetColourScheme(
311 wxColour
* tertiary
) const
314 *primary
= m_primary_scheme_colour
;
315 if(secondary
!= NULL
)
316 *secondary
= m_secondary_scheme_colour
;
318 *tertiary
= m_tertiary_scheme_colour
;
321 void wxRibbonMSWArtProvider::SetColourScheme(
322 const wxColour
& primary
,
323 const wxColour
& secondary
,
324 const wxColour
& tertiary
)
326 m_primary_scheme_colour
= primary
;
327 m_secondary_scheme_colour
= secondary
;
328 m_tertiary_scheme_colour
= tertiary
;
330 wxRibbonHSLColour
primary_hsl(primary
);
331 wxRibbonHSLColour
secondary_hsl(secondary
);
332 // tertiary not used for anything
334 // Map primary saturation from [0, 1] to [.25, .75]
335 bool primary_is_gray
= false;
336 static const double gray_saturation_threshold
= 0.01;
337 if(primary_hsl
.saturation
<= gray_saturation_threshold
)
338 primary_is_gray
= true;
341 primary_hsl
.saturation
= cos(primary_hsl
.saturation
* M_PI
)
345 // Map primary luminance from [0, 1] to [.23, .83]
346 primary_hsl
.luminance
= cos(primary_hsl
.luminance
* M_PI
) * -0.3 + 0.53;
348 // Map secondary saturation from [0, 1] to [0.16, 0.84]
349 bool secondary_is_gray
= false;
350 if(secondary_hsl
.saturation
<= gray_saturation_threshold
)
351 secondary_is_gray
= true;
354 secondary_hsl
.saturation
= cos(secondary_hsl
.saturation
* M_PI
)
358 // Map secondary luminance from [0, 1] to [0.1, 0.9]
359 secondary_hsl
.luminance
= cos(secondary_hsl
.luminance
* M_PI
) * -0.4 + 0.5;
361 #define LikePrimary(h, s, l) \
362 primary_hsl.ShiftHue(h ## f).Saturated(primary_is_gray ? 0 : s ## f) \
363 .Lighter(l ## f).ToRGB()
364 #define LikeSecondary(h, s, l) \
365 secondary_hsl.ShiftHue(h ## f).Saturated(secondary_is_gray ? 0 : s ## f) \
366 .Lighter(l ## f).ToRGB()
368 m_page_border_pen
= LikePrimary(1.4, 0.00, -0.08);
370 m_page_background_top_colour
= LikePrimary(-0.1, -0.03, 0.12);
371 m_page_hover_background_top_colour
= LikePrimary(-2.8, 0.27, 0.17);
372 m_page_background_top_gradient_colour
= LikePrimary(0.1, -0.10, 0.08);
373 m_page_hover_background_top_gradient_colour
= LikePrimary(3.2, 0.16, 0.13);
374 m_page_background_colour
= LikePrimary(0.4, -0.09, 0.05);
375 m_page_hover_background_colour
= LikePrimary(0.1, 0.19, 0.10);
376 m_page_background_gradient_colour
= LikePrimary(-3.2, 0.27, 0.10);
377 m_page_hover_background_gradient_colour
= LikePrimary(1.8, 0.01, 0.15);
379 m_tab_active_background_colour
= LikePrimary(-0.1, -0.31, 0.16);
380 m_tab_active_background_gradient_colour
= LikePrimary(-0.1, -0.03, 0.12);
381 m_tab_separator_colour
= LikePrimary(0.9, 0.24, 0.05);
382 m_tab_ctrl_background_brush
= LikePrimary(1.0, 0.39, 0.07);
383 m_tab_hover_background_colour
= LikePrimary(1.3, 0.15, 0.10);
384 m_tab_hover_background_top_colour
= LikePrimary(1.4, 0.36, 0.08);
385 m_tab_border_pen
= LikePrimary(1.4, 0.03, -0.05);
386 m_tab_separator_gradient_colour
= LikePrimary(1.7, -0.15, -0.18);
387 m_tab_hover_background_top_gradient_colour
= LikePrimary(1.8, 0.34, 0.13);
388 m_tab_label_colour
= LikePrimary(4.3, 0.13, -0.49);
389 m_tab_hover_background_gradient_colour
= LikeSecondary(-1.5, -0.34, 0.01);
391 m_panel_minimised_border_gradient_pen
= LikePrimary(-6.9, -0.17, -0.09);
392 m_panel_minimised_border_pen
= LikePrimary(-5.3, -0.24, -0.06);
393 m_panel_border_gradient_pen
= LikePrimary(-5.2, -0.15, -0.06);
394 m_panel_border_pen
= LikePrimary(-2.8, -0.32, 0.02);
395 m_panel_label_background_brush
= LikePrimary(-1.5, 0.03, 0.05);
396 m_panel_active_background_gradient_colour
= LikePrimary(0.5, 0.34, 0.05);
397 m_panel_hover_label_background_brush
= LikePrimary(1.0, 0.30, 0.09);
398 m_panel_active_background_top_gradient_colour
= LikePrimary(1.4, -0.17, -0.13);
399 m_panel_active_background_colour
= LikePrimary(1.6, -0.18, -0.18);
400 m_panel_active_background_top_colour
= LikePrimary(1.7, -0.20, -0.03);
401 m_panel_label_colour
= LikePrimary(2.8, -0.14, -0.35);
402 m_panel_hover_label_colour
= m_panel_label_colour
;
403 m_panel_minimised_label_colour
= m_tab_label_colour
;
404 m_panel_hover_button_background_brush
= LikeSecondary(-0.9, 0.16, -0.07);
405 m_panel_hover_button_border_pen
= LikeSecondary(-3.9, -0.16, -0.14);
406 SetColour(wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR
, LikePrimary(1.4, -0.21, -0.23));
407 SetColour(wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR
, LikePrimary(1.5, -0.24, -0.29));
409 m_ribbon_toggle_brush
= LikeSecondary(-0.9, 0.16, -0.07);
410 m_ribbon_toggle_pen
= LikeSecondary(-3.9, -0.16, -0.14);
411 SetColour(wxRIBBON_ART_PAGE_TOGGLE_FACE_COLOUR
, LikePrimary(1.7, -0.20, -0.15));
412 SetColour(wxRIBBON_ART_PAGE_TOGGLE_HOVER_FACE_COLOUR
, LikePrimary(1.8, -0.23, -0.21));
414 m_gallery_button_disabled_background_colour
= LikePrimary(-2.8, -0.46, 0.09);
415 m_gallery_button_disabled_background_top_brush
= LikePrimary(-2.8, -0.36, 0.15);
416 m_gallery_hover_background_brush
= LikePrimary(-0.8, 0.05, 0.15);
417 m_gallery_border_pen
= LikePrimary(0.7, -0.02, 0.03);
418 m_gallery_button_background_top_brush
= LikePrimary(0.8, 0.34, 0.13);
419 m_gallery_button_background_colour
= LikePrimary(1.3, 0.10, 0.08);
420 // SetColour used so that the relevant bitmaps are generated
421 SetColour(wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR
, LikePrimary(1.4, -0.21, -0.23));
422 SetColour(wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR
, LikePrimary(1.5, -0.24, -0.29));
423 SetColour(wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR
, LikePrimary(1.5, -0.24, -0.29));
424 SetColour(wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR
, LikePrimary(0.0, -1.0, 0.0));
425 m_gallery_button_disabled_background_gradient_colour
= LikePrimary(1.5, -0.43, 0.12);
426 m_gallery_button_background_gradient_colour
= LikePrimary(1.7, 0.11, 0.09);
427 m_gallery_item_border_pen
= LikeSecondary(-3.9, -0.16, -0.14);
428 m_gallery_button_hover_background_colour
= LikeSecondary(-0.9, 0.16, -0.07);
429 m_gallery_button_hover_background_gradient_colour
= LikeSecondary(0.1, 0.12, 0.03);
430 m_gallery_button_hover_background_top_brush
= LikeSecondary(4.3, 0.16, 0.17);
432 m_gallery_button_active_background_colour
= LikeSecondary(-9.9, 0.03, -0.22);
433 m_gallery_button_active_background_gradient_colour
= LikeSecondary(-9.5, 0.14, -0.11);
434 m_gallery_button_active_background_top_brush
= LikeSecondary(-9.0, 0.15, -0.08);
436 m_button_bar_label_colour
= m_tab_label_colour
;
437 m_button_bar_label_disabled_colour
= m_tab_label_colour
;
439 m_button_bar_hover_border_pen
= LikeSecondary(-6.2, -0.47, -0.14);
440 m_button_bar_hover_background_gradient_colour
= LikeSecondary(-0.6, 0.16, 0.04);
441 m_button_bar_hover_background_colour
= LikeSecondary(-0.2, 0.16, -0.10);
442 m_button_bar_hover_background_top_gradient_colour
= LikeSecondary(0.2, 0.16, 0.03);
443 m_button_bar_hover_background_top_colour
= LikeSecondary(8.8, 0.16, 0.17);
444 m_button_bar_active_border_pen
= LikeSecondary(-6.2, -0.47, -0.25);
445 m_button_bar_active_background_top_colour
= LikeSecondary(-8.4, 0.08, 0.06);
446 m_button_bar_active_background_top_gradient_colour
= LikeSecondary(-9.7, 0.13, -0.07);
447 m_button_bar_active_background_colour
= LikeSecondary(-9.9, 0.14, -0.14);
448 m_button_bar_active_background_gradient_colour
= LikeSecondary(-8.7, 0.17, -0.03);
450 m_toolbar_border_pen
= LikePrimary(1.4, -0.21, -0.16);
451 SetColour(wxRIBBON_ART_TOOLBAR_FACE_COLOUR
, LikePrimary(1.4, -0.17, -0.22));
452 m_tool_background_top_colour
= LikePrimary(-1.9, -0.07, 0.06);
453 m_tool_background_top_gradient_colour
= LikePrimary(1.4, 0.12, 0.08);
454 m_tool_background_colour
= LikePrimary(1.4, -0.09, 0.03);
455 m_tool_background_gradient_colour
= LikePrimary(1.9, 0.11, 0.09);
456 m_tool_hover_background_top_colour
= LikeSecondary(3.4, 0.11, 0.16);
457 m_tool_hover_background_top_gradient_colour
= LikeSecondary(-1.4, 0.04, 0.08);
458 m_tool_hover_background_colour
= LikeSecondary(-1.8, 0.16, -0.12);
459 m_tool_hover_background_gradient_colour
= LikeSecondary(-2.6, 0.16, 0.05);
460 m_tool_active_background_top_colour
= LikeSecondary(-9.9, -0.12, -0.09);
461 m_tool_active_background_top_gradient_colour
= LikeSecondary(-8.5, 0.16, -0.12);
462 m_tool_active_background_colour
= LikeSecondary(-7.9, 0.16, -0.20);
463 m_tool_active_background_gradient_colour
= LikeSecondary(-6.6, 0.16, -0.10);
468 // Invalidate cached tab separator
469 m_cached_tab_separator_visibility
= -1.0;
472 wxRibbonArtProvider
* wxRibbonMSWArtProvider::Clone() const
474 wxRibbonMSWArtProvider
*copy
= new wxRibbonMSWArtProvider
;
479 void wxRibbonMSWArtProvider::CloneTo(wxRibbonMSWArtProvider
* copy
) const
482 for(i
= 0; i
< 4; ++i
)
484 copy
->m_gallery_up_bitmap
[i
] = m_gallery_up_bitmap
[i
];
485 copy
->m_gallery_down_bitmap
[i
] = m_gallery_down_bitmap
[i
];
486 copy
->m_gallery_extension_bitmap
[i
] = m_gallery_extension_bitmap
[i
];
488 for(i
= 0; i
< 2; ++i
)
490 copy
->m_panel_extension_bitmap
[i
] = m_panel_extension_bitmap
[i
];
491 copy
->m_ribbon_toggle_up_bitmap
[i
] = m_ribbon_toggle_up_bitmap
[i
];
492 copy
->m_ribbon_toggle_down_bitmap
[i
] = m_ribbon_toggle_down_bitmap
[i
];
493 copy
->m_ribbon_toggle_pin_bitmap
[i
] = m_ribbon_toggle_pin_bitmap
[i
];
494 copy
->m_ribbon_bar_help_button_bitmap
[i
] = m_ribbon_bar_help_button_bitmap
[i
];
496 copy
->m_toolbar_drop_bitmap
= m_toolbar_drop_bitmap
;
498 copy
->m_primary_scheme_colour
= m_primary_scheme_colour
;
499 copy
->m_secondary_scheme_colour
= m_secondary_scheme_colour
;
500 copy
->m_tertiary_scheme_colour
= m_tertiary_scheme_colour
;
502 copy
->m_page_toggle_face_colour
= m_page_toggle_face_colour
;
503 copy
->m_page_toggle_hover_face_colour
= m_page_toggle_hover_face_colour
;
505 copy
->m_button_bar_label_colour
= m_button_bar_label_colour
;
506 copy
->m_button_bar_label_disabled_colour
= m_button_bar_label_disabled_colour
;
507 copy
->m_tab_label_colour
= m_tab_label_colour
;
508 copy
->m_tab_separator_colour
= m_tab_separator_colour
;
509 copy
->m_tab_separator_gradient_colour
= m_tab_separator_gradient_colour
;
510 copy
->m_tab_active_background_colour
= m_tab_hover_background_colour
;
511 copy
->m_tab_active_background_gradient_colour
= m_tab_hover_background_gradient_colour
;
512 copy
->m_tab_hover_background_colour
= m_tab_hover_background_colour
;
513 copy
->m_tab_hover_background_gradient_colour
= m_tab_hover_background_gradient_colour
;
514 copy
->m_tab_hover_background_top_colour
= m_tab_hover_background_top_colour
;
515 copy
->m_tab_hover_background_top_gradient_colour
= m_tab_hover_background_top_gradient_colour
;
516 copy
->m_panel_label_colour
= m_panel_label_colour
;
517 copy
->m_panel_hover_label_colour
= m_panel_hover_label_colour
;
518 copy
->m_panel_minimised_label_colour
= m_panel_minimised_label_colour
;
519 copy
->m_panel_button_face_colour
= m_panel_button_face_colour
;
520 copy
->m_panel_button_hover_face_colour
= m_panel_button_hover_face_colour
;
521 copy
->m_panel_active_background_colour
= m_panel_active_background_colour
;
522 copy
->m_panel_active_background_gradient_colour
= m_panel_active_background_gradient_colour
;
523 copy
->m_panel_active_background_top_colour
= m_panel_active_background_top_colour
;
524 copy
->m_panel_active_background_top_gradient_colour
= m_panel_active_background_top_gradient_colour
;
525 copy
->m_page_background_colour
= m_page_background_colour
;
526 copy
->m_page_background_gradient_colour
= m_page_background_gradient_colour
;
527 copy
->m_page_background_top_colour
= m_page_background_top_colour
;
528 copy
->m_page_background_top_gradient_colour
= m_page_background_top_gradient_colour
;
529 copy
->m_page_hover_background_colour
= m_page_hover_background_colour
;
530 copy
->m_page_hover_background_gradient_colour
= m_page_hover_background_gradient_colour
;
531 copy
->m_page_hover_background_top_colour
= m_page_hover_background_top_colour
;
532 copy
->m_page_hover_background_top_gradient_colour
= m_page_hover_background_top_gradient_colour
;
533 copy
->m_button_bar_hover_background_colour
= m_button_bar_hover_background_colour
;
534 copy
->m_button_bar_hover_background_gradient_colour
= m_button_bar_hover_background_gradient_colour
;
535 copy
->m_button_bar_hover_background_top_colour
= m_button_bar_hover_background_top_colour
;
536 copy
->m_button_bar_hover_background_top_gradient_colour
= m_button_bar_hover_background_top_gradient_colour
;
537 copy
->m_button_bar_active_background_colour
= m_button_bar_active_background_colour
;
538 copy
->m_button_bar_active_background_gradient_colour
= m_button_bar_active_background_gradient_colour
;
539 copy
->m_button_bar_active_background_top_colour
= m_button_bar_active_background_top_colour
;
540 copy
->m_button_bar_active_background_top_gradient_colour
= m_button_bar_active_background_top_gradient_colour
;
541 copy
->m_gallery_button_background_colour
= m_gallery_button_background_colour
;
542 copy
->m_gallery_button_background_gradient_colour
= m_gallery_button_background_gradient_colour
;
543 copy
->m_gallery_button_hover_background_colour
= m_gallery_button_hover_background_colour
;
544 copy
->m_gallery_button_hover_background_gradient_colour
= m_gallery_button_hover_background_gradient_colour
;
545 copy
->m_gallery_button_active_background_colour
= m_gallery_button_active_background_colour
;
546 copy
->m_gallery_button_active_background_gradient_colour
= m_gallery_button_active_background_gradient_colour
;
547 copy
->m_gallery_button_disabled_background_colour
= m_gallery_button_disabled_background_colour
;
548 copy
->m_gallery_button_disabled_background_gradient_colour
= m_gallery_button_disabled_background_gradient_colour
;
549 copy
->m_gallery_button_face_colour
= m_gallery_button_face_colour
;
550 copy
->m_gallery_button_hover_face_colour
= m_gallery_button_hover_face_colour
;
551 copy
->m_gallery_button_active_face_colour
= m_gallery_button_active_face_colour
;
552 copy
->m_gallery_button_disabled_face_colour
= m_gallery_button_disabled_face_colour
;
554 copy
->m_tab_ctrl_background_brush
= m_tab_ctrl_background_brush
;
555 copy
->m_panel_label_background_brush
= m_panel_label_background_brush
;
556 copy
->m_panel_hover_label_background_brush
= m_panel_hover_label_background_brush
;
557 copy
->m_panel_hover_button_background_brush
= m_panel_hover_button_background_brush
;
558 copy
->m_gallery_hover_background_brush
= m_gallery_hover_background_brush
;
559 copy
->m_gallery_button_background_top_brush
= m_gallery_button_background_top_brush
;
560 copy
->m_gallery_button_hover_background_top_brush
= m_gallery_button_hover_background_top_brush
;
561 copy
->m_gallery_button_active_background_top_brush
= m_gallery_button_active_background_top_brush
;
562 copy
->m_gallery_button_disabled_background_top_brush
= m_gallery_button_disabled_background_top_brush
;
563 copy
->m_ribbon_toggle_brush
= m_ribbon_toggle_brush
;
565 copy
->m_tab_label_font
= m_tab_label_font
;
566 copy
->m_button_bar_label_font
= m_button_bar_label_font
;
567 copy
->m_panel_label_font
= m_panel_label_font
;
569 copy
->m_page_border_pen
= m_page_border_pen
;
570 copy
->m_panel_border_pen
= m_panel_border_pen
;
571 copy
->m_panel_border_gradient_pen
= m_panel_border_gradient_pen
;
572 copy
->m_panel_minimised_border_pen
= m_panel_minimised_border_pen
;
573 copy
->m_panel_minimised_border_gradient_pen
= m_panel_minimised_border_gradient_pen
;
574 copy
->m_panel_hover_button_border_pen
= m_panel_hover_button_border_pen
;
575 copy
->m_tab_border_pen
= m_tab_border_pen
;
576 copy
->m_gallery_border_pen
= m_gallery_border_pen
;
577 copy
->m_button_bar_hover_border_pen
= m_button_bar_hover_border_pen
;
578 copy
->m_button_bar_active_border_pen
= m_button_bar_active_border_pen
;
579 copy
->m_gallery_item_border_pen
= m_gallery_item_border_pen
;
580 copy
->m_toolbar_border_pen
= m_toolbar_border_pen
;
581 copy
->m_ribbon_toggle_pen
= m_ribbon_toggle_pen
;
583 copy
->m_flags
= m_flags
;
584 copy
->m_tab_separation_size
= m_tab_separation_size
;
585 copy
->m_page_border_left
= m_page_border_left
;
586 copy
->m_page_border_top
= m_page_border_top
;
587 copy
->m_page_border_right
= m_page_border_right
;
588 copy
->m_page_border_bottom
= m_page_border_bottom
;
589 copy
->m_panel_x_separation_size
= m_panel_x_separation_size
;
590 copy
->m_panel_y_separation_size
= m_panel_y_separation_size
;
591 copy
->m_gallery_bitmap_padding_left_size
= m_gallery_bitmap_padding_left_size
;
592 copy
->m_gallery_bitmap_padding_right_size
= m_gallery_bitmap_padding_right_size
;
593 copy
->m_gallery_bitmap_padding_top_size
= m_gallery_bitmap_padding_top_size
;
594 copy
->m_gallery_bitmap_padding_bottom_size
= m_gallery_bitmap_padding_bottom_size
;
597 long wxRibbonMSWArtProvider::GetFlags() const
602 void wxRibbonMSWArtProvider::SetFlags(long flags
)
604 if((flags
^ m_flags
) & wxRIBBON_BAR_FLOW_VERTICAL
)
606 if(flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
608 m_page_border_left
++;
609 m_page_border_right
++;
611 m_page_border_bottom
--;
615 m_page_border_left
--;
616 m_page_border_right
--;
618 m_page_border_bottom
++;
623 // Need to reload some bitmaps when flags change
624 #define Reload(setting) SetColour(setting, GetColour(setting))
625 Reload(wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR
);
626 Reload(wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR
);
627 Reload(wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR
);
628 Reload(wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR
);
629 Reload(wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR
);
630 Reload(wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR
);
634 int wxRibbonMSWArtProvider::GetMetric(int id
) const
638 case wxRIBBON_ART_TAB_SEPARATION_SIZE
:
639 return m_tab_separation_size
;
640 case wxRIBBON_ART_PAGE_BORDER_LEFT_SIZE
:
641 return m_page_border_left
;
642 case wxRIBBON_ART_PAGE_BORDER_TOP_SIZE
:
643 return m_page_border_top
;
644 case wxRIBBON_ART_PAGE_BORDER_RIGHT_SIZE
:
645 return m_page_border_right
;
646 case wxRIBBON_ART_PAGE_BORDER_BOTTOM_SIZE
:
647 return m_page_border_bottom
;
648 case wxRIBBON_ART_PANEL_X_SEPARATION_SIZE
:
649 return m_panel_x_separation_size
;
650 case wxRIBBON_ART_PANEL_Y_SEPARATION_SIZE
:
651 return m_panel_y_separation_size
;
652 case wxRIBBON_ART_TOOL_GROUP_SEPARATION_SIZE
:
653 return m_tool_group_separation_size
;
654 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_LEFT_SIZE
:
655 return m_gallery_bitmap_padding_left_size
;
656 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_RIGHT_SIZE
:
657 return m_gallery_bitmap_padding_right_size
;
658 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_TOP_SIZE
:
659 return m_gallery_bitmap_padding_top_size
;
660 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_BOTTOM_SIZE
:
661 return m_gallery_bitmap_padding_bottom_size
;
663 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
670 void wxRibbonMSWArtProvider::SetMetric(int id
, int new_val
)
674 case wxRIBBON_ART_TAB_SEPARATION_SIZE
:
675 m_tab_separation_size
= new_val
;
677 case wxRIBBON_ART_PAGE_BORDER_LEFT_SIZE
:
678 m_page_border_left
= new_val
;
680 case wxRIBBON_ART_PAGE_BORDER_TOP_SIZE
:
681 m_page_border_top
= new_val
;
683 case wxRIBBON_ART_PAGE_BORDER_RIGHT_SIZE
:
684 m_page_border_right
= new_val
;
686 case wxRIBBON_ART_PAGE_BORDER_BOTTOM_SIZE
:
687 m_page_border_bottom
= new_val
;
689 case wxRIBBON_ART_PANEL_X_SEPARATION_SIZE
:
690 m_panel_x_separation_size
= new_val
;
692 case wxRIBBON_ART_PANEL_Y_SEPARATION_SIZE
:
693 m_panel_y_separation_size
= new_val
;
695 case wxRIBBON_ART_TOOL_GROUP_SEPARATION_SIZE
:
696 m_tool_group_separation_size
= new_val
;
698 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_LEFT_SIZE
:
699 m_gallery_bitmap_padding_left_size
= new_val
;
701 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_RIGHT_SIZE
:
702 m_gallery_bitmap_padding_right_size
= new_val
;
704 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_TOP_SIZE
:
705 m_gallery_bitmap_padding_top_size
= new_val
;
707 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_BOTTOM_SIZE
:
708 m_gallery_bitmap_padding_bottom_size
= new_val
;
711 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
716 void wxRibbonMSWArtProvider::SetFont(int id
, const wxFont
& font
)
720 case wxRIBBON_ART_TAB_LABEL_FONT
:
721 m_tab_label_font
= font
;
723 case wxRIBBON_ART_BUTTON_BAR_LABEL_FONT
:
724 m_button_bar_label_font
= font
;
726 case wxRIBBON_ART_PANEL_LABEL_FONT
:
727 m_panel_label_font
= font
;
730 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
735 wxFont
wxRibbonMSWArtProvider::GetFont(int id
) const
739 case wxRIBBON_ART_TAB_LABEL_FONT
:
740 return m_tab_label_font
;
741 case wxRIBBON_ART_BUTTON_BAR_LABEL_FONT
:
742 return m_button_bar_label_font
;
743 case wxRIBBON_ART_PANEL_LABEL_FONT
:
744 return m_panel_label_font
;
746 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
753 wxColour
wxRibbonMSWArtProvider::GetColour(int id
) const
757 case wxRIBBON_ART_BUTTON_BAR_LABEL_COLOUR
:
758 return m_button_bar_label_colour
;
759 case wxRIBBON_ART_BUTTON_BAR_LABEL_DISABLED_COLOUR
:
760 return m_button_bar_label_disabled_colour
;
761 case wxRIBBON_ART_BUTTON_BAR_HOVER_BORDER_COLOUR
:
762 return m_button_bar_hover_border_pen
.GetColour();
763 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_COLOUR
:
764 return m_button_bar_hover_background_top_colour
;
765 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
766 return m_button_bar_hover_background_top_gradient_colour
;
767 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_COLOUR
:
768 return m_button_bar_hover_background_colour
;
769 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_GRADIENT_COLOUR
:
770 return m_button_bar_hover_background_gradient_colour
;
771 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BORDER_COLOUR
:
772 return m_button_bar_active_border_pen
.GetColour();
773 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_COLOUR
:
774 return m_button_bar_active_background_top_colour
;
775 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
776 return m_button_bar_active_background_top_gradient_colour
;
777 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_COLOUR
:
778 return m_button_bar_active_background_colour
;
779 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
780 return m_button_bar_active_background_gradient_colour
;
781 case wxRIBBON_ART_GALLERY_BORDER_COLOUR
:
782 return m_gallery_border_pen
.GetColour();
783 case wxRIBBON_ART_GALLERY_HOVER_BACKGROUND_COLOUR
:
784 return m_gallery_hover_background_brush
.GetColour();
785 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_COLOUR
:
786 return m_gallery_button_background_colour
;
787 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_GRADIENT_COLOUR
:
788 return m_gallery_button_background_gradient_colour
;
789 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_TOP_COLOUR
:
790 return m_gallery_button_background_top_brush
.GetColour();
791 case wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR
:
792 return m_gallery_button_face_colour
;
793 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_COLOUR
:
794 return m_gallery_button_hover_background_colour
;
795 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_GRADIENT_COLOUR
:
796 return m_gallery_button_hover_background_gradient_colour
;
797 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_TOP_COLOUR
:
798 return m_gallery_button_hover_background_top_brush
.GetColour();
799 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR
:
800 return m_gallery_button_face_colour
;
801 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_COLOUR
:
802 return m_gallery_button_active_background_colour
;
803 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
804 return m_gallery_button_active_background_gradient_colour
;
805 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_TOP_COLOUR
:
806 return m_gallery_button_background_top_brush
.GetColour();
807 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR
:
808 return m_gallery_button_active_face_colour
;
809 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_COLOUR
:
810 return m_gallery_button_disabled_background_colour
;
811 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_GRADIENT_COLOUR
:
812 return m_gallery_button_disabled_background_gradient_colour
;
813 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_TOP_COLOUR
:
814 return m_gallery_button_disabled_background_top_brush
.GetColour();
815 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR
:
816 return m_gallery_button_disabled_face_colour
;
817 case wxRIBBON_ART_GALLERY_ITEM_BORDER_COLOUR
:
818 return m_gallery_item_border_pen
.GetColour();
819 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_COLOUR
:
820 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_GRADIENT_COLOUR
:
821 return m_tab_ctrl_background_brush
.GetColour();
822 case wxRIBBON_ART_TAB_LABEL_COLOUR
:
823 return m_tab_label_colour
;
824 case wxRIBBON_ART_TAB_SEPARATOR_COLOUR
:
825 return m_tab_separator_colour
;
826 case wxRIBBON_ART_TAB_SEPARATOR_GRADIENT_COLOUR
:
827 return m_tab_separator_gradient_colour
;
828 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_COLOUR
:
829 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
830 return wxColour(0, 0, 0);
831 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_COLOUR
:
832 return m_tab_active_background_colour
;
833 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
834 return m_tab_active_background_gradient_colour
;
835 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_COLOUR
:
836 return m_tab_hover_background_top_colour
;
837 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
838 return m_tab_hover_background_top_gradient_colour
;
839 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_COLOUR
:
840 return m_tab_hover_background_colour
;
841 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_GRADIENT_COLOUR
:
842 return m_tab_hover_background_gradient_colour
;
843 case wxRIBBON_ART_TAB_BORDER_COLOUR
:
844 return m_tab_border_pen
.GetColour();
845 case wxRIBBON_ART_PANEL_BORDER_COLOUR
:
846 return m_panel_border_pen
.GetColour();
847 case wxRIBBON_ART_PANEL_BORDER_GRADIENT_COLOUR
:
848 return m_panel_border_gradient_pen
.GetColour();
849 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_COLOUR
:
850 return m_panel_minimised_border_pen
.GetColour();
851 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_GRADIENT_COLOUR
:
852 return m_panel_minimised_border_gradient_pen
.GetColour();
853 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_COLOUR
:
854 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_GRADIENT_COLOUR
:
855 return m_panel_label_background_brush
.GetColour();
856 case wxRIBBON_ART_PANEL_LABEL_COLOUR
:
857 return m_panel_label_colour
;
858 case wxRIBBON_ART_PANEL_MINIMISED_LABEL_COLOUR
:
859 return m_panel_minimised_label_colour
;
860 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_COLOUR
:
861 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_GRADIENT_COLOUR
:
862 return m_panel_hover_label_background_brush
.GetColour();
863 case wxRIBBON_ART_PANEL_HOVER_LABEL_COLOUR
:
864 return m_panel_hover_label_colour
;
865 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_COLOUR
:
866 return m_panel_active_background_top_colour
;
867 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
868 return m_panel_active_background_top_gradient_colour
;
869 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_COLOUR
:
870 return m_panel_active_background_colour
;
871 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
872 return m_panel_active_background_gradient_colour
;
873 case wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR
:
874 return m_panel_button_face_colour
;
875 case wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR
:
876 return m_panel_button_hover_face_colour
;
877 case wxRIBBON_ART_PAGE_BORDER_COLOUR
:
878 return m_page_border_pen
.GetColour();
879 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_COLOUR
:
880 return m_page_background_top_colour
;
881 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_GRADIENT_COLOUR
:
882 return m_page_background_top_gradient_colour
;
883 case wxRIBBON_ART_PAGE_BACKGROUND_COLOUR
:
884 return m_page_background_colour
;
885 case wxRIBBON_ART_PAGE_BACKGROUND_GRADIENT_COLOUR
:
886 return m_page_background_gradient_colour
;
887 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_COLOUR
:
888 return m_page_hover_background_top_colour
;
889 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
890 return m_page_hover_background_top_gradient_colour
;
891 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_COLOUR
:
892 return m_page_hover_background_colour
;
893 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_GRADIENT_COLOUR
:
894 return m_page_hover_background_gradient_colour
;
895 case wxRIBBON_ART_TOOLBAR_BORDER_COLOUR
:
896 case wxRIBBON_ART_TOOLBAR_HOVER_BORDER_COLOUR
:
897 return m_toolbar_border_pen
.GetColour();
898 case wxRIBBON_ART_TOOLBAR_FACE_COLOUR
:
899 return m_tool_face_colour
;
900 case wxRIBBON_ART_PAGE_TOGGLE_FACE_COLOUR
:
901 return m_page_toggle_face_colour
;
902 case wxRIBBON_ART_PAGE_TOGGLE_HOVER_FACE_COLOUR
:
903 return m_page_toggle_hover_face_colour
;
905 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
912 void wxRibbonMSWArtProvider::SetColour(int id
, const wxColor
& colour
)
916 case wxRIBBON_ART_BUTTON_BAR_LABEL_COLOUR
:
917 m_button_bar_label_colour
= colour
;
919 case wxRIBBON_ART_BUTTON_BAR_LABEL_DISABLED_COLOUR
:
920 m_button_bar_label_disabled_colour
= colour
;
922 case wxRIBBON_ART_BUTTON_BAR_HOVER_BORDER_COLOUR
:
923 m_button_bar_hover_border_pen
.SetColour(colour
);
925 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_COLOUR
:
926 m_button_bar_hover_background_top_colour
= colour
;
928 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
929 m_button_bar_hover_background_top_gradient_colour
= colour
;
931 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_COLOUR
:
932 m_button_bar_hover_background_colour
= colour
;
934 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_GRADIENT_COLOUR
:
935 m_button_bar_hover_background_gradient_colour
= colour
;
937 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BORDER_COLOUR
:
938 m_button_bar_active_border_pen
.SetColour(colour
);
940 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_COLOUR
:
941 m_button_bar_active_background_top_colour
= colour
;
943 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
944 m_button_bar_active_background_top_gradient_colour
= colour
;
946 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_COLOUR
:
947 m_button_bar_active_background_colour
= colour
;
949 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
950 m_button_bar_active_background_gradient_colour
= colour
;
952 case wxRIBBON_ART_GALLERY_BORDER_COLOUR
:
953 m_gallery_border_pen
.SetColour(colour
);
955 case wxRIBBON_ART_GALLERY_HOVER_BACKGROUND_COLOUR
:
956 m_gallery_hover_background_brush
.SetColour(colour
);
958 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_COLOUR
:
959 m_gallery_button_background_colour
= colour
;
961 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_GRADIENT_COLOUR
:
962 m_gallery_button_background_gradient_colour
= colour
;
964 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_TOP_COLOUR
:
965 m_gallery_button_background_top_brush
.SetColour(colour
);
967 case wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR
:
968 m_gallery_button_face_colour
= colour
;
969 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
971 m_gallery_up_bitmap
[0] = wxRibbonLoadPixmap(gallery_left_xpm
, colour
);
972 m_gallery_down_bitmap
[0] = wxRibbonLoadPixmap(gallery_right_xpm
, colour
);
976 m_gallery_up_bitmap
[0] = wxRibbonLoadPixmap(gallery_up_xpm
, colour
);
977 m_gallery_down_bitmap
[0] = wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
979 m_gallery_extension_bitmap
[0] = wxRibbonLoadPixmap(gallery_extension_xpm
, colour
);
981 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_COLOUR
:
982 m_gallery_button_hover_background_colour
= colour
;
984 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_GRADIENT_COLOUR
:
985 m_gallery_button_hover_background_gradient_colour
= colour
;
987 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_TOP_COLOUR
:
988 m_gallery_button_hover_background_top_brush
.SetColour(colour
);
990 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR
:
991 m_gallery_button_hover_face_colour
= colour
;
992 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
994 m_gallery_up_bitmap
[1] = wxRibbonLoadPixmap(gallery_left_xpm
, colour
);
995 m_gallery_down_bitmap
[1] = wxRibbonLoadPixmap(gallery_right_xpm
, colour
);
999 m_gallery_up_bitmap
[1] = wxRibbonLoadPixmap(gallery_up_xpm
, colour
);
1000 m_gallery_down_bitmap
[1] = wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
1002 m_gallery_extension_bitmap
[1] = wxRibbonLoadPixmap(gallery_extension_xpm
, colour
);
1004 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_COLOUR
:
1005 m_gallery_button_active_background_colour
= colour
;
1007 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
1008 m_gallery_button_active_background_gradient_colour
= colour
;
1010 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_TOP_COLOUR
:
1011 m_gallery_button_background_top_brush
.SetColour(colour
);
1013 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR
:
1014 m_gallery_button_active_face_colour
= colour
;
1015 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1017 m_gallery_up_bitmap
[2] = wxRibbonLoadPixmap(gallery_left_xpm
, colour
);
1018 m_gallery_down_bitmap
[2] = wxRibbonLoadPixmap(gallery_right_xpm
, colour
);
1022 m_gallery_up_bitmap
[2] = wxRibbonLoadPixmap(gallery_up_xpm
, colour
);
1023 m_gallery_down_bitmap
[2] = wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
1025 m_gallery_extension_bitmap
[2] = wxRibbonLoadPixmap(gallery_extension_xpm
, colour
);
1027 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_COLOUR
:
1028 m_gallery_button_disabled_background_colour
= colour
;
1030 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_GRADIENT_COLOUR
:
1031 m_gallery_button_disabled_background_gradient_colour
= colour
;
1033 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_TOP_COLOUR
:
1034 m_gallery_button_disabled_background_top_brush
.SetColour(colour
);
1036 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR
:
1037 m_gallery_button_disabled_face_colour
= colour
;
1038 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1040 m_gallery_up_bitmap
[3] = wxRibbonLoadPixmap(gallery_left_xpm
, colour
);
1041 m_gallery_down_bitmap
[3] = wxRibbonLoadPixmap(gallery_right_xpm
, colour
);
1045 m_gallery_up_bitmap
[3] = wxRibbonLoadPixmap(gallery_up_xpm
, colour
);
1046 m_gallery_down_bitmap
[3] = wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
1048 m_gallery_extension_bitmap
[3] = wxRibbonLoadPixmap(gallery_extension_xpm
, colour
);
1050 case wxRIBBON_ART_GALLERY_ITEM_BORDER_COLOUR
:
1051 m_gallery_item_border_pen
.SetColour(colour
);
1053 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_COLOUR
:
1054 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_GRADIENT_COLOUR
:
1055 m_tab_ctrl_background_brush
.SetColour(colour
);
1056 m_cached_tab_separator_visibility
= -1.0;
1058 case wxRIBBON_ART_TAB_LABEL_COLOUR
:
1059 m_tab_label_colour
= colour
;
1061 case wxRIBBON_ART_TAB_SEPARATOR_COLOUR
:
1062 m_tab_separator_colour
= colour
;
1063 m_cached_tab_separator_visibility
= -1.0;
1065 case wxRIBBON_ART_TAB_SEPARATOR_GRADIENT_COLOUR
:
1066 m_tab_separator_gradient_colour
= colour
;
1067 m_cached_tab_separator_visibility
= -1.0;
1069 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_COLOUR
:
1070 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
1072 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_COLOUR
:
1073 m_tab_active_background_colour
= colour
;
1075 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
1076 m_tab_active_background_gradient_colour
= colour
;
1078 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_COLOUR
:
1079 m_tab_hover_background_top_colour
= colour
;
1081 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
1082 m_tab_hover_background_top_gradient_colour
= colour
;
1084 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_COLOUR
:
1085 m_tab_hover_background_colour
= colour
;
1087 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_GRADIENT_COLOUR
:
1088 m_tab_hover_background_gradient_colour
= colour
;
1090 case wxRIBBON_ART_TAB_BORDER_COLOUR
:
1091 m_tab_border_pen
.SetColour(colour
);
1093 case wxRIBBON_ART_PANEL_BORDER_COLOUR
:
1094 m_panel_border_pen
.SetColour(colour
);
1096 case wxRIBBON_ART_PANEL_BORDER_GRADIENT_COLOUR
:
1097 m_panel_border_gradient_pen
.SetColour(colour
);
1099 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_COLOUR
:
1100 m_panel_minimised_border_pen
.SetColour(colour
);
1102 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_GRADIENT_COLOUR
:
1103 m_panel_minimised_border_gradient_pen
.SetColour(colour
);
1105 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_COLOUR
:
1106 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_GRADIENT_COLOUR
:
1107 m_panel_label_background_brush
.SetColour(colour
);
1109 case wxRIBBON_ART_PANEL_LABEL_COLOUR
:
1110 m_panel_label_colour
= colour
;
1112 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_COLOUR
:
1113 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_GRADIENT_COLOUR
:
1114 m_panel_hover_label_background_brush
.SetColour(colour
);
1116 case wxRIBBON_ART_PANEL_HOVER_LABEL_COLOUR
:
1117 m_panel_hover_label_colour
= colour
;
1119 case wxRIBBON_ART_PANEL_MINIMISED_LABEL_COLOUR
:
1120 m_panel_minimised_label_colour
= colour
;
1122 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_COLOUR
:
1123 m_panel_active_background_top_colour
= colour
;
1125 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
1126 m_panel_active_background_top_gradient_colour
= colour
;
1128 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_COLOUR
:
1129 m_panel_active_background_colour
= colour
;
1131 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
1132 m_panel_active_background_gradient_colour
= colour
;
1134 case wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR
:
1135 m_panel_button_face_colour
= colour
;
1136 m_panel_extension_bitmap
[0] = wxRibbonLoadPixmap(panel_extension_xpm
, colour
);
1138 case wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR
:
1139 m_panel_button_hover_face_colour
= colour
;
1140 m_panel_extension_bitmap
[1] = wxRibbonLoadPixmap(panel_extension_xpm
, colour
);
1142 case wxRIBBON_ART_PAGE_BORDER_COLOUR
:
1143 m_page_border_pen
.SetColour(colour
);
1145 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_COLOUR
:
1146 m_page_background_top_colour
= colour
;
1148 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_GRADIENT_COLOUR
:
1149 m_page_background_top_gradient_colour
= colour
;
1151 case wxRIBBON_ART_PAGE_BACKGROUND_COLOUR
:
1152 m_page_background_colour
= colour
;
1154 case wxRIBBON_ART_PAGE_BACKGROUND_GRADIENT_COLOUR
:
1155 m_page_background_gradient_colour
= colour
;
1157 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_COLOUR
:
1158 m_page_hover_background_top_colour
= colour
;
1160 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
1161 m_page_hover_background_top_gradient_colour
= colour
;
1163 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_COLOUR
:
1164 m_page_hover_background_colour
= colour
;
1166 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_GRADIENT_COLOUR
:
1167 m_page_hover_background_gradient_colour
= colour
;
1169 case wxRIBBON_ART_TOOLBAR_BORDER_COLOUR
:
1170 case wxRIBBON_ART_TOOLBAR_HOVER_BORDER_COLOUR
:
1171 m_toolbar_border_pen
.SetColour(colour
);
1173 case wxRIBBON_ART_TOOLBAR_FACE_COLOUR
:
1174 m_tool_face_colour
= colour
;
1175 m_toolbar_drop_bitmap
= wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
1177 case wxRIBBON_ART_PAGE_TOGGLE_FACE_COLOUR
:
1178 m_page_toggle_face_colour
= colour
;
1179 m_ribbon_toggle_down_bitmap
[0] = wxRibbonLoadPixmap(panel_toggle_down_xpm
, colour
);
1180 m_ribbon_toggle_up_bitmap
[0] = wxRibbonLoadPixmap(panel_toggle_up_xpm
, colour
);
1181 m_ribbon_toggle_pin_bitmap
[0] = wxRibbonLoadPixmap(ribbon_toggle_pin_xpm
, colour
);
1182 m_ribbon_bar_help_button_bitmap
[0] = wxRibbonLoadPixmap(ribbon_help_button_xpm
, colour
);
1184 case wxRIBBON_ART_PAGE_TOGGLE_HOVER_FACE_COLOUR
:
1185 m_page_toggle_hover_face_colour
= colour
;
1186 m_ribbon_toggle_down_bitmap
[1] = wxRibbonLoadPixmap(panel_toggle_down_xpm
, colour
);
1187 m_ribbon_toggle_up_bitmap
[1] = wxRibbonLoadPixmap(panel_toggle_up_xpm
, colour
);
1188 m_ribbon_toggle_pin_bitmap
[1] = wxRibbonLoadPixmap(ribbon_toggle_pin_xpm
, colour
);
1189 m_ribbon_bar_help_button_bitmap
[1] = wxRibbonLoadPixmap(ribbon_help_button_xpm
, colour
);
1192 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
1197 void wxRibbonMSWArtProvider::DrawTabCtrlBackground(
1199 wxWindow
* WXUNUSED(wnd
),
1202 dc
.SetPen(*wxTRANSPARENT_PEN
);
1203 dc
.SetBrush(m_tab_ctrl_background_brush
);
1204 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
1206 dc
.SetPen(m_page_border_pen
);
1209 dc
.DrawLine(rect
.x
+ 3, rect
.y
+ rect
.height
- 1, rect
.x
+ rect
.width
- 3, rect
.y
+ rect
.height
- 1);
1213 dc
.DrawLine(rect
.x
, rect
.y
+ rect
.height
- 1, rect
.x
+ rect
.width
, rect
.y
+ rect
.height
- 1);
1217 void wxRibbonMSWArtProvider::DrawTab(
1219 wxWindow
* WXUNUSED(wnd
),
1220 const wxRibbonPageTabInfo
& tab
)
1222 if(tab
.rect
.height
<= 2)
1225 if(tab
.active
|| tab
.hovered
|| tab
.highlight
)
1229 wxRect
background(tab
.rect
);
1233 background
.width
-= 4;
1234 background
.height
-= 2;
1236 dc
.GradientFillLinear(background
, m_tab_active_background_colour
,
1237 m_tab_active_background_gradient_colour
, wxSOUTH
);
1239 // TODO: active and hovered
1241 else if(tab
.hovered
)
1243 wxRect
background(tab
.rect
);
1247 background
.width
-= 4;
1248 background
.height
-= 3;
1249 int h
= background
.height
;
1250 background
.height
/= 2;
1251 dc
.GradientFillLinear(background
,
1252 m_tab_hover_background_top_colour
,
1253 m_tab_hover_background_top_gradient_colour
, wxSOUTH
);
1255 background
.y
+= background
.height
;
1256 background
.height
= h
- background
.height
;
1257 dc
.GradientFillLinear(background
, m_tab_hover_background_colour
,
1258 m_tab_hover_background_gradient_colour
, wxSOUTH
);
1260 else if(tab
.highlight
)
1262 wxRect
background(tab
.rect
);
1266 background
.width
-= 4;
1267 background
.height
-= 3;
1268 int h
= background
.height
;
1269 background
.height
/= 2;
1271 //For highlight pages we show a colour between the active page and for a hovered page:
1272 wxColour
top_colour1((m_tab_active_background_colour
.Red() + m_tab_hover_background_top_colour
.Red())/2,
1273 (m_tab_active_background_colour
.Green() + m_tab_hover_background_top_colour
.Green())/2,
1274 (m_tab_active_background_colour
.Blue() + m_tab_hover_background_top_colour
.Blue())/2);
1276 wxColour
bottom_colour1((m_tab_active_background_gradient_colour
.Red() + m_tab_hover_background_top_gradient_colour
.Red())/2,
1277 (m_tab_active_background_gradient_colour
.Green() + m_tab_hover_background_top_gradient_colour
.Green())/2,
1278 (m_tab_active_background_gradient_colour
.Blue() + m_tab_hover_background_top_gradient_colour
.Blue())/2);
1280 dc
.GradientFillLinear(background
, top_colour1
, bottom_colour1
, wxSOUTH
);
1282 background
.y
+= background
.height
;
1283 background
.height
= h
- background
.height
;
1285 wxColour
top_colour2((m_tab_active_background_colour
.Red() + m_tab_hover_background_colour
.Red())/2,
1286 (m_tab_active_background_colour
.Green() + m_tab_hover_background_colour
.Green())/2,
1287 (m_tab_active_background_colour
.Blue() + m_tab_hover_background_colour
.Blue())/2);
1289 wxColour
bottom_colour2((m_tab_active_background_gradient_colour
.Red() + m_tab_hover_background_gradient_colour
.Red())/2,
1290 (m_tab_active_background_gradient_colour
.Green() + m_tab_hover_background_gradient_colour
.Green())/2,
1291 (m_tab_active_background_gradient_colour
.Blue() + m_tab_hover_background_gradient_colour
.Blue())/2);
1293 dc
.GradientFillLinear(background
, top_colour2
, bottom_colour2
, wxSOUTH
);
1296 wxPoint border_points
[6];
1297 border_points
[0] = wxPoint(1, tab
.rect
.height
- 2);
1298 border_points
[1] = wxPoint(1, 3);
1299 border_points
[2] = wxPoint(3, 1);
1300 border_points
[3] = wxPoint(tab
.rect
.width
- 4, 1);
1301 border_points
[4] = wxPoint(tab
.rect
.width
- 2, 3);
1302 border_points
[5] = wxPoint(tab
.rect
.width
- 2, tab
.rect
.height
- 1);
1304 dc
.SetPen(m_tab_border_pen
);
1305 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
, tab
.rect
.x
, tab
.rect
.y
);
1309 // Give the tab a curved outward border at the bottom
1310 dc
.DrawPoint(tab
.rect
.x
, tab
.rect
.y
+ tab
.rect
.height
- 2);
1311 dc
.DrawPoint(tab
.rect
.x
+ tab
.rect
.width
- 1, tab
.rect
.y
+ tab
.rect
.height
- 2);
1313 wxPen
p(m_tab_active_background_gradient_colour
);
1316 // Technically the first two points are the wrong colour, but they're near enough
1317 dc
.DrawPoint(tab
.rect
.x
+ 1, tab
.rect
.y
+ tab
.rect
.height
- 2);
1318 dc
.DrawPoint(tab
.rect
.x
+ tab
.rect
.width
- 2, tab
.rect
.y
+ tab
.rect
.height
- 2);
1319 dc
.DrawPoint(tab
.rect
.x
+ 1, tab
.rect
.y
+ tab
.rect
.height
- 1);
1320 dc
.DrawPoint(tab
.rect
.x
, tab
.rect
.y
+ tab
.rect
.height
- 1);
1321 dc
.DrawPoint(tab
.rect
.x
+ tab
.rect
.width
- 2, tab
.rect
.y
+ tab
.rect
.height
- 1);
1322 dc
.DrawPoint(tab
.rect
.x
+ tab
.rect
.width
- 1, tab
.rect
.y
+ tab
.rect
.height
- 1);
1326 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_ICONS
)
1328 wxBitmap icon
= tab
.page
->GetIcon();
1331 int x
= tab
.rect
.x
+ 4;
1332 if((m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
) == 0)
1333 x
= tab
.rect
.x
+ (tab
.rect
.width
- icon
.GetWidth()) / 2;
1334 dc
.DrawBitmap(icon
, x
, tab
.rect
.y
+ 1 + (tab
.rect
.height
- 1 -
1335 icon
.GetHeight()) / 2, true);
1338 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
)
1340 wxString label
= tab
.page
->GetLabel();
1341 if(!label
.IsEmpty())
1343 dc
.SetFont(m_tab_label_font
);
1344 dc
.SetTextForeground(m_tab_label_colour
);
1345 dc
.SetBackgroundMode(wxTRANSPARENT
);
1349 dc
.GetTextExtent(label
, &text_width
, &text_height
);
1350 int width
= tab
.rect
.width
- 5;
1351 int x
= tab
.rect
.x
+ 3;
1352 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_ICONS
)
1354 x
+= 3 + tab
.page
->GetIcon().GetWidth();
1355 width
-= 3 + tab
.page
->GetIcon().GetWidth();
1357 int y
= tab
.rect
.y
+ (tab
.rect
.height
- text_height
) / 2;
1359 if(width
<= text_width
)
1361 dc
.SetClippingRegion(x
, tab
.rect
.y
, width
, tab
.rect
.height
);
1362 dc
.DrawText(label
, x
, y
);
1366 dc
.DrawText(label
, x
+ (width
- text_width
) / 2 + 1, y
);
1372 void wxRibbonMSWArtProvider::DrawTabSeparator(
1378 if(visibility
<= 0.0)
1382 if(visibility
> 1.0)
1387 // The tab separator is relatively expensive to draw (for its size), and is
1388 // usually drawn multiple times sequentially (in different positions), so it
1389 // makes sense to draw it once and cache it.
1390 if(!m_cached_tab_separator
.IsOk() || m_cached_tab_separator
.GetSize() != rect
.GetSize() || visibility
!= m_cached_tab_separator_visibility
)
1392 wxRect
size(rect
.GetSize());
1393 ReallyDrawTabSeparator(wnd
, size
, visibility
);
1395 dc
.DrawBitmap(m_cached_tab_separator
, rect
.x
, rect
.y
, false);
1398 void wxRibbonMSWArtProvider::ReallyDrawTabSeparator(wxWindow
* wnd
, const wxRect
& rect
, double visibility
)
1400 if(!m_cached_tab_separator
.IsOk() || m_cached_tab_separator
.GetSize() != rect
.GetSize())
1402 m_cached_tab_separator
= wxBitmap(rect
.GetSize());
1405 wxMemoryDC
dc(m_cached_tab_separator
);
1406 DrawTabCtrlBackground(dc
, wnd
, rect
);
1408 wxCoord x
= rect
.x
+ rect
.width
/ 2;
1409 double h
= (double)(rect
.height
- 1);
1411 double r1
= m_tab_ctrl_background_brush
.GetColour().Red() * (1.0 - visibility
) + 0.5;
1412 double g1
= m_tab_ctrl_background_brush
.GetColour().Green() * (1.0 - visibility
) + 0.5;
1413 double b1
= m_tab_ctrl_background_brush
.GetColour().Blue() * (1.0 - visibility
) + 0.5;
1414 double r2
= m_tab_separator_colour
.Red();
1415 double g2
= m_tab_separator_colour
.Green();
1416 double b2
= m_tab_separator_colour
.Blue();
1417 double r3
= m_tab_separator_gradient_colour
.Red();
1418 double g3
= m_tab_separator_gradient_colour
.Green();
1419 double b3
= m_tab_separator_gradient_colour
.Blue();
1421 for(int i
= 0; i
< rect
.height
- 1; ++i
)
1423 double p
= ((double)i
)/h
;
1425 double r
= (p
* r3
+ (1.0 - p
) * r2
) * visibility
+ r1
;
1426 double g
= (p
* g3
+ (1.0 - p
) * g2
) * visibility
+ g1
;
1427 double b
= (p
* b3
+ (1.0 - p
) * b2
) * visibility
+ b1
;
1429 wxPen
P(wxColour((unsigned char)r
, (unsigned char)g
, (unsigned char)b
));
1431 dc
.DrawPoint(x
, rect
.y
+ i
);
1434 m_cached_tab_separator_visibility
= visibility
;
1437 void wxRibbonMSWArtProvider::DrawPartialPageBackground(wxDC
& dc
,
1438 wxWindow
* wnd
, const wxRect
& r
, wxRibbonPage
* page
,
1439 wxPoint offset
, bool hovered
)
1442 // Expanded panels need a background - the expanded panel at
1443 // best size may have a greater Y dimension higher than when
1444 // on the bar if it has a sizer. AUI art provider does not need this
1445 // because it paints the panel without reference to its parent's size.
1446 // Expanded panels use a wxFrame as parent (not a wxRibbonPage).
1448 if(wnd
->GetSizer() && wnd
->GetParent() != page
)
1450 background
= wnd
->GetParent()->GetSize();
1451 offset
= wxPoint(0,0);
1455 background
= page
->GetSize();
1456 page
->AdjustRectToIncludeScrollButtons(&background
);
1457 background
.height
-= 2;
1459 // Page background isn't dependent upon the width of the page
1460 // (at least not the part of it intended to be painted by this
1461 // function). Set to wider than the page itself for when externally
1462 // expanded panels need a background - the expanded panel can be wider
1465 background
.width
= INT_MAX
;
1467 // upper_rect, lower_rect, paint_rect are all in page co-ordinates
1468 wxRect
upper_rect(background
);
1469 upper_rect
.height
/= 5;
1471 wxRect
lower_rect(background
);
1472 lower_rect
.y
+= upper_rect
.height
;
1473 lower_rect
.height
-= upper_rect
.height
;
1475 wxRect
paint_rect(r
);
1476 paint_rect
.x
+= offset
.x
;
1477 paint_rect
.y
+= offset
.y
;
1479 wxColour bg_top
, bg_top_grad
, bg_btm
, bg_btm_grad
;
1482 bg_top
= m_page_hover_background_top_colour
;
1483 bg_top_grad
= m_page_hover_background_top_gradient_colour
;
1484 bg_btm
= m_page_hover_background_colour
;
1485 bg_btm_grad
= m_page_hover_background_gradient_colour
;
1489 bg_top
= m_page_background_top_colour
;
1490 bg_top_grad
= m_page_background_top_gradient_colour
;
1491 bg_btm
= m_page_background_colour
;
1492 bg_btm_grad
= m_page_background_gradient_colour
;
1495 if(paint_rect
.Intersects(upper_rect
))
1497 wxRect
rect(upper_rect
);
1498 rect
.Intersect(paint_rect
);
1501 wxColour
starting_colour(wxRibbonInterpolateColour(bg_top
, bg_top_grad
,
1502 paint_rect
.y
, upper_rect
.y
, upper_rect
.y
+ upper_rect
.height
));
1503 wxColour
ending_colour(wxRibbonInterpolateColour(bg_top
, bg_top_grad
,
1504 paint_rect
.y
+ paint_rect
.height
, upper_rect
.y
,
1505 upper_rect
.y
+ upper_rect
.height
));
1506 dc
.GradientFillLinear(rect
, starting_colour
, ending_colour
, wxSOUTH
);
1509 if(paint_rect
.Intersects(lower_rect
))
1511 wxRect
rect(lower_rect
);
1512 rect
.Intersect(paint_rect
);
1515 wxColour
starting_colour(wxRibbonInterpolateColour(bg_btm
, bg_btm_grad
,
1516 paint_rect
.y
, lower_rect
.y
, lower_rect
.y
+ lower_rect
.height
));
1517 wxColour
ending_colour(wxRibbonInterpolateColour(bg_btm
, bg_btm_grad
,
1518 paint_rect
.y
+ paint_rect
.height
,
1519 lower_rect
.y
, lower_rect
.y
+ lower_rect
.height
));
1520 dc
.GradientFillLinear(rect
, starting_colour
, ending_colour
, wxSOUTH
);
1524 void wxRibbonMSWArtProvider::DrawPageBackground(
1526 wxWindow
* WXUNUSED(wnd
),
1529 dc
.SetPen(*wxTRANSPARENT_PEN
);
1530 dc
.SetBrush(m_tab_ctrl_background_brush
);
1536 dc
.DrawRectangle(edge
.x
, edge
.y
, edge
.width
, edge
.height
);
1538 edge
.x
+= rect
.width
- 2;
1539 dc
.DrawRectangle(edge
.x
, edge
.y
, edge
.width
, edge
.height
);
1543 edge
.y
+= (rect
.height
- edge
.height
);
1544 dc
.DrawRectangle(edge
.x
, edge
.y
, edge
.width
, edge
.height
);
1548 wxRect
background(rect
);
1550 background
.width
-= 4;
1551 background
.height
-= 2;
1553 background
.height
/= 5;
1554 dc
.GradientFillLinear(background
, m_page_background_top_colour
,
1555 m_page_background_top_gradient_colour
, wxSOUTH
);
1557 background
.y
+= background
.height
;
1558 background
.height
= rect
.height
- 2 - background
.height
;
1559 dc
.GradientFillLinear(background
, m_page_background_colour
,
1560 m_page_background_gradient_colour
, wxSOUTH
);
1564 wxPoint border_points
[8];
1565 border_points
[0] = wxPoint(2, 0);
1566 border_points
[1] = wxPoint(1, 1);
1567 border_points
[2] = wxPoint(1, rect
.height
- 4);
1568 border_points
[3] = wxPoint(3, rect
.height
- 2);
1569 border_points
[4] = wxPoint(rect
.width
- 4, rect
.height
- 2);
1570 border_points
[5] = wxPoint(rect
.width
- 2, rect
.height
- 4);
1571 border_points
[6] = wxPoint(rect
.width
- 2, 1);
1572 border_points
[7] = wxPoint(rect
.width
- 4, -1);
1574 dc
.SetPen(m_page_border_pen
);
1575 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
, rect
.x
, rect
.y
);
1579 void wxRibbonMSWArtProvider::DrawScrollButton(
1581 wxWindow
* WXUNUSED(wnd
),
1582 const wxRect
& rect_
,
1587 if((style
& wxRIBBON_SCROLL_BTN_FOR_MASK
) == wxRIBBON_SCROLL_BTN_FOR_PAGE
)
1589 // Page scroll buttons do not have the luxury of rendering on top of anything
1590 // else, and their size includes some padding, hence the background painting
1591 // and size adjustment.
1592 dc
.SetPen(*wxTRANSPARENT_PEN
);
1593 dc
.SetBrush(m_tab_ctrl_background_brush
);
1594 dc
.DrawRectangle(rect
);
1595 dc
.SetClippingRegion(rect
);
1596 switch(style
& wxRIBBON_SCROLL_BTN_DIRECTION_MASK
)
1598 case wxRIBBON_SCROLL_BTN_LEFT
:
1600 case wxRIBBON_SCROLL_BTN_RIGHT
:
1604 case wxRIBBON_SCROLL_BTN_UP
:
1610 case wxRIBBON_SCROLL_BTN_DOWN
:
1619 wxRect
background(rect
);
1622 background
.width
-= 2;
1623 background
.height
-= 2;
1625 if(style
& wxRIBBON_SCROLL_BTN_UP
)
1626 background
.height
/= 2;
1628 background
.height
/= 5;
1629 dc
.GradientFillLinear(background
, m_page_background_top_colour
,
1630 m_page_background_top_gradient_colour
, wxSOUTH
);
1632 background
.y
+= background
.height
;
1633 background
.height
= rect
.height
- 2 - background
.height
;
1634 dc
.GradientFillLinear(background
, m_page_background_colour
,
1635 m_page_background_gradient_colour
, wxSOUTH
);
1639 wxPoint border_points
[7];
1640 switch(style
& wxRIBBON_SCROLL_BTN_DIRECTION_MASK
)
1642 case wxRIBBON_SCROLL_BTN_LEFT
:
1643 border_points
[0] = wxPoint(2, 0);
1644 border_points
[1] = wxPoint(rect
.width
- 1, 0);
1645 border_points
[2] = wxPoint(rect
.width
- 1, rect
.height
- 1);
1646 border_points
[3] = wxPoint(2, rect
.height
- 1);
1647 border_points
[4] = wxPoint(0, rect
.height
- 3);
1648 border_points
[5] = wxPoint(0, 2);
1650 case wxRIBBON_SCROLL_BTN_RIGHT
:
1651 border_points
[0] = wxPoint(0, 0);
1652 border_points
[1] = wxPoint(rect
.width
- 3, 0);
1653 border_points
[2] = wxPoint(rect
.width
- 1, 2);
1654 border_points
[3] = wxPoint(rect
.width
- 1, rect
.height
- 3);
1655 border_points
[4] = wxPoint(rect
.width
- 3, rect
.height
- 1);
1656 border_points
[5] = wxPoint(0, rect
.height
- 1);
1658 case wxRIBBON_SCROLL_BTN_UP
:
1659 border_points
[0] = wxPoint(2, 0);
1660 border_points
[1] = wxPoint(rect
.width
- 3, 0);
1661 border_points
[2] = wxPoint(rect
.width
- 1, 2);
1662 border_points
[3] = wxPoint(rect
.width
- 1, rect
.height
- 1);
1663 border_points
[4] = wxPoint(0, rect
.height
- 1);
1664 border_points
[5] = wxPoint(0, 2);
1666 case wxRIBBON_SCROLL_BTN_DOWN
:
1667 border_points
[0] = wxPoint(0, 0);
1668 border_points
[1] = wxPoint(rect
.width
- 1, 0);
1669 border_points
[2] = wxPoint(rect
.width
- 1, rect
.height
- 3);
1670 border_points
[3] = wxPoint(rect
.width
- 3, rect
.height
- 1);
1671 border_points
[4] = wxPoint(2, rect
.height
- 1);
1672 border_points
[5] = wxPoint(0, rect
.height
- 3);
1675 border_points
[6] = border_points
[0];
1677 dc
.SetPen(m_page_border_pen
);
1678 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
, rect
.x
, rect
.y
);
1682 // NB: Code for handling hovered/active state is temporary
1683 wxPoint arrow_points
[3];
1684 switch(style
& wxRIBBON_SCROLL_BTN_DIRECTION_MASK
)
1686 case wxRIBBON_SCROLL_BTN_LEFT
:
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_RIGHT
:
1694 arrow_points
[0] = wxPoint(rect
.width
/ 2 + 2, rect
.height
/ 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_UP
:
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);
1707 case wxRIBBON_SCROLL_BTN_DOWN
:
1708 arrow_points
[0] = wxPoint(rect
.width
/ 2, rect
.height
/ 2 + 2);
1709 if(style
& wxRIBBON_SCROLL_BTN_ACTIVE
)
1710 arrow_points
[0].y
+= 1;
1711 arrow_points
[1] = arrow_points
[0] - wxPoint( 3, 3);
1712 arrow_points
[2] = arrow_points
[0] - wxPoint(-3, 3);
1716 dc
.SetPen(*wxTRANSPARENT_PEN
);
1717 wxBrush
B(style
& wxRIBBON_SCROLL_BTN_HOVERED
? m_tab_active_background_colour
: m_tab_label_colour
);
1719 dc
.DrawPolygon(sizeof(arrow_points
)/sizeof(wxPoint
), arrow_points
, rect
.x
, rect
.y
);
1723 void wxRibbonMSWArtProvider::DrawDropdownArrow(wxDC
& dc
, int x
, int y
, const wxColour
& colour
)
1725 wxPoint arrow_points
[3];
1726 wxBrush
brush(colour
);
1727 arrow_points
[0] = wxPoint(1, 2);
1728 arrow_points
[1] = arrow_points
[0] + wxPoint(-3, -3);
1729 arrow_points
[2] = arrow_points
[0] + wxPoint( 3, -3);
1730 dc
.SetPen(*wxTRANSPARENT_PEN
);
1732 dc
.DrawPolygon(sizeof(arrow_points
)/sizeof(wxPoint
), arrow_points
, x
, y
);
1735 void wxRibbonMSWArtProvider::RemovePanelPadding(wxRect
* rect
)
1737 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1749 void wxRibbonMSWArtProvider::DrawPanelBackground(
1754 DrawPartialPageBackground(dc
, wnd
, rect
, false);
1756 wxRect
true_rect(rect
);
1757 RemovePanelPadding(&true_rect
);
1758 bool has_ext_button
= wnd
->HasExtButton();
1762 dc
.SetFont(m_panel_label_font
);
1763 dc
.SetPen(*wxTRANSPARENT_PEN
);
1764 if(wnd
->IsHovered())
1766 dc
.SetBrush(m_panel_hover_label_background_brush
);
1767 dc
.SetTextForeground(m_panel_hover_label_colour
);
1771 dc
.SetBrush(m_panel_label_background_brush
);
1772 dc
.SetTextForeground(m_panel_label_colour
);
1775 wxRect
label_rect(true_rect
);
1776 wxString label
= wnd
->GetLabel();
1777 bool clip_label
= false;
1778 wxSize
label_size(dc
.GetTextExtent(label
));
1780 label_rect
.SetX(label_rect
.GetX() + 1);
1781 label_rect
.SetWidth(label_rect
.GetWidth() - 2);
1782 label_rect
.SetHeight(label_size
.GetHeight() + 2);
1783 label_rect
.SetY(true_rect
.GetBottom() - label_rect
.GetHeight());
1784 label_height
= label_rect
.GetHeight();
1786 wxRect label_bg_rect
= label_rect
;
1789 label_rect
.SetWidth(label_rect
.GetWidth() - 13);
1791 if(label_size
.GetWidth() > label_rect
.GetWidth())
1793 // Test if there is enough length for 3 letters and ...
1794 wxString new_label
= label
.Mid(0, 3) + wxT("...");
1795 label_size
= dc
.GetTextExtent(new_label
);
1796 if(label_size
.GetWidth() > label_rect
.GetWidth())
1798 // Not enough room for three characters and ...
1799 // Display the entire label and just crop it
1804 // Room for some characters and ...
1805 // Display as many characters as possible and append ...
1806 for(size_t len
= label
.Len() - 1; len
>= 3; --len
)
1808 new_label
= label
.Mid(0, len
) + wxT("...");
1809 label_size
= dc
.GetTextExtent(new_label
);
1810 if(label_size
.GetWidth() <= label_rect
.GetWidth())
1819 dc
.DrawRectangle(label_bg_rect
);
1822 wxDCClipper
clip(dc
, label_rect
);
1823 dc
.DrawText(label
, label_rect
.x
, label_rect
.y
+
1824 (label_rect
.GetHeight() - label_size
.GetHeight()) / 2);
1828 dc
.DrawText(label
, label_rect
.x
+
1829 (label_rect
.GetWidth() - label_size
.GetWidth()) / 2,
1831 (label_rect
.GetHeight() - label_size
.GetHeight()) / 2);
1836 if(wnd
->IsExtButtonHovered())
1838 dc
.SetPen(m_panel_hover_button_border_pen
);
1839 dc
.SetBrush(m_panel_hover_button_background_brush
);
1840 dc
.DrawRoundedRectangle(label_rect
.GetRight(), label_rect
.GetBottom() - 13, 13, 13, 1.0);
1841 dc
.DrawBitmap(m_panel_extension_bitmap
[1], label_rect
.GetRight() + 3, label_rect
.GetBottom() - 10, true);
1844 dc
.DrawBitmap(m_panel_extension_bitmap
[0], label_rect
.GetRight() + 3, label_rect
.GetBottom() - 10, true);
1848 if(wnd
->IsHovered())
1850 wxRect
client_rect(true_rect
);
1852 client_rect
.width
-= 2;
1854 client_rect
.height
-= 2 + label_height
;
1855 DrawPartialPageBackground(dc
, wnd
, client_rect
, true);
1858 DrawPanelBorder(dc
, true_rect
, m_panel_border_pen
, m_panel_border_gradient_pen
);
1861 wxRect
wxRibbonMSWArtProvider::GetPanelExtButtonArea(wxDC
& WXUNUSED(dc
),
1862 const wxRibbonPanel
* WXUNUSED(wnd
),
1865 RemovePanelPadding(&rect
);
1866 rect
= wxRect(rect
.GetRight()-13, rect
.GetBottom()-13, 13, 13);
1870 void wxRibbonMSWArtProvider::DrawGalleryBackground(
1872 wxRibbonGallery
* wnd
,
1875 DrawPartialPageBackground(dc
, wnd
, rect
);
1877 if(wnd
->IsHovered())
1879 dc
.SetPen(*wxTRANSPARENT_PEN
);
1880 dc
.SetBrush(m_gallery_hover_background_brush
);
1881 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1883 dc
.DrawRectangle(rect
.x
+ 1, rect
.y
+ 1, rect
.width
- 2,
1888 dc
.DrawRectangle(rect
.x
+ 1, rect
.y
+ 1, rect
.width
- 16,
1893 dc
.SetPen(m_gallery_border_pen
);
1895 dc
.DrawLine(rect
.x
+ 1, rect
.y
, rect
.x
+ rect
.width
- 1, rect
.y
);
1896 dc
.DrawLine(rect
.x
, rect
.y
+ 1, rect
.x
, rect
.y
+ rect
.height
- 1);
1897 dc
.DrawLine(rect
.x
+ 1, rect
.y
+ rect
.height
- 1, rect
.x
+ rect
.width
- 1,
1898 rect
.y
+ rect
.height
- 1);
1899 dc
.DrawLine(rect
.x
+ rect
.width
- 1, rect
.y
+ 1, rect
.x
+ rect
.width
- 1,
1900 rect
.y
+ rect
.height
- 1);
1902 DrawGalleryBackgroundCommon(dc
, wnd
, rect
);
1905 void wxRibbonMSWArtProvider::DrawGalleryBackgroundCommon(wxDC
& dc
,
1906 wxRibbonGallery
* wnd
,
1909 wxRect up_btn
, down_btn
, ext_btn
;
1911 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1913 // Divider between items and buttons
1914 dc
.DrawLine(rect
.x
, rect
.y
+ rect
.height
- 15, rect
.x
+ rect
.width
,
1915 rect
.y
+ rect
.height
- 15);
1917 up_btn
= wxRect(rect
.x
, rect
.y
+ rect
.height
- 15, rect
.width
/ 3, 15);
1919 down_btn
= wxRect(up_btn
.GetRight() + 1, up_btn
.GetTop(),
1920 up_btn
.GetWidth(), up_btn
.GetHeight());
1921 dc
.DrawLine(down_btn
.GetLeft(), down_btn
.GetTop(), down_btn
.GetLeft(),
1922 down_btn
.GetBottom());
1924 ext_btn
= wxRect(down_btn
.GetRight() + 1, up_btn
.GetTop(), rect
.width
-
1925 up_btn
.GetWidth() - down_btn
.GetWidth() - 1, up_btn
.GetHeight());
1926 dc
.DrawLine(ext_btn
.GetLeft(), ext_btn
.GetTop(), ext_btn
.GetLeft(),
1927 ext_btn
.GetBottom());
1931 // Divider between items and buttons
1932 dc
.DrawLine(rect
.x
+ rect
.width
- 15, rect
.y
, rect
.x
+ rect
.width
- 15,
1933 rect
.y
+ rect
.height
);
1935 up_btn
= wxRect(rect
.x
+ rect
.width
- 15, rect
.y
, 15, rect
.height
/ 3);
1937 down_btn
= wxRect(up_btn
.GetLeft(), up_btn
.GetBottom() + 1,
1938 up_btn
.GetWidth(), up_btn
.GetHeight());
1939 dc
.DrawLine(down_btn
.GetLeft(), down_btn
.GetTop(), down_btn
.GetRight(),
1942 ext_btn
= wxRect(up_btn
.GetLeft(), down_btn
.GetBottom() + 1, up_btn
.GetWidth(),
1943 rect
.height
- up_btn
.GetHeight() - down_btn
.GetHeight() - 1);
1944 dc
.DrawLine(ext_btn
.GetLeft(), ext_btn
.GetTop(), ext_btn
.GetRight(),
1948 DrawGalleryButton(dc
, up_btn
, wnd
->GetUpButtonState(),
1949 m_gallery_up_bitmap
);
1950 DrawGalleryButton(dc
, down_btn
, wnd
->GetDownButtonState(),
1951 m_gallery_down_bitmap
);
1952 DrawGalleryButton(dc
, ext_btn
, wnd
->GetExtensionButtonState(),
1953 m_gallery_extension_bitmap
);
1956 void wxRibbonMSWArtProvider::DrawGalleryButton(wxDC
& dc
,
1958 wxRibbonGalleryButtonState state
,
1961 wxBitmap btn_bitmap
;
1962 wxBrush btn_top_brush
;
1963 wxColour btn_colour
;
1964 wxColour btn_grad_colour
;
1967 case wxRIBBON_GALLERY_BUTTON_NORMAL
:
1968 btn_top_brush
= m_gallery_button_background_top_brush
;
1969 btn_colour
= m_gallery_button_background_colour
;
1970 btn_grad_colour
= m_gallery_button_background_gradient_colour
;
1971 btn_bitmap
= bitmaps
[0];
1973 case wxRIBBON_GALLERY_BUTTON_HOVERED
:
1974 btn_top_brush
= m_gallery_button_hover_background_top_brush
;
1975 btn_colour
= m_gallery_button_hover_background_colour
;
1976 btn_grad_colour
= m_gallery_button_hover_background_gradient_colour
;
1977 btn_bitmap
= bitmaps
[1];
1979 case wxRIBBON_GALLERY_BUTTON_ACTIVE
:
1980 btn_top_brush
= m_gallery_button_active_background_top_brush
;
1981 btn_colour
= m_gallery_button_active_background_colour
;
1982 btn_grad_colour
= m_gallery_button_active_background_gradient_colour
;
1983 btn_bitmap
= bitmaps
[2];
1985 case wxRIBBON_GALLERY_BUTTON_DISABLED
:
1986 btn_top_brush
= m_gallery_button_disabled_background_top_brush
;
1987 btn_colour
= m_gallery_button_disabled_background_colour
;
1988 btn_grad_colour
= m_gallery_button_disabled_background_gradient_colour
;
1989 btn_bitmap
= bitmaps
[3];
1995 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2006 dc
.SetPen(*wxTRANSPARENT_PEN
);
2007 dc
.SetBrush(btn_top_brush
);
2008 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
/ 2);
2011 lower
.height
= (lower
.height
+ 1) / 2;
2012 lower
.y
+= rect
.height
- lower
.height
;
2013 dc
.GradientFillLinear(lower
, btn_colour
, btn_grad_colour
, wxSOUTH
);
2015 dc
.DrawBitmap(btn_bitmap
, rect
.x
+ rect
.width
/ 2 - 2, lower
.y
- 2, true);
2018 void wxRibbonMSWArtProvider::DrawGalleryItemBackground(
2020 wxRibbonGallery
* wnd
,
2022 wxRibbonGalleryItem
* item
)
2024 if(wnd
->GetHoveredItem() != item
&& wnd
->GetActiveItem() != item
&&
2025 wnd
->GetSelection() != item
)
2028 dc
.SetPen(m_gallery_item_border_pen
);
2029 dc
.DrawLine(rect
.x
+ 1, rect
.y
, rect
.x
+ rect
.width
- 1, rect
.y
);
2030 dc
.DrawLine(rect
.x
, rect
.y
+ 1, rect
.x
, rect
.y
+ rect
.height
- 1);
2031 dc
.DrawLine(rect
.x
+ 1, rect
.y
+ rect
.height
- 1, rect
.x
+ rect
.width
- 1,
2032 rect
.y
+ rect
.height
- 1);
2033 dc
.DrawLine(rect
.x
+ rect
.width
- 1, rect
.y
+ 1, rect
.x
+ rect
.width
- 1,
2034 rect
.y
+ rect
.height
- 1);
2038 wxColour bg_gradient_colour
;
2040 if(wnd
->GetActiveItem() == item
|| wnd
->GetSelection() == item
)
2042 top_brush
= m_gallery_button_active_background_top_brush
;
2043 bg_colour
= m_gallery_button_active_background_colour
;
2044 bg_gradient_colour
= m_gallery_button_active_background_gradient_colour
;
2048 top_brush
= m_gallery_button_hover_background_top_brush
;
2049 bg_colour
= m_gallery_button_hover_background_colour
;
2050 bg_gradient_colour
= m_gallery_button_hover_background_gradient_colour
;
2058 dc
.SetPen(*wxTRANSPARENT_PEN
);
2059 dc
.SetBrush(top_brush
);
2060 dc
.DrawRectangle(upper
.x
, upper
.y
, upper
.width
, upper
.height
);
2062 wxRect
lower(upper
);
2063 lower
.y
+= lower
.height
;
2064 lower
.height
= rect
.height
- 2 - lower
.height
;
2065 dc
.GradientFillLinear(lower
, bg_colour
, bg_gradient_colour
, wxSOUTH
);
2068 void wxRibbonMSWArtProvider::DrawPanelBorder(wxDC
& dc
, const wxRect
& rect
,
2069 wxPen
& primary_colour
,
2070 wxPen
& secondary_colour
)
2072 wxPoint border_points
[9];
2073 border_points
[0] = wxPoint(2, 0);
2074 border_points
[1] = wxPoint(rect
.width
- 3, 0);
2075 border_points
[2] = wxPoint(rect
.width
- 1, 2);
2076 border_points
[3] = wxPoint(rect
.width
- 1, rect
.height
- 3);
2077 border_points
[4] = wxPoint(rect
.width
- 3, rect
.height
- 1);
2078 border_points
[5] = wxPoint(2, rect
.height
- 1);
2079 border_points
[6] = wxPoint(0, rect
.height
- 3);
2080 border_points
[7] = wxPoint(0, 2);
2082 if(primary_colour
.GetColour() == secondary_colour
.GetColour())
2084 border_points
[8] = border_points
[0];
2085 dc
.SetPen(primary_colour
);
2086 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
, rect
.x
, rect
.y
);
2090 dc
.SetPen(primary_colour
);
2091 dc
.DrawLines(3, border_points
, rect
.x
, rect
.y
);
2093 #define SingleLine(start, finish) \
2094 dc.DrawLine(start.x + rect.x, start.y + rect.y, finish.x + rect.x, finish.y + rect.y)
2096 SingleLine(border_points
[0], border_points
[7]);
2097 dc
.SetPen(secondary_colour
);
2098 dc
.DrawLines(3, border_points
+ 4, rect
.x
, rect
.y
);
2099 SingleLine(border_points
[4], border_points
[3]);
2103 border_points
[6] = border_points
[2];
2104 wxRibbonDrawParallelGradientLines(dc
, 2, border_points
+ 6, 0, 1,
2105 border_points
[3].y
- border_points
[2].y
+ 1, rect
.x
, rect
.y
,
2106 primary_colour
.GetColour(), secondary_colour
.GetColour());
2110 void wxRibbonMSWArtProvider::DrawMinimisedPanel(
2116 DrawPartialPageBackground(dc
, wnd
, rect
, false);
2118 wxRect
true_rect(rect
);
2119 RemovePanelPadding(&true_rect
);
2121 if(wnd
->GetExpandedPanel() != NULL
)
2123 wxRect
client_rect(true_rect
);
2125 client_rect
.width
-= 2;
2127 client_rect
.height
= (rect
.y
+ rect
.height
/ 5) - client_rect
.x
;
2128 dc
.GradientFillLinear(client_rect
,
2129 m_panel_active_background_top_colour
,
2130 m_panel_active_background_top_gradient_colour
, wxSOUTH
);
2132 client_rect
.y
+= client_rect
.height
;
2133 client_rect
.height
= (true_rect
.y
+ true_rect
.height
) - client_rect
.y
;
2134 dc
.GradientFillLinear(client_rect
,
2135 m_panel_active_background_colour
,
2136 m_panel_active_background_gradient_colour
, wxSOUTH
);
2138 else if(wnd
->IsHovered())
2140 wxRect
client_rect(true_rect
);
2142 client_rect
.width
-= 2;
2144 client_rect
.height
-= 2;
2145 DrawPartialPageBackground(dc
, wnd
, client_rect
, true);
2149 DrawMinimisedPanelCommon(dc
, wnd
, true_rect
, &preview
);
2151 dc
.SetBrush(m_panel_hover_label_background_brush
);
2152 dc
.SetPen(*wxTRANSPARENT_PEN
);
2153 dc
.DrawRectangle(preview
.x
+ 1, preview
.y
+ preview
.height
- 8,
2154 preview
.width
- 2, 7);
2156 int mid_pos
= rect
.y
+ rect
.height
/ 5 - preview
.y
;
2157 if(mid_pos
< 0 || mid_pos
>= preview
.height
)
2159 wxRect
full_rect(preview
);
2162 full_rect
.width
-= 2;
2163 full_rect
.height
-= 9;
2166 dc
.GradientFillLinear(full_rect
,
2167 m_page_hover_background_colour
,
2168 m_page_hover_background_gradient_colour
, wxSOUTH
);
2172 dc
.GradientFillLinear(full_rect
,
2173 m_page_hover_background_top_colour
,
2174 m_page_hover_background_top_gradient_colour
, wxSOUTH
);
2179 wxRect
top_rect(preview
);
2182 top_rect
.width
-= 2;
2183 top_rect
.height
= mid_pos
;
2184 dc
.GradientFillLinear(top_rect
,
2185 m_page_hover_background_top_colour
,
2186 m_page_hover_background_top_gradient_colour
, wxSOUTH
);
2188 wxRect
btm_rect(top_rect
);
2189 btm_rect
.y
= preview
.y
+ mid_pos
;
2190 btm_rect
.height
= preview
.y
+ preview
.height
- 7 - btm_rect
.y
;
2191 dc
.GradientFillLinear(btm_rect
,
2192 m_page_hover_background_colour
,
2193 m_page_hover_background_gradient_colour
, wxSOUTH
);
2198 dc
.DrawBitmap(bitmap
, preview
.x
+ (preview
.width
- bitmap
.GetWidth()) / 2,
2199 preview
.y
+ (preview
.height
- 7 - bitmap
.GetHeight()) / 2, true);
2202 DrawPanelBorder(dc
, preview
, m_panel_border_pen
, m_panel_border_gradient_pen
);
2204 DrawPanelBorder(dc
, true_rect
, m_panel_minimised_border_pen
,
2205 m_panel_minimised_border_gradient_pen
);
2208 void wxRibbonMSWArtProvider::DrawMinimisedPanelCommon(
2211 const wxRect
& true_rect
,
2212 wxRect
* preview_rect
)
2214 wxRect
preview(0, 0, 32, 32);
2215 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2217 preview
.x
= true_rect
.x
+ 4;
2218 preview
.y
= true_rect
.y
+ (true_rect
.height
- preview
.height
) / 2;
2222 preview
.x
= true_rect
.x
+ (true_rect
.width
- preview
.width
) / 2;
2223 preview
.y
= true_rect
.y
+ 4;
2226 *preview_rect
= preview
;
2228 wxCoord label_width
, label_height
;
2229 dc
.SetFont(m_panel_label_font
);
2230 dc
.GetTextExtent(wnd
->GetLabel(), &label_width
, &label_height
);
2232 int xpos
= true_rect
.x
+ (true_rect
.width
- label_width
+ 1) / 2;
2233 int ypos
= preview
.y
+ preview
.height
+ 5;
2235 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2237 xpos
= preview
.x
+ preview
.width
+ 5;
2238 ypos
= true_rect
.y
+ (true_rect
.height
- label_height
) / 2;
2241 dc
.SetTextForeground(m_panel_minimised_label_colour
);
2242 dc
.DrawText(wnd
->GetLabel(), xpos
, ypos
);
2245 wxPoint arrow_points
[3];
2246 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2248 xpos
+= label_width
;
2249 arrow_points
[0] = wxPoint(xpos
+ 5, ypos
+ label_height
/ 2);
2250 arrow_points
[1] = arrow_points
[0] + wxPoint(-3, 3);
2251 arrow_points
[2] = arrow_points
[0] + wxPoint(-3, -3);
2255 ypos
+= label_height
;
2256 arrow_points
[0] = wxPoint(true_rect
.width
/ 2, ypos
+ 5);
2257 arrow_points
[1] = arrow_points
[0] + wxPoint(-3, -3);
2258 arrow_points
[2] = arrow_points
[0] + wxPoint( 3, -3);
2261 dc
.SetPen(*wxTRANSPARENT_PEN
);
2262 wxBrush
B(m_panel_minimised_label_colour
);
2264 dc
.DrawPolygon(sizeof(arrow_points
)/sizeof(wxPoint
), arrow_points
,
2265 true_rect
.x
, true_rect
.y
);
2268 void wxRibbonMSWArtProvider::DrawButtonBarBackground(
2273 DrawPartialPageBackground(dc
, wnd
, rect
, true);
2276 void wxRibbonMSWArtProvider::DrawPartialPageBackground(
2282 // Assume the window is a child of a ribbon page, and also check for a
2283 // hovered panel somewhere between the window and the page, as it causes
2284 // the background to change.
2285 wxPoint
offset(wnd
->GetPosition());
2286 wxRibbonPage
* page
= NULL
;
2287 wxWindow
* parent
= wnd
->GetParent();
2288 wxRibbonPanel
* panel
= wxDynamicCast(wnd
, wxRibbonPanel
);
2289 bool hovered
= false;
2293 hovered
= allow_hovered
&& panel
->IsHovered();
2294 if(panel
->GetExpandedDummy() != NULL
)
2296 offset
= panel
->GetExpandedDummy()->GetPosition();
2297 parent
= panel
->GetExpandedDummy()->GetParent();
2300 for(; parent
; parent
= parent
->GetParent())
2304 panel
= wxDynamicCast(parent
, wxRibbonPanel
);
2307 hovered
= allow_hovered
&& panel
->IsHovered();
2308 if(panel
->GetExpandedDummy() != NULL
)
2310 parent
= panel
->GetExpandedDummy();
2314 page
= wxDynamicCast(parent
, wxRibbonPage
);
2319 offset
+= parent
->GetPosition();
2323 DrawPartialPageBackground(dc
, wnd
, rect
, page
, offset
, hovered
);
2327 // No page found - fallback to painting with a stock brush
2328 dc
.SetBrush(*wxWHITE_BRUSH
);
2329 dc
.SetPen(*wxTRANSPARENT_PEN
);
2330 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
2333 void wxRibbonMSWArtProvider::DrawButtonBarButton(
2335 wxWindow
* WXUNUSED(wnd
),
2337 wxRibbonButtonKind kind
,
2339 const wxString
& label
,
2340 const wxBitmap
& bitmap_large
,
2341 const wxBitmap
& bitmap_small
)
2343 if(kind
== wxRIBBON_BUTTON_TOGGLE
)
2345 kind
= wxRIBBON_BUTTON_NORMAL
;
2346 if(state
& wxRIBBON_BUTTONBAR_BUTTON_TOGGLED
)
2347 state
^= wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK
;
2350 if(state
& (wxRIBBON_BUTTONBAR_BUTTON_HOVER_MASK
|
2351 wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK
))
2353 if(state
& wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK
)
2354 dc
.SetPen(m_button_bar_active_border_pen
);
2356 dc
.SetPen(m_button_bar_hover_border_pen
);
2358 wxRect
bg_rect(rect
);
2362 bg_rect
.height
-= 2;
2364 wxRect
bg_rect_top(bg_rect
);
2365 bg_rect_top
.height
/= 3;
2366 bg_rect
.y
+= bg_rect_top
.height
;
2367 bg_rect
.height
-= bg_rect_top
.height
;
2369 if(kind
== wxRIBBON_BUTTON_HYBRID
)
2371 switch(state
& wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK
)
2373 case wxRIBBON_BUTTONBAR_BUTTON_LARGE
:
2375 int iYBorder
= rect
.y
+ bitmap_large
.GetHeight() + 4;
2376 wxRect
partial_bg(rect
);
2377 if(state
& wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED
)
2379 partial_bg
.SetBottom(iYBorder
- 1);
2383 partial_bg
.height
-= (iYBorder
- partial_bg
.y
+ 1);
2384 partial_bg
.y
= iYBorder
+ 1;
2386 dc
.DrawLine(rect
.x
, iYBorder
, rect
.x
+ rect
.width
, iYBorder
);
2387 bg_rect
.Intersect(partial_bg
);
2388 bg_rect_top
.Intersect(partial_bg
);
2391 case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM
:
2393 int iArrowWidth
= 9;
2394 if(state
& wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED
)
2396 bg_rect
.width
-= iArrowWidth
;
2397 bg_rect_top
.width
-= iArrowWidth
;
2398 dc
.DrawLine(bg_rect_top
.x
+ bg_rect_top
.width
,
2399 rect
.y
, bg_rect_top
.x
+ bg_rect_top
.width
,
2400 rect
.y
+ rect
.height
);
2405 bg_rect
.x
+= bg_rect
.width
- iArrowWidth
;
2406 bg_rect_top
.x
+= bg_rect_top
.width
- iArrowWidth
;
2407 bg_rect
.width
= iArrowWidth
;
2408 bg_rect_top
.width
= iArrowWidth
;
2409 dc
.DrawLine(bg_rect_top
.x
- 1, rect
.y
,
2410 bg_rect_top
.x
- 1, rect
.y
+ rect
.height
);
2414 case wxRIBBON_BUTTONBAR_BUTTON_SMALL
:
2419 if(state
& wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK
)
2421 dc
.GradientFillLinear(bg_rect_top
,
2422 m_button_bar_active_background_top_colour
,
2423 m_button_bar_active_background_top_gradient_colour
, wxSOUTH
);
2424 dc
.GradientFillLinear(bg_rect
,
2425 m_button_bar_active_background_colour
,
2426 m_button_bar_active_background_gradient_colour
, wxSOUTH
);
2430 dc
.GradientFillLinear(bg_rect_top
,
2431 m_button_bar_hover_background_top_colour
,
2432 m_button_bar_hover_background_top_gradient_colour
, wxSOUTH
);
2433 dc
.GradientFillLinear(bg_rect
,
2434 m_button_bar_hover_background_colour
,
2435 m_button_bar_hover_background_gradient_colour
, wxSOUTH
);
2438 wxPoint border_points
[9];
2439 border_points
[0] = wxPoint(2, 0);
2440 border_points
[1] = wxPoint(rect
.width
- 3, 0);
2441 border_points
[2] = wxPoint(rect
.width
- 1, 2);
2442 border_points
[3] = wxPoint(rect
.width
- 1, rect
.height
- 3);
2443 border_points
[4] = wxPoint(rect
.width
- 3, rect
.height
- 1);
2444 border_points
[5] = wxPoint(2, rect
.height
- 1);
2445 border_points
[6] = wxPoint(0, rect
.height
- 3);
2446 border_points
[7] = wxPoint(0, 2);
2447 border_points
[8] = border_points
[0];
2449 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
,
2453 dc
.SetFont(m_button_bar_label_font
);
2454 dc
.SetTextForeground(state
& wxRIBBON_BUTTONBAR_BUTTON_DISABLED
2455 ? m_button_bar_label_disabled_colour
2456 : m_button_bar_label_colour
);
2457 DrawButtonBarButtonForeground(dc
, rect
, kind
, state
, label
, bitmap_large
,
2461 void wxRibbonMSWArtProvider::DrawButtonBarButtonForeground(
2464 wxRibbonButtonKind kind
,
2466 const wxString
& label
,
2467 const wxBitmap
& bitmap_large
,
2468 const wxBitmap
& bitmap_small
)
2471 arrowColour(state
& wxRIBBON_BUTTONBAR_BUTTON_DISABLED
2472 ? m_button_bar_label_disabled_colour
2473 : m_button_bar_label_colour
);
2475 switch(state
& wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK
)
2477 case wxRIBBON_BUTTONBAR_BUTTON_LARGE
:
2479 const int padding
= 2;
2480 dc
.DrawBitmap(bitmap_large
,
2481 rect
.x
+ (rect
.width
- bitmap_large
.GetWidth()) / 2,
2482 rect
.y
+ padding
, true);
2483 int ypos
= rect
.y
+ padding
+ bitmap_large
.GetHeight() + padding
;
2484 int arrow_width
= kind
== wxRIBBON_BUTTON_NORMAL
? 0 : 8;
2485 wxCoord label_w
, label_h
;
2486 dc
.GetTextExtent(label
, &label_w
, &label_h
);
2487 if(label_w
+ 2 * padding
<= rect
.width
)
2489 dc
.DrawText(label
, rect
.x
+ (rect
.width
- label_w
) / 2, ypos
);
2490 if(arrow_width
!= 0)
2492 DrawDropdownArrow(dc
, rect
.x
+ rect
.width
/ 2,
2493 ypos
+ (label_h
* 3) / 2,
2499 size_t breaki
= label
.Len();
2503 if(wxRibbonCanLabelBreakAtPosition(label
, breaki
))
2505 wxString label_top
= label
.Mid(0, breaki
);
2506 dc
.GetTextExtent(label_top
, &label_w
, &label_h
);
2507 if(label_w
+ 2 * padding
<= rect
.width
)
2509 dc
.DrawText(label_top
,
2510 rect
.x
+ (rect
.width
- label_w
) / 2, ypos
);
2512 wxString label_bottom
= label
.Mid(breaki
+ 1);
2513 dc
.GetTextExtent(label_bottom
, &label_w
, &label_h
);
2514 label_w
+= arrow_width
;
2515 int iX
= rect
.x
+ (rect
.width
- label_w
) / 2;
2516 dc
.DrawText(label_bottom
, iX
, ypos
);
2517 if(arrow_width
!= 0)
2519 DrawDropdownArrow(dc
,
2520 iX
+ 2 +label_w
- arrow_width
,
2521 ypos
+ label_h
/ 2 + 1,
2527 } while(breaki
> 0);
2531 case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM
:
2533 int x_cursor
= rect
.x
+ 2;
2534 dc
.DrawBitmap(bitmap_small
, x_cursor
,
2535 rect
.y
+ (rect
.height
- bitmap_small
.GetHeight())/2, true);
2536 x_cursor
+= bitmap_small
.GetWidth() + 2;
2537 wxCoord label_w
, label_h
;
2538 dc
.GetTextExtent(label
, &label_w
, &label_h
);
2539 dc
.DrawText(label
, x_cursor
,
2540 rect
.y
+ (rect
.height
- label_h
) / 2);
2541 x_cursor
+= label_w
+ 3;
2542 if(kind
!= wxRIBBON_BUTTON_NORMAL
)
2544 DrawDropdownArrow(dc
, x_cursor
, rect
.y
+ rect
.height
/ 2, arrowColour
);
2554 void wxRibbonMSWArtProvider::DrawToolBarBackground(
2559 DrawPartialPageBackground(dc
, wnd
, rect
);
2562 void wxRibbonMSWArtProvider::DrawToolGroupBackground(
2564 wxWindow
* WXUNUSED(wnd
),
2567 dc
.SetPen(m_toolbar_border_pen
);
2569 outline
[0] = wxPoint(2, 0);
2570 outline
[1] = wxPoint(rect
.width
- 3, 0);
2571 outline
[2] = wxPoint(rect
.width
- 1, 2);
2572 outline
[3] = wxPoint(rect
.width
- 1, rect
.height
- 3);
2573 outline
[4] = wxPoint(rect
.width
- 3, rect
.height
- 1);
2574 outline
[5] = wxPoint(2, rect
.height
- 1);
2575 outline
[6] = wxPoint(0, rect
.height
- 3);
2576 outline
[7] = wxPoint(0, 2);
2577 outline
[8] = outline
[0];
2579 dc
.DrawLines(sizeof(outline
)/sizeof(wxPoint
), outline
, rect
.x
, rect
.y
);
2582 void wxRibbonMSWArtProvider::DrawTool(
2584 wxWindow
* WXUNUSED(wnd
),
2586 const wxBitmap
& bitmap
,
2587 wxRibbonButtonKind kind
,
2590 if(kind
== wxRIBBON_BUTTON_TOGGLE
)
2592 if(state
& wxRIBBON_TOOLBAR_TOOL_TOGGLED
)
2593 state
^= wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK
;
2596 wxRect
bg_rect(rect
);
2598 if((state
& wxRIBBON_TOOLBAR_TOOL_LAST
) == 0)
2600 bool is_split_hybrid
= (kind
== wxRIBBON_BUTTON_HYBRID
&& (state
&
2601 (wxRIBBON_TOOLBAR_TOOL_HOVER_MASK
| wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK
)));
2604 wxRect
bg_rect_top(bg_rect
);
2605 bg_rect_top
.height
= (bg_rect_top
.height
* 2) / 5;
2606 wxRect
bg_rect_btm(bg_rect
);
2607 bg_rect_btm
.y
+= bg_rect_top
.height
;
2608 bg_rect_btm
.height
-= bg_rect_top
.height
;
2609 wxColour bg_top_colour
= m_tool_background_top_colour
;
2610 wxColour bg_top_grad_colour
= m_tool_background_top_gradient_colour
;
2611 wxColour bg_colour
= m_tool_background_colour
;
2612 wxColour bg_grad_colour
= m_tool_background_gradient_colour
;
2613 if(state
& wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK
)
2615 bg_top_colour
= m_tool_active_background_top_colour
;
2616 bg_top_grad_colour
= m_tool_active_background_top_gradient_colour
;
2617 bg_colour
= m_tool_active_background_colour
;
2618 bg_grad_colour
= m_tool_active_background_gradient_colour
;
2620 else if(state
& wxRIBBON_TOOLBAR_TOOL_HOVER_MASK
)
2622 bg_top_colour
= m_tool_hover_background_top_colour
;
2623 bg_top_grad_colour
= m_tool_hover_background_top_gradient_colour
;
2624 bg_colour
= m_tool_hover_background_colour
;
2625 bg_grad_colour
= m_tool_hover_background_gradient_colour
;
2627 dc
.GradientFillLinear(bg_rect_top
, bg_top_colour
, bg_top_grad_colour
, wxSOUTH
);
2628 dc
.GradientFillLinear(bg_rect_btm
, bg_colour
, bg_grad_colour
, wxSOUTH
);
2631 wxRect
nonrect(bg_rect
);
2632 if(state
& (wxRIBBON_TOOLBAR_TOOL_DROPDOWN_HOVERED
|
2633 wxRIBBON_TOOLBAR_TOOL_DROPDOWN_ACTIVE
))
2639 nonrect
.x
+= nonrect
.width
- 8;
2642 wxBrush
B(m_tool_hover_background_top_colour
);
2643 dc
.SetPen(*wxTRANSPARENT_PEN
);
2645 dc
.DrawRectangle(nonrect
.x
, nonrect
.y
, nonrect
.width
, nonrect
.height
);
2649 dc
.SetPen(m_toolbar_border_pen
);
2650 if(state
& wxRIBBON_TOOLBAR_TOOL_FIRST
)
2652 dc
.DrawPoint(rect
.x
+ 1, rect
.y
+ 1);
2653 dc
.DrawPoint(rect
.x
+ 1, rect
.y
+ rect
.height
- 2);
2656 dc
.DrawLine(rect
.x
, rect
.y
+ 1, rect
.x
, rect
.y
+ rect
.height
- 1);
2658 if(state
& wxRIBBON_TOOLBAR_TOOL_LAST
)
2660 dc
.DrawPoint(rect
.x
+ rect
.width
- 2, rect
.y
+ 1);
2661 dc
.DrawPoint(rect
.x
+ rect
.width
- 2, rect
.y
+ rect
.height
- 2);
2665 int avail_width
= bg_rect
.GetWidth();
2666 if(kind
& wxRIBBON_BUTTON_DROPDOWN
)
2671 dc
.DrawLine(rect
.x
+ avail_width
+ 1, rect
.y
,
2672 rect
.x
+ avail_width
+ 1, rect
.y
+ rect
.height
);
2674 dc
.DrawBitmap(m_toolbar_drop_bitmap
, bg_rect
.x
+ avail_width
+ 2,
2675 bg_rect
.y
+ (bg_rect
.height
/ 2) - 2, true);
2677 dc
.DrawBitmap(bitmap
, bg_rect
.x
+ (avail_width
- bitmap
.GetWidth()) / 2,
2678 bg_rect
.y
+ (bg_rect
.height
- bitmap
.GetHeight()) / 2, true);
2682 wxRibbonMSWArtProvider::DrawToggleButton(wxDC
& dc
,
2685 wxRibbonDisplayMode mode
)
2688 DrawPartialPageBackground(dc
, wnd
, rect
, false);
2690 dc
.DestroyClippingRegion();
2691 dc
.SetClippingRegion(rect
);
2693 if(wnd
->IsToggleButtonHovered())
2695 dc
.SetPen(m_ribbon_toggle_pen
);
2696 dc
.SetBrush(m_ribbon_toggle_brush
);
2697 dc
.DrawRoundedRectangle(rect
.GetX(), rect
.GetY(), 20, 20, 1.0);
2702 case wxRIBBON_BAR_PINNED
:
2703 dc
.DrawBitmap(m_ribbon_toggle_up_bitmap
[bindex
], rect
.GetX()+7, rect
.GetY()+6, true);
2705 case wxRIBBON_BAR_MINIMIZED
:
2706 dc
.DrawBitmap(m_ribbon_toggle_down_bitmap
[bindex
], rect
.GetX()+7, rect
.GetY()+6, true);
2708 case wxRIBBON_BAR_EXPANDED
:
2709 dc
.DrawBitmap(m_ribbon_toggle_pin_bitmap
[bindex
], rect
.GetX ()+4, rect
.GetY ()+5, true);
2714 void wxRibbonMSWArtProvider::DrawHelpButton(wxDC
& dc
,
2718 DrawPartialPageBackground(dc
, wnd
, rect
, false);
2720 dc
.DestroyClippingRegion();
2721 dc
.SetClippingRegion(rect
);
2723 if ( wnd
->IsHelpButtonHovered() )
2725 dc
.SetPen(m_ribbon_toggle_pen
);
2726 dc
.SetBrush(m_ribbon_toggle_brush
);
2727 dc
.DrawRoundedRectangle(rect
.GetX(), rect
.GetY(), 20, 20, 1.0);
2728 dc
.DrawBitmap(m_ribbon_bar_help_button_bitmap
[1], rect
.GetX ()+4, rect
.GetY()+5, true);
2732 dc
.DrawBitmap(m_ribbon_bar_help_button_bitmap
[0], rect
.GetX ()+4, rect
.GetY()+5, true);
2737 void wxRibbonMSWArtProvider::GetBarTabWidth(
2739 wxWindow
* WXUNUSED(wnd
),
2740 const wxString
& label
,
2741 const wxBitmap
& bitmap
,
2743 int* small_begin_need_separator
,
2744 int* small_must_have_separator
,
2749 if((m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
) && !label
.IsEmpty())
2751 dc
.SetFont(m_tab_label_font
);
2752 width
+= dc
.GetTextExtent(label
).GetWidth();
2753 min
+= wxMin(25, width
); // enough for a few chars
2756 // gap between label and bitmap
2761 if((m_flags
& wxRIBBON_BAR_SHOW_PAGE_ICONS
) && bitmap
.IsOk())
2763 width
+= bitmap
.GetWidth();
2764 min
+= bitmap
.GetWidth();
2769 *ideal
= width
+ 30;
2771 if(small_begin_need_separator
!= NULL
)
2773 *small_begin_need_separator
= width
+ 20;
2775 if(small_must_have_separator
!= NULL
)
2777 *small_must_have_separator
= width
+ 10;
2785 int wxRibbonMSWArtProvider::GetTabCtrlHeight(
2787 wxWindow
* WXUNUSED(wnd
),
2788 const wxRibbonPageTabInfoArray
& pages
)
2790 int text_height
= 0;
2791 int icon_height
= 0;
2793 if(pages
.GetCount() <= 1 && (m_flags
& wxRIBBON_BAR_ALWAYS_SHOW_TABS
) == 0)
2795 // To preserve space, a single tab need not be displayed. We still need
2796 // two pixels of border / padding though.
2800 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
)
2802 dc
.SetFont(m_tab_label_font
);
2803 text_height
= dc
.GetTextExtent(wxT("ABCDEFXj")).GetHeight() + 10;
2805 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_ICONS
)
2807 size_t numpages
= pages
.GetCount();
2808 for(size_t i
= 0; i
< numpages
; ++i
)
2810 const wxRibbonPageTabInfo
& info
= pages
.Item(i
);
2811 if(info
.page
->GetIcon().IsOk())
2813 icon_height
= wxMax(icon_height
, info
.page
->GetIcon().GetHeight() + 4);
2818 return wxMax(text_height
, icon_height
);
2821 wxSize
wxRibbonMSWArtProvider::GetScrollButtonMinimumSize(
2823 wxWindow
* WXUNUSED(wnd
),
2824 long WXUNUSED(style
))
2826 return wxSize(12, 12);
2829 wxSize
wxRibbonMSWArtProvider::GetPanelSize(
2831 const wxRibbonPanel
* wnd
,
2833 wxPoint
* client_offset
)
2835 dc
.SetFont(m_panel_label_font
);
2836 wxSize label_size
= dc
.GetTextExtent(wnd
->GetLabel());
2838 client_size
.IncBy(0, label_size
.GetHeight());
2839 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2840 client_size
.IncBy(4, 8);
2842 client_size
.IncBy(6, 6);
2844 if(client_offset
!= NULL
)
2846 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2847 *client_offset
= wxPoint(2, 3);
2849 *client_offset
= wxPoint(3, 2);
2855 wxSize
wxRibbonMSWArtProvider::GetPanelClientSize(
2857 const wxRibbonPanel
* wnd
,
2859 wxPoint
* client_offset
)
2861 dc
.SetFont(m_panel_label_font
);
2862 wxSize label_size
= dc
.GetTextExtent(wnd
->GetLabel());
2864 size
.DecBy(0, label_size
.GetHeight());
2865 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2870 if(client_offset
!= NULL
)
2872 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2873 *client_offset
= wxPoint(2, 3);
2875 *client_offset
= wxPoint(3, 2);
2877 if (size
.x
< 0) size
.x
= 0;
2878 if (size
.y
< 0) size
.y
= 0;
2883 wxSize
wxRibbonMSWArtProvider::GetGallerySize(
2885 const wxRibbonGallery
* WXUNUSED(wnd
),
2888 client_size
.IncBy( 2, 1); // Left / top padding
2889 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2890 client_size
.IncBy(1, 16); // Right / bottom padding
2892 client_size
.IncBy(16, 1); // Right / bottom padding
2896 wxSize
wxRibbonMSWArtProvider::GetGalleryClientSize(
2898 const wxRibbonGallery
* WXUNUSED(wnd
),
2900 wxPoint
* client_offset
,
2901 wxRect
* scroll_up_button
,
2902 wxRect
* scroll_down_button
,
2903 wxRect
* extension_button
)
2908 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2910 // Flow is vertical - put buttons on bottom
2911 scroll_up
.y
= size
.GetHeight() - 15;
2912 scroll_up
.height
= 15;
2914 scroll_up
.width
= (size
.GetWidth() + 2) / 3;
2915 scroll_down
.y
= scroll_up
.y
;
2916 scroll_down
.height
= scroll_up
.height
;
2917 scroll_down
.x
= scroll_up
.x
+ scroll_up
.width
;
2918 scroll_down
.width
= scroll_up
.width
;
2919 extension
.y
= scroll_down
.y
;
2920 extension
.height
= scroll_down
.height
;
2921 extension
.x
= scroll_down
.x
+ scroll_down
.width
;
2922 extension
.width
= size
.GetWidth() - scroll_up
.width
- scroll_down
.width
;
2928 // Flow is horizontal - put buttons on right
2929 scroll_up
.x
= size
.GetWidth() - 15;
2930 scroll_up
.width
= 15;
2932 scroll_up
.height
= (size
.GetHeight() + 2) / 3;
2933 scroll_down
.x
= scroll_up
.x
;
2934 scroll_down
.width
= scroll_up
.width
;
2935 scroll_down
.y
= scroll_up
.y
+ scroll_up
.height
;
2936 scroll_down
.height
= scroll_up
.height
;
2937 extension
.x
= scroll_down
.x
;
2938 extension
.width
= scroll_down
.width
;
2939 extension
.y
= scroll_down
.y
+ scroll_down
.height
;
2940 extension
.height
= size
.GetHeight() - scroll_up
.height
- scroll_down
.height
;
2945 if(client_offset
!= NULL
)
2946 *client_offset
= wxPoint(2, 1);
2947 if(scroll_up_button
!= NULL
)
2948 *scroll_up_button
= scroll_up
;
2949 if(scroll_down_button
!= NULL
)
2950 *scroll_down_button
= scroll_down
;
2951 if(extension_button
!= NULL
)
2952 *extension_button
= extension
;
2957 wxRect
wxRibbonMSWArtProvider::GetPageBackgroundRedrawArea(
2959 const wxRibbonPage
* WXUNUSED(wnd
),
2960 wxSize page_old_size
,
2961 wxSize page_new_size
)
2963 wxRect new_rect
, old_rect
;
2965 if(page_new_size
.GetWidth() != page_old_size
.GetWidth())
2967 if(page_new_size
.GetHeight() != page_old_size
.GetHeight())
2969 // Width and height both changed - redraw everything
2970 return wxRect(page_new_size
);
2974 // Only width changed - redraw right hand side
2975 const int right_edge_width
= 4;
2977 new_rect
= wxRect(page_new_size
.GetWidth() - right_edge_width
, 0, right_edge_width
, page_new_size
.GetHeight());
2978 old_rect
= wxRect(page_old_size
.GetWidth() - right_edge_width
, 0, right_edge_width
, page_old_size
.GetHeight());
2983 if(page_new_size
.GetHeight() == page_old_size
.GetHeight())
2985 // Nothing changed (should never happen) - redraw nothing
2986 return wxRect(0, 0, 0, 0);
2990 // Height changed - need to redraw everything (as the background
2991 // gradient is done vertically).
2992 return page_new_size
;
2996 new_rect
.Union(old_rect
);
2997 new_rect
.Intersect(wxRect(page_new_size
));
3001 bool wxRibbonMSWArtProvider::GetButtonBarButtonSize(
3004 wxRibbonButtonKind kind
,
3005 wxRibbonButtonBarButtonState size
,
3006 const wxString
& label
,
3007 wxSize bitmap_size_large
,
3008 wxSize bitmap_size_small
,
3009 wxSize
* button_size
,
3010 wxRect
* normal_region
,
3011 wxRect
* dropdown_region
)
3013 const int drop_button_width
= 8;
3015 dc
.SetFont(m_button_bar_label_font
);
3016 switch(size
& wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK
)
3018 case wxRIBBON_BUTTONBAR_BUTTON_SMALL
:
3019 // Small bitmap, no label
3020 *button_size
= bitmap_size_small
+ wxSize(6, 4);
3023 case wxRIBBON_BUTTON_NORMAL
:
3024 case wxRIBBON_BUTTON_TOGGLE
:
3025 *normal_region
= wxRect(*button_size
);
3026 *dropdown_region
= wxRect(0, 0, 0, 0);
3028 case wxRIBBON_BUTTON_DROPDOWN
:
3029 *button_size
+= wxSize(drop_button_width
, 0);
3030 *dropdown_region
= wxRect(*button_size
);
3031 *normal_region
= wxRect(0, 0, 0, 0);
3033 case wxRIBBON_BUTTON_HYBRID
:
3034 *normal_region
= wxRect(*button_size
);
3035 *dropdown_region
= wxRect(button_size
->GetWidth(), 0,
3036 drop_button_width
, button_size
->GetHeight());
3037 *button_size
+= wxSize(drop_button_width
, 0);
3041 case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM
:
3042 // Small bitmap, with label to the right
3044 GetButtonBarButtonSize(dc
, wnd
, kind
, wxRIBBON_BUTTONBAR_BUTTON_SMALL
,
3045 label
, bitmap_size_large
, bitmap_size_small
, button_size
,
3046 normal_region
, dropdown_region
);
3047 int text_size
= dc
.GetTextExtent(label
).GetWidth();
3048 button_size
->SetWidth(button_size
->GetWidth() + text_size
);
3051 case wxRIBBON_BUTTON_DROPDOWN
:
3052 dropdown_region
->SetWidth(dropdown_region
->GetWidth() + text_size
);
3054 case wxRIBBON_BUTTON_HYBRID
:
3055 dropdown_region
->SetX(dropdown_region
->GetX() + text_size
);
3057 case wxRIBBON_BUTTON_NORMAL
:
3058 case wxRIBBON_BUTTON_TOGGLE
:
3059 normal_region
->SetWidth(normal_region
->GetWidth() + text_size
);
3064 case wxRIBBON_BUTTONBAR_BUTTON_LARGE
:
3065 // Large bitmap, with label below (possibly split over 2 lines)
3067 wxSize
icon_size(bitmap_size_large
);
3068 icon_size
+= wxSize(4, 4);
3069 wxCoord label_height
;
3071 dc
.GetTextExtent(label
, &best_width
, &label_height
);
3072 int last_line_extra_width
= 0;
3073 if(kind
!= wxRIBBON_BUTTON_NORMAL
&& kind
!= wxRIBBON_BUTTON_TOGGLE
)
3075 last_line_extra_width
+= 8;
3078 for(i
= 0; i
< label
.Len(); ++i
)
3080 if(wxRibbonCanLabelBreakAtPosition(label
, i
))
3083 dc
.GetTextExtent(label
.Left(i
)).GetWidth(),
3084 dc
.GetTextExtent(label
.Mid(i
+ 1)).GetWidth() + last_line_extra_width
);
3085 if(width
< best_width
)
3091 label_height
*= 2; // Assume two lines even when only one is used
3092 // (to give all buttons a consistent height)
3093 icon_size
.SetWidth(wxMax(icon_size
.GetWidth(), best_width
) + 6);
3094 icon_size
.SetHeight(icon_size
.GetHeight() + label_height
);
3095 *button_size
= icon_size
;
3098 case wxRIBBON_BUTTON_DROPDOWN
:
3099 *dropdown_region
= wxRect(icon_size
);
3101 case wxRIBBON_BUTTON_HYBRID
:
3102 *normal_region
= wxRect(icon_size
);
3103 normal_region
->height
-= 2 + label_height
;
3104 dropdown_region
->x
= 0;
3105 dropdown_region
->y
= normal_region
->height
;
3106 dropdown_region
->width
= icon_size
.GetWidth();
3107 dropdown_region
->height
= icon_size
.GetHeight() - normal_region
->height
;
3109 case wxRIBBON_BUTTON_NORMAL
:
3110 case wxRIBBON_BUTTON_TOGGLE
:
3111 *normal_region
= wxRect(icon_size
);
3120 wxSize
wxRibbonMSWArtProvider::GetMinimisedPanelMinimumSize(
3122 const wxRibbonPanel
* wnd
,
3123 wxSize
* desired_bitmap_size
,
3124 wxDirection
* expanded_panel_direction
)
3126 if(desired_bitmap_size
!= NULL
)
3128 *desired_bitmap_size
= wxSize(16, 16);
3130 if(expanded_panel_direction
!= NULL
)
3132 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
3133 *expanded_panel_direction
= wxEAST
;
3135 *expanded_panel_direction
= wxSOUTH
;
3137 wxSize
base_size(42, 42);
3139 dc
.SetFont(m_panel_label_font
);
3140 wxSize
label_size(dc
.GetTextExtent(wnd
->GetLabel()));
3141 label_size
.IncBy(2, 2); // Allow for differences between this DC and a paint DC
3142 label_size
.IncBy(6, 0); // Padding
3143 label_size
.y
*= 2; // Second line for dropdown button
3145 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
3147 // Label alongside icon
3148 return wxSize(base_size
.x
+ label_size
.x
,
3149 wxMax(base_size
.y
, label_size
.y
));
3153 // Label beneath icon
3154 return wxSize(wxMax(base_size
.x
, label_size
.x
),
3155 base_size
.y
+ label_size
.y
);
3159 wxSize
wxRibbonMSWArtProvider::GetToolSize(
3161 wxWindow
* WXUNUSED(wnd
),
3163 wxRibbonButtonKind kind
,
3164 bool WXUNUSED(is_first
),
3166 wxRect
* dropdown_region
)
3168 wxSize
size(bitmap_size
);
3172 if(kind
& wxRIBBON_BUTTON_DROPDOWN
)
3177 if(kind
== wxRIBBON_BUTTON_DROPDOWN
)
3178 *dropdown_region
= size
;
3180 *dropdown_region
= wxRect(size
.GetWidth() - 8, 0, 8, size
.GetHeight());
3186 *dropdown_region
= wxRect(0, 0, 0, 0);
3192 wxRibbonMSWArtProvider::GetBarToggleButtonArea(const wxRect
& rect
)
3194 wxRect rectOut
= wxRect(rect
.GetWidth()-m_toggle_button_offset
, 2, 20, 20);
3195 if ( (m_toggle_button_offset
==22) && (m_help_button_offset
==22) )
3196 m_help_button_offset
+= 22;
3201 wxRibbonMSWArtProvider::GetRibbonHelpButtonArea(const wxRect
& rect
)
3203 wxRect rectOut
= wxRect(rect
.GetWidth()-m_help_button_offset
, 2, 20, 20);
3204 if ( (m_toggle_button_offset
==22) && (m_help_button_offset
==22) )
3205 m_toggle_button_offset
+= 22;
3209 #endif // wxUSE_RIBBON