]> git.saurik.com Git - wxWidgets.git/blob - src/ribbon/art_msw.cpp
wxFontProperty: Added support for wxFONTFAMILY_TELETYPE and wxFONTFAMILY_UNKNOWN...
[wxWidgets.git] / src / ribbon / art_msw.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/ribbon/art_msw.cpp
3 // Purpose: MSW style art provider for ribbon interface
4 // Author: Peter Cawley
5 // Modified by:
6 // Created: 2009-05-25
7 // RCS-ID: $Id$
8 // Copyright: (C) Peter Cawley
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13
14 #ifdef __BORLANDC__
15 #pragma hdrstop
16 #endif
17
18 #include "wx/dcmemory.h"
19 #include "wx/ribbon/art.h"
20
21 #if wxUSE_RIBBON
22
23 #include "wx/ribbon/art_internal.h"
24 #include "wx/ribbon/bar.h"
25 #include "wx/ribbon/buttonbar.h"
26 #include "wx/ribbon/gallery.h"
27 #include "wx/ribbon/toolbar.h"
28
29 #ifndef WX_PRECOMP
30 #endif
31
32 #ifdef __WXMSW__
33 #include "wx/msw/private.h"
34 #endif
35
36 static const char* const gallery_up_xpm[] = {
37 "5 5 2 1",
38 " c None",
39 "x c #FF00FF",
40 " ",
41 " x ",
42 " xxx ",
43 "xxxxx",
44 " "};
45
46 static const char* const gallery_down_xpm[] = {
47 "5 5 2 1",
48 " c None",
49 "x c #FF00FF",
50 " ",
51 "xxxxx",
52 " xxx ",
53 " x ",
54 " "};
55
56 static const char* const gallery_left_xpm[] = {
57 "5 5 2 1",
58 " c None",
59 "x c #FF00FF",
60 " x ",
61 " xx ",
62 " xxx ",
63 " xx ",
64 " x "};
65
66 static const char* const gallery_right_xpm[] = {
67 "5 5 2 1",
68 " c None",
69 "x c #FF00FF",
70 " x ",
71 " xx ",
72 " xxx ",
73 " xx ",
74 " x "};
75
76 static const char* const gallery_extension_xpm[] = {
77 "5 5 2 1",
78 " c None",
79 "x c #FF00FF",
80 "xxxxx",
81 " ",
82 "xxxxx",
83 " xxx ",
84 " x "};
85
86 wxRibbonMSWArtProvider::wxRibbonMSWArtProvider(bool set_colour_scheme)
87 {
88 m_flags = 0;
89 m_tab_label_font = wxFont(8, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE);
90 m_button_bar_label_font = m_tab_label_font;
91 m_panel_label_font = m_tab_label_font;
92
93 if(set_colour_scheme)
94 {
95 SetColourScheme(
96 wxColour(194, 216, 241),
97 wxColour(255, 223, 114),
98 wxColour( 0, 0, 0));
99 }
100
101 m_cached_tab_separator_visibility = -10.0; // valid visibilities are in range [0, 1]
102 m_tab_separation_size = 3;
103 m_page_border_left = 2;
104 m_page_border_top = 1;
105 m_page_border_right = 2;
106 m_page_border_bottom = 3;
107 m_panel_x_separation_size = 1;
108 m_panel_y_separation_size = 1;
109 m_tool_group_separation_size = 3;
110 m_gallery_bitmap_padding_left_size = 4;
111 m_gallery_bitmap_padding_right_size = 4;
112 m_gallery_bitmap_padding_top_size = 4;
113 m_gallery_bitmap_padding_bottom_size = 4;
114 }
115
116 wxRibbonMSWArtProvider::~wxRibbonMSWArtProvider()
117 {
118 }
119
120 void wxRibbonMSWArtProvider::GetColourScheme(
121 wxColour* primary,
122 wxColour* secondary,
123 wxColour* tertiary) const
124 {
125 if(primary != NULL)
126 *primary = m_primary_scheme_colour;
127 if(secondary != NULL)
128 *secondary = m_secondary_scheme_colour;
129 if(tertiary != NULL)
130 *tertiary = m_tertiary_scheme_colour;
131 }
132
133 void wxRibbonMSWArtProvider::SetColourScheme(
134 const wxColour& primary,
135 const wxColour& secondary,
136 const wxColour& tertiary)
137 {
138 m_primary_scheme_colour = primary;
139 m_secondary_scheme_colour = secondary;
140 m_tertiary_scheme_colour = tertiary;
141
142 wxRibbonHSLColour primary_hsl(primary);
143 wxRibbonHSLColour secondary_hsl(secondary);
144 // tertiary not used for anything
145
146 // Map primary saturation from [0, 1] to [.25, .75]
147 primary_hsl.saturation = cos(primary_hsl.saturation * M_PI) * -0.25 + 0.5;
148
149 // Map primary luminance from [0, 1] to [.23, .83]
150 primary_hsl.luminance = cos(primary_hsl.luminance * M_PI) * -0.3 + 0.53;
151
152 // Map secondary saturation from [0, 1] to [0.16, 0.84]
153 secondary_hsl.saturation = cos(secondary_hsl.saturation * M_PI) * -0.34 + 0.5;
154
155 // Map secondary luminance from [0, 1] to [0.1, 0.9]
156 secondary_hsl.luminance = cos(secondary_hsl.luminance * M_PI) * -0.4 + 0.5;
157
158 #define LikePrimary(h, s, l) \
159 primary_hsl.ShiftHue(h ## f).Saturated(s ## f).Lighter(l ## f).ToRGB()
160 #define LikeSecondary(h, s, l) \
161 secondary_hsl.ShiftHue(h ## f).Saturated(s ## f).Lighter(l ## f).ToRGB()
162
163 m_page_border_pen = LikePrimary(1.4, 0.00, -0.08);
164
165 m_page_background_top_colour = LikePrimary(-0.1, -0.03, 0.12);
166 m_page_hover_background_top_colour = LikePrimary(-2.8, 0.27, 0.17);
167 m_page_background_top_gradient_colour = LikePrimary(0.1, -0.10, 0.08);
168 m_page_hover_background_top_gradient_colour = LikePrimary(3.2, 0.16, 0.13);
169 m_page_background_colour = LikePrimary(0.4, -0.09, 0.05);
170 m_page_hover_background_colour = LikePrimary(0.1, 0.19, 0.10);
171 m_page_background_gradient_colour = LikePrimary(-3.2, 0.27, 0.10);
172 m_page_hover_background_gradient_colour = LikePrimary(1.8, 0.01, 0.15);
173
174 m_tab_active_background_colour = LikePrimary(-0.1, -0.31, 0.16);
175 m_tab_active_background_gradient_colour = LikePrimary(-0.1, -0.03, 0.12);
176 m_tab_separator_colour = LikePrimary(0.9, 0.24, 0.05);
177 m_tab_ctrl_background_brush = LikePrimary(1.0, 0.39, 0.07);
178 m_tab_hover_background_colour = LikePrimary(1.3, 0.15, 0.10);
179 m_tab_hover_background_top_colour = LikePrimary(1.4, 0.36, 0.08);
180 m_tab_border_pen = LikePrimary(1.4, 0.03, -0.05);
181 m_tab_separator_gradient_colour = LikePrimary(1.7, -0.15, -0.18);
182 m_tab_hover_background_top_gradient_colour = LikePrimary(1.8, 0.34, 0.13);
183 m_tab_label_colour = LikePrimary(4.3, 0.13, -0.49);
184 m_tab_hover_background_gradient_colour = LikeSecondary(-1.5, -0.34, 0.01);
185
186 m_panel_minimised_border_gradient_pen = LikePrimary(-6.9, -0.17, -0.09);
187 m_panel_minimised_border_pen = LikePrimary(-5.3, -0.24, -0.06);
188 m_panel_border_gradient_pen = LikePrimary(-5.2, -0.15, -0.06);
189 m_panel_border_pen = LikePrimary(-2.8, -0.32, 0.02);
190 m_panel_label_background_brush = LikePrimary(-1.5, 0.03, 0.05);
191 m_panel_active_background_gradient_colour = LikePrimary(0.5, 0.34, 0.05);
192 m_panel_hover_label_background_brush = LikePrimary(1.0, 0.30, 0.09);
193 m_panel_active_background_top_gradient_colour = LikePrimary(1.4, -0.17, -0.13);
194 m_panel_active_background_colour = LikePrimary(1.6, -0.18, -0.18);
195 m_panel_active_background_top_colour = LikePrimary(1.7, -0.20, -0.03);
196 m_panel_label_colour = LikePrimary(2.8, -0.14, -0.35);
197 m_panel_hover_label_colour = m_panel_label_colour;
198 m_panel_minimised_label_colour = m_tab_label_colour;
199
200 m_gallery_button_disabled_background_colour = LikePrimary(-2.8, -0.46, 0.09);
201 m_gallery_button_disabled_background_top_brush = LikePrimary(-2.8, -0.36, 0.15);
202 m_gallery_hover_background_brush = LikePrimary(-0.8, 0.05, 0.15);
203 m_gallery_border_pen = LikePrimary(0.7, -0.02, 0.03);
204 m_gallery_button_background_top_brush = LikePrimary(0.8, 0.34, 0.13);
205 m_gallery_button_background_colour = LikePrimary(1.3, 0.10, 0.08);
206 // SetColour used so that the relevant bitmaps are generated
207 SetColour(wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR, LikePrimary(1.4, -0.21, -0.23));
208 SetColour(wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR, LikePrimary(1.5, -0.24, -0.29));
209 SetColour(wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR, LikePrimary(1.5, -0.24, -0.29));
210 SetColour(wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR, LikePrimary(0.0, -1.0, 0.0));
211 m_gallery_button_disabled_background_gradient_colour = LikePrimary(1.5, -0.43, 0.12);
212 m_gallery_button_background_gradient_colour = LikePrimary(1.7, 0.11, 0.09);
213 m_gallery_item_border_pen = LikeSecondary(-3.9, -0.16, -0.14);
214 m_gallery_button_hover_background_colour = LikeSecondary(-0.9, 0.16, -0.07);
215 m_gallery_button_hover_background_gradient_colour = LikeSecondary(0.1, 0.12, 0.03);
216 m_gallery_button_hover_background_top_brush = LikeSecondary(4.3, 0.16, 0.17);
217
218 m_gallery_button_active_background_colour = LikeSecondary(-9.9, 0.03, -0.22);
219 m_gallery_button_active_background_gradient_colour = LikeSecondary(-9.5, 0.14, -0.11);
220 m_gallery_button_active_background_top_brush = LikeSecondary(-9.0, 0.15, -0.08);
221
222 m_button_bar_label_colour = m_tab_label_colour;
223 m_button_bar_hover_border_pen = LikeSecondary(-6.2, -0.47, -0.14);
224 m_button_bar_hover_background_gradient_colour = LikeSecondary(-0.6, 0.16, 0.04);
225 m_button_bar_hover_background_colour = LikeSecondary(-0.2, 0.16, -0.10);
226 m_button_bar_hover_background_top_gradient_colour = LikeSecondary(0.2, 0.16, 0.03);
227 m_button_bar_hover_background_top_colour = LikeSecondary(8.8, 0.16, 0.17);
228 m_button_bar_active_border_pen = LikeSecondary(-6.2, -0.47, -0.25);
229 m_button_bar_active_background_top_colour = LikeSecondary(-8.4, 0.08, 0.06);
230 m_button_bar_active_background_top_gradient_colour = LikeSecondary(-9.7, 0.13, -0.07);
231 m_button_bar_active_background_colour = LikeSecondary(-9.9, 0.14, -0.14);
232 m_button_bar_active_background_gradient_colour = LikeSecondary(-8.7, 0.17, -0.03);
233
234 m_toolbar_border_pen = LikePrimary(1.4, -0.21, -0.16);
235 SetColour(wxRIBBON_ART_TOOLBAR_FACE_COLOUR, LikePrimary(1.4, -0.17, -0.22));
236 m_tool_background_top_colour = LikePrimary(-1.9, -0.07, 0.06);
237 m_tool_background_top_gradient_colour = LikePrimary(1.4, 0.12, 0.08);
238 m_tool_background_colour = LikePrimary(1.4, -0.09, 0.03);
239 m_tool_background_gradient_colour = LikePrimary(1.9, 0.11, 0.09);
240 m_tool_hover_background_top_colour = LikeSecondary(3.4, 0.11, 0.16);
241 m_tool_hover_background_top_gradient_colour = LikeSecondary(-1.4, 0.04, 0.08);
242 m_tool_hover_background_colour = LikeSecondary(-1.8, 0.16, -0.12);
243 m_tool_hover_background_gradient_colour = LikeSecondary(-2.6, 0.16, 0.05);
244 m_tool_active_background_top_colour = LikeSecondary(-9.9, -0.12, -0.09);
245 m_tool_active_background_top_gradient_colour = LikeSecondary(-8.5, 0.16, -0.12);
246 m_tool_active_background_colour = LikeSecondary(-7.9, 0.16, -0.20);
247 m_tool_active_background_gradient_colour = LikeSecondary(-6.6, 0.16, -0.10);
248
249 #undef LikePrimary
250 #undef LikeSecondary
251
252 // Invalidate cached tab separator
253 m_cached_tab_separator_visibility = -1.0;
254 }
255
256 wxRibbonArtProvider* wxRibbonMSWArtProvider::Clone() const
257 {
258 wxRibbonMSWArtProvider *copy = new wxRibbonMSWArtProvider;
259 CloneTo(copy);
260 return copy;
261 }
262
263 void wxRibbonMSWArtProvider::CloneTo(wxRibbonMSWArtProvider* copy) const
264 {
265 for(int i = 0; i < 4; ++i)
266 {
267 copy->m_gallery_up_bitmap[i] = m_gallery_up_bitmap[i];
268 copy->m_gallery_down_bitmap[i] = m_gallery_down_bitmap[i];
269 copy->m_gallery_extension_bitmap[i] = m_gallery_extension_bitmap[i];
270 }
271 copy->m_toolbar_drop_bitmap = m_toolbar_drop_bitmap;
272
273 copy->m_primary_scheme_colour = m_primary_scheme_colour;
274 copy->m_secondary_scheme_colour = m_secondary_scheme_colour;
275 copy->m_tertiary_scheme_colour = m_tertiary_scheme_colour;
276
277 copy->m_button_bar_label_colour = m_button_bar_label_colour;
278 copy->m_tab_label_colour = m_tab_label_colour;
279 copy->m_tab_separator_colour = m_tab_separator_colour;
280 copy->m_tab_separator_gradient_colour = m_tab_separator_gradient_colour;
281 copy->m_tab_active_background_colour = m_tab_hover_background_colour;
282 copy->m_tab_active_background_gradient_colour = m_tab_hover_background_gradient_colour;
283 copy->m_tab_hover_background_colour = m_tab_hover_background_colour;
284 copy->m_tab_hover_background_gradient_colour = m_tab_hover_background_gradient_colour;
285 copy->m_tab_hover_background_top_colour = m_tab_hover_background_top_colour;
286 copy->m_tab_hover_background_top_gradient_colour = m_tab_hover_background_top_gradient_colour;
287 copy->m_panel_label_colour = m_panel_label_colour;
288 copy->m_panel_hover_label_colour = m_panel_hover_label_colour;
289 copy->m_panel_minimised_label_colour = m_panel_minimised_label_colour;
290 copy->m_panel_active_background_colour = m_panel_active_background_colour;
291 copy->m_panel_active_background_gradient_colour = m_panel_active_background_gradient_colour;
292 copy->m_panel_active_background_top_colour = m_panel_active_background_top_colour;
293 copy->m_panel_active_background_top_gradient_colour = m_panel_active_background_top_gradient_colour;
294 copy->m_page_background_colour = m_page_background_colour;
295 copy->m_page_background_gradient_colour = m_page_background_gradient_colour;
296 copy->m_page_background_top_colour = m_page_background_top_colour;
297 copy->m_page_background_top_gradient_colour = m_page_background_top_gradient_colour;
298 copy->m_page_hover_background_colour = m_page_hover_background_colour;
299 copy->m_page_hover_background_gradient_colour = m_page_hover_background_gradient_colour;
300 copy->m_page_hover_background_top_colour = m_page_hover_background_top_colour;
301 copy->m_page_hover_background_top_gradient_colour = m_page_hover_background_top_gradient_colour;
302 copy->m_button_bar_hover_background_colour = m_button_bar_hover_background_colour;
303 copy->m_button_bar_hover_background_gradient_colour = m_button_bar_hover_background_gradient_colour;
304 copy->m_button_bar_hover_background_top_colour = m_button_bar_hover_background_top_colour;
305 copy->m_button_bar_hover_background_top_gradient_colour = m_button_bar_hover_background_top_gradient_colour;
306 copy->m_button_bar_active_background_colour = m_button_bar_active_background_colour;
307 copy->m_button_bar_active_background_gradient_colour = m_button_bar_active_background_gradient_colour;
308 copy->m_button_bar_active_background_top_colour = m_button_bar_active_background_top_colour;
309 copy->m_button_bar_active_background_top_gradient_colour = m_button_bar_active_background_top_gradient_colour;
310 copy->m_gallery_button_background_colour = m_gallery_button_background_colour;
311 copy->m_gallery_button_background_gradient_colour = m_gallery_button_background_gradient_colour;
312 copy->m_gallery_button_hover_background_colour = m_gallery_button_hover_background_colour;
313 copy->m_gallery_button_hover_background_gradient_colour = m_gallery_button_hover_background_gradient_colour;
314 copy->m_gallery_button_active_background_colour = m_gallery_button_active_background_colour;
315 copy->m_gallery_button_active_background_gradient_colour = m_gallery_button_active_background_gradient_colour;
316 copy->m_gallery_button_disabled_background_colour = m_gallery_button_disabled_background_colour;
317 copy->m_gallery_button_disabled_background_gradient_colour = m_gallery_button_disabled_background_gradient_colour;
318 copy->m_gallery_button_face_colour = m_gallery_button_face_colour;
319 copy->m_gallery_button_hover_face_colour = m_gallery_button_hover_face_colour;
320 copy->m_gallery_button_active_face_colour = m_gallery_button_active_face_colour;
321 copy->m_gallery_button_disabled_face_colour = m_gallery_button_disabled_face_colour;
322
323 copy->m_tab_ctrl_background_brush = m_tab_ctrl_background_brush;
324 copy->m_panel_label_background_brush = m_panel_label_background_brush;
325 copy->m_panel_hover_label_background_brush = m_panel_hover_label_background_brush;
326 copy->m_gallery_hover_background_brush = m_gallery_hover_background_brush;
327 copy->m_gallery_button_background_top_brush = m_gallery_button_background_top_brush;
328 copy->m_gallery_button_hover_background_top_brush = m_gallery_button_hover_background_top_brush;
329 copy->m_gallery_button_active_background_top_brush = m_gallery_button_active_background_top_brush;
330 copy->m_gallery_button_disabled_background_top_brush = m_gallery_button_disabled_background_top_brush;
331
332 copy->m_tab_label_font = m_tab_label_font;
333 copy->m_button_bar_label_font = m_button_bar_label_font;
334 copy->m_panel_label_font = m_panel_label_font;
335
336 copy->m_page_border_pen = m_page_border_pen;
337 copy->m_panel_border_pen = m_panel_border_pen;
338 copy->m_panel_border_gradient_pen = m_panel_border_gradient_pen;
339 copy->m_panel_minimised_border_pen = m_panel_minimised_border_pen;
340 copy->m_panel_minimised_border_gradient_pen = m_panel_minimised_border_gradient_pen;
341 copy->m_tab_border_pen = m_tab_border_pen;
342 copy->m_gallery_border_pen = m_gallery_border_pen;
343 copy->m_button_bar_hover_border_pen = m_button_bar_hover_border_pen;
344 copy->m_button_bar_active_border_pen = m_button_bar_active_border_pen;
345 copy->m_gallery_item_border_pen = m_gallery_item_border_pen;
346 copy->m_toolbar_border_pen = m_toolbar_border_pen;
347
348 copy->m_flags = m_flags;
349 copy->m_tab_separation_size = m_tab_separation_size;
350 copy->m_page_border_left = m_page_border_left;
351 copy->m_page_border_top = m_page_border_top;
352 copy->m_page_border_right = m_page_border_right;
353 copy->m_page_border_bottom = m_page_border_bottom;
354 copy->m_panel_x_separation_size = m_panel_x_separation_size;
355 copy->m_panel_y_separation_size = m_panel_y_separation_size;
356 copy->m_gallery_bitmap_padding_left_size = m_gallery_bitmap_padding_left_size;
357 copy->m_gallery_bitmap_padding_right_size = m_gallery_bitmap_padding_right_size;
358 copy->m_gallery_bitmap_padding_top_size = m_gallery_bitmap_padding_top_size;
359 copy->m_gallery_bitmap_padding_bottom_size = m_gallery_bitmap_padding_bottom_size;
360 }
361
362 long wxRibbonMSWArtProvider::GetFlags() const
363 {
364 return m_flags;
365 }
366
367 void wxRibbonMSWArtProvider::SetFlags(long flags)
368 {
369 if((flags ^ m_flags) & wxRIBBON_BAR_FLOW_VERTICAL)
370 {
371 if(flags & wxRIBBON_BAR_FLOW_VERTICAL)
372 {
373 m_page_border_left++;
374 m_page_border_right++;
375 m_page_border_top--;
376 m_page_border_bottom--;
377 }
378 else
379 {
380 m_page_border_left--;
381 m_page_border_right--;
382 m_page_border_top++;
383 m_page_border_bottom++;
384 }
385 }
386 m_flags = flags;
387
388 // Need to reload some bitmaps when flags change
389 #define Reload(setting) SetColour(setting, GetColour(setting))
390 Reload(wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR);
391 Reload(wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR);
392 Reload(wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR);
393 Reload(wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR);
394 #undef Reload
395 }
396
397 int wxRibbonMSWArtProvider::GetMetric(int id) const
398 {
399 switch(id)
400 {
401 case wxRIBBON_ART_TAB_SEPARATION_SIZE:
402 return m_tab_separation_size;
403 case wxRIBBON_ART_PAGE_BORDER_LEFT_SIZE:
404 return m_page_border_left;
405 case wxRIBBON_ART_PAGE_BORDER_TOP_SIZE:
406 return m_page_border_top;
407 case wxRIBBON_ART_PAGE_BORDER_RIGHT_SIZE:
408 return m_page_border_right;
409 case wxRIBBON_ART_PAGE_BORDER_BOTTOM_SIZE:
410 return m_page_border_bottom;
411 case wxRIBBON_ART_PANEL_X_SEPARATION_SIZE:
412 return m_panel_x_separation_size;
413 case wxRIBBON_ART_PANEL_Y_SEPARATION_SIZE:
414 return m_panel_y_separation_size;
415 case wxRIBBON_ART_TOOL_GROUP_SEPARATION_SIZE:
416 return m_tool_group_separation_size;
417 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_LEFT_SIZE:
418 return m_gallery_bitmap_padding_left_size;
419 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_RIGHT_SIZE:
420 return m_gallery_bitmap_padding_right_size;
421 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_TOP_SIZE:
422 return m_gallery_bitmap_padding_top_size;
423 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_BOTTOM_SIZE:
424 return m_gallery_bitmap_padding_bottom_size;
425 default:
426 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
427 break;
428 }
429
430 return 0;
431 }
432
433 void wxRibbonMSWArtProvider::SetMetric(int id, int new_val)
434 {
435 switch(id)
436 {
437 case wxRIBBON_ART_TAB_SEPARATION_SIZE:
438 m_tab_separation_size = new_val;
439 break;
440 case wxRIBBON_ART_PAGE_BORDER_LEFT_SIZE:
441 m_page_border_left = new_val;
442 break;
443 case wxRIBBON_ART_PAGE_BORDER_TOP_SIZE:
444 m_page_border_top = new_val;
445 break;
446 case wxRIBBON_ART_PAGE_BORDER_RIGHT_SIZE:
447 m_page_border_right = new_val;
448 break;
449 case wxRIBBON_ART_PAGE_BORDER_BOTTOM_SIZE:
450 m_page_border_bottom = new_val;
451 break;
452 case wxRIBBON_ART_PANEL_X_SEPARATION_SIZE:
453 m_panel_x_separation_size = new_val;
454 break;
455 case wxRIBBON_ART_PANEL_Y_SEPARATION_SIZE:
456 m_panel_y_separation_size = new_val;
457 break;
458 case wxRIBBON_ART_TOOL_GROUP_SEPARATION_SIZE:
459 m_tool_group_separation_size = new_val;
460 break;
461 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_LEFT_SIZE:
462 m_gallery_bitmap_padding_left_size = new_val;
463 break;
464 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_RIGHT_SIZE:
465 m_gallery_bitmap_padding_right_size = new_val;
466 break;
467 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_TOP_SIZE:
468 m_gallery_bitmap_padding_top_size = new_val;
469 break;
470 case wxRIBBON_ART_GALLERY_BITMAP_PADDING_BOTTOM_SIZE:
471 m_gallery_bitmap_padding_bottom_size = new_val;
472 break;
473 default:
474 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
475 break;
476 }
477 }
478
479 void wxRibbonMSWArtProvider::SetFont(int id, const wxFont& font)
480 {
481 switch(id)
482 {
483 case wxRIBBON_ART_TAB_LABEL_FONT:
484 m_tab_label_font = font;
485 break;
486 case wxRIBBON_ART_BUTTON_BAR_LABEL_FONT:
487 m_button_bar_label_font = font;
488 break;
489 case wxRIBBON_ART_PANEL_LABEL_FONT:
490 m_panel_label_font = font;
491 break;
492 default:
493 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
494 break;
495 }
496 }
497
498 wxFont wxRibbonMSWArtProvider::GetFont(int id) const
499 {
500 switch(id)
501 {
502 case wxRIBBON_ART_TAB_LABEL_FONT:
503 return m_tab_label_font;
504 case wxRIBBON_ART_BUTTON_BAR_LABEL_FONT:
505 return m_button_bar_label_font;
506 case wxRIBBON_ART_PANEL_LABEL_FONT:
507 return m_panel_label_font;
508 default:
509 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
510 break;
511 }
512
513 return wxNullFont;
514 }
515
516 wxColour wxRibbonMSWArtProvider::GetColour(int id) const
517 {
518 switch(id)
519 {
520 case wxRIBBON_ART_BUTTON_BAR_LABEL_COLOUR:
521 return m_button_bar_label_colour;
522 case wxRIBBON_ART_BUTTON_BAR_HOVER_BORDER_COLOUR:
523 return m_button_bar_hover_border_pen.GetColour();
524 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_COLOUR:
525 return m_button_bar_hover_background_top_colour;
526 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR:
527 return m_button_bar_hover_background_top_gradient_colour;
528 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_COLOUR:
529 return m_button_bar_hover_background_colour;
530 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_GRADIENT_COLOUR:
531 return m_button_bar_hover_background_gradient_colour;
532 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BORDER_COLOUR:
533 return m_button_bar_active_border_pen.GetColour();
534 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_COLOUR:
535 return m_button_bar_active_background_top_colour;
536 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR:
537 return m_button_bar_active_background_top_gradient_colour;
538 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_COLOUR:
539 return m_button_bar_active_background_colour;
540 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_GRADIENT_COLOUR:
541 return m_button_bar_active_background_gradient_colour;
542 case wxRIBBON_ART_GALLERY_BORDER_COLOUR:
543 return m_gallery_border_pen.GetColour();
544 case wxRIBBON_ART_GALLERY_HOVER_BACKGROUND_COLOUR:
545 return m_gallery_hover_background_brush.GetColour();
546 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_COLOUR:
547 return m_gallery_button_background_colour;
548 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_GRADIENT_COLOUR:
549 return m_gallery_button_background_gradient_colour;
550 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_TOP_COLOUR:
551 return m_gallery_button_background_top_brush.GetColour();
552 case wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR:
553 return m_gallery_button_face_colour;
554 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_COLOUR:
555 return m_gallery_button_hover_background_colour;
556 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_GRADIENT_COLOUR:
557 return m_gallery_button_hover_background_gradient_colour;
558 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_TOP_COLOUR:
559 return m_gallery_button_hover_background_top_brush.GetColour();
560 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR:
561 return m_gallery_button_face_colour;
562 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_COLOUR:
563 return m_gallery_button_active_background_colour;
564 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_GRADIENT_COLOUR:
565 return m_gallery_button_active_background_gradient_colour;
566 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_TOP_COLOUR:
567 return m_gallery_button_background_top_brush.GetColour();
568 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR:
569 return m_gallery_button_active_face_colour;
570 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_COLOUR:
571 return m_gallery_button_disabled_background_colour;
572 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_GRADIENT_COLOUR:
573 return m_gallery_button_disabled_background_gradient_colour;
574 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_TOP_COLOUR:
575 return m_gallery_button_disabled_background_top_brush.GetColour();
576 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR:
577 return m_gallery_button_disabled_face_colour;
578 case wxRIBBON_ART_GALLERY_ITEM_BORDER_COLOUR:
579 return m_gallery_item_border_pen.GetColour();
580 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_COLOUR:
581 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_GRADIENT_COLOUR:
582 return m_tab_ctrl_background_brush.GetColour();
583 case wxRIBBON_ART_TAB_LABEL_COLOUR:
584 return m_tab_label_colour;
585 case wxRIBBON_ART_TAB_SEPARATOR_COLOUR:
586 return m_tab_separator_colour;
587 case wxRIBBON_ART_TAB_SEPARATOR_GRADIENT_COLOUR:
588 return m_tab_separator_gradient_colour;
589 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_COLOUR:
590 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR:
591 return wxColour(0, 0, 0);
592 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_COLOUR:
593 return m_tab_active_background_colour;
594 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_GRADIENT_COLOUR:
595 return m_tab_active_background_gradient_colour;
596 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_COLOUR:
597 return m_tab_hover_background_top_colour;
598 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR:
599 return m_tab_hover_background_top_gradient_colour;
600 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_COLOUR:
601 return m_tab_hover_background_colour;
602 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_GRADIENT_COLOUR:
603 return m_tab_hover_background_gradient_colour;
604 case wxRIBBON_ART_TAB_BORDER_COLOUR:
605 return m_tab_border_pen.GetColour();
606 case wxRIBBON_ART_PANEL_BORDER_COLOUR:
607 return m_panel_border_pen.GetColour();
608 case wxRIBBON_ART_PANEL_BORDER_GRADIENT_COLOUR:
609 return m_panel_border_gradient_pen.GetColour();
610 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_COLOUR:
611 return m_panel_minimised_border_pen.GetColour();
612 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_GRADIENT_COLOUR:
613 return m_panel_minimised_border_gradient_pen.GetColour();
614 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_COLOUR:
615 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_GRADIENT_COLOUR:
616 return m_panel_label_background_brush.GetColour();
617 case wxRIBBON_ART_PANEL_LABEL_COLOUR:
618 return m_panel_label_colour;
619 case wxRIBBON_ART_PANEL_MINIMISED_LABEL_COLOUR:
620 return m_panel_minimised_label_colour;
621 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_COLOUR:
622 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_GRADIENT_COLOUR:
623 return m_panel_hover_label_background_brush.GetColour();
624 case wxRIBBON_ART_PANEL_HOVER_LABEL_COLOUR:
625 return m_panel_hover_label_colour;
626 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_COLOUR:
627 return m_panel_active_background_top_colour;
628 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR:
629 return m_panel_active_background_top_gradient_colour;
630 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_COLOUR:
631 return m_panel_active_background_colour;
632 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_GRADIENT_COLOUR:
633 return m_panel_active_background_gradient_colour;
634 case wxRIBBON_ART_PAGE_BORDER_COLOUR:
635 return m_page_border_pen.GetColour();
636 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_COLOUR:
637 return m_page_background_top_colour;
638 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_GRADIENT_COLOUR:
639 return m_page_background_top_gradient_colour;
640 case wxRIBBON_ART_PAGE_BACKGROUND_COLOUR:
641 return m_page_background_colour;
642 case wxRIBBON_ART_PAGE_BACKGROUND_GRADIENT_COLOUR:
643 return m_page_background_gradient_colour;
644 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_COLOUR:
645 return m_page_hover_background_top_colour;
646 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR:
647 return m_page_hover_background_top_gradient_colour;
648 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_COLOUR:
649 return m_page_hover_background_colour;
650 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_GRADIENT_COLOUR:
651 return m_page_hover_background_gradient_colour;
652 case wxRIBBON_ART_TOOLBAR_BORDER_COLOUR:
653 case wxRIBBON_ART_TOOLBAR_HOVER_BORDER_COLOUR:
654 return m_toolbar_border_pen.GetColour();
655 case wxRIBBON_ART_TOOLBAR_FACE_COLOUR:
656 return m_tool_face_colour;
657 default:
658 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
659 break;
660 }
661
662 return wxColour();
663 }
664
665 void wxRibbonMSWArtProvider::SetColour(int id, const wxColor& colour)
666 {
667 switch(id)
668 {
669 case wxRIBBON_ART_BUTTON_BAR_LABEL_COLOUR:
670 m_button_bar_label_colour = colour;
671 break;
672 case wxRIBBON_ART_BUTTON_BAR_HOVER_BORDER_COLOUR:
673 m_button_bar_hover_border_pen.SetColour(colour);
674 break;
675 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_COLOUR:
676 m_button_bar_hover_background_top_colour = colour;
677 break;
678 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR:
679 m_button_bar_hover_background_top_gradient_colour = colour;
680 break;
681 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_COLOUR:
682 m_button_bar_hover_background_colour = colour;
683 break;
684 case wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_GRADIENT_COLOUR:
685 m_button_bar_hover_background_gradient_colour = colour;
686 break;
687 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BORDER_COLOUR:
688 m_button_bar_active_border_pen.SetColour(colour);
689 break;
690 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_COLOUR:
691 m_button_bar_active_background_top_colour = colour;
692 break;
693 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR:
694 m_button_bar_active_background_top_gradient_colour = colour;
695 break;
696 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_COLOUR:
697 m_button_bar_active_background_colour = colour;
698 break;
699 case wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_GRADIENT_COLOUR:
700 m_button_bar_active_background_gradient_colour = colour;
701 break;
702 case wxRIBBON_ART_GALLERY_BORDER_COLOUR:
703 m_gallery_border_pen.SetColour(colour);
704 break;
705 case wxRIBBON_ART_GALLERY_HOVER_BACKGROUND_COLOUR:
706 m_gallery_hover_background_brush.SetColour(colour);
707 break;
708 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_COLOUR:
709 m_gallery_button_background_colour = colour;
710 break;
711 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_GRADIENT_COLOUR:
712 m_gallery_button_background_gradient_colour = colour;
713 break;
714 case wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_TOP_COLOUR:
715 m_gallery_button_background_top_brush.SetColour(colour);
716 break;
717 case wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR:
718 m_gallery_button_face_colour = colour;
719 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
720 {
721 m_gallery_up_bitmap[0] = wxRibbonLoadPixmap(gallery_left_xpm, colour);
722 m_gallery_down_bitmap[0] = wxRibbonLoadPixmap(gallery_right_xpm, colour);
723 }
724 else
725 {
726 m_gallery_up_bitmap[0] = wxRibbonLoadPixmap(gallery_up_xpm, colour);
727 m_gallery_down_bitmap[0] = wxRibbonLoadPixmap(gallery_down_xpm, colour);
728 }
729 m_gallery_extension_bitmap[0] = wxRibbonLoadPixmap(gallery_extension_xpm, colour);
730 break;
731 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_COLOUR:
732 m_gallery_button_hover_background_colour = colour;
733 break;
734 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_GRADIENT_COLOUR:
735 m_gallery_button_hover_background_gradient_colour = colour;
736 break;
737 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_TOP_COLOUR:
738 m_gallery_button_hover_background_top_brush.SetColour(colour);
739 break;
740 case wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR:
741 m_gallery_button_hover_face_colour = colour;
742 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
743 {
744 m_gallery_up_bitmap[1] = wxRibbonLoadPixmap(gallery_left_xpm, colour);
745 m_gallery_down_bitmap[1] = wxRibbonLoadPixmap(gallery_right_xpm, colour);
746 }
747 else
748 {
749 m_gallery_up_bitmap[1] = wxRibbonLoadPixmap(gallery_up_xpm, colour);
750 m_gallery_down_bitmap[1] = wxRibbonLoadPixmap(gallery_down_xpm, colour);
751 }
752 m_gallery_extension_bitmap[1] = wxRibbonLoadPixmap(gallery_extension_xpm, colour);
753 break;
754 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_COLOUR:
755 m_gallery_button_active_background_colour = colour;
756 break;
757 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_GRADIENT_COLOUR:
758 m_gallery_button_active_background_gradient_colour = colour;
759 break;
760 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_TOP_COLOUR:
761 m_gallery_button_background_top_brush.SetColour(colour);
762 break;
763 case wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR:
764 m_gallery_button_active_face_colour = colour;
765 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
766 {
767 m_gallery_up_bitmap[2] = wxRibbonLoadPixmap(gallery_left_xpm, colour);
768 m_gallery_down_bitmap[2] = wxRibbonLoadPixmap(gallery_right_xpm, colour);
769 }
770 else
771 {
772 m_gallery_up_bitmap[2] = wxRibbonLoadPixmap(gallery_up_xpm, colour);
773 m_gallery_down_bitmap[2] = wxRibbonLoadPixmap(gallery_down_xpm, colour);
774 }
775 m_gallery_extension_bitmap[2] = wxRibbonLoadPixmap(gallery_extension_xpm, colour);
776 break;
777 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_COLOUR:
778 m_gallery_button_disabled_background_colour = colour;
779 break;
780 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_GRADIENT_COLOUR:
781 m_gallery_button_disabled_background_gradient_colour = colour;
782 break;
783 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_TOP_COLOUR:
784 m_gallery_button_disabled_background_top_brush.SetColour(colour);
785 break;
786 case wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR:
787 m_gallery_button_disabled_face_colour = colour;
788 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
789 {
790 m_gallery_up_bitmap[3] = wxRibbonLoadPixmap(gallery_left_xpm, colour);
791 m_gallery_down_bitmap[3] = wxRibbonLoadPixmap(gallery_right_xpm, colour);
792 }
793 else
794 {
795 m_gallery_up_bitmap[3] = wxRibbonLoadPixmap(gallery_up_xpm, colour);
796 m_gallery_down_bitmap[3] = wxRibbonLoadPixmap(gallery_down_xpm, colour);
797 }
798 m_gallery_extension_bitmap[3] = wxRibbonLoadPixmap(gallery_extension_xpm, colour);
799 break;
800 case wxRIBBON_ART_GALLERY_ITEM_BORDER_COLOUR:
801 m_gallery_item_border_pen.SetColour(colour);
802 break;
803 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_COLOUR:
804 case wxRIBBON_ART_TAB_CTRL_BACKGROUND_GRADIENT_COLOUR:
805 m_tab_ctrl_background_brush.SetColour(colour);
806 m_cached_tab_separator_visibility = -1.0;
807 break;
808 case wxRIBBON_ART_TAB_LABEL_COLOUR:
809 m_tab_label_colour = colour;
810 break;
811 case wxRIBBON_ART_TAB_SEPARATOR_COLOUR:
812 m_tab_separator_colour = colour;
813 m_cached_tab_separator_visibility = -1.0;
814 break;
815 case wxRIBBON_ART_TAB_SEPARATOR_GRADIENT_COLOUR:
816 m_tab_separator_gradient_colour = colour;
817 m_cached_tab_separator_visibility = -1.0;
818 break;
819 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_COLOUR:
820 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR:
821 break;
822 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_COLOUR:
823 m_tab_active_background_colour = colour;
824 break;
825 case wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_GRADIENT_COLOUR:
826 m_tab_active_background_gradient_colour = colour;
827 break;
828 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_COLOUR:
829 m_tab_hover_background_top_colour = colour;
830 break;
831 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR:
832 m_tab_hover_background_top_gradient_colour = colour;
833 break;
834 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_COLOUR:
835 m_tab_hover_background_colour = colour;
836 break;
837 case wxRIBBON_ART_TAB_HOVER_BACKGROUND_GRADIENT_COLOUR:
838 m_tab_hover_background_gradient_colour = colour;
839 break;
840 case wxRIBBON_ART_TAB_BORDER_COLOUR:
841 m_tab_border_pen.SetColour(colour);
842 break;
843 case wxRIBBON_ART_PANEL_BORDER_COLOUR:
844 m_panel_border_pen.SetColour(colour);
845 break;
846 case wxRIBBON_ART_PANEL_BORDER_GRADIENT_COLOUR:
847 m_panel_border_gradient_pen.SetColour(colour);
848 break;
849 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_COLOUR:
850 m_panel_minimised_border_pen.SetColour(colour);
851 break;
852 case wxRIBBON_ART_PANEL_MINIMISED_BORDER_GRADIENT_COLOUR:
853 m_panel_minimised_border_gradient_pen.SetColour(colour);
854 break;
855 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_COLOUR:
856 case wxRIBBON_ART_PANEL_LABEL_BACKGROUND_GRADIENT_COLOUR:
857 m_panel_label_background_brush.SetColour(colour);
858 break;
859 case wxRIBBON_ART_PANEL_LABEL_COLOUR:
860 m_panel_label_colour = colour;
861 break;
862 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_COLOUR:
863 case wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_GRADIENT_COLOUR:
864 m_panel_hover_label_background_brush.SetColour(colour);
865 break;
866 case wxRIBBON_ART_PANEL_HOVER_LABEL_COLOUR:
867 m_panel_hover_label_colour = colour;
868 break;
869 case wxRIBBON_ART_PANEL_MINIMISED_LABEL_COLOUR:
870 m_panel_minimised_label_colour = colour;
871 break;
872 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_COLOUR:
873 m_panel_active_background_top_colour = colour;
874 break;
875 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR:
876 m_panel_active_background_top_gradient_colour = colour;
877 break;
878 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_COLOUR:
879 m_panel_active_background_colour = colour;
880 break;
881 case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_GRADIENT_COLOUR:
882 m_panel_active_background_gradient_colour = colour;
883 break;
884 case wxRIBBON_ART_PAGE_BORDER_COLOUR:
885 m_page_border_pen.SetColour(colour);
886 break;
887 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_COLOUR:
888 m_page_background_top_colour = colour;
889 break;
890 case wxRIBBON_ART_PAGE_BACKGROUND_TOP_GRADIENT_COLOUR:
891 m_page_background_top_gradient_colour = colour;
892 break;
893 case wxRIBBON_ART_PAGE_BACKGROUND_COLOUR:
894 m_page_background_colour = colour;
895 break;
896 case wxRIBBON_ART_PAGE_BACKGROUND_GRADIENT_COLOUR:
897 m_page_background_gradient_colour = colour;
898 break;
899 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_COLOUR:
900 m_page_hover_background_top_colour = colour;
901 break;
902 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR:
903 m_page_hover_background_top_gradient_colour = colour;
904 break;
905 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_COLOUR:
906 m_page_hover_background_colour = colour;
907 break;
908 case wxRIBBON_ART_PAGE_HOVER_BACKGROUND_GRADIENT_COLOUR:
909 m_page_hover_background_gradient_colour = colour;
910 break;
911 case wxRIBBON_ART_TOOLBAR_BORDER_COLOUR:
912 case wxRIBBON_ART_TOOLBAR_HOVER_BORDER_COLOUR:
913 m_toolbar_border_pen.SetColour(colour);
914 break;
915 case wxRIBBON_ART_TOOLBAR_FACE_COLOUR:
916 m_tool_face_colour = colour;
917 m_toolbar_drop_bitmap = wxRibbonLoadPixmap(gallery_down_xpm, colour);
918 break;
919 default:
920 wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
921 break;
922 }
923 }
924
925 void wxRibbonMSWArtProvider::DrawTabCtrlBackground(
926 wxDC& dc,
927 wxWindow* WXUNUSED(wnd),
928 const wxRect& rect)
929 {
930 dc.SetPen(*wxTRANSPARENT_PEN);
931 dc.SetBrush(m_tab_ctrl_background_brush);
932 dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
933
934 dc.SetPen(m_page_border_pen);
935 if(rect.width > 6)
936 {
937 dc.DrawLine(rect.x + 3, rect.y + rect.height - 1, rect.x + rect.width - 3, rect.y + rect.height - 1);
938 }
939 else
940 {
941 dc.DrawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width, rect.y + rect.height - 1);
942 }
943 }
944
945 void wxRibbonMSWArtProvider::DrawTab(
946 wxDC& dc,
947 wxWindow* WXUNUSED(wnd),
948 const wxRibbonPageTabInfo& tab)
949 {
950 if(tab.rect.height <= 2)
951 return;
952
953 if(tab.active || tab.hovered)
954 {
955 if(tab.active)
956 {
957 wxRect background(tab.rect);
958
959 background.x += 2;
960 background.y += 2;
961 background.width -= 4;
962 background.height -= 2;
963
964 dc.GradientFillLinear(background, m_tab_active_background_colour,
965 m_tab_active_background_gradient_colour, wxSOUTH);
966
967 // TODO: active and hovered
968 }
969 else if(tab.hovered)
970 {
971 wxRect background(tab.rect);
972
973 background.x += 2;
974 background.y += 2;
975 background.width -= 4;
976 background.height -= 3;
977 int h = background.height;
978 background.height /= 2;
979 dc.GradientFillLinear(background,
980 m_tab_hover_background_top_colour,
981 m_tab_hover_background_top_gradient_colour, wxSOUTH);
982
983 background.y += background.height;
984 background.height = h - background.height;
985 dc.GradientFillLinear(background, m_tab_hover_background_colour,
986 m_tab_hover_background_gradient_colour, wxSOUTH);
987 }
988
989 wxPoint border_points[6];
990 border_points[0] = wxPoint(1, tab.rect.height - 2);
991 border_points[1] = wxPoint(1, 3);
992 border_points[2] = wxPoint(3, 1);
993 border_points[3] = wxPoint(tab.rect.width - 4, 1);
994 border_points[4] = wxPoint(tab.rect.width - 2, 3);
995 border_points[5] = wxPoint(tab.rect.width - 2, tab.rect.height - 1);
996
997 dc.SetPen(m_tab_border_pen);
998 dc.DrawLines(sizeof(border_points)/sizeof(wxPoint), border_points, tab.rect.x, tab.rect.y);
999
1000 if(tab.active)
1001 {
1002 // Give the tab a curved outward border at the bottom
1003 dc.DrawPoint(tab.rect.x, tab.rect.y + tab.rect.height - 2);
1004 dc.DrawPoint(tab.rect.x + tab.rect.width - 1, tab.rect.y + tab.rect.height - 2);
1005
1006 wxPen p(m_tab_active_background_gradient_colour);
1007 dc.SetPen(p);
1008
1009 // Technically the first two points are the wrong colour, but they're near enough
1010 dc.DrawPoint(tab.rect.x + 1, tab.rect.y + tab.rect.height - 2);
1011 dc.DrawPoint(tab.rect.x + tab.rect.width - 2, tab.rect.y + tab.rect.height - 2);
1012 dc.DrawPoint(tab.rect.x + 1, tab.rect.y + tab.rect.height - 1);
1013 dc.DrawPoint(tab.rect.x, tab.rect.y + tab.rect.height - 1);
1014 dc.DrawPoint(tab.rect.x + tab.rect.width - 2, tab.rect.y + tab.rect.height - 1);
1015 dc.DrawPoint(tab.rect.x + tab.rect.width - 1, tab.rect.y + tab.rect.height - 1);
1016 }
1017 }
1018
1019 if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS)
1020 {
1021 wxBitmap icon = tab.page->GetIcon();
1022 int x = tab.rect.x + 4;
1023 if((m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) == 0)
1024 x = tab.rect.x + (tab.rect.width - icon.GetWidth()) / 2;
1025 dc.DrawBitmap(icon, x, tab.rect.y + 1 + (tab.rect.height - 1 -
1026 icon.GetHeight()) / 2, true);
1027 }
1028 if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS)
1029 {
1030 wxString label = tab.page->GetLabel();
1031 if(!label.IsEmpty())
1032 {
1033 dc.SetFont(m_tab_label_font);
1034 dc.SetTextForeground(m_tab_label_colour);
1035 dc.SetBackgroundMode(wxTRANSPARENT);
1036
1037 int text_height;
1038 int text_width;
1039 dc.GetTextExtent(label, &text_width, &text_height);
1040 int width = tab.rect.width - 5;
1041 int x = tab.rect.x + 3;
1042 if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS)
1043 {
1044 x += 3 + tab.page->GetIcon().GetWidth();
1045 width -= 3 + tab.page->GetIcon().GetWidth();
1046 }
1047 int y = tab.rect.y + (tab.rect.height - text_height) / 2;
1048
1049 if(width <= text_width)
1050 {
1051 dc.SetClippingRegion(x, tab.rect.y, width, tab.rect.height);
1052 dc.DrawText(label, x, y);
1053 }
1054 else
1055 {
1056 dc.DrawText(label, x + (width - text_width) / 2 + 1, y);
1057 }
1058 }
1059 }
1060 }
1061
1062 void wxRibbonMSWArtProvider::DrawTabSeparator(
1063 wxDC& dc,
1064 wxWindow* wnd,
1065 const wxRect& rect,
1066 double visibility)
1067 {
1068 if(visibility <= 0.0)
1069 {
1070 return;
1071 }
1072 if(visibility > 1.0)
1073 {
1074 visibility = 1.0;
1075 }
1076
1077 // The tab separator is relatively expensive to draw (for its size), and is
1078 // usually drawn multiple times sequentially (in different positions), so it
1079 // makes sense to draw it once and cache it.
1080 if(!m_cached_tab_separator.IsOk() || m_cached_tab_separator.GetSize() != rect.GetSize() || visibility != m_cached_tab_separator_visibility)
1081 {
1082 wxRect size(rect.GetSize());
1083 ReallyDrawTabSeparator(wnd, size, visibility);
1084 }
1085 dc.DrawBitmap(m_cached_tab_separator, rect.x, rect.y, false);
1086 }
1087
1088 void wxRibbonMSWArtProvider::ReallyDrawTabSeparator(wxWindow* wnd, const wxRect& rect, double visibility)
1089 {
1090 if(!m_cached_tab_separator.IsOk() || m_cached_tab_separator.GetSize() != rect.GetSize())
1091 {
1092 m_cached_tab_separator = wxBitmap(rect.GetSize());
1093 }
1094
1095 wxMemoryDC dc(m_cached_tab_separator);
1096 DrawTabCtrlBackground(dc, wnd, rect);
1097
1098 wxCoord x = rect.x + rect.width / 2;
1099 double h = (double)(rect.height - 1);
1100
1101 double r1 = m_tab_ctrl_background_brush.GetColour().Red() * (1.0 - visibility) + 0.5;
1102 double g1 = m_tab_ctrl_background_brush.GetColour().Green() * (1.0 - visibility) + 0.5;
1103 double b1 = m_tab_ctrl_background_brush.GetColour().Blue() * (1.0 - visibility) + 0.5;
1104 double r2 = m_tab_separator_colour.Red();
1105 double g2 = m_tab_separator_colour.Green();
1106 double b2 = m_tab_separator_colour.Blue();
1107 double r3 = m_tab_separator_gradient_colour.Red();
1108 double g3 = m_tab_separator_gradient_colour.Green();
1109 double b3 = m_tab_separator_gradient_colour.Blue();
1110
1111 for(int i = 0; i < rect.height - 1; ++i)
1112 {
1113 double p = ((double)i)/h;
1114
1115 double r = (p * r3 + (1.0 - p) * r2) * visibility + r1;
1116 double g = (p * g3 + (1.0 - p) * g2) * visibility + g1;
1117 double b = (p * b3 + (1.0 - p) * b2) * visibility + b1;
1118
1119 wxPen P(wxColour((unsigned char)r, (unsigned char)g, (unsigned char)b));
1120 dc.SetPen(P);
1121 dc.DrawPoint(x, rect.y + i);
1122 }
1123
1124 m_cached_tab_separator_visibility = visibility;
1125 }
1126
1127 void wxRibbonMSWArtProvider::DrawPartialPageBackground(wxDC& dc,
1128 wxWindow* WXUNUSED(wnd), const wxRect& rect, wxRibbonPage* page,
1129 wxPoint offset, bool hovered)
1130 {
1131 wxRect background(page->GetSize());
1132 page->AdjustRectToIncludeScrollButtons(&background);
1133 background.height -= 2;
1134 // Page background isn't dependant upon the width of the page
1135 // (at least not the part of it intended to be painted by this
1136 // function). Set to wider than the page itself for when externally
1137 // expanded panels need a background - the expanded panel can be wider
1138 // than the bar.
1139 background.x = 0;
1140 background.width = INT_MAX;
1141
1142 // upper_rect, lower_rect, paint_rect are all in page co-ordinates
1143 wxRect upper_rect(background);
1144 upper_rect.height /= 5;
1145
1146 wxRect lower_rect(background);
1147 lower_rect.y += upper_rect.height;
1148 lower_rect.height -= upper_rect.height;
1149
1150 wxRect paint_rect(rect);
1151 paint_rect.x += offset.x;
1152 paint_rect.y += offset.y;
1153
1154 wxColour bg_top, bg_top_grad, bg_btm, bg_btm_grad;
1155 if(hovered)
1156 {
1157 bg_top = m_page_hover_background_top_colour;
1158 bg_top_grad = m_page_hover_background_top_gradient_colour;
1159 bg_btm = m_page_hover_background_colour;
1160 bg_btm_grad = m_page_hover_background_gradient_colour;
1161 }
1162 else
1163 {
1164 bg_top = m_page_background_top_colour;
1165 bg_top_grad = m_page_background_top_gradient_colour;
1166 bg_btm = m_page_background_colour;
1167 bg_btm_grad = m_page_background_gradient_colour;
1168 }
1169
1170 if(paint_rect.Intersects(upper_rect))
1171 {
1172 wxRect rect(upper_rect);
1173 rect.Intersect(paint_rect);
1174 rect.x -= offset.x;
1175 rect.y -= offset.y;
1176 wxColour starting_colour(wxRibbonInterpolateColour(bg_top, bg_top_grad,
1177 paint_rect.y, upper_rect.y, upper_rect.y + upper_rect.height));
1178 wxColour ending_colour(wxRibbonInterpolateColour(bg_top, bg_top_grad,
1179 paint_rect.y + paint_rect.height, upper_rect.y,
1180 upper_rect.y + upper_rect.height));
1181 dc.GradientFillLinear(rect, starting_colour, ending_colour, wxSOUTH);
1182 }
1183
1184 if(paint_rect.Intersects(lower_rect))
1185 {
1186 wxRect rect(lower_rect);
1187 rect.Intersect(paint_rect);
1188 rect.x -= offset.x;
1189 rect.y -= offset.y;
1190 wxColour starting_colour(wxRibbonInterpolateColour(bg_btm, bg_btm_grad,
1191 paint_rect.y, lower_rect.y, lower_rect.y + lower_rect.height));
1192 wxColour ending_colour(wxRibbonInterpolateColour(bg_btm, bg_btm_grad,
1193 paint_rect.y + paint_rect.height,
1194 lower_rect.y, lower_rect.y + lower_rect.height));
1195 dc.GradientFillLinear(rect, starting_colour, ending_colour, wxSOUTH);
1196 }
1197 }
1198
1199 void wxRibbonMSWArtProvider::DrawPageBackground(
1200 wxDC& dc,
1201 wxWindow* WXUNUSED(wnd),
1202 const wxRect& rect)
1203 {
1204 dc.SetPen(*wxTRANSPARENT_PEN);
1205 dc.SetBrush(m_tab_ctrl_background_brush);
1206
1207 {
1208 wxRect edge(rect);
1209
1210 edge.width = 2;
1211 dc.DrawRectangle(edge.x, edge.y, edge.width, edge.height);
1212
1213 edge.x += rect.width - 2;
1214 dc.DrawRectangle(edge.x, edge.y, edge.width, edge.height);
1215
1216 edge = rect;
1217 edge.height = 2;
1218 edge.y += (rect.height - edge.height);
1219 dc.DrawRectangle(edge.x, edge.y, edge.width, edge.height);
1220 }
1221
1222 {
1223 wxRect background(rect);
1224 background.x += 2;
1225 background.width -= 4;
1226 background.height -= 2;
1227
1228 background.height /= 5;
1229 dc.GradientFillLinear(background, m_page_background_top_colour,
1230 m_page_background_top_gradient_colour, wxSOUTH);
1231
1232 background.y += background.height;
1233 background.height = rect.height - 2 - background.height;
1234 dc.GradientFillLinear(background, m_page_background_colour,
1235 m_page_background_gradient_colour, wxSOUTH);
1236 }
1237
1238 {
1239 wxPoint border_points[8];
1240 border_points[0] = wxPoint(2, 0);
1241 border_points[1] = wxPoint(1, 1);
1242 border_points[2] = wxPoint(1, rect.height - 4);
1243 border_points[3] = wxPoint(3, rect.height - 2);
1244 border_points[4] = wxPoint(rect.width - 4, rect.height - 2);
1245 border_points[5] = wxPoint(rect.width - 2, rect.height - 4);
1246 border_points[6] = wxPoint(rect.width - 2, 1);
1247 border_points[7] = wxPoint(rect.width - 4, -1);
1248
1249 dc.SetPen(m_page_border_pen);
1250 dc.DrawLines(sizeof(border_points)/sizeof(wxPoint), border_points, rect.x, rect.y);
1251 }
1252 }
1253
1254 void wxRibbonMSWArtProvider::DrawScrollButton(
1255 wxDC& dc,
1256 wxWindow* WXUNUSED(wnd),
1257 const wxRect& rect_,
1258 long style)
1259 {
1260 wxRect rect(rect_);
1261
1262 if((style & wxRIBBON_SCROLL_BTN_FOR_MASK) == wxRIBBON_SCROLL_BTN_FOR_PAGE)
1263 {
1264 // Page scroll buttons do not have the luxury of rendering on top of anything
1265 // else, and their size includes some padding, hence the background painting
1266 // and size adjustment.
1267 dc.SetPen(*wxTRANSPARENT_PEN);
1268 dc.SetBrush(m_tab_ctrl_background_brush);
1269 dc.DrawRectangle(rect);
1270 dc.SetClippingRegion(rect);
1271 switch(style & wxRIBBON_SCROLL_BTN_DIRECTION_MASK)
1272 {
1273 case wxRIBBON_SCROLL_BTN_LEFT:
1274 rect.x++;
1275 case wxRIBBON_SCROLL_BTN_RIGHT:
1276 rect.y--;
1277 rect.width--;
1278 break;
1279 case wxRIBBON_SCROLL_BTN_UP:
1280 rect.x++;
1281 rect.y--;
1282 rect.width -= 2;
1283 rect.height++;
1284 break;
1285 case wxRIBBON_SCROLL_BTN_DOWN:
1286 rect.x++;
1287 rect.width -= 2;
1288 rect.height--;
1289 break;
1290 }
1291 }
1292
1293 {
1294 wxRect background(rect);
1295 background.x++;
1296 background.y++;
1297 background.width -= 2;
1298 background.height -= 2;
1299
1300 if(style & wxRIBBON_SCROLL_BTN_UP)
1301 background.height /= 2;
1302 else
1303 background.height /= 5;
1304 dc.GradientFillLinear(background, m_page_background_top_colour,
1305 m_page_background_top_gradient_colour, wxSOUTH);
1306
1307 background.y += background.height;
1308 background.height = rect.height - 2 - background.height;
1309 dc.GradientFillLinear(background, m_page_background_colour,
1310 m_page_background_gradient_colour, wxSOUTH);
1311 }
1312
1313 {
1314 wxPoint border_points[7];
1315 switch(style & wxRIBBON_SCROLL_BTN_DIRECTION_MASK)
1316 {
1317 case wxRIBBON_SCROLL_BTN_LEFT:
1318 border_points[0] = wxPoint(2, 0);
1319 border_points[1] = wxPoint(rect.width - 1, 0);
1320 border_points[2] = wxPoint(rect.width - 1, rect.height - 1);
1321 border_points[3] = wxPoint(2, rect.height - 1);
1322 border_points[4] = wxPoint(0, rect.height - 3);
1323 border_points[5] = wxPoint(0, 2);
1324 break;
1325 case wxRIBBON_SCROLL_BTN_RIGHT:
1326 border_points[0] = wxPoint(0, 0);
1327 border_points[1] = wxPoint(rect.width - 3, 0);
1328 border_points[2] = wxPoint(rect.width - 1, 2);
1329 border_points[3] = wxPoint(rect.width - 1, rect.height - 3);
1330 border_points[4] = wxPoint(rect.width - 3, rect.height - 1);
1331 border_points[5] = wxPoint(0, rect.height - 1);
1332 break;
1333 case wxRIBBON_SCROLL_BTN_UP:
1334 border_points[0] = wxPoint(2, 0);
1335 border_points[1] = wxPoint(rect.width - 3, 0);
1336 border_points[2] = wxPoint(rect.width - 1, 2);
1337 border_points[3] = wxPoint(rect.width - 1, rect.height - 1);
1338 border_points[4] = wxPoint(0, rect.height - 1);
1339 border_points[5] = wxPoint(0, 2);
1340 break;
1341 case wxRIBBON_SCROLL_BTN_DOWN:
1342 border_points[0] = wxPoint(0, 0);
1343 border_points[1] = wxPoint(rect.width - 1, 0);
1344 border_points[2] = wxPoint(rect.width - 1, rect.height - 3);
1345 border_points[3] = wxPoint(rect.width - 3, rect.height - 1);
1346 border_points[4] = wxPoint(2, rect.height - 1);
1347 border_points[5] = wxPoint(0, rect.height - 3);
1348 break;
1349 }
1350 border_points[6] = border_points[0];
1351
1352 dc.SetPen(m_page_border_pen);
1353 dc.DrawLines(sizeof(border_points)/sizeof(wxPoint), border_points, rect.x, rect.y);
1354 }
1355
1356 {
1357 // NB: Code for handling hovered/active state is temporary
1358 wxPoint arrow_points[3];
1359 switch(style & wxRIBBON_SCROLL_BTN_DIRECTION_MASK)
1360 {
1361 case wxRIBBON_SCROLL_BTN_LEFT:
1362 arrow_points[0] = wxPoint(rect.width / 2 - 2, rect.height / 2);
1363 if(style & wxRIBBON_SCROLL_BTN_ACTIVE)
1364 arrow_points[0].y += 1;
1365 arrow_points[1] = arrow_points[0] + wxPoint(3, -3);
1366 arrow_points[2] = arrow_points[0] + wxPoint(3, 3);
1367 break;
1368 case wxRIBBON_SCROLL_BTN_RIGHT:
1369 arrow_points[0] = wxPoint(rect.width / 2 + 2, rect.height / 2);
1370 if(style & wxRIBBON_SCROLL_BTN_ACTIVE)
1371 arrow_points[0].y += 1;
1372 arrow_points[1] = arrow_points[0] - wxPoint(3, 3);
1373 arrow_points[2] = arrow_points[0] - wxPoint(3, -3);
1374 break;
1375 case wxRIBBON_SCROLL_BTN_UP:
1376 arrow_points[0] = wxPoint(rect.width / 2, rect.height / 2 - 2);
1377 if(style & wxRIBBON_SCROLL_BTN_ACTIVE)
1378 arrow_points[0].y += 1;
1379 arrow_points[1] = arrow_points[0] + wxPoint( 3, 3);
1380 arrow_points[2] = arrow_points[0] + wxPoint(-3, 3);
1381 break;
1382 case wxRIBBON_SCROLL_BTN_DOWN:
1383 arrow_points[0] = wxPoint(rect.width / 2, rect.height / 2 + 2);
1384 if(style & wxRIBBON_SCROLL_BTN_ACTIVE)
1385 arrow_points[0].y += 1;
1386 arrow_points[1] = arrow_points[0] - wxPoint( 3, 3);
1387 arrow_points[2] = arrow_points[0] - wxPoint(-3, 3);
1388 break;
1389 }
1390
1391 dc.SetPen(*wxTRANSPARENT_PEN);
1392 wxBrush B(style & wxRIBBON_SCROLL_BTN_HOVERED ? m_tab_active_background_colour : m_tab_label_colour);
1393 dc.SetBrush(B);
1394 dc.DrawPolygon(sizeof(arrow_points)/sizeof(wxPoint), arrow_points, rect.x, rect.y);
1395 }
1396 }
1397
1398 void wxRibbonMSWArtProvider::DrawDropdownArrow(wxDC& dc, int x, int y, const wxColour& colour)
1399 {
1400 wxPoint arrow_points[3];
1401 wxBrush brush(colour);
1402 arrow_points[0] = wxPoint(1, 2);
1403 arrow_points[1] = arrow_points[0] + wxPoint(-3, -3);
1404 arrow_points[2] = arrow_points[0] + wxPoint( 3, -3);
1405 dc.SetPen(*wxTRANSPARENT_PEN);
1406 dc.SetBrush(brush);
1407 dc.DrawPolygon(sizeof(arrow_points)/sizeof(wxPoint), arrow_points, x, y);
1408 }
1409
1410 void wxRibbonMSWArtProvider::RemovePanelPadding(wxRect* rect)
1411 {
1412 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
1413 {
1414 rect->y += 1;
1415 rect->height -= 2;
1416 }
1417 else
1418 {
1419 rect->x += 1;
1420 rect->width -= 2;
1421 }
1422 }
1423
1424 void wxRibbonMSWArtProvider::DrawPanelBackground(
1425 wxDC& dc,
1426 wxRibbonPanel* wnd,
1427 const wxRect& rect)
1428 {
1429 DrawPartialPageBackground(dc, wnd, rect, false);
1430
1431 wxRect true_rect(rect);
1432 RemovePanelPadding(&true_rect);
1433
1434 int label_height;
1435 {
1436 dc.SetFont(m_panel_label_font);
1437 dc.SetPen(*wxTRANSPARENT_PEN);
1438 if(wnd->IsHovered())
1439 {
1440 dc.SetBrush(m_panel_hover_label_background_brush);
1441 dc.SetTextForeground(m_panel_hover_label_colour);
1442 }
1443 else
1444 {
1445 dc.SetBrush(m_panel_label_background_brush);
1446 dc.SetTextForeground(m_panel_label_colour);
1447 }
1448
1449 wxRect label_rect(true_rect);
1450 wxString label = wnd->GetLabel();
1451 bool clip_label = false;
1452 wxSize label_size(dc.GetTextExtent(label));
1453
1454 label_rect.SetX(label_rect.GetX() + 1);
1455 label_rect.SetWidth(label_rect.GetWidth() - 2);
1456 label_rect.SetHeight(label_size.GetHeight() + 2);
1457 label_rect.SetY(true_rect.GetBottom() - label_rect.GetHeight());
1458 label_height = label_rect.GetHeight();
1459
1460 if(label_size.GetWidth() > label_rect.GetWidth())
1461 {
1462 // Test if there is enough length for 3 letters and ...
1463 wxString new_label = label.Mid(0, 3) + wxT("...");
1464 label_size = dc.GetTextExtent(new_label);
1465 if(label_size.GetWidth() > label_rect.GetWidth())
1466 {
1467 // Not enough room for three characters and ...
1468 // Display the entire label and just crop it
1469 clip_label = true;
1470 }
1471 else
1472 {
1473 // Room for some characters and ...
1474 // Display as many characters as possible and append ...
1475 for(size_t len = label.Len() - 1; len >= 3; --len)
1476 {
1477 new_label = label.Mid(0, len) + wxT("...");
1478 label_size = dc.GetTextExtent(new_label);
1479 if(label_size.GetWidth() <= label_rect.GetWidth())
1480 {
1481 label = new_label;
1482 break;
1483 }
1484 }
1485 }
1486 }
1487
1488 dc.DrawRectangle(label_rect.GetX(), label_rect.GetY(), label_rect.GetWidth(), label_rect.GetHeight());
1489 if(clip_label)
1490 {
1491 wxDCClipper clip(dc, label_rect);
1492 dc.DrawText(label, label_rect.x, label_rect.y +
1493 (label_rect.GetHeight() - label_size.GetHeight()) / 2);
1494 }
1495 else
1496 {
1497 dc.DrawText(label, label_rect.x +
1498 (label_rect.GetWidth() - label_size.GetWidth()) / 2,
1499 label_rect.y +
1500 (label_rect.GetHeight() - label_size.GetHeight()) / 2);
1501 }
1502 }
1503
1504 if(wnd->IsHovered())
1505 {
1506 wxRect client_rect(true_rect);
1507 client_rect.x++;
1508 client_rect.width -= 2;
1509 client_rect.y++;
1510 client_rect.height -= 2 + label_height;
1511 DrawPartialPageBackground(dc, wnd, client_rect, true);
1512 }
1513
1514 DrawPanelBorder(dc, true_rect, m_panel_border_pen, m_panel_border_gradient_pen);
1515 }
1516
1517 void wxRibbonMSWArtProvider::DrawGalleryBackground(
1518 wxDC& dc,
1519 wxRibbonGallery* wnd,
1520 const wxRect& rect)
1521 {
1522 DrawPartialPageBackground(dc, wnd, rect);
1523
1524 if(wnd->IsHovered())
1525 {
1526 dc.SetPen(*wxTRANSPARENT_PEN);
1527 dc.SetBrush(m_gallery_hover_background_brush);
1528 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
1529 {
1530 dc.DrawRectangle(rect.x + 1, rect.y + 1, rect.width - 2,
1531 rect.height - 16);
1532 }
1533 else
1534 {
1535 dc.DrawRectangle(rect.x + 1, rect.y + 1, rect.width - 16,
1536 rect.height - 2);
1537 }
1538 }
1539
1540 dc.SetPen(m_gallery_border_pen);
1541 // Outline
1542 dc.DrawLine(rect.x + 1, rect.y, rect.x + rect.width - 1, rect.y);
1543 dc.DrawLine(rect.x, rect.y + 1, rect.x, rect.y + rect.height - 1);
1544 dc.DrawLine(rect.x + 1, rect.y + rect.height - 1, rect.x + rect.width - 1,
1545 rect.y + rect.height - 1);
1546 dc.DrawLine(rect.x + rect.width - 1, rect.y + 1, rect.x + rect.width - 1,
1547 rect.y + rect.height - 1);
1548
1549 DrawGalleryBackgroundCommon(dc, wnd, rect);
1550 }
1551
1552 void wxRibbonMSWArtProvider::DrawGalleryBackgroundCommon(wxDC& dc,
1553 wxRibbonGallery* wnd,
1554 const wxRect& rect)
1555 {
1556 wxRect up_btn, down_btn, ext_btn;
1557
1558 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
1559 {
1560 // Divider between items and buttons
1561 dc.DrawLine(rect.x, rect.y + rect.height - 15, rect.x + rect.width,
1562 rect.y + rect.height - 15);
1563
1564 up_btn = wxRect(rect.x, rect.y + rect.height - 15, rect.width / 3, 15);
1565
1566 down_btn = wxRect(up_btn.GetRight() + 1, up_btn.GetTop(),
1567 up_btn.GetWidth(), up_btn.GetHeight());
1568 dc.DrawLine(down_btn.GetLeft(), down_btn.GetTop(), down_btn.GetLeft(),
1569 down_btn.GetBottom());
1570
1571 ext_btn = wxRect(down_btn.GetRight() + 1, up_btn.GetTop(), rect.width -
1572 up_btn.GetWidth() - down_btn.GetWidth() - 1, up_btn.GetHeight());
1573 dc.DrawLine(ext_btn.GetLeft(), ext_btn.GetTop(), ext_btn.GetLeft(),
1574 ext_btn.GetBottom());
1575 }
1576 else
1577 {
1578 // Divider between items and buttons
1579 dc.DrawLine(rect.x + rect.width - 15, rect.y, rect.x + rect.width - 15,
1580 rect.y + rect.height);
1581
1582 up_btn = wxRect(rect.x + rect.width - 15, rect.y, 15, rect.height / 3);
1583
1584 down_btn = wxRect(up_btn.GetLeft(), up_btn.GetBottom() + 1,
1585 up_btn.GetWidth(), up_btn.GetHeight());
1586 dc.DrawLine(down_btn.GetLeft(), down_btn.GetTop(), down_btn.GetRight(),
1587 down_btn.GetTop());
1588
1589 ext_btn = wxRect(up_btn.GetLeft(), down_btn.GetBottom() + 1, up_btn.GetWidth(),
1590 rect.height - up_btn.GetHeight() - down_btn.GetHeight() - 1);
1591 dc.DrawLine(ext_btn.GetLeft(), ext_btn.GetTop(), ext_btn.GetRight(),
1592 ext_btn.GetTop());
1593 }
1594
1595 DrawGalleryButton(dc, up_btn, wnd->GetUpButtonState(),
1596 m_gallery_up_bitmap);
1597 DrawGalleryButton(dc, down_btn, wnd->GetDownButtonState(),
1598 m_gallery_down_bitmap);
1599 DrawGalleryButton(dc, ext_btn, wnd->GetExtensionButtonState(),
1600 m_gallery_extension_bitmap);
1601 }
1602
1603 void wxRibbonMSWArtProvider::DrawGalleryButton(wxDC& dc,
1604 wxRect rect,
1605 wxRibbonGalleryButtonState state,
1606 wxBitmap* bitmaps)
1607 {
1608 wxBitmap btn_bitmap;
1609 wxBrush btn_top_brush;
1610 wxColour btn_colour;
1611 wxColour btn_grad_colour;
1612 switch(state)
1613 {
1614 case wxRIBBON_GALLERY_BUTTON_NORMAL:
1615 btn_top_brush = m_gallery_button_background_top_brush;
1616 btn_colour = m_gallery_button_background_colour;
1617 btn_grad_colour = m_gallery_button_background_gradient_colour;
1618 btn_bitmap = bitmaps[0];
1619 break;
1620 case wxRIBBON_GALLERY_BUTTON_HOVERED:
1621 btn_top_brush = m_gallery_button_hover_background_top_brush;
1622 btn_colour = m_gallery_button_hover_background_colour;
1623 btn_grad_colour = m_gallery_button_hover_background_gradient_colour;
1624 btn_bitmap = bitmaps[1];
1625 break;
1626 case wxRIBBON_GALLERY_BUTTON_ACTIVE:
1627 btn_top_brush = m_gallery_button_active_background_top_brush;
1628 btn_colour = m_gallery_button_active_background_colour;
1629 btn_grad_colour = m_gallery_button_active_background_gradient_colour;
1630 btn_bitmap = bitmaps[2];
1631 break;
1632 case wxRIBBON_GALLERY_BUTTON_DISABLED:
1633 btn_top_brush = m_gallery_button_disabled_background_top_brush;
1634 btn_colour = m_gallery_button_disabled_background_colour;
1635 btn_grad_colour = m_gallery_button_disabled_background_gradient_colour;
1636 btn_bitmap = bitmaps[3];
1637 break;
1638 }
1639
1640 rect.x++;
1641 rect.y++;
1642 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
1643 {
1644 rect.width--;;
1645 rect.height -= 2;
1646 }
1647 else
1648 {
1649 rect.width -= 2;
1650 rect.height--;
1651 }
1652
1653 dc.SetPen(*wxTRANSPARENT_PEN);
1654 dc.SetBrush(btn_top_brush);
1655 dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height / 2);
1656
1657 wxRect lower(rect);
1658 lower.height = (lower.height + 1) / 2;
1659 lower.y += rect.height - lower.height;
1660 dc.GradientFillLinear(lower, btn_colour, btn_grad_colour, wxSOUTH);
1661
1662 dc.DrawBitmap(btn_bitmap, rect.x + rect.width / 2 - 2, lower.y - 2, true);
1663 }
1664
1665 void wxRibbonMSWArtProvider::DrawGalleryItemBackground(
1666 wxDC& dc,
1667 wxRibbonGallery* wnd,
1668 const wxRect& rect,
1669 wxRibbonGalleryItem* item)
1670 {
1671 if(wnd->GetHoveredItem() != item && wnd->GetActiveItem() != item &&
1672 wnd->GetSelection() != item)
1673 return;
1674
1675 dc.SetPen(m_gallery_item_border_pen);
1676 dc.DrawLine(rect.x + 1, rect.y, rect.x + rect.width - 1, rect.y);
1677 dc.DrawLine(rect.x, rect.y + 1, rect.x, rect.y + rect.height - 1);
1678 dc.DrawLine(rect.x + 1, rect.y + rect.height - 1, rect.x + rect.width - 1,
1679 rect.y + rect.height - 1);
1680 dc.DrawLine(rect.x + rect.width - 1, rect.y + 1, rect.x + rect.width - 1,
1681 rect.y + rect.height - 1);
1682
1683 wxBrush top_brush;
1684 wxColour bg_colour;
1685 wxColour bg_gradient_colour;
1686
1687 if(wnd->GetActiveItem() == item || wnd->GetSelection() == item)
1688 {
1689 top_brush = m_gallery_button_active_background_top_brush;
1690 bg_colour = m_gallery_button_active_background_colour;
1691 bg_gradient_colour = m_gallery_button_active_background_gradient_colour;
1692 }
1693 else
1694 {
1695 top_brush = m_gallery_button_hover_background_top_brush;
1696 bg_colour = m_gallery_button_hover_background_colour;
1697 bg_gradient_colour = m_gallery_button_hover_background_gradient_colour;
1698 }
1699
1700 wxRect upper(rect);
1701 upper.x += 1;
1702 upper.width -= 2;
1703 upper.y += 1;
1704 upper.height /= 3;
1705 dc.SetPen(*wxTRANSPARENT_PEN);
1706 dc.SetBrush(top_brush);
1707 dc.DrawRectangle(upper.x, upper.y, upper.width, upper.height);
1708
1709 wxRect lower(upper);
1710 lower.y += lower.height;
1711 lower.height = rect.height - 2 - lower.height;
1712 dc.GradientFillLinear(lower, bg_colour, bg_gradient_colour, wxSOUTH);
1713 }
1714
1715 void wxRibbonMSWArtProvider::DrawPanelBorder(wxDC& dc, const wxRect& rect,
1716 wxPen& primary_colour,
1717 wxPen& secondary_colour)
1718 {
1719 wxPoint border_points[9];
1720 border_points[0] = wxPoint(2, 0);
1721 border_points[1] = wxPoint(rect.width - 3, 0);
1722 border_points[2] = wxPoint(rect.width - 1, 2);
1723 border_points[3] = wxPoint(rect.width - 1, rect.height - 3);
1724 border_points[4] = wxPoint(rect.width - 3, rect.height - 1);
1725 border_points[5] = wxPoint(2, rect.height - 1);
1726 border_points[6] = wxPoint(0, rect.height - 3);
1727 border_points[7] = wxPoint(0, 2);
1728
1729 if(primary_colour.GetColour() == secondary_colour.GetColour())
1730 {
1731 border_points[8] = border_points[0];
1732 dc.SetPen(primary_colour);
1733 dc.DrawLines(sizeof(border_points)/sizeof(wxPoint), border_points, rect.x, rect.y);
1734 }
1735 else
1736 {
1737 dc.SetPen(primary_colour);
1738 dc.DrawLines(3, border_points, rect.x, rect.y);
1739
1740 #define SingleLine(start, finish) \
1741 dc.DrawLine(start.x + rect.x, start.y + rect.y, finish.x + rect.x, finish.y + rect.y)
1742
1743 SingleLine(border_points[0], border_points[7]);
1744 dc.SetPen(secondary_colour);
1745 dc.DrawLines(3, border_points + 4, rect.x, rect.y);
1746 SingleLine(border_points[4], border_points[3]);
1747
1748 #undef SingleLine
1749
1750 border_points[6] = border_points[2];
1751 wxRibbonDrawParallelGradientLines(dc, 2, border_points + 6, 0, 1,
1752 border_points[3].y - border_points[2].y + 1, rect.x, rect.y,
1753 primary_colour.GetColour(), secondary_colour.GetColour());
1754 }
1755 }
1756
1757 void wxRibbonMSWArtProvider::DrawMinimisedPanel(
1758 wxDC& dc,
1759 wxRibbonPanel* wnd,
1760 const wxRect& rect,
1761 wxBitmap& bitmap)
1762 {
1763 DrawPartialPageBackground(dc, wnd, rect, false);
1764
1765 wxRect true_rect(rect);
1766 RemovePanelPadding(&true_rect);
1767
1768 if(wnd->GetExpandedPanel() != NULL)
1769 {
1770 wxRect client_rect(true_rect);
1771 client_rect.x++;
1772 client_rect.width -= 2;
1773 client_rect.y++;
1774 client_rect.height = (rect.y + rect.height / 5) - client_rect.x;
1775 dc.GradientFillLinear(client_rect,
1776 m_panel_active_background_top_colour,
1777 m_panel_active_background_top_gradient_colour, wxSOUTH);
1778
1779 client_rect.y += client_rect.height;
1780 client_rect.height = (true_rect.y + true_rect.height) - client_rect.y;
1781 dc.GradientFillLinear(client_rect,
1782 m_panel_active_background_colour,
1783 m_panel_active_background_gradient_colour, wxSOUTH);
1784 }
1785 else if(wnd->IsHovered())
1786 {
1787 wxRect client_rect(true_rect);
1788 client_rect.x++;
1789 client_rect.width -= 2;
1790 client_rect.y++;
1791 client_rect.height -= 2;
1792 DrawPartialPageBackground(dc, wnd, client_rect, true);
1793 }
1794
1795 wxRect preview;
1796 DrawMinimisedPanelCommon(dc, wnd, true_rect, &preview);
1797
1798 dc.SetBrush(m_panel_hover_label_background_brush);
1799 dc.SetPen(*wxTRANSPARENT_PEN);
1800 dc.DrawRectangle(preview.x + 1, preview.y + preview.height - 8,
1801 preview.width - 2, 7);
1802
1803 int mid_pos = rect.y + rect.height / 5 - preview.y;
1804 if(mid_pos < 0 || mid_pos >= preview.height)
1805 {
1806 wxRect full_rect(preview);
1807 full_rect.x += 1;
1808 full_rect.y += 1;
1809 full_rect.width -= 2;
1810 full_rect.height -= 9;
1811 if(mid_pos < 0)
1812 {
1813 dc.GradientFillLinear(full_rect,
1814 m_page_hover_background_colour,
1815 m_page_hover_background_gradient_colour, wxSOUTH);
1816 }
1817 else
1818 {
1819 dc.GradientFillLinear(full_rect,
1820 m_page_hover_background_top_colour,
1821 m_page_hover_background_top_gradient_colour, wxSOUTH);
1822 }
1823 }
1824 else
1825 {
1826 wxRect top_rect(preview);
1827 top_rect.x += 1;
1828 top_rect.y += 1;
1829 top_rect.width -= 2;
1830 top_rect.height = mid_pos;
1831 dc.GradientFillLinear(top_rect,
1832 m_page_hover_background_top_colour,
1833 m_page_hover_background_top_gradient_colour, wxSOUTH);
1834
1835 wxRect btm_rect(top_rect);
1836 btm_rect.y = preview.y + mid_pos;
1837 btm_rect.height = preview.y + preview.height - 7 - btm_rect.y;
1838 dc.GradientFillLinear(btm_rect,
1839 m_page_hover_background_colour,
1840 m_page_hover_background_gradient_colour, wxSOUTH);
1841 }
1842
1843 if(bitmap.IsOk())
1844 {
1845 dc.DrawBitmap(bitmap, preview.x + (preview.width - bitmap.GetWidth()) / 2,
1846 preview.y + (preview.height - 7 - bitmap.GetHeight()) / 2, true);
1847 }
1848
1849 DrawPanelBorder(dc, preview, m_panel_border_pen, m_panel_border_gradient_pen);
1850
1851 DrawPanelBorder(dc, true_rect, m_panel_minimised_border_pen,
1852 m_panel_minimised_border_gradient_pen);
1853 }
1854
1855 void wxRibbonMSWArtProvider::DrawMinimisedPanelCommon(
1856 wxDC& dc,
1857 wxRibbonPanel* wnd,
1858 const wxRect& true_rect,
1859 wxRect* preview_rect)
1860 {
1861 wxRect preview(0, 0, 32, 32);
1862 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
1863 {
1864 preview.x = true_rect.x + 4;
1865 preview.y = true_rect.y + (true_rect.height - preview.height) / 2;
1866 }
1867 else
1868 {
1869 preview.x = true_rect.x + (true_rect.width - preview.width) / 2;
1870 preview.y = true_rect.y + 4;
1871 }
1872 if(preview_rect)
1873 *preview_rect = preview;
1874
1875 wxCoord label_width, label_height;
1876 dc.SetFont(m_panel_label_font);
1877 dc.GetTextExtent(wnd->GetLabel(), &label_width, &label_height);
1878
1879 int xpos = true_rect.x + (true_rect.width - label_width + 1) / 2;
1880 int ypos = preview.y + preview.height + 5;
1881
1882 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
1883 {
1884 xpos = preview.x + preview.width + 5;
1885 ypos = true_rect.y + (true_rect.height - label_height) / 2;
1886 }
1887
1888 dc.SetTextForeground(m_panel_minimised_label_colour);
1889 dc.DrawText(wnd->GetLabel(), xpos, ypos);
1890
1891
1892 wxPoint arrow_points[3];
1893 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
1894 {
1895 xpos += label_width;
1896 arrow_points[0] = wxPoint(xpos + 5, ypos + label_height / 2);
1897 arrow_points[1] = arrow_points[0] + wxPoint(-3, 3);
1898 arrow_points[2] = arrow_points[0] + wxPoint(-3, -3);
1899 }
1900 else
1901 {
1902 ypos += label_height;
1903 arrow_points[0] = wxPoint(true_rect.width / 2, ypos + 5);
1904 arrow_points[1] = arrow_points[0] + wxPoint(-3, -3);
1905 arrow_points[2] = arrow_points[0] + wxPoint( 3, -3);
1906 }
1907
1908 dc.SetPen(*wxTRANSPARENT_PEN);
1909 wxBrush B(m_panel_minimised_label_colour);
1910 dc.SetBrush(B);
1911 dc.DrawPolygon(sizeof(arrow_points)/sizeof(wxPoint), arrow_points,
1912 true_rect.x, true_rect.y);
1913 }
1914
1915 void wxRibbonMSWArtProvider::DrawButtonBarBackground(
1916 wxDC& dc,
1917 wxWindow* wnd,
1918 const wxRect& rect)
1919 {
1920 DrawPartialPageBackground(dc, wnd, rect, true);
1921 }
1922
1923 void wxRibbonMSWArtProvider::DrawPartialPageBackground(
1924 wxDC& dc,
1925 wxWindow* wnd,
1926 const wxRect& rect,
1927 bool allow_hovered)
1928 {
1929 // Assume the window is a child of a ribbon page, and also check for a
1930 // hovered panel somewhere between the window and the page, as it causes
1931 // the background to change.
1932 wxPoint offset(wnd->GetPosition());
1933 wxRibbonPage* page = NULL;
1934 wxWindow* parent = wnd->GetParent();
1935 wxRibbonPanel* panel = NULL;
1936 bool hovered = false;
1937
1938 panel = wxDynamicCast(wnd, wxRibbonPanel);
1939 if(panel != NULL)
1940 {
1941 hovered = allow_hovered && panel->IsHovered();
1942 if(panel->GetExpandedDummy() != NULL)
1943 {
1944 offset = panel->GetExpandedDummy()->GetPosition();
1945 parent = panel->GetExpandedDummy()->GetParent();
1946 }
1947 }
1948 for(; parent; parent = parent->GetParent())
1949 {
1950 if(panel == NULL)
1951 {
1952 panel = wxDynamicCast(parent, wxRibbonPanel);
1953 if(panel != NULL)
1954 {
1955 hovered = allow_hovered && panel->IsHovered();
1956 if(panel->GetExpandedDummy() != NULL)
1957 {
1958 parent = panel->GetExpandedDummy();
1959 }
1960 }
1961 }
1962 page = wxDynamicCast(parent, wxRibbonPage);
1963 if(page != NULL)
1964 {
1965 break;
1966 }
1967 offset += parent->GetPosition();
1968 }
1969 if(page != NULL)
1970 {
1971 DrawPartialPageBackground(dc, wnd, rect, page, offset, hovered);
1972 return;
1973 }
1974
1975 // No page found - fallback to painting with a stock brush
1976 dc.SetBrush(*wxWHITE_BRUSH);
1977 dc.SetPen(*wxTRANSPARENT_PEN);
1978 dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
1979 }
1980
1981 void wxRibbonMSWArtProvider::DrawButtonBarButton(
1982 wxDC& dc,
1983 wxWindow* WXUNUSED(wnd),
1984 const wxRect& rect,
1985 wxRibbonButtonKind kind,
1986 long state,
1987 const wxString& label,
1988 const wxBitmap& bitmap_large,
1989 const wxBitmap& bitmap_small)
1990 {
1991 if(state & (wxRIBBON_BUTTONBAR_BUTTON_HOVER_MASK |
1992 wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK))
1993 {
1994 if(state & wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK)
1995 dc.SetPen(m_button_bar_active_border_pen);
1996 else
1997 dc.SetPen(m_button_bar_hover_border_pen);
1998
1999 wxRect bg_rect(rect);
2000 bg_rect.x++;
2001 bg_rect.y++;
2002 bg_rect.width -= 2;
2003 bg_rect.height -= 2;
2004
2005 wxRect bg_rect_top(bg_rect);
2006 bg_rect_top.height /= 3;
2007 bg_rect.y += bg_rect_top.height;
2008 bg_rect.height -= bg_rect_top.height;
2009
2010 if(kind == wxRIBBON_BUTTON_HYBRID)
2011 {
2012 switch(state & wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK)
2013 {
2014 case wxRIBBON_BUTTONBAR_BUTTON_LARGE:
2015 {
2016 int iYBorder = rect.y + bitmap_large.GetHeight() + 4;
2017 wxRect partial_bg(rect);
2018 if(state & wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED)
2019 {
2020 partial_bg.SetBottom(iYBorder - 1);
2021 }
2022 else
2023 {
2024 partial_bg.height -= (iYBorder - partial_bg.y + 1);
2025 partial_bg.y = iYBorder + 1;
2026 }
2027 dc.DrawLine(rect.x, iYBorder, rect.x + rect.width, iYBorder);
2028 bg_rect.Intersect(partial_bg);
2029 bg_rect_top.Intersect(partial_bg);
2030 }
2031 break;
2032 case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM:
2033 {
2034 int iArrowWidth = 9;
2035 if(state & wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED)
2036 {
2037 bg_rect.width -= iArrowWidth;
2038 bg_rect_top.width -= iArrowWidth;
2039 dc.DrawLine(bg_rect_top.x + bg_rect_top.width,
2040 rect.y, bg_rect_top.x + bg_rect_top.width,
2041 rect.y + rect.height);
2042 }
2043 else
2044 {
2045 --iArrowWidth;
2046 bg_rect.x += bg_rect.width - iArrowWidth;
2047 bg_rect_top.x += bg_rect_top.width - iArrowWidth;
2048 bg_rect.width = iArrowWidth;
2049 bg_rect_top.width = iArrowWidth;
2050 dc.DrawLine(bg_rect_top.x - 1, rect.y,
2051 bg_rect_top.x - 1, rect.y + rect.height);
2052 }
2053 }
2054 break;
2055 case wxRIBBON_BUTTONBAR_BUTTON_SMALL:
2056 break;
2057 }
2058 }
2059
2060 if(state & wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK)
2061 {
2062 dc.GradientFillLinear(bg_rect_top,
2063 m_button_bar_active_background_top_colour,
2064 m_button_bar_active_background_top_gradient_colour, wxSOUTH);
2065 dc.GradientFillLinear(bg_rect,
2066 m_button_bar_active_background_colour,
2067 m_button_bar_active_background_gradient_colour, wxSOUTH);
2068 }
2069 else
2070 {
2071 dc.GradientFillLinear(bg_rect_top,
2072 m_button_bar_hover_background_top_colour,
2073 m_button_bar_hover_background_top_gradient_colour, wxSOUTH);
2074 dc.GradientFillLinear(bg_rect,
2075 m_button_bar_hover_background_colour,
2076 m_button_bar_hover_background_gradient_colour, wxSOUTH);
2077 }
2078
2079 wxPoint border_points[9];
2080 border_points[0] = wxPoint(2, 0);
2081 border_points[1] = wxPoint(rect.width - 3, 0);
2082 border_points[2] = wxPoint(rect.width - 1, 2);
2083 border_points[3] = wxPoint(rect.width - 1, rect.height - 3);
2084 border_points[4] = wxPoint(rect.width - 3, rect.height - 1);
2085 border_points[5] = wxPoint(2, rect.height - 1);
2086 border_points[6] = wxPoint(0, rect.height - 3);
2087 border_points[7] = wxPoint(0, 2);
2088 border_points[8] = border_points[0];
2089
2090 dc.DrawLines(sizeof(border_points)/sizeof(wxPoint), border_points,
2091 rect.x, rect.y);
2092 }
2093
2094 dc.SetFont(m_button_bar_label_font);
2095 dc.SetTextForeground(m_button_bar_label_colour);
2096 DrawButtonBarButtonForeground(dc, rect, kind, state, label, bitmap_large,
2097 bitmap_small);
2098 }
2099
2100 void wxRibbonMSWArtProvider::DrawButtonBarButtonForeground(
2101 wxDC& dc,
2102 const wxRect& rect,
2103 wxRibbonButtonKind kind,
2104 long state,
2105 const wxString& label,
2106 const wxBitmap& bitmap_large,
2107 const wxBitmap& bitmap_small)
2108 {
2109 switch(state & wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK)
2110 {
2111 case wxRIBBON_BUTTONBAR_BUTTON_LARGE:
2112 {
2113 const int padding = 2;
2114 dc.DrawBitmap(bitmap_large,
2115 rect.x + (rect.width - bitmap_large.GetWidth()) / 2,
2116 rect.y + padding, true);
2117 int ypos = rect.y + padding + bitmap_large.GetHeight() + padding;
2118 int arrow_width = kind == wxRIBBON_BUTTON_NORMAL ? 0 : 8;
2119 wxCoord label_w, label_h;
2120 dc.GetTextExtent(label, &label_w, &label_h);
2121 if(label_w + 2 * padding <= rect.width)
2122 {
2123 dc.DrawText(label, rect.x + (rect.width - label_w) / 2, ypos);
2124 if(arrow_width != 0)
2125 {
2126 DrawDropdownArrow(dc, rect.x + rect.width / 2,
2127 ypos + (label_h * 3) / 2,
2128 m_button_bar_label_colour);
2129 }
2130 }
2131 else
2132 {
2133 size_t breaki = label.Len();
2134 do
2135 {
2136 --breaki;
2137 if(wxRibbonCanLabelBreakAtPosition(label, breaki))
2138 {
2139 wxString label_top = label.Mid(0, breaki);
2140 dc.GetTextExtent(label_top, &label_w, &label_h);
2141 if(label_w + 2 * padding <= rect.width)
2142 {
2143 dc.DrawText(label_top,
2144 rect.x + (rect.width - label_w) / 2, ypos);
2145 ypos += label_h;
2146 wxString label_bottom = label.Mid(breaki + 1);
2147 dc.GetTextExtent(label_bottom, &label_w, &label_h);
2148 label_w += arrow_width;
2149 int iX = rect.x + (rect.width - label_w) / 2;
2150 dc.DrawText(label_bottom, iX, ypos);
2151 if(arrow_width != 0)
2152 {
2153 DrawDropdownArrow(dc,
2154 iX + 2 +label_w - arrow_width,
2155 ypos + label_h / 2 + 1,
2156 m_button_bar_label_colour);
2157 }
2158 break;
2159 }
2160 }
2161 } while(breaki > 0);
2162 }
2163 }
2164 break;
2165 case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM:
2166 {
2167 int x_cursor = rect.x + 2;
2168 dc.DrawBitmap(bitmap_small, x_cursor,
2169 rect.y + (rect.height - bitmap_small.GetHeight())/2, true);
2170 x_cursor += bitmap_small.GetWidth() + 2;
2171 wxCoord label_w, label_h;
2172 dc.GetTextExtent(label, &label_w, &label_h);
2173 dc.DrawText(label, x_cursor,
2174 rect.y + (rect.height - label_h) / 2);
2175 x_cursor += label_w + 3;
2176 if(kind != wxRIBBON_BUTTON_NORMAL)
2177 {
2178 DrawDropdownArrow(dc, x_cursor, rect.y + rect.height / 2,
2179 m_button_bar_label_colour);
2180 }
2181 break;
2182 }
2183 default:
2184 // TODO
2185 break;
2186 }
2187 }
2188
2189 void wxRibbonMSWArtProvider::DrawToolBarBackground(
2190 wxDC& dc,
2191 wxWindow* wnd,
2192 const wxRect& rect)
2193 {
2194 DrawPartialPageBackground(dc, wnd, rect);
2195 }
2196
2197 void wxRibbonMSWArtProvider::DrawToolGroupBackground(
2198 wxDC& dc,
2199 wxWindow* WXUNUSED(wnd),
2200 const wxRect& rect)
2201 {
2202 dc.SetPen(m_toolbar_border_pen);
2203 wxPoint outline[9];
2204 outline[0] = wxPoint(2, 0);
2205 outline[1] = wxPoint(rect.width - 3, 0);
2206 outline[2] = wxPoint(rect.width - 1, 2);
2207 outline[3] = wxPoint(rect.width - 1, rect.height - 3);
2208 outline[4] = wxPoint(rect.width - 3, rect.height - 1);
2209 outline[5] = wxPoint(2, rect.height - 1);
2210 outline[6] = wxPoint(0, rect.height - 3);
2211 outline[7] = wxPoint(0, 2);
2212 outline[8] = outline[0];
2213
2214 dc.DrawLines(sizeof(outline)/sizeof(wxPoint), outline, rect.x, rect.y);
2215 }
2216
2217 void wxRibbonMSWArtProvider::DrawTool(
2218 wxDC& dc,
2219 wxWindow* WXUNUSED(wnd),
2220 const wxRect& rect,
2221 const wxBitmap& bitmap,
2222 wxRibbonButtonKind kind,
2223 long state)
2224 {
2225 wxRect bg_rect(rect);
2226 bg_rect.Deflate(1);
2227 if((state & wxRIBBON_TOOLBAR_TOOL_LAST) == 0)
2228 bg_rect.width++;
2229 bool is_split_hybrid = (kind == wxRIBBON_BUTTON_HYBRID && (state &
2230 (wxRIBBON_TOOLBAR_TOOL_HOVER_MASK | wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK)));
2231
2232 // Background
2233 wxRect bg_rect_top(bg_rect);
2234 bg_rect_top.height = (bg_rect_top.height * 2) / 5;
2235 wxRect bg_rect_btm(bg_rect);
2236 bg_rect_btm.y += bg_rect_top.height;
2237 bg_rect_btm.height -= bg_rect_top.height;
2238 wxColour bg_top_colour = m_tool_background_top_colour;
2239 wxColour bg_top_grad_colour = m_tool_background_top_gradient_colour;
2240 wxColour bg_colour = m_tool_background_colour;
2241 wxColour bg_grad_colour = m_tool_background_gradient_colour;
2242 if(state & wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK)
2243 {
2244 bg_top_colour = m_tool_active_background_top_colour;
2245 bg_top_grad_colour = m_tool_active_background_top_gradient_colour;
2246 bg_colour = m_tool_active_background_colour;
2247 bg_grad_colour = m_tool_active_background_gradient_colour;
2248 }
2249 else if(state & wxRIBBON_TOOLBAR_TOOL_HOVER_MASK)
2250 {
2251 bg_top_colour = m_tool_hover_background_top_colour;
2252 bg_top_grad_colour = m_tool_hover_background_top_gradient_colour;
2253 bg_colour = m_tool_hover_background_colour;
2254 bg_grad_colour = m_tool_hover_background_gradient_colour;
2255 }
2256 dc.GradientFillLinear(bg_rect_top, bg_top_colour, bg_top_grad_colour, wxSOUTH);
2257 dc.GradientFillLinear(bg_rect_btm, bg_colour, bg_grad_colour, wxSOUTH);
2258 if(is_split_hybrid)
2259 {
2260 wxRect nonrect(bg_rect);
2261 if(state & (wxRIBBON_TOOLBAR_TOOL_DROPDOWN_HOVERED |
2262 wxRIBBON_TOOLBAR_TOOL_DROPDOWN_ACTIVE))
2263 {
2264 nonrect.width -= 8;
2265 }
2266 else
2267 {
2268 nonrect.x += nonrect.width - 8;
2269 nonrect.width = 8;
2270 }
2271 wxBrush B(m_tool_hover_background_top_colour);
2272 dc.SetPen(*wxTRANSPARENT_PEN);
2273 dc.SetBrush(B);
2274 dc.DrawRectangle(nonrect.x, nonrect.y, nonrect.width, nonrect.height);
2275 }
2276
2277 // Border
2278 dc.SetPen(m_toolbar_border_pen);
2279 if(state & wxRIBBON_TOOLBAR_TOOL_FIRST)
2280 {
2281 dc.DrawPoint(rect.x + 1, rect.y + 1);
2282 dc.DrawPoint(rect.x + 1, rect.y + rect.height - 2);
2283 }
2284 else
2285 dc.DrawLine(rect.x, rect.y + 1, rect.x, rect.y + rect.height - 1);
2286
2287 if(state & wxRIBBON_TOOLBAR_TOOL_LAST)
2288 {
2289 dc.DrawPoint(rect.x + rect.width - 2, rect.y + 1);
2290 dc.DrawPoint(rect.x + rect.width - 2, rect.y + rect.height - 2);
2291 }
2292
2293 // Foreground
2294 int avail_width = bg_rect.GetWidth();
2295 if(kind != wxRIBBON_BUTTON_NORMAL)
2296 {
2297 avail_width -= 8;
2298 if(is_split_hybrid)
2299 {
2300 dc.DrawLine(rect.x + avail_width + 1, rect.y,
2301 rect.x + avail_width + 1, rect.y + rect.height);
2302 }
2303 dc.DrawBitmap(m_toolbar_drop_bitmap, bg_rect.x + avail_width + 2,
2304 bg_rect.y + (bg_rect.height / 2) - 2, true);
2305 }
2306 dc.DrawBitmap(bitmap, bg_rect.x + (avail_width - bitmap.GetWidth()) / 2,
2307 bg_rect.y + (bg_rect.height - bitmap.GetHeight()) / 2, true);
2308 }
2309
2310 void wxRibbonMSWArtProvider::GetBarTabWidth(
2311 wxDC& dc,
2312 wxWindow* WXUNUSED(wnd),
2313 const wxString& label,
2314 const wxBitmap& bitmap,
2315 int* ideal,
2316 int* small_begin_need_separator,
2317 int* small_must_have_separator,
2318 int* minimum)
2319 {
2320 int width = 0;
2321 int min = 0;
2322 if((m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) && !label.IsEmpty())
2323 {
2324 dc.SetFont(m_tab_label_font);
2325 width += dc.GetTextExtent(label).GetWidth();
2326 min += wxMin(25, width); // enough for a few chars
2327 if(bitmap.IsOk())
2328 {
2329 // gap between label and bitmap
2330 width += 4;
2331 min += 2;
2332 }
2333 }
2334 if((m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS) && bitmap.IsOk())
2335 {
2336 width += bitmap.GetWidth();
2337 min += bitmap.GetWidth();
2338 }
2339
2340 if(ideal != NULL)
2341 {
2342 *ideal = width + 30;
2343 }
2344 if(small_begin_need_separator != NULL)
2345 {
2346 *small_begin_need_separator = width + 20;
2347 }
2348 if(small_must_have_separator != NULL)
2349 {
2350 *small_must_have_separator = width + 10;
2351 }
2352 if(minimum != NULL)
2353 {
2354 *minimum = min;
2355 }
2356 }
2357
2358 int wxRibbonMSWArtProvider::GetTabCtrlHeight(
2359 wxDC& dc,
2360 wxWindow* WXUNUSED(wnd),
2361 const wxRibbonPageTabInfoArray& pages)
2362 {
2363 int text_height = 0;
2364 int icon_height = 0;
2365
2366 if(pages.GetCount() <= 1 && (m_flags & wxRIBBON_BAR_ALWAYS_SHOW_TABS) == 0)
2367 {
2368 // To preserve space, a single tab need not be displayed. We still need
2369 // two pixels of border / padding though.
2370 return 2;
2371 }
2372
2373 if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS)
2374 {
2375 dc.SetFont(m_tab_label_font);
2376 text_height = dc.GetTextExtent(wxT("ABCDEFXj")).GetHeight() + 10;
2377 }
2378 if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS)
2379 {
2380 size_t numpages = pages.GetCount();
2381 for(size_t i = 0; i < numpages; ++i)
2382 {
2383 const wxRibbonPageTabInfo& info = pages.Item(i);
2384 if(info.page->GetIcon().IsOk())
2385 {
2386 icon_height = wxMax(icon_height, info.page->GetIcon().GetHeight() + 4);
2387 }
2388 }
2389 }
2390
2391 return wxMax(text_height, icon_height);
2392 }
2393
2394 wxSize wxRibbonMSWArtProvider::GetScrollButtonMinimumSize(
2395 wxDC& WXUNUSED(dc),
2396 wxWindow* WXUNUSED(wnd),
2397 long WXUNUSED(style))
2398 {
2399 return wxSize(12, 12);
2400 }
2401
2402 wxSize wxRibbonMSWArtProvider::GetPanelSize(
2403 wxDC& dc,
2404 const wxRibbonPanel* wnd,
2405 wxSize client_size,
2406 wxPoint* client_offset)
2407 {
2408 dc.SetFont(m_panel_label_font);
2409 wxSize label_size = dc.GetTextExtent(wnd->GetLabel());
2410
2411 client_size.IncBy(0, label_size.GetHeight());
2412 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
2413 client_size.IncBy(4, 8);
2414 else
2415 client_size.IncBy(6, 6);
2416
2417 if(client_offset != NULL)
2418 {
2419 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
2420 *client_offset = wxPoint(2, 3);
2421 else
2422 *client_offset = wxPoint(3, 2);
2423 }
2424
2425 return client_size;
2426 }
2427
2428 wxSize wxRibbonMSWArtProvider::GetPanelClientSize(
2429 wxDC& dc,
2430 const wxRibbonPanel* wnd,
2431 wxSize size,
2432 wxPoint* client_offset)
2433 {
2434 dc.SetFont(m_panel_label_font);
2435 wxSize label_size = dc.GetTextExtent(wnd->GetLabel());
2436
2437 size.DecBy(0, label_size.GetHeight());
2438 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
2439 size.DecBy(4, 8);
2440 else
2441 size.DecBy(6, 6);
2442
2443 if(client_offset != NULL)
2444 {
2445 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
2446 *client_offset = wxPoint(2, 3);
2447 else
2448 *client_offset = wxPoint(3, 2);
2449 }
2450
2451 return size;
2452 }
2453
2454 wxSize wxRibbonMSWArtProvider::GetGallerySize(
2455 wxDC& WXUNUSED(dc),
2456 const wxRibbonGallery* WXUNUSED(wnd),
2457 wxSize client_size)
2458 {
2459 client_size.IncBy( 2, 1); // Left / top padding
2460 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
2461 client_size.IncBy(1, 16); // Right / bottom padding
2462 else
2463 client_size.IncBy(16, 1); // Right / bottom padding
2464 return client_size;
2465 }
2466
2467 wxSize wxRibbonMSWArtProvider::GetGalleryClientSize(
2468 wxDC& WXUNUSED(dc),
2469 const wxRibbonGallery* WXUNUSED(wnd),
2470 wxSize size,
2471 wxPoint* client_offset,
2472 wxRect* scroll_up_button,
2473 wxRect* scroll_down_button,
2474 wxRect* extension_button)
2475 {
2476 wxRect scroll_up;
2477 wxRect scroll_down;
2478 wxRect extension;
2479 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
2480 {
2481 // Flow is vertical - put buttons on bottom
2482 scroll_up.y = size.GetHeight() - 15;
2483 scroll_up.height = 15;
2484 scroll_up.x = 0;
2485 scroll_up.width = (size.GetWidth() + 2) / 3;
2486 scroll_down.y = scroll_up.y;
2487 scroll_down.height = scroll_up.height;
2488 scroll_down.x = scroll_up.x + scroll_up.width;
2489 scroll_down.width = scroll_up.width;
2490 extension.y = scroll_down.y;
2491 extension.height = scroll_down.height;
2492 extension.x = scroll_down.x + scroll_down.width;
2493 extension.width = size.GetWidth() - scroll_up.width - scroll_down.width;
2494 size.DecBy(1, 16);
2495 size.DecBy( 2, 1);
2496 }
2497 else
2498 {
2499 // Flow is horizontal - put buttons on right
2500 scroll_up.x = size.GetWidth() - 15;
2501 scroll_up.width = 15;
2502 scroll_up.y = 0;
2503 scroll_up.height = (size.GetHeight() + 2) / 3;
2504 scroll_down.x = scroll_up.x;
2505 scroll_down.width = scroll_up.width;
2506 scroll_down.y = scroll_up.y + scroll_up.height;
2507 scroll_down.height = scroll_up.height;
2508 extension.x = scroll_down.x;
2509 extension.width = scroll_down.width;
2510 extension.y = scroll_down.y + scroll_down.height;
2511 extension.height = size.GetHeight() - scroll_up.height - scroll_down.height;
2512 size.DecBy(16, 1);
2513 size.DecBy( 2, 1);
2514 }
2515
2516 if(client_offset != NULL)
2517 *client_offset = wxPoint(2, 1);
2518 if(scroll_up_button != NULL)
2519 *scroll_up_button = scroll_up;
2520 if(scroll_down_button != NULL)
2521 *scroll_down_button = scroll_down;
2522 if(extension_button != NULL)
2523 *extension_button = extension;
2524
2525 return size;
2526 }
2527
2528 wxRect wxRibbonMSWArtProvider::GetPageBackgroundRedrawArea(
2529 wxDC& WXUNUSED(dc),
2530 const wxRibbonPage* WXUNUSED(wnd),
2531 wxSize page_old_size,
2532 wxSize page_new_size)
2533 {
2534 wxRect new_rect, old_rect;
2535
2536 if(page_new_size.GetWidth() != page_old_size.GetWidth())
2537 {
2538 if(page_new_size.GetHeight() != page_old_size.GetHeight())
2539 {
2540 // Width and height both changed - redraw everything
2541 return wxRect(page_new_size);
2542 }
2543 else
2544 {
2545 // Only width changed - redraw right hand side
2546 const int right_edge_width = 4;
2547
2548 new_rect = wxRect(page_new_size.GetWidth() - right_edge_width, 0, right_edge_width, page_new_size.GetHeight());
2549 old_rect = wxRect(page_old_size.GetWidth() - right_edge_width, 0, right_edge_width, page_old_size.GetHeight());
2550 }
2551 }
2552 else
2553 {
2554 if(page_new_size.GetHeight() == page_old_size.GetHeight())
2555 {
2556 // Nothing changed (should never happen) - redraw nothing
2557 return wxRect(0, 0, 0, 0);
2558 }
2559 else
2560 {
2561 // Height changed - need to redraw everything (as the background
2562 // gradient is done vertically).
2563 return page_new_size;
2564 }
2565 }
2566
2567 new_rect.Union(old_rect);
2568 new_rect.Intersect(wxRect(page_new_size));
2569 return new_rect;
2570 }
2571
2572 bool wxRibbonMSWArtProvider::GetButtonBarButtonSize(
2573 wxDC& dc,
2574 wxWindow* wnd,
2575 wxRibbonButtonKind kind,
2576 wxRibbonButtonBarButtonState size,
2577 const wxString& label,
2578 wxSize bitmap_size_large,
2579 wxSize bitmap_size_small,
2580 wxSize* button_size,
2581 wxRect* normal_region,
2582 wxRect* dropdown_region)
2583 {
2584 const int drop_button_width = 8;
2585
2586 dc.SetFont(m_button_bar_label_font);
2587 switch(size & wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK)
2588 {
2589 case wxRIBBON_BUTTONBAR_BUTTON_SMALL:
2590 // Small bitmap, no label
2591 *button_size = bitmap_size_small + wxSize(6, 4);
2592 switch(kind)
2593 {
2594 case wxRIBBON_BUTTON_NORMAL:
2595 *normal_region = wxRect(*button_size);
2596 *dropdown_region = wxRect(0, 0, 0, 0);
2597 break;
2598 case wxRIBBON_BUTTON_DROPDOWN:
2599 *button_size += wxSize(drop_button_width, 0);
2600 *dropdown_region = wxRect(*button_size);
2601 *normal_region = wxRect(0, 0, 0, 0);
2602 break;
2603 case wxRIBBON_BUTTON_HYBRID:
2604 *normal_region = wxRect(*button_size);
2605 *dropdown_region = wxRect(button_size->GetWidth(), 0,
2606 drop_button_width, button_size->GetHeight());
2607 *button_size += wxSize(drop_button_width, 0);
2608 break;
2609 }
2610 break;
2611 case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM:
2612 // Small bitmap, with label to the right
2613 {
2614 GetButtonBarButtonSize(dc, wnd, kind, wxRIBBON_BUTTONBAR_BUTTON_SMALL,
2615 label, bitmap_size_large, bitmap_size_small, button_size,
2616 normal_region, dropdown_region);
2617 int text_size = dc.GetTextExtent(label).GetWidth();
2618 button_size->SetWidth(button_size->GetWidth() + text_size);
2619 switch(kind)
2620 {
2621 case wxRIBBON_BUTTON_DROPDOWN:
2622 dropdown_region->SetWidth(dropdown_region->GetWidth() + text_size);
2623 break;
2624 case wxRIBBON_BUTTON_HYBRID:
2625 dropdown_region->SetX(dropdown_region->GetX() + text_size);
2626 // no break
2627 case wxRIBBON_BUTTON_NORMAL:
2628 normal_region->SetWidth(normal_region->GetWidth() + text_size);
2629 break;
2630 }
2631 break;
2632 }
2633 case wxRIBBON_BUTTONBAR_BUTTON_LARGE:
2634 // Large bitmap, with label below (possibly split over 2 lines)
2635 {
2636 wxSize icon_size(bitmap_size_large);
2637 icon_size += wxSize(4, 4);
2638 wxCoord label_height;
2639 wxCoord best_width;
2640 dc.GetTextExtent(label, &best_width, &label_height);
2641 int best_num_lines = 1;
2642 int last_line_extra_width = 0;
2643 if(kind != wxRIBBON_BUTTON_NORMAL)
2644 {
2645 last_line_extra_width += 8;
2646 best_num_lines = 2; // label on top line, button below
2647 }
2648 size_t i;
2649 for(i = 0; i < label.Len(); ++i)
2650 {
2651 if(wxRibbonCanLabelBreakAtPosition(label, i))
2652 {
2653 int width = wxMax(
2654 dc.GetTextExtent(label.Mid(0, i - 1)).GetWidth(),
2655 dc.GetTextExtent(label.Mid(i + 1)).GetWidth() + last_line_extra_width);
2656 if(width < best_width)
2657 {
2658 best_width = width;
2659 best_num_lines = 2;
2660 }
2661 }
2662 }
2663 label_height *= 2; // Assume two lines even when only one is used
2664 // (to give all buttons a consistent height)
2665 icon_size.SetWidth(wxMax(icon_size.GetWidth(), best_width) + 6);
2666 icon_size.SetHeight(icon_size.GetHeight() + label_height);
2667 *button_size = icon_size;
2668 switch(kind)
2669 {
2670 case wxRIBBON_BUTTON_DROPDOWN:
2671 *dropdown_region = wxRect(icon_size);
2672 break;
2673 case wxRIBBON_BUTTON_HYBRID:
2674 *normal_region = wxRect(icon_size);
2675 normal_region->height -= 2 + label_height;
2676 dropdown_region->x = 0;
2677 dropdown_region->y = normal_region->height;
2678 dropdown_region->width = icon_size.GetWidth();
2679 dropdown_region->height = icon_size.GetHeight() - normal_region->height;
2680 break;
2681 case wxRIBBON_BUTTON_NORMAL:
2682 *normal_region = wxRect(icon_size);
2683 break;
2684 }
2685 break;
2686 }
2687 };
2688 return true;
2689 }
2690
2691 wxSize wxRibbonMSWArtProvider::GetMinimisedPanelMinimumSize(
2692 wxDC& dc,
2693 const wxRibbonPanel* wnd,
2694 wxSize* desired_bitmap_size,
2695 wxDirection* expanded_panel_direction)
2696 {
2697 if(desired_bitmap_size != NULL)
2698 {
2699 *desired_bitmap_size = wxSize(16, 16);
2700 }
2701 if(expanded_panel_direction != NULL)
2702 {
2703 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
2704 *expanded_panel_direction = wxEAST;
2705 else
2706 *expanded_panel_direction = wxSOUTH;
2707 }
2708 wxSize base_size(42, 42);
2709
2710 dc.SetFont(m_panel_label_font);
2711 wxSize label_size(dc.GetTextExtent(wnd->GetLabel()));
2712 label_size.IncBy(2, 2); // Allow for differences between this DC and a paint DC
2713 label_size.IncBy(6, 0); // Padding
2714 label_size.y *= 2; // Second line for dropdown button
2715
2716 if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
2717 {
2718 // Label alongside icon
2719 return wxSize(base_size.x + label_size.x,
2720 wxMax(base_size.y, label_size.y));
2721 }
2722 else
2723 {
2724 // Label beneath icon
2725 return wxSize(wxMax(base_size.x, label_size.x),
2726 base_size.y + label_size.y);
2727 }
2728 }
2729
2730 wxSize wxRibbonMSWArtProvider::GetToolSize(
2731 wxDC& WXUNUSED(dc),
2732 wxWindow* WXUNUSED(wnd),
2733 wxSize bitmap_size,
2734 wxRibbonButtonKind kind,
2735 bool WXUNUSED(is_first),
2736 bool is_last,
2737 wxRect* dropdown_region)
2738 {
2739 wxSize size(bitmap_size);
2740 size.IncBy(7, 6);
2741 if(is_last)
2742 size.IncBy(1, 0);
2743 if(kind != wxRIBBON_BUTTON_NORMAL)
2744 {
2745 size.IncBy(8, 0);
2746 if(dropdown_region)
2747 {
2748 if(kind == wxRIBBON_BUTTON_DROPDOWN)
2749 *dropdown_region = size;
2750 else
2751 *dropdown_region = wxRect(size.GetWidth() - 8, 0, 8, size.GetHeight());
2752 }
2753 }
2754 else
2755 {
2756 if(dropdown_region)
2757 *dropdown_region = wxRect(0, 0, 0, 0);
2758 }
2759 return size;
2760 }
2761
2762 #endif // wxUSE_RIBBON