move everything inside wxUSE_RIBBON wrapper
[wxWidgets.git] / src / ribbon / art_aui.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/ribbon/art_aui.cpp
3 // Purpose: AUI style art provider for ribbon interface
4 // Author: Peter Cawley
5 // Modified by:
6 // Created: 2009-08-04
7 // RCS-ID: $Id$
8 // Copyright: (C) Peter Cawley
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13
14 #ifdef __BORLANDC__
15 #pragma hdrstop
16 #endif
17
18 #if wxUSE_RIBBON
19
20 #include "wx/ribbon/art.h"
21 #include "wx/ribbon/art_internal.h"
22 #include "wx/ribbon/bar.h"
23 #include "wx/ribbon/buttonbar.h"
24 #include "wx/ribbon/gallery.h"
25 #include "wx/ribbon/toolbar.h"
26
27 #ifndef WX_PRECOMP
28 #include "wx/dc.h"
29 #include "wx/settings.h"
30 #endif
31
32 #ifdef __WXMSW__
33 #include "wx/msw/private.h"
34 #elif defined(__WXMAC__)
35 #include "wx/osx/private.h"
36 // only for kThemeBrushToolbarBackground
37 #include <Carbon/Carbon.h>
38 #endif
39
40 wxRibbonAUIArtProvider::wxRibbonAUIArtProvider()
41 : wxRibbonMSWArtProvider(false)
42 {
43 #if defined( __WXMAC__ ) && wxOSX_USE_COCOA_OR_CARBON
44 wxColor base_colour = wxColour( wxMacCreateCGColorFromHITheme(kThemeBrushToolbarBackground));
45 #else
46 wxColor base_colour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
47 #endif
48
49 SetColourScheme(base_colour,
50 wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT),
51 wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
52
53 m_tab_active_label_font = m_tab_label_font;
54 m_tab_active_label_font.SetWeight(wxFONTWEIGHT_BOLD);
55
56 m_page_border_left = 1;
57 m_page_border_right = 1;
58 m_page_border_top = 1;
59 m_page_border_bottom = 2;
60 m_tab_separation_size = 0;
61
62 m_gallery_bitmap_padding_left_size = 3;
63 m_gallery_bitmap_padding_right_size = 3;
64 m_gallery_bitmap_padding_top_size = 3;
65 m_gallery_bitmap_padding_bottom_size = 3;
66 }
67
68 wxRibbonAUIArtProvider::~wxRibbonAUIArtProvider()
69 {
70 }
71
72 wxRibbonArtProvider* wxRibbonAUIArtProvider::Clone() const
73 {
74 wxRibbonAUIArtProvider *copy = new wxRibbonAUIArtProvider();
75 CloneTo(copy);
76
77 copy->m_tab_ctrl_background_colour = m_tab_ctrl_background_colour;
78 copy->m_tab_ctrl_background_gradient_colour = m_tab_ctrl_background_gradient_colour;
79 copy->m_panel_label_background_colour = m_panel_label_background_colour;
80 copy->m_panel_label_background_gradient_colour = m_panel_label_background_gradient_colour;
81 copy->m_panel_hover_label_background_colour = m_panel_hover_label_background_colour;
82 copy->m_panel_hover_label_background_gradient_colour = m_panel_hover_label_background_gradient_colour;
83
84 copy->m_background_brush = m_background_brush;
85 copy->m_tab_active_top_background_brush = m_tab_active_top_background_brush;
86 copy->m_tab_hover_background_brush = m_tab_hover_background_brush;
87 copy->m_button_bar_hover_background_brush = m_button_bar_hover_background_brush;
88 copy->m_button_bar_active_background_brush = m_button_bar_active_background_brush;
89 copy->m_gallery_button_active_background_brush = m_gallery_button_active_background_brush;
90 copy->m_gallery_button_hover_background_brush = m_gallery_button_hover_background_brush;
91 copy->m_gallery_button_disabled_background_brush = m_gallery_button_disabled_background_brush;
92
93 copy->m_toolbar_hover_borden_pen = m_toolbar_hover_borden_pen;
94 copy->m_tool_hover_background_brush = m_tool_hover_background_brush;
95 copy->m_tool_active_background_brush = m_tool_active_background_brush;
96
97 return copy;
98 }
99
100 void wxRibbonAUIArtProvider::SetFont(int id, const wxFont& font)
101 {
102 wxRibbonMSWArtProvider::SetFont(id, font);
103 if(id == wxRIBBON_ART_TAB_LABEL_FONT)
104 {
105 m_tab_active_label_font = m_tab_label_font;
106 m_tab_active_label_font.SetWeight(wxFONTWEIGHT_BOLD);
107 }
108 }
109
110 wxColour wxRibbonAUIArtProvider::GetColour(int id) const
111 {
112 switch(id)
113 {
114 case wxRIBBON_ART_PAGE_BACKGROUND_COLOUR:
115 case wxRIBBON_ART_PAGE_BACKGROUND_GRADIENT_COLOUR:
116 return m_background_brush.GetColour();
117 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_COLOUR:
118 return m_tab_ctrl_background_colour;
119 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_GRADIENT_COLOUR:
120 return m_tab_ctrl_background_gradient_colour;
121 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_COLOUR:
122 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR:
123 return m_tab_active_top_background_brush.GetColour();
124 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_COLOUR:
125 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_GRADIENT_COLOUR:
126 return m_tab_hover_background_brush.GetColour();
127 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_COLOUR:
128 return m_panel_label_background_colour;
129 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_GRADIENT_COLOUR:
130 return m_panel_label_background_gradient_colour;
131 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_COLOUR:
132 return m_panel_hover_label_background_colour;
133 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_GRADIENT_COLOUR:
134 return m_panel_hover_label_background_gradient_colour;
135 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_COLOUR:
136 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_GRADIENT_COLOUR:
137 return m_button_bar_hover_background_brush.GetColour();
138 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_COLOUR:
139 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_GRADIENT_COLOUR:
140 return m_gallery_button_hover_background_brush.GetColour();
141 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_COLOUR:
142 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_GRADIENT_COLOUR:
143 return m_gallery_button_active_background_brush.GetColour();
144 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_COLOUR:
145 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_GRADIENT_COLOUR:
146 return m_gallery_button_disabled_background_brush.GetColour();
147 default:
148 return wxRibbonMSWArtProvider::GetColour(id);
149 }
150 }
151
152 void wxRibbonAUIArtProvider::SetColour(int id, const wxColor& colour)
153 {
154 switch(id)
155 {
156 case wxRIBBON_ART_PAGE_BACKGROUND_COLOUR:
157 case wxRIBBON_ART_PAGE_BACKGROUND_GRADIENT_COLOUR:
158 m_background_brush.SetColour(colour);
159 break;
160 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_COLOUR:
161 m_tab_ctrl_background_colour = colour;
162 break;
163 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_GRADIENT_COLOUR:
164 m_tab_ctrl_background_gradient_colour = colour;
165 break;
166 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_COLOUR:
167 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR:
168 m_tab_active_top_background_brush.SetColour(colour);
169 break;
170 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_COLOUR:
171 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_GRADIENT_COLOUR:
172 m_tab_hover_background_brush.SetColour(colour);
173 break;
174 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_COLOUR:
175 m_panel_label_background_colour = colour;
176 break;
177 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_GRADIENT_COLOUR:
178 m_panel_label_background_gradient_colour = colour;
179 break;
180 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_COLOUR:
181 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_GRADIENT_COLOUR:
182 m_button_bar_hover_background_brush.SetColour(colour);
183 break;
184 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_COLOUR:
185 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_GRADIENT_COLOUR:
186 m_gallery_button_hover_background_brush.SetColour(colour);
187 break;
188 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_COLOUR:
189 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_GRADIENT_COLOUR:
190 m_gallery_button_active_background_brush.SetColour(colour);
191 break;
192 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_COLOUR:
193 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_GRADIENT_COLOUR:
194 m_gallery_button_disabled_background_brush.SetColour(colour);
195 break;
196 default:
197 wxRibbonMSWArtProvider::SetColour(id, colour);
198 break;
199 }
200 }
201
202 void wxRibbonAUIArtProvider::SetColourScheme(
203 const wxColour& primary,
204 const wxColour& secondary,
205 const wxColour& tertiary)
206 {
207 wxRibbonHSLColour primary_hsl(primary);
208 wxRibbonHSLColour secondary_hsl(secondary);
209 wxRibbonHSLColour tertiary_hsl(tertiary);
210
211 // Map primary & secondary luminance from [0, 1] to [0.15, 0.85]
212 primary_hsl.luminance = cos(primary_hsl.luminance * M_PI) * -0.35 + 0.5;
213 secondary_hsl.luminance = cos(secondary_hsl.luminance * M_PI) * -0.35 + 0.5;
214
215 // TODO: Remove next line once this provider stops piggybacking MSW
216 wxRibbonMSWArtProvider::SetColourScheme(primary, secondary, tertiary);
217
218 #define LikePrimary(luminance) \
219 wxRibbonShiftLuminance(primary_hsl, luminance ## f).ToRGB()
220 #define LikeSecondary(luminance) \
221 wxRibbonShiftLuminance(secondary_hsl, luminance ## f).ToRGB()
222
223 m_tab_ctrl_background_colour = LikePrimary(0.9);
224 m_tab_ctrl_background_gradient_colour = LikePrimary(1.7);
225 m_tab_border_pen = LikePrimary(0.75);
226 m_tab_label_colour = LikePrimary(0.1);
227 m_tab_hover_background_top_colour = primary_hsl.ToRGB();
228 m_tab_hover_background_top_gradient_colour = LikePrimary(1.6);
229 m_tab_hover_background_brush = m_tab_hover_background_top_colour;
230 m_tab_active_background_colour = m_tab_ctrl_background_gradient_colour;
231 m_tab_active_background_gradient_colour = primary_hsl.ToRGB();
232 m_tab_active_top_background_brush = m_tab_active_background_colour;
233 m_panel_label_colour = m_tab_label_colour;
234 m_panel_minimised_label_colour = m_panel_label_colour;
235 m_panel_hover_label_colour = tertiary_hsl.ToRGB();
236 m_page_border_pen = m_tab_border_pen;
237 m_panel_border_pen = m_tab_border_pen;
238 m_background_brush = primary_hsl.ToRGB();
239 m_page_hover_background_colour = LikePrimary(1.5);
240 m_page_hover_background_gradient_colour = LikePrimary(0.9);
241 m_panel_label_background_colour = LikePrimary(0.85);
242 m_panel_label_background_gradient_colour = LikePrimary(0.97);
243 m_panel_hover_label_background_gradient_colour = secondary_hsl.ToRGB();
244 m_panel_hover_label_background_colour = secondary_hsl.Lighter(0.2f).ToRGB();
245 m_button_bar_hover_border_pen = secondary_hsl.ToRGB();
246 m_button_bar_hover_background_brush = LikeSecondary(1.7);
247 m_button_bar_active_background_brush = LikeSecondary(1.4);
248 m_button_bar_label_colour = m_tab_label_colour;
249 m_gallery_border_pen = m_tab_border_pen;
250 m_gallery_item_border_pen = m_button_bar_hover_border_pen;
251 m_gallery_hover_background_brush = LikePrimary(1.2);
252 m_gallery_button_background_colour = m_page_hover_background_colour;
253 m_gallery_button_background_gradient_colour = m_page_hover_background_gradient_colour;
254 m_gallery_button_hover_background_brush = m_button_bar_hover_background_brush;
255 m_gallery_button_active_background_brush = m_button_bar_active_background_brush;
256 m_gallery_button_disabled_background_brush = primary_hsl.Desaturated(0.15f).ToRGB();
257 SetColour(wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR, LikePrimary(0.1));
258 SetColour(wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR, wxColour(128, 128, 128));
259 SetColour(wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR, LikeSecondary(0.1));
260 SetColour(wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR, LikeSecondary(0.1));
261 m_toolbar_border_pen = m_tab_border_pen;
262 SetColour(wxRIBBON_ART_TOOLBAR_FACE_COLOUR, LikePrimary(0.1));
263 m_tool_background_colour = m_page_hover_background_colour;
264 m_tool_background_gradient_colour = m_page_hover_background_gradient_colour;
265 m_toolbar_hover_borden_pen = m_button_bar_hover_border_pen;
266 m_tool_hover_background_brush = m_button_bar_hover_background_brush;
267 m_tool_active_background_brush = m_button_bar_active_background_brush;
268
269 #undef LikeSecondary
270 #undef LikePrimary
271 }
272
273 void wxRibbonAUIArtProvider::DrawTabCtrlBackground(
274 wxDC& dc,
275 wxWindow* WXUNUSED(wnd),
276 const wxRect& rect)
277 {
278 wxRect gradient_rect(rect);
279 gradient_rect.height--;
280 dc.GradientFillLinear(gradient_rect, m_tab_ctrl_background_colour,
281 m_tab_ctrl_background_gradient_colour, wxSOUTH);
282 dc.SetPen(m_tab_border_pen);
283 dc.DrawLine(rect.x, rect.GetBottom(), rect.GetRight()+1, rect.GetBottom());
284 }
285
286 int wxRibbonAUIArtProvider::GetTabCtrlHeight(
287 wxDC& dc,
288 wxWindow* WXUNUSED(wnd),
289 const wxRibbonPageTabInfoArray& pages)
290 {
291 int text_height = 0;
292 int icon_height = 0;
293
294 if(pages.GetCount() <= 1 && (m_flags & wxRIBBON_BAR_ALWAYS_SHOW_TABS) == 0)
295 {
296 // To preserve space, a single tab need not be displayed. We still need
297 // one pixel of border though.
298 return 1;
299 }
300
301 if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS)
302 {
303 dc.SetFont(m_tab_active_label_font);
304 text_height = dc.GetTextExtent(wxT("ABCDEFXj")).GetHeight();
305 }
306 if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS)
307 {
308 size_t numpages = pages.GetCount();
309 for(size_t i = 0; i < numpages; ++i)
310 {
311 const wxRibbonPageTabInfo& info = pages.Item(i);
312 if(info.page->GetIcon().IsOk())
313 {
314 icon_height = wxMax(icon_height, info.page->GetIcon().GetHeight());
315 }
316 }
317 }
318
319 return wxMax(text_height, icon_height) + 10;
320 }
321
322 void wxRibbonAUIArtProvider::DrawTab(wxDC& dc,
323 wxWindow* WXUNUSED(wnd),
324 const wxRibbonPageTabInfo& tab)
325 {
326 if(tab.rect.height <= 1)
327 return;
328
329 dc.SetFont(m_tab_label_font);
330 dc.SetPen(*wxTRANSPARENT_PEN);
331 if(tab.active || tab.hovered)
332 {
333 if(tab.active)
334 {
335 dc.SetFont(m_tab_active_label_font);
336 dc.SetBrush(m_background_brush);
337 dc.DrawRectangle(tab.rect.x, tab.rect.y + tab.rect.height - 1,
338 tab.rect.width - 1, 1);
339 }
340 wxRect grad_rect(tab.rect);
341 grad_rect.height -= 4;
342 grad_rect.width -= 1;
343 grad_rect.height /= 2;
344 grad_rect.y = grad_rect.y + tab.rect.height - grad_rect.height - 1;
345 dc.SetBrush(m_tab_active_top_background_brush);
346 dc.DrawRectangle(tab.rect.x, tab.rect.y + 3, tab.rect.width - 1,
347 grad_rect.y - tab.rect.y - 3);
348 dc.GradientFillLinear(grad_rect, m_tab_active_background_colour,
349 m_tab_active_background_gradient_colour, wxSOUTH);
350 }
351 else
352 {
353 wxRect btm_rect(tab.rect);
354 btm_rect.height -= 4;
355 btm_rect.width -= 1;
356 btm_rect.height /= 2;
357 btm_rect.y = btm_rect.y + tab.rect.height - btm_rect.height - 1;
358 dc.SetBrush(m_tab_hover_background_brush);
359 dc.DrawRectangle(btm_rect.x, btm_rect.y, btm_rect.width,
360 btm_rect.height);
361 wxRect grad_rect(tab.rect);
362 grad_rect.width -= 1;
363 grad_rect.y += 3;
364 grad_rect.height = btm_rect.y - grad_rect.y;
365 dc.GradientFillLinear(grad_rect, m_tab_hover_background_top_colour,
366 m_tab_hover_background_top_gradient_colour, wxSOUTH);
367 }
368
369 wxPoint border_points[5];
370 border_points[0] = wxPoint(0, 3);
371 border_points[1] = wxPoint(1, 2);
372 border_points[2] = wxPoint(tab.rect.width - 3, 2);
373 border_points[3] = wxPoint(tab.rect.width - 1, 4);
374 border_points[4] = wxPoint(tab.rect.width - 1, tab.rect.height - 1);
375
376 dc.SetPen(m_tab_border_pen);
377 dc.DrawLines(sizeof(border_points)/sizeof(wxPoint), border_points, tab.rect.x, tab.rect.y);
378
379 wxRect old_clip;
380 dc.GetClippingBox(old_clip);
381 bool is_first_tab = false;
382 wxRibbonBar* bar = wxDynamicCast(tab.page->GetParent(), wxRibbonBar);
383 if(bar && bar->GetPage(0) == tab.page)
384 is_first_tab = true;
385
386 wxBitmap icon;
387 if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS)
388 {
389 icon = tab.page->GetIcon();
390 if((m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) == 0)
391 {
392 int x = tab.rect.x + (tab.rect.width - icon.GetWidth()) / 2;
393 dc.DrawBitmap(icon, x, tab.rect.y + 1 + (tab.rect.height - 1 -
394 icon.GetHeight()) / 2, true);
395 }
396 }
397 if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS)
398 {
399 wxString label = tab.page->GetLabel();
400 if(!label.IsEmpty())
401 {
402 dc.SetTextForeground(m_tab_label_colour);
403 dc.SetBackgroundMode(wxTRANSPARENT);
404
405 int offset = 0;
406 if(icon.IsOk())
407 offset += icon.GetWidth() + 2;
408 int text_height;
409 int text_width;
410 dc.GetTextExtent(label, &text_width, &text_height);
411 int x = (tab.rect.width - 2 - text_width - offset) / 2;
412 if(x > 8)
413 x = 8;
414 else if(x < 1)
415 x = 1;
416 int width = tab.rect.width - x - 2;
417 x += tab.rect.x + offset;
418 int y = tab.rect.y + (tab.rect.height - text_height) / 2;
419 if(icon.IsOk())
420 {
421 dc.DrawBitmap(icon, x - offset, tab.rect.y + (tab.rect.height -
422 icon.GetHeight()) / 2, true);
423 }
424 dc.SetClippingRegion(x, tab.rect.y, width, tab.rect.height);
425 dc.DrawText(label, x, y);
426 }
427 }
428
429 // Draw the left hand edge of the tab only for the first tab (subsequent
430 // tabs use the right edge of the prior tab as their left edge). As this is
431 // outside the rectangle for the tab, only draw it if the leftmost part of
432 // the tab is within the clip rectangle (the clip region has to be cleared
433 // to draw outside the tab).
434 if(is_first_tab && old_clip.x <= tab.rect.x
435 && tab.rect.x < old_clip.x + old_clip.width)
436 {
437 dc.DestroyClippingRegion();
438 dc.DrawLine(tab.rect.x - 1, tab.rect.y + 4, tab.rect.x - 1,
439 tab.rect.y + tab.rect.height - 1);
440 }
441 }
442
443 void wxRibbonAUIArtProvider::GetBarTabWidth(
444 wxDC& dc,
445 wxWindow* WXUNUSED(wnd),
446 const wxString& label,
447 const wxBitmap& bitmap,
448 int* ideal,
449 int* small_begin_need_separator,
450 int* small_must_have_separator,
451 int* minimum)
452 {
453 int width = 0;
454 int min = 0;
455 if((m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) && !label.IsEmpty())
456 {
457 dc.SetFont(m_tab_active_label_font);
458 width += dc.GetTextExtent(label).GetWidth();
459 min += wxMin(30, width); // enough for a few chars
460 if(bitmap.IsOk())
461 {
462 // gap between label and bitmap
463 width += 4;
464 min += 2;
465 }
466 }
467 if((m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS) && bitmap.IsOk())
468 {
469 width += bitmap.GetWidth();
470 min += bitmap.GetWidth();
471 }
472
473 if(ideal != NULL)
474 {
475 *ideal = width + 16;
476 }
477 if(small_begin_need_separator != NULL)
478 {
479 *small_begin_need_separator = min;
480 }
481 if(small_must_have_separator != NULL)
482 {
483 *small_must_have_separator = min;
484 }
485 if(minimum != NULL)
486 {
487 *minimum = min;
488 }
489 }
490
491 void wxRibbonAUIArtProvider::DrawTabSeparator(
492 wxDC& WXUNUSED(dc),
493 wxWindow* WXUNUSED(wnd),
494 const wxRect& WXUNUSED(rect),
495 double WXUNUSED(visibility))
496 {
497 // No explicit separators between tabs
498 }
499
500 void wxRibbonAUIArtProvider::DrawPageBackground(
501 wxDC& dc,
502 wxWindow* WXUNUSED(wnd),
503 const wxRect& rect)
504 {
505 dc.SetPen(*wxTRANSPARENT_PEN);
506 dc.SetBrush(m_background_brush);
507 dc.DrawRectangle(rect.x + 1, rect.y, rect.width - 2, rect.height - 1);
508
509 dc.SetPen(m_page_border_pen);
510 dc.DrawLine(rect.x, rect.y, rect.x, rect.y + rect.height);
511 dc.DrawLine(rect.GetRight(), rect.y, rect.GetRight(), rect.y +rect.height);
512 dc.DrawLine(rect.x, rect.GetBottom(), rect.GetRight()+1, rect.GetBottom());
513 }
514
515 wxSize wxRibbonAUIArtProvider::GetScrollButtonMinimumSize(
516 wxDC& WXUNUSED(dc),
517 wxWindow* WXUNUSED(wnd),
518 long WXUNUSED(style))
519 {
520 return wxSize(11, 11);
521 }
522
523 void wxRibbonAUIArtProvider::DrawScrollButton(
524 wxDC& dc,
525 wxWindow* WXUNUSED(wnd),
526 const wxRect& rect,
527 long style)
528 {
529 wxRect true_rect(rect);
530 wxPoint arrow_points[3];
531
532 if((style & wxRIBBON_SCROLL_BTN_FOR_MASK) == wxRIBBON_SCROLL_BTN_FOR_TABS)
533 {
534 true_rect.y += 2;
535 true_rect.height -= 2;
536 dc.SetPen(m_tab_border_pen);
537 }
538 else
539 {
540 dc.SetPen(*wxTRANSPARENT_PEN);
541 dc.SetBrush(m_background_brush);
542 dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
543 dc.SetPen(m_page_border_pen);
544 }
545
546 switch(style & wxRIBBON_SCROLL_BTN_DIRECTION_MASK)
547 {
548 case wxRIBBON_SCROLL_BTN_LEFT:
549 dc.DrawLine(true_rect.GetRight(), true_rect.y, true_rect.GetRight(),
550 true_rect.y + true_rect.height);
551 arrow_points[0] = wxPoint(rect.width / 2 - 2, rect.height / 2);
552 arrow_points[1] = arrow_points[0] + wxPoint(5, -5);
553 arrow_points[2] = arrow_points[0] + wxPoint(5, 5);
554 break;
555 case wxRIBBON_SCROLL_BTN_RIGHT:
556 dc.DrawLine(true_rect.x, true_rect.y, true_rect.x,
557 true_rect.y + true_rect.height);
558 arrow_points[0] = wxPoint(rect.width / 2 + 3, rect.height / 2);
559 arrow_points[1] = arrow_points[0] - wxPoint(5, -5);
560 arrow_points[2] = arrow_points[0] - wxPoint(5, 5);
561 break;
562 case wxRIBBON_SCROLL_BTN_DOWN:
563 dc.DrawLine(true_rect.x, true_rect.y, true_rect.x + true_rect.width,
564 true_rect.y);
565 arrow_points[0] = wxPoint(rect.width / 2, rect.height / 2 + 3);
566 arrow_points[1] = arrow_points[0] - wxPoint( 5, 5);
567 arrow_points[2] = arrow_points[0] - wxPoint(-5, 5);
568 break;
569 case wxRIBBON_SCROLL_BTN_UP:
570 dc.DrawLine(true_rect.x, true_rect.GetBottom(),
571 true_rect.x + true_rect.width, true_rect.GetBottom());
572 arrow_points[0] = wxPoint(rect.width / 2, rect.height / 2 - 2);
573 arrow_points[1] = arrow_points[0] + wxPoint( 5, 5);
574 arrow_points[2] = arrow_points[0] + wxPoint(-5, 5);
575 break;
576 default:
577 return;
578 }
579
580 int x = rect.x;
581 int y = rect.y;
582 if(style & wxRIBBON_SCROLL_BTN_ACTIVE)
583 {
584 ++x;
585 ++y;
586 }
587
588 dc.SetPen(*wxTRANSPARENT_PEN);
589 wxBrush B(m_tab_label_colour);
590 dc.SetBrush(B);
591 dc.DrawPolygon(sizeof(arrow_points)/sizeof(wxPoint), arrow_points, x, y);
592 }
593
594 wxSize wxRibbonAUIArtProvider::GetPanelSize(
595 wxDC& dc,
596 const wxRibbonPanel* wnd,
597 wxSize client_size,
598 wxPoint* client_offset)
599 {
600 dc.SetFont(m_panel_label_font);
601 wxSize label_size = dc.GetTextExtent(wnd->GetLabel());
602 int label_height = label_size.GetHeight() + 5;
603 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
604 {
605 client_size.IncBy(4, label_height + 6);
606 if(client_offset)
607 *client_offset = wxPoint(2, label_height + 3);
608 }
609 else
610 {
611 client_size.IncBy(6, label_height + 4);
612 if(client_offset)
613 *client_offset = wxPoint(3, label_height + 2);
614 }
615 return client_size;
616 }
617
618 wxSize wxRibbonAUIArtProvider::GetPanelClientSize(
619 wxDC& dc,
620 const wxRibbonPanel* wnd,
621 wxSize size,
622 wxPoint* client_offset)
623 {
624 dc.SetFont(m_panel_label_font);
625 wxSize label_size = dc.GetTextExtent(wnd->GetLabel());
626 int label_height = label_size.GetHeight() + 5;
627 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
628 {
629 size.DecBy(4, label_height + 6);
630 if(client_offset)
631 *client_offset = wxPoint(2, label_height + 3);
632 }
633 else
634 {
635 size.DecBy(6, label_height + 4);
636 if(client_offset)
637 *client_offset = wxPoint(3, label_height + 2);
638 }
639 if (size.x < 0) size.x = 0;
640 if (size.y < 0) size.y = 0;
641 return size;
642 }
643
644 void wxRibbonAUIArtProvider::DrawPanelBackground(
645 wxDC& dc,
646 wxRibbonPanel* wnd,
647 const wxRect& rect)
648 {
649 dc.SetPen(*wxTRANSPARENT_PEN);
650 dc.SetBrush(m_background_brush);
651 dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
652
653 wxRect true_rect(rect);
654 RemovePanelPadding(&true_rect);
655
656 dc.SetPen(m_panel_border_pen);
657 dc.SetBrush(*wxTRANSPARENT_BRUSH);
658 dc.DrawRectangle(true_rect.x, true_rect.y, true_rect.width, true_rect.height);
659
660 true_rect.x++;
661 true_rect.width -= 2;
662 true_rect.y++;
663
664 dc.SetFont(m_panel_label_font);
665 wxSize label_size = dc.GetTextExtent(wnd->GetLabel());
666 int label_height = label_size.GetHeight() + 5;
667 wxRect label_rect(true_rect);
668 label_rect.height = label_height - 1;
669 dc.DrawLine(label_rect.x, label_rect.y + label_rect.height,
670 label_rect.x + label_rect.width, label_rect.y + label_rect.height);
671
672 wxColour label_bg_colour = m_panel_label_background_colour;
673 wxColour label_bg_grad_colour = m_panel_label_background_gradient_colour;
674 if(wnd->IsHovered())
675 {
676 label_bg_colour = m_panel_hover_label_background_colour;
677 label_bg_grad_colour = m_panel_hover_label_background_gradient_colour;
678 dc.SetTextForeground(m_panel_hover_label_colour);
679 }
680 else
681 {
682 dc.SetTextForeground(m_panel_label_colour);
683 }
684 dc.GradientFillLinear(label_rect,
685 #ifdef __WXMAC__
686 label_bg_grad_colour, label_bg_colour, wxSOUTH);
687 #else
688 label_bg_colour, label_bg_grad_colour, wxSOUTH);
689 #endif
690 dc.SetFont(m_panel_label_font);
691 dc.DrawText(wnd->GetLabel(), label_rect.x + 3, label_rect.y + 2);
692
693 if(wnd->IsHovered())
694 {
695 wxRect gradient_rect(true_rect);
696 gradient_rect.y += label_rect.height + 1;
697 gradient_rect.height = true_rect.height - label_rect.height - 3;
698 #ifdef __WXMAC__
699 wxColour colour = m_page_hover_background_gradient_colour;
700 wxColour gradient = m_page_hover_background_colour;
701 #else
702 wxColour colour = m_page_hover_background_colour;
703 wxColour gradient = m_page_hover_background_gradient_colour;
704 #endif
705 dc.GradientFillLinear(gradient_rect, colour, gradient, wxSOUTH);
706 }
707 }
708
709 void wxRibbonAUIArtProvider::DrawMinimisedPanel(
710 wxDC& dc,
711 wxRibbonPanel* wnd,
712 const wxRect& rect,
713 wxBitmap& bitmap)
714 {
715 dc.SetPen(*wxTRANSPARENT_PEN);
716 dc.SetBrush(m_background_brush);
717 dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
718
719 wxRect true_rect(rect);
720 RemovePanelPadding(&true_rect);
721
722 dc.SetPen(m_panel_border_pen);
723 dc.SetBrush(*wxTRANSPARENT_BRUSH);
724 dc.DrawRectangle(true_rect.x, true_rect.y, true_rect.width, true_rect.height);
725 true_rect.Deflate(1);
726
727 if(wnd->IsHovered() || wnd->GetExpandedPanel())
728 {
729 wxColour colour = m_page_hover_background_colour;
730 wxColour gradient = m_page_hover_background_gradient_colour;
731 #ifdef __WXMAC__
732 if(!wnd->GetExpandedPanel())
733 #else
734 if(wnd->GetExpandedPanel())
735 #endif
736 {
737 wxColour temp = colour;
738 colour = gradient;
739 gradient = temp;
740 }
741 dc.GradientFillLinear(true_rect, colour, gradient, wxSOUTH);
742 }
743
744 wxRect preview;
745 DrawMinimisedPanelCommon(dc, wnd, true_rect, &preview);
746
747 dc.SetPen(m_panel_border_pen);
748 dc.SetBrush(*wxTRANSPARENT_BRUSH);
749 dc.DrawRectangle(preview.x, preview.y, preview.width, preview.height);
750 preview.Deflate(1);
751 wxRect preview_caption_rect(preview);
752 preview_caption_rect.height = 7;
753 preview.y += preview_caption_rect.height;
754 preview.height -= preview_caption_rect.height;
755 #ifdef __WXMAC__
756 dc.GradientFillLinear(preview_caption_rect,
757 m_panel_hover_label_background_gradient_colour,
758 m_panel_hover_label_background_colour, wxSOUTH);
759 dc.GradientFillLinear(preview,
760 m_page_hover_background_gradient_colour,
761 m_page_hover_background_colour, wxSOUTH);
762 #else
763 dc.GradientFillLinear(preview_caption_rect,
764 m_panel_hover_label_background_colour,
765 m_panel_hover_label_background_gradient_colour, wxSOUTH);
766 dc.GradientFillLinear(preview,
767 m_page_hover_background_colour,
768 m_page_hover_background_gradient_colour, wxSOUTH);
769 #endif
770
771 if(bitmap.IsOk())
772 {
773 dc.DrawBitmap(bitmap, preview.x + (preview.width - bitmap.GetWidth()) / 2,
774 preview.y + (preview.height - bitmap.GetHeight()) / 2, true);
775 }
776 }
777
778 void wxRibbonAUIArtProvider::DrawPartialPanelBackground(wxDC& dc,
779 wxWindow* wnd, const wxRect& rect)
780 {
781 dc.SetPen(*wxTRANSPARENT_PEN);
782 dc.SetBrush(m_background_brush);
783 dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
784
785 wxPoint offset(wnd->GetPosition());
786 wxWindow* parent = wnd->GetParent();
787 wxRibbonPanel* panel = NULL;
788
789 for(; parent; parent = parent->GetParent())
790 {
791 panel = wxDynamicCast(parent, wxRibbonPanel);
792 if(panel != NULL)
793 {
794 if(!panel->IsHovered())
795 return;
796 break;
797 }
798 offset += parent->GetPosition();
799 }
800 if(panel == NULL)
801 return;
802
803 wxRect background(panel->GetSize());
804 RemovePanelPadding(&background);
805 background.x++;
806 background.width -= 2;
807 dc.SetFont(m_panel_label_font);
808 int caption_height = dc.GetTextExtent(panel->GetLabel()).GetHeight() + 7;
809 background.y += caption_height - 1;
810 background.height -= caption_height;
811
812 wxRect paint_rect(rect);
813 paint_rect.x += offset.x;
814 paint_rect.y += offset.y;
815
816 wxColour bg_clr, bg_grad_clr;
817 #ifdef __WXMAC__
818 bg_grad_clr = m_page_hover_background_colour;
819 bg_clr = m_page_hover_background_gradient_colour;
820 #else
821 bg_clr = m_page_hover_background_colour;
822 bg_grad_clr = m_page_hover_background_gradient_colour;
823 #endif
824
825 paint_rect.Intersect(background);
826 if(!paint_rect.IsEmpty())
827 {
828 wxColour starting_colour(wxRibbonInterpolateColour(bg_clr, bg_grad_clr,
829 paint_rect.y, background.y, background.y + background.height));
830 wxColour ending_colour(wxRibbonInterpolateColour(bg_clr, bg_grad_clr,
831 paint_rect.y + paint_rect.height, background.y,
832 background.y + background.height));
833 paint_rect.x -= offset.x;
834 paint_rect.y -= offset.y;
835 dc.GradientFillLinear(paint_rect, starting_colour, ending_colour
836 , wxSOUTH);
837 }
838 }
839
840 void wxRibbonAUIArtProvider::DrawGalleryBackground(
841 wxDC& dc,
842 wxRibbonGallery* wnd,
843 const wxRect& rect)
844 {
845 DrawPartialPanelBackground(dc, wnd, rect);
846
847 if(wnd->IsHovered())
848 {
849 dc.SetPen(*wxTRANSPARENT_PEN);
850 dc.SetBrush(m_gallery_hover_background_brush);
851 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
852 {
853 dc.DrawRectangle(rect.x + 1, rect.y + 1, rect.width - 2,
854 rect.height - 16);
855 }
856 else
857 {
858 dc.DrawRectangle(rect.x + 1, rect.y + 1, rect.width - 16,
859 rect.height - 2);
860 }
861 }
862
863 dc.SetPen(m_gallery_border_pen);
864 dc.SetBrush(*wxTRANSPARENT_BRUSH);
865 dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
866
867 DrawGalleryBackgroundCommon(dc, wnd, rect);
868 }
869
870 void wxRibbonAUIArtProvider::DrawGalleryButton(wxDC& dc, wxRect rect,
871 wxRibbonGalleryButtonState state, wxBitmap* bitmaps)
872 {
873 int extra_height = 0;
874 int extra_width = 0;
875 wxRect reduced_rect(rect);
876 reduced_rect.Deflate(1);
877 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
878 {
879 reduced_rect.width++;
880 extra_width = 1;
881 }
882 else
883 {
884 reduced_rect.height++;
885 extra_height = 1;
886 }
887
888 wxBitmap btn_bitmap;
889 switch(state)
890 {
891 case wxRIBBON_GALLERY_BUTTON_NORMAL:
892 dc.GradientFillLinear(reduced_rect,
893 m_gallery_button_background_colour,
894 m_gallery_button_background_gradient_colour, wxSOUTH);
895 btn_bitmap = bitmaps[0];
896 break;
897 case wxRIBBON_GALLERY_BUTTON_HOVERED:
898 dc.SetPen(m_gallery_item_border_pen);
899 dc.SetBrush(m_gallery_button_hover_background_brush);
900 dc.DrawRectangle(rect.x, rect.y, rect.width + extra_width,
901 rect.height + extra_height);
902 btn_bitmap = bitmaps[1];
903 break;
904 case wxRIBBON_GALLERY_BUTTON_ACTIVE:
905 dc.SetPen(m_gallery_item_border_pen);
906 dc.SetBrush(m_gallery_button_active_background_brush);
907 dc.DrawRectangle(rect.x, rect.y, rect.width + extra_width,
908 rect.height + extra_height);
909 btn_bitmap = bitmaps[2];
910 break;
911 case wxRIBBON_GALLERY_BUTTON_DISABLED:
912 dc.SetPen(*wxTRANSPARENT_PEN);
913 dc.SetBrush(m_gallery_button_disabled_background_brush);
914 dc.DrawRectangle(reduced_rect.x, reduced_rect.y, reduced_rect.width,
915 reduced_rect.height);
916 btn_bitmap = bitmaps[3];
917 break;
918 }
919
920 dc.DrawBitmap(btn_bitmap, reduced_rect.x + reduced_rect.width / 2 - 2,
921 (rect.y + rect.height / 2) - 2, true);
922 }
923
924 void wxRibbonAUIArtProvider::DrawGalleryItemBackground(
925 wxDC& dc,
926 wxRibbonGallery* wnd,
927 const wxRect& rect,
928 wxRibbonGalleryItem* item)
929 {
930 if(wnd->GetHoveredItem() != item && wnd->GetActiveItem() != item &&
931 wnd->GetSelection() != item)
932 return;
933
934 dc.SetPen(m_gallery_item_border_pen);
935 if(wnd->GetActiveItem() == item || wnd->GetSelection() == item)
936 dc.SetBrush(m_gallery_button_active_background_brush);
937 else
938 dc.SetBrush(m_gallery_button_hover_background_brush);
939
940 dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
941 }
942
943 void wxRibbonAUIArtProvider::DrawButtonBarBackground(
944 wxDC& dc,
945 wxWindow* wnd,
946 const wxRect& rect)
947 {
948 DrawPartialPanelBackground(dc, wnd, rect);
949 }
950
951 void wxRibbonAUIArtProvider::DrawButtonBarButton(
952 wxDC& dc,
953 wxWindow* WXUNUSED(wnd),
954 const wxRect& rect,
955 wxRibbonButtonKind kind,
956 long state,
957 const wxString& label,
958 const wxBitmap& bitmap_large,
959 const wxBitmap& bitmap_small)
960 {
961 if(state & (wxRIBBON_BUTTONBAR_BUTTON_HOVER_MASK
962 | wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK))
963 {
964 dc.SetPen(m_button_bar_hover_border_pen);
965
966 wxRect bg_rect(rect);
967 bg_rect.Deflate(1);
968
969 if(kind == wxRIBBON_BUTTON_HYBRID)
970 {
971 switch(state & wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK)
972 {
973 case wxRIBBON_BUTTONBAR_BUTTON_LARGE:
974 {
975 int iYBorder = rect.y + bitmap_large.GetHeight() + 4;
976 wxRect partial_bg(rect);
977 if(state & wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED)
978 {
979 partial_bg.SetBottom(iYBorder - 1);
980 }
981 else
982 {
983 partial_bg.height -= (iYBorder - partial_bg.y + 1);
984 partial_bg.y = iYBorder + 1;
985 }
986 dc.DrawLine(rect.x, iYBorder, rect.x + rect.width, iYBorder);
987 bg_rect.Intersect(partial_bg);
988 }
989 break;
990 case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM:
991 {
992 int iArrowWidth = 9;
993 if(state & wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED)
994 {
995 bg_rect.width -= iArrowWidth;
996 dc.DrawLine(bg_rect.x + bg_rect.width,
997 rect.y, bg_rect.x + bg_rect.width,
998 rect.y + rect.height);
999 }
1000 else
1001 {
1002 --iArrowWidth;
1003 bg_rect.x += bg_rect.width - iArrowWidth;
1004 bg_rect.width = iArrowWidth;
1005 dc.DrawLine(bg_rect.x - 1, rect.y,
1006 bg_rect.x - 1, rect.y + rect.height);
1007 }
1008 }
1009 break;
1010 case wxRIBBON_BUTTONBAR_BUTTON_SMALL:
1011 break;
1012 }
1013 }
1014
1015 dc.SetBrush(*wxTRANSPARENT_BRUSH);
1016 dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
1017
1018 dc.SetPen(*wxTRANSPARENT_PEN);
1019 if(state & wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK)
1020 dc.SetBrush(m_button_bar_active_background_brush);
1021 else
1022 dc.SetBrush(m_button_bar_hover_background_brush);
1023 dc.DrawRectangle(bg_rect.x, bg_rect.y, bg_rect.width, bg_rect.height);
1024 }
1025
1026 dc.SetFont(m_button_bar_label_font);
1027 dc.SetTextForeground(m_button_bar_label_colour);
1028 DrawButtonBarButtonForeground(dc, rect, kind, state, label, bitmap_large,
1029 bitmap_small);
1030 }
1031
1032 void wxRibbonAUIArtProvider::DrawToolBarBackground(
1033 wxDC& dc,
1034 wxWindow* wnd,
1035 const wxRect& rect)
1036 {
1037 DrawPartialPanelBackground(dc, wnd, rect);
1038 }
1039
1040 void wxRibbonAUIArtProvider::DrawToolGroupBackground(
1041 wxDC& dc,
1042 wxWindow* WXUNUSED(wnd),
1043 const wxRect& rect)
1044 {
1045 dc.SetPen(m_toolbar_border_pen);
1046 dc.SetBrush(*wxTRANSPARENT_BRUSH);
1047 dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
1048 wxRect bg_rect(rect);
1049 bg_rect.Deflate(1);
1050 dc.GradientFillLinear(bg_rect, m_tool_background_colour,
1051 m_tool_background_gradient_colour, wxSOUTH);
1052 }
1053
1054 void wxRibbonAUIArtProvider::DrawTool(
1055 wxDC& dc,
1056 wxWindow* WXUNUSED(wnd),
1057 const wxRect& rect,
1058 const wxBitmap& bitmap,
1059 wxRibbonButtonKind kind,
1060 long state)
1061 {
1062 wxRect bg_rect(rect);
1063 bg_rect.Deflate(1);
1064 if((state & wxRIBBON_TOOLBAR_TOOL_LAST) == 0)
1065 bg_rect.width++;
1066 bool is_custom_bg = (state & (wxRIBBON_TOOLBAR_TOOL_HOVER_MASK |
1067 wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK)) != 0;
1068 bool is_split_hybrid = kind == wxRIBBON_BUTTON_HYBRID && is_custom_bg;
1069
1070 // Background
1071 if(is_custom_bg)
1072 {
1073 dc.SetPen(*wxTRANSPARENT_PEN);
1074 dc.SetBrush(m_tool_hover_background_brush);
1075 dc.DrawRectangle(bg_rect.x, bg_rect.y, bg_rect.width, bg_rect.height);
1076 if(state & wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK)
1077 {
1078 wxRect active_rect(bg_rect);
1079 if(kind == wxRIBBON_BUTTON_HYBRID)
1080 {
1081 active_rect.width -= 8;
1082 if(state & wxRIBBON_TOOLBAR_TOOL_DROPDOWN_ACTIVE)
1083 {
1084 active_rect.x += active_rect.width;
1085 active_rect.width = 8;
1086 }
1087 }
1088 dc.SetBrush(m_tool_active_background_brush);
1089 dc.DrawRectangle(active_rect.x, active_rect.y, active_rect.width,
1090 active_rect.height);
1091 }
1092 }
1093
1094 // Border
1095 if(is_custom_bg)
1096 dc.SetPen(m_toolbar_hover_borden_pen);
1097 else
1098 dc.SetPen(m_toolbar_border_pen);
1099 if((state & wxRIBBON_TOOLBAR_TOOL_FIRST) == 0)
1100 {
1101 wxColour existing;
1102 if(!dc.GetPixel(rect.x, rect.y + 1, &existing) ||
1103 existing != m_toolbar_hover_borden_pen.GetColour())
1104 {
1105 dc.DrawLine(rect.x, rect.y + 1, rect.x, rect.y + rect.height - 1);
1106 }
1107 }
1108 if(is_custom_bg)
1109 {
1110 wxRect border_rect(bg_rect);
1111 border_rect.Inflate(1);
1112 dc.SetBrush(*wxTRANSPARENT_BRUSH);
1113 dc.DrawRectangle(border_rect.x, border_rect.y, border_rect.width,
1114 border_rect.height);
1115 }
1116
1117 // Foreground
1118 int avail_width = bg_rect.GetWidth();
1119 if(kind != wxRIBBON_BUTTON_NORMAL)
1120 {
1121 avail_width -= 8;
1122 if(is_split_hybrid)
1123 {
1124 dc.DrawLine(rect.x + avail_width + 1, rect.y,
1125 rect.x + avail_width + 1, rect.y + rect.height);
1126 }
1127 dc.DrawBitmap(m_toolbar_drop_bitmap, bg_rect.x + avail_width + 2,
1128 bg_rect.y + (bg_rect.height / 2) - 2, true);
1129 }
1130 dc.DrawBitmap(bitmap, bg_rect.x + (avail_width - bitmap.GetWidth()) / 2,
1131 bg_rect.y + (bg_rect.height - bitmap.GetHeight()) / 2, true);
1132 }
1133
1134 #endif // wxUSE_RIBBON