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