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