1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/ribbon/art_msw.cpp
3 // Purpose: MSW style art provider for ribbon interface
4 // Author: Peter Cawley
8 // Copyright: (C) Peter Cawley
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
20 #include "wx/ribbon/art.h"
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"
28 #include "wx/dcmemory.h"
32 #include "wx/msw/private.h"
35 static const char* const gallery_up_xpm
[] = {
45 static const char* const gallery_down_xpm
[] = {
55 static const char* const gallery_left_xpm
[] = {
65 static const char* const gallery_right_xpm
[] = {
75 static const char* const gallery_extension_xpm
[] = {
85 static const char* const panel_extension_xpm
[] = {
97 wxRibbonMSWArtProvider::wxRibbonMSWArtProvider(bool set_colour_scheme
)
100 #if defined( __WXMAC__ )
101 m_tab_label_font
= *wxSMALL_FONT
;
103 m_tab_label_font
= *wxNORMAL_FONT
;
105 m_button_bar_label_font
= m_tab_label_font
;
106 m_panel_label_font
= m_tab_label_font
;
108 if(set_colour_scheme
)
111 wxColour(194, 216, 241),
112 wxColour(255, 223, 114),
116 m_cached_tab_separator_visibility
= -10.0; // valid visibilities are in range [0, 1]
117 m_tab_separation_size
= 3;
118 m_page_border_left
= 2;
119 m_page_border_top
= 1;
120 m_page_border_right
= 2;
121 m_page_border_bottom
= 3;
122 m_panel_x_separation_size
= 1;
123 m_panel_y_separation_size
= 1;
124 m_tool_group_separation_size
= 3;
125 m_gallery_bitmap_padding_left_size
= 4;
126 m_gallery_bitmap_padding_right_size
= 4;
127 m_gallery_bitmap_padding_top_size
= 4;
128 m_gallery_bitmap_padding_bottom_size
= 4;
131 wxRibbonMSWArtProvider::~wxRibbonMSWArtProvider()
135 void wxRibbonMSWArtProvider::GetColourScheme(
138 wxColour
* tertiary
) const
141 *primary
= m_primary_scheme_colour
;
142 if(secondary
!= NULL
)
143 *secondary
= m_secondary_scheme_colour
;
145 *tertiary
= m_tertiary_scheme_colour
;
148 void wxRibbonMSWArtProvider::SetColourScheme(
149 const wxColour
& primary
,
150 const wxColour
& secondary
,
151 const wxColour
& tertiary
)
153 m_primary_scheme_colour
= primary
;
154 m_secondary_scheme_colour
= secondary
;
155 m_tertiary_scheme_colour
= tertiary
;
157 wxRibbonHSLColour
primary_hsl(primary
);
158 wxRibbonHSLColour
secondary_hsl(secondary
);
159 // tertiary not used for anything
161 // Map primary saturation from [0, 1] to [.25, .75]
162 bool primary_is_gray
= false;
163 static const double gray_saturation_threshold
= 0.01;
164 if(primary_hsl
.saturation
<= gray_saturation_threshold
)
165 primary_is_gray
= true;
168 primary_hsl
.saturation
= cos(primary_hsl
.saturation
* M_PI
)
172 // Map primary luminance from [0, 1] to [.23, .83]
173 primary_hsl
.luminance
= cos(primary_hsl
.luminance
* M_PI
) * -0.3 + 0.53;
175 // Map secondary saturation from [0, 1] to [0.16, 0.84]
176 bool secondary_is_gray
= false;
177 if(secondary_hsl
.saturation
<= gray_saturation_threshold
)
178 secondary_is_gray
= true;
181 secondary_hsl
.saturation
= cos(secondary_hsl
.saturation
* M_PI
)
185 // Map secondary luminance from [0, 1] to [0.1, 0.9]
186 secondary_hsl
.luminance
= cos(secondary_hsl
.luminance
* M_PI
) * -0.4 + 0.5;
188 #define LikePrimary(h, s, l) \
189 primary_hsl.ShiftHue(h ## f).Saturated(primary_is_gray ? 0 : s ## f) \
190 .Lighter(l ## f).ToRGB()
191 #define LikeSecondary(h, s, l) \
192 secondary_hsl.ShiftHue(h ## f).Saturated(secondary_is_gray ? 0 : s ## f) \
193 .Lighter(l ## f).ToRGB()
195 m_page_border_pen
= LikePrimary(1.4, 0.00, -0.08);
197 m_page_background_top_colour
= LikePrimary(-0.1, -0.03, 0.12);
198 m_page_hover_background_top_colour
= LikePrimary(-2.8, 0.27, 0.17);
199 m_page_background_top_gradient_colour
= LikePrimary(0.1, -0.10, 0.08);
200 m_page_hover_background_top_gradient_colour
= LikePrimary(3.2, 0.16, 0.13);
201 m_page_background_colour
= LikePrimary(0.4, -0.09, 0.05);
202 m_page_hover_background_colour
= LikePrimary(0.1, 0.19, 0.10);
203 m_page_background_gradient_colour
= LikePrimary(-3.2, 0.27, 0.10);
204 m_page_hover_background_gradient_colour
= LikePrimary(1.8, 0.01, 0.15);
206 m_tab_active_background_colour
= LikePrimary(-0.1, -0.31, 0.16);
207 m_tab_active_background_gradient_colour
= LikePrimary(-0.1, -0.03, 0.12);
208 m_tab_separator_colour
= LikePrimary(0.9, 0.24, 0.05);
209 m_tab_ctrl_background_brush
= LikePrimary(1.0, 0.39, 0.07);
210 m_tab_hover_background_colour
= LikePrimary(1.3, 0.15, 0.10);
211 m_tab_hover_background_top_colour
= LikePrimary(1.4, 0.36, 0.08);
212 m_tab_border_pen
= LikePrimary(1.4, 0.03, -0.05);
213 m_tab_separator_gradient_colour
= LikePrimary(1.7, -0.15, -0.18);
214 m_tab_hover_background_top_gradient_colour
= LikePrimary(1.8, 0.34, 0.13);
215 m_tab_label_colour
= LikePrimary(4.3, 0.13, -0.49);
216 m_tab_hover_background_gradient_colour
= LikeSecondary(-1.5, -0.34, 0.01);
218 m_panel_minimised_border_gradient_pen
= LikePrimary(-6.9, -0.17, -0.09);
219 m_panel_minimised_border_pen
= LikePrimary(-5.3, -0.24, -0.06);
220 m_panel_border_gradient_pen
= LikePrimary(-5.2, -0.15, -0.06);
221 m_panel_border_pen
= LikePrimary(-2.8, -0.32, 0.02);
222 m_panel_label_background_brush
= LikePrimary(-1.5, 0.03, 0.05);
223 m_panel_active_background_gradient_colour
= LikePrimary(0.5, 0.34, 0.05);
224 m_panel_hover_label_background_brush
= LikePrimary(1.0, 0.30, 0.09);
225 m_panel_active_background_top_gradient_colour
= LikePrimary(1.4, -0.17, -0.13);
226 m_panel_active_background_colour
= LikePrimary(1.6, -0.18, -0.18);
227 m_panel_active_background_top_colour
= LikePrimary(1.7, -0.20, -0.03);
228 m_panel_label_colour
= LikePrimary(2.8, -0.14, -0.35);
229 m_panel_hover_label_colour
= m_panel_label_colour
;
230 m_panel_minimised_label_colour
= m_tab_label_colour
;
231 m_panel_hover_button_background_brush
= LikeSecondary(-0.9, 0.16, -0.07);
232 m_panel_hover_button_border_pen
= LikeSecondary(-3.9, -0.16, -0.14);
233 SetColour(wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR
, LikePrimary(1.4, -0.21, -0.23));
234 SetColour(wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR
, LikePrimary(1.5, -0.24, -0.29));
236 m_gallery_button_disabled_background_colour
= LikePrimary(-2.8, -0.46, 0.09);
237 m_gallery_button_disabled_background_top_brush
= LikePrimary(-2.8, -0.36, 0.15);
238 m_gallery_hover_background_brush
= LikePrimary(-0.8, 0.05, 0.15);
239 m_gallery_border_pen
= LikePrimary(0.7, -0.02, 0.03);
240 m_gallery_button_background_top_brush
= LikePrimary(0.8, 0.34, 0.13);
241 m_gallery_button_background_colour
= LikePrimary(1.3, 0.10, 0.08);
242 // SetColour used so that the relevant bitmaps are generated
243 SetColour(wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR
, LikePrimary(1.4, -0.21, -0.23));
244 SetColour(wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR
, LikePrimary(1.5, -0.24, -0.29));
245 SetColour(wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR
, LikePrimary(1.5, -0.24, -0.29));
246 SetColour(wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR
, LikePrimary(0.0, -1.0, 0.0));
247 m_gallery_button_disabled_background_gradient_colour
= LikePrimary(1.5, -0.43, 0.12);
248 m_gallery_button_background_gradient_colour
= LikePrimary(1.7, 0.11, 0.09);
249 m_gallery_item_border_pen
= LikeSecondary(-3.9, -0.16, -0.14);
250 m_gallery_button_hover_background_colour
= LikeSecondary(-0.9, 0.16, -0.07);
251 m_gallery_button_hover_background_gradient_colour
= LikeSecondary(0.1, 0.12, 0.03);
252 m_gallery_button_hover_background_top_brush
= LikeSecondary(4.3, 0.16, 0.17);
254 m_gallery_button_active_background_colour
= LikeSecondary(-9.9, 0.03, -0.22);
255 m_gallery_button_active_background_gradient_colour
= LikeSecondary(-9.5, 0.14, -0.11);
256 m_gallery_button_active_background_top_brush
= LikeSecondary(-9.0, 0.15, -0.08);
258 m_button_bar_label_colour
= m_tab_label_colour
;
259 m_button_bar_hover_border_pen
= LikeSecondary(-6.2, -0.47, -0.14);
260 m_button_bar_hover_background_gradient_colour
= LikeSecondary(-0.6, 0.16, 0.04);
261 m_button_bar_hover_background_colour
= LikeSecondary(-0.2, 0.16, -0.10);
262 m_button_bar_hover_background_top_gradient_colour
= LikeSecondary(0.2, 0.16, 0.03);
263 m_button_bar_hover_background_top_colour
= LikeSecondary(8.8, 0.16, 0.17);
264 m_button_bar_active_border_pen
= LikeSecondary(-6.2, -0.47, -0.25);
265 m_button_bar_active_background_top_colour
= LikeSecondary(-8.4, 0.08, 0.06);
266 m_button_bar_active_background_top_gradient_colour
= LikeSecondary(-9.7, 0.13, -0.07);
267 m_button_bar_active_background_colour
= LikeSecondary(-9.9, 0.14, -0.14);
268 m_button_bar_active_background_gradient_colour
= LikeSecondary(-8.7, 0.17, -0.03);
270 m_toolbar_border_pen
= LikePrimary(1.4, -0.21, -0.16);
271 SetColour(wxRIBBON_ART_TOOLBAR_FACE_COLOUR
, LikePrimary(1.4, -0.17, -0.22));
272 m_tool_background_top_colour
= LikePrimary(-1.9, -0.07, 0.06);
273 m_tool_background_top_gradient_colour
= LikePrimary(1.4, 0.12, 0.08);
274 m_tool_background_colour
= LikePrimary(1.4, -0.09, 0.03);
275 m_tool_background_gradient_colour
= LikePrimary(1.9, 0.11, 0.09);
276 m_tool_hover_background_top_colour
= LikeSecondary(3.4, 0.11, 0.16);
277 m_tool_hover_background_top_gradient_colour
= LikeSecondary(-1.4, 0.04, 0.08);
278 m_tool_hover_background_colour
= LikeSecondary(-1.8, 0.16, -0.12);
279 m_tool_hover_background_gradient_colour
= LikeSecondary(-2.6, 0.16, 0.05);
280 m_tool_active_background_top_colour
= LikeSecondary(-9.9, -0.12, -0.09);
281 m_tool_active_background_top_gradient_colour
= LikeSecondary(-8.5, 0.16, -0.12);
282 m_tool_active_background_colour
= LikeSecondary(-7.9, 0.16, -0.20);
283 m_tool_active_background_gradient_colour
= LikeSecondary(-6.6, 0.16, -0.10);
288 // Invalidate cached tab separator
289 m_cached_tab_separator_visibility
= -1.0;
292 wxRibbonArtProvider
* wxRibbonMSWArtProvider::Clone() const
294 wxRibbonMSWArtProvider
*copy
= new wxRibbonMSWArtProvider
;
299 void wxRibbonMSWArtProvider::CloneTo(wxRibbonMSWArtProvider
* copy
) const
302 for(i
= 0; i
< 4; ++i
)
304 copy
->m_gallery_up_bitmap
[i
] = m_gallery_up_bitmap
[i
];
305 copy
->m_gallery_down_bitmap
[i
] = m_gallery_down_bitmap
[i
];
306 copy
->m_gallery_extension_bitmap
[i
] = m_gallery_extension_bitmap
[i
];
308 for(i
= 0; i
< 2; ++i
)
310 copy
->m_panel_extension_bitmap
[i
] = m_panel_extension_bitmap
[i
];
312 copy
->m_toolbar_drop_bitmap
= m_toolbar_drop_bitmap
;
314 copy
->m_primary_scheme_colour
= m_primary_scheme_colour
;
315 copy
->m_secondary_scheme_colour
= m_secondary_scheme_colour
;
316 copy
->m_tertiary_scheme_colour
= m_tertiary_scheme_colour
;
318 copy
->m_button_bar_label_colour
= m_button_bar_label_colour
;
319 copy
->m_tab_label_colour
= m_tab_label_colour
;
320 copy
->m_tab_separator_colour
= m_tab_separator_colour
;
321 copy
->m_tab_separator_gradient_colour
= m_tab_separator_gradient_colour
;
322 copy
->m_tab_active_background_colour
= m_tab_hover_background_colour
;
323 copy
->m_tab_active_background_gradient_colour
= m_tab_hover_background_gradient_colour
;
324 copy
->m_tab_hover_background_colour
= m_tab_hover_background_colour
;
325 copy
->m_tab_hover_background_gradient_colour
= m_tab_hover_background_gradient_colour
;
326 copy
->m_tab_hover_background_top_colour
= m_tab_hover_background_top_colour
;
327 copy
->m_tab_hover_background_top_gradient_colour
= m_tab_hover_background_top_gradient_colour
;
328 copy
->m_panel_label_colour
= m_panel_label_colour
;
329 copy
->m_panel_hover_label_colour
= m_panel_hover_label_colour
;
330 copy
->m_panel_minimised_label_colour
= m_panel_minimised_label_colour
;
331 copy
->m_panel_button_face_colour
= m_panel_button_face_colour
;
332 copy
->m_panel_button_hover_face_colour
= m_panel_button_hover_face_colour
;
333 copy
->m_panel_active_background_colour
= m_panel_active_background_colour
;
334 copy
->m_panel_active_background_gradient_colour
= m_panel_active_background_gradient_colour
;
335 copy
->m_panel_active_background_top_colour
= m_panel_active_background_top_colour
;
336 copy
->m_panel_active_background_top_gradient_colour
= m_panel_active_background_top_gradient_colour
;
337 copy
->m_page_background_colour
= m_page_background_colour
;
338 copy
->m_page_background_gradient_colour
= m_page_background_gradient_colour
;
339 copy
->m_page_background_top_colour
= m_page_background_top_colour
;
340 copy
->m_page_background_top_gradient_colour
= m_page_background_top_gradient_colour
;
341 copy
->m_page_hover_background_colour
= m_page_hover_background_colour
;
342 copy
->m_page_hover_background_gradient_colour
= m_page_hover_background_gradient_colour
;
343 copy
->m_page_hover_background_top_colour
= m_page_hover_background_top_colour
;
344 copy
->m_page_hover_background_top_gradient_colour
= m_page_hover_background_top_gradient_colour
;
345 copy
->m_button_bar_hover_background_colour
= m_button_bar_hover_background_colour
;
346 copy
->m_button_bar_hover_background_gradient_colour
= m_button_bar_hover_background_gradient_colour
;
347 copy
->m_button_bar_hover_background_top_colour
= m_button_bar_hover_background_top_colour
;
348 copy
->m_button_bar_hover_background_top_gradient_colour
= m_button_bar_hover_background_top_gradient_colour
;
349 copy
->m_button_bar_active_background_colour
= m_button_bar_active_background_colour
;
350 copy
->m_button_bar_active_background_gradient_colour
= m_button_bar_active_background_gradient_colour
;
351 copy
->m_button_bar_active_background_top_colour
= m_button_bar_active_background_top_colour
;
352 copy
->m_button_bar_active_background_top_gradient_colour
= m_button_bar_active_background_top_gradient_colour
;
353 copy
->m_gallery_button_background_colour
= m_gallery_button_background_colour
;
354 copy
->m_gallery_button_background_gradient_colour
= m_gallery_button_background_gradient_colour
;
355 copy
->m_gallery_button_hover_background_colour
= m_gallery_button_hover_background_colour
;
356 copy
->m_gallery_button_hover_background_gradient_colour
= m_gallery_button_hover_background_gradient_colour
;
357 copy
->m_gallery_button_active_background_colour
= m_gallery_button_active_background_colour
;
358 copy
->m_gallery_button_active_background_gradient_colour
= m_gallery_button_active_background_gradient_colour
;
359 copy
->m_gallery_button_disabled_background_colour
= m_gallery_button_disabled_background_colour
;
360 copy
->m_gallery_button_disabled_background_gradient_colour
= m_gallery_button_disabled_background_gradient_colour
;
361 copy
->m_gallery_button_face_colour
= m_gallery_button_face_colour
;
362 copy
->m_gallery_button_hover_face_colour
= m_gallery_button_hover_face_colour
;
363 copy
->m_gallery_button_active_face_colour
= m_gallery_button_active_face_colour
;
364 copy
->m_gallery_button_disabled_face_colour
= m_gallery_button_disabled_face_colour
;
366 copy
->m_tab_ctrl_background_brush
= m_tab_ctrl_background_brush
;
367 copy
->m_panel_label_background_brush
= m_panel_label_background_brush
;
368 copy
->m_panel_hover_label_background_brush
= m_panel_hover_label_background_brush
;
369 copy
->m_panel_hover_button_background_brush
= m_panel_hover_button_background_brush
;
370 copy
->m_gallery_hover_background_brush
= m_gallery_hover_background_brush
;
371 copy
->m_gallery_button_background_top_brush
= m_gallery_button_background_top_brush
;
372 copy
->m_gallery_button_hover_background_top_brush
= m_gallery_button_hover_background_top_brush
;
373 copy
->m_gallery_button_active_background_top_brush
= m_gallery_button_active_background_top_brush
;
374 copy
->m_gallery_button_disabled_background_top_brush
= m_gallery_button_disabled_background_top_brush
;
376 copy
->m_tab_label_font
= m_tab_label_font
;
377 copy
->m_button_bar_label_font
= m_button_bar_label_font
;
378 copy
->m_panel_label_font
= m_panel_label_font
;
380 copy
->m_page_border_pen
= m_page_border_pen
;
381 copy
->m_panel_border_pen
= m_panel_border_pen
;
382 copy
->m_panel_border_gradient_pen
= m_panel_border_gradient_pen
;
383 copy
->m_panel_minimised_border_pen
= m_panel_minimised_border_pen
;
384 copy
->m_panel_minimised_border_gradient_pen
= m_panel_minimised_border_gradient_pen
;
385 copy
->m_panel_hover_button_border_pen
= m_panel_hover_button_border_pen
;
386 copy
->m_tab_border_pen
= m_tab_border_pen
;
387 copy
->m_gallery_border_pen
= m_gallery_border_pen
;
388 copy
->m_button_bar_hover_border_pen
= m_button_bar_hover_border_pen
;
389 copy
->m_button_bar_active_border_pen
= m_button_bar_active_border_pen
;
390 copy
->m_gallery_item_border_pen
= m_gallery_item_border_pen
;
391 copy
->m_toolbar_border_pen
= m_toolbar_border_pen
;
393 copy
->m_flags
= m_flags
;
394 copy
->m_tab_separation_size
= m_tab_separation_size
;
395 copy
->m_page_border_left
= m_page_border_left
;
396 copy
->m_page_border_top
= m_page_border_top
;
397 copy
->m_page_border_right
= m_page_border_right
;
398 copy
->m_page_border_bottom
= m_page_border_bottom
;
399 copy
->m_panel_x_separation_size
= m_panel_x_separation_size
;
400 copy
->m_panel_y_separation_size
= m_panel_y_separation_size
;
401 copy
->m_gallery_bitmap_padding_left_size
= m_gallery_bitmap_padding_left_size
;
402 copy
->m_gallery_bitmap_padding_right_size
= m_gallery_bitmap_padding_right_size
;
403 copy
->m_gallery_bitmap_padding_top_size
= m_gallery_bitmap_padding_top_size
;
404 copy
->m_gallery_bitmap_padding_bottom_size
= m_gallery_bitmap_padding_bottom_size
;
407 long wxRibbonMSWArtProvider::GetFlags() const
412 void wxRibbonMSWArtProvider::SetFlags(long flags
)
414 if((flags
^ m_flags
) & wxRIBBON_BAR_FLOW_VERTICAL
)
416 if(flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
418 m_page_border_left
++;
419 m_page_border_right
++;
421 m_page_border_bottom
--;
425 m_page_border_left
--;
426 m_page_border_right
--;
428 m_page_border_bottom
++;
433 // Need to reload some bitmaps when flags change
434 #define Reload(setting) SetColour(setting, GetColour(setting))
435 Reload(wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR
);
436 Reload(wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR
);
437 Reload(wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR
);
438 Reload(wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR
);
439 Reload(wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR
);
440 Reload(wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR
);
444 int wxRibbonMSWArtProvider::GetMetric(int id
) const
448 case wxRIBBON_ART_TAB_SEPARATION_SIZE
:
449 return m_tab_separation_size
;
450 case wxRIBBON_ART_PAGE_BORDER_LEFT_SIZE
:
451 return m_page_border_left
;
452 case wxRIBBON_ART_PAGE_BORDER_TOP_SIZE
:
453 return m_page_border_top
;
454 case wxRIBBON_ART_PAGE_BORDER_RIGHT_SIZE
:
455 return m_page_border_right
;
456 case wxRIBBON_ART_PAGE_BORDER_BOTTOM_SIZE
:
457 return m_page_border_bottom
;
458 case wxRIBBON_ART_PANEL_X_SEPARATION_SIZE
:
459 return m_panel_x_separation_size
;
460 case wxRIBBON_ART_PANEL_Y_SEPARATION_SIZE
:
461 return m_panel_y_separation_size
;
462 case wxRIBBON_ART_TOOL_GROUP_SEPARATION_SIZE
:
463 return m_tool_group_separation_size
;
464 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_LEFT_SIZE
:
465 return m_gallery_bitmap_padding_left_size
;
466 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_RIGHT_SIZE
:
467 return m_gallery_bitmap_padding_right_size
;
468 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_TOP_SIZE
:
469 return m_gallery_bitmap_padding_top_size
;
470 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_BOTTOM_SIZE
:
471 return m_gallery_bitmap_padding_bottom_size
;
473 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
480 void wxRibbonMSWArtProvider::SetMetric(int id
, int new_val
)
484 case wxRIBBON_ART_TAB_SEPARATION_SIZE
:
485 m_tab_separation_size
= new_val
;
487 case wxRIBBON_ART_PAGE_BORDER_LEFT_SIZE
:
488 m_page_border_left
= new_val
;
490 case wxRIBBON_ART_PAGE_BORDER_TOP_SIZE
:
491 m_page_border_top
= new_val
;
493 case wxRIBBON_ART_PAGE_BORDER_RIGHT_SIZE
:
494 m_page_border_right
= new_val
;
496 case wxRIBBON_ART_PAGE_BORDER_BOTTOM_SIZE
:
497 m_page_border_bottom
= new_val
;
499 case wxRIBBON_ART_PANEL_X_SEPARATION_SIZE
:
500 m_panel_x_separation_size
= new_val
;
502 case wxRIBBON_ART_PANEL_Y_SEPARATION_SIZE
:
503 m_panel_y_separation_size
= new_val
;
505 case wxRIBBON_ART_TOOL_GROUP_SEPARATION_SIZE
:
506 m_tool_group_separation_size
= new_val
;
508 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_LEFT_SIZE
:
509 m_gallery_bitmap_padding_left_size
= new_val
;
511 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_RIGHT_SIZE
:
512 m_gallery_bitmap_padding_right_size
= new_val
;
514 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_TOP_SIZE
:
515 m_gallery_bitmap_padding_top_size
= new_val
;
517 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_BOTTOM_SIZE
:
518 m_gallery_bitmap_padding_bottom_size
= new_val
;
521 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
526 void wxRibbonMSWArtProvider::SetFont(int id
, const wxFont
& font
)
530 case wxRIBBON_ART_TAB_LABEL_FONT
:
531 m_tab_label_font
= font
;
533 case wxRIBBON_ART_BUTTON_BAR_LABEL_FONT
:
534 m_button_bar_label_font
= font
;
536 case wxRIBBON_ART_PANEL_LABEL_FONT
:
537 m_panel_label_font
= font
;
540 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
545 wxFont
wxRibbonMSWArtProvider::GetFont(int id
) const
549 case wxRIBBON_ART_TAB_LABEL_FONT
:
550 return m_tab_label_font
;
551 case wxRIBBON_ART_BUTTON_BAR_LABEL_FONT
:
552 return m_button_bar_label_font
;
553 case wxRIBBON_ART_PANEL_LABEL_FONT
:
554 return m_panel_label_font
;
556 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
563 wxColour
wxRibbonMSWArtProvider::GetColour(int id
) const
567 case wxRIBBON_ART_BUTTON_BAR_LABEL_COLOUR
:
568 return m_button_bar_label_colour
;
569 case wxRIBBON_ART_BUTTON_BAR_HOVER_BORDER_COLOUR
:
570 return m_button_bar_hover_border_pen
.GetColour();
571 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_COLOUR
:
572 return m_button_bar_hover_background_top_colour
;
573 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
574 return m_button_bar_hover_background_top_gradient_colour
;
575 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_COLOUR
:
576 return m_button_bar_hover_background_colour
;
577 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_GRADIENT_COLOUR
:
578 return m_button_bar_hover_background_gradient_colour
;
579 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BORDER_COLOUR
:
580 return m_button_bar_active_border_pen
.GetColour();
581 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_COLOUR
:
582 return m_button_bar_active_background_top_colour
;
583 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
584 return m_button_bar_active_background_top_gradient_colour
;
585 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_COLOUR
:
586 return m_button_bar_active_background_colour
;
587 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
588 return m_button_bar_active_background_gradient_colour
;
589 case wxRIBBON_ART_GALLERY_BORDER_COLOUR
:
590 return m_gallery_border_pen
.GetColour();
591 case wxRIBBON_ART_GALLERY_HOVER_BACKGROUND_COLOUR
:
592 return m_gallery_hover_background_brush
.GetColour();
593 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_COLOUR
:
594 return m_gallery_button_background_colour
;
595 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_GRADIENT_COLOUR
:
596 return m_gallery_button_background_gradient_colour
;
597 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_TOP_COLOUR
:
598 return m_gallery_button_background_top_brush
.GetColour();
599 case wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR
:
600 return m_gallery_button_face_colour
;
601 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_COLOUR
:
602 return m_gallery_button_hover_background_colour
;
603 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_GRADIENT_COLOUR
:
604 return m_gallery_button_hover_background_gradient_colour
;
605 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_TOP_COLOUR
:
606 return m_gallery_button_hover_background_top_brush
.GetColour();
607 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR
:
608 return m_gallery_button_face_colour
;
609 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_COLOUR
:
610 return m_gallery_button_active_background_colour
;
611 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
612 return m_gallery_button_active_background_gradient_colour
;
613 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_TOP_COLOUR
:
614 return m_gallery_button_background_top_brush
.GetColour();
615 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR
:
616 return m_gallery_button_active_face_colour
;
617 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_COLOUR
:
618 return m_gallery_button_disabled_background_colour
;
619 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_GRADIENT_COLOUR
:
620 return m_gallery_button_disabled_background_gradient_colour
;
621 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_TOP_COLOUR
:
622 return m_gallery_button_disabled_background_top_brush
.GetColour();
623 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR
:
624 return m_gallery_button_disabled_face_colour
;
625 case wxRIBBON_ART_GALLERY_ITEM_BORDER_COLOUR
:
626 return m_gallery_item_border_pen
.GetColour();
627 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_COLOUR
:
628 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_GRADIENT_COLOUR
:
629 return m_tab_ctrl_background_brush
.GetColour();
630 case wxRIBBON_ART_TAB_LABEL_COLOUR
:
631 return m_tab_label_colour
;
632 case wxRIBBON_ART_TAB_SEPARATOR_COLOUR
:
633 return m_tab_separator_colour
;
634 case wxRIBBON_ART_TAB_SEPARATOR_GRADIENT_COLOUR
:
635 return m_tab_separator_gradient_colour
;
636 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_COLOUR
:
637 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
638 return wxColour(0, 0, 0);
639 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_COLOUR
:
640 return m_tab_active_background_colour
;
641 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
642 return m_tab_active_background_gradient_colour
;
643 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_COLOUR
:
644 return m_tab_hover_background_top_colour
;
645 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
646 return m_tab_hover_background_top_gradient_colour
;
647 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_COLOUR
:
648 return m_tab_hover_background_colour
;
649 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_GRADIENT_COLOUR
:
650 return m_tab_hover_background_gradient_colour
;
651 case wxRIBBON_ART_TAB_BORDER_COLOUR
:
652 return m_tab_border_pen
.GetColour();
653 case wxRIBBON_ART_PANEL_BORDER_COLOUR
:
654 return m_panel_border_pen
.GetColour();
655 case wxRIBBON_ART_PANEL_BORDER_GRADIENT_COLOUR
:
656 return m_panel_border_gradient_pen
.GetColour();
657 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_COLOUR
:
658 return m_panel_minimised_border_pen
.GetColour();
659 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_GRADIENT_COLOUR
:
660 return m_panel_minimised_border_gradient_pen
.GetColour();
661 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_COLOUR
:
662 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_GRADIENT_COLOUR
:
663 return m_panel_label_background_brush
.GetColour();
664 case wxRIBBON_ART_PANEL_LABEL_COLOUR
:
665 return m_panel_label_colour
;
666 case wxRIBBON_ART_PANEL_MINIMISED_LABEL_COLOUR
:
667 return m_panel_minimised_label_colour
;
668 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_COLOUR
:
669 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_GRADIENT_COLOUR
:
670 return m_panel_hover_label_background_brush
.GetColour();
671 case wxRIBBON_ART_PANEL_HOVER_LABEL_COLOUR
:
672 return m_panel_hover_label_colour
;
673 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_COLOUR
:
674 return m_panel_active_background_top_colour
;
675 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
676 return m_panel_active_background_top_gradient_colour
;
677 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_COLOUR
:
678 return m_panel_active_background_colour
;
679 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
680 return m_panel_active_background_gradient_colour
;
681 case wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR
:
682 return m_panel_button_face_colour
;
683 case wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR
:
684 return m_panel_button_hover_face_colour
;
685 case wxRIBBON_ART_PAGE_BORDER_COLOUR
:
686 return m_page_border_pen
.GetColour();
687 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_COLOUR
:
688 return m_page_background_top_colour
;
689 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_GRADIENT_COLOUR
:
690 return m_page_background_top_gradient_colour
;
691 case wxRIBBON_ART_PAGE_BACKGROUND_COLOUR
:
692 return m_page_background_colour
;
693 case wxRIBBON_ART_PAGE_BACKGROUND_GRADIENT_COLOUR
:
694 return m_page_background_gradient_colour
;
695 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_COLOUR
:
696 return m_page_hover_background_top_colour
;
697 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
698 return m_page_hover_background_top_gradient_colour
;
699 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_COLOUR
:
700 return m_page_hover_background_colour
;
701 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_GRADIENT_COLOUR
:
702 return m_page_hover_background_gradient_colour
;
703 case wxRIBBON_ART_TOOLBAR_BORDER_COLOUR
:
704 case wxRIBBON_ART_TOOLBAR_HOVER_BORDER_COLOUR
:
705 return m_toolbar_border_pen
.GetColour();
706 case wxRIBBON_ART_TOOLBAR_FACE_COLOUR
:
707 return m_tool_face_colour
;
709 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
716 void wxRibbonMSWArtProvider::SetColour(int id
, const wxColor
& colour
)
720 case wxRIBBON_ART_BUTTON_BAR_LABEL_COLOUR
:
721 m_button_bar_label_colour
= colour
;
723 case wxRIBBON_ART_BUTTON_BAR_HOVER_BORDER_COLOUR
:
724 m_button_bar_hover_border_pen
.SetColour(colour
);
726 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_COLOUR
:
727 m_button_bar_hover_background_top_colour
= colour
;
729 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
730 m_button_bar_hover_background_top_gradient_colour
= colour
;
732 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_COLOUR
:
733 m_button_bar_hover_background_colour
= colour
;
735 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_GRADIENT_COLOUR
:
736 m_button_bar_hover_background_gradient_colour
= colour
;
738 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BORDER_COLOUR
:
739 m_button_bar_active_border_pen
.SetColour(colour
);
741 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_COLOUR
:
742 m_button_bar_active_background_top_colour
= colour
;
744 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
745 m_button_bar_active_background_top_gradient_colour
= colour
;
747 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_COLOUR
:
748 m_button_bar_active_background_colour
= colour
;
750 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
751 m_button_bar_active_background_gradient_colour
= colour
;
753 case wxRIBBON_ART_GALLERY_BORDER_COLOUR
:
754 m_gallery_border_pen
.SetColour(colour
);
756 case wxRIBBON_ART_GALLERY_HOVER_BACKGROUND_COLOUR
:
757 m_gallery_hover_background_brush
.SetColour(colour
);
759 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_COLOUR
:
760 m_gallery_button_background_colour
= colour
;
762 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_GRADIENT_COLOUR
:
763 m_gallery_button_background_gradient_colour
= colour
;
765 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_TOP_COLOUR
:
766 m_gallery_button_background_top_brush
.SetColour(colour
);
768 case wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR
:
769 m_gallery_button_face_colour
= colour
;
770 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
772 m_gallery_up_bitmap
[0] = wxRibbonLoadPixmap(gallery_left_xpm
, colour
);
773 m_gallery_down_bitmap
[0] = wxRibbonLoadPixmap(gallery_right_xpm
, colour
);
777 m_gallery_up_bitmap
[0] = wxRibbonLoadPixmap(gallery_up_xpm
, colour
);
778 m_gallery_down_bitmap
[0] = wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
780 m_gallery_extension_bitmap
[0] = wxRibbonLoadPixmap(gallery_extension_xpm
, colour
);
782 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_COLOUR
:
783 m_gallery_button_hover_background_colour
= colour
;
785 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_GRADIENT_COLOUR
:
786 m_gallery_button_hover_background_gradient_colour
= colour
;
788 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_TOP_COLOUR
:
789 m_gallery_button_hover_background_top_brush
.SetColour(colour
);
791 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR
:
792 m_gallery_button_hover_face_colour
= colour
;
793 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
795 m_gallery_up_bitmap
[1] = wxRibbonLoadPixmap(gallery_left_xpm
, colour
);
796 m_gallery_down_bitmap
[1] = wxRibbonLoadPixmap(gallery_right_xpm
, colour
);
800 m_gallery_up_bitmap
[1] = wxRibbonLoadPixmap(gallery_up_xpm
, colour
);
801 m_gallery_down_bitmap
[1] = wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
803 m_gallery_extension_bitmap
[1] = wxRibbonLoadPixmap(gallery_extension_xpm
, colour
);
805 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_COLOUR
:
806 m_gallery_button_active_background_colour
= colour
;
808 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
809 m_gallery_button_active_background_gradient_colour
= colour
;
811 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_TOP_COLOUR
:
812 m_gallery_button_background_top_brush
.SetColour(colour
);
814 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR
:
815 m_gallery_button_active_face_colour
= colour
;
816 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
818 m_gallery_up_bitmap
[2] = wxRibbonLoadPixmap(gallery_left_xpm
, colour
);
819 m_gallery_down_bitmap
[2] = wxRibbonLoadPixmap(gallery_right_xpm
, colour
);
823 m_gallery_up_bitmap
[2] = wxRibbonLoadPixmap(gallery_up_xpm
, colour
);
824 m_gallery_down_bitmap
[2] = wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
826 m_gallery_extension_bitmap
[2] = wxRibbonLoadPixmap(gallery_extension_xpm
, colour
);
828 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_COLOUR
:
829 m_gallery_button_disabled_background_colour
= colour
;
831 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_GRADIENT_COLOUR
:
832 m_gallery_button_disabled_background_gradient_colour
= colour
;
834 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_TOP_COLOUR
:
835 m_gallery_button_disabled_background_top_brush
.SetColour(colour
);
837 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR
:
838 m_gallery_button_disabled_face_colour
= colour
;
839 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
841 m_gallery_up_bitmap
[3] = wxRibbonLoadPixmap(gallery_left_xpm
, colour
);
842 m_gallery_down_bitmap
[3] = wxRibbonLoadPixmap(gallery_right_xpm
, colour
);
846 m_gallery_up_bitmap
[3] = wxRibbonLoadPixmap(gallery_up_xpm
, colour
);
847 m_gallery_down_bitmap
[3] = wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
849 m_gallery_extension_bitmap
[3] = wxRibbonLoadPixmap(gallery_extension_xpm
, colour
);
851 case wxRIBBON_ART_GALLERY_ITEM_BORDER_COLOUR
:
852 m_gallery_item_border_pen
.SetColour(colour
);
854 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_COLOUR
:
855 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_GRADIENT_COLOUR
:
856 m_tab_ctrl_background_brush
.SetColour(colour
);
857 m_cached_tab_separator_visibility
= -1.0;
859 case wxRIBBON_ART_TAB_LABEL_COLOUR
:
860 m_tab_label_colour
= colour
;
862 case wxRIBBON_ART_TAB_SEPARATOR_COLOUR
:
863 m_tab_separator_colour
= colour
;
864 m_cached_tab_separator_visibility
= -1.0;
866 case wxRIBBON_ART_TAB_SEPARATOR_GRADIENT_COLOUR
:
867 m_tab_separator_gradient_colour
= colour
;
868 m_cached_tab_separator_visibility
= -1.0;
870 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_COLOUR
:
871 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
873 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_COLOUR
:
874 m_tab_active_background_colour
= colour
;
876 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
877 m_tab_active_background_gradient_colour
= colour
;
879 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_COLOUR
:
880 m_tab_hover_background_top_colour
= colour
;
882 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
883 m_tab_hover_background_top_gradient_colour
= colour
;
885 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_COLOUR
:
886 m_tab_hover_background_colour
= colour
;
888 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_GRADIENT_COLOUR
:
889 m_tab_hover_background_gradient_colour
= colour
;
891 case wxRIBBON_ART_TAB_BORDER_COLOUR
:
892 m_tab_border_pen
.SetColour(colour
);
894 case wxRIBBON_ART_PANEL_BORDER_COLOUR
:
895 m_panel_border_pen
.SetColour(colour
);
897 case wxRIBBON_ART_PANEL_BORDER_GRADIENT_COLOUR
:
898 m_panel_border_gradient_pen
.SetColour(colour
);
900 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_COLOUR
:
901 m_panel_minimised_border_pen
.SetColour(colour
);
903 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_GRADIENT_COLOUR
:
904 m_panel_minimised_border_gradient_pen
.SetColour(colour
);
906 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_COLOUR
:
907 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_GRADIENT_COLOUR
:
908 m_panel_label_background_brush
.SetColour(colour
);
910 case wxRIBBON_ART_PANEL_LABEL_COLOUR
:
911 m_panel_label_colour
= colour
;
913 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_COLOUR
:
914 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_GRADIENT_COLOUR
:
915 m_panel_hover_label_background_brush
.SetColour(colour
);
917 case wxRIBBON_ART_PANEL_HOVER_LABEL_COLOUR
:
918 m_panel_hover_label_colour
= colour
;
920 case wxRIBBON_ART_PANEL_MINIMISED_LABEL_COLOUR
:
921 m_panel_minimised_label_colour
= colour
;
923 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_COLOUR
:
924 m_panel_active_background_top_colour
= colour
;
926 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
927 m_panel_active_background_top_gradient_colour
= colour
;
929 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_COLOUR
:
930 m_panel_active_background_colour
= colour
;
932 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
933 m_panel_active_background_gradient_colour
= colour
;
935 case wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR
:
936 m_panel_button_face_colour
= colour
;
937 m_panel_extension_bitmap
[0] = wxRibbonLoadPixmap(panel_extension_xpm
, colour
);
939 case wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR
:
940 m_panel_button_hover_face_colour
= colour
;
941 m_panel_extension_bitmap
[1] = wxRibbonLoadPixmap(panel_extension_xpm
, colour
);
943 case wxRIBBON_ART_PAGE_BORDER_COLOUR
:
944 m_page_border_pen
.SetColour(colour
);
946 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_COLOUR
:
947 m_page_background_top_colour
= colour
;
949 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_GRADIENT_COLOUR
:
950 m_page_background_top_gradient_colour
= colour
;
952 case wxRIBBON_ART_PAGE_BACKGROUND_COLOUR
:
953 m_page_background_colour
= colour
;
955 case wxRIBBON_ART_PAGE_BACKGROUND_GRADIENT_COLOUR
:
956 m_page_background_gradient_colour
= colour
;
958 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_COLOUR
:
959 m_page_hover_background_top_colour
= colour
;
961 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
962 m_page_hover_background_top_gradient_colour
= colour
;
964 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_COLOUR
:
965 m_page_hover_background_colour
= colour
;
967 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_GRADIENT_COLOUR
:
968 m_page_hover_background_gradient_colour
= colour
;
970 case wxRIBBON_ART_TOOLBAR_BORDER_COLOUR
:
971 case wxRIBBON_ART_TOOLBAR_HOVER_BORDER_COLOUR
:
972 m_toolbar_border_pen
.SetColour(colour
);
974 case wxRIBBON_ART_TOOLBAR_FACE_COLOUR
:
975 m_tool_face_colour
= colour
;
976 m_toolbar_drop_bitmap
= wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
979 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
984 void wxRibbonMSWArtProvider::DrawTabCtrlBackground(
986 wxWindow
* WXUNUSED(wnd
),
989 dc
.SetPen(*wxTRANSPARENT_PEN
);
990 dc
.SetBrush(m_tab_ctrl_background_brush
);
991 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
993 dc
.SetPen(m_page_border_pen
);
996 dc
.DrawLine(rect
.x
+ 3, rect
.y
+ rect
.height
- 1, rect
.x
+ rect
.width
- 3, rect
.y
+ rect
.height
- 1);
1000 dc
.DrawLine(rect
.x
, rect
.y
+ rect
.height
- 1, rect
.x
+ rect
.width
, rect
.y
+ rect
.height
- 1);
1004 void wxRibbonMSWArtProvider::DrawTab(
1006 wxWindow
* WXUNUSED(wnd
),
1007 const wxRibbonPageTabInfo
& tab
)
1009 if(tab
.rect
.height
<= 2)
1012 if(tab
.active
|| tab
.hovered
)
1016 wxRect
background(tab
.rect
);
1020 background
.width
-= 4;
1021 background
.height
-= 2;
1023 dc
.GradientFillLinear(background
, m_tab_active_background_colour
,
1024 m_tab_active_background_gradient_colour
, wxSOUTH
);
1026 // TODO: active and hovered
1028 else if(tab
.hovered
)
1030 wxRect
background(tab
.rect
);
1034 background
.width
-= 4;
1035 background
.height
-= 3;
1036 int h
= background
.height
;
1037 background
.height
/= 2;
1038 dc
.GradientFillLinear(background
,
1039 m_tab_hover_background_top_colour
,
1040 m_tab_hover_background_top_gradient_colour
, wxSOUTH
);
1042 background
.y
+= background
.height
;
1043 background
.height
= h
- background
.height
;
1044 dc
.GradientFillLinear(background
, m_tab_hover_background_colour
,
1045 m_tab_hover_background_gradient_colour
, wxSOUTH
);
1048 wxPoint border_points
[6];
1049 border_points
[0] = wxPoint(1, tab
.rect
.height
- 2);
1050 border_points
[1] = wxPoint(1, 3);
1051 border_points
[2] = wxPoint(3, 1);
1052 border_points
[3] = wxPoint(tab
.rect
.width
- 4, 1);
1053 border_points
[4] = wxPoint(tab
.rect
.width
- 2, 3);
1054 border_points
[5] = wxPoint(tab
.rect
.width
- 2, tab
.rect
.height
- 1);
1056 dc
.SetPen(m_tab_border_pen
);
1057 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
, tab
.rect
.x
, tab
.rect
.y
);
1061 // Give the tab a curved outward border at the bottom
1062 dc
.DrawPoint(tab
.rect
.x
, tab
.rect
.y
+ tab
.rect
.height
- 2);
1063 dc
.DrawPoint(tab
.rect
.x
+ tab
.rect
.width
- 1, tab
.rect
.y
+ tab
.rect
.height
- 2);
1065 wxPen
p(m_tab_active_background_gradient_colour
);
1068 // Technically the first two points are the wrong colour, but they're near enough
1069 dc
.DrawPoint(tab
.rect
.x
+ 1, tab
.rect
.y
+ tab
.rect
.height
- 2);
1070 dc
.DrawPoint(tab
.rect
.x
+ tab
.rect
.width
- 2, tab
.rect
.y
+ tab
.rect
.height
- 2);
1071 dc
.DrawPoint(tab
.rect
.x
+ 1, tab
.rect
.y
+ tab
.rect
.height
- 1);
1072 dc
.DrawPoint(tab
.rect
.x
, tab
.rect
.y
+ tab
.rect
.height
- 1);
1073 dc
.DrawPoint(tab
.rect
.x
+ tab
.rect
.width
- 2, tab
.rect
.y
+ tab
.rect
.height
- 1);
1074 dc
.DrawPoint(tab
.rect
.x
+ tab
.rect
.width
- 1, tab
.rect
.y
+ tab
.rect
.height
- 1);
1078 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_ICONS
)
1080 wxBitmap icon
= tab
.page
->GetIcon();
1083 int x
= tab
.rect
.x
+ 4;
1084 if((m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
) == 0)
1085 x
= tab
.rect
.x
+ (tab
.rect
.width
- icon
.GetWidth()) / 2;
1086 dc
.DrawBitmap(icon
, x
, tab
.rect
.y
+ 1 + (tab
.rect
.height
- 1 -
1087 icon
.GetHeight()) / 2, true);
1090 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
)
1092 wxString label
= tab
.page
->GetLabel();
1093 if(!label
.IsEmpty())
1095 dc
.SetFont(m_tab_label_font
);
1096 dc
.SetTextForeground(m_tab_label_colour
);
1097 dc
.SetBackgroundMode(wxTRANSPARENT
);
1101 dc
.GetTextExtent(label
, &text_width
, &text_height
);
1102 int width
= tab
.rect
.width
- 5;
1103 int x
= tab
.rect
.x
+ 3;
1104 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_ICONS
)
1106 x
+= 3 + tab
.page
->GetIcon().GetWidth();
1107 width
-= 3 + tab
.page
->GetIcon().GetWidth();
1109 int y
= tab
.rect
.y
+ (tab
.rect
.height
- text_height
) / 2;
1111 if(width
<= text_width
)
1113 dc
.SetClippingRegion(x
, tab
.rect
.y
, width
, tab
.rect
.height
);
1114 dc
.DrawText(label
, x
, y
);
1118 dc
.DrawText(label
, x
+ (width
- text_width
) / 2 + 1, y
);
1124 void wxRibbonMSWArtProvider::DrawTabSeparator(
1130 if(visibility
<= 0.0)
1134 if(visibility
> 1.0)
1139 // The tab separator is relatively expensive to draw (for its size), and is
1140 // usually drawn multiple times sequentially (in different positions), so it
1141 // makes sense to draw it once and cache it.
1142 if(!m_cached_tab_separator
.IsOk() || m_cached_tab_separator
.GetSize() != rect
.GetSize() || visibility
!= m_cached_tab_separator_visibility
)
1144 wxRect
size(rect
.GetSize());
1145 ReallyDrawTabSeparator(wnd
, size
, visibility
);
1147 dc
.DrawBitmap(m_cached_tab_separator
, rect
.x
, rect
.y
, false);
1150 void wxRibbonMSWArtProvider::ReallyDrawTabSeparator(wxWindow
* wnd
, const wxRect
& rect
, double visibility
)
1152 if(!m_cached_tab_separator
.IsOk() || m_cached_tab_separator
.GetSize() != rect
.GetSize())
1154 m_cached_tab_separator
= wxBitmap(rect
.GetSize());
1157 wxMemoryDC
dc(m_cached_tab_separator
);
1158 DrawTabCtrlBackground(dc
, wnd
, rect
);
1160 wxCoord x
= rect
.x
+ rect
.width
/ 2;
1161 double h
= (double)(rect
.height
- 1);
1163 double r1
= m_tab_ctrl_background_brush
.GetColour().Red() * (1.0 - visibility
) + 0.5;
1164 double g1
= m_tab_ctrl_background_brush
.GetColour().Green() * (1.0 - visibility
) + 0.5;
1165 double b1
= m_tab_ctrl_background_brush
.GetColour().Blue() * (1.0 - visibility
) + 0.5;
1166 double r2
= m_tab_separator_colour
.Red();
1167 double g2
= m_tab_separator_colour
.Green();
1168 double b2
= m_tab_separator_colour
.Blue();
1169 double r3
= m_tab_separator_gradient_colour
.Red();
1170 double g3
= m_tab_separator_gradient_colour
.Green();
1171 double b3
= m_tab_separator_gradient_colour
.Blue();
1173 for(int i
= 0; i
< rect
.height
- 1; ++i
)
1175 double p
= ((double)i
)/h
;
1177 double r
= (p
* r3
+ (1.0 - p
) * r2
) * visibility
+ r1
;
1178 double g
= (p
* g3
+ (1.0 - p
) * g2
) * visibility
+ g1
;
1179 double b
= (p
* b3
+ (1.0 - p
) * b2
) * visibility
+ b1
;
1181 wxPen
P(wxColour((unsigned char)r
, (unsigned char)g
, (unsigned char)b
));
1183 dc
.DrawPoint(x
, rect
.y
+ i
);
1186 m_cached_tab_separator_visibility
= visibility
;
1189 void wxRibbonMSWArtProvider::DrawPartialPageBackground(wxDC
& dc
,
1190 wxWindow
* wnd
, const wxRect
& rect
, wxRibbonPage
* page
,
1191 wxPoint offset
, bool hovered
)
1194 // Expanded panels need a background - the expanded panel at
1195 // best size may have a greater Y dimension higher than when
1196 // on the bar if it has a sizer. AUI art provider does not need this
1197 // because it paints the panel without reference to its parent's size.
1198 // Expanded panels use a wxFrame as parent (not a wxRibbonPage).
1200 if(wnd
->GetSizer() && wnd
->GetParent() != page
)
1202 background
= wnd
->GetParent()->GetSize();
1203 offset
= wxPoint(0,0);
1207 background
= page
->GetSize();
1208 page
->AdjustRectToIncludeScrollButtons(&background
);
1209 background
.height
-= 2;
1211 // Page background isn't dependant upon the width of the page
1212 // (at least not the part of it intended to be painted by this
1213 // function). Set to wider than the page itself for when externally
1214 // expanded panels need a background - the expanded panel can be wider
1217 background
.width
= INT_MAX
;
1219 // upper_rect, lower_rect, paint_rect are all in page co-ordinates
1220 wxRect
upper_rect(background
);
1221 upper_rect
.height
/= 5;
1223 wxRect
lower_rect(background
);
1224 lower_rect
.y
+= upper_rect
.height
;
1225 lower_rect
.height
-= upper_rect
.height
;
1227 wxRect
paint_rect(rect
);
1228 paint_rect
.x
+= offset
.x
;
1229 paint_rect
.y
+= offset
.y
;
1231 wxColour bg_top
, bg_top_grad
, bg_btm
, bg_btm_grad
;
1234 bg_top
= m_page_hover_background_top_colour
;
1235 bg_top_grad
= m_page_hover_background_top_gradient_colour
;
1236 bg_btm
= m_page_hover_background_colour
;
1237 bg_btm_grad
= m_page_hover_background_gradient_colour
;
1241 bg_top
= m_page_background_top_colour
;
1242 bg_top_grad
= m_page_background_top_gradient_colour
;
1243 bg_btm
= m_page_background_colour
;
1244 bg_btm_grad
= m_page_background_gradient_colour
;
1247 if(paint_rect
.Intersects(upper_rect
))
1249 wxRect
rect(upper_rect
);
1250 rect
.Intersect(paint_rect
);
1253 wxColour
starting_colour(wxRibbonInterpolateColour(bg_top
, bg_top_grad
,
1254 paint_rect
.y
, upper_rect
.y
, upper_rect
.y
+ upper_rect
.height
));
1255 wxColour
ending_colour(wxRibbonInterpolateColour(bg_top
, bg_top_grad
,
1256 paint_rect
.y
+ paint_rect
.height
, upper_rect
.y
,
1257 upper_rect
.y
+ upper_rect
.height
));
1258 dc
.GradientFillLinear(rect
, starting_colour
, ending_colour
, wxSOUTH
);
1261 if(paint_rect
.Intersects(lower_rect
))
1263 wxRect
rect(lower_rect
);
1264 rect
.Intersect(paint_rect
);
1267 wxColour
starting_colour(wxRibbonInterpolateColour(bg_btm
, bg_btm_grad
,
1268 paint_rect
.y
, lower_rect
.y
, lower_rect
.y
+ lower_rect
.height
));
1269 wxColour
ending_colour(wxRibbonInterpolateColour(bg_btm
, bg_btm_grad
,
1270 paint_rect
.y
+ paint_rect
.height
,
1271 lower_rect
.y
, lower_rect
.y
+ lower_rect
.height
));
1272 dc
.GradientFillLinear(rect
, starting_colour
, ending_colour
, wxSOUTH
);
1276 void wxRibbonMSWArtProvider::DrawPageBackground(
1278 wxWindow
* WXUNUSED(wnd
),
1281 dc
.SetPen(*wxTRANSPARENT_PEN
);
1282 dc
.SetBrush(m_tab_ctrl_background_brush
);
1288 dc
.DrawRectangle(edge
.x
, edge
.y
, edge
.width
, edge
.height
);
1290 edge
.x
+= rect
.width
- 2;
1291 dc
.DrawRectangle(edge
.x
, edge
.y
, edge
.width
, edge
.height
);
1295 edge
.y
+= (rect
.height
- edge
.height
);
1296 dc
.DrawRectangle(edge
.x
, edge
.y
, edge
.width
, edge
.height
);
1300 wxRect
background(rect
);
1302 background
.width
-= 4;
1303 background
.height
-= 2;
1305 background
.height
/= 5;
1306 dc
.GradientFillLinear(background
, m_page_background_top_colour
,
1307 m_page_background_top_gradient_colour
, wxSOUTH
);
1309 background
.y
+= background
.height
;
1310 background
.height
= rect
.height
- 2 - background
.height
;
1311 dc
.GradientFillLinear(background
, m_page_background_colour
,
1312 m_page_background_gradient_colour
, wxSOUTH
);
1316 wxPoint border_points
[8];
1317 border_points
[0] = wxPoint(2, 0);
1318 border_points
[1] = wxPoint(1, 1);
1319 border_points
[2] = wxPoint(1, rect
.height
- 4);
1320 border_points
[3] = wxPoint(3, rect
.height
- 2);
1321 border_points
[4] = wxPoint(rect
.width
- 4, rect
.height
- 2);
1322 border_points
[5] = wxPoint(rect
.width
- 2, rect
.height
- 4);
1323 border_points
[6] = wxPoint(rect
.width
- 2, 1);
1324 border_points
[7] = wxPoint(rect
.width
- 4, -1);
1326 dc
.SetPen(m_page_border_pen
);
1327 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
, rect
.x
, rect
.y
);
1331 void wxRibbonMSWArtProvider::DrawScrollButton(
1333 wxWindow
* WXUNUSED(wnd
),
1334 const wxRect
& rect_
,
1339 if((style
& wxRIBBON_SCROLL_BTN_FOR_MASK
) == wxRIBBON_SCROLL_BTN_FOR_PAGE
)
1341 // Page scroll buttons do not have the luxury of rendering on top of anything
1342 // else, and their size includes some padding, hence the background painting
1343 // and size adjustment.
1344 dc
.SetPen(*wxTRANSPARENT_PEN
);
1345 dc
.SetBrush(m_tab_ctrl_background_brush
);
1346 dc
.DrawRectangle(rect
);
1347 dc
.SetClippingRegion(rect
);
1348 switch(style
& wxRIBBON_SCROLL_BTN_DIRECTION_MASK
)
1350 case wxRIBBON_SCROLL_BTN_LEFT
:
1352 case wxRIBBON_SCROLL_BTN_RIGHT
:
1356 case wxRIBBON_SCROLL_BTN_UP
:
1362 case wxRIBBON_SCROLL_BTN_DOWN
:
1371 wxRect
background(rect
);
1374 background
.width
-= 2;
1375 background
.height
-= 2;
1377 if(style
& wxRIBBON_SCROLL_BTN_UP
)
1378 background
.height
/= 2;
1380 background
.height
/= 5;
1381 dc
.GradientFillLinear(background
, m_page_background_top_colour
,
1382 m_page_background_top_gradient_colour
, wxSOUTH
);
1384 background
.y
+= background
.height
;
1385 background
.height
= rect
.height
- 2 - background
.height
;
1386 dc
.GradientFillLinear(background
, m_page_background_colour
,
1387 m_page_background_gradient_colour
, wxSOUTH
);
1391 wxPoint border_points
[7];
1392 switch(style
& wxRIBBON_SCROLL_BTN_DIRECTION_MASK
)
1394 case wxRIBBON_SCROLL_BTN_LEFT
:
1395 border_points
[0] = wxPoint(2, 0);
1396 border_points
[1] = wxPoint(rect
.width
- 1, 0);
1397 border_points
[2] = wxPoint(rect
.width
- 1, rect
.height
- 1);
1398 border_points
[3] = wxPoint(2, rect
.height
- 1);
1399 border_points
[4] = wxPoint(0, rect
.height
- 3);
1400 border_points
[5] = wxPoint(0, 2);
1402 case wxRIBBON_SCROLL_BTN_RIGHT
:
1403 border_points
[0] = wxPoint(0, 0);
1404 border_points
[1] = wxPoint(rect
.width
- 3, 0);
1405 border_points
[2] = wxPoint(rect
.width
- 1, 2);
1406 border_points
[3] = wxPoint(rect
.width
- 1, rect
.height
- 3);
1407 border_points
[4] = wxPoint(rect
.width
- 3, rect
.height
- 1);
1408 border_points
[5] = wxPoint(0, rect
.height
- 1);
1410 case wxRIBBON_SCROLL_BTN_UP
:
1411 border_points
[0] = wxPoint(2, 0);
1412 border_points
[1] = wxPoint(rect
.width
- 3, 0);
1413 border_points
[2] = wxPoint(rect
.width
- 1, 2);
1414 border_points
[3] = wxPoint(rect
.width
- 1, rect
.height
- 1);
1415 border_points
[4] = wxPoint(0, rect
.height
- 1);
1416 border_points
[5] = wxPoint(0, 2);
1418 case wxRIBBON_SCROLL_BTN_DOWN
:
1419 border_points
[0] = wxPoint(0, 0);
1420 border_points
[1] = wxPoint(rect
.width
- 1, 0);
1421 border_points
[2] = wxPoint(rect
.width
- 1, rect
.height
- 3);
1422 border_points
[3] = wxPoint(rect
.width
- 3, rect
.height
- 1);
1423 border_points
[4] = wxPoint(2, rect
.height
- 1);
1424 border_points
[5] = wxPoint(0, rect
.height
- 3);
1427 border_points
[6] = border_points
[0];
1429 dc
.SetPen(m_page_border_pen
);
1430 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
, rect
.x
, rect
.y
);
1434 // NB: Code for handling hovered/active state is temporary
1435 wxPoint arrow_points
[3];
1436 switch(style
& wxRIBBON_SCROLL_BTN_DIRECTION_MASK
)
1438 case wxRIBBON_SCROLL_BTN_LEFT
:
1439 arrow_points
[0] = wxPoint(rect
.width
/ 2 - 2, rect
.height
/ 2);
1440 if(style
& wxRIBBON_SCROLL_BTN_ACTIVE
)
1441 arrow_points
[0].y
+= 1;
1442 arrow_points
[1] = arrow_points
[0] + wxPoint(3, -3);
1443 arrow_points
[2] = arrow_points
[0] + wxPoint(3, 3);
1445 case wxRIBBON_SCROLL_BTN_RIGHT
:
1446 arrow_points
[0] = wxPoint(rect
.width
/ 2 + 2, rect
.height
/ 2);
1447 if(style
& wxRIBBON_SCROLL_BTN_ACTIVE
)
1448 arrow_points
[0].y
+= 1;
1449 arrow_points
[1] = arrow_points
[0] - wxPoint(3, 3);
1450 arrow_points
[2] = arrow_points
[0] - wxPoint(3, -3);
1452 case wxRIBBON_SCROLL_BTN_UP
:
1453 arrow_points
[0] = wxPoint(rect
.width
/ 2, rect
.height
/ 2 - 2);
1454 if(style
& wxRIBBON_SCROLL_BTN_ACTIVE
)
1455 arrow_points
[0].y
+= 1;
1456 arrow_points
[1] = arrow_points
[0] + wxPoint( 3, 3);
1457 arrow_points
[2] = arrow_points
[0] + wxPoint(-3, 3);
1459 case wxRIBBON_SCROLL_BTN_DOWN
:
1460 arrow_points
[0] = wxPoint(rect
.width
/ 2, rect
.height
/ 2 + 2);
1461 if(style
& wxRIBBON_SCROLL_BTN_ACTIVE
)
1462 arrow_points
[0].y
+= 1;
1463 arrow_points
[1] = arrow_points
[0] - wxPoint( 3, 3);
1464 arrow_points
[2] = arrow_points
[0] - wxPoint(-3, 3);
1468 dc
.SetPen(*wxTRANSPARENT_PEN
);
1469 wxBrush
B(style
& wxRIBBON_SCROLL_BTN_HOVERED
? m_tab_active_background_colour
: m_tab_label_colour
);
1471 dc
.DrawPolygon(sizeof(arrow_points
)/sizeof(wxPoint
), arrow_points
, rect
.x
, rect
.y
);
1475 void wxRibbonMSWArtProvider::DrawDropdownArrow(wxDC
& dc
, int x
, int y
, const wxColour
& colour
)
1477 wxPoint arrow_points
[3];
1478 wxBrush
brush(colour
);
1479 arrow_points
[0] = wxPoint(1, 2);
1480 arrow_points
[1] = arrow_points
[0] + wxPoint(-3, -3);
1481 arrow_points
[2] = arrow_points
[0] + wxPoint( 3, -3);
1482 dc
.SetPen(*wxTRANSPARENT_PEN
);
1484 dc
.DrawPolygon(sizeof(arrow_points
)/sizeof(wxPoint
), arrow_points
, x
, y
);
1487 void wxRibbonMSWArtProvider::RemovePanelPadding(wxRect
* rect
)
1489 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1501 void wxRibbonMSWArtProvider::DrawPanelBackground(
1506 DrawPartialPageBackground(dc
, wnd
, rect
, false);
1508 wxRect
true_rect(rect
);
1509 RemovePanelPadding(&true_rect
);
1510 bool has_ext_button
= wnd
->HasExtButton();
1514 dc
.SetFont(m_panel_label_font
);
1515 dc
.SetPen(*wxTRANSPARENT_PEN
);
1516 if(wnd
->IsHovered())
1518 dc
.SetBrush(m_panel_hover_label_background_brush
);
1519 dc
.SetTextForeground(m_panel_hover_label_colour
);
1523 dc
.SetBrush(m_panel_label_background_brush
);
1524 dc
.SetTextForeground(m_panel_label_colour
);
1527 wxRect
label_rect(true_rect
);
1528 wxString label
= wnd
->GetLabel();
1529 bool clip_label
= false;
1530 wxSize
label_size(dc
.GetTextExtent(label
));
1532 label_rect
.SetX(label_rect
.GetX() + 1);
1533 label_rect
.SetWidth(label_rect
.GetWidth() - 2);
1534 label_rect
.SetHeight(label_size
.GetHeight() + 2);
1535 label_rect
.SetY(true_rect
.GetBottom() - label_rect
.GetHeight());
1536 label_height
= label_rect
.GetHeight();
1538 wxRect label_bg_rect
= label_rect
;
1541 label_rect
.SetWidth(label_rect
.GetWidth() - 13);
1543 if(label_size
.GetWidth() > label_rect
.GetWidth())
1545 // Test if there is enough length for 3 letters and ...
1546 wxString new_label
= label
.Mid(0, 3) + wxT("...");
1547 label_size
= dc
.GetTextExtent(new_label
);
1548 if(label_size
.GetWidth() > label_rect
.GetWidth())
1550 // Not enough room for three characters and ...
1551 // Display the entire label and just crop it
1556 // Room for some characters and ...
1557 // Display as many characters as possible and append ...
1558 for(size_t len
= label
.Len() - 1; len
>= 3; --len
)
1560 new_label
= label
.Mid(0, len
) + wxT("...");
1561 label_size
= dc
.GetTextExtent(new_label
);
1562 if(label_size
.GetWidth() <= label_rect
.GetWidth())
1571 dc
.DrawRectangle(label_bg_rect
);
1574 wxDCClipper
clip(dc
, label_rect
);
1575 dc
.DrawText(label
, label_rect
.x
, label_rect
.y
+
1576 (label_rect
.GetHeight() - label_size
.GetHeight()) / 2);
1580 dc
.DrawText(label
, label_rect
.x
+
1581 (label_rect
.GetWidth() - label_size
.GetWidth()) / 2,
1583 (label_rect
.GetHeight() - label_size
.GetHeight()) / 2);
1588 if(wnd
->IsExtButtonHovered())
1590 dc
.SetPen(m_panel_hover_button_border_pen
);
1591 dc
.SetBrush(m_panel_hover_button_background_brush
);
1592 dc
.DrawRoundedRectangle(label_rect
.GetRight(), label_rect
.GetBottom() - 13, 13, 13, 1.0);
1593 dc
.DrawBitmap(m_panel_extension_bitmap
[1], label_rect
.GetRight() + 3, label_rect
.GetBottom() - 10, true);
1596 dc
.DrawBitmap(m_panel_extension_bitmap
[0], label_rect
.GetRight() + 3, label_rect
.GetBottom() - 10, true);
1600 if(wnd
->IsHovered())
1602 wxRect
client_rect(true_rect
);
1604 client_rect
.width
-= 2;
1606 client_rect
.height
-= 2 + label_height
;
1607 DrawPartialPageBackground(dc
, wnd
, client_rect
, true);
1610 DrawPanelBorder(dc
, true_rect
, m_panel_border_pen
, m_panel_border_gradient_pen
);
1613 wxRect
wxRibbonMSWArtProvider::GetPanelExtButtonArea(wxDC
& WXUNUSED(dc
),
1614 const wxRibbonPanel
* WXUNUSED(wnd
),
1617 RemovePanelPadding(&rect
);
1618 rect
= wxRect(rect
.GetRight()-13, rect
.GetBottom()-13, 13, 13);
1622 void wxRibbonMSWArtProvider::DrawGalleryBackground(
1624 wxRibbonGallery
* wnd
,
1627 DrawPartialPageBackground(dc
, wnd
, rect
);
1629 if(wnd
->IsHovered())
1631 dc
.SetPen(*wxTRANSPARENT_PEN
);
1632 dc
.SetBrush(m_gallery_hover_background_brush
);
1633 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1635 dc
.DrawRectangle(rect
.x
+ 1, rect
.y
+ 1, rect
.width
- 2,
1640 dc
.DrawRectangle(rect
.x
+ 1, rect
.y
+ 1, rect
.width
- 16,
1645 dc
.SetPen(m_gallery_border_pen
);
1647 dc
.DrawLine(rect
.x
+ 1, rect
.y
, rect
.x
+ rect
.width
- 1, rect
.y
);
1648 dc
.DrawLine(rect
.x
, rect
.y
+ 1, rect
.x
, rect
.y
+ rect
.height
- 1);
1649 dc
.DrawLine(rect
.x
+ 1, rect
.y
+ rect
.height
- 1, rect
.x
+ rect
.width
- 1,
1650 rect
.y
+ rect
.height
- 1);
1651 dc
.DrawLine(rect
.x
+ rect
.width
- 1, rect
.y
+ 1, rect
.x
+ rect
.width
- 1,
1652 rect
.y
+ rect
.height
- 1);
1654 DrawGalleryBackgroundCommon(dc
, wnd
, rect
);
1657 void wxRibbonMSWArtProvider::DrawGalleryBackgroundCommon(wxDC
& dc
,
1658 wxRibbonGallery
* wnd
,
1661 wxRect up_btn
, down_btn
, ext_btn
;
1663 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1665 // Divider between items and buttons
1666 dc
.DrawLine(rect
.x
, rect
.y
+ rect
.height
- 15, rect
.x
+ rect
.width
,
1667 rect
.y
+ rect
.height
- 15);
1669 up_btn
= wxRect(rect
.x
, rect
.y
+ rect
.height
- 15, rect
.width
/ 3, 15);
1671 down_btn
= wxRect(up_btn
.GetRight() + 1, up_btn
.GetTop(),
1672 up_btn
.GetWidth(), up_btn
.GetHeight());
1673 dc
.DrawLine(down_btn
.GetLeft(), down_btn
.GetTop(), down_btn
.GetLeft(),
1674 down_btn
.GetBottom());
1676 ext_btn
= wxRect(down_btn
.GetRight() + 1, up_btn
.GetTop(), rect
.width
-
1677 up_btn
.GetWidth() - down_btn
.GetWidth() - 1, up_btn
.GetHeight());
1678 dc
.DrawLine(ext_btn
.GetLeft(), ext_btn
.GetTop(), ext_btn
.GetLeft(),
1679 ext_btn
.GetBottom());
1683 // Divider between items and buttons
1684 dc
.DrawLine(rect
.x
+ rect
.width
- 15, rect
.y
, rect
.x
+ rect
.width
- 15,
1685 rect
.y
+ rect
.height
);
1687 up_btn
= wxRect(rect
.x
+ rect
.width
- 15, rect
.y
, 15, rect
.height
/ 3);
1689 down_btn
= wxRect(up_btn
.GetLeft(), up_btn
.GetBottom() + 1,
1690 up_btn
.GetWidth(), up_btn
.GetHeight());
1691 dc
.DrawLine(down_btn
.GetLeft(), down_btn
.GetTop(), down_btn
.GetRight(),
1694 ext_btn
= wxRect(up_btn
.GetLeft(), down_btn
.GetBottom() + 1, up_btn
.GetWidth(),
1695 rect
.height
- up_btn
.GetHeight() - down_btn
.GetHeight() - 1);
1696 dc
.DrawLine(ext_btn
.GetLeft(), ext_btn
.GetTop(), ext_btn
.GetRight(),
1700 DrawGalleryButton(dc
, up_btn
, wnd
->GetUpButtonState(),
1701 m_gallery_up_bitmap
);
1702 DrawGalleryButton(dc
, down_btn
, wnd
->GetDownButtonState(),
1703 m_gallery_down_bitmap
);
1704 DrawGalleryButton(dc
, ext_btn
, wnd
->GetExtensionButtonState(),
1705 m_gallery_extension_bitmap
);
1708 void wxRibbonMSWArtProvider::DrawGalleryButton(wxDC
& dc
,
1710 wxRibbonGalleryButtonState state
,
1713 wxBitmap btn_bitmap
;
1714 wxBrush btn_top_brush
;
1715 wxColour btn_colour
;
1716 wxColour btn_grad_colour
;
1719 case wxRIBBON_GALLERY_BUTTON_NORMAL
:
1720 btn_top_brush
= m_gallery_button_background_top_brush
;
1721 btn_colour
= m_gallery_button_background_colour
;
1722 btn_grad_colour
= m_gallery_button_background_gradient_colour
;
1723 btn_bitmap
= bitmaps
[0];
1725 case wxRIBBON_GALLERY_BUTTON_HOVERED
:
1726 btn_top_brush
= m_gallery_button_hover_background_top_brush
;
1727 btn_colour
= m_gallery_button_hover_background_colour
;
1728 btn_grad_colour
= m_gallery_button_hover_background_gradient_colour
;
1729 btn_bitmap
= bitmaps
[1];
1731 case wxRIBBON_GALLERY_BUTTON_ACTIVE
:
1732 btn_top_brush
= m_gallery_button_active_background_top_brush
;
1733 btn_colour
= m_gallery_button_active_background_colour
;
1734 btn_grad_colour
= m_gallery_button_active_background_gradient_colour
;
1735 btn_bitmap
= bitmaps
[2];
1737 case wxRIBBON_GALLERY_BUTTON_DISABLED
:
1738 btn_top_brush
= m_gallery_button_disabled_background_top_brush
;
1739 btn_colour
= m_gallery_button_disabled_background_colour
;
1740 btn_grad_colour
= m_gallery_button_disabled_background_gradient_colour
;
1741 btn_bitmap
= bitmaps
[3];
1747 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1758 dc
.SetPen(*wxTRANSPARENT_PEN
);
1759 dc
.SetBrush(btn_top_brush
);
1760 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
/ 2);
1763 lower
.height
= (lower
.height
+ 1) / 2;
1764 lower
.y
+= rect
.height
- lower
.height
;
1765 dc
.GradientFillLinear(lower
, btn_colour
, btn_grad_colour
, wxSOUTH
);
1767 dc
.DrawBitmap(btn_bitmap
, rect
.x
+ rect
.width
/ 2 - 2, lower
.y
- 2, true);
1770 void wxRibbonMSWArtProvider::DrawGalleryItemBackground(
1772 wxRibbonGallery
* wnd
,
1774 wxRibbonGalleryItem
* item
)
1776 if(wnd
->GetHoveredItem() != item
&& wnd
->GetActiveItem() != item
&&
1777 wnd
->GetSelection() != item
)
1780 dc
.SetPen(m_gallery_item_border_pen
);
1781 dc
.DrawLine(rect
.x
+ 1, rect
.y
, rect
.x
+ rect
.width
- 1, rect
.y
);
1782 dc
.DrawLine(rect
.x
, rect
.y
+ 1, rect
.x
, rect
.y
+ rect
.height
- 1);
1783 dc
.DrawLine(rect
.x
+ 1, rect
.y
+ rect
.height
- 1, rect
.x
+ rect
.width
- 1,
1784 rect
.y
+ rect
.height
- 1);
1785 dc
.DrawLine(rect
.x
+ rect
.width
- 1, rect
.y
+ 1, rect
.x
+ rect
.width
- 1,
1786 rect
.y
+ rect
.height
- 1);
1790 wxColour bg_gradient_colour
;
1792 if(wnd
->GetActiveItem() == item
|| wnd
->GetSelection() == item
)
1794 top_brush
= m_gallery_button_active_background_top_brush
;
1795 bg_colour
= m_gallery_button_active_background_colour
;
1796 bg_gradient_colour
= m_gallery_button_active_background_gradient_colour
;
1800 top_brush
= m_gallery_button_hover_background_top_brush
;
1801 bg_colour
= m_gallery_button_hover_background_colour
;
1802 bg_gradient_colour
= m_gallery_button_hover_background_gradient_colour
;
1810 dc
.SetPen(*wxTRANSPARENT_PEN
);
1811 dc
.SetBrush(top_brush
);
1812 dc
.DrawRectangle(upper
.x
, upper
.y
, upper
.width
, upper
.height
);
1814 wxRect
lower(upper
);
1815 lower
.y
+= lower
.height
;
1816 lower
.height
= rect
.height
- 2 - lower
.height
;
1817 dc
.GradientFillLinear(lower
, bg_colour
, bg_gradient_colour
, wxSOUTH
);
1820 void wxRibbonMSWArtProvider::DrawPanelBorder(wxDC
& dc
, const wxRect
& rect
,
1821 wxPen
& primary_colour
,
1822 wxPen
& secondary_colour
)
1824 wxPoint border_points
[9];
1825 border_points
[0] = wxPoint(2, 0);
1826 border_points
[1] = wxPoint(rect
.width
- 3, 0);
1827 border_points
[2] = wxPoint(rect
.width
- 1, 2);
1828 border_points
[3] = wxPoint(rect
.width
- 1, rect
.height
- 3);
1829 border_points
[4] = wxPoint(rect
.width
- 3, rect
.height
- 1);
1830 border_points
[5] = wxPoint(2, rect
.height
- 1);
1831 border_points
[6] = wxPoint(0, rect
.height
- 3);
1832 border_points
[7] = wxPoint(0, 2);
1834 if(primary_colour
.GetColour() == secondary_colour
.GetColour())
1836 border_points
[8] = border_points
[0];
1837 dc
.SetPen(primary_colour
);
1838 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
, rect
.x
, rect
.y
);
1842 dc
.SetPen(primary_colour
);
1843 dc
.DrawLines(3, border_points
, rect
.x
, rect
.y
);
1845 #define SingleLine(start, finish) \
1846 dc.DrawLine(start.x + rect.x, start.y + rect.y, finish.x + rect.x, finish.y + rect.y)
1848 SingleLine(border_points
[0], border_points
[7]);
1849 dc
.SetPen(secondary_colour
);
1850 dc
.DrawLines(3, border_points
+ 4, rect
.x
, rect
.y
);
1851 SingleLine(border_points
[4], border_points
[3]);
1855 border_points
[6] = border_points
[2];
1856 wxRibbonDrawParallelGradientLines(dc
, 2, border_points
+ 6, 0, 1,
1857 border_points
[3].y
- border_points
[2].y
+ 1, rect
.x
, rect
.y
,
1858 primary_colour
.GetColour(), secondary_colour
.GetColour());
1862 void wxRibbonMSWArtProvider::DrawMinimisedPanel(
1868 DrawPartialPageBackground(dc
, wnd
, rect
, false);
1870 wxRect
true_rect(rect
);
1871 RemovePanelPadding(&true_rect
);
1873 if(wnd
->GetExpandedPanel() != NULL
)
1875 wxRect
client_rect(true_rect
);
1877 client_rect
.width
-= 2;
1879 client_rect
.height
= (rect
.y
+ rect
.height
/ 5) - client_rect
.x
;
1880 dc
.GradientFillLinear(client_rect
,
1881 m_panel_active_background_top_colour
,
1882 m_panel_active_background_top_gradient_colour
, wxSOUTH
);
1884 client_rect
.y
+= client_rect
.height
;
1885 client_rect
.height
= (true_rect
.y
+ true_rect
.height
) - client_rect
.y
;
1886 dc
.GradientFillLinear(client_rect
,
1887 m_panel_active_background_colour
,
1888 m_panel_active_background_gradient_colour
, wxSOUTH
);
1890 else if(wnd
->IsHovered())
1892 wxRect
client_rect(true_rect
);
1894 client_rect
.width
-= 2;
1896 client_rect
.height
-= 2;
1897 DrawPartialPageBackground(dc
, wnd
, client_rect
, true);
1901 DrawMinimisedPanelCommon(dc
, wnd
, true_rect
, &preview
);
1903 dc
.SetBrush(m_panel_hover_label_background_brush
);
1904 dc
.SetPen(*wxTRANSPARENT_PEN
);
1905 dc
.DrawRectangle(preview
.x
+ 1, preview
.y
+ preview
.height
- 8,
1906 preview
.width
- 2, 7);
1908 int mid_pos
= rect
.y
+ rect
.height
/ 5 - preview
.y
;
1909 if(mid_pos
< 0 || mid_pos
>= preview
.height
)
1911 wxRect
full_rect(preview
);
1914 full_rect
.width
-= 2;
1915 full_rect
.height
-= 9;
1918 dc
.GradientFillLinear(full_rect
,
1919 m_page_hover_background_colour
,
1920 m_page_hover_background_gradient_colour
, wxSOUTH
);
1924 dc
.GradientFillLinear(full_rect
,
1925 m_page_hover_background_top_colour
,
1926 m_page_hover_background_top_gradient_colour
, wxSOUTH
);
1931 wxRect
top_rect(preview
);
1934 top_rect
.width
-= 2;
1935 top_rect
.height
= mid_pos
;
1936 dc
.GradientFillLinear(top_rect
,
1937 m_page_hover_background_top_colour
,
1938 m_page_hover_background_top_gradient_colour
, wxSOUTH
);
1940 wxRect
btm_rect(top_rect
);
1941 btm_rect
.y
= preview
.y
+ mid_pos
;
1942 btm_rect
.height
= preview
.y
+ preview
.height
- 7 - btm_rect
.y
;
1943 dc
.GradientFillLinear(btm_rect
,
1944 m_page_hover_background_colour
,
1945 m_page_hover_background_gradient_colour
, wxSOUTH
);
1950 dc
.DrawBitmap(bitmap
, preview
.x
+ (preview
.width
- bitmap
.GetWidth()) / 2,
1951 preview
.y
+ (preview
.height
- 7 - bitmap
.GetHeight()) / 2, true);
1954 DrawPanelBorder(dc
, preview
, m_panel_border_pen
, m_panel_border_gradient_pen
);
1956 DrawPanelBorder(dc
, true_rect
, m_panel_minimised_border_pen
,
1957 m_panel_minimised_border_gradient_pen
);
1960 void wxRibbonMSWArtProvider::DrawMinimisedPanelCommon(
1963 const wxRect
& true_rect
,
1964 wxRect
* preview_rect
)
1966 wxRect
preview(0, 0, 32, 32);
1967 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1969 preview
.x
= true_rect
.x
+ 4;
1970 preview
.y
= true_rect
.y
+ (true_rect
.height
- preview
.height
) / 2;
1974 preview
.x
= true_rect
.x
+ (true_rect
.width
- preview
.width
) / 2;
1975 preview
.y
= true_rect
.y
+ 4;
1978 *preview_rect
= preview
;
1980 wxCoord label_width
, label_height
;
1981 dc
.SetFont(m_panel_label_font
);
1982 dc
.GetTextExtent(wnd
->GetLabel(), &label_width
, &label_height
);
1984 int xpos
= true_rect
.x
+ (true_rect
.width
- label_width
+ 1) / 2;
1985 int ypos
= preview
.y
+ preview
.height
+ 5;
1987 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1989 xpos
= preview
.x
+ preview
.width
+ 5;
1990 ypos
= true_rect
.y
+ (true_rect
.height
- label_height
) / 2;
1993 dc
.SetTextForeground(m_panel_minimised_label_colour
);
1994 dc
.DrawText(wnd
->GetLabel(), xpos
, ypos
);
1997 wxPoint arrow_points
[3];
1998 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2000 xpos
+= label_width
;
2001 arrow_points
[0] = wxPoint(xpos
+ 5, ypos
+ label_height
/ 2);
2002 arrow_points
[1] = arrow_points
[0] + wxPoint(-3, 3);
2003 arrow_points
[2] = arrow_points
[0] + wxPoint(-3, -3);
2007 ypos
+= label_height
;
2008 arrow_points
[0] = wxPoint(true_rect
.width
/ 2, ypos
+ 5);
2009 arrow_points
[1] = arrow_points
[0] + wxPoint(-3, -3);
2010 arrow_points
[2] = arrow_points
[0] + wxPoint( 3, -3);
2013 dc
.SetPen(*wxTRANSPARENT_PEN
);
2014 wxBrush
B(m_panel_minimised_label_colour
);
2016 dc
.DrawPolygon(sizeof(arrow_points
)/sizeof(wxPoint
), arrow_points
,
2017 true_rect
.x
, true_rect
.y
);
2020 void wxRibbonMSWArtProvider::DrawButtonBarBackground(
2025 DrawPartialPageBackground(dc
, wnd
, rect
, true);
2028 void wxRibbonMSWArtProvider::DrawPartialPageBackground(
2034 // Assume the window is a child of a ribbon page, and also check for a
2035 // hovered panel somewhere between the window and the page, as it causes
2036 // the background to change.
2037 wxPoint
offset(wnd
->GetPosition());
2038 wxRibbonPage
* page
= NULL
;
2039 wxWindow
* parent
= wnd
->GetParent();
2040 wxRibbonPanel
* panel
= wxDynamicCast(wnd
, wxRibbonPanel
);
2041 bool hovered
= false;
2045 hovered
= allow_hovered
&& panel
->IsHovered();
2046 if(panel
->GetExpandedDummy() != NULL
)
2048 offset
= panel
->GetExpandedDummy()->GetPosition();
2049 parent
= panel
->GetExpandedDummy()->GetParent();
2052 for(; parent
; parent
= parent
->GetParent())
2056 panel
= wxDynamicCast(parent
, wxRibbonPanel
);
2059 hovered
= allow_hovered
&& panel
->IsHovered();
2060 if(panel
->GetExpandedDummy() != NULL
)
2062 parent
= panel
->GetExpandedDummy();
2066 page
= wxDynamicCast(parent
, wxRibbonPage
);
2071 offset
+= parent
->GetPosition();
2075 DrawPartialPageBackground(dc
, wnd
, rect
, page
, offset
, hovered
);
2079 // No page found - fallback to painting with a stock brush
2080 dc
.SetBrush(*wxWHITE_BRUSH
);
2081 dc
.SetPen(*wxTRANSPARENT_PEN
);
2082 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
2085 void wxRibbonMSWArtProvider::DrawButtonBarButton(
2087 wxWindow
* WXUNUSED(wnd
),
2089 wxRibbonButtonKind kind
,
2091 const wxString
& label
,
2092 const wxBitmap
& bitmap_large
,
2093 const wxBitmap
& bitmap_small
)
2095 if(kind
== wxRIBBON_BUTTON_TOGGLE
)
2097 kind
= wxRIBBON_BUTTON_NORMAL
;
2098 if(state
& wxRIBBON_BUTTONBAR_BUTTON_TOGGLED
)
2099 state
^= wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK
;
2102 if(state
& (wxRIBBON_BUTTONBAR_BUTTON_HOVER_MASK
|
2103 wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK
))
2105 if(state
& wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK
)
2106 dc
.SetPen(m_button_bar_active_border_pen
);
2108 dc
.SetPen(m_button_bar_hover_border_pen
);
2110 wxRect
bg_rect(rect
);
2114 bg_rect
.height
-= 2;
2116 wxRect
bg_rect_top(bg_rect
);
2117 bg_rect_top
.height
/= 3;
2118 bg_rect
.y
+= bg_rect_top
.height
;
2119 bg_rect
.height
-= bg_rect_top
.height
;
2121 if(kind
== wxRIBBON_BUTTON_HYBRID
)
2123 switch(state
& wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK
)
2125 case wxRIBBON_BUTTONBAR_BUTTON_LARGE
:
2127 int iYBorder
= rect
.y
+ bitmap_large
.GetHeight() + 4;
2128 wxRect
partial_bg(rect
);
2129 if(state
& wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED
)
2131 partial_bg
.SetBottom(iYBorder
- 1);
2135 partial_bg
.height
-= (iYBorder
- partial_bg
.y
+ 1);
2136 partial_bg
.y
= iYBorder
+ 1;
2138 dc
.DrawLine(rect
.x
, iYBorder
, rect
.x
+ rect
.width
, iYBorder
);
2139 bg_rect
.Intersect(partial_bg
);
2140 bg_rect_top
.Intersect(partial_bg
);
2143 case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM
:
2145 int iArrowWidth
= 9;
2146 if(state
& wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED
)
2148 bg_rect
.width
-= iArrowWidth
;
2149 bg_rect_top
.width
-= iArrowWidth
;
2150 dc
.DrawLine(bg_rect_top
.x
+ bg_rect_top
.width
,
2151 rect
.y
, bg_rect_top
.x
+ bg_rect_top
.width
,
2152 rect
.y
+ rect
.height
);
2157 bg_rect
.x
+= bg_rect
.width
- iArrowWidth
;
2158 bg_rect_top
.x
+= bg_rect_top
.width
- iArrowWidth
;
2159 bg_rect
.width
= iArrowWidth
;
2160 bg_rect_top
.width
= iArrowWidth
;
2161 dc
.DrawLine(bg_rect_top
.x
- 1, rect
.y
,
2162 bg_rect_top
.x
- 1, rect
.y
+ rect
.height
);
2166 case wxRIBBON_BUTTONBAR_BUTTON_SMALL
:
2171 if(state
& wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK
)
2173 dc
.GradientFillLinear(bg_rect_top
,
2174 m_button_bar_active_background_top_colour
,
2175 m_button_bar_active_background_top_gradient_colour
, wxSOUTH
);
2176 dc
.GradientFillLinear(bg_rect
,
2177 m_button_bar_active_background_colour
,
2178 m_button_bar_active_background_gradient_colour
, wxSOUTH
);
2182 dc
.GradientFillLinear(bg_rect_top
,
2183 m_button_bar_hover_background_top_colour
,
2184 m_button_bar_hover_background_top_gradient_colour
, wxSOUTH
);
2185 dc
.GradientFillLinear(bg_rect
,
2186 m_button_bar_hover_background_colour
,
2187 m_button_bar_hover_background_gradient_colour
, wxSOUTH
);
2190 wxPoint border_points
[9];
2191 border_points
[0] = wxPoint(2, 0);
2192 border_points
[1] = wxPoint(rect
.width
- 3, 0);
2193 border_points
[2] = wxPoint(rect
.width
- 1, 2);
2194 border_points
[3] = wxPoint(rect
.width
- 1, rect
.height
- 3);
2195 border_points
[4] = wxPoint(rect
.width
- 3, rect
.height
- 1);
2196 border_points
[5] = wxPoint(2, rect
.height
- 1);
2197 border_points
[6] = wxPoint(0, rect
.height
- 3);
2198 border_points
[7] = wxPoint(0, 2);
2199 border_points
[8] = border_points
[0];
2201 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
,
2205 dc
.SetFont(m_button_bar_label_font
);
2206 dc
.SetTextForeground(m_button_bar_label_colour
);
2207 DrawButtonBarButtonForeground(dc
, rect
, kind
, state
, label
, bitmap_large
,
2211 void wxRibbonMSWArtProvider::DrawButtonBarButtonForeground(
2214 wxRibbonButtonKind kind
,
2216 const wxString
& label
,
2217 const wxBitmap
& bitmap_large
,
2218 const wxBitmap
& bitmap_small
)
2220 switch(state
& wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK
)
2222 case wxRIBBON_BUTTONBAR_BUTTON_LARGE
:
2224 const int padding
= 2;
2225 dc
.DrawBitmap(bitmap_large
,
2226 rect
.x
+ (rect
.width
- bitmap_large
.GetWidth()) / 2,
2227 rect
.y
+ padding
, true);
2228 int ypos
= rect
.y
+ padding
+ bitmap_large
.GetHeight() + padding
;
2229 int arrow_width
= kind
== wxRIBBON_BUTTON_NORMAL
? 0 : 8;
2230 wxCoord label_w
, label_h
;
2231 dc
.GetTextExtent(label
, &label_w
, &label_h
);
2232 if(label_w
+ 2 * padding
<= rect
.width
)
2234 dc
.DrawText(label
, rect
.x
+ (rect
.width
- label_w
) / 2, ypos
);
2235 if(arrow_width
!= 0)
2237 DrawDropdownArrow(dc
, rect
.x
+ rect
.width
/ 2,
2238 ypos
+ (label_h
* 3) / 2,
2239 m_button_bar_label_colour
);
2244 size_t breaki
= label
.Len();
2248 if(wxRibbonCanLabelBreakAtPosition(label
, breaki
))
2250 wxString label_top
= label
.Mid(0, breaki
);
2251 dc
.GetTextExtent(label_top
, &label_w
, &label_h
);
2252 if(label_w
+ 2 * padding
<= rect
.width
)
2254 dc
.DrawText(label_top
,
2255 rect
.x
+ (rect
.width
- label_w
) / 2, ypos
);
2257 wxString label_bottom
= label
.Mid(breaki
+ 1);
2258 dc
.GetTextExtent(label_bottom
, &label_w
, &label_h
);
2259 label_w
+= arrow_width
;
2260 int iX
= rect
.x
+ (rect
.width
- label_w
) / 2;
2261 dc
.DrawText(label_bottom
, iX
, ypos
);
2262 if(arrow_width
!= 0)
2264 DrawDropdownArrow(dc
,
2265 iX
+ 2 +label_w
- arrow_width
,
2266 ypos
+ label_h
/ 2 + 1,
2267 m_button_bar_label_colour
);
2272 } while(breaki
> 0);
2276 case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM
:
2278 int x_cursor
= rect
.x
+ 2;
2279 dc
.DrawBitmap(bitmap_small
, x_cursor
,
2280 rect
.y
+ (rect
.height
- bitmap_small
.GetHeight())/2, true);
2281 x_cursor
+= bitmap_small
.GetWidth() + 2;
2282 wxCoord label_w
, label_h
;
2283 dc
.GetTextExtent(label
, &label_w
, &label_h
);
2284 dc
.DrawText(label
, x_cursor
,
2285 rect
.y
+ (rect
.height
- label_h
) / 2);
2286 x_cursor
+= label_w
+ 3;
2287 if(kind
!= wxRIBBON_BUTTON_NORMAL
)
2289 DrawDropdownArrow(dc
, x_cursor
, rect
.y
+ rect
.height
/ 2,
2290 m_button_bar_label_colour
);
2300 void wxRibbonMSWArtProvider::DrawToolBarBackground(
2305 DrawPartialPageBackground(dc
, wnd
, rect
);
2308 void wxRibbonMSWArtProvider::DrawToolGroupBackground(
2310 wxWindow
* WXUNUSED(wnd
),
2313 dc
.SetPen(m_toolbar_border_pen
);
2315 outline
[0] = wxPoint(2, 0);
2316 outline
[1] = wxPoint(rect
.width
- 3, 0);
2317 outline
[2] = wxPoint(rect
.width
- 1, 2);
2318 outline
[3] = wxPoint(rect
.width
- 1, rect
.height
- 3);
2319 outline
[4] = wxPoint(rect
.width
- 3, rect
.height
- 1);
2320 outline
[5] = wxPoint(2, rect
.height
- 1);
2321 outline
[6] = wxPoint(0, rect
.height
- 3);
2322 outline
[7] = wxPoint(0, 2);
2323 outline
[8] = outline
[0];
2325 dc
.DrawLines(sizeof(outline
)/sizeof(wxPoint
), outline
, rect
.x
, rect
.y
);
2328 void wxRibbonMSWArtProvider::DrawTool(
2330 wxWindow
* WXUNUSED(wnd
),
2332 const wxBitmap
& bitmap
,
2333 wxRibbonButtonKind kind
,
2336 if(kind
== wxRIBBON_BUTTON_TOGGLE
)
2338 if(state
& wxRIBBON_TOOLBAR_TOOL_TOGGLED
)
2339 state
^= wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK
;
2342 wxRect
bg_rect(rect
);
2344 if((state
& wxRIBBON_TOOLBAR_TOOL_LAST
) == 0)
2346 bool is_split_hybrid
= (kind
== wxRIBBON_BUTTON_HYBRID
&& (state
&
2347 (wxRIBBON_TOOLBAR_TOOL_HOVER_MASK
| wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK
)));
2350 wxRect
bg_rect_top(bg_rect
);
2351 bg_rect_top
.height
= (bg_rect_top
.height
* 2) / 5;
2352 wxRect
bg_rect_btm(bg_rect
);
2353 bg_rect_btm
.y
+= bg_rect_top
.height
;
2354 bg_rect_btm
.height
-= bg_rect_top
.height
;
2355 wxColour bg_top_colour
= m_tool_background_top_colour
;
2356 wxColour bg_top_grad_colour
= m_tool_background_top_gradient_colour
;
2357 wxColour bg_colour
= m_tool_background_colour
;
2358 wxColour bg_grad_colour
= m_tool_background_gradient_colour
;
2359 if(state
& wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK
)
2361 bg_top_colour
= m_tool_active_background_top_colour
;
2362 bg_top_grad_colour
= m_tool_active_background_top_gradient_colour
;
2363 bg_colour
= m_tool_active_background_colour
;
2364 bg_grad_colour
= m_tool_active_background_gradient_colour
;
2366 else if(state
& wxRIBBON_TOOLBAR_TOOL_HOVER_MASK
)
2368 bg_top_colour
= m_tool_hover_background_top_colour
;
2369 bg_top_grad_colour
= m_tool_hover_background_top_gradient_colour
;
2370 bg_colour
= m_tool_hover_background_colour
;
2371 bg_grad_colour
= m_tool_hover_background_gradient_colour
;
2373 dc
.GradientFillLinear(bg_rect_top
, bg_top_colour
, bg_top_grad_colour
, wxSOUTH
);
2374 dc
.GradientFillLinear(bg_rect_btm
, bg_colour
, bg_grad_colour
, wxSOUTH
);
2377 wxRect
nonrect(bg_rect
);
2378 if(state
& (wxRIBBON_TOOLBAR_TOOL_DROPDOWN_HOVERED
|
2379 wxRIBBON_TOOLBAR_TOOL_DROPDOWN_ACTIVE
))
2385 nonrect
.x
+= nonrect
.width
- 8;
2388 wxBrush
B(m_tool_hover_background_top_colour
);
2389 dc
.SetPen(*wxTRANSPARENT_PEN
);
2391 dc
.DrawRectangle(nonrect
.x
, nonrect
.y
, nonrect
.width
, nonrect
.height
);
2395 dc
.SetPen(m_toolbar_border_pen
);
2396 if(state
& wxRIBBON_TOOLBAR_TOOL_FIRST
)
2398 dc
.DrawPoint(rect
.x
+ 1, rect
.y
+ 1);
2399 dc
.DrawPoint(rect
.x
+ 1, rect
.y
+ rect
.height
- 2);
2402 dc
.DrawLine(rect
.x
, rect
.y
+ 1, rect
.x
, rect
.y
+ rect
.height
- 1);
2404 if(state
& wxRIBBON_TOOLBAR_TOOL_LAST
)
2406 dc
.DrawPoint(rect
.x
+ rect
.width
- 2, rect
.y
+ 1);
2407 dc
.DrawPoint(rect
.x
+ rect
.width
- 2, rect
.y
+ rect
.height
- 2);
2411 int avail_width
= bg_rect
.GetWidth();
2412 if(kind
& wxRIBBON_BUTTON_DROPDOWN
)
2417 dc
.DrawLine(rect
.x
+ avail_width
+ 1, rect
.y
,
2418 rect
.x
+ avail_width
+ 1, rect
.y
+ rect
.height
);
2420 dc
.DrawBitmap(m_toolbar_drop_bitmap
, bg_rect
.x
+ avail_width
+ 2,
2421 bg_rect
.y
+ (bg_rect
.height
/ 2) - 2, true);
2423 dc
.DrawBitmap(bitmap
, bg_rect
.x
+ (avail_width
- bitmap
.GetWidth()) / 2,
2424 bg_rect
.y
+ (bg_rect
.height
- bitmap
.GetHeight()) / 2, true);
2427 void wxRibbonMSWArtProvider::GetBarTabWidth(
2429 wxWindow
* WXUNUSED(wnd
),
2430 const wxString
& label
,
2431 const wxBitmap
& bitmap
,
2433 int* small_begin_need_separator
,
2434 int* small_must_have_separator
,
2439 if((m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
) && !label
.IsEmpty())
2441 dc
.SetFont(m_tab_label_font
);
2442 width
+= dc
.GetTextExtent(label
).GetWidth();
2443 min
+= wxMin(25, width
); // enough for a few chars
2446 // gap between label and bitmap
2451 if((m_flags
& wxRIBBON_BAR_SHOW_PAGE_ICONS
) && bitmap
.IsOk())
2453 width
+= bitmap
.GetWidth();
2454 min
+= bitmap
.GetWidth();
2459 *ideal
= width
+ 30;
2461 if(small_begin_need_separator
!= NULL
)
2463 *small_begin_need_separator
= width
+ 20;
2465 if(small_must_have_separator
!= NULL
)
2467 *small_must_have_separator
= width
+ 10;
2475 int wxRibbonMSWArtProvider::GetTabCtrlHeight(
2477 wxWindow
* WXUNUSED(wnd
),
2478 const wxRibbonPageTabInfoArray
& pages
)
2480 int text_height
= 0;
2481 int icon_height
= 0;
2483 if(pages
.GetCount() <= 1 && (m_flags
& wxRIBBON_BAR_ALWAYS_SHOW_TABS
) == 0)
2485 // To preserve space, a single tab need not be displayed. We still need
2486 // two pixels of border / padding though.
2490 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
)
2492 dc
.SetFont(m_tab_label_font
);
2493 text_height
= dc
.GetTextExtent(wxT("ABCDEFXj")).GetHeight() + 10;
2495 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_ICONS
)
2497 size_t numpages
= pages
.GetCount();
2498 for(size_t i
= 0; i
< numpages
; ++i
)
2500 const wxRibbonPageTabInfo
& info
= pages
.Item(i
);
2501 if(info
.page
->GetIcon().IsOk())
2503 icon_height
= wxMax(icon_height
, info
.page
->GetIcon().GetHeight() + 4);
2508 return wxMax(text_height
, icon_height
);
2511 wxSize
wxRibbonMSWArtProvider::GetScrollButtonMinimumSize(
2513 wxWindow
* WXUNUSED(wnd
),
2514 long WXUNUSED(style
))
2516 return wxSize(12, 12);
2519 wxSize
wxRibbonMSWArtProvider::GetPanelSize(
2521 const wxRibbonPanel
* wnd
,
2523 wxPoint
* client_offset
)
2525 dc
.SetFont(m_panel_label_font
);
2526 wxSize label_size
= dc
.GetTextExtent(wnd
->GetLabel());
2528 client_size
.IncBy(0, label_size
.GetHeight());
2529 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2530 client_size
.IncBy(4, 8);
2532 client_size
.IncBy(6, 6);
2534 if(client_offset
!= NULL
)
2536 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2537 *client_offset
= wxPoint(2, 3);
2539 *client_offset
= wxPoint(3, 2);
2545 wxSize
wxRibbonMSWArtProvider::GetPanelClientSize(
2547 const wxRibbonPanel
* wnd
,
2549 wxPoint
* client_offset
)
2551 dc
.SetFont(m_panel_label_font
);
2552 wxSize label_size
= dc
.GetTextExtent(wnd
->GetLabel());
2554 size
.DecBy(0, label_size
.GetHeight());
2555 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2560 if(client_offset
!= NULL
)
2562 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2563 *client_offset
= wxPoint(2, 3);
2565 *client_offset
= wxPoint(3, 2);
2567 if (size
.x
< 0) size
.x
= 0;
2568 if (size
.y
< 0) size
.y
= 0;
2573 wxSize
wxRibbonMSWArtProvider::GetGallerySize(
2575 const wxRibbonGallery
* WXUNUSED(wnd
),
2578 client_size
.IncBy( 2, 1); // Left / top padding
2579 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2580 client_size
.IncBy(1, 16); // Right / bottom padding
2582 client_size
.IncBy(16, 1); // Right / bottom padding
2586 wxSize
wxRibbonMSWArtProvider::GetGalleryClientSize(
2588 const wxRibbonGallery
* WXUNUSED(wnd
),
2590 wxPoint
* client_offset
,
2591 wxRect
* scroll_up_button
,
2592 wxRect
* scroll_down_button
,
2593 wxRect
* extension_button
)
2598 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2600 // Flow is vertical - put buttons on bottom
2601 scroll_up
.y
= size
.GetHeight() - 15;
2602 scroll_up
.height
= 15;
2604 scroll_up
.width
= (size
.GetWidth() + 2) / 3;
2605 scroll_down
.y
= scroll_up
.y
;
2606 scroll_down
.height
= scroll_up
.height
;
2607 scroll_down
.x
= scroll_up
.x
+ scroll_up
.width
;
2608 scroll_down
.width
= scroll_up
.width
;
2609 extension
.y
= scroll_down
.y
;
2610 extension
.height
= scroll_down
.height
;
2611 extension
.x
= scroll_down
.x
+ scroll_down
.width
;
2612 extension
.width
= size
.GetWidth() - scroll_up
.width
- scroll_down
.width
;
2618 // Flow is horizontal - put buttons on right
2619 scroll_up
.x
= size
.GetWidth() - 15;
2620 scroll_up
.width
= 15;
2622 scroll_up
.height
= (size
.GetHeight() + 2) / 3;
2623 scroll_down
.x
= scroll_up
.x
;
2624 scroll_down
.width
= scroll_up
.width
;
2625 scroll_down
.y
= scroll_up
.y
+ scroll_up
.height
;
2626 scroll_down
.height
= scroll_up
.height
;
2627 extension
.x
= scroll_down
.x
;
2628 extension
.width
= scroll_down
.width
;
2629 extension
.y
= scroll_down
.y
+ scroll_down
.height
;
2630 extension
.height
= size
.GetHeight() - scroll_up
.height
- scroll_down
.height
;
2635 if(client_offset
!= NULL
)
2636 *client_offset
= wxPoint(2, 1);
2637 if(scroll_up_button
!= NULL
)
2638 *scroll_up_button
= scroll_up
;
2639 if(scroll_down_button
!= NULL
)
2640 *scroll_down_button
= scroll_down
;
2641 if(extension_button
!= NULL
)
2642 *extension_button
= extension
;
2647 wxRect
wxRibbonMSWArtProvider::GetPageBackgroundRedrawArea(
2649 const wxRibbonPage
* WXUNUSED(wnd
),
2650 wxSize page_old_size
,
2651 wxSize page_new_size
)
2653 wxRect new_rect
, old_rect
;
2655 if(page_new_size
.GetWidth() != page_old_size
.GetWidth())
2657 if(page_new_size
.GetHeight() != page_old_size
.GetHeight())
2659 // Width and height both changed - redraw everything
2660 return wxRect(page_new_size
);
2664 // Only width changed - redraw right hand side
2665 const int right_edge_width
= 4;
2667 new_rect
= wxRect(page_new_size
.GetWidth() - right_edge_width
, 0, right_edge_width
, page_new_size
.GetHeight());
2668 old_rect
= wxRect(page_old_size
.GetWidth() - right_edge_width
, 0, right_edge_width
, page_old_size
.GetHeight());
2673 if(page_new_size
.GetHeight() == page_old_size
.GetHeight())
2675 // Nothing changed (should never happen) - redraw nothing
2676 return wxRect(0, 0, 0, 0);
2680 // Height changed - need to redraw everything (as the background
2681 // gradient is done vertically).
2682 return page_new_size
;
2686 new_rect
.Union(old_rect
);
2687 new_rect
.Intersect(wxRect(page_new_size
));
2691 bool wxRibbonMSWArtProvider::GetButtonBarButtonSize(
2694 wxRibbonButtonKind kind
,
2695 wxRibbonButtonBarButtonState size
,
2696 const wxString
& label
,
2697 wxSize bitmap_size_large
,
2698 wxSize bitmap_size_small
,
2699 wxSize
* button_size
,
2700 wxRect
* normal_region
,
2701 wxRect
* dropdown_region
)
2703 const int drop_button_width
= 8;
2705 dc
.SetFont(m_button_bar_label_font
);
2706 switch(size
& wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK
)
2708 case wxRIBBON_BUTTONBAR_BUTTON_SMALL
:
2709 // Small bitmap, no label
2710 *button_size
= bitmap_size_small
+ wxSize(6, 4);
2713 case wxRIBBON_BUTTON_NORMAL
:
2714 case wxRIBBON_BUTTON_TOGGLE
:
2715 *normal_region
= wxRect(*button_size
);
2716 *dropdown_region
= wxRect(0, 0, 0, 0);
2718 case wxRIBBON_BUTTON_DROPDOWN
:
2719 *button_size
+= wxSize(drop_button_width
, 0);
2720 *dropdown_region
= wxRect(*button_size
);
2721 *normal_region
= wxRect(0, 0, 0, 0);
2723 case wxRIBBON_BUTTON_HYBRID
:
2724 *normal_region
= wxRect(*button_size
);
2725 *dropdown_region
= wxRect(button_size
->GetWidth(), 0,
2726 drop_button_width
, button_size
->GetHeight());
2727 *button_size
+= wxSize(drop_button_width
, 0);
2731 case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM
:
2732 // Small bitmap, with label to the right
2734 GetButtonBarButtonSize(dc
, wnd
, kind
, wxRIBBON_BUTTONBAR_BUTTON_SMALL
,
2735 label
, bitmap_size_large
, bitmap_size_small
, button_size
,
2736 normal_region
, dropdown_region
);
2737 int text_size
= dc
.GetTextExtent(label
).GetWidth();
2738 button_size
->SetWidth(button_size
->GetWidth() + text_size
);
2741 case wxRIBBON_BUTTON_DROPDOWN
:
2742 dropdown_region
->SetWidth(dropdown_region
->GetWidth() + text_size
);
2744 case wxRIBBON_BUTTON_HYBRID
:
2745 dropdown_region
->SetX(dropdown_region
->GetX() + text_size
);
2747 case wxRIBBON_BUTTON_NORMAL
:
2748 case wxRIBBON_BUTTON_TOGGLE
:
2749 normal_region
->SetWidth(normal_region
->GetWidth() + text_size
);
2754 case wxRIBBON_BUTTONBAR_BUTTON_LARGE
:
2755 // Large bitmap, with label below (possibly split over 2 lines)
2757 wxSize
icon_size(bitmap_size_large
);
2758 icon_size
+= wxSize(4, 4);
2759 wxCoord label_height
;
2761 dc
.GetTextExtent(label
, &best_width
, &label_height
);
2762 int last_line_extra_width
= 0;
2763 if(kind
!= wxRIBBON_BUTTON_NORMAL
&& kind
!= wxRIBBON_BUTTON_TOGGLE
)
2765 last_line_extra_width
+= 8;
2768 for(i
= 0; i
< label
.Len(); ++i
)
2770 if(wxRibbonCanLabelBreakAtPosition(label
, i
))
2773 dc
.GetTextExtent(label
.Mid(0, i
- 1)).GetWidth(),
2774 dc
.GetTextExtent(label
.Mid(i
+ 1)).GetWidth() + last_line_extra_width
);
2775 if(width
< best_width
)
2781 label_height
*= 2; // Assume two lines even when only one is used
2782 // (to give all buttons a consistent height)
2783 icon_size
.SetWidth(wxMax(icon_size
.GetWidth(), best_width
) + 6);
2784 icon_size
.SetHeight(icon_size
.GetHeight() + label_height
);
2785 *button_size
= icon_size
;
2788 case wxRIBBON_BUTTON_DROPDOWN
:
2789 *dropdown_region
= wxRect(icon_size
);
2791 case wxRIBBON_BUTTON_HYBRID
:
2792 *normal_region
= wxRect(icon_size
);
2793 normal_region
->height
-= 2 + label_height
;
2794 dropdown_region
->x
= 0;
2795 dropdown_region
->y
= normal_region
->height
;
2796 dropdown_region
->width
= icon_size
.GetWidth();
2797 dropdown_region
->height
= icon_size
.GetHeight() - normal_region
->height
;
2799 case wxRIBBON_BUTTON_NORMAL
:
2800 case wxRIBBON_BUTTON_TOGGLE
:
2801 *normal_region
= wxRect(icon_size
);
2810 wxSize
wxRibbonMSWArtProvider::GetMinimisedPanelMinimumSize(
2812 const wxRibbonPanel
* wnd
,
2813 wxSize
* desired_bitmap_size
,
2814 wxDirection
* expanded_panel_direction
)
2816 if(desired_bitmap_size
!= NULL
)
2818 *desired_bitmap_size
= wxSize(16, 16);
2820 if(expanded_panel_direction
!= NULL
)
2822 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2823 *expanded_panel_direction
= wxEAST
;
2825 *expanded_panel_direction
= wxSOUTH
;
2827 wxSize
base_size(42, 42);
2829 dc
.SetFont(m_panel_label_font
);
2830 wxSize
label_size(dc
.GetTextExtent(wnd
->GetLabel()));
2831 label_size
.IncBy(2, 2); // Allow for differences between this DC and a paint DC
2832 label_size
.IncBy(6, 0); // Padding
2833 label_size
.y
*= 2; // Second line for dropdown button
2835 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2837 // Label alongside icon
2838 return wxSize(base_size
.x
+ label_size
.x
,
2839 wxMax(base_size
.y
, label_size
.y
));
2843 // Label beneath icon
2844 return wxSize(wxMax(base_size
.x
, label_size
.x
),
2845 base_size
.y
+ label_size
.y
);
2849 wxSize
wxRibbonMSWArtProvider::GetToolSize(
2851 wxWindow
* WXUNUSED(wnd
),
2853 wxRibbonButtonKind kind
,
2854 bool WXUNUSED(is_first
),
2856 wxRect
* dropdown_region
)
2858 wxSize
size(bitmap_size
);
2862 if(kind
& wxRIBBON_BUTTON_DROPDOWN
)
2867 if(kind
== wxRIBBON_BUTTON_DROPDOWN
)
2868 *dropdown_region
= size
;
2870 *dropdown_region
= wxRect(size
.GetWidth() - 8, 0, 8, size
.GetHeight());
2876 *dropdown_region
= wxRect(0, 0, 0, 0);
2881 #endif // wxUSE_RIBBON