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