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