1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/ribbon/art_aui.cpp
3 // Purpose: AUI style art provider for ribbon interface
4 // Author: Peter Cawley
8 // Copyright: (C) Peter Cawley
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
18 #include "wx/ribbon/art.h"
22 #include "wx/ribbon/art_internal.h"
23 #include "wx/ribbon/bar.h"
24 #include "wx/ribbon/buttonbar.h"
25 #include "wx/ribbon/gallery.h"
26 #include "wx/ribbon/toolbar.h"
32 #include "wx/msw/private.h"
35 wxRibbonAUIArtProvider::wxRibbonAUIArtProvider()
36 : wxRibbonMSWArtProvider(false)
38 #if defined( __WXMAC__ ) && wxOSX_USE_COCOA_OR_CARBON
39 wxColor base_colour
= wxColour( wxMacCreateCGColorFromHITheme(kThemeBrushToolbarBackground
));
41 wxColor base_colour
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
);
44 SetColourScheme(base_colour
,
45 wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT
),
46 wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT
));
48 m_tab_active_label_font
= m_tab_label_font
;
49 m_tab_active_label_font
.SetWeight(wxFONTWEIGHT_BOLD
);
51 m_page_border_left
= 1;
52 m_page_border_right
= 1;
53 m_page_border_top
= 1;
54 m_page_border_bottom
= 2;
55 m_tab_separation_size
= 0;
57 m_gallery_bitmap_padding_left_size
= 3;
58 m_gallery_bitmap_padding_right_size
= 3;
59 m_gallery_bitmap_padding_top_size
= 3;
60 m_gallery_bitmap_padding_bottom_size
= 3;
63 wxRibbonAUIArtProvider::~wxRibbonAUIArtProvider()
67 wxRibbonArtProvider
* wxRibbonAUIArtProvider::Clone() const
69 wxRibbonAUIArtProvider
*copy
= new wxRibbonAUIArtProvider();
72 copy
->m_tab_ctrl_background_colour
= m_tab_ctrl_background_colour
;
73 copy
->m_tab_ctrl_background_gradient_colour
= m_tab_ctrl_background_gradient_colour
;
74 copy
->m_panel_label_background_colour
= m_panel_label_background_colour
;
75 copy
->m_panel_label_background_gradient_colour
= m_panel_label_background_gradient_colour
;
76 copy
->m_panel_hover_label_background_colour
= m_panel_hover_label_background_colour
;
77 copy
->m_panel_hover_label_background_gradient_colour
= m_panel_hover_label_background_gradient_colour
;
79 copy
->m_background_brush
= m_background_brush
;
80 copy
->m_tab_active_top_background_brush
= m_tab_active_top_background_brush
;
81 copy
->m_tab_hover_background_brush
= m_tab_hover_background_brush
;
82 copy
->m_button_bar_hover_background_brush
= m_button_bar_hover_background_brush
;
83 copy
->m_button_bar_active_background_brush
= m_button_bar_active_background_brush
;
84 copy
->m_gallery_button_active_background_brush
= m_gallery_button_active_background_brush
;
85 copy
->m_gallery_button_hover_background_brush
= m_gallery_button_hover_background_brush
;
86 copy
->m_gallery_button_disabled_background_brush
= m_gallery_button_disabled_background_brush
;
88 copy
->m_toolbar_hover_borden_pen
= m_toolbar_hover_borden_pen
;
89 copy
->m_tool_hover_background_brush
= m_tool_hover_background_brush
;
90 copy
->m_tool_active_background_brush
= m_tool_active_background_brush
;
95 void wxRibbonAUIArtProvider::SetFont(int id
, const wxFont
& font
)
97 wxRibbonMSWArtProvider::SetFont(id
, font
);
98 if(id
== wxRIBBON_ART_TAB_LABEL_FONT
)
100 m_tab_active_label_font
= m_tab_label_font
;
101 m_tab_active_label_font
.SetWeight(wxFONTWEIGHT_BOLD
);
105 wxColour
wxRibbonAUIArtProvider::GetColour(int id
) const
109 case wxRIBBON_ART_PAGE_BACKGROUND_COLOUR
:
110 case wxRIBBON_ART_PAGE_BACKGROUND_GRADIENT_COLOUR
:
111 return m_background_brush
.GetColour();
112 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_COLOUR
:
113 return m_tab_ctrl_background_colour
;
114 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_GRADIENT_COLOUR
:
115 return m_tab_ctrl_background_gradient_colour
;
116 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_COLOUR
:
117 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
118 return m_tab_active_top_background_brush
.GetColour();
119 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_COLOUR
:
120 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_GRADIENT_COLOUR
:
121 return m_tab_hover_background_brush
.GetColour();
122 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_COLOUR
:
123 return m_panel_label_background_colour
;
124 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_GRADIENT_COLOUR
:
125 return m_panel_label_background_gradient_colour
;
126 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_COLOUR
:
127 return m_panel_hover_label_background_colour
;
128 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_GRADIENT_COLOUR
:
129 return m_panel_hover_label_background_gradient_colour
;
130 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_COLOUR
:
131 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_GRADIENT_COLOUR
:
132 return m_button_bar_hover_background_brush
.GetColour();
133 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_COLOUR
:
134 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_GRADIENT_COLOUR
:
135 return m_gallery_button_hover_background_brush
.GetColour();
136 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_COLOUR
:
137 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
138 return m_gallery_button_active_background_brush
.GetColour();
139 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_COLOUR
:
140 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_GRADIENT_COLOUR
:
141 return m_gallery_button_disabled_background_brush
.GetColour();
143 return wxRibbonMSWArtProvider::GetColour(id
);
147 void wxRibbonAUIArtProvider::SetColour(int id
, const wxColor
& colour
)
151 case wxRIBBON_ART_PAGE_BACKGROUND_COLOUR
:
152 case wxRIBBON_ART_PAGE_BACKGROUND_GRADIENT_COLOUR
:
153 m_background_brush
.SetColour(colour
);
155 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_COLOUR
:
156 m_tab_ctrl_background_colour
= colour
;
158 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_GRADIENT_COLOUR
:
159 m_tab_ctrl_background_gradient_colour
= colour
;
161 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_COLOUR
:
162 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
163 m_tab_active_top_background_brush
.SetColour(colour
);
165 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_COLOUR
:
166 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_GRADIENT_COLOUR
:
167 m_tab_hover_background_brush
.SetColour(colour
);
169 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_COLOUR
:
170 m_panel_label_background_colour
= colour
;
172 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_GRADIENT_COLOUR
:
173 m_panel_label_background_gradient_colour
= colour
;
175 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_COLOUR
:
176 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_GRADIENT_COLOUR
:
177 m_button_bar_hover_background_brush
.SetColour(colour
);
179 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_COLOUR
:
180 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_GRADIENT_COLOUR
:
181 m_gallery_button_hover_background_brush
.SetColour(colour
);
183 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_COLOUR
:
184 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
185 m_gallery_button_active_background_brush
.SetColour(colour
);
187 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_COLOUR
:
188 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_GRADIENT_COLOUR
:
189 m_gallery_button_disabled_background_brush
.SetColour(colour
);
192 wxRibbonMSWArtProvider::SetColour(id
, colour
);
197 void wxRibbonAUIArtProvider::SetColourScheme(
198 const wxColour
& primary
,
199 const wxColour
& secondary
,
200 const wxColour
& tertiary
)
202 wxRibbonHSLColour
primary_hsl(primary
);
203 wxRibbonHSLColour
secondary_hsl(secondary
);
204 wxRibbonHSLColour
tertiary_hsl(tertiary
);
206 // Map primary & secondary luminance from [0, 1] to [0.15, 0.85]
207 primary_hsl
.luminance
= cos(primary_hsl
.luminance
* M_PI
) * -0.35 + 0.5;
208 secondary_hsl
.luminance
= cos(secondary_hsl
.luminance
* M_PI
) * -0.35 + 0.5;
210 // TODO: Remove next line once this provider stops piggybacking MSW
211 wxRibbonMSWArtProvider::SetColourScheme(primary
, secondary
, tertiary
);
213 #define LikePrimary(luminance) \
214 wxRibbonShiftLuminance(primary_hsl, luminance ## f).ToRGB()
215 #define LikeSecondary(luminance) \
216 wxRibbonShiftLuminance(secondary_hsl, luminance ## f).ToRGB()
218 m_tab_ctrl_background_colour
= LikePrimary(0.9);
219 m_tab_ctrl_background_gradient_colour
= LikePrimary(1.7);
220 m_tab_border_pen
= LikePrimary(0.75);
221 m_tab_label_colour
= LikePrimary(0.1);
222 m_tab_hover_background_top_colour
= primary_hsl
.ToRGB();
223 m_tab_hover_background_top_gradient_colour
= LikePrimary(1.6);
224 m_tab_hover_background_brush
= m_tab_hover_background_top_colour
;
225 m_tab_active_background_colour
= m_tab_ctrl_background_gradient_colour
;
226 m_tab_active_background_gradient_colour
= primary_hsl
.ToRGB();
227 m_tab_active_top_background_brush
= m_tab_active_background_colour
;
228 m_panel_label_colour
= m_tab_label_colour
;
229 m_panel_minimised_label_colour
= m_panel_label_colour
;
230 m_panel_hover_label_colour
= tertiary_hsl
.ToRGB();
231 m_page_border_pen
= m_tab_border_pen
;
232 m_panel_border_pen
= m_tab_border_pen
;
233 m_background_brush
= primary_hsl
.ToRGB();
234 m_page_hover_background_colour
= LikePrimary(1.5);
235 m_page_hover_background_gradient_colour
= LikePrimary(0.9);
236 m_panel_label_background_colour
= LikePrimary(0.85);
237 m_panel_label_background_gradient_colour
= LikePrimary(0.97);
238 m_panel_hover_label_background_gradient_colour
= secondary_hsl
.ToRGB();
239 m_panel_hover_label_background_colour
= secondary_hsl
.Lighter(0.2f
).ToRGB();
240 m_button_bar_hover_border_pen
= secondary_hsl
.ToRGB();
241 m_button_bar_hover_background_brush
= LikeSecondary(1.7);
242 m_button_bar_active_background_brush
= LikeSecondary(1.4);
243 m_button_bar_label_colour
= m_tab_label_colour
;
244 m_gallery_border_pen
= m_tab_border_pen
;
245 m_gallery_item_border_pen
= m_button_bar_hover_border_pen
;
246 m_gallery_hover_background_brush
= LikePrimary(1.2);
247 m_gallery_button_background_colour
= m_page_hover_background_colour
;
248 m_gallery_button_background_gradient_colour
= m_page_hover_background_gradient_colour
;
249 m_gallery_button_hover_background_brush
= m_button_bar_hover_background_brush
;
250 m_gallery_button_active_background_brush
= m_button_bar_active_background_brush
;
251 m_gallery_button_disabled_background_brush
= primary_hsl
.Desaturated(0.15f
).ToRGB();
252 SetColour(wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR
, LikePrimary(0.1));
253 SetColour(wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR
, wxColour(128, 128, 128));
254 SetColour(wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR
, LikeSecondary(0.1));
255 SetColour(wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR
, LikeSecondary(0.1));
256 m_toolbar_border_pen
= m_tab_border_pen
;
257 SetColour(wxRIBBON_ART_TOOLBAR_FACE_COLOUR
, LikePrimary(0.1));
258 m_tool_background_colour
= m_page_hover_background_colour
;
259 m_tool_background_gradient_colour
= m_page_hover_background_gradient_colour
;
260 m_toolbar_hover_borden_pen
= m_button_bar_hover_border_pen
;
261 m_tool_hover_background_brush
= m_button_bar_hover_background_brush
;
262 m_tool_active_background_brush
= m_button_bar_active_background_brush
;
268 void wxRibbonAUIArtProvider::DrawTabCtrlBackground(
270 wxWindow
* WXUNUSED(wnd
),
273 wxRect
gradient_rect(rect
);
274 gradient_rect
.height
--;
275 dc
.GradientFillLinear(gradient_rect
, m_tab_ctrl_background_colour
,
276 m_tab_ctrl_background_gradient_colour
, wxSOUTH
);
277 dc
.SetPen(m_tab_border_pen
);
278 dc
.DrawLine(rect
.x
, rect
.GetBottom(), rect
.GetRight()+1, rect
.GetBottom());
281 int wxRibbonAUIArtProvider::GetTabCtrlHeight(
283 wxWindow
* WXUNUSED(wnd
),
284 const wxRibbonPageTabInfoArray
& pages
)
289 if(pages
.GetCount() <= 1 && (m_flags
& wxRIBBON_BAR_ALWAYS_SHOW_TABS
) == 0)
291 // To preserve space, a single tab need not be displayed. We still need
292 // one pixel of border though.
296 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
)
298 dc
.SetFont(m_tab_active_label_font
);
299 text_height
= dc
.GetTextExtent(wxT("ABCDEFXj")).GetHeight();
301 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_ICONS
)
303 size_t numpages
= pages
.GetCount();
304 for(size_t i
= 0; i
< numpages
; ++i
)
306 const wxRibbonPageTabInfo
& info
= pages
.Item(i
);
307 if(info
.page
->GetIcon().IsOk())
309 icon_height
= wxMax(icon_height
, info
.page
->GetIcon().GetHeight());
314 return wxMax(text_height
, icon_height
) + 10;
317 void wxRibbonAUIArtProvider::DrawTab(wxDC
& dc
,
318 wxWindow
* WXUNUSED(wnd
),
319 const wxRibbonPageTabInfo
& tab
)
321 if(tab
.rect
.height
<= 1)
324 dc
.SetFont(m_tab_label_font
);
325 dc
.SetPen(*wxTRANSPARENT_PEN
);
326 if(tab
.active
|| tab
.hovered
)
330 dc
.SetFont(m_tab_active_label_font
);
331 dc
.SetBrush(m_background_brush
);
332 dc
.DrawRectangle(tab
.rect
.x
, tab
.rect
.y
+ tab
.rect
.height
- 1,
333 tab
.rect
.width
- 1, 1);
335 wxRect
grad_rect(tab
.rect
);
336 grad_rect
.height
-= 4;
337 grad_rect
.width
-= 1;
338 grad_rect
.height
/= 2;
339 grad_rect
.y
= grad_rect
.y
+ tab
.rect
.height
- grad_rect
.height
- 1;
340 dc
.SetBrush(m_tab_active_top_background_brush
);
341 dc
.DrawRectangle(tab
.rect
.x
, tab
.rect
.y
+ 3, tab
.rect
.width
- 1,
342 grad_rect
.y
- tab
.rect
.y
- 3);
343 dc
.GradientFillLinear(grad_rect
, m_tab_active_background_colour
,
344 m_tab_active_background_gradient_colour
, wxSOUTH
);
348 wxRect
btm_rect(tab
.rect
);
349 btm_rect
.height
-= 4;
351 btm_rect
.height
/= 2;
352 btm_rect
.y
= btm_rect
.y
+ tab
.rect
.height
- btm_rect
.height
- 1;
353 dc
.SetBrush(m_tab_hover_background_brush
);
354 dc
.DrawRectangle(btm_rect
.x
, btm_rect
.y
, btm_rect
.width
,
356 wxRect
grad_rect(tab
.rect
);
357 grad_rect
.width
-= 1;
359 grad_rect
.height
= btm_rect
.y
- grad_rect
.y
;
360 dc
.GradientFillLinear(grad_rect
, m_tab_hover_background_top_colour
,
361 m_tab_hover_background_top_gradient_colour
, wxSOUTH
);
364 wxPoint border_points
[5];
365 border_points
[0] = wxPoint(0, 3);
366 border_points
[1] = wxPoint(1, 2);
367 border_points
[2] = wxPoint(tab
.rect
.width
- 3, 2);
368 border_points
[3] = wxPoint(tab
.rect
.width
- 1, 4);
369 border_points
[4] = wxPoint(tab
.rect
.width
- 1, tab
.rect
.height
- 1);
371 dc
.SetPen(m_tab_border_pen
);
372 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
, tab
.rect
.x
, tab
.rect
.y
);
375 dc
.GetClippingBox(old_clip
);
376 bool is_first_tab
= false;
377 wxRibbonBar
* bar
= wxDynamicCast(tab
.page
->GetParent(), wxRibbonBar
);
378 if(bar
&& bar
->GetPage(0) == tab
.page
)
382 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_ICONS
)
384 icon
= tab
.page
->GetIcon();
385 if((m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
) == 0)
387 int x
= tab
.rect
.x
+ (tab
.rect
.width
- icon
.GetWidth()) / 2;
388 dc
.DrawBitmap(icon
, x
, tab
.rect
.y
+ 1 + (tab
.rect
.height
- 1 -
389 icon
.GetHeight()) / 2, true);
392 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
)
394 wxString label
= tab
.page
->GetLabel();
397 dc
.SetTextForeground(m_tab_label_colour
);
398 dc
.SetBackgroundMode(wxTRANSPARENT
);
402 offset
+= icon
.GetWidth() + 2;
405 dc
.GetTextExtent(label
, &text_width
, &text_height
);
406 int x
= (tab
.rect
.width
- 2 - text_width
- offset
) / 2;
411 int width
= tab
.rect
.width
- x
- 2;
412 x
+= tab
.rect
.x
+ offset
;
413 int y
= tab
.rect
.y
+ (tab
.rect
.height
- text_height
) / 2;
416 dc
.DrawBitmap(icon
, x
- offset
, tab
.rect
.y
+ (tab
.rect
.height
-
417 icon
.GetHeight()) / 2, true);
419 dc
.SetClippingRegion(x
, tab
.rect
.y
, width
, tab
.rect
.height
);
420 dc
.DrawText(label
, x
, y
);
424 // Draw the left hand edge of the tab only for the first tab (subsequent
425 // tabs use the right edge of the prior tab as their left edge). As this is
426 // outside the rectangle for the tab, only draw it if the leftmost part of
427 // the tab is within the clip rectangle (the clip region has to be cleared
428 // to draw outside the tab).
429 if(is_first_tab
&& old_clip
.x
<= tab
.rect
.x
430 && tab
.rect
.x
< old_clip
.x
+ old_clip
.width
)
432 dc
.DestroyClippingRegion();
433 dc
.DrawLine(tab
.rect
.x
- 1, tab
.rect
.y
+ 4, tab
.rect
.x
- 1,
434 tab
.rect
.y
+ tab
.rect
.height
- 1);
438 void wxRibbonAUIArtProvider::GetBarTabWidth(
440 wxWindow
* WXUNUSED(wnd
),
441 const wxString
& label
,
442 const wxBitmap
& bitmap
,
444 int* small_begin_need_separator
,
445 int* small_must_have_separator
,
450 if((m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
) && !label
.IsEmpty())
452 dc
.SetFont(m_tab_active_label_font
);
453 width
+= dc
.GetTextExtent(label
).GetWidth();
454 min
+= wxMin(30, width
); // enough for a few chars
457 // gap between label and bitmap
462 if((m_flags
& wxRIBBON_BAR_SHOW_PAGE_ICONS
) && bitmap
.IsOk())
464 width
+= bitmap
.GetWidth();
465 min
+= bitmap
.GetWidth();
472 if(small_begin_need_separator
!= NULL
)
474 *small_begin_need_separator
= min
;
476 if(small_must_have_separator
!= NULL
)
478 *small_must_have_separator
= min
;
486 void wxRibbonAUIArtProvider::DrawTabSeparator(
488 wxWindow
* WXUNUSED(wnd
),
489 const wxRect
& WXUNUSED(rect
),
490 double WXUNUSED(visibility
))
492 // No explicit separators between tabs
495 void wxRibbonAUIArtProvider::DrawPageBackground(
497 wxWindow
* WXUNUSED(wnd
),
500 dc
.SetPen(*wxTRANSPARENT_PEN
);
501 dc
.SetBrush(m_background_brush
);
502 dc
.DrawRectangle(rect
.x
+ 1, rect
.y
, rect
.width
- 2, rect
.height
- 1);
504 dc
.SetPen(m_page_border_pen
);
505 dc
.DrawLine(rect
.x
, rect
.y
, rect
.x
, rect
.y
+ rect
.height
);
506 dc
.DrawLine(rect
.GetRight(), rect
.y
, rect
.GetRight(), rect
.y
+rect
.height
);
507 dc
.DrawLine(rect
.x
, rect
.GetBottom(), rect
.GetRight()+1, rect
.GetBottom());
510 wxSize
wxRibbonAUIArtProvider::GetScrollButtonMinimumSize(
512 wxWindow
* WXUNUSED(wnd
),
513 long WXUNUSED(style
))
515 return wxSize(11, 11);
518 void wxRibbonAUIArtProvider::DrawScrollButton(
520 wxWindow
* WXUNUSED(wnd
),
524 wxRect
true_rect(rect
);
525 wxPoint arrow_points
[3];
527 if((style
& wxRIBBON_SCROLL_BTN_FOR_MASK
) == wxRIBBON_SCROLL_BTN_FOR_TABS
)
530 true_rect
.height
-= 2;
531 dc
.SetPen(m_tab_border_pen
);
535 dc
.SetPen(*wxTRANSPARENT_PEN
);
536 dc
.SetBrush(m_background_brush
);
537 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
538 dc
.SetPen(m_page_border_pen
);
541 switch(style
& wxRIBBON_SCROLL_BTN_DIRECTION_MASK
)
543 case wxRIBBON_SCROLL_BTN_LEFT
:
544 dc
.DrawLine(true_rect
.GetRight(), true_rect
.y
, true_rect
.GetRight(),
545 true_rect
.y
+ true_rect
.height
);
546 arrow_points
[0] = wxPoint(rect
.width
/ 2 - 2, rect
.height
/ 2);
547 arrow_points
[1] = arrow_points
[0] + wxPoint(5, -5);
548 arrow_points
[2] = arrow_points
[0] + wxPoint(5, 5);
550 case wxRIBBON_SCROLL_BTN_RIGHT
:
551 dc
.DrawLine(true_rect
.x
, true_rect
.y
, true_rect
.x
,
552 true_rect
.y
+ true_rect
.height
);
553 arrow_points
[0] = wxPoint(rect
.width
/ 2 + 3, rect
.height
/ 2);
554 arrow_points
[1] = arrow_points
[0] - wxPoint(5, -5);
555 arrow_points
[2] = arrow_points
[0] - wxPoint(5, 5);
557 case wxRIBBON_SCROLL_BTN_DOWN
:
558 dc
.DrawLine(true_rect
.x
, true_rect
.y
, true_rect
.x
+ true_rect
.width
,
560 arrow_points
[0] = wxPoint(rect
.width
/ 2, rect
.height
/ 2 + 3);
561 arrow_points
[1] = arrow_points
[0] - wxPoint( 5, 5);
562 arrow_points
[2] = arrow_points
[0] - wxPoint(-5, 5);
564 case wxRIBBON_SCROLL_BTN_UP
:
565 dc
.DrawLine(true_rect
.x
, true_rect
.GetBottom(),
566 true_rect
.x
+ true_rect
.width
, true_rect
.GetBottom());
567 arrow_points
[0] = wxPoint(rect
.width
/ 2, rect
.height
/ 2 - 2);
568 arrow_points
[1] = arrow_points
[0] + wxPoint( 5, 5);
569 arrow_points
[2] = arrow_points
[0] + wxPoint(-5, 5);
577 if(style
& wxRIBBON_SCROLL_BTN_ACTIVE
)
583 dc
.SetPen(*wxTRANSPARENT_PEN
);
584 wxBrush
B(m_tab_label_colour
);
586 dc
.DrawPolygon(sizeof(arrow_points
)/sizeof(wxPoint
), arrow_points
, x
, y
);
589 wxSize
wxRibbonAUIArtProvider::GetPanelSize(
591 const wxRibbonPanel
* wnd
,
593 wxPoint
* client_offset
)
595 dc
.SetFont(m_panel_label_font
);
596 wxSize label_size
= dc
.GetTextExtent(wnd
->GetLabel());
597 int label_height
= label_size
.GetHeight() + 5;
598 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
600 client_size
.IncBy(4, label_height
+ 6);
602 *client_offset
= wxPoint(2, label_height
+ 3);
606 client_size
.IncBy(6, label_height
+ 4);
608 *client_offset
= wxPoint(3, label_height
+ 2);
613 wxSize
wxRibbonAUIArtProvider::GetPanelClientSize(
615 const wxRibbonPanel
* wnd
,
617 wxPoint
* client_offset
)
619 dc
.SetFont(m_panel_label_font
);
620 wxSize label_size
= dc
.GetTextExtent(wnd
->GetLabel());
621 int label_height
= label_size
.GetHeight() + 5;
622 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
624 size
.DecBy(4, label_height
+ 6);
626 *client_offset
= wxPoint(2, label_height
+ 3);
630 size
.DecBy(6, label_height
+ 4);
632 *client_offset
= wxPoint(3, label_height
+ 2);
637 void wxRibbonAUIArtProvider::DrawPanelBackground(
642 dc
.SetPen(*wxTRANSPARENT_PEN
);
643 dc
.SetBrush(m_background_brush
);
644 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
646 wxRect
true_rect(rect
);
647 RemovePanelPadding(&true_rect
);
649 dc
.SetPen(m_panel_border_pen
);
650 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
651 dc
.DrawRectangle(true_rect
.x
, true_rect
.y
, true_rect
.width
, true_rect
.height
);
654 true_rect
.width
-= 2;
657 dc
.SetFont(m_panel_label_font
);
658 wxSize label_size
= dc
.GetTextExtent(wnd
->GetLabel());
659 int label_height
= label_size
.GetHeight() + 5;
660 wxRect
label_rect(true_rect
);
661 label_rect
.height
= label_height
- 1;
662 dc
.DrawLine(label_rect
.x
, label_rect
.y
+ label_rect
.height
,
663 label_rect
.x
+ label_rect
.width
, label_rect
.y
+ label_rect
.height
);
665 wxColour label_bg_colour
= m_panel_label_background_colour
;
666 wxColour label_bg_grad_colour
= m_panel_label_background_gradient_colour
;
669 label_bg_colour
= m_panel_hover_label_background_colour
;
670 label_bg_grad_colour
= m_panel_hover_label_background_gradient_colour
;
671 dc
.SetTextForeground(m_panel_hover_label_colour
);
675 dc
.SetTextForeground(m_panel_label_colour
);
677 dc
.GradientFillLinear(label_rect
,
679 label_bg_grad_colour
, label_bg_colour
, wxSOUTH
);
681 label_bg_colour
, label_bg_grad_colour
, wxSOUTH
);
683 dc
.SetFont(m_panel_label_font
);
684 dc
.DrawText(wnd
->GetLabel(), label_rect
.x
+ 3, label_rect
.y
+ 2);
688 wxRect
gradient_rect(true_rect
);
689 gradient_rect
.y
+= label_rect
.height
+ 1;
690 gradient_rect
.height
= true_rect
.height
- label_rect
.height
- 3;
692 wxColour colour
= m_page_hover_background_gradient_colour
;
693 wxColour gradient
= m_page_hover_background_colour
;
695 wxColour colour
= m_page_hover_background_colour
;
696 wxColour gradient
= m_page_hover_background_gradient_colour
;
698 dc
.GradientFillLinear(gradient_rect
, colour
, gradient
, wxSOUTH
);
702 void wxRibbonAUIArtProvider::DrawMinimisedPanel(
708 dc
.SetPen(*wxTRANSPARENT_PEN
);
709 dc
.SetBrush(m_background_brush
);
710 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
712 wxRect
true_rect(rect
);
713 RemovePanelPadding(&true_rect
);
715 dc
.SetPen(m_panel_border_pen
);
716 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
717 dc
.DrawRectangle(true_rect
.x
, true_rect
.y
, true_rect
.width
, true_rect
.height
);
718 true_rect
.Deflate(1);
720 if(wnd
->IsHovered() || wnd
->GetExpandedPanel())
722 wxColour colour
= m_page_hover_background_colour
;
723 wxColour gradient
= m_page_hover_background_gradient_colour
;
725 if(!wnd
->GetExpandedPanel())
727 if(wnd
->GetExpandedPanel())
730 wxColour temp
= colour
;
734 dc
.GradientFillLinear(true_rect
, colour
, gradient
, wxSOUTH
);
738 DrawMinimisedPanelCommon(dc
, wnd
, true_rect
, &preview
);
740 dc
.SetPen(m_panel_border_pen
);
741 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
742 dc
.DrawRectangle(preview
.x
, preview
.y
, preview
.width
, preview
.height
);
744 wxRect
preview_caption_rect(preview
);
745 preview_caption_rect
.height
= 7;
746 preview
.y
+= preview_caption_rect
.height
;
747 preview
.height
-= preview_caption_rect
.height
;
749 dc
.GradientFillLinear(preview_caption_rect
,
750 m_panel_hover_label_background_gradient_colour
,
751 m_panel_hover_label_background_colour
, wxSOUTH
);
752 dc
.GradientFillLinear(preview
,
753 m_page_hover_background_gradient_colour
,
754 m_page_hover_background_colour
, wxSOUTH
);
756 dc
.GradientFillLinear(preview_caption_rect
,
757 m_panel_hover_label_background_colour
,
758 m_panel_hover_label_background_gradient_colour
, wxSOUTH
);
759 dc
.GradientFillLinear(preview
,
760 m_page_hover_background_colour
,
761 m_page_hover_background_gradient_colour
, wxSOUTH
);
766 dc
.DrawBitmap(bitmap
, preview
.x
+ (preview
.width
- bitmap
.GetWidth()) / 2,
767 preview
.y
+ (preview
.height
- bitmap
.GetHeight()) / 2, true);
771 void wxRibbonAUIArtProvider::DrawPartialPanelBackground(wxDC
& dc
,
772 wxWindow
* wnd
, const wxRect
& rect
)
774 dc
.SetPen(*wxTRANSPARENT_PEN
);
775 dc
.SetBrush(m_background_brush
);
776 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
778 wxPoint
offset(wnd
->GetPosition());
779 wxWindow
* parent
= wnd
->GetParent();
780 wxRibbonPanel
* panel
= NULL
;
782 for(; parent
; parent
= parent
->GetParent())
784 panel
= wxDynamicCast(parent
, wxRibbonPanel
);
787 if(!panel
->IsHovered())
791 offset
+= parent
->GetPosition();
796 wxRect
background(panel
->GetSize());
797 RemovePanelPadding(&background
);
799 background
.width
-= 2;
800 dc
.SetFont(m_panel_label_font
);
801 int caption_height
= dc
.GetTextExtent(panel
->GetLabel()).GetHeight() + 7;
802 background
.y
+= caption_height
- 1;
803 background
.height
-= caption_height
;
805 wxRect
paint_rect(rect
);
806 paint_rect
.x
+= offset
.x
;
807 paint_rect
.y
+= offset
.y
;
809 wxColour bg_clr
, bg_grad_clr
;
811 bg_grad_clr
= m_page_hover_background_colour
;
812 bg_clr
= m_page_hover_background_gradient_colour
;
814 bg_clr
= m_page_hover_background_colour
;
815 bg_grad_clr
= m_page_hover_background_gradient_colour
;
818 paint_rect
.Intersect(background
);
819 if(!paint_rect
.IsEmpty())
821 wxColour
starting_colour(wxRibbonInterpolateColour(bg_clr
, bg_grad_clr
,
822 paint_rect
.y
, background
.y
, background
.y
+ background
.height
));
823 wxColour
ending_colour(wxRibbonInterpolateColour(bg_clr
, bg_grad_clr
,
824 paint_rect
.y
+ paint_rect
.height
, background
.y
,
825 background
.y
+ background
.height
));
826 paint_rect
.x
-= offset
.x
;
827 paint_rect
.y
-= offset
.y
;
828 dc
.GradientFillLinear(paint_rect
, starting_colour
, ending_colour
833 void wxRibbonAUIArtProvider::DrawGalleryBackground(
835 wxRibbonGallery
* wnd
,
838 DrawPartialPanelBackground(dc
, wnd
, rect
);
842 dc
.SetPen(*wxTRANSPARENT_PEN
);
843 dc
.SetBrush(m_gallery_hover_background_brush
);
844 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
846 dc
.DrawRectangle(rect
.x
+ 1, rect
.y
+ 1, rect
.width
- 2,
851 dc
.DrawRectangle(rect
.x
+ 1, rect
.y
+ 1, rect
.width
- 16,
856 dc
.SetPen(m_gallery_border_pen
);
857 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
858 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
860 DrawGalleryBackgroundCommon(dc
, wnd
, rect
);
863 void wxRibbonAUIArtProvider::DrawGalleryButton(wxDC
& dc
, wxRect rect
,
864 wxRibbonGalleryButtonState state
, wxBitmap
* bitmaps
)
866 int extra_height
= 0;
868 wxRect
reduced_rect(rect
);
869 reduced_rect
.Deflate(1);
870 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
872 reduced_rect
.width
++;
877 reduced_rect
.height
++;
884 case wxRIBBON_GALLERY_BUTTON_NORMAL
:
885 dc
.GradientFillLinear(reduced_rect
,
886 m_gallery_button_background_colour
,
887 m_gallery_button_background_gradient_colour
, wxSOUTH
);
888 btn_bitmap
= bitmaps
[0];
890 case wxRIBBON_GALLERY_BUTTON_HOVERED
:
891 dc
.SetPen(m_gallery_item_border_pen
);
892 dc
.SetBrush(m_gallery_button_hover_background_brush
);
893 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
+ extra_width
,
894 rect
.height
+ extra_height
);
895 btn_bitmap
= bitmaps
[1];
897 case wxRIBBON_GALLERY_BUTTON_ACTIVE
:
898 dc
.SetPen(m_gallery_item_border_pen
);
899 dc
.SetBrush(m_gallery_button_active_background_brush
);
900 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
+ extra_width
,
901 rect
.height
+ extra_height
);
902 btn_bitmap
= bitmaps
[2];
904 case wxRIBBON_GALLERY_BUTTON_DISABLED
:
905 dc
.SetPen(*wxTRANSPARENT_PEN
);
906 dc
.SetBrush(m_gallery_button_disabled_background_brush
);
907 dc
.DrawRectangle(reduced_rect
.x
, reduced_rect
.y
, reduced_rect
.width
,
908 reduced_rect
.height
);
909 btn_bitmap
= bitmaps
[3];
913 dc
.DrawBitmap(btn_bitmap
, reduced_rect
.x
+ reduced_rect
.width
/ 2 - 2,
914 (rect
.y
+ rect
.height
/ 2) - 2, true);
917 void wxRibbonAUIArtProvider::DrawGalleryItemBackground(
919 wxRibbonGallery
* wnd
,
921 wxRibbonGalleryItem
* item
)
923 if(wnd
->GetHoveredItem() != item
&& wnd
->GetActiveItem() != item
&&
924 wnd
->GetSelection() != item
)
927 dc
.SetPen(m_gallery_item_border_pen
);
928 if(wnd
->GetActiveItem() == item
|| wnd
->GetSelection() == item
)
929 dc
.SetBrush(m_gallery_button_active_background_brush
);
931 dc
.SetBrush(m_gallery_button_hover_background_brush
);
933 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
936 void wxRibbonAUIArtProvider::DrawButtonBarBackground(
941 DrawPartialPanelBackground(dc
, wnd
, rect
);
944 void wxRibbonAUIArtProvider::DrawButtonBarButton(
946 wxWindow
* WXUNUSED(wnd
),
948 wxRibbonButtonKind kind
,
950 const wxString
& label
,
951 const wxBitmap
& bitmap_large
,
952 const wxBitmap
& bitmap_small
)
954 if(state
& (wxRIBBON_BUTTONBAR_BUTTON_HOVER_MASK
955 | wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK
))
957 dc
.SetPen(m_button_bar_hover_border_pen
);
959 wxRect
bg_rect(rect
);
962 if(kind
== wxRIBBON_BUTTON_HYBRID
)
964 switch(state
& wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK
)
966 case wxRIBBON_BUTTONBAR_BUTTON_LARGE
:
968 int iYBorder
= rect
.y
+ bitmap_large
.GetHeight() + 4;
969 wxRect
partial_bg(rect
);
970 if(state
& wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED
)
972 partial_bg
.SetBottom(iYBorder
- 1);
976 partial_bg
.height
-= (iYBorder
- partial_bg
.y
+ 1);
977 partial_bg
.y
= iYBorder
+ 1;
979 dc
.DrawLine(rect
.x
, iYBorder
, rect
.x
+ rect
.width
, iYBorder
);
980 bg_rect
.Intersect(partial_bg
);
983 case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM
:
986 if(state
& wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED
)
988 bg_rect
.width
-= iArrowWidth
;
989 dc
.DrawLine(bg_rect
.x
+ bg_rect
.width
,
990 rect
.y
, bg_rect
.x
+ bg_rect
.width
,
991 rect
.y
+ rect
.height
);
996 bg_rect
.x
+= bg_rect
.width
- iArrowWidth
;
997 bg_rect
.width
= iArrowWidth
;
998 dc
.DrawLine(bg_rect
.x
- 1, rect
.y
,
999 bg_rect
.x
- 1, rect
.y
+ rect
.height
);
1003 case wxRIBBON_BUTTONBAR_BUTTON_SMALL
:
1008 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
1009 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
1011 dc
.SetPen(*wxTRANSPARENT_PEN
);
1012 if(state
& wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK
)
1013 dc
.SetBrush(m_button_bar_active_background_brush
);
1015 dc
.SetBrush(m_button_bar_hover_background_brush
);
1016 dc
.DrawRectangle(bg_rect
.x
, bg_rect
.y
, bg_rect
.width
, bg_rect
.height
);
1019 dc
.SetFont(m_button_bar_label_font
);
1020 dc
.SetTextForeground(m_button_bar_label_colour
);
1021 DrawButtonBarButtonForeground(dc
, rect
, kind
, state
, label
, bitmap_large
,
1025 void wxRibbonAUIArtProvider::DrawToolBarBackground(
1030 DrawPartialPanelBackground(dc
, wnd
, rect
);
1033 void wxRibbonAUIArtProvider::DrawToolGroupBackground(
1035 wxWindow
* WXUNUSED(wnd
),
1038 dc
.SetPen(m_toolbar_border_pen
);
1039 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
1040 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
1041 wxRect
bg_rect(rect
);
1043 dc
.GradientFillLinear(bg_rect
, m_tool_background_colour
,
1044 m_tool_background_gradient_colour
, wxSOUTH
);
1047 void wxRibbonAUIArtProvider::DrawTool(
1049 wxWindow
* WXUNUSED(wnd
),
1051 const wxBitmap
& bitmap
,
1052 wxRibbonButtonKind kind
,
1055 wxRect
bg_rect(rect
);
1057 if((state
& wxRIBBON_TOOLBAR_TOOL_LAST
) == 0)
1059 bool is_custom_bg
= (state
& (wxRIBBON_TOOLBAR_TOOL_HOVER_MASK
|
1060 wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK
)) != 0;
1061 bool is_split_hybrid
= kind
== wxRIBBON_BUTTON_HYBRID
&& is_custom_bg
;
1066 dc
.SetPen(*wxTRANSPARENT_PEN
);
1067 dc
.SetBrush(m_tool_hover_background_brush
);
1068 dc
.DrawRectangle(bg_rect
.x
, bg_rect
.y
, bg_rect
.width
, bg_rect
.height
);
1069 if(state
& wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK
)
1071 wxRect
active_rect(bg_rect
);
1072 if(kind
== wxRIBBON_BUTTON_HYBRID
)
1074 active_rect
.width
-= 8;
1075 if(state
& wxRIBBON_TOOLBAR_TOOL_DROPDOWN_ACTIVE
)
1077 active_rect
.x
+= active_rect
.width
;
1078 active_rect
.width
= 8;
1081 dc
.SetBrush(m_tool_active_background_brush
);
1082 dc
.DrawRectangle(active_rect
.x
, active_rect
.y
, active_rect
.width
,
1083 active_rect
.height
);
1089 dc
.SetPen(m_toolbar_hover_borden_pen
);
1091 dc
.SetPen(m_toolbar_border_pen
);
1092 if((state
& wxRIBBON_TOOLBAR_TOOL_FIRST
) == 0)
1095 if(!dc
.GetPixel(rect
.x
, rect
.y
+ 1, &existing
) ||
1096 existing
!= m_toolbar_hover_borden_pen
.GetColour())
1098 dc
.DrawLine(rect
.x
, rect
.y
+ 1, rect
.x
, rect
.y
+ rect
.height
- 1);
1103 wxRect
border_rect(bg_rect
);
1104 border_rect
.Inflate(1);
1105 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
1106 dc
.DrawRectangle(border_rect
.x
, border_rect
.y
, border_rect
.width
,
1107 border_rect
.height
);
1111 int avail_width
= bg_rect
.GetWidth();
1112 if(kind
!= wxRIBBON_BUTTON_NORMAL
)
1117 dc
.DrawLine(rect
.x
+ avail_width
+ 1, rect
.y
,
1118 rect
.x
+ avail_width
+ 1, rect
.y
+ rect
.height
);
1120 dc
.DrawBitmap(m_toolbar_drop_bitmap
, bg_rect
.x
+ avail_width
+ 2,
1121 bg_rect
.y
+ (bg_rect
.height
/ 2) - 2, true);
1123 dc
.DrawBitmap(bitmap
, bg_rect
.x
+ (avail_width
- bitmap
.GetWidth()) / 2,
1124 bg_rect
.y
+ (bg_rect
.height
- bitmap
.GetHeight()) / 2, true);
1127 #endif // wxUSE_RIBBON