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