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