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