1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/ribbon/art_msw.cpp
3 // Purpose: MSW style art provider for ribbon interface
4 // Author: Peter Cawley
8 // Copyright: (C) Peter Cawley
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
20 #include "wx/ribbon/art.h"
21 #include "wx/ribbon/art_internal.h"
22 #include "wx/ribbon/bar.h"
23 #include "wx/ribbon/buttonbar.h"
24 #include "wx/ribbon/gallery.h"
25 #include "wx/ribbon/toolbar.h"
28 #include "wx/dcmemory.h"
32 #include "wx/msw/private.h"
35 static const char* const gallery_up_xpm
[] = {
45 static const char* const gallery_down_xpm
[] = {
55 static const char* const gallery_left_xpm
[] = {
65 static const char* const gallery_right_xpm
[] = {
75 static const char* const gallery_extension_xpm
[] = {
85 static const char* const panel_extension_xpm
[] = {
97 wxRibbonMSWArtProvider::wxRibbonMSWArtProvider(bool set_colour_scheme
)
100 m_tab_label_font
= *wxNORMAL_FONT
;
101 m_button_bar_label_font
= m_tab_label_font
;
102 m_panel_label_font
= m_tab_label_font
;
104 if(set_colour_scheme
)
107 wxColour(194, 216, 241),
108 wxColour(255, 223, 114),
112 m_cached_tab_separator_visibility
= -10.0; // valid visibilities are in range [0, 1]
113 m_tab_separation_size
= 3;
114 m_page_border_left
= 2;
115 m_page_border_top
= 1;
116 m_page_border_right
= 2;
117 m_page_border_bottom
= 3;
118 m_panel_x_separation_size
= 1;
119 m_panel_y_separation_size
= 1;
120 m_tool_group_separation_size
= 3;
121 m_gallery_bitmap_padding_left_size
= 4;
122 m_gallery_bitmap_padding_right_size
= 4;
123 m_gallery_bitmap_padding_top_size
= 4;
124 m_gallery_bitmap_padding_bottom_size
= 4;
127 wxRibbonMSWArtProvider::~wxRibbonMSWArtProvider()
131 void wxRibbonMSWArtProvider::GetColourScheme(
134 wxColour
* tertiary
) const
137 *primary
= m_primary_scheme_colour
;
138 if(secondary
!= NULL
)
139 *secondary
= m_secondary_scheme_colour
;
141 *tertiary
= m_tertiary_scheme_colour
;
144 void wxRibbonMSWArtProvider::SetColourScheme(
145 const wxColour
& primary
,
146 const wxColour
& secondary
,
147 const wxColour
& tertiary
)
149 m_primary_scheme_colour
= primary
;
150 m_secondary_scheme_colour
= secondary
;
151 m_tertiary_scheme_colour
= tertiary
;
153 wxRibbonHSLColour
primary_hsl(primary
);
154 wxRibbonHSLColour
secondary_hsl(secondary
);
155 // tertiary not used for anything
157 // Map primary saturation from [0, 1] to [.25, .75]
158 bool primary_is_gray
= false;
159 static const double gray_saturation_threshold
= 0.01;
160 if(primary_hsl
.saturation
<= gray_saturation_threshold
)
161 primary_is_gray
= true;
164 primary_hsl
.saturation
= cos(primary_hsl
.saturation
* M_PI
)
168 // Map primary luminance from [0, 1] to [.23, .83]
169 primary_hsl
.luminance
= cos(primary_hsl
.luminance
* M_PI
) * -0.3 + 0.53;
171 // Map secondary saturation from [0, 1] to [0.16, 0.84]
172 bool secondary_is_gray
= false;
173 if(secondary_hsl
.saturation
<= gray_saturation_threshold
)
174 secondary_is_gray
= true;
177 secondary_hsl
.saturation
= cos(secondary_hsl
.saturation
* M_PI
)
181 // Map secondary luminance from [0, 1] to [0.1, 0.9]
182 secondary_hsl
.luminance
= cos(secondary_hsl
.luminance
* M_PI
) * -0.4 + 0.5;
184 #define LikePrimary(h, s, l) \
185 primary_hsl.ShiftHue(h ## f).Saturated(primary_is_gray ? 0 : s ## f) \
186 .Lighter(l ## f).ToRGB()
187 #define LikeSecondary(h, s, l) \
188 secondary_hsl.ShiftHue(h ## f).Saturated(secondary_is_gray ? 0 : s ## f) \
189 .Lighter(l ## f).ToRGB()
191 m_page_border_pen
= LikePrimary(1.4, 0.00, -0.08);
193 m_page_background_top_colour
= LikePrimary(-0.1, -0.03, 0.12);
194 m_page_hover_background_top_colour
= LikePrimary(-2.8, 0.27, 0.17);
195 m_page_background_top_gradient_colour
= LikePrimary(0.1, -0.10, 0.08);
196 m_page_hover_background_top_gradient_colour
= LikePrimary(3.2, 0.16, 0.13);
197 m_page_background_colour
= LikePrimary(0.4, -0.09, 0.05);
198 m_page_hover_background_colour
= LikePrimary(0.1, 0.19, 0.10);
199 m_page_background_gradient_colour
= LikePrimary(-3.2, 0.27, 0.10);
200 m_page_hover_background_gradient_colour
= LikePrimary(1.8, 0.01, 0.15);
202 m_tab_active_background_colour
= LikePrimary(-0.1, -0.31, 0.16);
203 m_tab_active_background_gradient_colour
= LikePrimary(-0.1, -0.03, 0.12);
204 m_tab_separator_colour
= LikePrimary(0.9, 0.24, 0.05);
205 m_tab_ctrl_background_brush
= LikePrimary(1.0, 0.39, 0.07);
206 m_tab_hover_background_colour
= LikePrimary(1.3, 0.15, 0.10);
207 m_tab_hover_background_top_colour
= LikePrimary(1.4, 0.36, 0.08);
208 m_tab_border_pen
= LikePrimary(1.4, 0.03, -0.05);
209 m_tab_separator_gradient_colour
= LikePrimary(1.7, -0.15, -0.18);
210 m_tab_hover_background_top_gradient_colour
= LikePrimary(1.8, 0.34, 0.13);
211 m_tab_label_colour
= LikePrimary(4.3, 0.13, -0.49);
212 m_tab_hover_background_gradient_colour
= LikeSecondary(-1.5, -0.34, 0.01);
214 m_panel_minimised_border_gradient_pen
= LikePrimary(-6.9, -0.17, -0.09);
215 m_panel_minimised_border_pen
= LikePrimary(-5.3, -0.24, -0.06);
216 m_panel_border_gradient_pen
= LikePrimary(-5.2, -0.15, -0.06);
217 m_panel_border_pen
= LikePrimary(-2.8, -0.32, 0.02);
218 m_panel_label_background_brush
= LikePrimary(-1.5, 0.03, 0.05);
219 m_panel_active_background_gradient_colour
= LikePrimary(0.5, 0.34, 0.05);
220 m_panel_hover_label_background_brush
= LikePrimary(1.0, 0.30, 0.09);
221 m_panel_active_background_top_gradient_colour
= LikePrimary(1.4, -0.17, -0.13);
222 m_panel_active_background_colour
= LikePrimary(1.6, -0.18, -0.18);
223 m_panel_active_background_top_colour
= LikePrimary(1.7, -0.20, -0.03);
224 m_panel_label_colour
= LikePrimary(2.8, -0.14, -0.35);
225 m_panel_hover_label_colour
= m_panel_label_colour
;
226 m_panel_minimised_label_colour
= m_tab_label_colour
;
227 m_panel_hover_button_background_brush
= LikeSecondary(-0.9, 0.16, -0.07);
228 m_panel_hover_button_border_pen
= LikeSecondary(-3.9, -0.16, -0.14);
229 SetColour(wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR
, LikePrimary(1.4, -0.21, -0.23));
230 SetColour(wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR
, LikePrimary(1.5, -0.24, -0.29));
232 m_gallery_button_disabled_background_colour
= LikePrimary(-2.8, -0.46, 0.09);
233 m_gallery_button_disabled_background_top_brush
= LikePrimary(-2.8, -0.36, 0.15);
234 m_gallery_hover_background_brush
= LikePrimary(-0.8, 0.05, 0.15);
235 m_gallery_border_pen
= LikePrimary(0.7, -0.02, 0.03);
236 m_gallery_button_background_top_brush
= LikePrimary(0.8, 0.34, 0.13);
237 m_gallery_button_background_colour
= LikePrimary(1.3, 0.10, 0.08);
238 // SetColour used so that the relevant bitmaps are generated
239 SetColour(wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR
, LikePrimary(1.4, -0.21, -0.23));
240 SetColour(wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR
, LikePrimary(1.5, -0.24, -0.29));
241 SetColour(wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR
, LikePrimary(1.5, -0.24, -0.29));
242 SetColour(wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR
, LikePrimary(0.0, -1.0, 0.0));
243 m_gallery_button_disabled_background_gradient_colour
= LikePrimary(1.5, -0.43, 0.12);
244 m_gallery_button_background_gradient_colour
= LikePrimary(1.7, 0.11, 0.09);
245 m_gallery_item_border_pen
= LikeSecondary(-3.9, -0.16, -0.14);
246 m_gallery_button_hover_background_colour
= LikeSecondary(-0.9, 0.16, -0.07);
247 m_gallery_button_hover_background_gradient_colour
= LikeSecondary(0.1, 0.12, 0.03);
248 m_gallery_button_hover_background_top_brush
= LikeSecondary(4.3, 0.16, 0.17);
250 m_gallery_button_active_background_colour
= LikeSecondary(-9.9, 0.03, -0.22);
251 m_gallery_button_active_background_gradient_colour
= LikeSecondary(-9.5, 0.14, -0.11);
252 m_gallery_button_active_background_top_brush
= LikeSecondary(-9.0, 0.15, -0.08);
254 m_button_bar_label_colour
= m_tab_label_colour
;
255 m_button_bar_hover_border_pen
= LikeSecondary(-6.2, -0.47, -0.14);
256 m_button_bar_hover_background_gradient_colour
= LikeSecondary(-0.6, 0.16, 0.04);
257 m_button_bar_hover_background_colour
= LikeSecondary(-0.2, 0.16, -0.10);
258 m_button_bar_hover_background_top_gradient_colour
= LikeSecondary(0.2, 0.16, 0.03);
259 m_button_bar_hover_background_top_colour
= LikeSecondary(8.8, 0.16, 0.17);
260 m_button_bar_active_border_pen
= LikeSecondary(-6.2, -0.47, -0.25);
261 m_button_bar_active_background_top_colour
= LikeSecondary(-8.4, 0.08, 0.06);
262 m_button_bar_active_background_top_gradient_colour
= LikeSecondary(-9.7, 0.13, -0.07);
263 m_button_bar_active_background_colour
= LikeSecondary(-9.9, 0.14, -0.14);
264 m_button_bar_active_background_gradient_colour
= LikeSecondary(-8.7, 0.17, -0.03);
266 m_toolbar_border_pen
= LikePrimary(1.4, -0.21, -0.16);
267 SetColour(wxRIBBON_ART_TOOLBAR_FACE_COLOUR
, LikePrimary(1.4, -0.17, -0.22));
268 m_tool_background_top_colour
= LikePrimary(-1.9, -0.07, 0.06);
269 m_tool_background_top_gradient_colour
= LikePrimary(1.4, 0.12, 0.08);
270 m_tool_background_colour
= LikePrimary(1.4, -0.09, 0.03);
271 m_tool_background_gradient_colour
= LikePrimary(1.9, 0.11, 0.09);
272 m_tool_hover_background_top_colour
= LikeSecondary(3.4, 0.11, 0.16);
273 m_tool_hover_background_top_gradient_colour
= LikeSecondary(-1.4, 0.04, 0.08);
274 m_tool_hover_background_colour
= LikeSecondary(-1.8, 0.16, -0.12);
275 m_tool_hover_background_gradient_colour
= LikeSecondary(-2.6, 0.16, 0.05);
276 m_tool_active_background_top_colour
= LikeSecondary(-9.9, -0.12, -0.09);
277 m_tool_active_background_top_gradient_colour
= LikeSecondary(-8.5, 0.16, -0.12);
278 m_tool_active_background_colour
= LikeSecondary(-7.9, 0.16, -0.20);
279 m_tool_active_background_gradient_colour
= LikeSecondary(-6.6, 0.16, -0.10);
284 // Invalidate cached tab separator
285 m_cached_tab_separator_visibility
= -1.0;
288 wxRibbonArtProvider
* wxRibbonMSWArtProvider::Clone() const
290 wxRibbonMSWArtProvider
*copy
= new wxRibbonMSWArtProvider
;
295 void wxRibbonMSWArtProvider::CloneTo(wxRibbonMSWArtProvider
* copy
) const
297 for(int i
= 0; i
< 4; ++i
)
299 copy
->m_gallery_up_bitmap
[i
] = m_gallery_up_bitmap
[i
];
300 copy
->m_gallery_down_bitmap
[i
] = m_gallery_down_bitmap
[i
];
301 copy
->m_gallery_extension_bitmap
[i
] = m_gallery_extension_bitmap
[i
];
303 for(int i
= 0; i
< 2; ++i
)
305 copy
->m_panel_extension_bitmap
[i
] = m_panel_extension_bitmap
[i
];
307 copy
->m_toolbar_drop_bitmap
= m_toolbar_drop_bitmap
;
309 copy
->m_primary_scheme_colour
= m_primary_scheme_colour
;
310 copy
->m_secondary_scheme_colour
= m_secondary_scheme_colour
;
311 copy
->m_tertiary_scheme_colour
= m_tertiary_scheme_colour
;
313 copy
->m_button_bar_label_colour
= m_button_bar_label_colour
;
314 copy
->m_tab_label_colour
= m_tab_label_colour
;
315 copy
->m_tab_separator_colour
= m_tab_separator_colour
;
316 copy
->m_tab_separator_gradient_colour
= m_tab_separator_gradient_colour
;
317 copy
->m_tab_active_background_colour
= m_tab_hover_background_colour
;
318 copy
->m_tab_active_background_gradient_colour
= m_tab_hover_background_gradient_colour
;
319 copy
->m_tab_hover_background_colour
= m_tab_hover_background_colour
;
320 copy
->m_tab_hover_background_gradient_colour
= m_tab_hover_background_gradient_colour
;
321 copy
->m_tab_hover_background_top_colour
= m_tab_hover_background_top_colour
;
322 copy
->m_tab_hover_background_top_gradient_colour
= m_tab_hover_background_top_gradient_colour
;
323 copy
->m_panel_label_colour
= m_panel_label_colour
;
324 copy
->m_panel_hover_label_colour
= m_panel_hover_label_colour
;
325 copy
->m_panel_minimised_label_colour
= m_panel_minimised_label_colour
;
326 copy
->m_panel_button_face_colour
= m_panel_button_face_colour
;
327 copy
->m_panel_button_hover_face_colour
= m_panel_button_hover_face_colour
;
328 copy
->m_panel_active_background_colour
= m_panel_active_background_colour
;
329 copy
->m_panel_active_background_gradient_colour
= m_panel_active_background_gradient_colour
;
330 copy
->m_panel_active_background_top_colour
= m_panel_active_background_top_colour
;
331 copy
->m_panel_active_background_top_gradient_colour
= m_panel_active_background_top_gradient_colour
;
332 copy
->m_page_background_colour
= m_page_background_colour
;
333 copy
->m_page_background_gradient_colour
= m_page_background_gradient_colour
;
334 copy
->m_page_background_top_colour
= m_page_background_top_colour
;
335 copy
->m_page_background_top_gradient_colour
= m_page_background_top_gradient_colour
;
336 copy
->m_page_hover_background_colour
= m_page_hover_background_colour
;
337 copy
->m_page_hover_background_gradient_colour
= m_page_hover_background_gradient_colour
;
338 copy
->m_page_hover_background_top_colour
= m_page_hover_background_top_colour
;
339 copy
->m_page_hover_background_top_gradient_colour
= m_page_hover_background_top_gradient_colour
;
340 copy
->m_button_bar_hover_background_colour
= m_button_bar_hover_background_colour
;
341 copy
->m_button_bar_hover_background_gradient_colour
= m_button_bar_hover_background_gradient_colour
;
342 copy
->m_button_bar_hover_background_top_colour
= m_button_bar_hover_background_top_colour
;
343 copy
->m_button_bar_hover_background_top_gradient_colour
= m_button_bar_hover_background_top_gradient_colour
;
344 copy
->m_button_bar_active_background_colour
= m_button_bar_active_background_colour
;
345 copy
->m_button_bar_active_background_gradient_colour
= m_button_bar_active_background_gradient_colour
;
346 copy
->m_button_bar_active_background_top_colour
= m_button_bar_active_background_top_colour
;
347 copy
->m_button_bar_active_background_top_gradient_colour
= m_button_bar_active_background_top_gradient_colour
;
348 copy
->m_gallery_button_background_colour
= m_gallery_button_background_colour
;
349 copy
->m_gallery_button_background_gradient_colour
= m_gallery_button_background_gradient_colour
;
350 copy
->m_gallery_button_hover_background_colour
= m_gallery_button_hover_background_colour
;
351 copy
->m_gallery_button_hover_background_gradient_colour
= m_gallery_button_hover_background_gradient_colour
;
352 copy
->m_gallery_button_active_background_colour
= m_gallery_button_active_background_colour
;
353 copy
->m_gallery_button_active_background_gradient_colour
= m_gallery_button_active_background_gradient_colour
;
354 copy
->m_gallery_button_disabled_background_colour
= m_gallery_button_disabled_background_colour
;
355 copy
->m_gallery_button_disabled_background_gradient_colour
= m_gallery_button_disabled_background_gradient_colour
;
356 copy
->m_gallery_button_face_colour
= m_gallery_button_face_colour
;
357 copy
->m_gallery_button_hover_face_colour
= m_gallery_button_hover_face_colour
;
358 copy
->m_gallery_button_active_face_colour
= m_gallery_button_active_face_colour
;
359 copy
->m_gallery_button_disabled_face_colour
= m_gallery_button_disabled_face_colour
;
361 copy
->m_tab_ctrl_background_brush
= m_tab_ctrl_background_brush
;
362 copy
->m_panel_label_background_brush
= m_panel_label_background_brush
;
363 copy
->m_panel_hover_label_background_brush
= m_panel_hover_label_background_brush
;
364 copy
->m_panel_hover_button_background_brush
= m_panel_hover_button_background_brush
;
365 copy
->m_gallery_hover_background_brush
= m_gallery_hover_background_brush
;
366 copy
->m_gallery_button_background_top_brush
= m_gallery_button_background_top_brush
;
367 copy
->m_gallery_button_hover_background_top_brush
= m_gallery_button_hover_background_top_brush
;
368 copy
->m_gallery_button_active_background_top_brush
= m_gallery_button_active_background_top_brush
;
369 copy
->m_gallery_button_disabled_background_top_brush
= m_gallery_button_disabled_background_top_brush
;
371 copy
->m_tab_label_font
= m_tab_label_font
;
372 copy
->m_button_bar_label_font
= m_button_bar_label_font
;
373 copy
->m_panel_label_font
= m_panel_label_font
;
375 copy
->m_page_border_pen
= m_page_border_pen
;
376 copy
->m_panel_border_pen
= m_panel_border_pen
;
377 copy
->m_panel_border_gradient_pen
= m_panel_border_gradient_pen
;
378 copy
->m_panel_minimised_border_pen
= m_panel_minimised_border_pen
;
379 copy
->m_panel_minimised_border_gradient_pen
= m_panel_minimised_border_gradient_pen
;
380 copy
->m_panel_hover_button_border_pen
= m_panel_hover_button_border_pen
;
381 copy
->m_tab_border_pen
= m_tab_border_pen
;
382 copy
->m_gallery_border_pen
= m_gallery_border_pen
;
383 copy
->m_button_bar_hover_border_pen
= m_button_bar_hover_border_pen
;
384 copy
->m_button_bar_active_border_pen
= m_button_bar_active_border_pen
;
385 copy
->m_gallery_item_border_pen
= m_gallery_item_border_pen
;
386 copy
->m_toolbar_border_pen
= m_toolbar_border_pen
;
388 copy
->m_flags
= m_flags
;
389 copy
->m_tab_separation_size
= m_tab_separation_size
;
390 copy
->m_page_border_left
= m_page_border_left
;
391 copy
->m_page_border_top
= m_page_border_top
;
392 copy
->m_page_border_right
= m_page_border_right
;
393 copy
->m_page_border_bottom
= m_page_border_bottom
;
394 copy
->m_panel_x_separation_size
= m_panel_x_separation_size
;
395 copy
->m_panel_y_separation_size
= m_panel_y_separation_size
;
396 copy
->m_gallery_bitmap_padding_left_size
= m_gallery_bitmap_padding_left_size
;
397 copy
->m_gallery_bitmap_padding_right_size
= m_gallery_bitmap_padding_right_size
;
398 copy
->m_gallery_bitmap_padding_top_size
= m_gallery_bitmap_padding_top_size
;
399 copy
->m_gallery_bitmap_padding_bottom_size
= m_gallery_bitmap_padding_bottom_size
;
402 long wxRibbonMSWArtProvider::GetFlags() const
407 void wxRibbonMSWArtProvider::SetFlags(long flags
)
409 if((flags
^ m_flags
) & wxRIBBON_BAR_FLOW_VERTICAL
)
411 if(flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
413 m_page_border_left
++;
414 m_page_border_right
++;
416 m_page_border_bottom
--;
420 m_page_border_left
--;
421 m_page_border_right
--;
423 m_page_border_bottom
++;
428 // Need to reload some bitmaps when flags change
429 #define Reload(setting) SetColour(setting, GetColour(setting))
430 Reload(wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR
);
431 Reload(wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR
);
432 Reload(wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR
);
433 Reload(wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR
);
434 Reload(wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR
);
435 Reload(wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR
);
439 int wxRibbonMSWArtProvider::GetMetric(int id
) const
443 case wxRIBBON_ART_TAB_SEPARATION_SIZE
:
444 return m_tab_separation_size
;
445 case wxRIBBON_ART_PAGE_BORDER_LEFT_SIZE
:
446 return m_page_border_left
;
447 case wxRIBBON_ART_PAGE_BORDER_TOP_SIZE
:
448 return m_page_border_top
;
449 case wxRIBBON_ART_PAGE_BORDER_RIGHT_SIZE
:
450 return m_page_border_right
;
451 case wxRIBBON_ART_PAGE_BORDER_BOTTOM_SIZE
:
452 return m_page_border_bottom
;
453 case wxRIBBON_ART_PANEL_X_SEPARATION_SIZE
:
454 return m_panel_x_separation_size
;
455 case wxRIBBON_ART_PANEL_Y_SEPARATION_SIZE
:
456 return m_panel_y_separation_size
;
457 case wxRIBBON_ART_TOOL_GROUP_SEPARATION_SIZE
:
458 return m_tool_group_separation_size
;
459 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_LEFT_SIZE
:
460 return m_gallery_bitmap_padding_left_size
;
461 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_RIGHT_SIZE
:
462 return m_gallery_bitmap_padding_right_size
;
463 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_TOP_SIZE
:
464 return m_gallery_bitmap_padding_top_size
;
465 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_BOTTOM_SIZE
:
466 return m_gallery_bitmap_padding_bottom_size
;
468 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
475 void wxRibbonMSWArtProvider::SetMetric(int id
, int new_val
)
479 case wxRIBBON_ART_TAB_SEPARATION_SIZE
:
480 m_tab_separation_size
= new_val
;
482 case wxRIBBON_ART_PAGE_BORDER_LEFT_SIZE
:
483 m_page_border_left
= new_val
;
485 case wxRIBBON_ART_PAGE_BORDER_TOP_SIZE
:
486 m_page_border_top
= new_val
;
488 case wxRIBBON_ART_PAGE_BORDER_RIGHT_SIZE
:
489 m_page_border_right
= new_val
;
491 case wxRIBBON_ART_PAGE_BORDER_BOTTOM_SIZE
:
492 m_page_border_bottom
= new_val
;
494 case wxRIBBON_ART_PANEL_X_SEPARATION_SIZE
:
495 m_panel_x_separation_size
= new_val
;
497 case wxRIBBON_ART_PANEL_Y_SEPARATION_SIZE
:
498 m_panel_y_separation_size
= new_val
;
500 case wxRIBBON_ART_TOOL_GROUP_SEPARATION_SIZE
:
501 m_tool_group_separation_size
= new_val
;
503 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_LEFT_SIZE
:
504 m_gallery_bitmap_padding_left_size
= new_val
;
506 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_RIGHT_SIZE
:
507 m_gallery_bitmap_padding_right_size
= new_val
;
509 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_TOP_SIZE
:
510 m_gallery_bitmap_padding_top_size
= new_val
;
512 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_BOTTOM_SIZE
:
513 m_gallery_bitmap_padding_bottom_size
= new_val
;
516 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
521 void wxRibbonMSWArtProvider::SetFont(int id
, const wxFont
& font
)
525 case wxRIBBON_ART_TAB_LABEL_FONT
:
526 m_tab_label_font
= font
;
528 case wxRIBBON_ART_BUTTON_BAR_LABEL_FONT
:
529 m_button_bar_label_font
= font
;
531 case wxRIBBON_ART_PANEL_LABEL_FONT
:
532 m_panel_label_font
= font
;
535 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
540 wxFont
wxRibbonMSWArtProvider::GetFont(int id
) const
544 case wxRIBBON_ART_TAB_LABEL_FONT
:
545 return m_tab_label_font
;
546 case wxRIBBON_ART_BUTTON_BAR_LABEL_FONT
:
547 return m_button_bar_label_font
;
548 case wxRIBBON_ART_PANEL_LABEL_FONT
:
549 return m_panel_label_font
;
551 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
558 wxColour
wxRibbonMSWArtProvider::GetColour(int id
) const
562 case wxRIBBON_ART_BUTTON_BAR_LABEL_COLOUR
:
563 return m_button_bar_label_colour
;
564 case wxRIBBON_ART_BUTTON_BAR_HOVER_BORDER_COLOUR
:
565 return m_button_bar_hover_border_pen
.GetColour();
566 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_COLOUR
:
567 return m_button_bar_hover_background_top_colour
;
568 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
569 return m_button_bar_hover_background_top_gradient_colour
;
570 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_COLOUR
:
571 return m_button_bar_hover_background_colour
;
572 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_GRADIENT_COLOUR
:
573 return m_button_bar_hover_background_gradient_colour
;
574 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BORDER_COLOUR
:
575 return m_button_bar_active_border_pen
.GetColour();
576 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_COLOUR
:
577 return m_button_bar_active_background_top_colour
;
578 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
579 return m_button_bar_active_background_top_gradient_colour
;
580 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_COLOUR
:
581 return m_button_bar_active_background_colour
;
582 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
583 return m_button_bar_active_background_gradient_colour
;
584 case wxRIBBON_ART_GALLERY_BORDER_COLOUR
:
585 return m_gallery_border_pen
.GetColour();
586 case wxRIBBON_ART_GALLERY_HOVER_BACKGROUND_COLOUR
:
587 return m_gallery_hover_background_brush
.GetColour();
588 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_COLOUR
:
589 return m_gallery_button_background_colour
;
590 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_GRADIENT_COLOUR
:
591 return m_gallery_button_background_gradient_colour
;
592 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_TOP_COLOUR
:
593 return m_gallery_button_background_top_brush
.GetColour();
594 case wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR
:
595 return m_gallery_button_face_colour
;
596 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_COLOUR
:
597 return m_gallery_button_hover_background_colour
;
598 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_GRADIENT_COLOUR
:
599 return m_gallery_button_hover_background_gradient_colour
;
600 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_TOP_COLOUR
:
601 return m_gallery_button_hover_background_top_brush
.GetColour();
602 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR
:
603 return m_gallery_button_face_colour
;
604 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_COLOUR
:
605 return m_gallery_button_active_background_colour
;
606 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
607 return m_gallery_button_active_background_gradient_colour
;
608 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_TOP_COLOUR
:
609 return m_gallery_button_background_top_brush
.GetColour();
610 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR
:
611 return m_gallery_button_active_face_colour
;
612 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_COLOUR
:
613 return m_gallery_button_disabled_background_colour
;
614 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_GRADIENT_COLOUR
:
615 return m_gallery_button_disabled_background_gradient_colour
;
616 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_TOP_COLOUR
:
617 return m_gallery_button_disabled_background_top_brush
.GetColour();
618 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR
:
619 return m_gallery_button_disabled_face_colour
;
620 case wxRIBBON_ART_GALLERY_ITEM_BORDER_COLOUR
:
621 return m_gallery_item_border_pen
.GetColour();
622 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_COLOUR
:
623 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_GRADIENT_COLOUR
:
624 return m_tab_ctrl_background_brush
.GetColour();
625 case wxRIBBON_ART_TAB_LABEL_COLOUR
:
626 return m_tab_label_colour
;
627 case wxRIBBON_ART_TAB_SEPARATOR_COLOUR
:
628 return m_tab_separator_colour
;
629 case wxRIBBON_ART_TAB_SEPARATOR_GRADIENT_COLOUR
:
630 return m_tab_separator_gradient_colour
;
631 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_COLOUR
:
632 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
633 return wxColour(0, 0, 0);
634 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_COLOUR
:
635 return m_tab_active_background_colour
;
636 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
637 return m_tab_active_background_gradient_colour
;
638 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_COLOUR
:
639 return m_tab_hover_background_top_colour
;
640 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
641 return m_tab_hover_background_top_gradient_colour
;
642 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_COLOUR
:
643 return m_tab_hover_background_colour
;
644 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_GRADIENT_COLOUR
:
645 return m_tab_hover_background_gradient_colour
;
646 case wxRIBBON_ART_TAB_BORDER_COLOUR
:
647 return m_tab_border_pen
.GetColour();
648 case wxRIBBON_ART_PANEL_BORDER_COLOUR
:
649 return m_panel_border_pen
.GetColour();
650 case wxRIBBON_ART_PANEL_BORDER_GRADIENT_COLOUR
:
651 return m_panel_border_gradient_pen
.GetColour();
652 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_COLOUR
:
653 return m_panel_minimised_border_pen
.GetColour();
654 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_GRADIENT_COLOUR
:
655 return m_panel_minimised_border_gradient_pen
.GetColour();
656 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_COLOUR
:
657 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_GRADIENT_COLOUR
:
658 return m_panel_label_background_brush
.GetColour();
659 case wxRIBBON_ART_PANEL_LABEL_COLOUR
:
660 return m_panel_label_colour
;
661 case wxRIBBON_ART_PANEL_MINIMISED_LABEL_COLOUR
:
662 return m_panel_minimised_label_colour
;
663 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_COLOUR
:
664 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_GRADIENT_COLOUR
:
665 return m_panel_hover_label_background_brush
.GetColour();
666 case wxRIBBON_ART_PANEL_HOVER_LABEL_COLOUR
:
667 return m_panel_hover_label_colour
;
668 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_COLOUR
:
669 return m_panel_active_background_top_colour
;
670 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
671 return m_panel_active_background_top_gradient_colour
;
672 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_COLOUR
:
673 return m_panel_active_background_colour
;
674 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
675 return m_panel_active_background_gradient_colour
;
676 case wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR
:
677 return m_panel_button_face_colour
;
678 case wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR
:
679 return m_panel_button_hover_face_colour
;
680 case wxRIBBON_ART_PAGE_BORDER_COLOUR
:
681 return m_page_border_pen
.GetColour();
682 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_COLOUR
:
683 return m_page_background_top_colour
;
684 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_GRADIENT_COLOUR
:
685 return m_page_background_top_gradient_colour
;
686 case wxRIBBON_ART_PAGE_BACKGROUND_COLOUR
:
687 return m_page_background_colour
;
688 case wxRIBBON_ART_PAGE_BACKGROUND_GRADIENT_COLOUR
:
689 return m_page_background_gradient_colour
;
690 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_COLOUR
:
691 return m_page_hover_background_top_colour
;
692 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
693 return m_page_hover_background_top_gradient_colour
;
694 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_COLOUR
:
695 return m_page_hover_background_colour
;
696 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_GRADIENT_COLOUR
:
697 return m_page_hover_background_gradient_colour
;
698 case wxRIBBON_ART_TOOLBAR_BORDER_COLOUR
:
699 case wxRIBBON_ART_TOOLBAR_HOVER_BORDER_COLOUR
:
700 return m_toolbar_border_pen
.GetColour();
701 case wxRIBBON_ART_TOOLBAR_FACE_COLOUR
:
702 return m_tool_face_colour
;
704 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
711 void wxRibbonMSWArtProvider::SetColour(int id
, const wxColor
& colour
)
715 case wxRIBBON_ART_BUTTON_BAR_LABEL_COLOUR
:
716 m_button_bar_label_colour
= colour
;
718 case wxRIBBON_ART_BUTTON_BAR_HOVER_BORDER_COLOUR
:
719 m_button_bar_hover_border_pen
.SetColour(colour
);
721 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_COLOUR
:
722 m_button_bar_hover_background_top_colour
= colour
;
724 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
725 m_button_bar_hover_background_top_gradient_colour
= colour
;
727 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_COLOUR
:
728 m_button_bar_hover_background_colour
= colour
;
730 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_GRADIENT_COLOUR
:
731 m_button_bar_hover_background_gradient_colour
= colour
;
733 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BORDER_COLOUR
:
734 m_button_bar_active_border_pen
.SetColour(colour
);
736 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_COLOUR
:
737 m_button_bar_active_background_top_colour
= colour
;
739 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
740 m_button_bar_active_background_top_gradient_colour
= colour
;
742 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_COLOUR
:
743 m_button_bar_active_background_colour
= colour
;
745 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
746 m_button_bar_active_background_gradient_colour
= colour
;
748 case wxRIBBON_ART_GALLERY_BORDER_COLOUR
:
749 m_gallery_border_pen
.SetColour(colour
);
751 case wxRIBBON_ART_GALLERY_HOVER_BACKGROUND_COLOUR
:
752 m_gallery_hover_background_brush
.SetColour(colour
);
754 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_COLOUR
:
755 m_gallery_button_background_colour
= colour
;
757 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_GRADIENT_COLOUR
:
758 m_gallery_button_background_gradient_colour
= colour
;
760 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_TOP_COLOUR
:
761 m_gallery_button_background_top_brush
.SetColour(colour
);
763 case wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR
:
764 m_gallery_button_face_colour
= colour
;
765 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
767 m_gallery_up_bitmap
[0] = wxRibbonLoadPixmap(gallery_left_xpm
, colour
);
768 m_gallery_down_bitmap
[0] = wxRibbonLoadPixmap(gallery_right_xpm
, colour
);
772 m_gallery_up_bitmap
[0] = wxRibbonLoadPixmap(gallery_up_xpm
, colour
);
773 m_gallery_down_bitmap
[0] = wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
775 m_gallery_extension_bitmap
[0] = wxRibbonLoadPixmap(gallery_extension_xpm
, colour
);
777 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_COLOUR
:
778 m_gallery_button_hover_background_colour
= colour
;
780 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_GRADIENT_COLOUR
:
781 m_gallery_button_hover_background_gradient_colour
= colour
;
783 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_TOP_COLOUR
:
784 m_gallery_button_hover_background_top_brush
.SetColour(colour
);
786 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR
:
787 m_gallery_button_hover_face_colour
= colour
;
788 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
790 m_gallery_up_bitmap
[1] = wxRibbonLoadPixmap(gallery_left_xpm
, colour
);
791 m_gallery_down_bitmap
[1] = wxRibbonLoadPixmap(gallery_right_xpm
, colour
);
795 m_gallery_up_bitmap
[1] = wxRibbonLoadPixmap(gallery_up_xpm
, colour
);
796 m_gallery_down_bitmap
[1] = wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
798 m_gallery_extension_bitmap
[1] = wxRibbonLoadPixmap(gallery_extension_xpm
, colour
);
800 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_COLOUR
:
801 m_gallery_button_active_background_colour
= colour
;
803 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
804 m_gallery_button_active_background_gradient_colour
= colour
;
806 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_TOP_COLOUR
:
807 m_gallery_button_background_top_brush
.SetColour(colour
);
809 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR
:
810 m_gallery_button_active_face_colour
= colour
;
811 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
813 m_gallery_up_bitmap
[2] = wxRibbonLoadPixmap(gallery_left_xpm
, colour
);
814 m_gallery_down_bitmap
[2] = wxRibbonLoadPixmap(gallery_right_xpm
, colour
);
818 m_gallery_up_bitmap
[2] = wxRibbonLoadPixmap(gallery_up_xpm
, colour
);
819 m_gallery_down_bitmap
[2] = wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
821 m_gallery_extension_bitmap
[2] = wxRibbonLoadPixmap(gallery_extension_xpm
, colour
);
823 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_COLOUR
:
824 m_gallery_button_disabled_background_colour
= colour
;
826 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_GRADIENT_COLOUR
:
827 m_gallery_button_disabled_background_gradient_colour
= colour
;
829 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_TOP_COLOUR
:
830 m_gallery_button_disabled_background_top_brush
.SetColour(colour
);
832 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR
:
833 m_gallery_button_disabled_face_colour
= colour
;
834 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
836 m_gallery_up_bitmap
[3] = wxRibbonLoadPixmap(gallery_left_xpm
, colour
);
837 m_gallery_down_bitmap
[3] = wxRibbonLoadPixmap(gallery_right_xpm
, colour
);
841 m_gallery_up_bitmap
[3] = wxRibbonLoadPixmap(gallery_up_xpm
, colour
);
842 m_gallery_down_bitmap
[3] = wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
844 m_gallery_extension_bitmap
[3] = wxRibbonLoadPixmap(gallery_extension_xpm
, colour
);
846 case wxRIBBON_ART_GALLERY_ITEM_BORDER_COLOUR
:
847 m_gallery_item_border_pen
.SetColour(colour
);
849 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_COLOUR
:
850 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_GRADIENT_COLOUR
:
851 m_tab_ctrl_background_brush
.SetColour(colour
);
852 m_cached_tab_separator_visibility
= -1.0;
854 case wxRIBBON_ART_TAB_LABEL_COLOUR
:
855 m_tab_label_colour
= colour
;
857 case wxRIBBON_ART_TAB_SEPARATOR_COLOUR
:
858 m_tab_separator_colour
= colour
;
859 m_cached_tab_separator_visibility
= -1.0;
861 case wxRIBBON_ART_TAB_SEPARATOR_GRADIENT_COLOUR
:
862 m_tab_separator_gradient_colour
= colour
;
863 m_cached_tab_separator_visibility
= -1.0;
865 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_COLOUR
:
866 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
868 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_COLOUR
:
869 m_tab_active_background_colour
= colour
;
871 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
872 m_tab_active_background_gradient_colour
= colour
;
874 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_COLOUR
:
875 m_tab_hover_background_top_colour
= colour
;
877 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
878 m_tab_hover_background_top_gradient_colour
= colour
;
880 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_COLOUR
:
881 m_tab_hover_background_colour
= colour
;
883 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_GRADIENT_COLOUR
:
884 m_tab_hover_background_gradient_colour
= colour
;
886 case wxRIBBON_ART_TAB_BORDER_COLOUR
:
887 m_tab_border_pen
.SetColour(colour
);
889 case wxRIBBON_ART_PANEL_BORDER_COLOUR
:
890 m_panel_border_pen
.SetColour(colour
);
892 case wxRIBBON_ART_PANEL_BORDER_GRADIENT_COLOUR
:
893 m_panel_border_gradient_pen
.SetColour(colour
);
895 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_COLOUR
:
896 m_panel_minimised_border_pen
.SetColour(colour
);
898 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_GRADIENT_COLOUR
:
899 m_panel_minimised_border_gradient_pen
.SetColour(colour
);
901 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_COLOUR
:
902 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_GRADIENT_COLOUR
:
903 m_panel_label_background_brush
.SetColour(colour
);
905 case wxRIBBON_ART_PANEL_LABEL_COLOUR
:
906 m_panel_label_colour
= colour
;
908 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_COLOUR
:
909 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_GRADIENT_COLOUR
:
910 m_panel_hover_label_background_brush
.SetColour(colour
);
912 case wxRIBBON_ART_PANEL_HOVER_LABEL_COLOUR
:
913 m_panel_hover_label_colour
= colour
;
915 case wxRIBBON_ART_PANEL_MINIMISED_LABEL_COLOUR
:
916 m_panel_minimised_label_colour
= colour
;
918 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_COLOUR
:
919 m_panel_active_background_top_colour
= colour
;
921 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
922 m_panel_active_background_top_gradient_colour
= colour
;
924 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_COLOUR
:
925 m_panel_active_background_colour
= colour
;
927 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
928 m_panel_active_background_gradient_colour
= colour
;
930 case wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR
:
931 m_panel_button_face_colour
= colour
;
932 m_panel_extension_bitmap
[0] = wxRibbonLoadPixmap(panel_extension_xpm
, colour
);
934 case wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR
:
935 m_panel_button_hover_face_colour
= colour
;
936 m_panel_extension_bitmap
[1] = wxRibbonLoadPixmap(panel_extension_xpm
, colour
);
938 case wxRIBBON_ART_PAGE_BORDER_COLOUR
:
939 m_page_border_pen
.SetColour(colour
);
941 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_COLOUR
:
942 m_page_background_top_colour
= colour
;
944 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_GRADIENT_COLOUR
:
945 m_page_background_top_gradient_colour
= colour
;
947 case wxRIBBON_ART_PAGE_BACKGROUND_COLOUR
:
948 m_page_background_colour
= colour
;
950 case wxRIBBON_ART_PAGE_BACKGROUND_GRADIENT_COLOUR
:
951 m_page_background_gradient_colour
= colour
;
953 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_COLOUR
:
954 m_page_hover_background_top_colour
= colour
;
956 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
957 m_page_hover_background_top_gradient_colour
= colour
;
959 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_COLOUR
:
960 m_page_hover_background_colour
= colour
;
962 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_GRADIENT_COLOUR
:
963 m_page_hover_background_gradient_colour
= colour
;
965 case wxRIBBON_ART_TOOLBAR_BORDER_COLOUR
:
966 case wxRIBBON_ART_TOOLBAR_HOVER_BORDER_COLOUR
:
967 m_toolbar_border_pen
.SetColour(colour
);
969 case wxRIBBON_ART_TOOLBAR_FACE_COLOUR
:
970 m_tool_face_colour
= colour
;
971 m_toolbar_drop_bitmap
= wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
974 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
979 void wxRibbonMSWArtProvider::DrawTabCtrlBackground(
981 wxWindow
* WXUNUSED(wnd
),
984 dc
.SetPen(*wxTRANSPARENT_PEN
);
985 dc
.SetBrush(m_tab_ctrl_background_brush
);
986 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
988 dc
.SetPen(m_page_border_pen
);
991 dc
.DrawLine(rect
.x
+ 3, rect
.y
+ rect
.height
- 1, rect
.x
+ rect
.width
- 3, rect
.y
+ rect
.height
- 1);
995 dc
.DrawLine(rect
.x
, rect
.y
+ rect
.height
- 1, rect
.x
+ rect
.width
, rect
.y
+ rect
.height
- 1);
999 void wxRibbonMSWArtProvider::DrawTab(
1001 wxWindow
* WXUNUSED(wnd
),
1002 const wxRibbonPageTabInfo
& tab
)
1004 if(tab
.rect
.height
<= 2)
1007 if(tab
.active
|| tab
.hovered
)
1011 wxRect
background(tab
.rect
);
1015 background
.width
-= 4;
1016 background
.height
-= 2;
1018 dc
.GradientFillLinear(background
, m_tab_active_background_colour
,
1019 m_tab_active_background_gradient_colour
, wxSOUTH
);
1021 // TODO: active and hovered
1023 else if(tab
.hovered
)
1025 wxRect
background(tab
.rect
);
1029 background
.width
-= 4;
1030 background
.height
-= 3;
1031 int h
= background
.height
;
1032 background
.height
/= 2;
1033 dc
.GradientFillLinear(background
,
1034 m_tab_hover_background_top_colour
,
1035 m_tab_hover_background_top_gradient_colour
, wxSOUTH
);
1037 background
.y
+= background
.height
;
1038 background
.height
= h
- background
.height
;
1039 dc
.GradientFillLinear(background
, m_tab_hover_background_colour
,
1040 m_tab_hover_background_gradient_colour
, wxSOUTH
);
1043 wxPoint border_points
[6];
1044 border_points
[0] = wxPoint(1, tab
.rect
.height
- 2);
1045 border_points
[1] = wxPoint(1, 3);
1046 border_points
[2] = wxPoint(3, 1);
1047 border_points
[3] = wxPoint(tab
.rect
.width
- 4, 1);
1048 border_points
[4] = wxPoint(tab
.rect
.width
- 2, 3);
1049 border_points
[5] = wxPoint(tab
.rect
.width
- 2, tab
.rect
.height
- 1);
1051 dc
.SetPen(m_tab_border_pen
);
1052 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
, tab
.rect
.x
, tab
.rect
.y
);
1056 // Give the tab a curved outward border at the bottom
1057 dc
.DrawPoint(tab
.rect
.x
, tab
.rect
.y
+ tab
.rect
.height
- 2);
1058 dc
.DrawPoint(tab
.rect
.x
+ tab
.rect
.width
- 1, tab
.rect
.y
+ tab
.rect
.height
- 2);
1060 wxPen
p(m_tab_active_background_gradient_colour
);
1063 // Technically the first two points are the wrong colour, but they're near enough
1064 dc
.DrawPoint(tab
.rect
.x
+ 1, tab
.rect
.y
+ tab
.rect
.height
- 2);
1065 dc
.DrawPoint(tab
.rect
.x
+ tab
.rect
.width
- 2, tab
.rect
.y
+ tab
.rect
.height
- 2);
1066 dc
.DrawPoint(tab
.rect
.x
+ 1, tab
.rect
.y
+ tab
.rect
.height
- 1);
1067 dc
.DrawPoint(tab
.rect
.x
, tab
.rect
.y
+ tab
.rect
.height
- 1);
1068 dc
.DrawPoint(tab
.rect
.x
+ tab
.rect
.width
- 2, tab
.rect
.y
+ tab
.rect
.height
- 1);
1069 dc
.DrawPoint(tab
.rect
.x
+ tab
.rect
.width
- 1, tab
.rect
.y
+ tab
.rect
.height
- 1);
1073 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_ICONS
)
1075 wxBitmap icon
= tab
.page
->GetIcon();
1078 int x
= tab
.rect
.x
+ 4;
1079 if((m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
) == 0)
1080 x
= tab
.rect
.x
+ (tab
.rect
.width
- icon
.GetWidth()) / 2;
1081 dc
.DrawBitmap(icon
, x
, tab
.rect
.y
+ 1 + (tab
.rect
.height
- 1 -
1082 icon
.GetHeight()) / 2, true);
1085 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
)
1087 wxString label
= tab
.page
->GetLabel();
1088 if(!label
.IsEmpty())
1090 dc
.SetFont(m_tab_label_font
);
1091 dc
.SetTextForeground(m_tab_label_colour
);
1092 dc
.SetBackgroundMode(wxTRANSPARENT
);
1096 dc
.GetTextExtent(label
, &text_width
, &text_height
);
1097 int width
= tab
.rect
.width
- 5;
1098 int x
= tab
.rect
.x
+ 3;
1099 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_ICONS
)
1101 x
+= 3 + tab
.page
->GetIcon().GetWidth();
1102 width
-= 3 + tab
.page
->GetIcon().GetWidth();
1104 int y
= tab
.rect
.y
+ (tab
.rect
.height
- text_height
) / 2;
1106 if(width
<= text_width
)
1108 dc
.SetClippingRegion(x
, tab
.rect
.y
, width
, tab
.rect
.height
);
1109 dc
.DrawText(label
, x
, y
);
1113 dc
.DrawText(label
, x
+ (width
- text_width
) / 2 + 1, y
);
1119 void wxRibbonMSWArtProvider::DrawTabSeparator(
1125 if(visibility
<= 0.0)
1129 if(visibility
> 1.0)
1134 // The tab separator is relatively expensive to draw (for its size), and is
1135 // usually drawn multiple times sequentially (in different positions), so it
1136 // makes sense to draw it once and cache it.
1137 if(!m_cached_tab_separator
.IsOk() || m_cached_tab_separator
.GetSize() != rect
.GetSize() || visibility
!= m_cached_tab_separator_visibility
)
1139 wxRect
size(rect
.GetSize());
1140 ReallyDrawTabSeparator(wnd
, size
, visibility
);
1142 dc
.DrawBitmap(m_cached_tab_separator
, rect
.x
, rect
.y
, false);
1145 void wxRibbonMSWArtProvider::ReallyDrawTabSeparator(wxWindow
* wnd
, const wxRect
& rect
, double visibility
)
1147 if(!m_cached_tab_separator
.IsOk() || m_cached_tab_separator
.GetSize() != rect
.GetSize())
1149 m_cached_tab_separator
= wxBitmap(rect
.GetSize());
1152 wxMemoryDC
dc(m_cached_tab_separator
);
1153 DrawTabCtrlBackground(dc
, wnd
, rect
);
1155 wxCoord x
= rect
.x
+ rect
.width
/ 2;
1156 double h
= (double)(rect
.height
- 1);
1158 double r1
= m_tab_ctrl_background_brush
.GetColour().Red() * (1.0 - visibility
) + 0.5;
1159 double g1
= m_tab_ctrl_background_brush
.GetColour().Green() * (1.0 - visibility
) + 0.5;
1160 double b1
= m_tab_ctrl_background_brush
.GetColour().Blue() * (1.0 - visibility
) + 0.5;
1161 double r2
= m_tab_separator_colour
.Red();
1162 double g2
= m_tab_separator_colour
.Green();
1163 double b2
= m_tab_separator_colour
.Blue();
1164 double r3
= m_tab_separator_gradient_colour
.Red();
1165 double g3
= m_tab_separator_gradient_colour
.Green();
1166 double b3
= m_tab_separator_gradient_colour
.Blue();
1168 for(int i
= 0; i
< rect
.height
- 1; ++i
)
1170 double p
= ((double)i
)/h
;
1172 double r
= (p
* r3
+ (1.0 - p
) * r2
) * visibility
+ r1
;
1173 double g
= (p
* g3
+ (1.0 - p
) * g2
) * visibility
+ g1
;
1174 double b
= (p
* b3
+ (1.0 - p
) * b2
) * visibility
+ b1
;
1176 wxPen
P(wxColour((unsigned char)r
, (unsigned char)g
, (unsigned char)b
));
1178 dc
.DrawPoint(x
, rect
.y
+ i
);
1181 m_cached_tab_separator_visibility
= visibility
;
1184 void wxRibbonMSWArtProvider::DrawPartialPageBackground(wxDC
& dc
,
1185 wxWindow
* wnd
, const wxRect
& rect
, wxRibbonPage
* page
,
1186 wxPoint offset
, bool hovered
)
1189 // Expanded panels need a background - the expanded panel at
1190 // best size may have a greater Y dimension higher than when
1191 // on the bar if it has a sizer. AUI art provider does not need this
1192 // because it paints the panel without reference to its parent's size.
1193 // Expanded panels use a wxFrame as parent (not a wxRibbonPage).
1195 if(wnd
->GetSizer() && wnd
->GetParent() != page
)
1197 background
= wnd
->GetParent()->GetSize();
1198 offset
= wxPoint(0,0);
1202 background
= page
->GetSize();
1203 page
->AdjustRectToIncludeScrollButtons(&background
);
1204 background
.height
-= 2;
1206 // Page background isn't dependant upon the width of the page
1207 // (at least not the part of it intended to be painted by this
1208 // function). Set to wider than the page itself for when externally
1209 // expanded panels need a background - the expanded panel can be wider
1212 background
.width
= INT_MAX
;
1214 // upper_rect, lower_rect, paint_rect are all in page co-ordinates
1215 wxRect
upper_rect(background
);
1216 upper_rect
.height
/= 5;
1218 wxRect
lower_rect(background
);
1219 lower_rect
.y
+= upper_rect
.height
;
1220 lower_rect
.height
-= upper_rect
.height
;
1222 wxRect
paint_rect(rect
);
1223 paint_rect
.x
+= offset
.x
;
1224 paint_rect
.y
+= offset
.y
;
1226 wxColour bg_top
, bg_top_grad
, bg_btm
, bg_btm_grad
;
1229 bg_top
= m_page_hover_background_top_colour
;
1230 bg_top_grad
= m_page_hover_background_top_gradient_colour
;
1231 bg_btm
= m_page_hover_background_colour
;
1232 bg_btm_grad
= m_page_hover_background_gradient_colour
;
1236 bg_top
= m_page_background_top_colour
;
1237 bg_top_grad
= m_page_background_top_gradient_colour
;
1238 bg_btm
= m_page_background_colour
;
1239 bg_btm_grad
= m_page_background_gradient_colour
;
1242 if(paint_rect
.Intersects(upper_rect
))
1244 wxRect
rect(upper_rect
);
1245 rect
.Intersect(paint_rect
);
1248 wxColour
starting_colour(wxRibbonInterpolateColour(bg_top
, bg_top_grad
,
1249 paint_rect
.y
, upper_rect
.y
, upper_rect
.y
+ upper_rect
.height
));
1250 wxColour
ending_colour(wxRibbonInterpolateColour(bg_top
, bg_top_grad
,
1251 paint_rect
.y
+ paint_rect
.height
, upper_rect
.y
,
1252 upper_rect
.y
+ upper_rect
.height
));
1253 dc
.GradientFillLinear(rect
, starting_colour
, ending_colour
, wxSOUTH
);
1256 if(paint_rect
.Intersects(lower_rect
))
1258 wxRect
rect(lower_rect
);
1259 rect
.Intersect(paint_rect
);
1262 wxColour
starting_colour(wxRibbonInterpolateColour(bg_btm
, bg_btm_grad
,
1263 paint_rect
.y
, lower_rect
.y
, lower_rect
.y
+ lower_rect
.height
));
1264 wxColour
ending_colour(wxRibbonInterpolateColour(bg_btm
, bg_btm_grad
,
1265 paint_rect
.y
+ paint_rect
.height
,
1266 lower_rect
.y
, lower_rect
.y
+ lower_rect
.height
));
1267 dc
.GradientFillLinear(rect
, starting_colour
, ending_colour
, wxSOUTH
);
1271 void wxRibbonMSWArtProvider::DrawPageBackground(
1273 wxWindow
* WXUNUSED(wnd
),
1276 dc
.SetPen(*wxTRANSPARENT_PEN
);
1277 dc
.SetBrush(m_tab_ctrl_background_brush
);
1283 dc
.DrawRectangle(edge
.x
, edge
.y
, edge
.width
, edge
.height
);
1285 edge
.x
+= rect
.width
- 2;
1286 dc
.DrawRectangle(edge
.x
, edge
.y
, edge
.width
, edge
.height
);
1290 edge
.y
+= (rect
.height
- edge
.height
);
1291 dc
.DrawRectangle(edge
.x
, edge
.y
, edge
.width
, edge
.height
);
1295 wxRect
background(rect
);
1297 background
.width
-= 4;
1298 background
.height
-= 2;
1300 background
.height
/= 5;
1301 dc
.GradientFillLinear(background
, m_page_background_top_colour
,
1302 m_page_background_top_gradient_colour
, wxSOUTH
);
1304 background
.y
+= background
.height
;
1305 background
.height
= rect
.height
- 2 - background
.height
;
1306 dc
.GradientFillLinear(background
, m_page_background_colour
,
1307 m_page_background_gradient_colour
, wxSOUTH
);
1311 wxPoint border_points
[8];
1312 border_points
[0] = wxPoint(2, 0);
1313 border_points
[1] = wxPoint(1, 1);
1314 border_points
[2] = wxPoint(1, rect
.height
- 4);
1315 border_points
[3] = wxPoint(3, rect
.height
- 2);
1316 border_points
[4] = wxPoint(rect
.width
- 4, rect
.height
- 2);
1317 border_points
[5] = wxPoint(rect
.width
- 2, rect
.height
- 4);
1318 border_points
[6] = wxPoint(rect
.width
- 2, 1);
1319 border_points
[7] = wxPoint(rect
.width
- 4, -1);
1321 dc
.SetPen(m_page_border_pen
);
1322 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
, rect
.x
, rect
.y
);
1326 void wxRibbonMSWArtProvider::DrawScrollButton(
1328 wxWindow
* WXUNUSED(wnd
),
1329 const wxRect
& rect_
,
1334 if((style
& wxRIBBON_SCROLL_BTN_FOR_MASK
) == wxRIBBON_SCROLL_BTN_FOR_PAGE
)
1336 // Page scroll buttons do not have the luxury of rendering on top of anything
1337 // else, and their size includes some padding, hence the background painting
1338 // and size adjustment.
1339 dc
.SetPen(*wxTRANSPARENT_PEN
);
1340 dc
.SetBrush(m_tab_ctrl_background_brush
);
1341 dc
.DrawRectangle(rect
);
1342 dc
.SetClippingRegion(rect
);
1343 switch(style
& wxRIBBON_SCROLL_BTN_DIRECTION_MASK
)
1345 case wxRIBBON_SCROLL_BTN_LEFT
:
1347 case wxRIBBON_SCROLL_BTN_RIGHT
:
1351 case wxRIBBON_SCROLL_BTN_UP
:
1357 case wxRIBBON_SCROLL_BTN_DOWN
:
1366 wxRect
background(rect
);
1369 background
.width
-= 2;
1370 background
.height
-= 2;
1372 if(style
& wxRIBBON_SCROLL_BTN_UP
)
1373 background
.height
/= 2;
1375 background
.height
/= 5;
1376 dc
.GradientFillLinear(background
, m_page_background_top_colour
,
1377 m_page_background_top_gradient_colour
, wxSOUTH
);
1379 background
.y
+= background
.height
;
1380 background
.height
= rect
.height
- 2 - background
.height
;
1381 dc
.GradientFillLinear(background
, m_page_background_colour
,
1382 m_page_background_gradient_colour
, wxSOUTH
);
1386 wxPoint border_points
[7];
1387 switch(style
& wxRIBBON_SCROLL_BTN_DIRECTION_MASK
)
1389 case wxRIBBON_SCROLL_BTN_LEFT
:
1390 border_points
[0] = wxPoint(2, 0);
1391 border_points
[1] = wxPoint(rect
.width
- 1, 0);
1392 border_points
[2] = wxPoint(rect
.width
- 1, rect
.height
- 1);
1393 border_points
[3] = wxPoint(2, rect
.height
- 1);
1394 border_points
[4] = wxPoint(0, rect
.height
- 3);
1395 border_points
[5] = wxPoint(0, 2);
1397 case wxRIBBON_SCROLL_BTN_RIGHT
:
1398 border_points
[0] = wxPoint(0, 0);
1399 border_points
[1] = wxPoint(rect
.width
- 3, 0);
1400 border_points
[2] = wxPoint(rect
.width
- 1, 2);
1401 border_points
[3] = wxPoint(rect
.width
- 1, rect
.height
- 3);
1402 border_points
[4] = wxPoint(rect
.width
- 3, rect
.height
- 1);
1403 border_points
[5] = wxPoint(0, rect
.height
- 1);
1405 case wxRIBBON_SCROLL_BTN_UP
:
1406 border_points
[0] = wxPoint(2, 0);
1407 border_points
[1] = wxPoint(rect
.width
- 3, 0);
1408 border_points
[2] = wxPoint(rect
.width
- 1, 2);
1409 border_points
[3] = wxPoint(rect
.width
- 1, rect
.height
- 1);
1410 border_points
[4] = wxPoint(0, rect
.height
- 1);
1411 border_points
[5] = wxPoint(0, 2);
1413 case wxRIBBON_SCROLL_BTN_DOWN
:
1414 border_points
[0] = wxPoint(0, 0);
1415 border_points
[1] = wxPoint(rect
.width
- 1, 0);
1416 border_points
[2] = wxPoint(rect
.width
- 1, rect
.height
- 3);
1417 border_points
[3] = wxPoint(rect
.width
- 3, rect
.height
- 1);
1418 border_points
[4] = wxPoint(2, rect
.height
- 1);
1419 border_points
[5] = wxPoint(0, rect
.height
- 3);
1422 border_points
[6] = border_points
[0];
1424 dc
.SetPen(m_page_border_pen
);
1425 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
, rect
.x
, rect
.y
);
1429 // NB: Code for handling hovered/active state is temporary
1430 wxPoint arrow_points
[3];
1431 switch(style
& wxRIBBON_SCROLL_BTN_DIRECTION_MASK
)
1433 case wxRIBBON_SCROLL_BTN_LEFT
:
1434 arrow_points
[0] = wxPoint(rect
.width
/ 2 - 2, rect
.height
/ 2);
1435 if(style
& wxRIBBON_SCROLL_BTN_ACTIVE
)
1436 arrow_points
[0].y
+= 1;
1437 arrow_points
[1] = arrow_points
[0] + wxPoint(3, -3);
1438 arrow_points
[2] = arrow_points
[0] + wxPoint(3, 3);
1440 case wxRIBBON_SCROLL_BTN_RIGHT
:
1441 arrow_points
[0] = wxPoint(rect
.width
/ 2 + 2, rect
.height
/ 2);
1442 if(style
& wxRIBBON_SCROLL_BTN_ACTIVE
)
1443 arrow_points
[0].y
+= 1;
1444 arrow_points
[1] = arrow_points
[0] - wxPoint(3, 3);
1445 arrow_points
[2] = arrow_points
[0] - wxPoint(3, -3);
1447 case wxRIBBON_SCROLL_BTN_UP
:
1448 arrow_points
[0] = wxPoint(rect
.width
/ 2, rect
.height
/ 2 - 2);
1449 if(style
& wxRIBBON_SCROLL_BTN_ACTIVE
)
1450 arrow_points
[0].y
+= 1;
1451 arrow_points
[1] = arrow_points
[0] + wxPoint( 3, 3);
1452 arrow_points
[2] = arrow_points
[0] + wxPoint(-3, 3);
1454 case wxRIBBON_SCROLL_BTN_DOWN
:
1455 arrow_points
[0] = wxPoint(rect
.width
/ 2, rect
.height
/ 2 + 2);
1456 if(style
& wxRIBBON_SCROLL_BTN_ACTIVE
)
1457 arrow_points
[0].y
+= 1;
1458 arrow_points
[1] = arrow_points
[0] - wxPoint( 3, 3);
1459 arrow_points
[2] = arrow_points
[0] - wxPoint(-3, 3);
1463 dc
.SetPen(*wxTRANSPARENT_PEN
);
1464 wxBrush
B(style
& wxRIBBON_SCROLL_BTN_HOVERED
? m_tab_active_background_colour
: m_tab_label_colour
);
1466 dc
.DrawPolygon(sizeof(arrow_points
)/sizeof(wxPoint
), arrow_points
, rect
.x
, rect
.y
);
1470 void wxRibbonMSWArtProvider::DrawDropdownArrow(wxDC
& dc
, int x
, int y
, const wxColour
& colour
)
1472 wxPoint arrow_points
[3];
1473 wxBrush
brush(colour
);
1474 arrow_points
[0] = wxPoint(1, 2);
1475 arrow_points
[1] = arrow_points
[0] + wxPoint(-3, -3);
1476 arrow_points
[2] = arrow_points
[0] + wxPoint( 3, -3);
1477 dc
.SetPen(*wxTRANSPARENT_PEN
);
1479 dc
.DrawPolygon(sizeof(arrow_points
)/sizeof(wxPoint
), arrow_points
, x
, y
);
1482 void wxRibbonMSWArtProvider::RemovePanelPadding(wxRect
* rect
)
1484 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1496 void wxRibbonMSWArtProvider::DrawPanelBackground(
1501 DrawPartialPageBackground(dc
, wnd
, rect
, false);
1503 wxRect
true_rect(rect
);
1504 RemovePanelPadding(&true_rect
);
1505 bool has_ext_button
= wnd
->HasExtButton();
1509 dc
.SetFont(m_panel_label_font
);
1510 dc
.SetPen(*wxTRANSPARENT_PEN
);
1511 if(wnd
->IsHovered())
1513 dc
.SetBrush(m_panel_hover_label_background_brush
);
1514 dc
.SetTextForeground(m_panel_hover_label_colour
);
1518 dc
.SetBrush(m_panel_label_background_brush
);
1519 dc
.SetTextForeground(m_panel_label_colour
);
1522 wxRect
label_rect(true_rect
);
1523 wxString label
= wnd
->GetLabel();
1524 bool clip_label
= false;
1525 wxSize
label_size(dc
.GetTextExtent(label
));
1527 label_rect
.SetX(label_rect
.GetX() + 1);
1528 label_rect
.SetWidth(label_rect
.GetWidth() - 2);
1529 label_rect
.SetHeight(label_size
.GetHeight() + 2);
1530 label_rect
.SetY(true_rect
.GetBottom() - label_rect
.GetHeight());
1531 label_height
= label_rect
.GetHeight();
1533 wxRect label_bg_rect
= label_rect
;
1536 label_rect
.SetWidth(label_rect
.GetWidth() - 13);
1538 if(label_size
.GetWidth() > label_rect
.GetWidth())
1540 // Test if there is enough length for 3 letters and ...
1541 wxString new_label
= label
.Mid(0, 3) + wxT("...");
1542 label_size
= dc
.GetTextExtent(new_label
);
1543 if(label_size
.GetWidth() > label_rect
.GetWidth())
1545 // Not enough room for three characters and ...
1546 // Display the entire label and just crop it
1551 // Room for some characters and ...
1552 // Display as many characters as possible and append ...
1553 for(size_t len
= label
.Len() - 1; len
>= 3; --len
)
1555 new_label
= label
.Mid(0, len
) + wxT("...");
1556 label_size
= dc
.GetTextExtent(new_label
);
1557 if(label_size
.GetWidth() <= label_rect
.GetWidth())
1566 dc
.DrawRectangle(label_bg_rect
);
1569 wxDCClipper
clip(dc
, label_rect
);
1570 dc
.DrawText(label
, label_rect
.x
, label_rect
.y
+
1571 (label_rect
.GetHeight() - label_size
.GetHeight()) / 2);
1575 dc
.DrawText(label
, label_rect
.x
+
1576 (label_rect
.GetWidth() - label_size
.GetWidth()) / 2,
1578 (label_rect
.GetHeight() - label_size
.GetHeight()) / 2);
1583 if(wnd
->IsExtButtonHovered())
1585 dc
.SetPen(m_panel_hover_button_border_pen
);
1586 dc
.SetBrush(m_panel_hover_button_background_brush
);
1587 dc
.DrawRoundedRectangle(label_rect
.GetRight(), label_rect
.GetBottom() - 13, 13, 13, 1.0);
1588 dc
.DrawBitmap(m_panel_extension_bitmap
[1], label_rect
.GetRight() + 3, label_rect
.GetBottom() - 10, true);
1591 dc
.DrawBitmap(m_panel_extension_bitmap
[0], label_rect
.GetRight() + 3, label_rect
.GetBottom() - 10, true);
1595 if(wnd
->IsHovered())
1597 wxRect
client_rect(true_rect
);
1599 client_rect
.width
-= 2;
1601 client_rect
.height
-= 2 + label_height
;
1602 DrawPartialPageBackground(dc
, wnd
, client_rect
, true);
1605 DrawPanelBorder(dc
, true_rect
, m_panel_border_pen
, m_panel_border_gradient_pen
);
1608 wxRect
wxRibbonMSWArtProvider::GetPanelExtButtonArea(wxDC
& WXUNUSED(dc
),
1609 const wxRibbonPanel
* WXUNUSED(wnd
),
1612 RemovePanelPadding(&rect
);
1613 rect
= wxRect(rect
.GetRight()-13, rect
.GetBottom()-13, 13, 13);
1617 void wxRibbonMSWArtProvider::DrawGalleryBackground(
1619 wxRibbonGallery
* wnd
,
1622 DrawPartialPageBackground(dc
, wnd
, rect
);
1624 if(wnd
->IsHovered())
1626 dc
.SetPen(*wxTRANSPARENT_PEN
);
1627 dc
.SetBrush(m_gallery_hover_background_brush
);
1628 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1630 dc
.DrawRectangle(rect
.x
+ 1, rect
.y
+ 1, rect
.width
- 2,
1635 dc
.DrawRectangle(rect
.x
+ 1, rect
.y
+ 1, rect
.width
- 16,
1640 dc
.SetPen(m_gallery_border_pen
);
1642 dc
.DrawLine(rect
.x
+ 1, rect
.y
, rect
.x
+ rect
.width
- 1, rect
.y
);
1643 dc
.DrawLine(rect
.x
, rect
.y
+ 1, rect
.x
, rect
.y
+ rect
.height
- 1);
1644 dc
.DrawLine(rect
.x
+ 1, rect
.y
+ rect
.height
- 1, rect
.x
+ rect
.width
- 1,
1645 rect
.y
+ rect
.height
- 1);
1646 dc
.DrawLine(rect
.x
+ rect
.width
- 1, rect
.y
+ 1, rect
.x
+ rect
.width
- 1,
1647 rect
.y
+ rect
.height
- 1);
1649 DrawGalleryBackgroundCommon(dc
, wnd
, rect
);
1652 void wxRibbonMSWArtProvider::DrawGalleryBackgroundCommon(wxDC
& dc
,
1653 wxRibbonGallery
* wnd
,
1656 wxRect up_btn
, down_btn
, ext_btn
;
1658 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1660 // Divider between items and buttons
1661 dc
.DrawLine(rect
.x
, rect
.y
+ rect
.height
- 15, rect
.x
+ rect
.width
,
1662 rect
.y
+ rect
.height
- 15);
1664 up_btn
= wxRect(rect
.x
, rect
.y
+ rect
.height
- 15, rect
.width
/ 3, 15);
1666 down_btn
= wxRect(up_btn
.GetRight() + 1, up_btn
.GetTop(),
1667 up_btn
.GetWidth(), up_btn
.GetHeight());
1668 dc
.DrawLine(down_btn
.GetLeft(), down_btn
.GetTop(), down_btn
.GetLeft(),
1669 down_btn
.GetBottom());
1671 ext_btn
= wxRect(down_btn
.GetRight() + 1, up_btn
.GetTop(), rect
.width
-
1672 up_btn
.GetWidth() - down_btn
.GetWidth() - 1, up_btn
.GetHeight());
1673 dc
.DrawLine(ext_btn
.GetLeft(), ext_btn
.GetTop(), ext_btn
.GetLeft(),
1674 ext_btn
.GetBottom());
1678 // Divider between items and buttons
1679 dc
.DrawLine(rect
.x
+ rect
.width
- 15, rect
.y
, rect
.x
+ rect
.width
- 15,
1680 rect
.y
+ rect
.height
);
1682 up_btn
= wxRect(rect
.x
+ rect
.width
- 15, rect
.y
, 15, rect
.height
/ 3);
1684 down_btn
= wxRect(up_btn
.GetLeft(), up_btn
.GetBottom() + 1,
1685 up_btn
.GetWidth(), up_btn
.GetHeight());
1686 dc
.DrawLine(down_btn
.GetLeft(), down_btn
.GetTop(), down_btn
.GetRight(),
1689 ext_btn
= wxRect(up_btn
.GetLeft(), down_btn
.GetBottom() + 1, up_btn
.GetWidth(),
1690 rect
.height
- up_btn
.GetHeight() - down_btn
.GetHeight() - 1);
1691 dc
.DrawLine(ext_btn
.GetLeft(), ext_btn
.GetTop(), ext_btn
.GetRight(),
1695 DrawGalleryButton(dc
, up_btn
, wnd
->GetUpButtonState(),
1696 m_gallery_up_bitmap
);
1697 DrawGalleryButton(dc
, down_btn
, wnd
->GetDownButtonState(),
1698 m_gallery_down_bitmap
);
1699 DrawGalleryButton(dc
, ext_btn
, wnd
->GetExtensionButtonState(),
1700 m_gallery_extension_bitmap
);
1703 void wxRibbonMSWArtProvider::DrawGalleryButton(wxDC
& dc
,
1705 wxRibbonGalleryButtonState state
,
1708 wxBitmap btn_bitmap
;
1709 wxBrush btn_top_brush
;
1710 wxColour btn_colour
;
1711 wxColour btn_grad_colour
;
1714 case wxRIBBON_GALLERY_BUTTON_NORMAL
:
1715 btn_top_brush
= m_gallery_button_background_top_brush
;
1716 btn_colour
= m_gallery_button_background_colour
;
1717 btn_grad_colour
= m_gallery_button_background_gradient_colour
;
1718 btn_bitmap
= bitmaps
[0];
1720 case wxRIBBON_GALLERY_BUTTON_HOVERED
:
1721 btn_top_brush
= m_gallery_button_hover_background_top_brush
;
1722 btn_colour
= m_gallery_button_hover_background_colour
;
1723 btn_grad_colour
= m_gallery_button_hover_background_gradient_colour
;
1724 btn_bitmap
= bitmaps
[1];
1726 case wxRIBBON_GALLERY_BUTTON_ACTIVE
:
1727 btn_top_brush
= m_gallery_button_active_background_top_brush
;
1728 btn_colour
= m_gallery_button_active_background_colour
;
1729 btn_grad_colour
= m_gallery_button_active_background_gradient_colour
;
1730 btn_bitmap
= bitmaps
[2];
1732 case wxRIBBON_GALLERY_BUTTON_DISABLED
:
1733 btn_top_brush
= m_gallery_button_disabled_background_top_brush
;
1734 btn_colour
= m_gallery_button_disabled_background_colour
;
1735 btn_grad_colour
= m_gallery_button_disabled_background_gradient_colour
;
1736 btn_bitmap
= bitmaps
[3];
1742 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1753 dc
.SetPen(*wxTRANSPARENT_PEN
);
1754 dc
.SetBrush(btn_top_brush
);
1755 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
/ 2);
1758 lower
.height
= (lower
.height
+ 1) / 2;
1759 lower
.y
+= rect
.height
- lower
.height
;
1760 dc
.GradientFillLinear(lower
, btn_colour
, btn_grad_colour
, wxSOUTH
);
1762 dc
.DrawBitmap(btn_bitmap
, rect
.x
+ rect
.width
/ 2 - 2, lower
.y
- 2, true);
1765 void wxRibbonMSWArtProvider::DrawGalleryItemBackground(
1767 wxRibbonGallery
* wnd
,
1769 wxRibbonGalleryItem
* item
)
1771 if(wnd
->GetHoveredItem() != item
&& wnd
->GetActiveItem() != item
&&
1772 wnd
->GetSelection() != item
)
1775 dc
.SetPen(m_gallery_item_border_pen
);
1776 dc
.DrawLine(rect
.x
+ 1, rect
.y
, rect
.x
+ rect
.width
- 1, rect
.y
);
1777 dc
.DrawLine(rect
.x
, rect
.y
+ 1, rect
.x
, rect
.y
+ rect
.height
- 1);
1778 dc
.DrawLine(rect
.x
+ 1, rect
.y
+ rect
.height
- 1, rect
.x
+ rect
.width
- 1,
1779 rect
.y
+ rect
.height
- 1);
1780 dc
.DrawLine(rect
.x
+ rect
.width
- 1, rect
.y
+ 1, rect
.x
+ rect
.width
- 1,
1781 rect
.y
+ rect
.height
- 1);
1785 wxColour bg_gradient_colour
;
1787 if(wnd
->GetActiveItem() == item
|| wnd
->GetSelection() == item
)
1789 top_brush
= m_gallery_button_active_background_top_brush
;
1790 bg_colour
= m_gallery_button_active_background_colour
;
1791 bg_gradient_colour
= m_gallery_button_active_background_gradient_colour
;
1795 top_brush
= m_gallery_button_hover_background_top_brush
;
1796 bg_colour
= m_gallery_button_hover_background_colour
;
1797 bg_gradient_colour
= m_gallery_button_hover_background_gradient_colour
;
1805 dc
.SetPen(*wxTRANSPARENT_PEN
);
1806 dc
.SetBrush(top_brush
);
1807 dc
.DrawRectangle(upper
.x
, upper
.y
, upper
.width
, upper
.height
);
1809 wxRect
lower(upper
);
1810 lower
.y
+= lower
.height
;
1811 lower
.height
= rect
.height
- 2 - lower
.height
;
1812 dc
.GradientFillLinear(lower
, bg_colour
, bg_gradient_colour
, wxSOUTH
);
1815 void wxRibbonMSWArtProvider::DrawPanelBorder(wxDC
& dc
, const wxRect
& rect
,
1816 wxPen
& primary_colour
,
1817 wxPen
& secondary_colour
)
1819 wxPoint border_points
[9];
1820 border_points
[0] = wxPoint(2, 0);
1821 border_points
[1] = wxPoint(rect
.width
- 3, 0);
1822 border_points
[2] = wxPoint(rect
.width
- 1, 2);
1823 border_points
[3] = wxPoint(rect
.width
- 1, rect
.height
- 3);
1824 border_points
[4] = wxPoint(rect
.width
- 3, rect
.height
- 1);
1825 border_points
[5] = wxPoint(2, rect
.height
- 1);
1826 border_points
[6] = wxPoint(0, rect
.height
- 3);
1827 border_points
[7] = wxPoint(0, 2);
1829 if(primary_colour
.GetColour() == secondary_colour
.GetColour())
1831 border_points
[8] = border_points
[0];
1832 dc
.SetPen(primary_colour
);
1833 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
, rect
.x
, rect
.y
);
1837 dc
.SetPen(primary_colour
);
1838 dc
.DrawLines(3, border_points
, rect
.x
, rect
.y
);
1840 #define SingleLine(start, finish) \
1841 dc.DrawLine(start.x + rect.x, start.y + rect.y, finish.x + rect.x, finish.y + rect.y)
1843 SingleLine(border_points
[0], border_points
[7]);
1844 dc
.SetPen(secondary_colour
);
1845 dc
.DrawLines(3, border_points
+ 4, rect
.x
, rect
.y
);
1846 SingleLine(border_points
[4], border_points
[3]);
1850 border_points
[6] = border_points
[2];
1851 wxRibbonDrawParallelGradientLines(dc
, 2, border_points
+ 6, 0, 1,
1852 border_points
[3].y
- border_points
[2].y
+ 1, rect
.x
, rect
.y
,
1853 primary_colour
.GetColour(), secondary_colour
.GetColour());
1857 void wxRibbonMSWArtProvider::DrawMinimisedPanel(
1863 DrawPartialPageBackground(dc
, wnd
, rect
, false);
1865 wxRect
true_rect(rect
);
1866 RemovePanelPadding(&true_rect
);
1868 if(wnd
->GetExpandedPanel() != NULL
)
1870 wxRect
client_rect(true_rect
);
1872 client_rect
.width
-= 2;
1874 client_rect
.height
= (rect
.y
+ rect
.height
/ 5) - client_rect
.x
;
1875 dc
.GradientFillLinear(client_rect
,
1876 m_panel_active_background_top_colour
,
1877 m_panel_active_background_top_gradient_colour
, wxSOUTH
);
1879 client_rect
.y
+= client_rect
.height
;
1880 client_rect
.height
= (true_rect
.y
+ true_rect
.height
) - client_rect
.y
;
1881 dc
.GradientFillLinear(client_rect
,
1882 m_panel_active_background_colour
,
1883 m_panel_active_background_gradient_colour
, wxSOUTH
);
1885 else if(wnd
->IsHovered())
1887 wxRect
client_rect(true_rect
);
1889 client_rect
.width
-= 2;
1891 client_rect
.height
-= 2;
1892 DrawPartialPageBackground(dc
, wnd
, client_rect
, true);
1896 DrawMinimisedPanelCommon(dc
, wnd
, true_rect
, &preview
);
1898 dc
.SetBrush(m_panel_hover_label_background_brush
);
1899 dc
.SetPen(*wxTRANSPARENT_PEN
);
1900 dc
.DrawRectangle(preview
.x
+ 1, preview
.y
+ preview
.height
- 8,
1901 preview
.width
- 2, 7);
1903 int mid_pos
= rect
.y
+ rect
.height
/ 5 - preview
.y
;
1904 if(mid_pos
< 0 || mid_pos
>= preview
.height
)
1906 wxRect
full_rect(preview
);
1909 full_rect
.width
-= 2;
1910 full_rect
.height
-= 9;
1913 dc
.GradientFillLinear(full_rect
,
1914 m_page_hover_background_colour
,
1915 m_page_hover_background_gradient_colour
, wxSOUTH
);
1919 dc
.GradientFillLinear(full_rect
,
1920 m_page_hover_background_top_colour
,
1921 m_page_hover_background_top_gradient_colour
, wxSOUTH
);
1926 wxRect
top_rect(preview
);
1929 top_rect
.width
-= 2;
1930 top_rect
.height
= mid_pos
;
1931 dc
.GradientFillLinear(top_rect
,
1932 m_page_hover_background_top_colour
,
1933 m_page_hover_background_top_gradient_colour
, wxSOUTH
);
1935 wxRect
btm_rect(top_rect
);
1936 btm_rect
.y
= preview
.y
+ mid_pos
;
1937 btm_rect
.height
= preview
.y
+ preview
.height
- 7 - btm_rect
.y
;
1938 dc
.GradientFillLinear(btm_rect
,
1939 m_page_hover_background_colour
,
1940 m_page_hover_background_gradient_colour
, wxSOUTH
);
1945 dc
.DrawBitmap(bitmap
, preview
.x
+ (preview
.width
- bitmap
.GetWidth()) / 2,
1946 preview
.y
+ (preview
.height
- 7 - bitmap
.GetHeight()) / 2, true);
1949 DrawPanelBorder(dc
, preview
, m_panel_border_pen
, m_panel_border_gradient_pen
);
1951 DrawPanelBorder(dc
, true_rect
, m_panel_minimised_border_pen
,
1952 m_panel_minimised_border_gradient_pen
);
1955 void wxRibbonMSWArtProvider::DrawMinimisedPanelCommon(
1958 const wxRect
& true_rect
,
1959 wxRect
* preview_rect
)
1961 wxRect
preview(0, 0, 32, 32);
1962 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1964 preview
.x
= true_rect
.x
+ 4;
1965 preview
.y
= true_rect
.y
+ (true_rect
.height
- preview
.height
) / 2;
1969 preview
.x
= true_rect
.x
+ (true_rect
.width
- preview
.width
) / 2;
1970 preview
.y
= true_rect
.y
+ 4;
1973 *preview_rect
= preview
;
1975 wxCoord label_width
, label_height
;
1976 dc
.SetFont(m_panel_label_font
);
1977 dc
.GetTextExtent(wnd
->GetLabel(), &label_width
, &label_height
);
1979 int xpos
= true_rect
.x
+ (true_rect
.width
- label_width
+ 1) / 2;
1980 int ypos
= preview
.y
+ preview
.height
+ 5;
1982 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1984 xpos
= preview
.x
+ preview
.width
+ 5;
1985 ypos
= true_rect
.y
+ (true_rect
.height
- label_height
) / 2;
1988 dc
.SetTextForeground(m_panel_minimised_label_colour
);
1989 dc
.DrawText(wnd
->GetLabel(), xpos
, ypos
);
1992 wxPoint arrow_points
[3];
1993 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1995 xpos
+= label_width
;
1996 arrow_points
[0] = wxPoint(xpos
+ 5, ypos
+ label_height
/ 2);
1997 arrow_points
[1] = arrow_points
[0] + wxPoint(-3, 3);
1998 arrow_points
[2] = arrow_points
[0] + wxPoint(-3, -3);
2002 ypos
+= label_height
;
2003 arrow_points
[0] = wxPoint(true_rect
.width
/ 2, ypos
+ 5);
2004 arrow_points
[1] = arrow_points
[0] + wxPoint(-3, -3);
2005 arrow_points
[2] = arrow_points
[0] + wxPoint( 3, -3);
2008 dc
.SetPen(*wxTRANSPARENT_PEN
);
2009 wxBrush
B(m_panel_minimised_label_colour
);
2011 dc
.DrawPolygon(sizeof(arrow_points
)/sizeof(wxPoint
), arrow_points
,
2012 true_rect
.x
, true_rect
.y
);
2015 void wxRibbonMSWArtProvider::DrawButtonBarBackground(
2020 DrawPartialPageBackground(dc
, wnd
, rect
, true);
2023 void wxRibbonMSWArtProvider::DrawPartialPageBackground(
2029 // Assume the window is a child of a ribbon page, and also check for a
2030 // hovered panel somewhere between the window and the page, as it causes
2031 // the background to change.
2032 wxPoint
offset(wnd
->GetPosition());
2033 wxRibbonPage
* page
= NULL
;
2034 wxWindow
* parent
= wnd
->GetParent();
2035 wxRibbonPanel
* panel
= wxDynamicCast(wnd
, wxRibbonPanel
);
2036 bool hovered
= false;
2040 hovered
= allow_hovered
&& panel
->IsHovered();
2041 if(panel
->GetExpandedDummy() != NULL
)
2043 offset
= panel
->GetExpandedDummy()->GetPosition();
2044 parent
= panel
->GetExpandedDummy()->GetParent();
2047 for(; parent
; parent
= parent
->GetParent())
2051 panel
= wxDynamicCast(parent
, wxRibbonPanel
);
2054 hovered
= allow_hovered
&& panel
->IsHovered();
2055 if(panel
->GetExpandedDummy() != NULL
)
2057 parent
= panel
->GetExpandedDummy();
2061 page
= wxDynamicCast(parent
, wxRibbonPage
);
2066 offset
+= parent
->GetPosition();
2070 DrawPartialPageBackground(dc
, wnd
, rect
, page
, offset
, hovered
);
2074 // No page found - fallback to painting with a stock brush
2075 dc
.SetBrush(*wxWHITE_BRUSH
);
2076 dc
.SetPen(*wxTRANSPARENT_PEN
);
2077 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
2080 void wxRibbonMSWArtProvider::DrawButtonBarButton(
2082 wxWindow
* WXUNUSED(wnd
),
2084 wxRibbonButtonKind kind
,
2086 const wxString
& label
,
2087 const wxBitmap
& bitmap_large
,
2088 const wxBitmap
& bitmap_small
)
2090 if(kind
== wxRIBBON_BUTTON_TOGGLE
)
2092 kind
= wxRIBBON_BUTTON_NORMAL
;
2093 if(state
& wxRIBBON_BUTTONBAR_BUTTON_TOGGLED
)
2094 state
^= wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK
;
2097 if(state
& (wxRIBBON_BUTTONBAR_BUTTON_HOVER_MASK
|
2098 wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK
))
2100 if(state
& wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK
)
2101 dc
.SetPen(m_button_bar_active_border_pen
);
2103 dc
.SetPen(m_button_bar_hover_border_pen
);
2105 wxRect
bg_rect(rect
);
2109 bg_rect
.height
-= 2;
2111 wxRect
bg_rect_top(bg_rect
);
2112 bg_rect_top
.height
/= 3;
2113 bg_rect
.y
+= bg_rect_top
.height
;
2114 bg_rect
.height
-= bg_rect_top
.height
;
2116 if(kind
== wxRIBBON_BUTTON_HYBRID
)
2118 switch(state
& wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK
)
2120 case wxRIBBON_BUTTONBAR_BUTTON_LARGE
:
2122 int iYBorder
= rect
.y
+ bitmap_large
.GetHeight() + 4;
2123 wxRect
partial_bg(rect
);
2124 if(state
& wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED
)
2126 partial_bg
.SetBottom(iYBorder
- 1);
2130 partial_bg
.height
-= (iYBorder
- partial_bg
.y
+ 1);
2131 partial_bg
.y
= iYBorder
+ 1;
2133 dc
.DrawLine(rect
.x
, iYBorder
, rect
.x
+ rect
.width
, iYBorder
);
2134 bg_rect
.Intersect(partial_bg
);
2135 bg_rect_top
.Intersect(partial_bg
);
2138 case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM
:
2140 int iArrowWidth
= 9;
2141 if(state
& wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED
)
2143 bg_rect
.width
-= iArrowWidth
;
2144 bg_rect_top
.width
-= iArrowWidth
;
2145 dc
.DrawLine(bg_rect_top
.x
+ bg_rect_top
.width
,
2146 rect
.y
, bg_rect_top
.x
+ bg_rect_top
.width
,
2147 rect
.y
+ rect
.height
);
2152 bg_rect
.x
+= bg_rect
.width
- iArrowWidth
;
2153 bg_rect_top
.x
+= bg_rect_top
.width
- iArrowWidth
;
2154 bg_rect
.width
= iArrowWidth
;
2155 bg_rect_top
.width
= iArrowWidth
;
2156 dc
.DrawLine(bg_rect_top
.x
- 1, rect
.y
,
2157 bg_rect_top
.x
- 1, rect
.y
+ rect
.height
);
2161 case wxRIBBON_BUTTONBAR_BUTTON_SMALL
:
2166 if(state
& wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK
)
2168 dc
.GradientFillLinear(bg_rect_top
,
2169 m_button_bar_active_background_top_colour
,
2170 m_button_bar_active_background_top_gradient_colour
, wxSOUTH
);
2171 dc
.GradientFillLinear(bg_rect
,
2172 m_button_bar_active_background_colour
,
2173 m_button_bar_active_background_gradient_colour
, wxSOUTH
);
2177 dc
.GradientFillLinear(bg_rect_top
,
2178 m_button_bar_hover_background_top_colour
,
2179 m_button_bar_hover_background_top_gradient_colour
, wxSOUTH
);
2180 dc
.GradientFillLinear(bg_rect
,
2181 m_button_bar_hover_background_colour
,
2182 m_button_bar_hover_background_gradient_colour
, wxSOUTH
);
2185 wxPoint border_points
[9];
2186 border_points
[0] = wxPoint(2, 0);
2187 border_points
[1] = wxPoint(rect
.width
- 3, 0);
2188 border_points
[2] = wxPoint(rect
.width
- 1, 2);
2189 border_points
[3] = wxPoint(rect
.width
- 1, rect
.height
- 3);
2190 border_points
[4] = wxPoint(rect
.width
- 3, rect
.height
- 1);
2191 border_points
[5] = wxPoint(2, rect
.height
- 1);
2192 border_points
[6] = wxPoint(0, rect
.height
- 3);
2193 border_points
[7] = wxPoint(0, 2);
2194 border_points
[8] = border_points
[0];
2196 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
,
2200 dc
.SetFont(m_button_bar_label_font
);
2201 dc
.SetTextForeground(m_button_bar_label_colour
);
2202 DrawButtonBarButtonForeground(dc
, rect
, kind
, state
, label
, bitmap_large
,
2206 void wxRibbonMSWArtProvider::DrawButtonBarButtonForeground(
2209 wxRibbonButtonKind kind
,
2211 const wxString
& label
,
2212 const wxBitmap
& bitmap_large
,
2213 const wxBitmap
& bitmap_small
)
2215 switch(state
& wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK
)
2217 case wxRIBBON_BUTTONBAR_BUTTON_LARGE
:
2219 const int padding
= 2;
2220 dc
.DrawBitmap(bitmap_large
,
2221 rect
.x
+ (rect
.width
- bitmap_large
.GetWidth()) / 2,
2222 rect
.y
+ padding
, true);
2223 int ypos
= rect
.y
+ padding
+ bitmap_large
.GetHeight() + padding
;
2224 int arrow_width
= kind
== wxRIBBON_BUTTON_NORMAL
? 0 : 8;
2225 wxCoord label_w
, label_h
;
2226 dc
.GetTextExtent(label
, &label_w
, &label_h
);
2227 if(label_w
+ 2 * padding
<= rect
.width
)
2229 dc
.DrawText(label
, rect
.x
+ (rect
.width
- label_w
) / 2, ypos
);
2230 if(arrow_width
!= 0)
2232 DrawDropdownArrow(dc
, rect
.x
+ rect
.width
/ 2,
2233 ypos
+ (label_h
* 3) / 2,
2234 m_button_bar_label_colour
);
2239 size_t breaki
= label
.Len();
2243 if(wxRibbonCanLabelBreakAtPosition(label
, breaki
))
2245 wxString label_top
= label
.Mid(0, breaki
);
2246 dc
.GetTextExtent(label_top
, &label_w
, &label_h
);
2247 if(label_w
+ 2 * padding
<= rect
.width
)
2249 dc
.DrawText(label_top
,
2250 rect
.x
+ (rect
.width
- label_w
) / 2, ypos
);
2252 wxString label_bottom
= label
.Mid(breaki
+ 1);
2253 dc
.GetTextExtent(label_bottom
, &label_w
, &label_h
);
2254 label_w
+= arrow_width
;
2255 int iX
= rect
.x
+ (rect
.width
- label_w
) / 2;
2256 dc
.DrawText(label_bottom
, iX
, ypos
);
2257 if(arrow_width
!= 0)
2259 DrawDropdownArrow(dc
,
2260 iX
+ 2 +label_w
- arrow_width
,
2261 ypos
+ label_h
/ 2 + 1,
2262 m_button_bar_label_colour
);
2267 } while(breaki
> 0);
2271 case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM
:
2273 int x_cursor
= rect
.x
+ 2;
2274 dc
.DrawBitmap(bitmap_small
, x_cursor
,
2275 rect
.y
+ (rect
.height
- bitmap_small
.GetHeight())/2, true);
2276 x_cursor
+= bitmap_small
.GetWidth() + 2;
2277 wxCoord label_w
, label_h
;
2278 dc
.GetTextExtent(label
, &label_w
, &label_h
);
2279 dc
.DrawText(label
, x_cursor
,
2280 rect
.y
+ (rect
.height
- label_h
) / 2);
2281 x_cursor
+= label_w
+ 3;
2282 if(kind
!= wxRIBBON_BUTTON_NORMAL
)
2284 DrawDropdownArrow(dc
, x_cursor
, rect
.y
+ rect
.height
/ 2,
2285 m_button_bar_label_colour
);
2295 void wxRibbonMSWArtProvider::DrawToolBarBackground(
2300 DrawPartialPageBackground(dc
, wnd
, rect
);
2303 void wxRibbonMSWArtProvider::DrawToolGroupBackground(
2305 wxWindow
* WXUNUSED(wnd
),
2308 dc
.SetPen(m_toolbar_border_pen
);
2310 outline
[0] = wxPoint(2, 0);
2311 outline
[1] = wxPoint(rect
.width
- 3, 0);
2312 outline
[2] = wxPoint(rect
.width
- 1, 2);
2313 outline
[3] = wxPoint(rect
.width
- 1, rect
.height
- 3);
2314 outline
[4] = wxPoint(rect
.width
- 3, rect
.height
- 1);
2315 outline
[5] = wxPoint(2, rect
.height
- 1);
2316 outline
[6] = wxPoint(0, rect
.height
- 3);
2317 outline
[7] = wxPoint(0, 2);
2318 outline
[8] = outline
[0];
2320 dc
.DrawLines(sizeof(outline
)/sizeof(wxPoint
), outline
, rect
.x
, rect
.y
);
2323 void wxRibbonMSWArtProvider::DrawTool(
2325 wxWindow
* WXUNUSED(wnd
),
2327 const wxBitmap
& bitmap
,
2328 wxRibbonButtonKind kind
,
2331 if(kind
== wxRIBBON_BUTTON_TOGGLE
)
2333 if(state
& wxRIBBON_TOOLBAR_TOOL_TOGGLED
)
2334 state
^= wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK
;
2337 wxRect
bg_rect(rect
);
2339 if((state
& wxRIBBON_TOOLBAR_TOOL_LAST
) == 0)
2341 bool is_split_hybrid
= (kind
== wxRIBBON_BUTTON_HYBRID
&& (state
&
2342 (wxRIBBON_TOOLBAR_TOOL_HOVER_MASK
| wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK
)));
2345 wxRect
bg_rect_top(bg_rect
);
2346 bg_rect_top
.height
= (bg_rect_top
.height
* 2) / 5;
2347 wxRect
bg_rect_btm(bg_rect
);
2348 bg_rect_btm
.y
+= bg_rect_top
.height
;
2349 bg_rect_btm
.height
-= bg_rect_top
.height
;
2350 wxColour bg_top_colour
= m_tool_background_top_colour
;
2351 wxColour bg_top_grad_colour
= m_tool_background_top_gradient_colour
;
2352 wxColour bg_colour
= m_tool_background_colour
;
2353 wxColour bg_grad_colour
= m_tool_background_gradient_colour
;
2354 if(state
& wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK
)
2356 bg_top_colour
= m_tool_active_background_top_colour
;
2357 bg_top_grad_colour
= m_tool_active_background_top_gradient_colour
;
2358 bg_colour
= m_tool_active_background_colour
;
2359 bg_grad_colour
= m_tool_active_background_gradient_colour
;
2361 else if(state
& wxRIBBON_TOOLBAR_TOOL_HOVER_MASK
)
2363 bg_top_colour
= m_tool_hover_background_top_colour
;
2364 bg_top_grad_colour
= m_tool_hover_background_top_gradient_colour
;
2365 bg_colour
= m_tool_hover_background_colour
;
2366 bg_grad_colour
= m_tool_hover_background_gradient_colour
;
2368 dc
.GradientFillLinear(bg_rect_top
, bg_top_colour
, bg_top_grad_colour
, wxSOUTH
);
2369 dc
.GradientFillLinear(bg_rect_btm
, bg_colour
, bg_grad_colour
, wxSOUTH
);
2372 wxRect
nonrect(bg_rect
);
2373 if(state
& (wxRIBBON_TOOLBAR_TOOL_DROPDOWN_HOVERED
|
2374 wxRIBBON_TOOLBAR_TOOL_DROPDOWN_ACTIVE
))
2380 nonrect
.x
+= nonrect
.width
- 8;
2383 wxBrush
B(m_tool_hover_background_top_colour
);
2384 dc
.SetPen(*wxTRANSPARENT_PEN
);
2386 dc
.DrawRectangle(nonrect
.x
, nonrect
.y
, nonrect
.width
, nonrect
.height
);
2390 dc
.SetPen(m_toolbar_border_pen
);
2391 if(state
& wxRIBBON_TOOLBAR_TOOL_FIRST
)
2393 dc
.DrawPoint(rect
.x
+ 1, rect
.y
+ 1);
2394 dc
.DrawPoint(rect
.x
+ 1, rect
.y
+ rect
.height
- 2);
2397 dc
.DrawLine(rect
.x
, rect
.y
+ 1, rect
.x
, rect
.y
+ rect
.height
- 1);
2399 if(state
& wxRIBBON_TOOLBAR_TOOL_LAST
)
2401 dc
.DrawPoint(rect
.x
+ rect
.width
- 2, rect
.y
+ 1);
2402 dc
.DrawPoint(rect
.x
+ rect
.width
- 2, rect
.y
+ rect
.height
- 2);
2406 int avail_width
= bg_rect
.GetWidth();
2407 if(kind
& wxRIBBON_BUTTON_DROPDOWN
)
2412 dc
.DrawLine(rect
.x
+ avail_width
+ 1, rect
.y
,
2413 rect
.x
+ avail_width
+ 1, rect
.y
+ rect
.height
);
2415 dc
.DrawBitmap(m_toolbar_drop_bitmap
, bg_rect
.x
+ avail_width
+ 2,
2416 bg_rect
.y
+ (bg_rect
.height
/ 2) - 2, true);
2418 dc
.DrawBitmap(bitmap
, bg_rect
.x
+ (avail_width
- bitmap
.GetWidth()) / 2,
2419 bg_rect
.y
+ (bg_rect
.height
- bitmap
.GetHeight()) / 2, true);
2422 void wxRibbonMSWArtProvider::GetBarTabWidth(
2424 wxWindow
* WXUNUSED(wnd
),
2425 const wxString
& label
,
2426 const wxBitmap
& bitmap
,
2428 int* small_begin_need_separator
,
2429 int* small_must_have_separator
,
2434 if((m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
) && !label
.IsEmpty())
2436 dc
.SetFont(m_tab_label_font
);
2437 width
+= dc
.GetTextExtent(label
).GetWidth();
2438 min
+= wxMin(25, width
); // enough for a few chars
2441 // gap between label and bitmap
2446 if((m_flags
& wxRIBBON_BAR_SHOW_PAGE_ICONS
) && bitmap
.IsOk())
2448 width
+= bitmap
.GetWidth();
2449 min
+= bitmap
.GetWidth();
2454 *ideal
= width
+ 30;
2456 if(small_begin_need_separator
!= NULL
)
2458 *small_begin_need_separator
= width
+ 20;
2460 if(small_must_have_separator
!= NULL
)
2462 *small_must_have_separator
= width
+ 10;
2470 int wxRibbonMSWArtProvider::GetTabCtrlHeight(
2472 wxWindow
* WXUNUSED(wnd
),
2473 const wxRibbonPageTabInfoArray
& pages
)
2475 int text_height
= 0;
2476 int icon_height
= 0;
2478 if(pages
.GetCount() <= 1 && (m_flags
& wxRIBBON_BAR_ALWAYS_SHOW_TABS
) == 0)
2480 // To preserve space, a single tab need not be displayed. We still need
2481 // two pixels of border / padding though.
2485 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
)
2487 dc
.SetFont(m_tab_label_font
);
2488 text_height
= dc
.GetTextExtent(wxT("ABCDEFXj")).GetHeight() + 10;
2490 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_ICONS
)
2492 size_t numpages
= pages
.GetCount();
2493 for(size_t i
= 0; i
< numpages
; ++i
)
2495 const wxRibbonPageTabInfo
& info
= pages
.Item(i
);
2496 if(info
.page
->GetIcon().IsOk())
2498 icon_height
= wxMax(icon_height
, info
.page
->GetIcon().GetHeight() + 4);
2503 return wxMax(text_height
, icon_height
);
2506 wxSize
wxRibbonMSWArtProvider::GetScrollButtonMinimumSize(
2508 wxWindow
* WXUNUSED(wnd
),
2509 long WXUNUSED(style
))
2511 return wxSize(12, 12);
2514 wxSize
wxRibbonMSWArtProvider::GetPanelSize(
2516 const wxRibbonPanel
* wnd
,
2518 wxPoint
* client_offset
)
2520 dc
.SetFont(m_panel_label_font
);
2521 wxSize label_size
= dc
.GetTextExtent(wnd
->GetLabel());
2523 client_size
.IncBy(0, label_size
.GetHeight());
2524 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2525 client_size
.IncBy(4, 8);
2527 client_size
.IncBy(6, 6);
2529 if(client_offset
!= NULL
)
2531 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2532 *client_offset
= wxPoint(2, 3);
2534 *client_offset
= wxPoint(3, 2);
2540 wxSize
wxRibbonMSWArtProvider::GetPanelClientSize(
2542 const wxRibbonPanel
* wnd
,
2544 wxPoint
* client_offset
)
2546 dc
.SetFont(m_panel_label_font
);
2547 wxSize label_size
= dc
.GetTextExtent(wnd
->GetLabel());
2549 size
.DecBy(0, label_size
.GetHeight());
2550 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2555 if(client_offset
!= NULL
)
2557 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2558 *client_offset
= wxPoint(2, 3);
2560 *client_offset
= wxPoint(3, 2);
2562 if (size
.x
< 0) size
.x
= 0;
2563 if (size
.y
< 0) size
.y
= 0;
2568 wxSize
wxRibbonMSWArtProvider::GetGallerySize(
2570 const wxRibbonGallery
* WXUNUSED(wnd
),
2573 client_size
.IncBy( 2, 1); // Left / top padding
2574 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2575 client_size
.IncBy(1, 16); // Right / bottom padding
2577 client_size
.IncBy(16, 1); // Right / bottom padding
2581 wxSize
wxRibbonMSWArtProvider::GetGalleryClientSize(
2583 const wxRibbonGallery
* WXUNUSED(wnd
),
2585 wxPoint
* client_offset
,
2586 wxRect
* scroll_up_button
,
2587 wxRect
* scroll_down_button
,
2588 wxRect
* extension_button
)
2593 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2595 // Flow is vertical - put buttons on bottom
2596 scroll_up
.y
= size
.GetHeight() - 15;
2597 scroll_up
.height
= 15;
2599 scroll_up
.width
= (size
.GetWidth() + 2) / 3;
2600 scroll_down
.y
= scroll_up
.y
;
2601 scroll_down
.height
= scroll_up
.height
;
2602 scroll_down
.x
= scroll_up
.x
+ scroll_up
.width
;
2603 scroll_down
.width
= scroll_up
.width
;
2604 extension
.y
= scroll_down
.y
;
2605 extension
.height
= scroll_down
.height
;
2606 extension
.x
= scroll_down
.x
+ scroll_down
.width
;
2607 extension
.width
= size
.GetWidth() - scroll_up
.width
- scroll_down
.width
;
2613 // Flow is horizontal - put buttons on right
2614 scroll_up
.x
= size
.GetWidth() - 15;
2615 scroll_up
.width
= 15;
2617 scroll_up
.height
= (size
.GetHeight() + 2) / 3;
2618 scroll_down
.x
= scroll_up
.x
;
2619 scroll_down
.width
= scroll_up
.width
;
2620 scroll_down
.y
= scroll_up
.y
+ scroll_up
.height
;
2621 scroll_down
.height
= scroll_up
.height
;
2622 extension
.x
= scroll_down
.x
;
2623 extension
.width
= scroll_down
.width
;
2624 extension
.y
= scroll_down
.y
+ scroll_down
.height
;
2625 extension
.height
= size
.GetHeight() - scroll_up
.height
- scroll_down
.height
;
2630 if(client_offset
!= NULL
)
2631 *client_offset
= wxPoint(2, 1);
2632 if(scroll_up_button
!= NULL
)
2633 *scroll_up_button
= scroll_up
;
2634 if(scroll_down_button
!= NULL
)
2635 *scroll_down_button
= scroll_down
;
2636 if(extension_button
!= NULL
)
2637 *extension_button
= extension
;
2642 wxRect
wxRibbonMSWArtProvider::GetPageBackgroundRedrawArea(
2644 const wxRibbonPage
* WXUNUSED(wnd
),
2645 wxSize page_old_size
,
2646 wxSize page_new_size
)
2648 wxRect new_rect
, old_rect
;
2650 if(page_new_size
.GetWidth() != page_old_size
.GetWidth())
2652 if(page_new_size
.GetHeight() != page_old_size
.GetHeight())
2654 // Width and height both changed - redraw everything
2655 return wxRect(page_new_size
);
2659 // Only width changed - redraw right hand side
2660 const int right_edge_width
= 4;
2662 new_rect
= wxRect(page_new_size
.GetWidth() - right_edge_width
, 0, right_edge_width
, page_new_size
.GetHeight());
2663 old_rect
= wxRect(page_old_size
.GetWidth() - right_edge_width
, 0, right_edge_width
, page_old_size
.GetHeight());
2668 if(page_new_size
.GetHeight() == page_old_size
.GetHeight())
2670 // Nothing changed (should never happen) - redraw nothing
2671 return wxRect(0, 0, 0, 0);
2675 // Height changed - need to redraw everything (as the background
2676 // gradient is done vertically).
2677 return page_new_size
;
2681 new_rect
.Union(old_rect
);
2682 new_rect
.Intersect(wxRect(page_new_size
));
2686 bool wxRibbonMSWArtProvider::GetButtonBarButtonSize(
2689 wxRibbonButtonKind kind
,
2690 wxRibbonButtonBarButtonState size
,
2691 const wxString
& label
,
2692 wxSize bitmap_size_large
,
2693 wxSize bitmap_size_small
,
2694 wxSize
* button_size
,
2695 wxRect
* normal_region
,
2696 wxRect
* dropdown_region
)
2698 const int drop_button_width
= 8;
2700 dc
.SetFont(m_button_bar_label_font
);
2701 switch(size
& wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK
)
2703 case wxRIBBON_BUTTONBAR_BUTTON_SMALL
:
2704 // Small bitmap, no label
2705 *button_size
= bitmap_size_small
+ wxSize(6, 4);
2708 case wxRIBBON_BUTTON_NORMAL
:
2709 case wxRIBBON_BUTTON_TOGGLE
:
2710 *normal_region
= wxRect(*button_size
);
2711 *dropdown_region
= wxRect(0, 0, 0, 0);
2713 case wxRIBBON_BUTTON_DROPDOWN
:
2714 *button_size
+= wxSize(drop_button_width
, 0);
2715 *dropdown_region
= wxRect(*button_size
);
2716 *normal_region
= wxRect(0, 0, 0, 0);
2718 case wxRIBBON_BUTTON_HYBRID
:
2719 *normal_region
= wxRect(*button_size
);
2720 *dropdown_region
= wxRect(button_size
->GetWidth(), 0,
2721 drop_button_width
, button_size
->GetHeight());
2722 *button_size
+= wxSize(drop_button_width
, 0);
2726 case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM
:
2727 // Small bitmap, with label to the right
2729 GetButtonBarButtonSize(dc
, wnd
, kind
, wxRIBBON_BUTTONBAR_BUTTON_SMALL
,
2730 label
, bitmap_size_large
, bitmap_size_small
, button_size
,
2731 normal_region
, dropdown_region
);
2732 int text_size
= dc
.GetTextExtent(label
).GetWidth();
2733 button_size
->SetWidth(button_size
->GetWidth() + text_size
);
2736 case wxRIBBON_BUTTON_DROPDOWN
:
2737 dropdown_region
->SetWidth(dropdown_region
->GetWidth() + text_size
);
2739 case wxRIBBON_BUTTON_HYBRID
:
2740 dropdown_region
->SetX(dropdown_region
->GetX() + text_size
);
2742 case wxRIBBON_BUTTON_NORMAL
:
2743 case wxRIBBON_BUTTON_TOGGLE
:
2744 normal_region
->SetWidth(normal_region
->GetWidth() + text_size
);
2749 case wxRIBBON_BUTTONBAR_BUTTON_LARGE
:
2750 // Large bitmap, with label below (possibly split over 2 lines)
2752 wxSize
icon_size(bitmap_size_large
);
2753 icon_size
+= wxSize(4, 4);
2754 wxCoord label_height
;
2756 dc
.GetTextExtent(label
, &best_width
, &label_height
);
2757 int last_line_extra_width
= 0;
2758 if(kind
!= wxRIBBON_BUTTON_NORMAL
&& kind
!= wxRIBBON_BUTTON_TOGGLE
)
2760 last_line_extra_width
+= 8;
2763 for(i
= 0; i
< label
.Len(); ++i
)
2765 if(wxRibbonCanLabelBreakAtPosition(label
, i
))
2768 dc
.GetTextExtent(label
.Mid(0, i
- 1)).GetWidth(),
2769 dc
.GetTextExtent(label
.Mid(i
+ 1)).GetWidth() + last_line_extra_width
);
2770 if(width
< best_width
)
2776 label_height
*= 2; // Assume two lines even when only one is used
2777 // (to give all buttons a consistent height)
2778 icon_size
.SetWidth(wxMax(icon_size
.GetWidth(), best_width
) + 6);
2779 icon_size
.SetHeight(icon_size
.GetHeight() + label_height
);
2780 *button_size
= icon_size
;
2783 case wxRIBBON_BUTTON_DROPDOWN
:
2784 *dropdown_region
= wxRect(icon_size
);
2786 case wxRIBBON_BUTTON_HYBRID
:
2787 *normal_region
= wxRect(icon_size
);
2788 normal_region
->height
-= 2 + label_height
;
2789 dropdown_region
->x
= 0;
2790 dropdown_region
->y
= normal_region
->height
;
2791 dropdown_region
->width
= icon_size
.GetWidth();
2792 dropdown_region
->height
= icon_size
.GetHeight() - normal_region
->height
;
2794 case wxRIBBON_BUTTON_NORMAL
:
2795 case wxRIBBON_BUTTON_TOGGLE
:
2796 *normal_region
= wxRect(icon_size
);
2805 wxSize
wxRibbonMSWArtProvider::GetMinimisedPanelMinimumSize(
2807 const wxRibbonPanel
* wnd
,
2808 wxSize
* desired_bitmap_size
,
2809 wxDirection
* expanded_panel_direction
)
2811 if(desired_bitmap_size
!= NULL
)
2813 *desired_bitmap_size
= wxSize(16, 16);
2815 if(expanded_panel_direction
!= NULL
)
2817 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2818 *expanded_panel_direction
= wxEAST
;
2820 *expanded_panel_direction
= wxSOUTH
;
2822 wxSize
base_size(42, 42);
2824 dc
.SetFont(m_panel_label_font
);
2825 wxSize
label_size(dc
.GetTextExtent(wnd
->GetLabel()));
2826 label_size
.IncBy(2, 2); // Allow for differences between this DC and a paint DC
2827 label_size
.IncBy(6, 0); // Padding
2828 label_size
.y
*= 2; // Second line for dropdown button
2830 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2832 // Label alongside icon
2833 return wxSize(base_size
.x
+ label_size
.x
,
2834 wxMax(base_size
.y
, label_size
.y
));
2838 // Label beneath icon
2839 return wxSize(wxMax(base_size
.x
, label_size
.x
),
2840 base_size
.y
+ label_size
.y
);
2844 wxSize
wxRibbonMSWArtProvider::GetToolSize(
2846 wxWindow
* WXUNUSED(wnd
),
2848 wxRibbonButtonKind kind
,
2849 bool WXUNUSED(is_first
),
2851 wxRect
* dropdown_region
)
2853 wxSize
size(bitmap_size
);
2857 if(kind
& wxRIBBON_BUTTON_DROPDOWN
)
2862 if(kind
== wxRIBBON_BUTTON_DROPDOWN
)
2863 *dropdown_region
= size
;
2865 *dropdown_region
= wxRect(size
.GetWidth() - 8, 0, 8, size
.GetHeight());
2871 *dropdown_region
= wxRect(0, 0, 0, 0);
2876 #endif // wxUSE_RIBBON