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 static const char* const panel_toggle_down_xpm
[] = {
111 static const char* const panel_toggle_up_xpm
[] = {
125 wxRibbonMSWArtProvider::wxRibbonMSWArtProvider(bool set_colour_scheme
)
128 #if defined( __WXMAC__ )
129 m_tab_label_font
= *wxSMALL_FONT
;
131 m_tab_label_font
= *wxNORMAL_FONT
;
133 m_button_bar_label_font
= m_tab_label_font
;
134 m_panel_label_font
= m_tab_label_font
;
136 if(set_colour_scheme
)
139 wxColour(194, 216, 241),
140 wxColour(255, 223, 114),
144 m_cached_tab_separator_visibility
= -10.0; // valid visibilities are in range [0, 1]
145 m_tab_separation_size
= 3;
146 m_page_border_left
= 2;
147 m_page_border_top
= 1;
148 m_page_border_right
= 2;
149 m_page_border_bottom
= 3;
150 m_panel_x_separation_size
= 1;
151 m_panel_y_separation_size
= 1;
152 m_tool_group_separation_size
= 3;
153 m_gallery_bitmap_padding_left_size
= 4;
154 m_gallery_bitmap_padding_right_size
= 4;
155 m_gallery_bitmap_padding_top_size
= 4;
156 m_gallery_bitmap_padding_bottom_size
= 4;
159 wxRibbonMSWArtProvider::~wxRibbonMSWArtProvider()
163 void wxRibbonMSWArtProvider::GetColourScheme(
166 wxColour
* tertiary
) const
169 *primary
= m_primary_scheme_colour
;
170 if(secondary
!= NULL
)
171 *secondary
= m_secondary_scheme_colour
;
173 *tertiary
= m_tertiary_scheme_colour
;
176 void wxRibbonMSWArtProvider::SetColourScheme(
177 const wxColour
& primary
,
178 const wxColour
& secondary
,
179 const wxColour
& tertiary
)
181 m_primary_scheme_colour
= primary
;
182 m_secondary_scheme_colour
= secondary
;
183 m_tertiary_scheme_colour
= tertiary
;
185 wxRibbonHSLColour
primary_hsl(primary
);
186 wxRibbonHSLColour
secondary_hsl(secondary
);
187 // tertiary not used for anything
189 // Map primary saturation from [0, 1] to [.25, .75]
190 bool primary_is_gray
= false;
191 static const double gray_saturation_threshold
= 0.01;
192 if(primary_hsl
.saturation
<= gray_saturation_threshold
)
193 primary_is_gray
= true;
196 primary_hsl
.saturation
= cos(primary_hsl
.saturation
* M_PI
)
200 // Map primary luminance from [0, 1] to [.23, .83]
201 primary_hsl
.luminance
= cos(primary_hsl
.luminance
* M_PI
) * -0.3 + 0.53;
203 // Map secondary saturation from [0, 1] to [0.16, 0.84]
204 bool secondary_is_gray
= false;
205 if(secondary_hsl
.saturation
<= gray_saturation_threshold
)
206 secondary_is_gray
= true;
209 secondary_hsl
.saturation
= cos(secondary_hsl
.saturation
* M_PI
)
213 // Map secondary luminance from [0, 1] to [0.1, 0.9]
214 secondary_hsl
.luminance
= cos(secondary_hsl
.luminance
* M_PI
) * -0.4 + 0.5;
216 #define LikePrimary(h, s, l) \
217 primary_hsl.ShiftHue(h ## f).Saturated(primary_is_gray ? 0 : s ## f) \
218 .Lighter(l ## f).ToRGB()
219 #define LikeSecondary(h, s, l) \
220 secondary_hsl.ShiftHue(h ## f).Saturated(secondary_is_gray ? 0 : s ## f) \
221 .Lighter(l ## f).ToRGB()
223 m_page_border_pen
= LikePrimary(1.4, 0.00, -0.08);
225 m_page_background_top_colour
= LikePrimary(-0.1, -0.03, 0.12);
226 m_page_hover_background_top_colour
= LikePrimary(-2.8, 0.27, 0.17);
227 m_page_background_top_gradient_colour
= LikePrimary(0.1, -0.10, 0.08);
228 m_page_hover_background_top_gradient_colour
= LikePrimary(3.2, 0.16, 0.13);
229 m_page_background_colour
= LikePrimary(0.4, -0.09, 0.05);
230 m_page_hover_background_colour
= LikePrimary(0.1, 0.19, 0.10);
231 m_page_background_gradient_colour
= LikePrimary(-3.2, 0.27, 0.10);
232 m_page_hover_background_gradient_colour
= LikePrimary(1.8, 0.01, 0.15);
234 m_tab_active_background_colour
= LikePrimary(-0.1, -0.31, 0.16);
235 m_tab_active_background_gradient_colour
= LikePrimary(-0.1, -0.03, 0.12);
236 m_tab_separator_colour
= LikePrimary(0.9, 0.24, 0.05);
237 m_tab_ctrl_background_brush
= LikePrimary(1.0, 0.39, 0.07);
238 m_tab_hover_background_colour
= LikePrimary(1.3, 0.15, 0.10);
239 m_tab_hover_background_top_colour
= LikePrimary(1.4, 0.36, 0.08);
240 m_tab_border_pen
= LikePrimary(1.4, 0.03, -0.05);
241 m_tab_separator_gradient_colour
= LikePrimary(1.7, -0.15, -0.18);
242 m_tab_hover_background_top_gradient_colour
= LikePrimary(1.8, 0.34, 0.13);
243 m_tab_label_colour
= LikePrimary(4.3, 0.13, -0.49);
244 m_tab_hover_background_gradient_colour
= LikeSecondary(-1.5, -0.34, 0.01);
246 m_panel_minimised_border_gradient_pen
= LikePrimary(-6.9, -0.17, -0.09);
247 m_panel_minimised_border_pen
= LikePrimary(-5.3, -0.24, -0.06);
248 m_panel_border_gradient_pen
= LikePrimary(-5.2, -0.15, -0.06);
249 m_panel_border_pen
= LikePrimary(-2.8, -0.32, 0.02);
250 m_panel_label_background_brush
= LikePrimary(-1.5, 0.03, 0.05);
251 m_panel_active_background_gradient_colour
= LikePrimary(0.5, 0.34, 0.05);
252 m_panel_hover_label_background_brush
= LikePrimary(1.0, 0.30, 0.09);
253 m_panel_active_background_top_gradient_colour
= LikePrimary(1.4, -0.17, -0.13);
254 m_panel_active_background_colour
= LikePrimary(1.6, -0.18, -0.18);
255 m_panel_active_background_top_colour
= LikePrimary(1.7, -0.20, -0.03);
256 m_panel_label_colour
= LikePrimary(2.8, -0.14, -0.35);
257 m_panel_hover_label_colour
= m_panel_label_colour
;
258 m_panel_minimised_label_colour
= m_tab_label_colour
;
259 m_panel_hover_button_background_brush
= LikeSecondary(-0.9, 0.16, -0.07);
260 m_panel_hover_button_border_pen
= LikeSecondary(-3.9, -0.16, -0.14);
261 SetColour(wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR
, LikePrimary(1.4, -0.21, -0.23));
262 SetColour(wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR
, LikePrimary(1.5, -0.24, -0.29));
264 m_ribbon_toggle_brush
= LikeSecondary(-0.9, 0.16, -0.07);
265 m_ribbon_toggle_pen
= LikeSecondary(-3.9, -0.16, -0.14);
266 SetColour(wxRIBBON_ART_PAGE_TOGGLE_FACE_COLOUR
, LikePrimary(1.7, -0.20, -0.15));
267 SetColour(wxRIBBON_ART_PAGE_TOGGLE_HOVER_FACE_COLOUR
, LikePrimary(1.8, -0.23, -0.21));
269 m_gallery_button_disabled_background_colour
= LikePrimary(-2.8, -0.46, 0.09);
270 m_gallery_button_disabled_background_top_brush
= LikePrimary(-2.8, -0.36, 0.15);
271 m_gallery_hover_background_brush
= LikePrimary(-0.8, 0.05, 0.15);
272 m_gallery_border_pen
= LikePrimary(0.7, -0.02, 0.03);
273 m_gallery_button_background_top_brush
= LikePrimary(0.8, 0.34, 0.13);
274 m_gallery_button_background_colour
= LikePrimary(1.3, 0.10, 0.08);
275 // SetColour used so that the relevant bitmaps are generated
276 SetColour(wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR
, LikePrimary(1.4, -0.21, -0.23));
277 SetColour(wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR
, LikePrimary(1.5, -0.24, -0.29));
278 SetColour(wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR
, LikePrimary(1.5, -0.24, -0.29));
279 SetColour(wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR
, LikePrimary(0.0, -1.0, 0.0));
280 m_gallery_button_disabled_background_gradient_colour
= LikePrimary(1.5, -0.43, 0.12);
281 m_gallery_button_background_gradient_colour
= LikePrimary(1.7, 0.11, 0.09);
282 m_gallery_item_border_pen
= LikeSecondary(-3.9, -0.16, -0.14);
283 m_gallery_button_hover_background_colour
= LikeSecondary(-0.9, 0.16, -0.07);
284 m_gallery_button_hover_background_gradient_colour
= LikeSecondary(0.1, 0.12, 0.03);
285 m_gallery_button_hover_background_top_brush
= LikeSecondary(4.3, 0.16, 0.17);
287 m_gallery_button_active_background_colour
= LikeSecondary(-9.9, 0.03, -0.22);
288 m_gallery_button_active_background_gradient_colour
= LikeSecondary(-9.5, 0.14, -0.11);
289 m_gallery_button_active_background_top_brush
= LikeSecondary(-9.0, 0.15, -0.08);
291 m_button_bar_label_colour
= m_tab_label_colour
;
292 m_button_bar_hover_border_pen
= LikeSecondary(-6.2, -0.47, -0.14);
293 m_button_bar_hover_background_gradient_colour
= LikeSecondary(-0.6, 0.16, 0.04);
294 m_button_bar_hover_background_colour
= LikeSecondary(-0.2, 0.16, -0.10);
295 m_button_bar_hover_background_top_gradient_colour
= LikeSecondary(0.2, 0.16, 0.03);
296 m_button_bar_hover_background_top_colour
= LikeSecondary(8.8, 0.16, 0.17);
297 m_button_bar_active_border_pen
= LikeSecondary(-6.2, -0.47, -0.25);
298 m_button_bar_active_background_top_colour
= LikeSecondary(-8.4, 0.08, 0.06);
299 m_button_bar_active_background_top_gradient_colour
= LikeSecondary(-9.7, 0.13, -0.07);
300 m_button_bar_active_background_colour
= LikeSecondary(-9.9, 0.14, -0.14);
301 m_button_bar_active_background_gradient_colour
= LikeSecondary(-8.7, 0.17, -0.03);
303 m_toolbar_border_pen
= LikePrimary(1.4, -0.21, -0.16);
304 SetColour(wxRIBBON_ART_TOOLBAR_FACE_COLOUR
, LikePrimary(1.4, -0.17, -0.22));
305 m_tool_background_top_colour
= LikePrimary(-1.9, -0.07, 0.06);
306 m_tool_background_top_gradient_colour
= LikePrimary(1.4, 0.12, 0.08);
307 m_tool_background_colour
= LikePrimary(1.4, -0.09, 0.03);
308 m_tool_background_gradient_colour
= LikePrimary(1.9, 0.11, 0.09);
309 m_tool_hover_background_top_colour
= LikeSecondary(3.4, 0.11, 0.16);
310 m_tool_hover_background_top_gradient_colour
= LikeSecondary(-1.4, 0.04, 0.08);
311 m_tool_hover_background_colour
= LikeSecondary(-1.8, 0.16, -0.12);
312 m_tool_hover_background_gradient_colour
= LikeSecondary(-2.6, 0.16, 0.05);
313 m_tool_active_background_top_colour
= LikeSecondary(-9.9, -0.12, -0.09);
314 m_tool_active_background_top_gradient_colour
= LikeSecondary(-8.5, 0.16, -0.12);
315 m_tool_active_background_colour
= LikeSecondary(-7.9, 0.16, -0.20);
316 m_tool_active_background_gradient_colour
= LikeSecondary(-6.6, 0.16, -0.10);
321 // Invalidate cached tab separator
322 m_cached_tab_separator_visibility
= -1.0;
325 wxRibbonArtProvider
* wxRibbonMSWArtProvider::Clone() const
327 wxRibbonMSWArtProvider
*copy
= new wxRibbonMSWArtProvider
;
332 void wxRibbonMSWArtProvider::CloneTo(wxRibbonMSWArtProvider
* copy
) const
335 for(i
= 0; i
< 4; ++i
)
337 copy
->m_gallery_up_bitmap
[i
] = m_gallery_up_bitmap
[i
];
338 copy
->m_gallery_down_bitmap
[i
] = m_gallery_down_bitmap
[i
];
339 copy
->m_gallery_extension_bitmap
[i
] = m_gallery_extension_bitmap
[i
];
341 for(i
= 0; i
< 2; ++i
)
343 copy
->m_panel_extension_bitmap
[i
] = m_panel_extension_bitmap
[i
];
344 copy
->m_ribbon_toggle_up_bitmap
[i
] = m_ribbon_toggle_up_bitmap
[i
];
345 copy
->m_ribbon_toggle_down_bitmap
[i
] = m_ribbon_toggle_down_bitmap
[i
];
347 copy
->m_toolbar_drop_bitmap
= m_toolbar_drop_bitmap
;
349 copy
->m_primary_scheme_colour
= m_primary_scheme_colour
;
350 copy
->m_secondary_scheme_colour
= m_secondary_scheme_colour
;
351 copy
->m_tertiary_scheme_colour
= m_tertiary_scheme_colour
;
353 copy
->m_page_toggle_face_colour
= m_page_toggle_face_colour
;
354 copy
->m_page_toggle_hover_face_colour
= m_page_toggle_hover_face_colour
;
356 copy
->m_button_bar_label_colour
= m_button_bar_label_colour
;
357 copy
->m_tab_label_colour
= m_tab_label_colour
;
358 copy
->m_tab_separator_colour
= m_tab_separator_colour
;
359 copy
->m_tab_separator_gradient_colour
= m_tab_separator_gradient_colour
;
360 copy
->m_tab_active_background_colour
= m_tab_hover_background_colour
;
361 copy
->m_tab_active_background_gradient_colour
= m_tab_hover_background_gradient_colour
;
362 copy
->m_tab_hover_background_colour
= m_tab_hover_background_colour
;
363 copy
->m_tab_hover_background_gradient_colour
= m_tab_hover_background_gradient_colour
;
364 copy
->m_tab_hover_background_top_colour
= m_tab_hover_background_top_colour
;
365 copy
->m_tab_hover_background_top_gradient_colour
= m_tab_hover_background_top_gradient_colour
;
366 copy
->m_panel_label_colour
= m_panel_label_colour
;
367 copy
->m_panel_hover_label_colour
= m_panel_hover_label_colour
;
368 copy
->m_panel_minimised_label_colour
= m_panel_minimised_label_colour
;
369 copy
->m_panel_button_face_colour
= m_panel_button_face_colour
;
370 copy
->m_panel_button_hover_face_colour
= m_panel_button_hover_face_colour
;
371 copy
->m_panel_active_background_colour
= m_panel_active_background_colour
;
372 copy
->m_panel_active_background_gradient_colour
= m_panel_active_background_gradient_colour
;
373 copy
->m_panel_active_background_top_colour
= m_panel_active_background_top_colour
;
374 copy
->m_panel_active_background_top_gradient_colour
= m_panel_active_background_top_gradient_colour
;
375 copy
->m_page_background_colour
= m_page_background_colour
;
376 copy
->m_page_background_gradient_colour
= m_page_background_gradient_colour
;
377 copy
->m_page_background_top_colour
= m_page_background_top_colour
;
378 copy
->m_page_background_top_gradient_colour
= m_page_background_top_gradient_colour
;
379 copy
->m_page_hover_background_colour
= m_page_hover_background_colour
;
380 copy
->m_page_hover_background_gradient_colour
= m_page_hover_background_gradient_colour
;
381 copy
->m_page_hover_background_top_colour
= m_page_hover_background_top_colour
;
382 copy
->m_page_hover_background_top_gradient_colour
= m_page_hover_background_top_gradient_colour
;
383 copy
->m_button_bar_hover_background_colour
= m_button_bar_hover_background_colour
;
384 copy
->m_button_bar_hover_background_gradient_colour
= m_button_bar_hover_background_gradient_colour
;
385 copy
->m_button_bar_hover_background_top_colour
= m_button_bar_hover_background_top_colour
;
386 copy
->m_button_bar_hover_background_top_gradient_colour
= m_button_bar_hover_background_top_gradient_colour
;
387 copy
->m_button_bar_active_background_colour
= m_button_bar_active_background_colour
;
388 copy
->m_button_bar_active_background_gradient_colour
= m_button_bar_active_background_gradient_colour
;
389 copy
->m_button_bar_active_background_top_colour
= m_button_bar_active_background_top_colour
;
390 copy
->m_button_bar_active_background_top_gradient_colour
= m_button_bar_active_background_top_gradient_colour
;
391 copy
->m_gallery_button_background_colour
= m_gallery_button_background_colour
;
392 copy
->m_gallery_button_background_gradient_colour
= m_gallery_button_background_gradient_colour
;
393 copy
->m_gallery_button_hover_background_colour
= m_gallery_button_hover_background_colour
;
394 copy
->m_gallery_button_hover_background_gradient_colour
= m_gallery_button_hover_background_gradient_colour
;
395 copy
->m_gallery_button_active_background_colour
= m_gallery_button_active_background_colour
;
396 copy
->m_gallery_button_active_background_gradient_colour
= m_gallery_button_active_background_gradient_colour
;
397 copy
->m_gallery_button_disabled_background_colour
= m_gallery_button_disabled_background_colour
;
398 copy
->m_gallery_button_disabled_background_gradient_colour
= m_gallery_button_disabled_background_gradient_colour
;
399 copy
->m_gallery_button_face_colour
= m_gallery_button_face_colour
;
400 copy
->m_gallery_button_hover_face_colour
= m_gallery_button_hover_face_colour
;
401 copy
->m_gallery_button_active_face_colour
= m_gallery_button_active_face_colour
;
402 copy
->m_gallery_button_disabled_face_colour
= m_gallery_button_disabled_face_colour
;
404 copy
->m_tab_ctrl_background_brush
= m_tab_ctrl_background_brush
;
405 copy
->m_panel_label_background_brush
= m_panel_label_background_brush
;
406 copy
->m_panel_hover_label_background_brush
= m_panel_hover_label_background_brush
;
407 copy
->m_panel_hover_button_background_brush
= m_panel_hover_button_background_brush
;
408 copy
->m_gallery_hover_background_brush
= m_gallery_hover_background_brush
;
409 copy
->m_gallery_button_background_top_brush
= m_gallery_button_background_top_brush
;
410 copy
->m_gallery_button_hover_background_top_brush
= m_gallery_button_hover_background_top_brush
;
411 copy
->m_gallery_button_active_background_top_brush
= m_gallery_button_active_background_top_brush
;
412 copy
->m_gallery_button_disabled_background_top_brush
= m_gallery_button_disabled_background_top_brush
;
413 copy
->m_ribbon_toggle_brush
= m_ribbon_toggle_brush
;
415 copy
->m_tab_label_font
= m_tab_label_font
;
416 copy
->m_button_bar_label_font
= m_button_bar_label_font
;
417 copy
->m_panel_label_font
= m_panel_label_font
;
419 copy
->m_page_border_pen
= m_page_border_pen
;
420 copy
->m_panel_border_pen
= m_panel_border_pen
;
421 copy
->m_panel_border_gradient_pen
= m_panel_border_gradient_pen
;
422 copy
->m_panel_minimised_border_pen
= m_panel_minimised_border_pen
;
423 copy
->m_panel_minimised_border_gradient_pen
= m_panel_minimised_border_gradient_pen
;
424 copy
->m_panel_hover_button_border_pen
= m_panel_hover_button_border_pen
;
425 copy
->m_tab_border_pen
= m_tab_border_pen
;
426 copy
->m_gallery_border_pen
= m_gallery_border_pen
;
427 copy
->m_button_bar_hover_border_pen
= m_button_bar_hover_border_pen
;
428 copy
->m_button_bar_active_border_pen
= m_button_bar_active_border_pen
;
429 copy
->m_gallery_item_border_pen
= m_gallery_item_border_pen
;
430 copy
->m_toolbar_border_pen
= m_toolbar_border_pen
;
431 copy
->m_ribbon_toggle_pen
= m_ribbon_toggle_pen
;
433 copy
->m_flags
= m_flags
;
434 copy
->m_tab_separation_size
= m_tab_separation_size
;
435 copy
->m_page_border_left
= m_page_border_left
;
436 copy
->m_page_border_top
= m_page_border_top
;
437 copy
->m_page_border_right
= m_page_border_right
;
438 copy
->m_page_border_bottom
= m_page_border_bottom
;
439 copy
->m_panel_x_separation_size
= m_panel_x_separation_size
;
440 copy
->m_panel_y_separation_size
= m_panel_y_separation_size
;
441 copy
->m_gallery_bitmap_padding_left_size
= m_gallery_bitmap_padding_left_size
;
442 copy
->m_gallery_bitmap_padding_right_size
= m_gallery_bitmap_padding_right_size
;
443 copy
->m_gallery_bitmap_padding_top_size
= m_gallery_bitmap_padding_top_size
;
444 copy
->m_gallery_bitmap_padding_bottom_size
= m_gallery_bitmap_padding_bottom_size
;
447 long wxRibbonMSWArtProvider::GetFlags() const
452 void wxRibbonMSWArtProvider::SetFlags(long flags
)
454 if((flags
^ m_flags
) & wxRIBBON_BAR_FLOW_VERTICAL
)
456 if(flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
458 m_page_border_left
++;
459 m_page_border_right
++;
461 m_page_border_bottom
--;
465 m_page_border_left
--;
466 m_page_border_right
--;
468 m_page_border_bottom
++;
473 // Need to reload some bitmaps when flags change
474 #define Reload(setting) SetColour(setting, GetColour(setting))
475 Reload(wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR
);
476 Reload(wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR
);
477 Reload(wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR
);
478 Reload(wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR
);
479 Reload(wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR
);
480 Reload(wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR
);
484 int wxRibbonMSWArtProvider::GetMetric(int id
) const
488 case wxRIBBON_ART_TAB_SEPARATION_SIZE
:
489 return m_tab_separation_size
;
490 case wxRIBBON_ART_PAGE_BORDER_LEFT_SIZE
:
491 return m_page_border_left
;
492 case wxRIBBON_ART_PAGE_BORDER_TOP_SIZE
:
493 return m_page_border_top
;
494 case wxRIBBON_ART_PAGE_BORDER_RIGHT_SIZE
:
495 return m_page_border_right
;
496 case wxRIBBON_ART_PAGE_BORDER_BOTTOM_SIZE
:
497 return m_page_border_bottom
;
498 case wxRIBBON_ART_PANEL_X_SEPARATION_SIZE
:
499 return m_panel_x_separation_size
;
500 case wxRIBBON_ART_PANEL_Y_SEPARATION_SIZE
:
501 return m_panel_y_separation_size
;
502 case wxRIBBON_ART_TOOL_GROUP_SEPARATION_SIZE
:
503 return m_tool_group_separation_size
;
504 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_LEFT_SIZE
:
505 return m_gallery_bitmap_padding_left_size
;
506 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_RIGHT_SIZE
:
507 return m_gallery_bitmap_padding_right_size
;
508 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_TOP_SIZE
:
509 return m_gallery_bitmap_padding_top_size
;
510 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_BOTTOM_SIZE
:
511 return m_gallery_bitmap_padding_bottom_size
;
513 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
520 void wxRibbonMSWArtProvider::SetMetric(int id
, int new_val
)
524 case wxRIBBON_ART_TAB_SEPARATION_SIZE
:
525 m_tab_separation_size
= new_val
;
527 case wxRIBBON_ART_PAGE_BORDER_LEFT_SIZE
:
528 m_page_border_left
= new_val
;
530 case wxRIBBON_ART_PAGE_BORDER_TOP_SIZE
:
531 m_page_border_top
= new_val
;
533 case wxRIBBON_ART_PAGE_BORDER_RIGHT_SIZE
:
534 m_page_border_right
= new_val
;
536 case wxRIBBON_ART_PAGE_BORDER_BOTTOM_SIZE
:
537 m_page_border_bottom
= new_val
;
539 case wxRIBBON_ART_PANEL_X_SEPARATION_SIZE
:
540 m_panel_x_separation_size
= new_val
;
542 case wxRIBBON_ART_PANEL_Y_SEPARATION_SIZE
:
543 m_panel_y_separation_size
= new_val
;
545 case wxRIBBON_ART_TOOL_GROUP_SEPARATION_SIZE
:
546 m_tool_group_separation_size
= new_val
;
548 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_LEFT_SIZE
:
549 m_gallery_bitmap_padding_left_size
= new_val
;
551 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_RIGHT_SIZE
:
552 m_gallery_bitmap_padding_right_size
= new_val
;
554 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_TOP_SIZE
:
555 m_gallery_bitmap_padding_top_size
= new_val
;
557 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_BOTTOM_SIZE
:
558 m_gallery_bitmap_padding_bottom_size
= new_val
;
561 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
566 void wxRibbonMSWArtProvider::SetFont(int id
, const wxFont
& font
)
570 case wxRIBBON_ART_TAB_LABEL_FONT
:
571 m_tab_label_font
= font
;
573 case wxRIBBON_ART_BUTTON_BAR_LABEL_FONT
:
574 m_button_bar_label_font
= font
;
576 case wxRIBBON_ART_PANEL_LABEL_FONT
:
577 m_panel_label_font
= font
;
580 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
585 wxFont
wxRibbonMSWArtProvider::GetFont(int id
) const
589 case wxRIBBON_ART_TAB_LABEL_FONT
:
590 return m_tab_label_font
;
591 case wxRIBBON_ART_BUTTON_BAR_LABEL_FONT
:
592 return m_button_bar_label_font
;
593 case wxRIBBON_ART_PANEL_LABEL_FONT
:
594 return m_panel_label_font
;
596 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
603 wxColour
wxRibbonMSWArtProvider::GetColour(int id
) const
607 case wxRIBBON_ART_BUTTON_BAR_LABEL_COLOUR
:
608 return m_button_bar_label_colour
;
609 case wxRIBBON_ART_BUTTON_BAR_HOVER_BORDER_COLOUR
:
610 return m_button_bar_hover_border_pen
.GetColour();
611 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_COLOUR
:
612 return m_button_bar_hover_background_top_colour
;
613 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
614 return m_button_bar_hover_background_top_gradient_colour
;
615 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_COLOUR
:
616 return m_button_bar_hover_background_colour
;
617 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_GRADIENT_COLOUR
:
618 return m_button_bar_hover_background_gradient_colour
;
619 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BORDER_COLOUR
:
620 return m_button_bar_active_border_pen
.GetColour();
621 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_COLOUR
:
622 return m_button_bar_active_background_top_colour
;
623 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
624 return m_button_bar_active_background_top_gradient_colour
;
625 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_COLOUR
:
626 return m_button_bar_active_background_colour
;
627 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
628 return m_button_bar_active_background_gradient_colour
;
629 case wxRIBBON_ART_GALLERY_BORDER_COLOUR
:
630 return m_gallery_border_pen
.GetColour();
631 case wxRIBBON_ART_GALLERY_HOVER_BACKGROUND_COLOUR
:
632 return m_gallery_hover_background_brush
.GetColour();
633 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_COLOUR
:
634 return m_gallery_button_background_colour
;
635 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_GRADIENT_COLOUR
:
636 return m_gallery_button_background_gradient_colour
;
637 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_TOP_COLOUR
:
638 return m_gallery_button_background_top_brush
.GetColour();
639 case wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR
:
640 return m_gallery_button_face_colour
;
641 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_COLOUR
:
642 return m_gallery_button_hover_background_colour
;
643 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_GRADIENT_COLOUR
:
644 return m_gallery_button_hover_background_gradient_colour
;
645 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_TOP_COLOUR
:
646 return m_gallery_button_hover_background_top_brush
.GetColour();
647 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR
:
648 return m_gallery_button_face_colour
;
649 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_COLOUR
:
650 return m_gallery_button_active_background_colour
;
651 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
652 return m_gallery_button_active_background_gradient_colour
;
653 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_TOP_COLOUR
:
654 return m_gallery_button_background_top_brush
.GetColour();
655 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR
:
656 return m_gallery_button_active_face_colour
;
657 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_COLOUR
:
658 return m_gallery_button_disabled_background_colour
;
659 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_GRADIENT_COLOUR
:
660 return m_gallery_button_disabled_background_gradient_colour
;
661 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_TOP_COLOUR
:
662 return m_gallery_button_disabled_background_top_brush
.GetColour();
663 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR
:
664 return m_gallery_button_disabled_face_colour
;
665 case wxRIBBON_ART_GALLERY_ITEM_BORDER_COLOUR
:
666 return m_gallery_item_border_pen
.GetColour();
667 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_COLOUR
:
668 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_GRADIENT_COLOUR
:
669 return m_tab_ctrl_background_brush
.GetColour();
670 case wxRIBBON_ART_TAB_LABEL_COLOUR
:
671 return m_tab_label_colour
;
672 case wxRIBBON_ART_TAB_SEPARATOR_COLOUR
:
673 return m_tab_separator_colour
;
674 case wxRIBBON_ART_TAB_SEPARATOR_GRADIENT_COLOUR
:
675 return m_tab_separator_gradient_colour
;
676 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_COLOUR
:
677 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
678 return wxColour(0, 0, 0);
679 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_COLOUR
:
680 return m_tab_active_background_colour
;
681 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
682 return m_tab_active_background_gradient_colour
;
683 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_COLOUR
:
684 return m_tab_hover_background_top_colour
;
685 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
686 return m_tab_hover_background_top_gradient_colour
;
687 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_COLOUR
:
688 return m_tab_hover_background_colour
;
689 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_GRADIENT_COLOUR
:
690 return m_tab_hover_background_gradient_colour
;
691 case wxRIBBON_ART_TAB_BORDER_COLOUR
:
692 return m_tab_border_pen
.GetColour();
693 case wxRIBBON_ART_PANEL_BORDER_COLOUR
:
694 return m_panel_border_pen
.GetColour();
695 case wxRIBBON_ART_PANEL_BORDER_GRADIENT_COLOUR
:
696 return m_panel_border_gradient_pen
.GetColour();
697 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_COLOUR
:
698 return m_panel_minimised_border_pen
.GetColour();
699 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_GRADIENT_COLOUR
:
700 return m_panel_minimised_border_gradient_pen
.GetColour();
701 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_COLOUR
:
702 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_GRADIENT_COLOUR
:
703 return m_panel_label_background_brush
.GetColour();
704 case wxRIBBON_ART_PANEL_LABEL_COLOUR
:
705 return m_panel_label_colour
;
706 case wxRIBBON_ART_PANEL_MINIMISED_LABEL_COLOUR
:
707 return m_panel_minimised_label_colour
;
708 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_COLOUR
:
709 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_GRADIENT_COLOUR
:
710 return m_panel_hover_label_background_brush
.GetColour();
711 case wxRIBBON_ART_PANEL_HOVER_LABEL_COLOUR
:
712 return m_panel_hover_label_colour
;
713 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_COLOUR
:
714 return m_panel_active_background_top_colour
;
715 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
716 return m_panel_active_background_top_gradient_colour
;
717 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_COLOUR
:
718 return m_panel_active_background_colour
;
719 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
720 return m_panel_active_background_gradient_colour
;
721 case wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR
:
722 return m_panel_button_face_colour
;
723 case wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR
:
724 return m_panel_button_hover_face_colour
;
725 case wxRIBBON_ART_PAGE_BORDER_COLOUR
:
726 return m_page_border_pen
.GetColour();
727 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_COLOUR
:
728 return m_page_background_top_colour
;
729 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_GRADIENT_COLOUR
:
730 return m_page_background_top_gradient_colour
;
731 case wxRIBBON_ART_PAGE_BACKGROUND_COLOUR
:
732 return m_page_background_colour
;
733 case wxRIBBON_ART_PAGE_BACKGROUND_GRADIENT_COLOUR
:
734 return m_page_background_gradient_colour
;
735 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_COLOUR
:
736 return m_page_hover_background_top_colour
;
737 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
738 return m_page_hover_background_top_gradient_colour
;
739 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_COLOUR
:
740 return m_page_hover_background_colour
;
741 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_GRADIENT_COLOUR
:
742 return m_page_hover_background_gradient_colour
;
743 case wxRIBBON_ART_TOOLBAR_BORDER_COLOUR
:
744 case wxRIBBON_ART_TOOLBAR_HOVER_BORDER_COLOUR
:
745 return m_toolbar_border_pen
.GetColour();
746 case wxRIBBON_ART_TOOLBAR_FACE_COLOUR
:
747 return m_tool_face_colour
;
748 case wxRIBBON_ART_PAGE_TOGGLE_FACE_COLOUR
:
749 return m_page_toggle_face_colour
;
750 case wxRIBBON_ART_PAGE_TOGGLE_HOVER_FACE_COLOUR
:
751 return m_page_toggle_hover_face_colour
;
753 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
760 void wxRibbonMSWArtProvider::SetColour(int id
, const wxColor
& colour
)
764 case wxRIBBON_ART_BUTTON_BAR_LABEL_COLOUR
:
765 m_button_bar_label_colour
= colour
;
767 case wxRIBBON_ART_BUTTON_BAR_HOVER_BORDER_COLOUR
:
768 m_button_bar_hover_border_pen
.SetColour(colour
);
770 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_COLOUR
:
771 m_button_bar_hover_background_top_colour
= colour
;
773 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
774 m_button_bar_hover_background_top_gradient_colour
= colour
;
776 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_COLOUR
:
777 m_button_bar_hover_background_colour
= colour
;
779 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_GRADIENT_COLOUR
:
780 m_button_bar_hover_background_gradient_colour
= colour
;
782 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BORDER_COLOUR
:
783 m_button_bar_active_border_pen
.SetColour(colour
);
785 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_COLOUR
:
786 m_button_bar_active_background_top_colour
= colour
;
788 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
789 m_button_bar_active_background_top_gradient_colour
= colour
;
791 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_COLOUR
:
792 m_button_bar_active_background_colour
= colour
;
794 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
795 m_button_bar_active_background_gradient_colour
= colour
;
797 case wxRIBBON_ART_GALLERY_BORDER_COLOUR
:
798 m_gallery_border_pen
.SetColour(colour
);
800 case wxRIBBON_ART_GALLERY_HOVER_BACKGROUND_COLOUR
:
801 m_gallery_hover_background_brush
.SetColour(colour
);
803 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_COLOUR
:
804 m_gallery_button_background_colour
= colour
;
806 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_GRADIENT_COLOUR
:
807 m_gallery_button_background_gradient_colour
= colour
;
809 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_TOP_COLOUR
:
810 m_gallery_button_background_top_brush
.SetColour(colour
);
812 case wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR
:
813 m_gallery_button_face_colour
= colour
;
814 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
816 m_gallery_up_bitmap
[0] = wxRibbonLoadPixmap(gallery_left_xpm
, colour
);
817 m_gallery_down_bitmap
[0] = wxRibbonLoadPixmap(gallery_right_xpm
, colour
);
821 m_gallery_up_bitmap
[0] = wxRibbonLoadPixmap(gallery_up_xpm
, colour
);
822 m_gallery_down_bitmap
[0] = wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
824 m_gallery_extension_bitmap
[0] = wxRibbonLoadPixmap(gallery_extension_xpm
, colour
);
826 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_COLOUR
:
827 m_gallery_button_hover_background_colour
= colour
;
829 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_GRADIENT_COLOUR
:
830 m_gallery_button_hover_background_gradient_colour
= colour
;
832 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_TOP_COLOUR
:
833 m_gallery_button_hover_background_top_brush
.SetColour(colour
);
835 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR
:
836 m_gallery_button_hover_face_colour
= colour
;
837 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
839 m_gallery_up_bitmap
[1] = wxRibbonLoadPixmap(gallery_left_xpm
, colour
);
840 m_gallery_down_bitmap
[1] = wxRibbonLoadPixmap(gallery_right_xpm
, colour
);
844 m_gallery_up_bitmap
[1] = wxRibbonLoadPixmap(gallery_up_xpm
, colour
);
845 m_gallery_down_bitmap
[1] = wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
847 m_gallery_extension_bitmap
[1] = wxRibbonLoadPixmap(gallery_extension_xpm
, colour
);
849 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_COLOUR
:
850 m_gallery_button_active_background_colour
= colour
;
852 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
853 m_gallery_button_active_background_gradient_colour
= colour
;
855 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_TOP_COLOUR
:
856 m_gallery_button_background_top_brush
.SetColour(colour
);
858 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR
:
859 m_gallery_button_active_face_colour
= colour
;
860 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
862 m_gallery_up_bitmap
[2] = wxRibbonLoadPixmap(gallery_left_xpm
, colour
);
863 m_gallery_down_bitmap
[2] = wxRibbonLoadPixmap(gallery_right_xpm
, colour
);
867 m_gallery_up_bitmap
[2] = wxRibbonLoadPixmap(gallery_up_xpm
, colour
);
868 m_gallery_down_bitmap
[2] = wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
870 m_gallery_extension_bitmap
[2] = wxRibbonLoadPixmap(gallery_extension_xpm
, colour
);
872 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_COLOUR
:
873 m_gallery_button_disabled_background_colour
= colour
;
875 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_GRADIENT_COLOUR
:
876 m_gallery_button_disabled_background_gradient_colour
= colour
;
878 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_TOP_COLOUR
:
879 m_gallery_button_disabled_background_top_brush
.SetColour(colour
);
881 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR
:
882 m_gallery_button_disabled_face_colour
= colour
;
883 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
885 m_gallery_up_bitmap
[3] = wxRibbonLoadPixmap(gallery_left_xpm
, colour
);
886 m_gallery_down_bitmap
[3] = wxRibbonLoadPixmap(gallery_right_xpm
, colour
);
890 m_gallery_up_bitmap
[3] = wxRibbonLoadPixmap(gallery_up_xpm
, colour
);
891 m_gallery_down_bitmap
[3] = wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
893 m_gallery_extension_bitmap
[3] = wxRibbonLoadPixmap(gallery_extension_xpm
, colour
);
895 case wxRIBBON_ART_GALLERY_ITEM_BORDER_COLOUR
:
896 m_gallery_item_border_pen
.SetColour(colour
);
898 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_COLOUR
:
899 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_GRADIENT_COLOUR
:
900 m_tab_ctrl_background_brush
.SetColour(colour
);
901 m_cached_tab_separator_visibility
= -1.0;
903 case wxRIBBON_ART_TAB_LABEL_COLOUR
:
904 m_tab_label_colour
= colour
;
906 case wxRIBBON_ART_TAB_SEPARATOR_COLOUR
:
907 m_tab_separator_colour
= colour
;
908 m_cached_tab_separator_visibility
= -1.0;
910 case wxRIBBON_ART_TAB_SEPARATOR_GRADIENT_COLOUR
:
911 m_tab_separator_gradient_colour
= colour
;
912 m_cached_tab_separator_visibility
= -1.0;
914 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_COLOUR
:
915 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
917 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_COLOUR
:
918 m_tab_active_background_colour
= colour
;
920 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
921 m_tab_active_background_gradient_colour
= colour
;
923 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_COLOUR
:
924 m_tab_hover_background_top_colour
= colour
;
926 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
927 m_tab_hover_background_top_gradient_colour
= colour
;
929 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_COLOUR
:
930 m_tab_hover_background_colour
= colour
;
932 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_GRADIENT_COLOUR
:
933 m_tab_hover_background_gradient_colour
= colour
;
935 case wxRIBBON_ART_TAB_BORDER_COLOUR
:
936 m_tab_border_pen
.SetColour(colour
);
938 case wxRIBBON_ART_PANEL_BORDER_COLOUR
:
939 m_panel_border_pen
.SetColour(colour
);
941 case wxRIBBON_ART_PANEL_BORDER_GRADIENT_COLOUR
:
942 m_panel_border_gradient_pen
.SetColour(colour
);
944 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_COLOUR
:
945 m_panel_minimised_border_pen
.SetColour(colour
);
947 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_GRADIENT_COLOUR
:
948 m_panel_minimised_border_gradient_pen
.SetColour(colour
);
950 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_COLOUR
:
951 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_GRADIENT_COLOUR
:
952 m_panel_label_background_brush
.SetColour(colour
);
954 case wxRIBBON_ART_PANEL_LABEL_COLOUR
:
955 m_panel_label_colour
= colour
;
957 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_COLOUR
:
958 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_GRADIENT_COLOUR
:
959 m_panel_hover_label_background_brush
.SetColour(colour
);
961 case wxRIBBON_ART_PANEL_HOVER_LABEL_COLOUR
:
962 m_panel_hover_label_colour
= colour
;
964 case wxRIBBON_ART_PANEL_MINIMISED_LABEL_COLOUR
:
965 m_panel_minimised_label_colour
= colour
;
967 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_COLOUR
:
968 m_panel_active_background_top_colour
= colour
;
970 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
971 m_panel_active_background_top_gradient_colour
= colour
;
973 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_COLOUR
:
974 m_panel_active_background_colour
= colour
;
976 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
977 m_panel_active_background_gradient_colour
= colour
;
979 case wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR
:
980 m_panel_button_face_colour
= colour
;
981 m_panel_extension_bitmap
[0] = wxRibbonLoadPixmap(panel_extension_xpm
, colour
);
983 case wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR
:
984 m_panel_button_hover_face_colour
= colour
;
985 m_panel_extension_bitmap
[1] = wxRibbonLoadPixmap(panel_extension_xpm
, colour
);
987 case wxRIBBON_ART_PAGE_BORDER_COLOUR
:
988 m_page_border_pen
.SetColour(colour
);
990 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_COLOUR
:
991 m_page_background_top_colour
= colour
;
993 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_GRADIENT_COLOUR
:
994 m_page_background_top_gradient_colour
= colour
;
996 case wxRIBBON_ART_PAGE_BACKGROUND_COLOUR
:
997 m_page_background_colour
= colour
;
999 case wxRIBBON_ART_PAGE_BACKGROUND_GRADIENT_COLOUR
:
1000 m_page_background_gradient_colour
= colour
;
1002 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_COLOUR
:
1003 m_page_hover_background_top_colour
= colour
;
1005 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
1006 m_page_hover_background_top_gradient_colour
= colour
;
1008 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_COLOUR
:
1009 m_page_hover_background_colour
= colour
;
1011 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_GRADIENT_COLOUR
:
1012 m_page_hover_background_gradient_colour
= colour
;
1014 case wxRIBBON_ART_TOOLBAR_BORDER_COLOUR
:
1015 case wxRIBBON_ART_TOOLBAR_HOVER_BORDER_COLOUR
:
1016 m_toolbar_border_pen
.SetColour(colour
);
1018 case wxRIBBON_ART_TOOLBAR_FACE_COLOUR
:
1019 m_tool_face_colour
= colour
;
1020 m_toolbar_drop_bitmap
= wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
1022 case wxRIBBON_ART_PAGE_TOGGLE_FACE_COLOUR
:
1023 m_page_toggle_face_colour
= colour
;
1024 m_ribbon_toggle_down_bitmap
[0] = wxRibbonLoadPixmap(panel_toggle_down_xpm
, colour
);
1025 m_ribbon_toggle_up_bitmap
[0] = wxRibbonLoadPixmap(panel_toggle_up_xpm
, colour
);
1027 case wxRIBBON_ART_PAGE_TOGGLE_HOVER_FACE_COLOUR
:
1028 m_page_toggle_hover_face_colour
= colour
;
1029 m_ribbon_toggle_down_bitmap
[1] = wxRibbonLoadPixmap(panel_toggle_down_xpm
, colour
);
1030 m_ribbon_toggle_up_bitmap
[1] = wxRibbonLoadPixmap(panel_toggle_up_xpm
, colour
);
1033 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
1038 void wxRibbonMSWArtProvider::DrawTabCtrlBackground(
1040 wxWindow
* WXUNUSED(wnd
),
1043 dc
.SetPen(*wxTRANSPARENT_PEN
);
1044 dc
.SetBrush(m_tab_ctrl_background_brush
);
1045 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
1047 dc
.SetPen(m_page_border_pen
);
1050 dc
.DrawLine(rect
.x
+ 3, rect
.y
+ rect
.height
- 1, rect
.x
+ rect
.width
- 3, rect
.y
+ rect
.height
- 1);
1054 dc
.DrawLine(rect
.x
, rect
.y
+ rect
.height
- 1, rect
.x
+ rect
.width
, rect
.y
+ rect
.height
- 1);
1058 void wxRibbonMSWArtProvider::DrawTab(
1060 wxWindow
* WXUNUSED(wnd
),
1061 const wxRibbonPageTabInfo
& tab
)
1063 if(tab
.rect
.height
<= 2)
1066 if(tab
.active
|| tab
.hovered
)
1070 wxRect
background(tab
.rect
);
1074 background
.width
-= 4;
1075 background
.height
-= 2;
1077 dc
.GradientFillLinear(background
, m_tab_active_background_colour
,
1078 m_tab_active_background_gradient_colour
, wxSOUTH
);
1080 // TODO: active and hovered
1082 else if(tab
.hovered
)
1084 wxRect
background(tab
.rect
);
1088 background
.width
-= 4;
1089 background
.height
-= 3;
1090 int h
= background
.height
;
1091 background
.height
/= 2;
1092 dc
.GradientFillLinear(background
,
1093 m_tab_hover_background_top_colour
,
1094 m_tab_hover_background_top_gradient_colour
, wxSOUTH
);
1096 background
.y
+= background
.height
;
1097 background
.height
= h
- background
.height
;
1098 dc
.GradientFillLinear(background
, m_tab_hover_background_colour
,
1099 m_tab_hover_background_gradient_colour
, wxSOUTH
);
1102 wxPoint border_points
[6];
1103 border_points
[0] = wxPoint(1, tab
.rect
.height
- 2);
1104 border_points
[1] = wxPoint(1, 3);
1105 border_points
[2] = wxPoint(3, 1);
1106 border_points
[3] = wxPoint(tab
.rect
.width
- 4, 1);
1107 border_points
[4] = wxPoint(tab
.rect
.width
- 2, 3);
1108 border_points
[5] = wxPoint(tab
.rect
.width
- 2, tab
.rect
.height
- 1);
1110 dc
.SetPen(m_tab_border_pen
);
1111 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
, tab
.rect
.x
, tab
.rect
.y
);
1115 // Give the tab a curved outward border at the bottom
1116 dc
.DrawPoint(tab
.rect
.x
, tab
.rect
.y
+ tab
.rect
.height
- 2);
1117 dc
.DrawPoint(tab
.rect
.x
+ tab
.rect
.width
- 1, tab
.rect
.y
+ tab
.rect
.height
- 2);
1119 wxPen
p(m_tab_active_background_gradient_colour
);
1122 // Technically the first two points are the wrong colour, but they're near enough
1123 dc
.DrawPoint(tab
.rect
.x
+ 1, tab
.rect
.y
+ tab
.rect
.height
- 2);
1124 dc
.DrawPoint(tab
.rect
.x
+ tab
.rect
.width
- 2, tab
.rect
.y
+ tab
.rect
.height
- 2);
1125 dc
.DrawPoint(tab
.rect
.x
+ 1, tab
.rect
.y
+ tab
.rect
.height
- 1);
1126 dc
.DrawPoint(tab
.rect
.x
, tab
.rect
.y
+ tab
.rect
.height
- 1);
1127 dc
.DrawPoint(tab
.rect
.x
+ tab
.rect
.width
- 2, tab
.rect
.y
+ tab
.rect
.height
- 1);
1128 dc
.DrawPoint(tab
.rect
.x
+ tab
.rect
.width
- 1, tab
.rect
.y
+ tab
.rect
.height
- 1);
1132 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_ICONS
)
1134 wxBitmap icon
= tab
.page
->GetIcon();
1137 int x
= tab
.rect
.x
+ 4;
1138 if((m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
) == 0)
1139 x
= tab
.rect
.x
+ (tab
.rect
.width
- icon
.GetWidth()) / 2;
1140 dc
.DrawBitmap(icon
, x
, tab
.rect
.y
+ 1 + (tab
.rect
.height
- 1 -
1141 icon
.GetHeight()) / 2, true);
1144 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
)
1146 wxString label
= tab
.page
->GetLabel();
1147 if(!label
.IsEmpty())
1149 dc
.SetFont(m_tab_label_font
);
1150 dc
.SetTextForeground(m_tab_label_colour
);
1151 dc
.SetBackgroundMode(wxTRANSPARENT
);
1155 dc
.GetTextExtent(label
, &text_width
, &text_height
);
1156 int width
= tab
.rect
.width
- 5;
1157 int x
= tab
.rect
.x
+ 3;
1158 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_ICONS
)
1160 x
+= 3 + tab
.page
->GetIcon().GetWidth();
1161 width
-= 3 + tab
.page
->GetIcon().GetWidth();
1163 int y
= tab
.rect
.y
+ (tab
.rect
.height
- text_height
) / 2;
1165 if(width
<= text_width
)
1167 dc
.SetClippingRegion(x
, tab
.rect
.y
, width
, tab
.rect
.height
);
1168 dc
.DrawText(label
, x
, y
);
1172 dc
.DrawText(label
, x
+ (width
- text_width
) / 2 + 1, y
);
1178 void wxRibbonMSWArtProvider::DrawTabSeparator(
1184 if(visibility
<= 0.0)
1188 if(visibility
> 1.0)
1193 // The tab separator is relatively expensive to draw (for its size), and is
1194 // usually drawn multiple times sequentially (in different positions), so it
1195 // makes sense to draw it once and cache it.
1196 if(!m_cached_tab_separator
.IsOk() || m_cached_tab_separator
.GetSize() != rect
.GetSize() || visibility
!= m_cached_tab_separator_visibility
)
1198 wxRect
size(rect
.GetSize());
1199 ReallyDrawTabSeparator(wnd
, size
, visibility
);
1201 dc
.DrawBitmap(m_cached_tab_separator
, rect
.x
, rect
.y
, false);
1204 void wxRibbonMSWArtProvider::ReallyDrawTabSeparator(wxWindow
* wnd
, const wxRect
& rect
, double visibility
)
1206 if(!m_cached_tab_separator
.IsOk() || m_cached_tab_separator
.GetSize() != rect
.GetSize())
1208 m_cached_tab_separator
= wxBitmap(rect
.GetSize());
1211 wxMemoryDC
dc(m_cached_tab_separator
);
1212 DrawTabCtrlBackground(dc
, wnd
, rect
);
1214 wxCoord x
= rect
.x
+ rect
.width
/ 2;
1215 double h
= (double)(rect
.height
- 1);
1217 double r1
= m_tab_ctrl_background_brush
.GetColour().Red() * (1.0 - visibility
) + 0.5;
1218 double g1
= m_tab_ctrl_background_brush
.GetColour().Green() * (1.0 - visibility
) + 0.5;
1219 double b1
= m_tab_ctrl_background_brush
.GetColour().Blue() * (1.0 - visibility
) + 0.5;
1220 double r2
= m_tab_separator_colour
.Red();
1221 double g2
= m_tab_separator_colour
.Green();
1222 double b2
= m_tab_separator_colour
.Blue();
1223 double r3
= m_tab_separator_gradient_colour
.Red();
1224 double g3
= m_tab_separator_gradient_colour
.Green();
1225 double b3
= m_tab_separator_gradient_colour
.Blue();
1227 for(int i
= 0; i
< rect
.height
- 1; ++i
)
1229 double p
= ((double)i
)/h
;
1231 double r
= (p
* r3
+ (1.0 - p
) * r2
) * visibility
+ r1
;
1232 double g
= (p
* g3
+ (1.0 - p
) * g2
) * visibility
+ g1
;
1233 double b
= (p
* b3
+ (1.0 - p
) * b2
) * visibility
+ b1
;
1235 wxPen
P(wxColour((unsigned char)r
, (unsigned char)g
, (unsigned char)b
));
1237 dc
.DrawPoint(x
, rect
.y
+ i
);
1240 m_cached_tab_separator_visibility
= visibility
;
1243 void wxRibbonMSWArtProvider::DrawPartialPageBackground(wxDC
& dc
,
1244 wxWindow
* wnd
, const wxRect
& rect
, wxRibbonPage
* page
,
1245 wxPoint offset
, bool hovered
)
1248 // Expanded panels need a background - the expanded panel at
1249 // best size may have a greater Y dimension higher than when
1250 // on the bar if it has a sizer. AUI art provider does not need this
1251 // because it paints the panel without reference to its parent's size.
1252 // Expanded panels use a wxFrame as parent (not a wxRibbonPage).
1254 if(wnd
->GetSizer() && wnd
->GetParent() != page
)
1256 background
= wnd
->GetParent()->GetSize();
1257 offset
= wxPoint(0,0);
1261 background
= page
->GetSize();
1262 page
->AdjustRectToIncludeScrollButtons(&background
);
1263 background
.height
-= 2;
1265 // Page background isn't dependant upon the width of the page
1266 // (at least not the part of it intended to be painted by this
1267 // function). Set to wider than the page itself for when externally
1268 // expanded panels need a background - the expanded panel can be wider
1271 background
.width
= INT_MAX
;
1273 // upper_rect, lower_rect, paint_rect are all in page co-ordinates
1274 wxRect
upper_rect(background
);
1275 upper_rect
.height
/= 5;
1277 wxRect
lower_rect(background
);
1278 lower_rect
.y
+= upper_rect
.height
;
1279 lower_rect
.height
-= upper_rect
.height
;
1281 wxRect
paint_rect(rect
);
1282 paint_rect
.x
+= offset
.x
;
1283 paint_rect
.y
+= offset
.y
;
1285 wxColour bg_top
, bg_top_grad
, bg_btm
, bg_btm_grad
;
1288 bg_top
= m_page_hover_background_top_colour
;
1289 bg_top_grad
= m_page_hover_background_top_gradient_colour
;
1290 bg_btm
= m_page_hover_background_colour
;
1291 bg_btm_grad
= m_page_hover_background_gradient_colour
;
1295 bg_top
= m_page_background_top_colour
;
1296 bg_top_grad
= m_page_background_top_gradient_colour
;
1297 bg_btm
= m_page_background_colour
;
1298 bg_btm_grad
= m_page_background_gradient_colour
;
1301 if(paint_rect
.Intersects(upper_rect
))
1303 wxRect
rect(upper_rect
);
1304 rect
.Intersect(paint_rect
);
1307 wxColour
starting_colour(wxRibbonInterpolateColour(bg_top
, bg_top_grad
,
1308 paint_rect
.y
, upper_rect
.y
, upper_rect
.y
+ upper_rect
.height
));
1309 wxColour
ending_colour(wxRibbonInterpolateColour(bg_top
, bg_top_grad
,
1310 paint_rect
.y
+ paint_rect
.height
, upper_rect
.y
,
1311 upper_rect
.y
+ upper_rect
.height
));
1312 dc
.GradientFillLinear(rect
, starting_colour
, ending_colour
, wxSOUTH
);
1315 if(paint_rect
.Intersects(lower_rect
))
1317 wxRect
rect(lower_rect
);
1318 rect
.Intersect(paint_rect
);
1321 wxColour
starting_colour(wxRibbonInterpolateColour(bg_btm
, bg_btm_grad
,
1322 paint_rect
.y
, lower_rect
.y
, lower_rect
.y
+ lower_rect
.height
));
1323 wxColour
ending_colour(wxRibbonInterpolateColour(bg_btm
, bg_btm_grad
,
1324 paint_rect
.y
+ paint_rect
.height
,
1325 lower_rect
.y
, lower_rect
.y
+ lower_rect
.height
));
1326 dc
.GradientFillLinear(rect
, starting_colour
, ending_colour
, wxSOUTH
);
1330 void wxRibbonMSWArtProvider::DrawPageBackground(
1332 wxWindow
* WXUNUSED(wnd
),
1335 dc
.SetPen(*wxTRANSPARENT_PEN
);
1336 dc
.SetBrush(m_tab_ctrl_background_brush
);
1342 dc
.DrawRectangle(edge
.x
, edge
.y
, edge
.width
, edge
.height
);
1344 edge
.x
+= rect
.width
- 2;
1345 dc
.DrawRectangle(edge
.x
, edge
.y
, edge
.width
, edge
.height
);
1349 edge
.y
+= (rect
.height
- edge
.height
);
1350 dc
.DrawRectangle(edge
.x
, edge
.y
, edge
.width
, edge
.height
);
1354 wxRect
background(rect
);
1356 background
.width
-= 4;
1357 background
.height
-= 2;
1359 background
.height
/= 5;
1360 dc
.GradientFillLinear(background
, m_page_background_top_colour
,
1361 m_page_background_top_gradient_colour
, wxSOUTH
);
1363 background
.y
+= background
.height
;
1364 background
.height
= rect
.height
- 2 - background
.height
;
1365 dc
.GradientFillLinear(background
, m_page_background_colour
,
1366 m_page_background_gradient_colour
, wxSOUTH
);
1370 wxPoint border_points
[8];
1371 border_points
[0] = wxPoint(2, 0);
1372 border_points
[1] = wxPoint(1, 1);
1373 border_points
[2] = wxPoint(1, rect
.height
- 4);
1374 border_points
[3] = wxPoint(3, rect
.height
- 2);
1375 border_points
[4] = wxPoint(rect
.width
- 4, rect
.height
- 2);
1376 border_points
[5] = wxPoint(rect
.width
- 2, rect
.height
- 4);
1377 border_points
[6] = wxPoint(rect
.width
- 2, 1);
1378 border_points
[7] = wxPoint(rect
.width
- 4, -1);
1380 dc
.SetPen(m_page_border_pen
);
1381 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
, rect
.x
, rect
.y
);
1385 void wxRibbonMSWArtProvider::DrawScrollButton(
1387 wxWindow
* WXUNUSED(wnd
),
1388 const wxRect
& rect_
,
1393 if((style
& wxRIBBON_SCROLL_BTN_FOR_MASK
) == wxRIBBON_SCROLL_BTN_FOR_PAGE
)
1395 // Page scroll buttons do not have the luxury of rendering on top of anything
1396 // else, and their size includes some padding, hence the background painting
1397 // and size adjustment.
1398 dc
.SetPen(*wxTRANSPARENT_PEN
);
1399 dc
.SetBrush(m_tab_ctrl_background_brush
);
1400 dc
.DrawRectangle(rect
);
1401 dc
.SetClippingRegion(rect
);
1402 switch(style
& wxRIBBON_SCROLL_BTN_DIRECTION_MASK
)
1404 case wxRIBBON_SCROLL_BTN_LEFT
:
1406 case wxRIBBON_SCROLL_BTN_RIGHT
:
1410 case wxRIBBON_SCROLL_BTN_UP
:
1416 case wxRIBBON_SCROLL_BTN_DOWN
:
1425 wxRect
background(rect
);
1428 background
.width
-= 2;
1429 background
.height
-= 2;
1431 if(style
& wxRIBBON_SCROLL_BTN_UP
)
1432 background
.height
/= 2;
1434 background
.height
/= 5;
1435 dc
.GradientFillLinear(background
, m_page_background_top_colour
,
1436 m_page_background_top_gradient_colour
, wxSOUTH
);
1438 background
.y
+= background
.height
;
1439 background
.height
= rect
.height
- 2 - background
.height
;
1440 dc
.GradientFillLinear(background
, m_page_background_colour
,
1441 m_page_background_gradient_colour
, wxSOUTH
);
1445 wxPoint border_points
[7];
1446 switch(style
& wxRIBBON_SCROLL_BTN_DIRECTION_MASK
)
1448 case wxRIBBON_SCROLL_BTN_LEFT
:
1449 border_points
[0] = wxPoint(2, 0);
1450 border_points
[1] = wxPoint(rect
.width
- 1, 0);
1451 border_points
[2] = wxPoint(rect
.width
- 1, rect
.height
- 1);
1452 border_points
[3] = wxPoint(2, rect
.height
- 1);
1453 border_points
[4] = wxPoint(0, rect
.height
- 3);
1454 border_points
[5] = wxPoint(0, 2);
1456 case wxRIBBON_SCROLL_BTN_RIGHT
:
1457 border_points
[0] = wxPoint(0, 0);
1458 border_points
[1] = wxPoint(rect
.width
- 3, 0);
1459 border_points
[2] = wxPoint(rect
.width
- 1, 2);
1460 border_points
[3] = wxPoint(rect
.width
- 1, rect
.height
- 3);
1461 border_points
[4] = wxPoint(rect
.width
- 3, rect
.height
- 1);
1462 border_points
[5] = wxPoint(0, rect
.height
- 1);
1464 case wxRIBBON_SCROLL_BTN_UP
:
1465 border_points
[0] = wxPoint(2, 0);
1466 border_points
[1] = wxPoint(rect
.width
- 3, 0);
1467 border_points
[2] = wxPoint(rect
.width
- 1, 2);
1468 border_points
[3] = wxPoint(rect
.width
- 1, rect
.height
- 1);
1469 border_points
[4] = wxPoint(0, rect
.height
- 1);
1470 border_points
[5] = wxPoint(0, 2);
1472 case wxRIBBON_SCROLL_BTN_DOWN
:
1473 border_points
[0] = wxPoint(0, 0);
1474 border_points
[1] = wxPoint(rect
.width
- 1, 0);
1475 border_points
[2] = wxPoint(rect
.width
- 1, rect
.height
- 3);
1476 border_points
[3] = wxPoint(rect
.width
- 3, rect
.height
- 1);
1477 border_points
[4] = wxPoint(2, rect
.height
- 1);
1478 border_points
[5] = wxPoint(0, rect
.height
- 3);
1481 border_points
[6] = border_points
[0];
1483 dc
.SetPen(m_page_border_pen
);
1484 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
, rect
.x
, rect
.y
);
1488 // NB: Code for handling hovered/active state is temporary
1489 wxPoint arrow_points
[3];
1490 switch(style
& wxRIBBON_SCROLL_BTN_DIRECTION_MASK
)
1492 case wxRIBBON_SCROLL_BTN_LEFT
:
1493 arrow_points
[0] = wxPoint(rect
.width
/ 2 - 2, rect
.height
/ 2);
1494 if(style
& wxRIBBON_SCROLL_BTN_ACTIVE
)
1495 arrow_points
[0].y
+= 1;
1496 arrow_points
[1] = arrow_points
[0] + wxPoint(3, -3);
1497 arrow_points
[2] = arrow_points
[0] + wxPoint(3, 3);
1499 case wxRIBBON_SCROLL_BTN_RIGHT
:
1500 arrow_points
[0] = wxPoint(rect
.width
/ 2 + 2, rect
.height
/ 2);
1501 if(style
& wxRIBBON_SCROLL_BTN_ACTIVE
)
1502 arrow_points
[0].y
+= 1;
1503 arrow_points
[1] = arrow_points
[0] - wxPoint(3, 3);
1504 arrow_points
[2] = arrow_points
[0] - wxPoint(3, -3);
1506 case wxRIBBON_SCROLL_BTN_UP
:
1507 arrow_points
[0] = wxPoint(rect
.width
/ 2, rect
.height
/ 2 - 2);
1508 if(style
& wxRIBBON_SCROLL_BTN_ACTIVE
)
1509 arrow_points
[0].y
+= 1;
1510 arrow_points
[1] = arrow_points
[0] + wxPoint( 3, 3);
1511 arrow_points
[2] = arrow_points
[0] + wxPoint(-3, 3);
1513 case wxRIBBON_SCROLL_BTN_DOWN
:
1514 arrow_points
[0] = wxPoint(rect
.width
/ 2, rect
.height
/ 2 + 2);
1515 if(style
& wxRIBBON_SCROLL_BTN_ACTIVE
)
1516 arrow_points
[0].y
+= 1;
1517 arrow_points
[1] = arrow_points
[0] - wxPoint( 3, 3);
1518 arrow_points
[2] = arrow_points
[0] - wxPoint(-3, 3);
1522 dc
.SetPen(*wxTRANSPARENT_PEN
);
1523 wxBrush
B(style
& wxRIBBON_SCROLL_BTN_HOVERED
? m_tab_active_background_colour
: m_tab_label_colour
);
1525 dc
.DrawPolygon(sizeof(arrow_points
)/sizeof(wxPoint
), arrow_points
, rect
.x
, rect
.y
);
1529 void wxRibbonMSWArtProvider::DrawDropdownArrow(wxDC
& dc
, int x
, int y
, const wxColour
& colour
)
1531 wxPoint arrow_points
[3];
1532 wxBrush
brush(colour
);
1533 arrow_points
[0] = wxPoint(1, 2);
1534 arrow_points
[1] = arrow_points
[0] + wxPoint(-3, -3);
1535 arrow_points
[2] = arrow_points
[0] + wxPoint( 3, -3);
1536 dc
.SetPen(*wxTRANSPARENT_PEN
);
1538 dc
.DrawPolygon(sizeof(arrow_points
)/sizeof(wxPoint
), arrow_points
, x
, y
);
1541 void wxRibbonMSWArtProvider::RemovePanelPadding(wxRect
* rect
)
1543 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1555 void wxRibbonMSWArtProvider::DrawPanelBackground(
1560 DrawPartialPageBackground(dc
, wnd
, rect
, false);
1562 wxRect
true_rect(rect
);
1563 RemovePanelPadding(&true_rect
);
1564 bool has_ext_button
= wnd
->HasExtButton();
1568 dc
.SetFont(m_panel_label_font
);
1569 dc
.SetPen(*wxTRANSPARENT_PEN
);
1570 if(wnd
->IsHovered())
1572 dc
.SetBrush(m_panel_hover_label_background_brush
);
1573 dc
.SetTextForeground(m_panel_hover_label_colour
);
1577 dc
.SetBrush(m_panel_label_background_brush
);
1578 dc
.SetTextForeground(m_panel_label_colour
);
1581 wxRect
label_rect(true_rect
);
1582 wxString label
= wnd
->GetLabel();
1583 bool clip_label
= false;
1584 wxSize
label_size(dc
.GetTextExtent(label
));
1586 label_rect
.SetX(label_rect
.GetX() + 1);
1587 label_rect
.SetWidth(label_rect
.GetWidth() - 2);
1588 label_rect
.SetHeight(label_size
.GetHeight() + 2);
1589 label_rect
.SetY(true_rect
.GetBottom() - label_rect
.GetHeight());
1590 label_height
= label_rect
.GetHeight();
1592 wxRect label_bg_rect
= label_rect
;
1595 label_rect
.SetWidth(label_rect
.GetWidth() - 13);
1597 if(label_size
.GetWidth() > label_rect
.GetWidth())
1599 // Test if there is enough length for 3 letters and ...
1600 wxString new_label
= label
.Mid(0, 3) + wxT("...");
1601 label_size
= dc
.GetTextExtent(new_label
);
1602 if(label_size
.GetWidth() > label_rect
.GetWidth())
1604 // Not enough room for three characters and ...
1605 // Display the entire label and just crop it
1610 // Room for some characters and ...
1611 // Display as many characters as possible and append ...
1612 for(size_t len
= label
.Len() - 1; len
>= 3; --len
)
1614 new_label
= label
.Mid(0, len
) + wxT("...");
1615 label_size
= dc
.GetTextExtent(new_label
);
1616 if(label_size
.GetWidth() <= label_rect
.GetWidth())
1625 dc
.DrawRectangle(label_bg_rect
);
1628 wxDCClipper
clip(dc
, label_rect
);
1629 dc
.DrawText(label
, label_rect
.x
, label_rect
.y
+
1630 (label_rect
.GetHeight() - label_size
.GetHeight()) / 2);
1634 dc
.DrawText(label
, label_rect
.x
+
1635 (label_rect
.GetWidth() - label_size
.GetWidth()) / 2,
1637 (label_rect
.GetHeight() - label_size
.GetHeight()) / 2);
1642 if(wnd
->IsExtButtonHovered())
1644 dc
.SetPen(m_panel_hover_button_border_pen
);
1645 dc
.SetBrush(m_panel_hover_button_background_brush
);
1646 dc
.DrawRoundedRectangle(label_rect
.GetRight(), label_rect
.GetBottom() - 13, 13, 13, 1.0);
1647 dc
.DrawBitmap(m_panel_extension_bitmap
[1], label_rect
.GetRight() + 3, label_rect
.GetBottom() - 10, true);
1650 dc
.DrawBitmap(m_panel_extension_bitmap
[0], label_rect
.GetRight() + 3, label_rect
.GetBottom() - 10, true);
1654 if(wnd
->IsHovered())
1656 wxRect
client_rect(true_rect
);
1658 client_rect
.width
-= 2;
1660 client_rect
.height
-= 2 + label_height
;
1661 DrawPartialPageBackground(dc
, wnd
, client_rect
, true);
1664 DrawPanelBorder(dc
, true_rect
, m_panel_border_pen
, m_panel_border_gradient_pen
);
1667 wxRect
wxRibbonMSWArtProvider::GetPanelExtButtonArea(wxDC
& WXUNUSED(dc
),
1668 const wxRibbonPanel
* WXUNUSED(wnd
),
1671 RemovePanelPadding(&rect
);
1672 rect
= wxRect(rect
.GetRight()-13, rect
.GetBottom()-13, 13, 13);
1676 void wxRibbonMSWArtProvider::DrawGalleryBackground(
1678 wxRibbonGallery
* wnd
,
1681 DrawPartialPageBackground(dc
, wnd
, rect
);
1683 if(wnd
->IsHovered())
1685 dc
.SetPen(*wxTRANSPARENT_PEN
);
1686 dc
.SetBrush(m_gallery_hover_background_brush
);
1687 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1689 dc
.DrawRectangle(rect
.x
+ 1, rect
.y
+ 1, rect
.width
- 2,
1694 dc
.DrawRectangle(rect
.x
+ 1, rect
.y
+ 1, rect
.width
- 16,
1699 dc
.SetPen(m_gallery_border_pen
);
1701 dc
.DrawLine(rect
.x
+ 1, rect
.y
, rect
.x
+ rect
.width
- 1, rect
.y
);
1702 dc
.DrawLine(rect
.x
, rect
.y
+ 1, rect
.x
, rect
.y
+ rect
.height
- 1);
1703 dc
.DrawLine(rect
.x
+ 1, rect
.y
+ rect
.height
- 1, rect
.x
+ rect
.width
- 1,
1704 rect
.y
+ rect
.height
- 1);
1705 dc
.DrawLine(rect
.x
+ rect
.width
- 1, rect
.y
+ 1, rect
.x
+ rect
.width
- 1,
1706 rect
.y
+ rect
.height
- 1);
1708 DrawGalleryBackgroundCommon(dc
, wnd
, rect
);
1711 void wxRibbonMSWArtProvider::DrawGalleryBackgroundCommon(wxDC
& dc
,
1712 wxRibbonGallery
* wnd
,
1715 wxRect up_btn
, down_btn
, ext_btn
;
1717 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1719 // Divider between items and buttons
1720 dc
.DrawLine(rect
.x
, rect
.y
+ rect
.height
- 15, rect
.x
+ rect
.width
,
1721 rect
.y
+ rect
.height
- 15);
1723 up_btn
= wxRect(rect
.x
, rect
.y
+ rect
.height
- 15, rect
.width
/ 3, 15);
1725 down_btn
= wxRect(up_btn
.GetRight() + 1, up_btn
.GetTop(),
1726 up_btn
.GetWidth(), up_btn
.GetHeight());
1727 dc
.DrawLine(down_btn
.GetLeft(), down_btn
.GetTop(), down_btn
.GetLeft(),
1728 down_btn
.GetBottom());
1730 ext_btn
= wxRect(down_btn
.GetRight() + 1, up_btn
.GetTop(), rect
.width
-
1731 up_btn
.GetWidth() - down_btn
.GetWidth() - 1, up_btn
.GetHeight());
1732 dc
.DrawLine(ext_btn
.GetLeft(), ext_btn
.GetTop(), ext_btn
.GetLeft(),
1733 ext_btn
.GetBottom());
1737 // Divider between items and buttons
1738 dc
.DrawLine(rect
.x
+ rect
.width
- 15, rect
.y
, rect
.x
+ rect
.width
- 15,
1739 rect
.y
+ rect
.height
);
1741 up_btn
= wxRect(rect
.x
+ rect
.width
- 15, rect
.y
, 15, rect
.height
/ 3);
1743 down_btn
= wxRect(up_btn
.GetLeft(), up_btn
.GetBottom() + 1,
1744 up_btn
.GetWidth(), up_btn
.GetHeight());
1745 dc
.DrawLine(down_btn
.GetLeft(), down_btn
.GetTop(), down_btn
.GetRight(),
1748 ext_btn
= wxRect(up_btn
.GetLeft(), down_btn
.GetBottom() + 1, up_btn
.GetWidth(),
1749 rect
.height
- up_btn
.GetHeight() - down_btn
.GetHeight() - 1);
1750 dc
.DrawLine(ext_btn
.GetLeft(), ext_btn
.GetTop(), ext_btn
.GetRight(),
1754 DrawGalleryButton(dc
, up_btn
, wnd
->GetUpButtonState(),
1755 m_gallery_up_bitmap
);
1756 DrawGalleryButton(dc
, down_btn
, wnd
->GetDownButtonState(),
1757 m_gallery_down_bitmap
);
1758 DrawGalleryButton(dc
, ext_btn
, wnd
->GetExtensionButtonState(),
1759 m_gallery_extension_bitmap
);
1762 void wxRibbonMSWArtProvider::DrawGalleryButton(wxDC
& dc
,
1764 wxRibbonGalleryButtonState state
,
1767 wxBitmap btn_bitmap
;
1768 wxBrush btn_top_brush
;
1769 wxColour btn_colour
;
1770 wxColour btn_grad_colour
;
1773 case wxRIBBON_GALLERY_BUTTON_NORMAL
:
1774 btn_top_brush
= m_gallery_button_background_top_brush
;
1775 btn_colour
= m_gallery_button_background_colour
;
1776 btn_grad_colour
= m_gallery_button_background_gradient_colour
;
1777 btn_bitmap
= bitmaps
[0];
1779 case wxRIBBON_GALLERY_BUTTON_HOVERED
:
1780 btn_top_brush
= m_gallery_button_hover_background_top_brush
;
1781 btn_colour
= m_gallery_button_hover_background_colour
;
1782 btn_grad_colour
= m_gallery_button_hover_background_gradient_colour
;
1783 btn_bitmap
= bitmaps
[1];
1785 case wxRIBBON_GALLERY_BUTTON_ACTIVE
:
1786 btn_top_brush
= m_gallery_button_active_background_top_brush
;
1787 btn_colour
= m_gallery_button_active_background_colour
;
1788 btn_grad_colour
= m_gallery_button_active_background_gradient_colour
;
1789 btn_bitmap
= bitmaps
[2];
1791 case wxRIBBON_GALLERY_BUTTON_DISABLED
:
1792 btn_top_brush
= m_gallery_button_disabled_background_top_brush
;
1793 btn_colour
= m_gallery_button_disabled_background_colour
;
1794 btn_grad_colour
= m_gallery_button_disabled_background_gradient_colour
;
1795 btn_bitmap
= bitmaps
[3];
1801 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1812 dc
.SetPen(*wxTRANSPARENT_PEN
);
1813 dc
.SetBrush(btn_top_brush
);
1814 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
/ 2);
1817 lower
.height
= (lower
.height
+ 1) / 2;
1818 lower
.y
+= rect
.height
- lower
.height
;
1819 dc
.GradientFillLinear(lower
, btn_colour
, btn_grad_colour
, wxSOUTH
);
1821 dc
.DrawBitmap(btn_bitmap
, rect
.x
+ rect
.width
/ 2 - 2, lower
.y
- 2, true);
1824 void wxRibbonMSWArtProvider::DrawGalleryItemBackground(
1826 wxRibbonGallery
* wnd
,
1828 wxRibbonGalleryItem
* item
)
1830 if(wnd
->GetHoveredItem() != item
&& wnd
->GetActiveItem() != item
&&
1831 wnd
->GetSelection() != item
)
1834 dc
.SetPen(m_gallery_item_border_pen
);
1835 dc
.DrawLine(rect
.x
+ 1, rect
.y
, rect
.x
+ rect
.width
- 1, rect
.y
);
1836 dc
.DrawLine(rect
.x
, rect
.y
+ 1, rect
.x
, rect
.y
+ rect
.height
- 1);
1837 dc
.DrawLine(rect
.x
+ 1, rect
.y
+ rect
.height
- 1, rect
.x
+ rect
.width
- 1,
1838 rect
.y
+ rect
.height
- 1);
1839 dc
.DrawLine(rect
.x
+ rect
.width
- 1, rect
.y
+ 1, rect
.x
+ rect
.width
- 1,
1840 rect
.y
+ rect
.height
- 1);
1844 wxColour bg_gradient_colour
;
1846 if(wnd
->GetActiveItem() == item
|| wnd
->GetSelection() == item
)
1848 top_brush
= m_gallery_button_active_background_top_brush
;
1849 bg_colour
= m_gallery_button_active_background_colour
;
1850 bg_gradient_colour
= m_gallery_button_active_background_gradient_colour
;
1854 top_brush
= m_gallery_button_hover_background_top_brush
;
1855 bg_colour
= m_gallery_button_hover_background_colour
;
1856 bg_gradient_colour
= m_gallery_button_hover_background_gradient_colour
;
1864 dc
.SetPen(*wxTRANSPARENT_PEN
);
1865 dc
.SetBrush(top_brush
);
1866 dc
.DrawRectangle(upper
.x
, upper
.y
, upper
.width
, upper
.height
);
1868 wxRect
lower(upper
);
1869 lower
.y
+= lower
.height
;
1870 lower
.height
= rect
.height
- 2 - lower
.height
;
1871 dc
.GradientFillLinear(lower
, bg_colour
, bg_gradient_colour
, wxSOUTH
);
1874 void wxRibbonMSWArtProvider::DrawPanelBorder(wxDC
& dc
, const wxRect
& rect
,
1875 wxPen
& primary_colour
,
1876 wxPen
& secondary_colour
)
1878 wxPoint border_points
[9];
1879 border_points
[0] = wxPoint(2, 0);
1880 border_points
[1] = wxPoint(rect
.width
- 3, 0);
1881 border_points
[2] = wxPoint(rect
.width
- 1, 2);
1882 border_points
[3] = wxPoint(rect
.width
- 1, rect
.height
- 3);
1883 border_points
[4] = wxPoint(rect
.width
- 3, rect
.height
- 1);
1884 border_points
[5] = wxPoint(2, rect
.height
- 1);
1885 border_points
[6] = wxPoint(0, rect
.height
- 3);
1886 border_points
[7] = wxPoint(0, 2);
1888 if(primary_colour
.GetColour() == secondary_colour
.GetColour())
1890 border_points
[8] = border_points
[0];
1891 dc
.SetPen(primary_colour
);
1892 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
, rect
.x
, rect
.y
);
1896 dc
.SetPen(primary_colour
);
1897 dc
.DrawLines(3, border_points
, rect
.x
, rect
.y
);
1899 #define SingleLine(start, finish) \
1900 dc.DrawLine(start.x + rect.x, start.y + rect.y, finish.x + rect.x, finish.y + rect.y)
1902 SingleLine(border_points
[0], border_points
[7]);
1903 dc
.SetPen(secondary_colour
);
1904 dc
.DrawLines(3, border_points
+ 4, rect
.x
, rect
.y
);
1905 SingleLine(border_points
[4], border_points
[3]);
1909 border_points
[6] = border_points
[2];
1910 wxRibbonDrawParallelGradientLines(dc
, 2, border_points
+ 6, 0, 1,
1911 border_points
[3].y
- border_points
[2].y
+ 1, rect
.x
, rect
.y
,
1912 primary_colour
.GetColour(), secondary_colour
.GetColour());
1916 void wxRibbonMSWArtProvider::DrawMinimisedPanel(
1922 DrawPartialPageBackground(dc
, wnd
, rect
, false);
1924 wxRect
true_rect(rect
);
1925 RemovePanelPadding(&true_rect
);
1927 if(wnd
->GetExpandedPanel() != NULL
)
1929 wxRect
client_rect(true_rect
);
1931 client_rect
.width
-= 2;
1933 client_rect
.height
= (rect
.y
+ rect
.height
/ 5) - client_rect
.x
;
1934 dc
.GradientFillLinear(client_rect
,
1935 m_panel_active_background_top_colour
,
1936 m_panel_active_background_top_gradient_colour
, wxSOUTH
);
1938 client_rect
.y
+= client_rect
.height
;
1939 client_rect
.height
= (true_rect
.y
+ true_rect
.height
) - client_rect
.y
;
1940 dc
.GradientFillLinear(client_rect
,
1941 m_panel_active_background_colour
,
1942 m_panel_active_background_gradient_colour
, wxSOUTH
);
1944 else if(wnd
->IsHovered())
1946 wxRect
client_rect(true_rect
);
1948 client_rect
.width
-= 2;
1950 client_rect
.height
-= 2;
1951 DrawPartialPageBackground(dc
, wnd
, client_rect
, true);
1955 DrawMinimisedPanelCommon(dc
, wnd
, true_rect
, &preview
);
1957 dc
.SetBrush(m_panel_hover_label_background_brush
);
1958 dc
.SetPen(*wxTRANSPARENT_PEN
);
1959 dc
.DrawRectangle(preview
.x
+ 1, preview
.y
+ preview
.height
- 8,
1960 preview
.width
- 2, 7);
1962 int mid_pos
= rect
.y
+ rect
.height
/ 5 - preview
.y
;
1963 if(mid_pos
< 0 || mid_pos
>= preview
.height
)
1965 wxRect
full_rect(preview
);
1968 full_rect
.width
-= 2;
1969 full_rect
.height
-= 9;
1972 dc
.GradientFillLinear(full_rect
,
1973 m_page_hover_background_colour
,
1974 m_page_hover_background_gradient_colour
, wxSOUTH
);
1978 dc
.GradientFillLinear(full_rect
,
1979 m_page_hover_background_top_colour
,
1980 m_page_hover_background_top_gradient_colour
, wxSOUTH
);
1985 wxRect
top_rect(preview
);
1988 top_rect
.width
-= 2;
1989 top_rect
.height
= mid_pos
;
1990 dc
.GradientFillLinear(top_rect
,
1991 m_page_hover_background_top_colour
,
1992 m_page_hover_background_top_gradient_colour
, wxSOUTH
);
1994 wxRect
btm_rect(top_rect
);
1995 btm_rect
.y
= preview
.y
+ mid_pos
;
1996 btm_rect
.height
= preview
.y
+ preview
.height
- 7 - btm_rect
.y
;
1997 dc
.GradientFillLinear(btm_rect
,
1998 m_page_hover_background_colour
,
1999 m_page_hover_background_gradient_colour
, wxSOUTH
);
2004 dc
.DrawBitmap(bitmap
, preview
.x
+ (preview
.width
- bitmap
.GetWidth()) / 2,
2005 preview
.y
+ (preview
.height
- 7 - bitmap
.GetHeight()) / 2, true);
2008 DrawPanelBorder(dc
, preview
, m_panel_border_pen
, m_panel_border_gradient_pen
);
2010 DrawPanelBorder(dc
, true_rect
, m_panel_minimised_border_pen
,
2011 m_panel_minimised_border_gradient_pen
);
2014 void wxRibbonMSWArtProvider::DrawMinimisedPanelCommon(
2017 const wxRect
& true_rect
,
2018 wxRect
* preview_rect
)
2020 wxRect
preview(0, 0, 32, 32);
2021 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2023 preview
.x
= true_rect
.x
+ 4;
2024 preview
.y
= true_rect
.y
+ (true_rect
.height
- preview
.height
) / 2;
2028 preview
.x
= true_rect
.x
+ (true_rect
.width
- preview
.width
) / 2;
2029 preview
.y
= true_rect
.y
+ 4;
2032 *preview_rect
= preview
;
2034 wxCoord label_width
, label_height
;
2035 dc
.SetFont(m_panel_label_font
);
2036 dc
.GetTextExtent(wnd
->GetLabel(), &label_width
, &label_height
);
2038 int xpos
= true_rect
.x
+ (true_rect
.width
- label_width
+ 1) / 2;
2039 int ypos
= preview
.y
+ preview
.height
+ 5;
2041 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2043 xpos
= preview
.x
+ preview
.width
+ 5;
2044 ypos
= true_rect
.y
+ (true_rect
.height
- label_height
) / 2;
2047 dc
.SetTextForeground(m_panel_minimised_label_colour
);
2048 dc
.DrawText(wnd
->GetLabel(), xpos
, ypos
);
2051 wxPoint arrow_points
[3];
2052 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2054 xpos
+= label_width
;
2055 arrow_points
[0] = wxPoint(xpos
+ 5, ypos
+ label_height
/ 2);
2056 arrow_points
[1] = arrow_points
[0] + wxPoint(-3, 3);
2057 arrow_points
[2] = arrow_points
[0] + wxPoint(-3, -3);
2061 ypos
+= label_height
;
2062 arrow_points
[0] = wxPoint(true_rect
.width
/ 2, ypos
+ 5);
2063 arrow_points
[1] = arrow_points
[0] + wxPoint(-3, -3);
2064 arrow_points
[2] = arrow_points
[0] + wxPoint( 3, -3);
2067 dc
.SetPen(*wxTRANSPARENT_PEN
);
2068 wxBrush
B(m_panel_minimised_label_colour
);
2070 dc
.DrawPolygon(sizeof(arrow_points
)/sizeof(wxPoint
), arrow_points
,
2071 true_rect
.x
, true_rect
.y
);
2074 void wxRibbonMSWArtProvider::DrawButtonBarBackground(
2079 DrawPartialPageBackground(dc
, wnd
, rect
, true);
2082 void wxRibbonMSWArtProvider::DrawPartialPageBackground(
2088 // Assume the window is a child of a ribbon page, and also check for a
2089 // hovered panel somewhere between the window and the page, as it causes
2090 // the background to change.
2091 wxPoint
offset(wnd
->GetPosition());
2092 wxRibbonPage
* page
= NULL
;
2093 wxWindow
* parent
= wnd
->GetParent();
2094 wxRibbonPanel
* panel
= wxDynamicCast(wnd
, wxRibbonPanel
);
2095 bool hovered
= false;
2099 hovered
= allow_hovered
&& panel
->IsHovered();
2100 if(panel
->GetExpandedDummy() != NULL
)
2102 offset
= panel
->GetExpandedDummy()->GetPosition();
2103 parent
= panel
->GetExpandedDummy()->GetParent();
2106 for(; parent
; parent
= parent
->GetParent())
2110 panel
= wxDynamicCast(parent
, wxRibbonPanel
);
2113 hovered
= allow_hovered
&& panel
->IsHovered();
2114 if(panel
->GetExpandedDummy() != NULL
)
2116 parent
= panel
->GetExpandedDummy();
2120 page
= wxDynamicCast(parent
, wxRibbonPage
);
2125 offset
+= parent
->GetPosition();
2129 DrawPartialPageBackground(dc
, wnd
, rect
, page
, offset
, hovered
);
2133 // No page found - fallback to painting with a stock brush
2134 dc
.SetBrush(*wxWHITE_BRUSH
);
2135 dc
.SetPen(*wxTRANSPARENT_PEN
);
2136 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
2139 void wxRibbonMSWArtProvider::DrawButtonBarButton(
2141 wxWindow
* WXUNUSED(wnd
),
2143 wxRibbonButtonKind kind
,
2145 const wxString
& label
,
2146 const wxBitmap
& bitmap_large
,
2147 const wxBitmap
& bitmap_small
)
2149 if(kind
== wxRIBBON_BUTTON_TOGGLE
)
2151 kind
= wxRIBBON_BUTTON_NORMAL
;
2152 if(state
& wxRIBBON_BUTTONBAR_BUTTON_TOGGLED
)
2153 state
^= wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK
;
2156 if(state
& (wxRIBBON_BUTTONBAR_BUTTON_HOVER_MASK
|
2157 wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK
))
2159 if(state
& wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK
)
2160 dc
.SetPen(m_button_bar_active_border_pen
);
2162 dc
.SetPen(m_button_bar_hover_border_pen
);
2164 wxRect
bg_rect(rect
);
2168 bg_rect
.height
-= 2;
2170 wxRect
bg_rect_top(bg_rect
);
2171 bg_rect_top
.height
/= 3;
2172 bg_rect
.y
+= bg_rect_top
.height
;
2173 bg_rect
.height
-= bg_rect_top
.height
;
2175 if(kind
== wxRIBBON_BUTTON_HYBRID
)
2177 switch(state
& wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK
)
2179 case wxRIBBON_BUTTONBAR_BUTTON_LARGE
:
2181 int iYBorder
= rect
.y
+ bitmap_large
.GetHeight() + 4;
2182 wxRect
partial_bg(rect
);
2183 if(state
& wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED
)
2185 partial_bg
.SetBottom(iYBorder
- 1);
2189 partial_bg
.height
-= (iYBorder
- partial_bg
.y
+ 1);
2190 partial_bg
.y
= iYBorder
+ 1;
2192 dc
.DrawLine(rect
.x
, iYBorder
, rect
.x
+ rect
.width
, iYBorder
);
2193 bg_rect
.Intersect(partial_bg
);
2194 bg_rect_top
.Intersect(partial_bg
);
2197 case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM
:
2199 int iArrowWidth
= 9;
2200 if(state
& wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED
)
2202 bg_rect
.width
-= iArrowWidth
;
2203 bg_rect_top
.width
-= iArrowWidth
;
2204 dc
.DrawLine(bg_rect_top
.x
+ bg_rect_top
.width
,
2205 rect
.y
, bg_rect_top
.x
+ bg_rect_top
.width
,
2206 rect
.y
+ rect
.height
);
2211 bg_rect
.x
+= bg_rect
.width
- iArrowWidth
;
2212 bg_rect_top
.x
+= bg_rect_top
.width
- iArrowWidth
;
2213 bg_rect
.width
= iArrowWidth
;
2214 bg_rect_top
.width
= iArrowWidth
;
2215 dc
.DrawLine(bg_rect_top
.x
- 1, rect
.y
,
2216 bg_rect_top
.x
- 1, rect
.y
+ rect
.height
);
2220 case wxRIBBON_BUTTONBAR_BUTTON_SMALL
:
2225 if(state
& wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK
)
2227 dc
.GradientFillLinear(bg_rect_top
,
2228 m_button_bar_active_background_top_colour
,
2229 m_button_bar_active_background_top_gradient_colour
, wxSOUTH
);
2230 dc
.GradientFillLinear(bg_rect
,
2231 m_button_bar_active_background_colour
,
2232 m_button_bar_active_background_gradient_colour
, wxSOUTH
);
2236 dc
.GradientFillLinear(bg_rect_top
,
2237 m_button_bar_hover_background_top_colour
,
2238 m_button_bar_hover_background_top_gradient_colour
, wxSOUTH
);
2239 dc
.GradientFillLinear(bg_rect
,
2240 m_button_bar_hover_background_colour
,
2241 m_button_bar_hover_background_gradient_colour
, wxSOUTH
);
2244 wxPoint border_points
[9];
2245 border_points
[0] = wxPoint(2, 0);
2246 border_points
[1] = wxPoint(rect
.width
- 3, 0);
2247 border_points
[2] = wxPoint(rect
.width
- 1, 2);
2248 border_points
[3] = wxPoint(rect
.width
- 1, rect
.height
- 3);
2249 border_points
[4] = wxPoint(rect
.width
- 3, rect
.height
- 1);
2250 border_points
[5] = wxPoint(2, rect
.height
- 1);
2251 border_points
[6] = wxPoint(0, rect
.height
- 3);
2252 border_points
[7] = wxPoint(0, 2);
2253 border_points
[8] = border_points
[0];
2255 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
,
2259 dc
.SetFont(m_button_bar_label_font
);
2260 dc
.SetTextForeground(m_button_bar_label_colour
);
2261 DrawButtonBarButtonForeground(dc
, rect
, kind
, state
, label
, bitmap_large
,
2265 void wxRibbonMSWArtProvider::DrawButtonBarButtonForeground(
2268 wxRibbonButtonKind kind
,
2270 const wxString
& label
,
2271 const wxBitmap
& bitmap_large
,
2272 const wxBitmap
& bitmap_small
)
2274 switch(state
& wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK
)
2276 case wxRIBBON_BUTTONBAR_BUTTON_LARGE
:
2278 const int padding
= 2;
2279 dc
.DrawBitmap(bitmap_large
,
2280 rect
.x
+ (rect
.width
- bitmap_large
.GetWidth()) / 2,
2281 rect
.y
+ padding
, true);
2282 int ypos
= rect
.y
+ padding
+ bitmap_large
.GetHeight() + padding
;
2283 int arrow_width
= kind
== wxRIBBON_BUTTON_NORMAL
? 0 : 8;
2284 wxCoord label_w
, label_h
;
2285 dc
.GetTextExtent(label
, &label_w
, &label_h
);
2286 if(label_w
+ 2 * padding
<= rect
.width
)
2288 dc
.DrawText(label
, rect
.x
+ (rect
.width
- label_w
) / 2, ypos
);
2289 if(arrow_width
!= 0)
2291 DrawDropdownArrow(dc
, rect
.x
+ rect
.width
/ 2,
2292 ypos
+ (label_h
* 3) / 2,
2293 m_button_bar_label_colour
);
2298 size_t breaki
= label
.Len();
2302 if(wxRibbonCanLabelBreakAtPosition(label
, breaki
))
2304 wxString label_top
= label
.Mid(0, breaki
);
2305 dc
.GetTextExtent(label_top
, &label_w
, &label_h
);
2306 if(label_w
+ 2 * padding
<= rect
.width
)
2308 dc
.DrawText(label_top
,
2309 rect
.x
+ (rect
.width
- label_w
) / 2, ypos
);
2311 wxString label_bottom
= label
.Mid(breaki
+ 1);
2312 dc
.GetTextExtent(label_bottom
, &label_w
, &label_h
);
2313 label_w
+= arrow_width
;
2314 int iX
= rect
.x
+ (rect
.width
- label_w
) / 2;
2315 dc
.DrawText(label_bottom
, iX
, ypos
);
2316 if(arrow_width
!= 0)
2318 DrawDropdownArrow(dc
,
2319 iX
+ 2 +label_w
- arrow_width
,
2320 ypos
+ label_h
/ 2 + 1,
2321 m_button_bar_label_colour
);
2326 } while(breaki
> 0);
2330 case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM
:
2332 int x_cursor
= rect
.x
+ 2;
2333 dc
.DrawBitmap(bitmap_small
, x_cursor
,
2334 rect
.y
+ (rect
.height
- bitmap_small
.GetHeight())/2, true);
2335 x_cursor
+= bitmap_small
.GetWidth() + 2;
2336 wxCoord label_w
, label_h
;
2337 dc
.GetTextExtent(label
, &label_w
, &label_h
);
2338 dc
.DrawText(label
, x_cursor
,
2339 rect
.y
+ (rect
.height
- label_h
) / 2);
2340 x_cursor
+= label_w
+ 3;
2341 if(kind
!= wxRIBBON_BUTTON_NORMAL
)
2343 DrawDropdownArrow(dc
, x_cursor
, rect
.y
+ rect
.height
/ 2,
2344 m_button_bar_label_colour
);
2354 void wxRibbonMSWArtProvider::DrawToolBarBackground(
2359 DrawPartialPageBackground(dc
, wnd
, rect
);
2362 void wxRibbonMSWArtProvider::DrawToolGroupBackground(
2364 wxWindow
* WXUNUSED(wnd
),
2367 dc
.SetPen(m_toolbar_border_pen
);
2369 outline
[0] = wxPoint(2, 0);
2370 outline
[1] = wxPoint(rect
.width
- 3, 0);
2371 outline
[2] = wxPoint(rect
.width
- 1, 2);
2372 outline
[3] = wxPoint(rect
.width
- 1, rect
.height
- 3);
2373 outline
[4] = wxPoint(rect
.width
- 3, rect
.height
- 1);
2374 outline
[5] = wxPoint(2, rect
.height
- 1);
2375 outline
[6] = wxPoint(0, rect
.height
- 3);
2376 outline
[7] = wxPoint(0, 2);
2377 outline
[8] = outline
[0];
2379 dc
.DrawLines(sizeof(outline
)/sizeof(wxPoint
), outline
, rect
.x
, rect
.y
);
2382 void wxRibbonMSWArtProvider::DrawTool(
2384 wxWindow
* WXUNUSED(wnd
),
2386 const wxBitmap
& bitmap
,
2387 wxRibbonButtonKind kind
,
2390 if(kind
== wxRIBBON_BUTTON_TOGGLE
)
2392 if(state
& wxRIBBON_TOOLBAR_TOOL_TOGGLED
)
2393 state
^= wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK
;
2396 wxRect
bg_rect(rect
);
2398 if((state
& wxRIBBON_TOOLBAR_TOOL_LAST
) == 0)
2400 bool is_split_hybrid
= (kind
== wxRIBBON_BUTTON_HYBRID
&& (state
&
2401 (wxRIBBON_TOOLBAR_TOOL_HOVER_MASK
| wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK
)));
2404 wxRect
bg_rect_top(bg_rect
);
2405 bg_rect_top
.height
= (bg_rect_top
.height
* 2) / 5;
2406 wxRect
bg_rect_btm(bg_rect
);
2407 bg_rect_btm
.y
+= bg_rect_top
.height
;
2408 bg_rect_btm
.height
-= bg_rect_top
.height
;
2409 wxColour bg_top_colour
= m_tool_background_top_colour
;
2410 wxColour bg_top_grad_colour
= m_tool_background_top_gradient_colour
;
2411 wxColour bg_colour
= m_tool_background_colour
;
2412 wxColour bg_grad_colour
= m_tool_background_gradient_colour
;
2413 if(state
& wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK
)
2415 bg_top_colour
= m_tool_active_background_top_colour
;
2416 bg_top_grad_colour
= m_tool_active_background_top_gradient_colour
;
2417 bg_colour
= m_tool_active_background_colour
;
2418 bg_grad_colour
= m_tool_active_background_gradient_colour
;
2420 else if(state
& wxRIBBON_TOOLBAR_TOOL_HOVER_MASK
)
2422 bg_top_colour
= m_tool_hover_background_top_colour
;
2423 bg_top_grad_colour
= m_tool_hover_background_top_gradient_colour
;
2424 bg_colour
= m_tool_hover_background_colour
;
2425 bg_grad_colour
= m_tool_hover_background_gradient_colour
;
2427 dc
.GradientFillLinear(bg_rect_top
, bg_top_colour
, bg_top_grad_colour
, wxSOUTH
);
2428 dc
.GradientFillLinear(bg_rect_btm
, bg_colour
, bg_grad_colour
, wxSOUTH
);
2431 wxRect
nonrect(bg_rect
);
2432 if(state
& (wxRIBBON_TOOLBAR_TOOL_DROPDOWN_HOVERED
|
2433 wxRIBBON_TOOLBAR_TOOL_DROPDOWN_ACTIVE
))
2439 nonrect
.x
+= nonrect
.width
- 8;
2442 wxBrush
B(m_tool_hover_background_top_colour
);
2443 dc
.SetPen(*wxTRANSPARENT_PEN
);
2445 dc
.DrawRectangle(nonrect
.x
, nonrect
.y
, nonrect
.width
, nonrect
.height
);
2449 dc
.SetPen(m_toolbar_border_pen
);
2450 if(state
& wxRIBBON_TOOLBAR_TOOL_FIRST
)
2452 dc
.DrawPoint(rect
.x
+ 1, rect
.y
+ 1);
2453 dc
.DrawPoint(rect
.x
+ 1, rect
.y
+ rect
.height
- 2);
2456 dc
.DrawLine(rect
.x
, rect
.y
+ 1, rect
.x
, rect
.y
+ rect
.height
- 1);
2458 if(state
& wxRIBBON_TOOLBAR_TOOL_LAST
)
2460 dc
.DrawPoint(rect
.x
+ rect
.width
- 2, rect
.y
+ 1);
2461 dc
.DrawPoint(rect
.x
+ rect
.width
- 2, rect
.y
+ rect
.height
- 2);
2465 int avail_width
= bg_rect
.GetWidth();
2466 if(kind
& wxRIBBON_BUTTON_DROPDOWN
)
2471 dc
.DrawLine(rect
.x
+ avail_width
+ 1, rect
.y
,
2472 rect
.x
+ avail_width
+ 1, rect
.y
+ rect
.height
);
2474 dc
.DrawBitmap(m_toolbar_drop_bitmap
, bg_rect
.x
+ avail_width
+ 2,
2475 bg_rect
.y
+ (bg_rect
.height
/ 2) - 2, true);
2477 dc
.DrawBitmap(bitmap
, bg_rect
.x
+ (avail_width
- bitmap
.GetWidth()) / 2,
2478 bg_rect
.y
+ (bg_rect
.height
- bitmap
.GetHeight()) / 2, true);
2482 wxRibbonMSWArtProvider::DrawToggleButton(wxDC
& dc
,
2487 DrawPartialPageBackground(dc
, wnd
, rect
, false);
2489 dc
.DestroyClippingRegion();
2490 dc
.SetClippingRegion(rect
);
2492 if(wnd
->IsToggleButtonHovered())
2494 dc
.SetPen(m_ribbon_toggle_pen
);
2495 dc
.SetBrush(m_ribbon_toggle_brush
);
2496 dc
.DrawRoundedRectangle(rect
.GetX(), rect
.GetY(), 12, 12, 1.0);
2498 dc
.DrawBitmap(m_ribbon_toggle_up_bitmap
[1], rect
.GetX()+2, rect
.GetY()+2, true);
2500 dc
.DrawBitmap(m_ribbon_toggle_down_bitmap
[1], rect
.GetX()+2, rect
.GetY()+2, true);
2505 dc
.DrawBitmap(m_ribbon_toggle_up_bitmap
[0], rect
.GetX()+2, rect
.GetY()+2, true);
2507 dc
.DrawBitmap(m_ribbon_toggle_down_bitmap
[0], rect
.GetX()+2, rect
.GetY()+2, true);
2511 void wxRibbonMSWArtProvider::GetBarTabWidth(
2513 wxWindow
* WXUNUSED(wnd
),
2514 const wxString
& label
,
2515 const wxBitmap
& bitmap
,
2517 int* small_begin_need_separator
,
2518 int* small_must_have_separator
,
2523 if((m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
) && !label
.IsEmpty())
2525 dc
.SetFont(m_tab_label_font
);
2526 width
+= dc
.GetTextExtent(label
).GetWidth();
2527 min
+= wxMin(25, width
); // enough for a few chars
2530 // gap between label and bitmap
2535 if((m_flags
& wxRIBBON_BAR_SHOW_PAGE_ICONS
) && bitmap
.IsOk())
2537 width
+= bitmap
.GetWidth();
2538 min
+= bitmap
.GetWidth();
2543 *ideal
= width
+ 30;
2545 if(small_begin_need_separator
!= NULL
)
2547 *small_begin_need_separator
= width
+ 20;
2549 if(small_must_have_separator
!= NULL
)
2551 *small_must_have_separator
= width
+ 10;
2559 int wxRibbonMSWArtProvider::GetTabCtrlHeight(
2561 wxWindow
* WXUNUSED(wnd
),
2562 const wxRibbonPageTabInfoArray
& pages
)
2564 int text_height
= 0;
2565 int icon_height
= 0;
2567 if(pages
.GetCount() <= 1 && (m_flags
& wxRIBBON_BAR_ALWAYS_SHOW_TABS
) == 0)
2569 // To preserve space, a single tab need not be displayed. We still need
2570 // two pixels of border / padding though.
2574 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
)
2576 dc
.SetFont(m_tab_label_font
);
2577 text_height
= dc
.GetTextExtent(wxT("ABCDEFXj")).GetHeight() + 10;
2579 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_ICONS
)
2581 size_t numpages
= pages
.GetCount();
2582 for(size_t i
= 0; i
< numpages
; ++i
)
2584 const wxRibbonPageTabInfo
& info
= pages
.Item(i
);
2585 if(info
.page
->GetIcon().IsOk())
2587 icon_height
= wxMax(icon_height
, info
.page
->GetIcon().GetHeight() + 4);
2592 return wxMax(text_height
, icon_height
);
2595 wxSize
wxRibbonMSWArtProvider::GetScrollButtonMinimumSize(
2597 wxWindow
* WXUNUSED(wnd
),
2598 long WXUNUSED(style
))
2600 return wxSize(12, 12);
2603 wxSize
wxRibbonMSWArtProvider::GetPanelSize(
2605 const wxRibbonPanel
* wnd
,
2607 wxPoint
* client_offset
)
2609 dc
.SetFont(m_panel_label_font
);
2610 wxSize label_size
= dc
.GetTextExtent(wnd
->GetLabel());
2612 client_size
.IncBy(0, label_size
.GetHeight());
2613 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2614 client_size
.IncBy(4, 8);
2616 client_size
.IncBy(6, 6);
2618 if(client_offset
!= NULL
)
2620 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2621 *client_offset
= wxPoint(2, 3);
2623 *client_offset
= wxPoint(3, 2);
2629 wxSize
wxRibbonMSWArtProvider::GetPanelClientSize(
2631 const wxRibbonPanel
* wnd
,
2633 wxPoint
* client_offset
)
2635 dc
.SetFont(m_panel_label_font
);
2636 wxSize label_size
= dc
.GetTextExtent(wnd
->GetLabel());
2638 size
.DecBy(0, label_size
.GetHeight());
2639 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2644 if(client_offset
!= NULL
)
2646 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2647 *client_offset
= wxPoint(2, 3);
2649 *client_offset
= wxPoint(3, 2);
2651 if (size
.x
< 0) size
.x
= 0;
2652 if (size
.y
< 0) size
.y
= 0;
2657 wxSize
wxRibbonMSWArtProvider::GetGallerySize(
2659 const wxRibbonGallery
* WXUNUSED(wnd
),
2662 client_size
.IncBy( 2, 1); // Left / top padding
2663 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2664 client_size
.IncBy(1, 16); // Right / bottom padding
2666 client_size
.IncBy(16, 1); // Right / bottom padding
2670 wxSize
wxRibbonMSWArtProvider::GetGalleryClientSize(
2672 const wxRibbonGallery
* WXUNUSED(wnd
),
2674 wxPoint
* client_offset
,
2675 wxRect
* scroll_up_button
,
2676 wxRect
* scroll_down_button
,
2677 wxRect
* extension_button
)
2682 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2684 // Flow is vertical - put buttons on bottom
2685 scroll_up
.y
= size
.GetHeight() - 15;
2686 scroll_up
.height
= 15;
2688 scroll_up
.width
= (size
.GetWidth() + 2) / 3;
2689 scroll_down
.y
= scroll_up
.y
;
2690 scroll_down
.height
= scroll_up
.height
;
2691 scroll_down
.x
= scroll_up
.x
+ scroll_up
.width
;
2692 scroll_down
.width
= scroll_up
.width
;
2693 extension
.y
= scroll_down
.y
;
2694 extension
.height
= scroll_down
.height
;
2695 extension
.x
= scroll_down
.x
+ scroll_down
.width
;
2696 extension
.width
= size
.GetWidth() - scroll_up
.width
- scroll_down
.width
;
2702 // Flow is horizontal - put buttons on right
2703 scroll_up
.x
= size
.GetWidth() - 15;
2704 scroll_up
.width
= 15;
2706 scroll_up
.height
= (size
.GetHeight() + 2) / 3;
2707 scroll_down
.x
= scroll_up
.x
;
2708 scroll_down
.width
= scroll_up
.width
;
2709 scroll_down
.y
= scroll_up
.y
+ scroll_up
.height
;
2710 scroll_down
.height
= scroll_up
.height
;
2711 extension
.x
= scroll_down
.x
;
2712 extension
.width
= scroll_down
.width
;
2713 extension
.y
= scroll_down
.y
+ scroll_down
.height
;
2714 extension
.height
= size
.GetHeight() - scroll_up
.height
- scroll_down
.height
;
2719 if(client_offset
!= NULL
)
2720 *client_offset
= wxPoint(2, 1);
2721 if(scroll_up_button
!= NULL
)
2722 *scroll_up_button
= scroll_up
;
2723 if(scroll_down_button
!= NULL
)
2724 *scroll_down_button
= scroll_down
;
2725 if(extension_button
!= NULL
)
2726 *extension_button
= extension
;
2731 wxRect
wxRibbonMSWArtProvider::GetPageBackgroundRedrawArea(
2733 const wxRibbonPage
* WXUNUSED(wnd
),
2734 wxSize page_old_size
,
2735 wxSize page_new_size
)
2737 wxRect new_rect
, old_rect
;
2739 if(page_new_size
.GetWidth() != page_old_size
.GetWidth())
2741 if(page_new_size
.GetHeight() != page_old_size
.GetHeight())
2743 // Width and height both changed - redraw everything
2744 return wxRect(page_new_size
);
2748 // Only width changed - redraw right hand side
2749 const int right_edge_width
= 4;
2751 new_rect
= wxRect(page_new_size
.GetWidth() - right_edge_width
, 0, right_edge_width
, page_new_size
.GetHeight());
2752 old_rect
= wxRect(page_old_size
.GetWidth() - right_edge_width
, 0, right_edge_width
, page_old_size
.GetHeight());
2757 if(page_new_size
.GetHeight() == page_old_size
.GetHeight())
2759 // Nothing changed (should never happen) - redraw nothing
2760 return wxRect(0, 0, 0, 0);
2764 // Height changed - need to redraw everything (as the background
2765 // gradient is done vertically).
2766 return page_new_size
;
2770 new_rect
.Union(old_rect
);
2771 new_rect
.Intersect(wxRect(page_new_size
));
2775 bool wxRibbonMSWArtProvider::GetButtonBarButtonSize(
2778 wxRibbonButtonKind kind
,
2779 wxRibbonButtonBarButtonState size
,
2780 const wxString
& label
,
2781 wxSize bitmap_size_large
,
2782 wxSize bitmap_size_small
,
2783 wxSize
* button_size
,
2784 wxRect
* normal_region
,
2785 wxRect
* dropdown_region
)
2787 const int drop_button_width
= 8;
2789 dc
.SetFont(m_button_bar_label_font
);
2790 switch(size
& wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK
)
2792 case wxRIBBON_BUTTONBAR_BUTTON_SMALL
:
2793 // Small bitmap, no label
2794 *button_size
= bitmap_size_small
+ wxSize(6, 4);
2797 case wxRIBBON_BUTTON_NORMAL
:
2798 case wxRIBBON_BUTTON_TOGGLE
:
2799 *normal_region
= wxRect(*button_size
);
2800 *dropdown_region
= wxRect(0, 0, 0, 0);
2802 case wxRIBBON_BUTTON_DROPDOWN
:
2803 *button_size
+= wxSize(drop_button_width
, 0);
2804 *dropdown_region
= wxRect(*button_size
);
2805 *normal_region
= wxRect(0, 0, 0, 0);
2807 case wxRIBBON_BUTTON_HYBRID
:
2808 *normal_region
= wxRect(*button_size
);
2809 *dropdown_region
= wxRect(button_size
->GetWidth(), 0,
2810 drop_button_width
, button_size
->GetHeight());
2811 *button_size
+= wxSize(drop_button_width
, 0);
2815 case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM
:
2816 // Small bitmap, with label to the right
2818 GetButtonBarButtonSize(dc
, wnd
, kind
, wxRIBBON_BUTTONBAR_BUTTON_SMALL
,
2819 label
, bitmap_size_large
, bitmap_size_small
, button_size
,
2820 normal_region
, dropdown_region
);
2821 int text_size
= dc
.GetTextExtent(label
).GetWidth();
2822 button_size
->SetWidth(button_size
->GetWidth() + text_size
);
2825 case wxRIBBON_BUTTON_DROPDOWN
:
2826 dropdown_region
->SetWidth(dropdown_region
->GetWidth() + text_size
);
2828 case wxRIBBON_BUTTON_HYBRID
:
2829 dropdown_region
->SetX(dropdown_region
->GetX() + text_size
);
2831 case wxRIBBON_BUTTON_NORMAL
:
2832 case wxRIBBON_BUTTON_TOGGLE
:
2833 normal_region
->SetWidth(normal_region
->GetWidth() + text_size
);
2838 case wxRIBBON_BUTTONBAR_BUTTON_LARGE
:
2839 // Large bitmap, with label below (possibly split over 2 lines)
2841 wxSize
icon_size(bitmap_size_large
);
2842 icon_size
+= wxSize(4, 4);
2843 wxCoord label_height
;
2845 dc
.GetTextExtent(label
, &best_width
, &label_height
);
2846 int last_line_extra_width
= 0;
2847 if(kind
!= wxRIBBON_BUTTON_NORMAL
&& kind
!= wxRIBBON_BUTTON_TOGGLE
)
2849 last_line_extra_width
+= 8;
2852 for(i
= 0; i
< label
.Len(); ++i
)
2854 if(wxRibbonCanLabelBreakAtPosition(label
, i
))
2857 dc
.GetTextExtent(label
.Mid(0, i
- 1)).GetWidth(),
2858 dc
.GetTextExtent(label
.Mid(i
+ 1)).GetWidth() + last_line_extra_width
);
2859 if(width
< best_width
)
2865 label_height
*= 2; // Assume two lines even when only one is used
2866 // (to give all buttons a consistent height)
2867 icon_size
.SetWidth(wxMax(icon_size
.GetWidth(), best_width
) + 6);
2868 icon_size
.SetHeight(icon_size
.GetHeight() + label_height
);
2869 *button_size
= icon_size
;
2872 case wxRIBBON_BUTTON_DROPDOWN
:
2873 *dropdown_region
= wxRect(icon_size
);
2875 case wxRIBBON_BUTTON_HYBRID
:
2876 *normal_region
= wxRect(icon_size
);
2877 normal_region
->height
-= 2 + label_height
;
2878 dropdown_region
->x
= 0;
2879 dropdown_region
->y
= normal_region
->height
;
2880 dropdown_region
->width
= icon_size
.GetWidth();
2881 dropdown_region
->height
= icon_size
.GetHeight() - normal_region
->height
;
2883 case wxRIBBON_BUTTON_NORMAL
:
2884 case wxRIBBON_BUTTON_TOGGLE
:
2885 *normal_region
= wxRect(icon_size
);
2894 wxSize
wxRibbonMSWArtProvider::GetMinimisedPanelMinimumSize(
2896 const wxRibbonPanel
* wnd
,
2897 wxSize
* desired_bitmap_size
,
2898 wxDirection
* expanded_panel_direction
)
2900 if(desired_bitmap_size
!= NULL
)
2902 *desired_bitmap_size
= wxSize(16, 16);
2904 if(expanded_panel_direction
!= NULL
)
2906 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2907 *expanded_panel_direction
= wxEAST
;
2909 *expanded_panel_direction
= wxSOUTH
;
2911 wxSize
base_size(42, 42);
2913 dc
.SetFont(m_panel_label_font
);
2914 wxSize
label_size(dc
.GetTextExtent(wnd
->GetLabel()));
2915 label_size
.IncBy(2, 2); // Allow for differences between this DC and a paint DC
2916 label_size
.IncBy(6, 0); // Padding
2917 label_size
.y
*= 2; // Second line for dropdown button
2919 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2921 // Label alongside icon
2922 return wxSize(base_size
.x
+ label_size
.x
,
2923 wxMax(base_size
.y
, label_size
.y
));
2927 // Label beneath icon
2928 return wxSize(wxMax(base_size
.x
, label_size
.x
),
2929 base_size
.y
+ label_size
.y
);
2933 wxSize
wxRibbonMSWArtProvider::GetToolSize(
2935 wxWindow
* WXUNUSED(wnd
),
2937 wxRibbonButtonKind kind
,
2938 bool WXUNUSED(is_first
),
2940 wxRect
* dropdown_region
)
2942 wxSize
size(bitmap_size
);
2946 if(kind
& wxRIBBON_BUTTON_DROPDOWN
)
2951 if(kind
== wxRIBBON_BUTTON_DROPDOWN
)
2952 *dropdown_region
= size
;
2954 *dropdown_region
= wxRect(size
.GetWidth() - 8, 0, 8, size
.GetHeight());
2960 *dropdown_region
= wxRect(0, 0, 0, 0);
2966 wxRibbonMSWArtProvider::GetBarToggleButtonArea(wxDC
& WXUNUSED(dc
),
2967 const wxRibbonBar
* WXUNUSED(wnd
),
2970 rect
= wxRect(rect
.GetWidth()-30, 6, 12, 12);
2974 #endif // wxUSE_RIBBON