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
298 for(i
= 0; i
< 4; ++i
)
300 copy
->m_gallery_up_bitmap
[i
] = m_gallery_up_bitmap
[i
];
301 copy
->m_gallery_down_bitmap
[i
] = m_gallery_down_bitmap
[i
];
302 copy
->m_gallery_extension_bitmap
[i
] = m_gallery_extension_bitmap
[i
];
304 for(i
= 0; i
< 2; ++i
)
306 copy
->m_panel_extension_bitmap
[i
] = m_panel_extension_bitmap
[i
];
308 copy
->m_toolbar_drop_bitmap
= m_toolbar_drop_bitmap
;
310 copy
->m_primary_scheme_colour
= m_primary_scheme_colour
;
311 copy
->m_secondary_scheme_colour
= m_secondary_scheme_colour
;
312 copy
->m_tertiary_scheme_colour
= m_tertiary_scheme_colour
;
314 copy
->m_button_bar_label_colour
= m_button_bar_label_colour
;
315 copy
->m_tab_label_colour
= m_tab_label_colour
;
316 copy
->m_tab_separator_colour
= m_tab_separator_colour
;
317 copy
->m_tab_separator_gradient_colour
= m_tab_separator_gradient_colour
;
318 copy
->m_tab_active_background_colour
= m_tab_hover_background_colour
;
319 copy
->m_tab_active_background_gradient_colour
= m_tab_hover_background_gradient_colour
;
320 copy
->m_tab_hover_background_colour
= m_tab_hover_background_colour
;
321 copy
->m_tab_hover_background_gradient_colour
= m_tab_hover_background_gradient_colour
;
322 copy
->m_tab_hover_background_top_colour
= m_tab_hover_background_top_colour
;
323 copy
->m_tab_hover_background_top_gradient_colour
= m_tab_hover_background_top_gradient_colour
;
324 copy
->m_panel_label_colour
= m_panel_label_colour
;
325 copy
->m_panel_hover_label_colour
= m_panel_hover_label_colour
;
326 copy
->m_panel_minimised_label_colour
= m_panel_minimised_label_colour
;
327 copy
->m_panel_button_face_colour
= m_panel_button_face_colour
;
328 copy
->m_panel_button_hover_face_colour
= m_panel_button_hover_face_colour
;
329 copy
->m_panel_active_background_colour
= m_panel_active_background_colour
;
330 copy
->m_panel_active_background_gradient_colour
= m_panel_active_background_gradient_colour
;
331 copy
->m_panel_active_background_top_colour
= m_panel_active_background_top_colour
;
332 copy
->m_panel_active_background_top_gradient_colour
= m_panel_active_background_top_gradient_colour
;
333 copy
->m_page_background_colour
= m_page_background_colour
;
334 copy
->m_page_background_gradient_colour
= m_page_background_gradient_colour
;
335 copy
->m_page_background_top_colour
= m_page_background_top_colour
;
336 copy
->m_page_background_top_gradient_colour
= m_page_background_top_gradient_colour
;
337 copy
->m_page_hover_background_colour
= m_page_hover_background_colour
;
338 copy
->m_page_hover_background_gradient_colour
= m_page_hover_background_gradient_colour
;
339 copy
->m_page_hover_background_top_colour
= m_page_hover_background_top_colour
;
340 copy
->m_page_hover_background_top_gradient_colour
= m_page_hover_background_top_gradient_colour
;
341 copy
->m_button_bar_hover_background_colour
= m_button_bar_hover_background_colour
;
342 copy
->m_button_bar_hover_background_gradient_colour
= m_button_bar_hover_background_gradient_colour
;
343 copy
->m_button_bar_hover_background_top_colour
= m_button_bar_hover_background_top_colour
;
344 copy
->m_button_bar_hover_background_top_gradient_colour
= m_button_bar_hover_background_top_gradient_colour
;
345 copy
->m_button_bar_active_background_colour
= m_button_bar_active_background_colour
;
346 copy
->m_button_bar_active_background_gradient_colour
= m_button_bar_active_background_gradient_colour
;
347 copy
->m_button_bar_active_background_top_colour
= m_button_bar_active_background_top_colour
;
348 copy
->m_button_bar_active_background_top_gradient_colour
= m_button_bar_active_background_top_gradient_colour
;
349 copy
->m_gallery_button_background_colour
= m_gallery_button_background_colour
;
350 copy
->m_gallery_button_background_gradient_colour
= m_gallery_button_background_gradient_colour
;
351 copy
->m_gallery_button_hover_background_colour
= m_gallery_button_hover_background_colour
;
352 copy
->m_gallery_button_hover_background_gradient_colour
= m_gallery_button_hover_background_gradient_colour
;
353 copy
->m_gallery_button_active_background_colour
= m_gallery_button_active_background_colour
;
354 copy
->m_gallery_button_active_background_gradient_colour
= m_gallery_button_active_background_gradient_colour
;
355 copy
->m_gallery_button_disabled_background_colour
= m_gallery_button_disabled_background_colour
;
356 copy
->m_gallery_button_disabled_background_gradient_colour
= m_gallery_button_disabled_background_gradient_colour
;
357 copy
->m_gallery_button_face_colour
= m_gallery_button_face_colour
;
358 copy
->m_gallery_button_hover_face_colour
= m_gallery_button_hover_face_colour
;
359 copy
->m_gallery_button_active_face_colour
= m_gallery_button_active_face_colour
;
360 copy
->m_gallery_button_disabled_face_colour
= m_gallery_button_disabled_face_colour
;
362 copy
->m_tab_ctrl_background_brush
= m_tab_ctrl_background_brush
;
363 copy
->m_panel_label_background_brush
= m_panel_label_background_brush
;
364 copy
->m_panel_hover_label_background_brush
= m_panel_hover_label_background_brush
;
365 copy
->m_panel_hover_button_background_brush
= m_panel_hover_button_background_brush
;
366 copy
->m_gallery_hover_background_brush
= m_gallery_hover_background_brush
;
367 copy
->m_gallery_button_background_top_brush
= m_gallery_button_background_top_brush
;
368 copy
->m_gallery_button_hover_background_top_brush
= m_gallery_button_hover_background_top_brush
;
369 copy
->m_gallery_button_active_background_top_brush
= m_gallery_button_active_background_top_brush
;
370 copy
->m_gallery_button_disabled_background_top_brush
= m_gallery_button_disabled_background_top_brush
;
372 copy
->m_tab_label_font
= m_tab_label_font
;
373 copy
->m_button_bar_label_font
= m_button_bar_label_font
;
374 copy
->m_panel_label_font
= m_panel_label_font
;
376 copy
->m_page_border_pen
= m_page_border_pen
;
377 copy
->m_panel_border_pen
= m_panel_border_pen
;
378 copy
->m_panel_border_gradient_pen
= m_panel_border_gradient_pen
;
379 copy
->m_panel_minimised_border_pen
= m_panel_minimised_border_pen
;
380 copy
->m_panel_minimised_border_gradient_pen
= m_panel_minimised_border_gradient_pen
;
381 copy
->m_panel_hover_button_border_pen
= m_panel_hover_button_border_pen
;
382 copy
->m_tab_border_pen
= m_tab_border_pen
;
383 copy
->m_gallery_border_pen
= m_gallery_border_pen
;
384 copy
->m_button_bar_hover_border_pen
= m_button_bar_hover_border_pen
;
385 copy
->m_button_bar_active_border_pen
= m_button_bar_active_border_pen
;
386 copy
->m_gallery_item_border_pen
= m_gallery_item_border_pen
;
387 copy
->m_toolbar_border_pen
= m_toolbar_border_pen
;
389 copy
->m_flags
= m_flags
;
390 copy
->m_tab_separation_size
= m_tab_separation_size
;
391 copy
->m_page_border_left
= m_page_border_left
;
392 copy
->m_page_border_top
= m_page_border_top
;
393 copy
->m_page_border_right
= m_page_border_right
;
394 copy
->m_page_border_bottom
= m_page_border_bottom
;
395 copy
->m_panel_x_separation_size
= m_panel_x_separation_size
;
396 copy
->m_panel_y_separation_size
= m_panel_y_separation_size
;
397 copy
->m_gallery_bitmap_padding_left_size
= m_gallery_bitmap_padding_left_size
;
398 copy
->m_gallery_bitmap_padding_right_size
= m_gallery_bitmap_padding_right_size
;
399 copy
->m_gallery_bitmap_padding_top_size
= m_gallery_bitmap_padding_top_size
;
400 copy
->m_gallery_bitmap_padding_bottom_size
= m_gallery_bitmap_padding_bottom_size
;
403 long wxRibbonMSWArtProvider::GetFlags() const
408 void wxRibbonMSWArtProvider::SetFlags(long flags
)
410 if((flags
^ m_flags
) & wxRIBBON_BAR_FLOW_VERTICAL
)
412 if(flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
414 m_page_border_left
++;
415 m_page_border_right
++;
417 m_page_border_bottom
--;
421 m_page_border_left
--;
422 m_page_border_right
--;
424 m_page_border_bottom
++;
429 // Need to reload some bitmaps when flags change
430 #define Reload(setting) SetColour(setting, GetColour(setting))
431 Reload(wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR
);
432 Reload(wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR
);
433 Reload(wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR
);
434 Reload(wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR
);
435 Reload(wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR
);
436 Reload(wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR
);
440 int wxRibbonMSWArtProvider::GetMetric(int id
) const
444 case wxRIBBON_ART_TAB_SEPARATION_SIZE
:
445 return m_tab_separation_size
;
446 case wxRIBBON_ART_PAGE_BORDER_LEFT_SIZE
:
447 return m_page_border_left
;
448 case wxRIBBON_ART_PAGE_BORDER_TOP_SIZE
:
449 return m_page_border_top
;
450 case wxRIBBON_ART_PAGE_BORDER_RIGHT_SIZE
:
451 return m_page_border_right
;
452 case wxRIBBON_ART_PAGE_BORDER_BOTTOM_SIZE
:
453 return m_page_border_bottom
;
454 case wxRIBBON_ART_PANEL_X_SEPARATION_SIZE
:
455 return m_panel_x_separation_size
;
456 case wxRIBBON_ART_PANEL_Y_SEPARATION_SIZE
:
457 return m_panel_y_separation_size
;
458 case wxRIBBON_ART_TOOL_GROUP_SEPARATION_SIZE
:
459 return m_tool_group_separation_size
;
460 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_LEFT_SIZE
:
461 return m_gallery_bitmap_padding_left_size
;
462 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_RIGHT_SIZE
:
463 return m_gallery_bitmap_padding_right_size
;
464 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_TOP_SIZE
:
465 return m_gallery_bitmap_padding_top_size
;
466 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_BOTTOM_SIZE
:
467 return m_gallery_bitmap_padding_bottom_size
;
469 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
476 void wxRibbonMSWArtProvider::SetMetric(int id
, int new_val
)
480 case wxRIBBON_ART_TAB_SEPARATION_SIZE
:
481 m_tab_separation_size
= new_val
;
483 case wxRIBBON_ART_PAGE_BORDER_LEFT_SIZE
:
484 m_page_border_left
= new_val
;
486 case wxRIBBON_ART_PAGE_BORDER_TOP_SIZE
:
487 m_page_border_top
= new_val
;
489 case wxRIBBON_ART_PAGE_BORDER_RIGHT_SIZE
:
490 m_page_border_right
= new_val
;
492 case wxRIBBON_ART_PAGE_BORDER_BOTTOM_SIZE
:
493 m_page_border_bottom
= new_val
;
495 case wxRIBBON_ART_PANEL_X_SEPARATION_SIZE
:
496 m_panel_x_separation_size
= new_val
;
498 case wxRIBBON_ART_PANEL_Y_SEPARATION_SIZE
:
499 m_panel_y_separation_size
= new_val
;
501 case wxRIBBON_ART_TOOL_GROUP_SEPARATION_SIZE
:
502 m_tool_group_separation_size
= new_val
;
504 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_LEFT_SIZE
:
505 m_gallery_bitmap_padding_left_size
= new_val
;
507 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_RIGHT_SIZE
:
508 m_gallery_bitmap_padding_right_size
= new_val
;
510 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_TOP_SIZE
:
511 m_gallery_bitmap_padding_top_size
= new_val
;
513 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_BOTTOM_SIZE
:
514 m_gallery_bitmap_padding_bottom_size
= new_val
;
517 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
522 void wxRibbonMSWArtProvider::SetFont(int id
, const wxFont
& font
)
526 case wxRIBBON_ART_TAB_LABEL_FONT
:
527 m_tab_label_font
= font
;
529 case wxRIBBON_ART_BUTTON_BAR_LABEL_FONT
:
530 m_button_bar_label_font
= font
;
532 case wxRIBBON_ART_PANEL_LABEL_FONT
:
533 m_panel_label_font
= font
;
536 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
541 wxFont
wxRibbonMSWArtProvider::GetFont(int id
) const
545 case wxRIBBON_ART_TAB_LABEL_FONT
:
546 return m_tab_label_font
;
547 case wxRIBBON_ART_BUTTON_BAR_LABEL_FONT
:
548 return m_button_bar_label_font
;
549 case wxRIBBON_ART_PANEL_LABEL_FONT
:
550 return m_panel_label_font
;
552 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
559 wxColour
wxRibbonMSWArtProvider::GetColour(int id
) const
563 case wxRIBBON_ART_BUTTON_BAR_LABEL_COLOUR
:
564 return m_button_bar_label_colour
;
565 case wxRIBBON_ART_BUTTON_BAR_HOVER_BORDER_COLOUR
:
566 return m_button_bar_hover_border_pen
.GetColour();
567 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_COLOUR
:
568 return m_button_bar_hover_background_top_colour
;
569 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
570 return m_button_bar_hover_background_top_gradient_colour
;
571 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_COLOUR
:
572 return m_button_bar_hover_background_colour
;
573 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_GRADIENT_COLOUR
:
574 return m_button_bar_hover_background_gradient_colour
;
575 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BORDER_COLOUR
:
576 return m_button_bar_active_border_pen
.GetColour();
577 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_COLOUR
:
578 return m_button_bar_active_background_top_colour
;
579 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
580 return m_button_bar_active_background_top_gradient_colour
;
581 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_COLOUR
:
582 return m_button_bar_active_background_colour
;
583 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
584 return m_button_bar_active_background_gradient_colour
;
585 case wxRIBBON_ART_GALLERY_BORDER_COLOUR
:
586 return m_gallery_border_pen
.GetColour();
587 case wxRIBBON_ART_GALLERY_HOVER_BACKGROUND_COLOUR
:
588 return m_gallery_hover_background_brush
.GetColour();
589 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_COLOUR
:
590 return m_gallery_button_background_colour
;
591 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_GRADIENT_COLOUR
:
592 return m_gallery_button_background_gradient_colour
;
593 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_TOP_COLOUR
:
594 return m_gallery_button_background_top_brush
.GetColour();
595 case wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR
:
596 return m_gallery_button_face_colour
;
597 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_COLOUR
:
598 return m_gallery_button_hover_background_colour
;
599 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_GRADIENT_COLOUR
:
600 return m_gallery_button_hover_background_gradient_colour
;
601 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_TOP_COLOUR
:
602 return m_gallery_button_hover_background_top_brush
.GetColour();
603 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR
:
604 return m_gallery_button_face_colour
;
605 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_COLOUR
:
606 return m_gallery_button_active_background_colour
;
607 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
608 return m_gallery_button_active_background_gradient_colour
;
609 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_TOP_COLOUR
:
610 return m_gallery_button_background_top_brush
.GetColour();
611 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR
:
612 return m_gallery_button_active_face_colour
;
613 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_COLOUR
:
614 return m_gallery_button_disabled_background_colour
;
615 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_GRADIENT_COLOUR
:
616 return m_gallery_button_disabled_background_gradient_colour
;
617 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_TOP_COLOUR
:
618 return m_gallery_button_disabled_background_top_brush
.GetColour();
619 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR
:
620 return m_gallery_button_disabled_face_colour
;
621 case wxRIBBON_ART_GALLERY_ITEM_BORDER_COLOUR
:
622 return m_gallery_item_border_pen
.GetColour();
623 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_COLOUR
:
624 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_GRADIENT_COLOUR
:
625 return m_tab_ctrl_background_brush
.GetColour();
626 case wxRIBBON_ART_TAB_LABEL_COLOUR
:
627 return m_tab_label_colour
;
628 case wxRIBBON_ART_TAB_SEPARATOR_COLOUR
:
629 return m_tab_separator_colour
;
630 case wxRIBBON_ART_TAB_SEPARATOR_GRADIENT_COLOUR
:
631 return m_tab_separator_gradient_colour
;
632 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_COLOUR
:
633 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
634 return wxColour(0, 0, 0);
635 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_COLOUR
:
636 return m_tab_active_background_colour
;
637 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
638 return m_tab_active_background_gradient_colour
;
639 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_COLOUR
:
640 return m_tab_hover_background_top_colour
;
641 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
642 return m_tab_hover_background_top_gradient_colour
;
643 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_COLOUR
:
644 return m_tab_hover_background_colour
;
645 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_GRADIENT_COLOUR
:
646 return m_tab_hover_background_gradient_colour
;
647 case wxRIBBON_ART_TAB_BORDER_COLOUR
:
648 return m_tab_border_pen
.GetColour();
649 case wxRIBBON_ART_PANEL_BORDER_COLOUR
:
650 return m_panel_border_pen
.GetColour();
651 case wxRIBBON_ART_PANEL_BORDER_GRADIENT_COLOUR
:
652 return m_panel_border_gradient_pen
.GetColour();
653 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_COLOUR
:
654 return m_panel_minimised_border_pen
.GetColour();
655 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_GRADIENT_COLOUR
:
656 return m_panel_minimised_border_gradient_pen
.GetColour();
657 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_COLOUR
:
658 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_GRADIENT_COLOUR
:
659 return m_panel_label_background_brush
.GetColour();
660 case wxRIBBON_ART_PANEL_LABEL_COLOUR
:
661 return m_panel_label_colour
;
662 case wxRIBBON_ART_PANEL_MINIMISED_LABEL_COLOUR
:
663 return m_panel_minimised_label_colour
;
664 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_COLOUR
:
665 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_GRADIENT_COLOUR
:
666 return m_panel_hover_label_background_brush
.GetColour();
667 case wxRIBBON_ART_PANEL_HOVER_LABEL_COLOUR
:
668 return m_panel_hover_label_colour
;
669 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_COLOUR
:
670 return m_panel_active_background_top_colour
;
671 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
672 return m_panel_active_background_top_gradient_colour
;
673 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_COLOUR
:
674 return m_panel_active_background_colour
;
675 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
676 return m_panel_active_background_gradient_colour
;
677 case wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR
:
678 return m_panel_button_face_colour
;
679 case wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR
:
680 return m_panel_button_hover_face_colour
;
681 case wxRIBBON_ART_PAGE_BORDER_COLOUR
:
682 return m_page_border_pen
.GetColour();
683 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_COLOUR
:
684 return m_page_background_top_colour
;
685 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_GRADIENT_COLOUR
:
686 return m_page_background_top_gradient_colour
;
687 case wxRIBBON_ART_PAGE_BACKGROUND_COLOUR
:
688 return m_page_background_colour
;
689 case wxRIBBON_ART_PAGE_BACKGROUND_GRADIENT_COLOUR
:
690 return m_page_background_gradient_colour
;
691 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_COLOUR
:
692 return m_page_hover_background_top_colour
;
693 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
694 return m_page_hover_background_top_gradient_colour
;
695 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_COLOUR
:
696 return m_page_hover_background_colour
;
697 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_GRADIENT_COLOUR
:
698 return m_page_hover_background_gradient_colour
;
699 case wxRIBBON_ART_TOOLBAR_BORDER_COLOUR
:
700 case wxRIBBON_ART_TOOLBAR_HOVER_BORDER_COLOUR
:
701 return m_toolbar_border_pen
.GetColour();
702 case wxRIBBON_ART_TOOLBAR_FACE_COLOUR
:
703 return m_tool_face_colour
;
705 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
712 void wxRibbonMSWArtProvider::SetColour(int id
, const wxColor
& colour
)
716 case wxRIBBON_ART_BUTTON_BAR_LABEL_COLOUR
:
717 m_button_bar_label_colour
= colour
;
719 case wxRIBBON_ART_BUTTON_BAR_HOVER_BORDER_COLOUR
:
720 m_button_bar_hover_border_pen
.SetColour(colour
);
722 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_COLOUR
:
723 m_button_bar_hover_background_top_colour
= colour
;
725 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
726 m_button_bar_hover_background_top_gradient_colour
= colour
;
728 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_COLOUR
:
729 m_button_bar_hover_background_colour
= colour
;
731 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_GRADIENT_COLOUR
:
732 m_button_bar_hover_background_gradient_colour
= colour
;
734 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BORDER_COLOUR
:
735 m_button_bar_active_border_pen
.SetColour(colour
);
737 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_COLOUR
:
738 m_button_bar_active_background_top_colour
= colour
;
740 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
741 m_button_bar_active_background_top_gradient_colour
= colour
;
743 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_COLOUR
:
744 m_button_bar_active_background_colour
= colour
;
746 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
747 m_button_bar_active_background_gradient_colour
= colour
;
749 case wxRIBBON_ART_GALLERY_BORDER_COLOUR
:
750 m_gallery_border_pen
.SetColour(colour
);
752 case wxRIBBON_ART_GALLERY_HOVER_BACKGROUND_COLOUR
:
753 m_gallery_hover_background_brush
.SetColour(colour
);
755 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_COLOUR
:
756 m_gallery_button_background_colour
= colour
;
758 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_GRADIENT_COLOUR
:
759 m_gallery_button_background_gradient_colour
= colour
;
761 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_TOP_COLOUR
:
762 m_gallery_button_background_top_brush
.SetColour(colour
);
764 case wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR
:
765 m_gallery_button_face_colour
= colour
;
766 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
768 m_gallery_up_bitmap
[0] = wxRibbonLoadPixmap(gallery_left_xpm
, colour
);
769 m_gallery_down_bitmap
[0] = wxRibbonLoadPixmap(gallery_right_xpm
, colour
);
773 m_gallery_up_bitmap
[0] = wxRibbonLoadPixmap(gallery_up_xpm
, colour
);
774 m_gallery_down_bitmap
[0] = wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
776 m_gallery_extension_bitmap
[0] = wxRibbonLoadPixmap(gallery_extension_xpm
, colour
);
778 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_COLOUR
:
779 m_gallery_button_hover_background_colour
= colour
;
781 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_GRADIENT_COLOUR
:
782 m_gallery_button_hover_background_gradient_colour
= colour
;
784 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_TOP_COLOUR
:
785 m_gallery_button_hover_background_top_brush
.SetColour(colour
);
787 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR
:
788 m_gallery_button_hover_face_colour
= colour
;
789 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
791 m_gallery_up_bitmap
[1] = wxRibbonLoadPixmap(gallery_left_xpm
, colour
);
792 m_gallery_down_bitmap
[1] = wxRibbonLoadPixmap(gallery_right_xpm
, colour
);
796 m_gallery_up_bitmap
[1] = wxRibbonLoadPixmap(gallery_up_xpm
, colour
);
797 m_gallery_down_bitmap
[1] = wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
799 m_gallery_extension_bitmap
[1] = wxRibbonLoadPixmap(gallery_extension_xpm
, colour
);
801 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_COLOUR
:
802 m_gallery_button_active_background_colour
= colour
;
804 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
805 m_gallery_button_active_background_gradient_colour
= colour
;
807 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_TOP_COLOUR
:
808 m_gallery_button_background_top_brush
.SetColour(colour
);
810 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR
:
811 m_gallery_button_active_face_colour
= colour
;
812 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
814 m_gallery_up_bitmap
[2] = wxRibbonLoadPixmap(gallery_left_xpm
, colour
);
815 m_gallery_down_bitmap
[2] = wxRibbonLoadPixmap(gallery_right_xpm
, colour
);
819 m_gallery_up_bitmap
[2] = wxRibbonLoadPixmap(gallery_up_xpm
, colour
);
820 m_gallery_down_bitmap
[2] = wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
822 m_gallery_extension_bitmap
[2] = wxRibbonLoadPixmap(gallery_extension_xpm
, colour
);
824 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_COLOUR
:
825 m_gallery_button_disabled_background_colour
= colour
;
827 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_GRADIENT_COLOUR
:
828 m_gallery_button_disabled_background_gradient_colour
= colour
;
830 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_TOP_COLOUR
:
831 m_gallery_button_disabled_background_top_brush
.SetColour(colour
);
833 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR
:
834 m_gallery_button_disabled_face_colour
= colour
;
835 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
837 m_gallery_up_bitmap
[3] = wxRibbonLoadPixmap(gallery_left_xpm
, colour
);
838 m_gallery_down_bitmap
[3] = wxRibbonLoadPixmap(gallery_right_xpm
, colour
);
842 m_gallery_up_bitmap
[3] = wxRibbonLoadPixmap(gallery_up_xpm
, colour
);
843 m_gallery_down_bitmap
[3] = wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
845 m_gallery_extension_bitmap
[3] = wxRibbonLoadPixmap(gallery_extension_xpm
, colour
);
847 case wxRIBBON_ART_GALLERY_ITEM_BORDER_COLOUR
:
848 m_gallery_item_border_pen
.SetColour(colour
);
850 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_COLOUR
:
851 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_GRADIENT_COLOUR
:
852 m_tab_ctrl_background_brush
.SetColour(colour
);
853 m_cached_tab_separator_visibility
= -1.0;
855 case wxRIBBON_ART_TAB_LABEL_COLOUR
:
856 m_tab_label_colour
= colour
;
858 case wxRIBBON_ART_TAB_SEPARATOR_COLOUR
:
859 m_tab_separator_colour
= colour
;
860 m_cached_tab_separator_visibility
= -1.0;
862 case wxRIBBON_ART_TAB_SEPARATOR_GRADIENT_COLOUR
:
863 m_tab_separator_gradient_colour
= colour
;
864 m_cached_tab_separator_visibility
= -1.0;
866 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_COLOUR
:
867 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
869 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_COLOUR
:
870 m_tab_active_background_colour
= colour
;
872 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
873 m_tab_active_background_gradient_colour
= colour
;
875 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_COLOUR
:
876 m_tab_hover_background_top_colour
= colour
;
878 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
879 m_tab_hover_background_top_gradient_colour
= colour
;
881 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_COLOUR
:
882 m_tab_hover_background_colour
= colour
;
884 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_GRADIENT_COLOUR
:
885 m_tab_hover_background_gradient_colour
= colour
;
887 case wxRIBBON_ART_TAB_BORDER_COLOUR
:
888 m_tab_border_pen
.SetColour(colour
);
890 case wxRIBBON_ART_PANEL_BORDER_COLOUR
:
891 m_panel_border_pen
.SetColour(colour
);
893 case wxRIBBON_ART_PANEL_BORDER_GRADIENT_COLOUR
:
894 m_panel_border_gradient_pen
.SetColour(colour
);
896 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_COLOUR
:
897 m_panel_minimised_border_pen
.SetColour(colour
);
899 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_GRADIENT_COLOUR
:
900 m_panel_minimised_border_gradient_pen
.SetColour(colour
);
902 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_COLOUR
:
903 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_GRADIENT_COLOUR
:
904 m_panel_label_background_brush
.SetColour(colour
);
906 case wxRIBBON_ART_PANEL_LABEL_COLOUR
:
907 m_panel_label_colour
= colour
;
909 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_COLOUR
:
910 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_GRADIENT_COLOUR
:
911 m_panel_hover_label_background_brush
.SetColour(colour
);
913 case wxRIBBON_ART_PANEL_HOVER_LABEL_COLOUR
:
914 m_panel_hover_label_colour
= colour
;
916 case wxRIBBON_ART_PANEL_MINIMISED_LABEL_COLOUR
:
917 m_panel_minimised_label_colour
= colour
;
919 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_COLOUR
:
920 m_panel_active_background_top_colour
= colour
;
922 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR
:
923 m_panel_active_background_top_gradient_colour
= colour
;
925 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_COLOUR
:
926 m_panel_active_background_colour
= colour
;
928 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_GRADIENT_COLOUR
:
929 m_panel_active_background_gradient_colour
= colour
;
931 case wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR
:
932 m_panel_button_face_colour
= colour
;
933 m_panel_extension_bitmap
[0] = wxRibbonLoadPixmap(panel_extension_xpm
, colour
);
935 case wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR
:
936 m_panel_button_hover_face_colour
= colour
;
937 m_panel_extension_bitmap
[1] = wxRibbonLoadPixmap(panel_extension_xpm
, colour
);
939 case wxRIBBON_ART_PAGE_BORDER_COLOUR
:
940 m_page_border_pen
.SetColour(colour
);
942 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_COLOUR
:
943 m_page_background_top_colour
= colour
;
945 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_GRADIENT_COLOUR
:
946 m_page_background_top_gradient_colour
= colour
;
948 case wxRIBBON_ART_PAGE_BACKGROUND_COLOUR
:
949 m_page_background_colour
= colour
;
951 case wxRIBBON_ART_PAGE_BACKGROUND_GRADIENT_COLOUR
:
952 m_page_background_gradient_colour
= colour
;
954 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_COLOUR
:
955 m_page_hover_background_top_colour
= colour
;
957 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR
:
958 m_page_hover_background_top_gradient_colour
= colour
;
960 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_COLOUR
:
961 m_page_hover_background_colour
= colour
;
963 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_GRADIENT_COLOUR
:
964 m_page_hover_background_gradient_colour
= colour
;
966 case wxRIBBON_ART_TOOLBAR_BORDER_COLOUR
:
967 case wxRIBBON_ART_TOOLBAR_HOVER_BORDER_COLOUR
:
968 m_toolbar_border_pen
.SetColour(colour
);
970 case wxRIBBON_ART_TOOLBAR_FACE_COLOUR
:
971 m_tool_face_colour
= colour
;
972 m_toolbar_drop_bitmap
= wxRibbonLoadPixmap(gallery_down_xpm
, colour
);
975 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
980 void wxRibbonMSWArtProvider::DrawTabCtrlBackground(
982 wxWindow
* WXUNUSED(wnd
),
985 dc
.SetPen(*wxTRANSPARENT_PEN
);
986 dc
.SetBrush(m_tab_ctrl_background_brush
);
987 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
989 dc
.SetPen(m_page_border_pen
);
992 dc
.DrawLine(rect
.x
+ 3, rect
.y
+ rect
.height
- 1, rect
.x
+ rect
.width
- 3, rect
.y
+ rect
.height
- 1);
996 dc
.DrawLine(rect
.x
, rect
.y
+ rect
.height
- 1, rect
.x
+ rect
.width
, rect
.y
+ rect
.height
- 1);
1000 void wxRibbonMSWArtProvider::DrawTab(
1002 wxWindow
* WXUNUSED(wnd
),
1003 const wxRibbonPageTabInfo
& tab
)
1005 if(tab
.rect
.height
<= 2)
1008 if(tab
.active
|| tab
.hovered
)
1012 wxRect
background(tab
.rect
);
1016 background
.width
-= 4;
1017 background
.height
-= 2;
1019 dc
.GradientFillLinear(background
, m_tab_active_background_colour
,
1020 m_tab_active_background_gradient_colour
, wxSOUTH
);
1022 // TODO: active and hovered
1024 else if(tab
.hovered
)
1026 wxRect
background(tab
.rect
);
1030 background
.width
-= 4;
1031 background
.height
-= 3;
1032 int h
= background
.height
;
1033 background
.height
/= 2;
1034 dc
.GradientFillLinear(background
,
1035 m_tab_hover_background_top_colour
,
1036 m_tab_hover_background_top_gradient_colour
, wxSOUTH
);
1038 background
.y
+= background
.height
;
1039 background
.height
= h
- background
.height
;
1040 dc
.GradientFillLinear(background
, m_tab_hover_background_colour
,
1041 m_tab_hover_background_gradient_colour
, wxSOUTH
);
1044 wxPoint border_points
[6];
1045 border_points
[0] = wxPoint(1, tab
.rect
.height
- 2);
1046 border_points
[1] = wxPoint(1, 3);
1047 border_points
[2] = wxPoint(3, 1);
1048 border_points
[3] = wxPoint(tab
.rect
.width
- 4, 1);
1049 border_points
[4] = wxPoint(tab
.rect
.width
- 2, 3);
1050 border_points
[5] = wxPoint(tab
.rect
.width
- 2, tab
.rect
.height
- 1);
1052 dc
.SetPen(m_tab_border_pen
);
1053 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
, tab
.rect
.x
, tab
.rect
.y
);
1057 // Give the tab a curved outward border at the bottom
1058 dc
.DrawPoint(tab
.rect
.x
, tab
.rect
.y
+ tab
.rect
.height
- 2);
1059 dc
.DrawPoint(tab
.rect
.x
+ tab
.rect
.width
- 1, tab
.rect
.y
+ tab
.rect
.height
- 2);
1061 wxPen
p(m_tab_active_background_gradient_colour
);
1064 // Technically the first two points are the wrong colour, but they're near enough
1065 dc
.DrawPoint(tab
.rect
.x
+ 1, tab
.rect
.y
+ tab
.rect
.height
- 2);
1066 dc
.DrawPoint(tab
.rect
.x
+ tab
.rect
.width
- 2, tab
.rect
.y
+ tab
.rect
.height
- 2);
1067 dc
.DrawPoint(tab
.rect
.x
+ 1, tab
.rect
.y
+ tab
.rect
.height
- 1);
1068 dc
.DrawPoint(tab
.rect
.x
, tab
.rect
.y
+ tab
.rect
.height
- 1);
1069 dc
.DrawPoint(tab
.rect
.x
+ tab
.rect
.width
- 2, tab
.rect
.y
+ tab
.rect
.height
- 1);
1070 dc
.DrawPoint(tab
.rect
.x
+ tab
.rect
.width
- 1, tab
.rect
.y
+ tab
.rect
.height
- 1);
1074 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_ICONS
)
1076 wxBitmap icon
= tab
.page
->GetIcon();
1079 int x
= tab
.rect
.x
+ 4;
1080 if((m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
) == 0)
1081 x
= tab
.rect
.x
+ (tab
.rect
.width
- icon
.GetWidth()) / 2;
1082 dc
.DrawBitmap(icon
, x
, tab
.rect
.y
+ 1 + (tab
.rect
.height
- 1 -
1083 icon
.GetHeight()) / 2, true);
1086 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
)
1088 wxString label
= tab
.page
->GetLabel();
1089 if(!label
.IsEmpty())
1091 dc
.SetFont(m_tab_label_font
);
1092 dc
.SetTextForeground(m_tab_label_colour
);
1093 dc
.SetBackgroundMode(wxTRANSPARENT
);
1097 dc
.GetTextExtent(label
, &text_width
, &text_height
);
1098 int width
= tab
.rect
.width
- 5;
1099 int x
= tab
.rect
.x
+ 3;
1100 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_ICONS
)
1102 x
+= 3 + tab
.page
->GetIcon().GetWidth();
1103 width
-= 3 + tab
.page
->GetIcon().GetWidth();
1105 int y
= tab
.rect
.y
+ (tab
.rect
.height
- text_height
) / 2;
1107 if(width
<= text_width
)
1109 dc
.SetClippingRegion(x
, tab
.rect
.y
, width
, tab
.rect
.height
);
1110 dc
.DrawText(label
, x
, y
);
1114 dc
.DrawText(label
, x
+ (width
- text_width
) / 2 + 1, y
);
1120 void wxRibbonMSWArtProvider::DrawTabSeparator(
1126 if(visibility
<= 0.0)
1130 if(visibility
> 1.0)
1135 // The tab separator is relatively expensive to draw (for its size), and is
1136 // usually drawn multiple times sequentially (in different positions), so it
1137 // makes sense to draw it once and cache it.
1138 if(!m_cached_tab_separator
.IsOk() || m_cached_tab_separator
.GetSize() != rect
.GetSize() || visibility
!= m_cached_tab_separator_visibility
)
1140 wxRect
size(rect
.GetSize());
1141 ReallyDrawTabSeparator(wnd
, size
, visibility
);
1143 dc
.DrawBitmap(m_cached_tab_separator
, rect
.x
, rect
.y
, false);
1146 void wxRibbonMSWArtProvider::ReallyDrawTabSeparator(wxWindow
* wnd
, const wxRect
& rect
, double visibility
)
1148 if(!m_cached_tab_separator
.IsOk() || m_cached_tab_separator
.GetSize() != rect
.GetSize())
1150 m_cached_tab_separator
= wxBitmap(rect
.GetSize());
1153 wxMemoryDC
dc(m_cached_tab_separator
);
1154 DrawTabCtrlBackground(dc
, wnd
, rect
);
1156 wxCoord x
= rect
.x
+ rect
.width
/ 2;
1157 double h
= (double)(rect
.height
- 1);
1159 double r1
= m_tab_ctrl_background_brush
.GetColour().Red() * (1.0 - visibility
) + 0.5;
1160 double g1
= m_tab_ctrl_background_brush
.GetColour().Green() * (1.0 - visibility
) + 0.5;
1161 double b1
= m_tab_ctrl_background_brush
.GetColour().Blue() * (1.0 - visibility
) + 0.5;
1162 double r2
= m_tab_separator_colour
.Red();
1163 double g2
= m_tab_separator_colour
.Green();
1164 double b2
= m_tab_separator_colour
.Blue();
1165 double r3
= m_tab_separator_gradient_colour
.Red();
1166 double g3
= m_tab_separator_gradient_colour
.Green();
1167 double b3
= m_tab_separator_gradient_colour
.Blue();
1169 for(int i
= 0; i
< rect
.height
- 1; ++i
)
1171 double p
= ((double)i
)/h
;
1173 double r
= (p
* r3
+ (1.0 - p
) * r2
) * visibility
+ r1
;
1174 double g
= (p
* g3
+ (1.0 - p
) * g2
) * visibility
+ g1
;
1175 double b
= (p
* b3
+ (1.0 - p
) * b2
) * visibility
+ b1
;
1177 wxPen
P(wxColour((unsigned char)r
, (unsigned char)g
, (unsigned char)b
));
1179 dc
.DrawPoint(x
, rect
.y
+ i
);
1182 m_cached_tab_separator_visibility
= visibility
;
1185 void wxRibbonMSWArtProvider::DrawPartialPageBackground(wxDC
& dc
,
1186 wxWindow
* wnd
, const wxRect
& rect
, wxRibbonPage
* page
,
1187 wxPoint offset
, bool hovered
)
1190 // Expanded panels need a background - the expanded panel at
1191 // best size may have a greater Y dimension higher than when
1192 // on the bar if it has a sizer. AUI art provider does not need this
1193 // because it paints the panel without reference to its parent's size.
1194 // Expanded panels use a wxFrame as parent (not a wxRibbonPage).
1196 if(wnd
->GetSizer() && wnd
->GetParent() != page
)
1198 background
= wnd
->GetParent()->GetSize();
1199 offset
= wxPoint(0,0);
1203 background
= page
->GetSize();
1204 page
->AdjustRectToIncludeScrollButtons(&background
);
1205 background
.height
-= 2;
1207 // Page background isn't dependant upon the width of the page
1208 // (at least not the part of it intended to be painted by this
1209 // function). Set to wider than the page itself for when externally
1210 // expanded panels need a background - the expanded panel can be wider
1213 background
.width
= INT_MAX
;
1215 // upper_rect, lower_rect, paint_rect are all in page co-ordinates
1216 wxRect
upper_rect(background
);
1217 upper_rect
.height
/= 5;
1219 wxRect
lower_rect(background
);
1220 lower_rect
.y
+= upper_rect
.height
;
1221 lower_rect
.height
-= upper_rect
.height
;
1223 wxRect
paint_rect(rect
);
1224 paint_rect
.x
+= offset
.x
;
1225 paint_rect
.y
+= offset
.y
;
1227 wxColour bg_top
, bg_top_grad
, bg_btm
, bg_btm_grad
;
1230 bg_top
= m_page_hover_background_top_colour
;
1231 bg_top_grad
= m_page_hover_background_top_gradient_colour
;
1232 bg_btm
= m_page_hover_background_colour
;
1233 bg_btm_grad
= m_page_hover_background_gradient_colour
;
1237 bg_top
= m_page_background_top_colour
;
1238 bg_top_grad
= m_page_background_top_gradient_colour
;
1239 bg_btm
= m_page_background_colour
;
1240 bg_btm_grad
= m_page_background_gradient_colour
;
1243 if(paint_rect
.Intersects(upper_rect
))
1245 wxRect
rect(upper_rect
);
1246 rect
.Intersect(paint_rect
);
1249 wxColour
starting_colour(wxRibbonInterpolateColour(bg_top
, bg_top_grad
,
1250 paint_rect
.y
, upper_rect
.y
, upper_rect
.y
+ upper_rect
.height
));
1251 wxColour
ending_colour(wxRibbonInterpolateColour(bg_top
, bg_top_grad
,
1252 paint_rect
.y
+ paint_rect
.height
, upper_rect
.y
,
1253 upper_rect
.y
+ upper_rect
.height
));
1254 dc
.GradientFillLinear(rect
, starting_colour
, ending_colour
, wxSOUTH
);
1257 if(paint_rect
.Intersects(lower_rect
))
1259 wxRect
rect(lower_rect
);
1260 rect
.Intersect(paint_rect
);
1263 wxColour
starting_colour(wxRibbonInterpolateColour(bg_btm
, bg_btm_grad
,
1264 paint_rect
.y
, lower_rect
.y
, lower_rect
.y
+ lower_rect
.height
));
1265 wxColour
ending_colour(wxRibbonInterpolateColour(bg_btm
, bg_btm_grad
,
1266 paint_rect
.y
+ paint_rect
.height
,
1267 lower_rect
.y
, lower_rect
.y
+ lower_rect
.height
));
1268 dc
.GradientFillLinear(rect
, starting_colour
, ending_colour
, wxSOUTH
);
1272 void wxRibbonMSWArtProvider::DrawPageBackground(
1274 wxWindow
* WXUNUSED(wnd
),
1277 dc
.SetPen(*wxTRANSPARENT_PEN
);
1278 dc
.SetBrush(m_tab_ctrl_background_brush
);
1284 dc
.DrawRectangle(edge
.x
, edge
.y
, edge
.width
, edge
.height
);
1286 edge
.x
+= rect
.width
- 2;
1287 dc
.DrawRectangle(edge
.x
, edge
.y
, edge
.width
, edge
.height
);
1291 edge
.y
+= (rect
.height
- edge
.height
);
1292 dc
.DrawRectangle(edge
.x
, edge
.y
, edge
.width
, edge
.height
);
1296 wxRect
background(rect
);
1298 background
.width
-= 4;
1299 background
.height
-= 2;
1301 background
.height
/= 5;
1302 dc
.GradientFillLinear(background
, m_page_background_top_colour
,
1303 m_page_background_top_gradient_colour
, wxSOUTH
);
1305 background
.y
+= background
.height
;
1306 background
.height
= rect
.height
- 2 - background
.height
;
1307 dc
.GradientFillLinear(background
, m_page_background_colour
,
1308 m_page_background_gradient_colour
, wxSOUTH
);
1312 wxPoint border_points
[8];
1313 border_points
[0] = wxPoint(2, 0);
1314 border_points
[1] = wxPoint(1, 1);
1315 border_points
[2] = wxPoint(1, rect
.height
- 4);
1316 border_points
[3] = wxPoint(3, rect
.height
- 2);
1317 border_points
[4] = wxPoint(rect
.width
- 4, rect
.height
- 2);
1318 border_points
[5] = wxPoint(rect
.width
- 2, rect
.height
- 4);
1319 border_points
[6] = wxPoint(rect
.width
- 2, 1);
1320 border_points
[7] = wxPoint(rect
.width
- 4, -1);
1322 dc
.SetPen(m_page_border_pen
);
1323 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
, rect
.x
, rect
.y
);
1327 void wxRibbonMSWArtProvider::DrawScrollButton(
1329 wxWindow
* WXUNUSED(wnd
),
1330 const wxRect
& rect_
,
1335 if((style
& wxRIBBON_SCROLL_BTN_FOR_MASK
) == wxRIBBON_SCROLL_BTN_FOR_PAGE
)
1337 // Page scroll buttons do not have the luxury of rendering on top of anything
1338 // else, and their size includes some padding, hence the background painting
1339 // and size adjustment.
1340 dc
.SetPen(*wxTRANSPARENT_PEN
);
1341 dc
.SetBrush(m_tab_ctrl_background_brush
);
1342 dc
.DrawRectangle(rect
);
1343 dc
.SetClippingRegion(rect
);
1344 switch(style
& wxRIBBON_SCROLL_BTN_DIRECTION_MASK
)
1346 case wxRIBBON_SCROLL_BTN_LEFT
:
1348 case wxRIBBON_SCROLL_BTN_RIGHT
:
1352 case wxRIBBON_SCROLL_BTN_UP
:
1358 case wxRIBBON_SCROLL_BTN_DOWN
:
1367 wxRect
background(rect
);
1370 background
.width
-= 2;
1371 background
.height
-= 2;
1373 if(style
& wxRIBBON_SCROLL_BTN_UP
)
1374 background
.height
/= 2;
1376 background
.height
/= 5;
1377 dc
.GradientFillLinear(background
, m_page_background_top_colour
,
1378 m_page_background_top_gradient_colour
, wxSOUTH
);
1380 background
.y
+= background
.height
;
1381 background
.height
= rect
.height
- 2 - background
.height
;
1382 dc
.GradientFillLinear(background
, m_page_background_colour
,
1383 m_page_background_gradient_colour
, wxSOUTH
);
1387 wxPoint border_points
[7];
1388 switch(style
& wxRIBBON_SCROLL_BTN_DIRECTION_MASK
)
1390 case wxRIBBON_SCROLL_BTN_LEFT
:
1391 border_points
[0] = wxPoint(2, 0);
1392 border_points
[1] = wxPoint(rect
.width
- 1, 0);
1393 border_points
[2] = wxPoint(rect
.width
- 1, rect
.height
- 1);
1394 border_points
[3] = wxPoint(2, rect
.height
- 1);
1395 border_points
[4] = wxPoint(0, rect
.height
- 3);
1396 border_points
[5] = wxPoint(0, 2);
1398 case wxRIBBON_SCROLL_BTN_RIGHT
:
1399 border_points
[0] = wxPoint(0, 0);
1400 border_points
[1] = wxPoint(rect
.width
- 3, 0);
1401 border_points
[2] = wxPoint(rect
.width
- 1, 2);
1402 border_points
[3] = wxPoint(rect
.width
- 1, rect
.height
- 3);
1403 border_points
[4] = wxPoint(rect
.width
- 3, rect
.height
- 1);
1404 border_points
[5] = wxPoint(0, rect
.height
- 1);
1406 case wxRIBBON_SCROLL_BTN_UP
:
1407 border_points
[0] = wxPoint(2, 0);
1408 border_points
[1] = wxPoint(rect
.width
- 3, 0);
1409 border_points
[2] = wxPoint(rect
.width
- 1, 2);
1410 border_points
[3] = wxPoint(rect
.width
- 1, rect
.height
- 1);
1411 border_points
[4] = wxPoint(0, rect
.height
- 1);
1412 border_points
[5] = wxPoint(0, 2);
1414 case wxRIBBON_SCROLL_BTN_DOWN
:
1415 border_points
[0] = wxPoint(0, 0);
1416 border_points
[1] = wxPoint(rect
.width
- 1, 0);
1417 border_points
[2] = wxPoint(rect
.width
- 1, rect
.height
- 3);
1418 border_points
[3] = wxPoint(rect
.width
- 3, rect
.height
- 1);
1419 border_points
[4] = wxPoint(2, rect
.height
- 1);
1420 border_points
[5] = wxPoint(0, rect
.height
- 3);
1423 border_points
[6] = border_points
[0];
1425 dc
.SetPen(m_page_border_pen
);
1426 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
, rect
.x
, rect
.y
);
1430 // NB: Code for handling hovered/active state is temporary
1431 wxPoint arrow_points
[3];
1432 switch(style
& wxRIBBON_SCROLL_BTN_DIRECTION_MASK
)
1434 case wxRIBBON_SCROLL_BTN_LEFT
:
1435 arrow_points
[0] = wxPoint(rect
.width
/ 2 - 2, rect
.height
/ 2);
1436 if(style
& wxRIBBON_SCROLL_BTN_ACTIVE
)
1437 arrow_points
[0].y
+= 1;
1438 arrow_points
[1] = arrow_points
[0] + wxPoint(3, -3);
1439 arrow_points
[2] = arrow_points
[0] + wxPoint(3, 3);
1441 case wxRIBBON_SCROLL_BTN_RIGHT
:
1442 arrow_points
[0] = wxPoint(rect
.width
/ 2 + 2, rect
.height
/ 2);
1443 if(style
& wxRIBBON_SCROLL_BTN_ACTIVE
)
1444 arrow_points
[0].y
+= 1;
1445 arrow_points
[1] = arrow_points
[0] - wxPoint(3, 3);
1446 arrow_points
[2] = arrow_points
[0] - wxPoint(3, -3);
1448 case wxRIBBON_SCROLL_BTN_UP
:
1449 arrow_points
[0] = wxPoint(rect
.width
/ 2, rect
.height
/ 2 - 2);
1450 if(style
& wxRIBBON_SCROLL_BTN_ACTIVE
)
1451 arrow_points
[0].y
+= 1;
1452 arrow_points
[1] = arrow_points
[0] + wxPoint( 3, 3);
1453 arrow_points
[2] = arrow_points
[0] + wxPoint(-3, 3);
1455 case wxRIBBON_SCROLL_BTN_DOWN
:
1456 arrow_points
[0] = wxPoint(rect
.width
/ 2, rect
.height
/ 2 + 2);
1457 if(style
& wxRIBBON_SCROLL_BTN_ACTIVE
)
1458 arrow_points
[0].y
+= 1;
1459 arrow_points
[1] = arrow_points
[0] - wxPoint( 3, 3);
1460 arrow_points
[2] = arrow_points
[0] - wxPoint(-3, 3);
1464 dc
.SetPen(*wxTRANSPARENT_PEN
);
1465 wxBrush
B(style
& wxRIBBON_SCROLL_BTN_HOVERED
? m_tab_active_background_colour
: m_tab_label_colour
);
1467 dc
.DrawPolygon(sizeof(arrow_points
)/sizeof(wxPoint
), arrow_points
, rect
.x
, rect
.y
);
1471 void wxRibbonMSWArtProvider::DrawDropdownArrow(wxDC
& dc
, int x
, int y
, const wxColour
& colour
)
1473 wxPoint arrow_points
[3];
1474 wxBrush
brush(colour
);
1475 arrow_points
[0] = wxPoint(1, 2);
1476 arrow_points
[1] = arrow_points
[0] + wxPoint(-3, -3);
1477 arrow_points
[2] = arrow_points
[0] + wxPoint( 3, -3);
1478 dc
.SetPen(*wxTRANSPARENT_PEN
);
1480 dc
.DrawPolygon(sizeof(arrow_points
)/sizeof(wxPoint
), arrow_points
, x
, y
);
1483 void wxRibbonMSWArtProvider::RemovePanelPadding(wxRect
* rect
)
1485 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1497 void wxRibbonMSWArtProvider::DrawPanelBackground(
1502 DrawPartialPageBackground(dc
, wnd
, rect
, false);
1504 wxRect
true_rect(rect
);
1505 RemovePanelPadding(&true_rect
);
1506 bool has_ext_button
= wnd
->HasExtButton();
1510 dc
.SetFont(m_panel_label_font
);
1511 dc
.SetPen(*wxTRANSPARENT_PEN
);
1512 if(wnd
->IsHovered())
1514 dc
.SetBrush(m_panel_hover_label_background_brush
);
1515 dc
.SetTextForeground(m_panel_hover_label_colour
);
1519 dc
.SetBrush(m_panel_label_background_brush
);
1520 dc
.SetTextForeground(m_panel_label_colour
);
1523 wxRect
label_rect(true_rect
);
1524 wxString label
= wnd
->GetLabel();
1525 bool clip_label
= false;
1526 wxSize
label_size(dc
.GetTextExtent(label
));
1528 label_rect
.SetX(label_rect
.GetX() + 1);
1529 label_rect
.SetWidth(label_rect
.GetWidth() - 2);
1530 label_rect
.SetHeight(label_size
.GetHeight() + 2);
1531 label_rect
.SetY(true_rect
.GetBottom() - label_rect
.GetHeight());
1532 label_height
= label_rect
.GetHeight();
1534 wxRect label_bg_rect
= label_rect
;
1537 label_rect
.SetWidth(label_rect
.GetWidth() - 13);
1539 if(label_size
.GetWidth() > label_rect
.GetWidth())
1541 // Test if there is enough length for 3 letters and ...
1542 wxString new_label
= label
.Mid(0, 3) + wxT("...");
1543 label_size
= dc
.GetTextExtent(new_label
);
1544 if(label_size
.GetWidth() > label_rect
.GetWidth())
1546 // Not enough room for three characters and ...
1547 // Display the entire label and just crop it
1552 // Room for some characters and ...
1553 // Display as many characters as possible and append ...
1554 for(size_t len
= label
.Len() - 1; len
>= 3; --len
)
1556 new_label
= label
.Mid(0, len
) + wxT("...");
1557 label_size
= dc
.GetTextExtent(new_label
);
1558 if(label_size
.GetWidth() <= label_rect
.GetWidth())
1567 dc
.DrawRectangle(label_bg_rect
);
1570 wxDCClipper
clip(dc
, label_rect
);
1571 dc
.DrawText(label
, label_rect
.x
, label_rect
.y
+
1572 (label_rect
.GetHeight() - label_size
.GetHeight()) / 2);
1576 dc
.DrawText(label
, label_rect
.x
+
1577 (label_rect
.GetWidth() - label_size
.GetWidth()) / 2,
1579 (label_rect
.GetHeight() - label_size
.GetHeight()) / 2);
1584 if(wnd
->IsExtButtonHovered())
1586 dc
.SetPen(m_panel_hover_button_border_pen
);
1587 dc
.SetBrush(m_panel_hover_button_background_brush
);
1588 dc
.DrawRoundedRectangle(label_rect
.GetRight(), label_rect
.GetBottom() - 13, 13, 13, 1.0);
1589 dc
.DrawBitmap(m_panel_extension_bitmap
[1], label_rect
.GetRight() + 3, label_rect
.GetBottom() - 10, true);
1592 dc
.DrawBitmap(m_panel_extension_bitmap
[0], label_rect
.GetRight() + 3, label_rect
.GetBottom() - 10, true);
1596 if(wnd
->IsHovered())
1598 wxRect
client_rect(true_rect
);
1600 client_rect
.width
-= 2;
1602 client_rect
.height
-= 2 + label_height
;
1603 DrawPartialPageBackground(dc
, wnd
, client_rect
, true);
1606 DrawPanelBorder(dc
, true_rect
, m_panel_border_pen
, m_panel_border_gradient_pen
);
1609 wxRect
wxRibbonMSWArtProvider::GetPanelExtButtonArea(wxDC
& WXUNUSED(dc
),
1610 const wxRibbonPanel
* WXUNUSED(wnd
),
1613 RemovePanelPadding(&rect
);
1614 rect
= wxRect(rect
.GetRight()-13, rect
.GetBottom()-13, 13, 13);
1618 void wxRibbonMSWArtProvider::DrawGalleryBackground(
1620 wxRibbonGallery
* wnd
,
1623 DrawPartialPageBackground(dc
, wnd
, rect
);
1625 if(wnd
->IsHovered())
1627 dc
.SetPen(*wxTRANSPARENT_PEN
);
1628 dc
.SetBrush(m_gallery_hover_background_brush
);
1629 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1631 dc
.DrawRectangle(rect
.x
+ 1, rect
.y
+ 1, rect
.width
- 2,
1636 dc
.DrawRectangle(rect
.x
+ 1, rect
.y
+ 1, rect
.width
- 16,
1641 dc
.SetPen(m_gallery_border_pen
);
1643 dc
.DrawLine(rect
.x
+ 1, rect
.y
, rect
.x
+ rect
.width
- 1, rect
.y
);
1644 dc
.DrawLine(rect
.x
, rect
.y
+ 1, rect
.x
, rect
.y
+ rect
.height
- 1);
1645 dc
.DrawLine(rect
.x
+ 1, rect
.y
+ rect
.height
- 1, rect
.x
+ rect
.width
- 1,
1646 rect
.y
+ rect
.height
- 1);
1647 dc
.DrawLine(rect
.x
+ rect
.width
- 1, rect
.y
+ 1, rect
.x
+ rect
.width
- 1,
1648 rect
.y
+ rect
.height
- 1);
1650 DrawGalleryBackgroundCommon(dc
, wnd
, rect
);
1653 void wxRibbonMSWArtProvider::DrawGalleryBackgroundCommon(wxDC
& dc
,
1654 wxRibbonGallery
* wnd
,
1657 wxRect up_btn
, down_btn
, ext_btn
;
1659 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1661 // Divider between items and buttons
1662 dc
.DrawLine(rect
.x
, rect
.y
+ rect
.height
- 15, rect
.x
+ rect
.width
,
1663 rect
.y
+ rect
.height
- 15);
1665 up_btn
= wxRect(rect
.x
, rect
.y
+ rect
.height
- 15, rect
.width
/ 3, 15);
1667 down_btn
= wxRect(up_btn
.GetRight() + 1, up_btn
.GetTop(),
1668 up_btn
.GetWidth(), up_btn
.GetHeight());
1669 dc
.DrawLine(down_btn
.GetLeft(), down_btn
.GetTop(), down_btn
.GetLeft(),
1670 down_btn
.GetBottom());
1672 ext_btn
= wxRect(down_btn
.GetRight() + 1, up_btn
.GetTop(), rect
.width
-
1673 up_btn
.GetWidth() - down_btn
.GetWidth() - 1, up_btn
.GetHeight());
1674 dc
.DrawLine(ext_btn
.GetLeft(), ext_btn
.GetTop(), ext_btn
.GetLeft(),
1675 ext_btn
.GetBottom());
1679 // Divider between items and buttons
1680 dc
.DrawLine(rect
.x
+ rect
.width
- 15, rect
.y
, rect
.x
+ rect
.width
- 15,
1681 rect
.y
+ rect
.height
);
1683 up_btn
= wxRect(rect
.x
+ rect
.width
- 15, rect
.y
, 15, rect
.height
/ 3);
1685 down_btn
= wxRect(up_btn
.GetLeft(), up_btn
.GetBottom() + 1,
1686 up_btn
.GetWidth(), up_btn
.GetHeight());
1687 dc
.DrawLine(down_btn
.GetLeft(), down_btn
.GetTop(), down_btn
.GetRight(),
1690 ext_btn
= wxRect(up_btn
.GetLeft(), down_btn
.GetBottom() + 1, up_btn
.GetWidth(),
1691 rect
.height
- up_btn
.GetHeight() - down_btn
.GetHeight() - 1);
1692 dc
.DrawLine(ext_btn
.GetLeft(), ext_btn
.GetTop(), ext_btn
.GetRight(),
1696 DrawGalleryButton(dc
, up_btn
, wnd
->GetUpButtonState(),
1697 m_gallery_up_bitmap
);
1698 DrawGalleryButton(dc
, down_btn
, wnd
->GetDownButtonState(),
1699 m_gallery_down_bitmap
);
1700 DrawGalleryButton(dc
, ext_btn
, wnd
->GetExtensionButtonState(),
1701 m_gallery_extension_bitmap
);
1704 void wxRibbonMSWArtProvider::DrawGalleryButton(wxDC
& dc
,
1706 wxRibbonGalleryButtonState state
,
1709 wxBitmap btn_bitmap
;
1710 wxBrush btn_top_brush
;
1711 wxColour btn_colour
;
1712 wxColour btn_grad_colour
;
1715 case wxRIBBON_GALLERY_BUTTON_NORMAL
:
1716 btn_top_brush
= m_gallery_button_background_top_brush
;
1717 btn_colour
= m_gallery_button_background_colour
;
1718 btn_grad_colour
= m_gallery_button_background_gradient_colour
;
1719 btn_bitmap
= bitmaps
[0];
1721 case wxRIBBON_GALLERY_BUTTON_HOVERED
:
1722 btn_top_brush
= m_gallery_button_hover_background_top_brush
;
1723 btn_colour
= m_gallery_button_hover_background_colour
;
1724 btn_grad_colour
= m_gallery_button_hover_background_gradient_colour
;
1725 btn_bitmap
= bitmaps
[1];
1727 case wxRIBBON_GALLERY_BUTTON_ACTIVE
:
1728 btn_top_brush
= m_gallery_button_active_background_top_brush
;
1729 btn_colour
= m_gallery_button_active_background_colour
;
1730 btn_grad_colour
= m_gallery_button_active_background_gradient_colour
;
1731 btn_bitmap
= bitmaps
[2];
1733 case wxRIBBON_GALLERY_BUTTON_DISABLED
:
1734 btn_top_brush
= m_gallery_button_disabled_background_top_brush
;
1735 btn_colour
= m_gallery_button_disabled_background_colour
;
1736 btn_grad_colour
= m_gallery_button_disabled_background_gradient_colour
;
1737 btn_bitmap
= bitmaps
[3];
1743 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1754 dc
.SetPen(*wxTRANSPARENT_PEN
);
1755 dc
.SetBrush(btn_top_brush
);
1756 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
/ 2);
1759 lower
.height
= (lower
.height
+ 1) / 2;
1760 lower
.y
+= rect
.height
- lower
.height
;
1761 dc
.GradientFillLinear(lower
, btn_colour
, btn_grad_colour
, wxSOUTH
);
1763 dc
.DrawBitmap(btn_bitmap
, rect
.x
+ rect
.width
/ 2 - 2, lower
.y
- 2, true);
1766 void wxRibbonMSWArtProvider::DrawGalleryItemBackground(
1768 wxRibbonGallery
* wnd
,
1770 wxRibbonGalleryItem
* item
)
1772 if(wnd
->GetHoveredItem() != item
&& wnd
->GetActiveItem() != item
&&
1773 wnd
->GetSelection() != item
)
1776 dc
.SetPen(m_gallery_item_border_pen
);
1777 dc
.DrawLine(rect
.x
+ 1, rect
.y
, rect
.x
+ rect
.width
- 1, rect
.y
);
1778 dc
.DrawLine(rect
.x
, rect
.y
+ 1, rect
.x
, rect
.y
+ rect
.height
- 1);
1779 dc
.DrawLine(rect
.x
+ 1, rect
.y
+ rect
.height
- 1, rect
.x
+ rect
.width
- 1,
1780 rect
.y
+ rect
.height
- 1);
1781 dc
.DrawLine(rect
.x
+ rect
.width
- 1, rect
.y
+ 1, rect
.x
+ rect
.width
- 1,
1782 rect
.y
+ rect
.height
- 1);
1786 wxColour bg_gradient_colour
;
1788 if(wnd
->GetActiveItem() == item
|| wnd
->GetSelection() == item
)
1790 top_brush
= m_gallery_button_active_background_top_brush
;
1791 bg_colour
= m_gallery_button_active_background_colour
;
1792 bg_gradient_colour
= m_gallery_button_active_background_gradient_colour
;
1796 top_brush
= m_gallery_button_hover_background_top_brush
;
1797 bg_colour
= m_gallery_button_hover_background_colour
;
1798 bg_gradient_colour
= m_gallery_button_hover_background_gradient_colour
;
1806 dc
.SetPen(*wxTRANSPARENT_PEN
);
1807 dc
.SetBrush(top_brush
);
1808 dc
.DrawRectangle(upper
.x
, upper
.y
, upper
.width
, upper
.height
);
1810 wxRect
lower(upper
);
1811 lower
.y
+= lower
.height
;
1812 lower
.height
= rect
.height
- 2 - lower
.height
;
1813 dc
.GradientFillLinear(lower
, bg_colour
, bg_gradient_colour
, wxSOUTH
);
1816 void wxRibbonMSWArtProvider::DrawPanelBorder(wxDC
& dc
, const wxRect
& rect
,
1817 wxPen
& primary_colour
,
1818 wxPen
& secondary_colour
)
1820 wxPoint border_points
[9];
1821 border_points
[0] = wxPoint(2, 0);
1822 border_points
[1] = wxPoint(rect
.width
- 3, 0);
1823 border_points
[2] = wxPoint(rect
.width
- 1, 2);
1824 border_points
[3] = wxPoint(rect
.width
- 1, rect
.height
- 3);
1825 border_points
[4] = wxPoint(rect
.width
- 3, rect
.height
- 1);
1826 border_points
[5] = wxPoint(2, rect
.height
- 1);
1827 border_points
[6] = wxPoint(0, rect
.height
- 3);
1828 border_points
[7] = wxPoint(0, 2);
1830 if(primary_colour
.GetColour() == secondary_colour
.GetColour())
1832 border_points
[8] = border_points
[0];
1833 dc
.SetPen(primary_colour
);
1834 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
, rect
.x
, rect
.y
);
1838 dc
.SetPen(primary_colour
);
1839 dc
.DrawLines(3, border_points
, rect
.x
, rect
.y
);
1841 #define SingleLine(start, finish) \
1842 dc.DrawLine(start.x + rect.x, start.y + rect.y, finish.x + rect.x, finish.y + rect.y)
1844 SingleLine(border_points
[0], border_points
[7]);
1845 dc
.SetPen(secondary_colour
);
1846 dc
.DrawLines(3, border_points
+ 4, rect
.x
, rect
.y
);
1847 SingleLine(border_points
[4], border_points
[3]);
1851 border_points
[6] = border_points
[2];
1852 wxRibbonDrawParallelGradientLines(dc
, 2, border_points
+ 6, 0, 1,
1853 border_points
[3].y
- border_points
[2].y
+ 1, rect
.x
, rect
.y
,
1854 primary_colour
.GetColour(), secondary_colour
.GetColour());
1858 void wxRibbonMSWArtProvider::DrawMinimisedPanel(
1864 DrawPartialPageBackground(dc
, wnd
, rect
, false);
1866 wxRect
true_rect(rect
);
1867 RemovePanelPadding(&true_rect
);
1869 if(wnd
->GetExpandedPanel() != NULL
)
1871 wxRect
client_rect(true_rect
);
1873 client_rect
.width
-= 2;
1875 client_rect
.height
= (rect
.y
+ rect
.height
/ 5) - client_rect
.x
;
1876 dc
.GradientFillLinear(client_rect
,
1877 m_panel_active_background_top_colour
,
1878 m_panel_active_background_top_gradient_colour
, wxSOUTH
);
1880 client_rect
.y
+= client_rect
.height
;
1881 client_rect
.height
= (true_rect
.y
+ true_rect
.height
) - client_rect
.y
;
1882 dc
.GradientFillLinear(client_rect
,
1883 m_panel_active_background_colour
,
1884 m_panel_active_background_gradient_colour
, wxSOUTH
);
1886 else if(wnd
->IsHovered())
1888 wxRect
client_rect(true_rect
);
1890 client_rect
.width
-= 2;
1892 client_rect
.height
-= 2;
1893 DrawPartialPageBackground(dc
, wnd
, client_rect
, true);
1897 DrawMinimisedPanelCommon(dc
, wnd
, true_rect
, &preview
);
1899 dc
.SetBrush(m_panel_hover_label_background_brush
);
1900 dc
.SetPen(*wxTRANSPARENT_PEN
);
1901 dc
.DrawRectangle(preview
.x
+ 1, preview
.y
+ preview
.height
- 8,
1902 preview
.width
- 2, 7);
1904 int mid_pos
= rect
.y
+ rect
.height
/ 5 - preview
.y
;
1905 if(mid_pos
< 0 || mid_pos
>= preview
.height
)
1907 wxRect
full_rect(preview
);
1910 full_rect
.width
-= 2;
1911 full_rect
.height
-= 9;
1914 dc
.GradientFillLinear(full_rect
,
1915 m_page_hover_background_colour
,
1916 m_page_hover_background_gradient_colour
, wxSOUTH
);
1920 dc
.GradientFillLinear(full_rect
,
1921 m_page_hover_background_top_colour
,
1922 m_page_hover_background_top_gradient_colour
, wxSOUTH
);
1927 wxRect
top_rect(preview
);
1930 top_rect
.width
-= 2;
1931 top_rect
.height
= mid_pos
;
1932 dc
.GradientFillLinear(top_rect
,
1933 m_page_hover_background_top_colour
,
1934 m_page_hover_background_top_gradient_colour
, wxSOUTH
);
1936 wxRect
btm_rect(top_rect
);
1937 btm_rect
.y
= preview
.y
+ mid_pos
;
1938 btm_rect
.height
= preview
.y
+ preview
.height
- 7 - btm_rect
.y
;
1939 dc
.GradientFillLinear(btm_rect
,
1940 m_page_hover_background_colour
,
1941 m_page_hover_background_gradient_colour
, wxSOUTH
);
1946 dc
.DrawBitmap(bitmap
, preview
.x
+ (preview
.width
- bitmap
.GetWidth()) / 2,
1947 preview
.y
+ (preview
.height
- 7 - bitmap
.GetHeight()) / 2, true);
1950 DrawPanelBorder(dc
, preview
, m_panel_border_pen
, m_panel_border_gradient_pen
);
1952 DrawPanelBorder(dc
, true_rect
, m_panel_minimised_border_pen
,
1953 m_panel_minimised_border_gradient_pen
);
1956 void wxRibbonMSWArtProvider::DrawMinimisedPanelCommon(
1959 const wxRect
& true_rect
,
1960 wxRect
* preview_rect
)
1962 wxRect
preview(0, 0, 32, 32);
1963 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1965 preview
.x
= true_rect
.x
+ 4;
1966 preview
.y
= true_rect
.y
+ (true_rect
.height
- preview
.height
) / 2;
1970 preview
.x
= true_rect
.x
+ (true_rect
.width
- preview
.width
) / 2;
1971 preview
.y
= true_rect
.y
+ 4;
1974 *preview_rect
= preview
;
1976 wxCoord label_width
, label_height
;
1977 dc
.SetFont(m_panel_label_font
);
1978 dc
.GetTextExtent(wnd
->GetLabel(), &label_width
, &label_height
);
1980 int xpos
= true_rect
.x
+ (true_rect
.width
- label_width
+ 1) / 2;
1981 int ypos
= preview
.y
+ preview
.height
+ 5;
1983 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1985 xpos
= preview
.x
+ preview
.width
+ 5;
1986 ypos
= true_rect
.y
+ (true_rect
.height
- label_height
) / 2;
1989 dc
.SetTextForeground(m_panel_minimised_label_colour
);
1990 dc
.DrawText(wnd
->GetLabel(), xpos
, ypos
);
1993 wxPoint arrow_points
[3];
1994 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
1996 xpos
+= label_width
;
1997 arrow_points
[0] = wxPoint(xpos
+ 5, ypos
+ label_height
/ 2);
1998 arrow_points
[1] = arrow_points
[0] + wxPoint(-3, 3);
1999 arrow_points
[2] = arrow_points
[0] + wxPoint(-3, -3);
2003 ypos
+= label_height
;
2004 arrow_points
[0] = wxPoint(true_rect
.width
/ 2, ypos
+ 5);
2005 arrow_points
[1] = arrow_points
[0] + wxPoint(-3, -3);
2006 arrow_points
[2] = arrow_points
[0] + wxPoint( 3, -3);
2009 dc
.SetPen(*wxTRANSPARENT_PEN
);
2010 wxBrush
B(m_panel_minimised_label_colour
);
2012 dc
.DrawPolygon(sizeof(arrow_points
)/sizeof(wxPoint
), arrow_points
,
2013 true_rect
.x
, true_rect
.y
);
2016 void wxRibbonMSWArtProvider::DrawButtonBarBackground(
2021 DrawPartialPageBackground(dc
, wnd
, rect
, true);
2024 void wxRibbonMSWArtProvider::DrawPartialPageBackground(
2030 // Assume the window is a child of a ribbon page, and also check for a
2031 // hovered panel somewhere between the window and the page, as it causes
2032 // the background to change.
2033 wxPoint
offset(wnd
->GetPosition());
2034 wxRibbonPage
* page
= NULL
;
2035 wxWindow
* parent
= wnd
->GetParent();
2036 wxRibbonPanel
* panel
= wxDynamicCast(wnd
, wxRibbonPanel
);
2037 bool hovered
= false;
2041 hovered
= allow_hovered
&& panel
->IsHovered();
2042 if(panel
->GetExpandedDummy() != NULL
)
2044 offset
= panel
->GetExpandedDummy()->GetPosition();
2045 parent
= panel
->GetExpandedDummy()->GetParent();
2048 for(; parent
; parent
= parent
->GetParent())
2052 panel
= wxDynamicCast(parent
, wxRibbonPanel
);
2055 hovered
= allow_hovered
&& panel
->IsHovered();
2056 if(panel
->GetExpandedDummy() != NULL
)
2058 parent
= panel
->GetExpandedDummy();
2062 page
= wxDynamicCast(parent
, wxRibbonPage
);
2067 offset
+= parent
->GetPosition();
2071 DrawPartialPageBackground(dc
, wnd
, rect
, page
, offset
, hovered
);
2075 // No page found - fallback to painting with a stock brush
2076 dc
.SetBrush(*wxWHITE_BRUSH
);
2077 dc
.SetPen(*wxTRANSPARENT_PEN
);
2078 dc
.DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
2081 void wxRibbonMSWArtProvider::DrawButtonBarButton(
2083 wxWindow
* WXUNUSED(wnd
),
2085 wxRibbonButtonKind kind
,
2087 const wxString
& label
,
2088 const wxBitmap
& bitmap_large
,
2089 const wxBitmap
& bitmap_small
)
2091 if(kind
== wxRIBBON_BUTTON_TOGGLE
)
2093 kind
= wxRIBBON_BUTTON_NORMAL
;
2094 if(state
& wxRIBBON_BUTTONBAR_BUTTON_TOGGLED
)
2095 state
^= wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK
;
2098 if(state
& (wxRIBBON_BUTTONBAR_BUTTON_HOVER_MASK
|
2099 wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK
))
2101 if(state
& wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK
)
2102 dc
.SetPen(m_button_bar_active_border_pen
);
2104 dc
.SetPen(m_button_bar_hover_border_pen
);
2106 wxRect
bg_rect(rect
);
2110 bg_rect
.height
-= 2;
2112 wxRect
bg_rect_top(bg_rect
);
2113 bg_rect_top
.height
/= 3;
2114 bg_rect
.y
+= bg_rect_top
.height
;
2115 bg_rect
.height
-= bg_rect_top
.height
;
2117 if(kind
== wxRIBBON_BUTTON_HYBRID
)
2119 switch(state
& wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK
)
2121 case wxRIBBON_BUTTONBAR_BUTTON_LARGE
:
2123 int iYBorder
= rect
.y
+ bitmap_large
.GetHeight() + 4;
2124 wxRect
partial_bg(rect
);
2125 if(state
& wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED
)
2127 partial_bg
.SetBottom(iYBorder
- 1);
2131 partial_bg
.height
-= (iYBorder
- partial_bg
.y
+ 1);
2132 partial_bg
.y
= iYBorder
+ 1;
2134 dc
.DrawLine(rect
.x
, iYBorder
, rect
.x
+ rect
.width
, iYBorder
);
2135 bg_rect
.Intersect(partial_bg
);
2136 bg_rect_top
.Intersect(partial_bg
);
2139 case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM
:
2141 int iArrowWidth
= 9;
2142 if(state
& wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED
)
2144 bg_rect
.width
-= iArrowWidth
;
2145 bg_rect_top
.width
-= iArrowWidth
;
2146 dc
.DrawLine(bg_rect_top
.x
+ bg_rect_top
.width
,
2147 rect
.y
, bg_rect_top
.x
+ bg_rect_top
.width
,
2148 rect
.y
+ rect
.height
);
2153 bg_rect
.x
+= bg_rect
.width
- iArrowWidth
;
2154 bg_rect_top
.x
+= bg_rect_top
.width
- iArrowWidth
;
2155 bg_rect
.width
= iArrowWidth
;
2156 bg_rect_top
.width
= iArrowWidth
;
2157 dc
.DrawLine(bg_rect_top
.x
- 1, rect
.y
,
2158 bg_rect_top
.x
- 1, rect
.y
+ rect
.height
);
2162 case wxRIBBON_BUTTONBAR_BUTTON_SMALL
:
2167 if(state
& wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK
)
2169 dc
.GradientFillLinear(bg_rect_top
,
2170 m_button_bar_active_background_top_colour
,
2171 m_button_bar_active_background_top_gradient_colour
, wxSOUTH
);
2172 dc
.GradientFillLinear(bg_rect
,
2173 m_button_bar_active_background_colour
,
2174 m_button_bar_active_background_gradient_colour
, wxSOUTH
);
2178 dc
.GradientFillLinear(bg_rect_top
,
2179 m_button_bar_hover_background_top_colour
,
2180 m_button_bar_hover_background_top_gradient_colour
, wxSOUTH
);
2181 dc
.GradientFillLinear(bg_rect
,
2182 m_button_bar_hover_background_colour
,
2183 m_button_bar_hover_background_gradient_colour
, wxSOUTH
);
2186 wxPoint border_points
[9];
2187 border_points
[0] = wxPoint(2, 0);
2188 border_points
[1] = wxPoint(rect
.width
- 3, 0);
2189 border_points
[2] = wxPoint(rect
.width
- 1, 2);
2190 border_points
[3] = wxPoint(rect
.width
- 1, rect
.height
- 3);
2191 border_points
[4] = wxPoint(rect
.width
- 3, rect
.height
- 1);
2192 border_points
[5] = wxPoint(2, rect
.height
- 1);
2193 border_points
[6] = wxPoint(0, rect
.height
- 3);
2194 border_points
[7] = wxPoint(0, 2);
2195 border_points
[8] = border_points
[0];
2197 dc
.DrawLines(sizeof(border_points
)/sizeof(wxPoint
), border_points
,
2201 dc
.SetFont(m_button_bar_label_font
);
2202 dc
.SetTextForeground(m_button_bar_label_colour
);
2203 DrawButtonBarButtonForeground(dc
, rect
, kind
, state
, label
, bitmap_large
,
2207 void wxRibbonMSWArtProvider::DrawButtonBarButtonForeground(
2210 wxRibbonButtonKind kind
,
2212 const wxString
& label
,
2213 const wxBitmap
& bitmap_large
,
2214 const wxBitmap
& bitmap_small
)
2216 switch(state
& wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK
)
2218 case wxRIBBON_BUTTONBAR_BUTTON_LARGE
:
2220 const int padding
= 2;
2221 dc
.DrawBitmap(bitmap_large
,
2222 rect
.x
+ (rect
.width
- bitmap_large
.GetWidth()) / 2,
2223 rect
.y
+ padding
, true);
2224 int ypos
= rect
.y
+ padding
+ bitmap_large
.GetHeight() + padding
;
2225 int arrow_width
= kind
== wxRIBBON_BUTTON_NORMAL
? 0 : 8;
2226 wxCoord label_w
, label_h
;
2227 dc
.GetTextExtent(label
, &label_w
, &label_h
);
2228 if(label_w
+ 2 * padding
<= rect
.width
)
2230 dc
.DrawText(label
, rect
.x
+ (rect
.width
- label_w
) / 2, ypos
);
2231 if(arrow_width
!= 0)
2233 DrawDropdownArrow(dc
, rect
.x
+ rect
.width
/ 2,
2234 ypos
+ (label_h
* 3) / 2,
2235 m_button_bar_label_colour
);
2240 size_t breaki
= label
.Len();
2244 if(wxRibbonCanLabelBreakAtPosition(label
, breaki
))
2246 wxString label_top
= label
.Mid(0, breaki
);
2247 dc
.GetTextExtent(label_top
, &label_w
, &label_h
);
2248 if(label_w
+ 2 * padding
<= rect
.width
)
2250 dc
.DrawText(label_top
,
2251 rect
.x
+ (rect
.width
- label_w
) / 2, ypos
);
2253 wxString label_bottom
= label
.Mid(breaki
+ 1);
2254 dc
.GetTextExtent(label_bottom
, &label_w
, &label_h
);
2255 label_w
+= arrow_width
;
2256 int iX
= rect
.x
+ (rect
.width
- label_w
) / 2;
2257 dc
.DrawText(label_bottom
, iX
, ypos
);
2258 if(arrow_width
!= 0)
2260 DrawDropdownArrow(dc
,
2261 iX
+ 2 +label_w
- arrow_width
,
2262 ypos
+ label_h
/ 2 + 1,
2263 m_button_bar_label_colour
);
2268 } while(breaki
> 0);
2272 case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM
:
2274 int x_cursor
= rect
.x
+ 2;
2275 dc
.DrawBitmap(bitmap_small
, x_cursor
,
2276 rect
.y
+ (rect
.height
- bitmap_small
.GetHeight())/2, true);
2277 x_cursor
+= bitmap_small
.GetWidth() + 2;
2278 wxCoord label_w
, label_h
;
2279 dc
.GetTextExtent(label
, &label_w
, &label_h
);
2280 dc
.DrawText(label
, x_cursor
,
2281 rect
.y
+ (rect
.height
- label_h
) / 2);
2282 x_cursor
+= label_w
+ 3;
2283 if(kind
!= wxRIBBON_BUTTON_NORMAL
)
2285 DrawDropdownArrow(dc
, x_cursor
, rect
.y
+ rect
.height
/ 2,
2286 m_button_bar_label_colour
);
2296 void wxRibbonMSWArtProvider::DrawToolBarBackground(
2301 DrawPartialPageBackground(dc
, wnd
, rect
);
2304 void wxRibbonMSWArtProvider::DrawToolGroupBackground(
2306 wxWindow
* WXUNUSED(wnd
),
2309 dc
.SetPen(m_toolbar_border_pen
);
2311 outline
[0] = wxPoint(2, 0);
2312 outline
[1] = wxPoint(rect
.width
- 3, 0);
2313 outline
[2] = wxPoint(rect
.width
- 1, 2);
2314 outline
[3] = wxPoint(rect
.width
- 1, rect
.height
- 3);
2315 outline
[4] = wxPoint(rect
.width
- 3, rect
.height
- 1);
2316 outline
[5] = wxPoint(2, rect
.height
- 1);
2317 outline
[6] = wxPoint(0, rect
.height
- 3);
2318 outline
[7] = wxPoint(0, 2);
2319 outline
[8] = outline
[0];
2321 dc
.DrawLines(sizeof(outline
)/sizeof(wxPoint
), outline
, rect
.x
, rect
.y
);
2324 void wxRibbonMSWArtProvider::DrawTool(
2326 wxWindow
* WXUNUSED(wnd
),
2328 const wxBitmap
& bitmap
,
2329 wxRibbonButtonKind kind
,
2332 if(kind
== wxRIBBON_BUTTON_TOGGLE
)
2334 if(state
& wxRIBBON_TOOLBAR_TOOL_TOGGLED
)
2335 state
^= wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK
;
2338 wxRect
bg_rect(rect
);
2340 if((state
& wxRIBBON_TOOLBAR_TOOL_LAST
) == 0)
2342 bool is_split_hybrid
= (kind
== wxRIBBON_BUTTON_HYBRID
&& (state
&
2343 (wxRIBBON_TOOLBAR_TOOL_HOVER_MASK
| wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK
)));
2346 wxRect
bg_rect_top(bg_rect
);
2347 bg_rect_top
.height
= (bg_rect_top
.height
* 2) / 5;
2348 wxRect
bg_rect_btm(bg_rect
);
2349 bg_rect_btm
.y
+= bg_rect_top
.height
;
2350 bg_rect_btm
.height
-= bg_rect_top
.height
;
2351 wxColour bg_top_colour
= m_tool_background_top_colour
;
2352 wxColour bg_top_grad_colour
= m_tool_background_top_gradient_colour
;
2353 wxColour bg_colour
= m_tool_background_colour
;
2354 wxColour bg_grad_colour
= m_tool_background_gradient_colour
;
2355 if(state
& wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK
)
2357 bg_top_colour
= m_tool_active_background_top_colour
;
2358 bg_top_grad_colour
= m_tool_active_background_top_gradient_colour
;
2359 bg_colour
= m_tool_active_background_colour
;
2360 bg_grad_colour
= m_tool_active_background_gradient_colour
;
2362 else if(state
& wxRIBBON_TOOLBAR_TOOL_HOVER_MASK
)
2364 bg_top_colour
= m_tool_hover_background_top_colour
;
2365 bg_top_grad_colour
= m_tool_hover_background_top_gradient_colour
;
2366 bg_colour
= m_tool_hover_background_colour
;
2367 bg_grad_colour
= m_tool_hover_background_gradient_colour
;
2369 dc
.GradientFillLinear(bg_rect_top
, bg_top_colour
, bg_top_grad_colour
, wxSOUTH
);
2370 dc
.GradientFillLinear(bg_rect_btm
, bg_colour
, bg_grad_colour
, wxSOUTH
);
2373 wxRect
nonrect(bg_rect
);
2374 if(state
& (wxRIBBON_TOOLBAR_TOOL_DROPDOWN_HOVERED
|
2375 wxRIBBON_TOOLBAR_TOOL_DROPDOWN_ACTIVE
))
2381 nonrect
.x
+= nonrect
.width
- 8;
2384 wxBrush
B(m_tool_hover_background_top_colour
);
2385 dc
.SetPen(*wxTRANSPARENT_PEN
);
2387 dc
.DrawRectangle(nonrect
.x
, nonrect
.y
, nonrect
.width
, nonrect
.height
);
2391 dc
.SetPen(m_toolbar_border_pen
);
2392 if(state
& wxRIBBON_TOOLBAR_TOOL_FIRST
)
2394 dc
.DrawPoint(rect
.x
+ 1, rect
.y
+ 1);
2395 dc
.DrawPoint(rect
.x
+ 1, rect
.y
+ rect
.height
- 2);
2398 dc
.DrawLine(rect
.x
, rect
.y
+ 1, rect
.x
, rect
.y
+ rect
.height
- 1);
2400 if(state
& wxRIBBON_TOOLBAR_TOOL_LAST
)
2402 dc
.DrawPoint(rect
.x
+ rect
.width
- 2, rect
.y
+ 1);
2403 dc
.DrawPoint(rect
.x
+ rect
.width
- 2, rect
.y
+ rect
.height
- 2);
2407 int avail_width
= bg_rect
.GetWidth();
2408 if(kind
& wxRIBBON_BUTTON_DROPDOWN
)
2413 dc
.DrawLine(rect
.x
+ avail_width
+ 1, rect
.y
,
2414 rect
.x
+ avail_width
+ 1, rect
.y
+ rect
.height
);
2416 dc
.DrawBitmap(m_toolbar_drop_bitmap
, bg_rect
.x
+ avail_width
+ 2,
2417 bg_rect
.y
+ (bg_rect
.height
/ 2) - 2, true);
2419 dc
.DrawBitmap(bitmap
, bg_rect
.x
+ (avail_width
- bitmap
.GetWidth()) / 2,
2420 bg_rect
.y
+ (bg_rect
.height
- bitmap
.GetHeight()) / 2, true);
2423 void wxRibbonMSWArtProvider::GetBarTabWidth(
2425 wxWindow
* WXUNUSED(wnd
),
2426 const wxString
& label
,
2427 const wxBitmap
& bitmap
,
2429 int* small_begin_need_separator
,
2430 int* small_must_have_separator
,
2435 if((m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
) && !label
.IsEmpty())
2437 dc
.SetFont(m_tab_label_font
);
2438 width
+= dc
.GetTextExtent(label
).GetWidth();
2439 min
+= wxMin(25, width
); // enough for a few chars
2442 // gap between label and bitmap
2447 if((m_flags
& wxRIBBON_BAR_SHOW_PAGE_ICONS
) && bitmap
.IsOk())
2449 width
+= bitmap
.GetWidth();
2450 min
+= bitmap
.GetWidth();
2455 *ideal
= width
+ 30;
2457 if(small_begin_need_separator
!= NULL
)
2459 *small_begin_need_separator
= width
+ 20;
2461 if(small_must_have_separator
!= NULL
)
2463 *small_must_have_separator
= width
+ 10;
2471 int wxRibbonMSWArtProvider::GetTabCtrlHeight(
2473 wxWindow
* WXUNUSED(wnd
),
2474 const wxRibbonPageTabInfoArray
& pages
)
2476 int text_height
= 0;
2477 int icon_height
= 0;
2479 if(pages
.GetCount() <= 1 && (m_flags
& wxRIBBON_BAR_ALWAYS_SHOW_TABS
) == 0)
2481 // To preserve space, a single tab need not be displayed. We still need
2482 // two pixels of border / padding though.
2486 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_LABELS
)
2488 dc
.SetFont(m_tab_label_font
);
2489 text_height
= dc
.GetTextExtent(wxT("ABCDEFXj")).GetHeight() + 10;
2491 if(m_flags
& wxRIBBON_BAR_SHOW_PAGE_ICONS
)
2493 size_t numpages
= pages
.GetCount();
2494 for(size_t i
= 0; i
< numpages
; ++i
)
2496 const wxRibbonPageTabInfo
& info
= pages
.Item(i
);
2497 if(info
.page
->GetIcon().IsOk())
2499 icon_height
= wxMax(icon_height
, info
.page
->GetIcon().GetHeight() + 4);
2504 return wxMax(text_height
, icon_height
);
2507 wxSize
wxRibbonMSWArtProvider::GetScrollButtonMinimumSize(
2509 wxWindow
* WXUNUSED(wnd
),
2510 long WXUNUSED(style
))
2512 return wxSize(12, 12);
2515 wxSize
wxRibbonMSWArtProvider::GetPanelSize(
2517 const wxRibbonPanel
* wnd
,
2519 wxPoint
* client_offset
)
2521 dc
.SetFont(m_panel_label_font
);
2522 wxSize label_size
= dc
.GetTextExtent(wnd
->GetLabel());
2524 client_size
.IncBy(0, label_size
.GetHeight());
2525 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2526 client_size
.IncBy(4, 8);
2528 client_size
.IncBy(6, 6);
2530 if(client_offset
!= NULL
)
2532 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2533 *client_offset
= wxPoint(2, 3);
2535 *client_offset
= wxPoint(3, 2);
2541 wxSize
wxRibbonMSWArtProvider::GetPanelClientSize(
2543 const wxRibbonPanel
* wnd
,
2545 wxPoint
* client_offset
)
2547 dc
.SetFont(m_panel_label_font
);
2548 wxSize label_size
= dc
.GetTextExtent(wnd
->GetLabel());
2550 size
.DecBy(0, label_size
.GetHeight());
2551 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2556 if(client_offset
!= NULL
)
2558 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2559 *client_offset
= wxPoint(2, 3);
2561 *client_offset
= wxPoint(3, 2);
2563 if (size
.x
< 0) size
.x
= 0;
2564 if (size
.y
< 0) size
.y
= 0;
2569 wxSize
wxRibbonMSWArtProvider::GetGallerySize(
2571 const wxRibbonGallery
* WXUNUSED(wnd
),
2574 client_size
.IncBy( 2, 1); // Left / top padding
2575 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2576 client_size
.IncBy(1, 16); // Right / bottom padding
2578 client_size
.IncBy(16, 1); // Right / bottom padding
2582 wxSize
wxRibbonMSWArtProvider::GetGalleryClientSize(
2584 const wxRibbonGallery
* WXUNUSED(wnd
),
2586 wxPoint
* client_offset
,
2587 wxRect
* scroll_up_button
,
2588 wxRect
* scroll_down_button
,
2589 wxRect
* extension_button
)
2594 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2596 // Flow is vertical - put buttons on bottom
2597 scroll_up
.y
= size
.GetHeight() - 15;
2598 scroll_up
.height
= 15;
2600 scroll_up
.width
= (size
.GetWidth() + 2) / 3;
2601 scroll_down
.y
= scroll_up
.y
;
2602 scroll_down
.height
= scroll_up
.height
;
2603 scroll_down
.x
= scroll_up
.x
+ scroll_up
.width
;
2604 scroll_down
.width
= scroll_up
.width
;
2605 extension
.y
= scroll_down
.y
;
2606 extension
.height
= scroll_down
.height
;
2607 extension
.x
= scroll_down
.x
+ scroll_down
.width
;
2608 extension
.width
= size
.GetWidth() - scroll_up
.width
- scroll_down
.width
;
2614 // Flow is horizontal - put buttons on right
2615 scroll_up
.x
= size
.GetWidth() - 15;
2616 scroll_up
.width
= 15;
2618 scroll_up
.height
= (size
.GetHeight() + 2) / 3;
2619 scroll_down
.x
= scroll_up
.x
;
2620 scroll_down
.width
= scroll_up
.width
;
2621 scroll_down
.y
= scroll_up
.y
+ scroll_up
.height
;
2622 scroll_down
.height
= scroll_up
.height
;
2623 extension
.x
= scroll_down
.x
;
2624 extension
.width
= scroll_down
.width
;
2625 extension
.y
= scroll_down
.y
+ scroll_down
.height
;
2626 extension
.height
= size
.GetHeight() - scroll_up
.height
- scroll_down
.height
;
2631 if(client_offset
!= NULL
)
2632 *client_offset
= wxPoint(2, 1);
2633 if(scroll_up_button
!= NULL
)
2634 *scroll_up_button
= scroll_up
;
2635 if(scroll_down_button
!= NULL
)
2636 *scroll_down_button
= scroll_down
;
2637 if(extension_button
!= NULL
)
2638 *extension_button
= extension
;
2643 wxRect
wxRibbonMSWArtProvider::GetPageBackgroundRedrawArea(
2645 const wxRibbonPage
* WXUNUSED(wnd
),
2646 wxSize page_old_size
,
2647 wxSize page_new_size
)
2649 wxRect new_rect
, old_rect
;
2651 if(page_new_size
.GetWidth() != page_old_size
.GetWidth())
2653 if(page_new_size
.GetHeight() != page_old_size
.GetHeight())
2655 // Width and height both changed - redraw everything
2656 return wxRect(page_new_size
);
2660 // Only width changed - redraw right hand side
2661 const int right_edge_width
= 4;
2663 new_rect
= wxRect(page_new_size
.GetWidth() - right_edge_width
, 0, right_edge_width
, page_new_size
.GetHeight());
2664 old_rect
= wxRect(page_old_size
.GetWidth() - right_edge_width
, 0, right_edge_width
, page_old_size
.GetHeight());
2669 if(page_new_size
.GetHeight() == page_old_size
.GetHeight())
2671 // Nothing changed (should never happen) - redraw nothing
2672 return wxRect(0, 0, 0, 0);
2676 // Height changed - need to redraw everything (as the background
2677 // gradient is done vertically).
2678 return page_new_size
;
2682 new_rect
.Union(old_rect
);
2683 new_rect
.Intersect(wxRect(page_new_size
));
2687 bool wxRibbonMSWArtProvider::GetButtonBarButtonSize(
2690 wxRibbonButtonKind kind
,
2691 wxRibbonButtonBarButtonState size
,
2692 const wxString
& label
,
2693 wxSize bitmap_size_large
,
2694 wxSize bitmap_size_small
,
2695 wxSize
* button_size
,
2696 wxRect
* normal_region
,
2697 wxRect
* dropdown_region
)
2699 const int drop_button_width
= 8;
2701 dc
.SetFont(m_button_bar_label_font
);
2702 switch(size
& wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK
)
2704 case wxRIBBON_BUTTONBAR_BUTTON_SMALL
:
2705 // Small bitmap, no label
2706 *button_size
= bitmap_size_small
+ wxSize(6, 4);
2709 case wxRIBBON_BUTTON_NORMAL
:
2710 case wxRIBBON_BUTTON_TOGGLE
:
2711 *normal_region
= wxRect(*button_size
);
2712 *dropdown_region
= wxRect(0, 0, 0, 0);
2714 case wxRIBBON_BUTTON_DROPDOWN
:
2715 *button_size
+= wxSize(drop_button_width
, 0);
2716 *dropdown_region
= wxRect(*button_size
);
2717 *normal_region
= wxRect(0, 0, 0, 0);
2719 case wxRIBBON_BUTTON_HYBRID
:
2720 *normal_region
= wxRect(*button_size
);
2721 *dropdown_region
= wxRect(button_size
->GetWidth(), 0,
2722 drop_button_width
, button_size
->GetHeight());
2723 *button_size
+= wxSize(drop_button_width
, 0);
2727 case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM
:
2728 // Small bitmap, with label to the right
2730 GetButtonBarButtonSize(dc
, wnd
, kind
, wxRIBBON_BUTTONBAR_BUTTON_SMALL
,
2731 label
, bitmap_size_large
, bitmap_size_small
, button_size
,
2732 normal_region
, dropdown_region
);
2733 int text_size
= dc
.GetTextExtent(label
).GetWidth();
2734 button_size
->SetWidth(button_size
->GetWidth() + text_size
);
2737 case wxRIBBON_BUTTON_DROPDOWN
:
2738 dropdown_region
->SetWidth(dropdown_region
->GetWidth() + text_size
);
2740 case wxRIBBON_BUTTON_HYBRID
:
2741 dropdown_region
->SetX(dropdown_region
->GetX() + text_size
);
2743 case wxRIBBON_BUTTON_NORMAL
:
2744 case wxRIBBON_BUTTON_TOGGLE
:
2745 normal_region
->SetWidth(normal_region
->GetWidth() + text_size
);
2750 case wxRIBBON_BUTTONBAR_BUTTON_LARGE
:
2751 // Large bitmap, with label below (possibly split over 2 lines)
2753 wxSize
icon_size(bitmap_size_large
);
2754 icon_size
+= wxSize(4, 4);
2755 wxCoord label_height
;
2757 dc
.GetTextExtent(label
, &best_width
, &label_height
);
2758 int last_line_extra_width
= 0;
2759 if(kind
!= wxRIBBON_BUTTON_NORMAL
&& kind
!= wxRIBBON_BUTTON_TOGGLE
)
2761 last_line_extra_width
+= 8;
2764 for(i
= 0; i
< label
.Len(); ++i
)
2766 if(wxRibbonCanLabelBreakAtPosition(label
, i
))
2769 dc
.GetTextExtent(label
.Mid(0, i
- 1)).GetWidth(),
2770 dc
.GetTextExtent(label
.Mid(i
+ 1)).GetWidth() + last_line_extra_width
);
2771 if(width
< best_width
)
2777 label_height
*= 2; // Assume two lines even when only one is used
2778 // (to give all buttons a consistent height)
2779 icon_size
.SetWidth(wxMax(icon_size
.GetWidth(), best_width
) + 6);
2780 icon_size
.SetHeight(icon_size
.GetHeight() + label_height
);
2781 *button_size
= icon_size
;
2784 case wxRIBBON_BUTTON_DROPDOWN
:
2785 *dropdown_region
= wxRect(icon_size
);
2787 case wxRIBBON_BUTTON_HYBRID
:
2788 *normal_region
= wxRect(icon_size
);
2789 normal_region
->height
-= 2 + label_height
;
2790 dropdown_region
->x
= 0;
2791 dropdown_region
->y
= normal_region
->height
;
2792 dropdown_region
->width
= icon_size
.GetWidth();
2793 dropdown_region
->height
= icon_size
.GetHeight() - normal_region
->height
;
2795 case wxRIBBON_BUTTON_NORMAL
:
2796 case wxRIBBON_BUTTON_TOGGLE
:
2797 *normal_region
= wxRect(icon_size
);
2806 wxSize
wxRibbonMSWArtProvider::GetMinimisedPanelMinimumSize(
2808 const wxRibbonPanel
* wnd
,
2809 wxSize
* desired_bitmap_size
,
2810 wxDirection
* expanded_panel_direction
)
2812 if(desired_bitmap_size
!= NULL
)
2814 *desired_bitmap_size
= wxSize(16, 16);
2816 if(expanded_panel_direction
!= NULL
)
2818 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2819 *expanded_panel_direction
= wxEAST
;
2821 *expanded_panel_direction
= wxSOUTH
;
2823 wxSize
base_size(42, 42);
2825 dc
.SetFont(m_panel_label_font
);
2826 wxSize
label_size(dc
.GetTextExtent(wnd
->GetLabel()));
2827 label_size
.IncBy(2, 2); // Allow for differences between this DC and a paint DC
2828 label_size
.IncBy(6, 0); // Padding
2829 label_size
.y
*= 2; // Second line for dropdown button
2831 if(m_flags
& wxRIBBON_BAR_FLOW_VERTICAL
)
2833 // Label alongside icon
2834 return wxSize(base_size
.x
+ label_size
.x
,
2835 wxMax(base_size
.y
, label_size
.y
));
2839 // Label beneath icon
2840 return wxSize(wxMax(base_size
.x
, label_size
.x
),
2841 base_size
.y
+ label_size
.y
);
2845 wxSize
wxRibbonMSWArtProvider::GetToolSize(
2847 wxWindow
* WXUNUSED(wnd
),
2849 wxRibbonButtonKind kind
,
2850 bool WXUNUSED(is_first
),
2852 wxRect
* dropdown_region
)
2854 wxSize
size(bitmap_size
);
2858 if(kind
& wxRIBBON_BUTTON_DROPDOWN
)
2863 if(kind
== wxRIBBON_BUTTON_DROPDOWN
)
2864 *dropdown_region
= size
;
2866 *dropdown_region
= wxRect(size
.GetWidth() - 8, 0, 8, size
.GetHeight());
2872 *dropdown_region
= wxRect(0, 0, 0, 0);
2877 #endif // wxUSE_RIBBON