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