]>
Commit | Line | Data |
---|---|---|
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 | ||
35 | static const char* const gallery_up_xpm[] = { | |
36 | "5 5 2 1", | |
37 | " c None", | |
38 | "x c #FF00FF", | |
39 | " ", | |
40 | " x ", | |
41 | " xxx ", | |
42 | "xxxxx", | |
43 | " "}; | |
44 | ||
45 | static const char* const gallery_down_xpm[] = { | |
46 | "5 5 2 1", | |
47 | " c None", | |
48 | "x c #FF00FF", | |
49 | " ", | |
50 | "xxxxx", | |
51 | " xxx ", | |
52 | " x ", | |
53 | " "}; | |
54 | ||
55 | static const char* const gallery_left_xpm[] = { | |
56 | "5 5 2 1", | |
57 | " c None", | |
58 | "x c #FF00FF", | |
59 | " x ", | |
60 | " xx ", | |
61 | " xxx ", | |
62 | " xx ", | |
63 | " x "}; | |
64 | ||
65 | static const char* const gallery_right_xpm[] = { | |
66 | "5 5 2 1", | |
67 | " c None", | |
68 | "x c #FF00FF", | |
69 | " x ", | |
70 | " xx ", | |
71 | " xxx ", | |
72 | " xx ", | |
73 | " x "}; | |
74 | ||
75 | static const char* const gallery_extension_xpm[] = { | |
76 | "5 5 2 1", | |
77 | " c None", | |
78 | "x c #FF00FF", | |
79 | "xxxxx", | |
80 | " ", | |
81 | "xxxxx", | |
82 | " xxx ", | |
83 | " x "}; | |
84 | ||
85 | wxRibbonMSWArtProvider::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 | ||
115 | wxRibbonMSWArtProvider::~wxRibbonMSWArtProvider() | |
116 | { | |
117 | } | |
118 | ||
119 | void 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 | ||
132 | void 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 PC |
146 | bool primary_is_gray = false; |
147 | const float gray_saturation_threshold = 0.01; | |
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 | ||
272 | wxRibbonArtProvider* wxRibbonMSWArtProvider::Clone() const | |
273 | { | |
274 | wxRibbonMSWArtProvider *copy = new wxRibbonMSWArtProvider; | |
275 | CloneTo(copy); | |
276 | return copy; | |
277 | } | |
278 | ||
279 | void 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 | ||
378 | long wxRibbonMSWArtProvider::GetFlags() const | |
379 | { | |
380 | return m_flags; | |
381 | } | |
382 | ||
383 | void 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 | ||
413 | int 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 | ||
449 | void 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 | ||
495 | void 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 | ||
514 | wxFont 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 | ||
532 | wxColour 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 | ||
681 | void 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 | ||
941 | void 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 | ||
961 | void 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(); | |
1038 | int x = tab.rect.x + 4; | |
1039 | if((m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) == 0) | |
1040 | x = tab.rect.x + (tab.rect.width - icon.GetWidth()) / 2; | |
1041 | dc.DrawBitmap(icon, x, tab.rect.y + 1 + (tab.rect.height - 1 - | |
1042 | icon.GetHeight()) / 2, true); | |
1043 | } | |
1044 | if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) | |
1045 | { | |
1046 | wxString label = tab.page->GetLabel(); | |
1047 | if(!label.IsEmpty()) | |
1048 | { | |
1049 | dc.SetFont(m_tab_label_font); | |
1050 | dc.SetTextForeground(m_tab_label_colour); | |
1051 | dc.SetBackgroundMode(wxTRANSPARENT); | |
1052 | ||
1053 | int text_height; | |
1054 | int text_width; | |
1055 | dc.GetTextExtent(label, &text_width, &text_height); | |
1056 | int width = tab.rect.width - 5; | |
1057 | int x = tab.rect.x + 3; | |
1058 | if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS) | |
1059 | { | |
1060 | x += 3 + tab.page->GetIcon().GetWidth(); | |
1061 | width -= 3 + tab.page->GetIcon().GetWidth(); | |
1062 | } | |
1063 | int y = tab.rect.y + (tab.rect.height - text_height) / 2; | |
1064 | ||
1065 | if(width <= text_width) | |
1066 | { | |
1067 | dc.SetClippingRegion(x, tab.rect.y, width, tab.rect.height); | |
1068 | dc.DrawText(label, x, y); | |
1069 | } | |
1070 | else | |
1071 | { | |
1072 | dc.DrawText(label, x + (width - text_width) / 2 + 1, y); | |
1073 | } | |
1074 | } | |
1075 | } | |
1076 | } | |
1077 | ||
1078 | void wxRibbonMSWArtProvider::DrawTabSeparator( | |
1079 | wxDC& dc, | |
1080 | wxWindow* wnd, | |
1081 | const wxRect& rect, | |
1082 | double visibility) | |
1083 | { | |
1084 | if(visibility <= 0.0) | |
1085 | { | |
1086 | return; | |
1087 | } | |
1088 | if(visibility > 1.0) | |
1089 | { | |
1090 | visibility = 1.0; | |
1091 | } | |
1092 | ||
1093 | // The tab separator is relatively expensive to draw (for its size), and is | |
1094 | // usually drawn multiple times sequentially (in different positions), so it | |
1095 | // makes sense to draw it once and cache it. | |
1096 | if(!m_cached_tab_separator.IsOk() || m_cached_tab_separator.GetSize() != rect.GetSize() || visibility != m_cached_tab_separator_visibility) | |
1097 | { | |
1098 | wxRect size(rect.GetSize()); | |
1099 | ReallyDrawTabSeparator(wnd, size, visibility); | |
1100 | } | |
1101 | dc.DrawBitmap(m_cached_tab_separator, rect.x, rect.y, false); | |
1102 | } | |
1103 | ||
1104 | void wxRibbonMSWArtProvider::ReallyDrawTabSeparator(wxWindow* wnd, const wxRect& rect, double visibility) | |
1105 | { | |
1106 | if(!m_cached_tab_separator.IsOk() || m_cached_tab_separator.GetSize() != rect.GetSize()) | |
1107 | { | |
1108 | m_cached_tab_separator = wxBitmap(rect.GetSize()); | |
1109 | } | |
1110 | ||
1111 | wxMemoryDC dc(m_cached_tab_separator); | |
1112 | DrawTabCtrlBackground(dc, wnd, rect); | |
1113 | ||
1114 | wxCoord x = rect.x + rect.width / 2; | |
1115 | double h = (double)(rect.height - 1); | |
1116 | ||
1117 | double r1 = m_tab_ctrl_background_brush.GetColour().Red() * (1.0 - visibility) + 0.5; | |
1118 | double g1 = m_tab_ctrl_background_brush.GetColour().Green() * (1.0 - visibility) + 0.5; | |
1119 | double b1 = m_tab_ctrl_background_brush.GetColour().Blue() * (1.0 - visibility) + 0.5; | |
1120 | double r2 = m_tab_separator_colour.Red(); | |
1121 | double g2 = m_tab_separator_colour.Green(); | |
1122 | double b2 = m_tab_separator_colour.Blue(); | |
1123 | double r3 = m_tab_separator_gradient_colour.Red(); | |
1124 | double g3 = m_tab_separator_gradient_colour.Green(); | |
1125 | double b3 = m_tab_separator_gradient_colour.Blue(); | |
1126 | ||
1127 | for(int i = 0; i < rect.height - 1; ++i) | |
1128 | { | |
1129 | double p = ((double)i)/h; | |
1130 | ||
1131 | double r = (p * r3 + (1.0 - p) * r2) * visibility + r1; | |
1132 | double g = (p * g3 + (1.0 - p) * g2) * visibility + g1; | |
1133 | double b = (p * b3 + (1.0 - p) * b2) * visibility + b1; | |
1134 | ||
1135 | wxPen P(wxColour((unsigned char)r, (unsigned char)g, (unsigned char)b)); | |
1136 | dc.SetPen(P); | |
1137 | dc.DrawPoint(x, rect.y + i); | |
1138 | } | |
1139 | ||
1140 | m_cached_tab_separator_visibility = visibility; | |
1141 | } | |
1142 | ||
1143 | void wxRibbonMSWArtProvider::DrawPartialPageBackground(wxDC& dc, | |
1144 | wxWindow* WXUNUSED(wnd), const wxRect& rect, wxRibbonPage* page, | |
1145 | wxPoint offset, bool hovered) | |
1146 | { | |
1147 | wxRect background(page->GetSize()); | |
1148 | page->AdjustRectToIncludeScrollButtons(&background); | |
1149 | background.height -= 2; | |
1150 | // Page background isn't dependant upon the width of the page | |
1151 | // (at least not the part of it intended to be painted by this | |
1152 | // function). Set to wider than the page itself for when externally | |
1153 | // expanded panels need a background - the expanded panel can be wider | |
1154 | // than the bar. | |
1155 | background.x = 0; | |
1156 | background.width = INT_MAX; | |
1157 | ||
1158 | // upper_rect, lower_rect, paint_rect are all in page co-ordinates | |
1159 | wxRect upper_rect(background); | |
1160 | upper_rect.height /= 5; | |
1161 | ||
1162 | wxRect lower_rect(background); | |
1163 | lower_rect.y += upper_rect.height; | |
1164 | lower_rect.height -= upper_rect.height; | |
1165 | ||
1166 | wxRect paint_rect(rect); | |
1167 | paint_rect.x += offset.x; | |
1168 | paint_rect.y += offset.y; | |
1169 | ||
1170 | wxColour bg_top, bg_top_grad, bg_btm, bg_btm_grad; | |
1171 | if(hovered) | |
1172 | { | |
1173 | bg_top = m_page_hover_background_top_colour; | |
1174 | bg_top_grad = m_page_hover_background_top_gradient_colour; | |
1175 | bg_btm = m_page_hover_background_colour; | |
1176 | bg_btm_grad = m_page_hover_background_gradient_colour; | |
1177 | } | |
1178 | else | |
1179 | { | |
1180 | bg_top = m_page_background_top_colour; | |
1181 | bg_top_grad = m_page_background_top_gradient_colour; | |
1182 | bg_btm = m_page_background_colour; | |
1183 | bg_btm_grad = m_page_background_gradient_colour; | |
1184 | } | |
1185 | ||
1186 | if(paint_rect.Intersects(upper_rect)) | |
1187 | { | |
1188 | wxRect rect(upper_rect); | |
1189 | rect.Intersect(paint_rect); | |
1190 | rect.x -= offset.x; | |
1191 | rect.y -= offset.y; | |
1192 | wxColour starting_colour(wxRibbonInterpolateColour(bg_top, bg_top_grad, | |
1193 | paint_rect.y, upper_rect.y, upper_rect.y + upper_rect.height)); | |
1194 | wxColour ending_colour(wxRibbonInterpolateColour(bg_top, bg_top_grad, | |
1195 | paint_rect.y + paint_rect.height, upper_rect.y, | |
1196 | upper_rect.y + upper_rect.height)); | |
1197 | dc.GradientFillLinear(rect, starting_colour, ending_colour, wxSOUTH); | |
1198 | } | |
1199 | ||
1200 | if(paint_rect.Intersects(lower_rect)) | |
1201 | { | |
1202 | wxRect rect(lower_rect); | |
1203 | rect.Intersect(paint_rect); | |
1204 | rect.x -= offset.x; | |
1205 | rect.y -= offset.y; | |
1206 | wxColour starting_colour(wxRibbonInterpolateColour(bg_btm, bg_btm_grad, | |
1207 | paint_rect.y, lower_rect.y, lower_rect.y + lower_rect.height)); | |
1208 | wxColour ending_colour(wxRibbonInterpolateColour(bg_btm, bg_btm_grad, | |
1209 | paint_rect.y + paint_rect.height, | |
1210 | lower_rect.y, lower_rect.y + lower_rect.height)); | |
1211 | dc.GradientFillLinear(rect, starting_colour, ending_colour, wxSOUTH); | |
1212 | } | |
1213 | } | |
1214 | ||
1215 | void wxRibbonMSWArtProvider::DrawPageBackground( | |
1216 | wxDC& dc, | |
1217 | wxWindow* WXUNUSED(wnd), | |
1218 | const wxRect& rect) | |
1219 | { | |
1220 | dc.SetPen(*wxTRANSPARENT_PEN); | |
1221 | dc.SetBrush(m_tab_ctrl_background_brush); | |
1222 | ||
1223 | { | |
1224 | wxRect edge(rect); | |
1225 | ||
1226 | edge.width = 2; | |
1227 | dc.DrawRectangle(edge.x, edge.y, edge.width, edge.height); | |
1228 | ||
1229 | edge.x += rect.width - 2; | |
1230 | dc.DrawRectangle(edge.x, edge.y, edge.width, edge.height); | |
1231 | ||
1232 | edge = rect; | |
1233 | edge.height = 2; | |
1234 | edge.y += (rect.height - edge.height); | |
1235 | dc.DrawRectangle(edge.x, edge.y, edge.width, edge.height); | |
1236 | } | |
1237 | ||
1238 | { | |
1239 | wxRect background(rect); | |
1240 | background.x += 2; | |
1241 | background.width -= 4; | |
1242 | background.height -= 2; | |
1243 | ||
1244 | background.height /= 5; | |
1245 | dc.GradientFillLinear(background, m_page_background_top_colour, | |
1246 | m_page_background_top_gradient_colour, wxSOUTH); | |
1247 | ||
1248 | background.y += background.height; | |
1249 | background.height = rect.height - 2 - background.height; | |
1250 | dc.GradientFillLinear(background, m_page_background_colour, | |
1251 | m_page_background_gradient_colour, wxSOUTH); | |
1252 | } | |
1253 | ||
1254 | { | |
1255 | wxPoint border_points[8]; | |
1256 | border_points[0] = wxPoint(2, 0); | |
1257 | border_points[1] = wxPoint(1, 1); | |
1258 | border_points[2] = wxPoint(1, rect.height - 4); | |
1259 | border_points[3] = wxPoint(3, rect.height - 2); | |
1260 | border_points[4] = wxPoint(rect.width - 4, rect.height - 2); | |
1261 | border_points[5] = wxPoint(rect.width - 2, rect.height - 4); | |
1262 | border_points[6] = wxPoint(rect.width - 2, 1); | |
1263 | border_points[7] = wxPoint(rect.width - 4, -1); | |
1264 | ||
1265 | dc.SetPen(m_page_border_pen); | |
1266 | dc.DrawLines(sizeof(border_points)/sizeof(wxPoint), border_points, rect.x, rect.y); | |
1267 | } | |
1268 | } | |
1269 | ||
1270 | void wxRibbonMSWArtProvider::DrawScrollButton( | |
1271 | wxDC& dc, | |
1272 | wxWindow* WXUNUSED(wnd), | |
1273 | const wxRect& rect_, | |
1274 | long style) | |
1275 | { | |
1276 | wxRect rect(rect_); | |
1277 | ||
1278 | if((style & wxRIBBON_SCROLL_BTN_FOR_MASK) == wxRIBBON_SCROLL_BTN_FOR_PAGE) | |
1279 | { | |
1280 | // Page scroll buttons do not have the luxury of rendering on top of anything | |
1281 | // else, and their size includes some padding, hence the background painting | |
1282 | // and size adjustment. | |
1283 | dc.SetPen(*wxTRANSPARENT_PEN); | |
1284 | dc.SetBrush(m_tab_ctrl_background_brush); | |
1285 | dc.DrawRectangle(rect); | |
1286 | dc.SetClippingRegion(rect); | |
1287 | switch(style & wxRIBBON_SCROLL_BTN_DIRECTION_MASK) | |
1288 | { | |
1289 | case wxRIBBON_SCROLL_BTN_LEFT: | |
1290 | rect.x++; | |
1291 | case wxRIBBON_SCROLL_BTN_RIGHT: | |
1292 | rect.y--; | |
1293 | rect.width--; | |
1294 | break; | |
1295 | case wxRIBBON_SCROLL_BTN_UP: | |
1296 | rect.x++; | |
1297 | rect.y--; | |
1298 | rect.width -= 2; | |
1299 | rect.height++; | |
1300 | break; | |
1301 | case wxRIBBON_SCROLL_BTN_DOWN: | |
1302 | rect.x++; | |
1303 | rect.width -= 2; | |
1304 | rect.height--; | |
1305 | break; | |
1306 | } | |
1307 | } | |
1308 | ||
1309 | { | |
1310 | wxRect background(rect); | |
1311 | background.x++; | |
1312 | background.y++; | |
1313 | background.width -= 2; | |
1314 | background.height -= 2; | |
1315 | ||
1316 | if(style & wxRIBBON_SCROLL_BTN_UP) | |
1317 | background.height /= 2; | |
1318 | else | |
1319 | background.height /= 5; | |
1320 | dc.GradientFillLinear(background, m_page_background_top_colour, | |
1321 | m_page_background_top_gradient_colour, wxSOUTH); | |
1322 | ||
1323 | background.y += background.height; | |
1324 | background.height = rect.height - 2 - background.height; | |
1325 | dc.GradientFillLinear(background, m_page_background_colour, | |
1326 | m_page_background_gradient_colour, wxSOUTH); | |
1327 | } | |
1328 | ||
1329 | { | |
1330 | wxPoint border_points[7]; | |
1331 | switch(style & wxRIBBON_SCROLL_BTN_DIRECTION_MASK) | |
1332 | { | |
1333 | case wxRIBBON_SCROLL_BTN_LEFT: | |
1334 | border_points[0] = wxPoint(2, 0); | |
1335 | border_points[1] = wxPoint(rect.width - 1, 0); | |
1336 | border_points[2] = wxPoint(rect.width - 1, rect.height - 1); | |
1337 | border_points[3] = wxPoint(2, rect.height - 1); | |
1338 | border_points[4] = wxPoint(0, rect.height - 3); | |
1339 | border_points[5] = wxPoint(0, 2); | |
1340 | break; | |
1341 | case wxRIBBON_SCROLL_BTN_RIGHT: | |
1342 | border_points[0] = wxPoint(0, 0); | |
1343 | border_points[1] = wxPoint(rect.width - 3, 0); | |
1344 | border_points[2] = wxPoint(rect.width - 1, 2); | |
1345 | border_points[3] = wxPoint(rect.width - 1, rect.height - 3); | |
1346 | border_points[4] = wxPoint(rect.width - 3, rect.height - 1); | |
1347 | border_points[5] = wxPoint(0, rect.height - 1); | |
1348 | break; | |
1349 | case wxRIBBON_SCROLL_BTN_UP: | |
1350 | border_points[0] = wxPoint(2, 0); | |
1351 | border_points[1] = wxPoint(rect.width - 3, 0); | |
1352 | border_points[2] = wxPoint(rect.width - 1, 2); | |
1353 | border_points[3] = wxPoint(rect.width - 1, rect.height - 1); | |
1354 | border_points[4] = wxPoint(0, rect.height - 1); | |
1355 | border_points[5] = wxPoint(0, 2); | |
1356 | break; | |
1357 | case wxRIBBON_SCROLL_BTN_DOWN: | |
1358 | border_points[0] = wxPoint(0, 0); | |
1359 | border_points[1] = wxPoint(rect.width - 1, 0); | |
1360 | border_points[2] = wxPoint(rect.width - 1, rect.height - 3); | |
1361 | border_points[3] = wxPoint(rect.width - 3, rect.height - 1); | |
1362 | border_points[4] = wxPoint(2, rect.height - 1); | |
1363 | border_points[5] = wxPoint(0, rect.height - 3); | |
1364 | break; | |
1365 | } | |
1366 | border_points[6] = border_points[0]; | |
1367 | ||
1368 | dc.SetPen(m_page_border_pen); | |
1369 | dc.DrawLines(sizeof(border_points)/sizeof(wxPoint), border_points, rect.x, rect.y); | |
1370 | } | |
1371 | ||
1372 | { | |
1373 | // NB: Code for handling hovered/active state is temporary | |
1374 | wxPoint arrow_points[3]; | |
1375 | switch(style & wxRIBBON_SCROLL_BTN_DIRECTION_MASK) | |
1376 | { | |
1377 | case wxRIBBON_SCROLL_BTN_LEFT: | |
1378 | arrow_points[0] = wxPoint(rect.width / 2 - 2, rect.height / 2); | |
1379 | if(style & wxRIBBON_SCROLL_BTN_ACTIVE) | |
1380 | arrow_points[0].y += 1; | |
1381 | arrow_points[1] = arrow_points[0] + wxPoint(3, -3); | |
1382 | arrow_points[2] = arrow_points[0] + wxPoint(3, 3); | |
1383 | break; | |
1384 | case wxRIBBON_SCROLL_BTN_RIGHT: | |
1385 | arrow_points[0] = wxPoint(rect.width / 2 + 2, rect.height / 2); | |
1386 | if(style & wxRIBBON_SCROLL_BTN_ACTIVE) | |
1387 | arrow_points[0].y += 1; | |
1388 | arrow_points[1] = arrow_points[0] - wxPoint(3, 3); | |
1389 | arrow_points[2] = arrow_points[0] - wxPoint(3, -3); | |
1390 | break; | |
1391 | case wxRIBBON_SCROLL_BTN_UP: | |
1392 | arrow_points[0] = wxPoint(rect.width / 2, rect.height / 2 - 2); | |
1393 | if(style & wxRIBBON_SCROLL_BTN_ACTIVE) | |
1394 | arrow_points[0].y += 1; | |
1395 | arrow_points[1] = arrow_points[0] + wxPoint( 3, 3); | |
1396 | arrow_points[2] = arrow_points[0] + wxPoint(-3, 3); | |
1397 | break; | |
1398 | case wxRIBBON_SCROLL_BTN_DOWN: | |
1399 | arrow_points[0] = wxPoint(rect.width / 2, rect.height / 2 + 2); | |
1400 | if(style & wxRIBBON_SCROLL_BTN_ACTIVE) | |
1401 | arrow_points[0].y += 1; | |
1402 | arrow_points[1] = arrow_points[0] - wxPoint( 3, 3); | |
1403 | arrow_points[2] = arrow_points[0] - wxPoint(-3, 3); | |
1404 | break; | |
1405 | } | |
1406 | ||
1407 | dc.SetPen(*wxTRANSPARENT_PEN); | |
1408 | wxBrush B(style & wxRIBBON_SCROLL_BTN_HOVERED ? m_tab_active_background_colour : m_tab_label_colour); | |
1409 | dc.SetBrush(B); | |
1410 | dc.DrawPolygon(sizeof(arrow_points)/sizeof(wxPoint), arrow_points, rect.x, rect.y); | |
1411 | } | |
1412 | } | |
1413 | ||
1414 | void wxRibbonMSWArtProvider::DrawDropdownArrow(wxDC& dc, int x, int y, const wxColour& colour) | |
1415 | { | |
1416 | wxPoint arrow_points[3]; | |
1417 | wxBrush brush(colour); | |
1418 | arrow_points[0] = wxPoint(1, 2); | |
1419 | arrow_points[1] = arrow_points[0] + wxPoint(-3, -3); | |
1420 | arrow_points[2] = arrow_points[0] + wxPoint( 3, -3); | |
1421 | dc.SetPen(*wxTRANSPARENT_PEN); | |
1422 | dc.SetBrush(brush); | |
1423 | dc.DrawPolygon(sizeof(arrow_points)/sizeof(wxPoint), arrow_points, x, y); | |
1424 | } | |
1425 | ||
1426 | void wxRibbonMSWArtProvider::RemovePanelPadding(wxRect* rect) | |
1427 | { | |
1428 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
1429 | { | |
1430 | rect->y += 1; | |
1431 | rect->height -= 2; | |
1432 | } | |
1433 | else | |
1434 | { | |
1435 | rect->x += 1; | |
1436 | rect->width -= 2; | |
1437 | } | |
1438 | } | |
1439 | ||
1440 | void wxRibbonMSWArtProvider::DrawPanelBackground( | |
1441 | wxDC& dc, | |
1442 | wxRibbonPanel* wnd, | |
1443 | const wxRect& rect) | |
1444 | { | |
1445 | DrawPartialPageBackground(dc, wnd, rect, false); | |
1446 | ||
1447 | wxRect true_rect(rect); | |
1448 | RemovePanelPadding(&true_rect); | |
1449 | ||
1450 | int label_height; | |
1451 | { | |
1452 | dc.SetFont(m_panel_label_font); | |
1453 | dc.SetPen(*wxTRANSPARENT_PEN); | |
1454 | if(wnd->IsHovered()) | |
1455 | { | |
1456 | dc.SetBrush(m_panel_hover_label_background_brush); | |
1457 | dc.SetTextForeground(m_panel_hover_label_colour); | |
1458 | } | |
1459 | else | |
1460 | { | |
1461 | dc.SetBrush(m_panel_label_background_brush); | |
1462 | dc.SetTextForeground(m_panel_label_colour); | |
1463 | } | |
1464 | ||
1465 | wxRect label_rect(true_rect); | |
1466 | wxString label = wnd->GetLabel(); | |
1467 | bool clip_label = false; | |
1468 | wxSize label_size(dc.GetTextExtent(label)); | |
1469 | ||
1470 | label_rect.SetX(label_rect.GetX() + 1); | |
1471 | label_rect.SetWidth(label_rect.GetWidth() - 2); | |
1472 | label_rect.SetHeight(label_size.GetHeight() + 2); | |
1473 | label_rect.SetY(true_rect.GetBottom() - label_rect.GetHeight()); | |
1474 | label_height = label_rect.GetHeight(); | |
1475 | ||
1476 | if(label_size.GetWidth() > label_rect.GetWidth()) | |
1477 | { | |
1478 | // Test if there is enough length for 3 letters and ... | |
1479 | wxString new_label = label.Mid(0, 3) + wxT("..."); | |
1480 | label_size = dc.GetTextExtent(new_label); | |
1481 | if(label_size.GetWidth() > label_rect.GetWidth()) | |
1482 | { | |
1483 | // Not enough room for three characters and ... | |
1484 | // Display the entire label and just crop it | |
1485 | clip_label = true; | |
1486 | } | |
1487 | else | |
1488 | { | |
1489 | // Room for some characters and ... | |
1490 | // Display as many characters as possible and append ... | |
1491 | for(size_t len = label.Len() - 1; len >= 3; --len) | |
1492 | { | |
1493 | new_label = label.Mid(0, len) + wxT("..."); | |
1494 | label_size = dc.GetTextExtent(new_label); | |
1495 | if(label_size.GetWidth() <= label_rect.GetWidth()) | |
1496 | { | |
1497 | label = new_label; | |
1498 | break; | |
1499 | } | |
1500 | } | |
1501 | } | |
1502 | } | |
1503 | ||
1504 | dc.DrawRectangle(label_rect.GetX(), label_rect.GetY(), label_rect.GetWidth(), label_rect.GetHeight()); | |
1505 | if(clip_label) | |
1506 | { | |
1507 | wxDCClipper clip(dc, label_rect); | |
1508 | dc.DrawText(label, label_rect.x, label_rect.y + | |
1509 | (label_rect.GetHeight() - label_size.GetHeight()) / 2); | |
1510 | } | |
1511 | else | |
1512 | { | |
1513 | dc.DrawText(label, label_rect.x + | |
1514 | (label_rect.GetWidth() - label_size.GetWidth()) / 2, | |
1515 | label_rect.y + | |
1516 | (label_rect.GetHeight() - label_size.GetHeight()) / 2); | |
1517 | } | |
1518 | } | |
1519 | ||
1520 | if(wnd->IsHovered()) | |
1521 | { | |
1522 | wxRect client_rect(true_rect); | |
1523 | client_rect.x++; | |
1524 | client_rect.width -= 2; | |
1525 | client_rect.y++; | |
1526 | client_rect.height -= 2 + label_height; | |
1527 | DrawPartialPageBackground(dc, wnd, client_rect, true); | |
1528 | } | |
1529 | ||
1530 | DrawPanelBorder(dc, true_rect, m_panel_border_pen, m_panel_border_gradient_pen); | |
1531 | } | |
1532 | ||
1533 | void wxRibbonMSWArtProvider::DrawGalleryBackground( | |
1534 | wxDC& dc, | |
1535 | wxRibbonGallery* wnd, | |
1536 | const wxRect& rect) | |
1537 | { | |
1538 | DrawPartialPageBackground(dc, wnd, rect); | |
1539 | ||
1540 | if(wnd->IsHovered()) | |
1541 | { | |
1542 | dc.SetPen(*wxTRANSPARENT_PEN); | |
1543 | dc.SetBrush(m_gallery_hover_background_brush); | |
1544 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
1545 | { | |
1546 | dc.DrawRectangle(rect.x + 1, rect.y + 1, rect.width - 2, | |
1547 | rect.height - 16); | |
1548 | } | |
1549 | else | |
1550 | { | |
1551 | dc.DrawRectangle(rect.x + 1, rect.y + 1, rect.width - 16, | |
1552 | rect.height - 2); | |
1553 | } | |
1554 | } | |
1555 | ||
1556 | dc.SetPen(m_gallery_border_pen); | |
1557 | // Outline | |
1558 | dc.DrawLine(rect.x + 1, rect.y, rect.x + rect.width - 1, rect.y); | |
1559 | dc.DrawLine(rect.x, rect.y + 1, rect.x, rect.y + rect.height - 1); | |
1560 | dc.DrawLine(rect.x + 1, rect.y + rect.height - 1, rect.x + rect.width - 1, | |
1561 | rect.y + rect.height - 1); | |
1562 | dc.DrawLine(rect.x + rect.width - 1, rect.y + 1, rect.x + rect.width - 1, | |
1563 | rect.y + rect.height - 1); | |
1564 | ||
1565 | DrawGalleryBackgroundCommon(dc, wnd, rect); | |
1566 | } | |
1567 | ||
1568 | void wxRibbonMSWArtProvider::DrawGalleryBackgroundCommon(wxDC& dc, | |
1569 | wxRibbonGallery* wnd, | |
1570 | const wxRect& rect) | |
1571 | { | |
1572 | wxRect up_btn, down_btn, ext_btn; | |
1573 | ||
1574 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
1575 | { | |
1576 | // Divider between items and buttons | |
1577 | dc.DrawLine(rect.x, rect.y + rect.height - 15, rect.x + rect.width, | |
1578 | rect.y + rect.height - 15); | |
1579 | ||
1580 | up_btn = wxRect(rect.x, rect.y + rect.height - 15, rect.width / 3, 15); | |
1581 | ||
1582 | down_btn = wxRect(up_btn.GetRight() + 1, up_btn.GetTop(), | |
1583 | up_btn.GetWidth(), up_btn.GetHeight()); | |
1584 | dc.DrawLine(down_btn.GetLeft(), down_btn.GetTop(), down_btn.GetLeft(), | |
1585 | down_btn.GetBottom()); | |
1586 | ||
1587 | ext_btn = wxRect(down_btn.GetRight() + 1, up_btn.GetTop(), rect.width - | |
1588 | up_btn.GetWidth() - down_btn.GetWidth() - 1, up_btn.GetHeight()); | |
1589 | dc.DrawLine(ext_btn.GetLeft(), ext_btn.GetTop(), ext_btn.GetLeft(), | |
1590 | ext_btn.GetBottom()); | |
1591 | } | |
1592 | else | |
1593 | { | |
1594 | // Divider between items and buttons | |
1595 | dc.DrawLine(rect.x + rect.width - 15, rect.y, rect.x + rect.width - 15, | |
1596 | rect.y + rect.height); | |
1597 | ||
1598 | up_btn = wxRect(rect.x + rect.width - 15, rect.y, 15, rect.height / 3); | |
1599 | ||
1600 | down_btn = wxRect(up_btn.GetLeft(), up_btn.GetBottom() + 1, | |
1601 | up_btn.GetWidth(), up_btn.GetHeight()); | |
1602 | dc.DrawLine(down_btn.GetLeft(), down_btn.GetTop(), down_btn.GetRight(), | |
1603 | down_btn.GetTop()); | |
1604 | ||
1605 | ext_btn = wxRect(up_btn.GetLeft(), down_btn.GetBottom() + 1, up_btn.GetWidth(), | |
1606 | rect.height - up_btn.GetHeight() - down_btn.GetHeight() - 1); | |
1607 | dc.DrawLine(ext_btn.GetLeft(), ext_btn.GetTop(), ext_btn.GetRight(), | |
1608 | ext_btn.GetTop()); | |
1609 | } | |
1610 | ||
1611 | DrawGalleryButton(dc, up_btn, wnd->GetUpButtonState(), | |
1612 | m_gallery_up_bitmap); | |
1613 | DrawGalleryButton(dc, down_btn, wnd->GetDownButtonState(), | |
1614 | m_gallery_down_bitmap); | |
1615 | DrawGalleryButton(dc, ext_btn, wnd->GetExtensionButtonState(), | |
1616 | m_gallery_extension_bitmap); | |
1617 | } | |
1618 | ||
1619 | void wxRibbonMSWArtProvider::DrawGalleryButton(wxDC& dc, | |
1620 | wxRect rect, | |
1621 | wxRibbonGalleryButtonState state, | |
1622 | wxBitmap* bitmaps) | |
1623 | { | |
1624 | wxBitmap btn_bitmap; | |
1625 | wxBrush btn_top_brush; | |
1626 | wxColour btn_colour; | |
1627 | wxColour btn_grad_colour; | |
1628 | switch(state) | |
1629 | { | |
1630 | case wxRIBBON_GALLERY_BUTTON_NORMAL: | |
1631 | btn_top_brush = m_gallery_button_background_top_brush; | |
1632 | btn_colour = m_gallery_button_background_colour; | |
1633 | btn_grad_colour = m_gallery_button_background_gradient_colour; | |
1634 | btn_bitmap = bitmaps[0]; | |
1635 | break; | |
1636 | case wxRIBBON_GALLERY_BUTTON_HOVERED: | |
1637 | btn_top_brush = m_gallery_button_hover_background_top_brush; | |
1638 | btn_colour = m_gallery_button_hover_background_colour; | |
1639 | btn_grad_colour = m_gallery_button_hover_background_gradient_colour; | |
1640 | btn_bitmap = bitmaps[1]; | |
1641 | break; | |
1642 | case wxRIBBON_GALLERY_BUTTON_ACTIVE: | |
1643 | btn_top_brush = m_gallery_button_active_background_top_brush; | |
1644 | btn_colour = m_gallery_button_active_background_colour; | |
1645 | btn_grad_colour = m_gallery_button_active_background_gradient_colour; | |
1646 | btn_bitmap = bitmaps[2]; | |
1647 | break; | |
1648 | case wxRIBBON_GALLERY_BUTTON_DISABLED: | |
1649 | btn_top_brush = m_gallery_button_disabled_background_top_brush; | |
1650 | btn_colour = m_gallery_button_disabled_background_colour; | |
1651 | btn_grad_colour = m_gallery_button_disabled_background_gradient_colour; | |
1652 | btn_bitmap = bitmaps[3]; | |
1653 | break; | |
1654 | } | |
1655 | ||
1656 | rect.x++; | |
1657 | rect.y++; | |
1658 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
1659 | { | |
1660 | rect.width--;; | |
1661 | rect.height -= 2; | |
1662 | } | |
1663 | else | |
1664 | { | |
1665 | rect.width -= 2; | |
1666 | rect.height--; | |
1667 | } | |
1668 | ||
1669 | dc.SetPen(*wxTRANSPARENT_PEN); | |
1670 | dc.SetBrush(btn_top_brush); | |
1671 | dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height / 2); | |
1672 | ||
1673 | wxRect lower(rect); | |
1674 | lower.height = (lower.height + 1) / 2; | |
1675 | lower.y += rect.height - lower.height; | |
1676 | dc.GradientFillLinear(lower, btn_colour, btn_grad_colour, wxSOUTH); | |
1677 | ||
1678 | dc.DrawBitmap(btn_bitmap, rect.x + rect.width / 2 - 2, lower.y - 2, true); | |
1679 | } | |
1680 | ||
1681 | void wxRibbonMSWArtProvider::DrawGalleryItemBackground( | |
1682 | wxDC& dc, | |
1683 | wxRibbonGallery* wnd, | |
1684 | const wxRect& rect, | |
1685 | wxRibbonGalleryItem* item) | |
1686 | { | |
1687 | if(wnd->GetHoveredItem() != item && wnd->GetActiveItem() != item && | |
1688 | wnd->GetSelection() != item) | |
1689 | return; | |
1690 | ||
1691 | dc.SetPen(m_gallery_item_border_pen); | |
1692 | dc.DrawLine(rect.x + 1, rect.y, rect.x + rect.width - 1, rect.y); | |
1693 | dc.DrawLine(rect.x, rect.y + 1, rect.x, rect.y + rect.height - 1); | |
1694 | dc.DrawLine(rect.x + 1, rect.y + rect.height - 1, rect.x + rect.width - 1, | |
1695 | rect.y + rect.height - 1); | |
1696 | dc.DrawLine(rect.x + rect.width - 1, rect.y + 1, rect.x + rect.width - 1, | |
1697 | rect.y + rect.height - 1); | |
1698 | ||
1699 | wxBrush top_brush; | |
1700 | wxColour bg_colour; | |
1701 | wxColour bg_gradient_colour; | |
1702 | ||
1703 | if(wnd->GetActiveItem() == item || wnd->GetSelection() == item) | |
1704 | { | |
1705 | top_brush = m_gallery_button_active_background_top_brush; | |
1706 | bg_colour = m_gallery_button_active_background_colour; | |
1707 | bg_gradient_colour = m_gallery_button_active_background_gradient_colour; | |
1708 | } | |
1709 | else | |
1710 | { | |
1711 | top_brush = m_gallery_button_hover_background_top_brush; | |
1712 | bg_colour = m_gallery_button_hover_background_colour; | |
1713 | bg_gradient_colour = m_gallery_button_hover_background_gradient_colour; | |
1714 | } | |
1715 | ||
1716 | wxRect upper(rect); | |
1717 | upper.x += 1; | |
1718 | upper.width -= 2; | |
1719 | upper.y += 1; | |
1720 | upper.height /= 3; | |
1721 | dc.SetPen(*wxTRANSPARENT_PEN); | |
1722 | dc.SetBrush(top_brush); | |
1723 | dc.DrawRectangle(upper.x, upper.y, upper.width, upper.height); | |
1724 | ||
1725 | wxRect lower(upper); | |
1726 | lower.y += lower.height; | |
1727 | lower.height = rect.height - 2 - lower.height; | |
1728 | dc.GradientFillLinear(lower, bg_colour, bg_gradient_colour, wxSOUTH); | |
1729 | } | |
1730 | ||
1731 | void wxRibbonMSWArtProvider::DrawPanelBorder(wxDC& dc, const wxRect& rect, | |
1732 | wxPen& primary_colour, | |
1733 | wxPen& secondary_colour) | |
1734 | { | |
1735 | wxPoint border_points[9]; | |
1736 | border_points[0] = wxPoint(2, 0); | |
1737 | border_points[1] = wxPoint(rect.width - 3, 0); | |
1738 | border_points[2] = wxPoint(rect.width - 1, 2); | |
1739 | border_points[3] = wxPoint(rect.width - 1, rect.height - 3); | |
1740 | border_points[4] = wxPoint(rect.width - 3, rect.height - 1); | |
1741 | border_points[5] = wxPoint(2, rect.height - 1); | |
1742 | border_points[6] = wxPoint(0, rect.height - 3); | |
1743 | border_points[7] = wxPoint(0, 2); | |
1744 | ||
1745 | if(primary_colour.GetColour() == secondary_colour.GetColour()) | |
1746 | { | |
1747 | border_points[8] = border_points[0]; | |
1748 | dc.SetPen(primary_colour); | |
1749 | dc.DrawLines(sizeof(border_points)/sizeof(wxPoint), border_points, rect.x, rect.y); | |
1750 | } | |
1751 | else | |
1752 | { | |
1753 | dc.SetPen(primary_colour); | |
1754 | dc.DrawLines(3, border_points, rect.x, rect.y); | |
1755 | ||
1756 | #define SingleLine(start, finish) \ | |
1757 | dc.DrawLine(start.x + rect.x, start.y + rect.y, finish.x + rect.x, finish.y + rect.y) | |
1758 | ||
1759 | SingleLine(border_points[0], border_points[7]); | |
1760 | dc.SetPen(secondary_colour); | |
1761 | dc.DrawLines(3, border_points + 4, rect.x, rect.y); | |
1762 | SingleLine(border_points[4], border_points[3]); | |
1763 | ||
1764 | #undef SingleLine | |
1765 | ||
1766 | border_points[6] = border_points[2]; | |
1767 | wxRibbonDrawParallelGradientLines(dc, 2, border_points + 6, 0, 1, | |
1768 | border_points[3].y - border_points[2].y + 1, rect.x, rect.y, | |
1769 | primary_colour.GetColour(), secondary_colour.GetColour()); | |
1770 | } | |
1771 | } | |
1772 | ||
1773 | void wxRibbonMSWArtProvider::DrawMinimisedPanel( | |
1774 | wxDC& dc, | |
1775 | wxRibbonPanel* wnd, | |
1776 | const wxRect& rect, | |
1777 | wxBitmap& bitmap) | |
1778 | { | |
1779 | DrawPartialPageBackground(dc, wnd, rect, false); | |
1780 | ||
1781 | wxRect true_rect(rect); | |
1782 | RemovePanelPadding(&true_rect); | |
1783 | ||
1784 | if(wnd->GetExpandedPanel() != NULL) | |
1785 | { | |
1786 | wxRect client_rect(true_rect); | |
1787 | client_rect.x++; | |
1788 | client_rect.width -= 2; | |
1789 | client_rect.y++; | |
1790 | client_rect.height = (rect.y + rect.height / 5) - client_rect.x; | |
1791 | dc.GradientFillLinear(client_rect, | |
1792 | m_panel_active_background_top_colour, | |
1793 | m_panel_active_background_top_gradient_colour, wxSOUTH); | |
1794 | ||
1795 | client_rect.y += client_rect.height; | |
1796 | client_rect.height = (true_rect.y + true_rect.height) - client_rect.y; | |
1797 | dc.GradientFillLinear(client_rect, | |
1798 | m_panel_active_background_colour, | |
1799 | m_panel_active_background_gradient_colour, wxSOUTH); | |
1800 | } | |
1801 | else if(wnd->IsHovered()) | |
1802 | { | |
1803 | wxRect client_rect(true_rect); | |
1804 | client_rect.x++; | |
1805 | client_rect.width -= 2; | |
1806 | client_rect.y++; | |
1807 | client_rect.height -= 2; | |
1808 | DrawPartialPageBackground(dc, wnd, client_rect, true); | |
1809 | } | |
1810 | ||
1811 | wxRect preview; | |
1812 | DrawMinimisedPanelCommon(dc, wnd, true_rect, &preview); | |
1813 | ||
1814 | dc.SetBrush(m_panel_hover_label_background_brush); | |
1815 | dc.SetPen(*wxTRANSPARENT_PEN); | |
1816 | dc.DrawRectangle(preview.x + 1, preview.y + preview.height - 8, | |
1817 | preview.width - 2, 7); | |
1818 | ||
1819 | int mid_pos = rect.y + rect.height / 5 - preview.y; | |
1820 | if(mid_pos < 0 || mid_pos >= preview.height) | |
1821 | { | |
1822 | wxRect full_rect(preview); | |
1823 | full_rect.x += 1; | |
1824 | full_rect.y += 1; | |
1825 | full_rect.width -= 2; | |
1826 | full_rect.height -= 9; | |
1827 | if(mid_pos < 0) | |
1828 | { | |
1829 | dc.GradientFillLinear(full_rect, | |
1830 | m_page_hover_background_colour, | |
1831 | m_page_hover_background_gradient_colour, wxSOUTH); | |
1832 | } | |
1833 | else | |
1834 | { | |
1835 | dc.GradientFillLinear(full_rect, | |
1836 | m_page_hover_background_top_colour, | |
1837 | m_page_hover_background_top_gradient_colour, wxSOUTH); | |
1838 | } | |
1839 | } | |
1840 | else | |
1841 | { | |
1842 | wxRect top_rect(preview); | |
1843 | top_rect.x += 1; | |
1844 | top_rect.y += 1; | |
1845 | top_rect.width -= 2; | |
1846 | top_rect.height = mid_pos; | |
1847 | dc.GradientFillLinear(top_rect, | |
1848 | m_page_hover_background_top_colour, | |
1849 | m_page_hover_background_top_gradient_colour, wxSOUTH); | |
1850 | ||
1851 | wxRect btm_rect(top_rect); | |
1852 | btm_rect.y = preview.y + mid_pos; | |
1853 | btm_rect.height = preview.y + preview.height - 7 - btm_rect.y; | |
1854 | dc.GradientFillLinear(btm_rect, | |
1855 | m_page_hover_background_colour, | |
1856 | m_page_hover_background_gradient_colour, wxSOUTH); | |
1857 | } | |
1858 | ||
1859 | if(bitmap.IsOk()) | |
1860 | { | |
1861 | dc.DrawBitmap(bitmap, preview.x + (preview.width - bitmap.GetWidth()) / 2, | |
1862 | preview.y + (preview.height - 7 - bitmap.GetHeight()) / 2, true); | |
1863 | } | |
1864 | ||
1865 | DrawPanelBorder(dc, preview, m_panel_border_pen, m_panel_border_gradient_pen); | |
1866 | ||
1867 | DrawPanelBorder(dc, true_rect, m_panel_minimised_border_pen, | |
1868 | m_panel_minimised_border_gradient_pen); | |
1869 | } | |
1870 | ||
1871 | void wxRibbonMSWArtProvider::DrawMinimisedPanelCommon( | |
1872 | wxDC& dc, | |
1873 | wxRibbonPanel* wnd, | |
1874 | const wxRect& true_rect, | |
1875 | wxRect* preview_rect) | |
1876 | { | |
1877 | wxRect preview(0, 0, 32, 32); | |
1878 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
1879 | { | |
1880 | preview.x = true_rect.x + 4; | |
1881 | preview.y = true_rect.y + (true_rect.height - preview.height) / 2; | |
1882 | } | |
1883 | else | |
1884 | { | |
1885 | preview.x = true_rect.x + (true_rect.width - preview.width) / 2; | |
1886 | preview.y = true_rect.y + 4; | |
1887 | } | |
1888 | if(preview_rect) | |
1889 | *preview_rect = preview; | |
1890 | ||
1891 | wxCoord label_width, label_height; | |
1892 | dc.SetFont(m_panel_label_font); | |
1893 | dc.GetTextExtent(wnd->GetLabel(), &label_width, &label_height); | |
1894 | ||
1895 | int xpos = true_rect.x + (true_rect.width - label_width + 1) / 2; | |
1896 | int ypos = preview.y + preview.height + 5; | |
1897 | ||
1898 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
1899 | { | |
1900 | xpos = preview.x + preview.width + 5; | |
1901 | ypos = true_rect.y + (true_rect.height - label_height) / 2; | |
1902 | } | |
1903 | ||
1904 | dc.SetTextForeground(m_panel_minimised_label_colour); | |
1905 | dc.DrawText(wnd->GetLabel(), xpos, ypos); | |
1906 | ||
1907 | ||
1908 | wxPoint arrow_points[3]; | |
1909 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
1910 | { | |
1911 | xpos += label_width; | |
1912 | arrow_points[0] = wxPoint(xpos + 5, ypos + label_height / 2); | |
1913 | arrow_points[1] = arrow_points[0] + wxPoint(-3, 3); | |
1914 | arrow_points[2] = arrow_points[0] + wxPoint(-3, -3); | |
1915 | } | |
1916 | else | |
1917 | { | |
1918 | ypos += label_height; | |
1919 | arrow_points[0] = wxPoint(true_rect.width / 2, ypos + 5); | |
1920 | arrow_points[1] = arrow_points[0] + wxPoint(-3, -3); | |
1921 | arrow_points[2] = arrow_points[0] + wxPoint( 3, -3); | |
1922 | } | |
1923 | ||
1924 | dc.SetPen(*wxTRANSPARENT_PEN); | |
1925 | wxBrush B(m_panel_minimised_label_colour); | |
1926 | dc.SetBrush(B); | |
1927 | dc.DrawPolygon(sizeof(arrow_points)/sizeof(wxPoint), arrow_points, | |
1928 | true_rect.x, true_rect.y); | |
1929 | } | |
1930 | ||
1931 | void wxRibbonMSWArtProvider::DrawButtonBarBackground( | |
1932 | wxDC& dc, | |
1933 | wxWindow* wnd, | |
1934 | const wxRect& rect) | |
1935 | { | |
1936 | DrawPartialPageBackground(dc, wnd, rect, true); | |
1937 | } | |
1938 | ||
1939 | void wxRibbonMSWArtProvider::DrawPartialPageBackground( | |
1940 | wxDC& dc, | |
1941 | wxWindow* wnd, | |
1942 | const wxRect& rect, | |
1943 | bool allow_hovered) | |
1944 | { | |
1945 | // Assume the window is a child of a ribbon page, and also check for a | |
1946 | // hovered panel somewhere between the window and the page, as it causes | |
1947 | // the background to change. | |
1948 | wxPoint offset(wnd->GetPosition()); | |
1949 | wxRibbonPage* page = NULL; | |
1950 | wxWindow* parent = wnd->GetParent(); | |
00491f99 | 1951 | wxRibbonPanel* panel = wxDynamicCast(wnd, wxRibbonPanel); |
3c3ead1d PC |
1952 | bool hovered = false; |
1953 | ||
3c3ead1d PC |
1954 | if(panel != NULL) |
1955 | { | |
1956 | hovered = allow_hovered && panel->IsHovered(); | |
1957 | if(panel->GetExpandedDummy() != NULL) | |
1958 | { | |
1959 | offset = panel->GetExpandedDummy()->GetPosition(); | |
1960 | parent = panel->GetExpandedDummy()->GetParent(); | |
1961 | } | |
1962 | } | |
1963 | for(; parent; parent = parent->GetParent()) | |
1964 | { | |
1965 | if(panel == NULL) | |
1966 | { | |
1967 | panel = wxDynamicCast(parent, wxRibbonPanel); | |
1968 | if(panel != NULL) | |
1969 | { | |
1970 | hovered = allow_hovered && panel->IsHovered(); | |
1971 | if(panel->GetExpandedDummy() != NULL) | |
1972 | { | |
1973 | parent = panel->GetExpandedDummy(); | |
1974 | } | |
1975 | } | |
1976 | } | |
1977 | page = wxDynamicCast(parent, wxRibbonPage); | |
1978 | if(page != NULL) | |
1979 | { | |
1980 | break; | |
1981 | } | |
1982 | offset += parent->GetPosition(); | |
1983 | } | |
1984 | if(page != NULL) | |
1985 | { | |
1986 | DrawPartialPageBackground(dc, wnd, rect, page, offset, hovered); | |
1987 | return; | |
1988 | } | |
1989 | ||
1990 | // No page found - fallback to painting with a stock brush | |
1991 | dc.SetBrush(*wxWHITE_BRUSH); | |
1992 | dc.SetPen(*wxTRANSPARENT_PEN); | |
1993 | dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height); | |
1994 | } | |
1995 | ||
1996 | void wxRibbonMSWArtProvider::DrawButtonBarButton( | |
1997 | wxDC& dc, | |
1998 | wxWindow* WXUNUSED(wnd), | |
1999 | const wxRect& rect, | |
2000 | wxRibbonButtonKind kind, | |
2001 | long state, | |
2002 | const wxString& label, | |
2003 | const wxBitmap& bitmap_large, | |
2004 | const wxBitmap& bitmap_small) | |
2005 | { | |
2006 | if(state & (wxRIBBON_BUTTONBAR_BUTTON_HOVER_MASK | | |
2007 | wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK)) | |
2008 | { | |
2009 | if(state & wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK) | |
2010 | dc.SetPen(m_button_bar_active_border_pen); | |
2011 | else | |
2012 | dc.SetPen(m_button_bar_hover_border_pen); | |
2013 | ||
2014 | wxRect bg_rect(rect); | |
2015 | bg_rect.x++; | |
2016 | bg_rect.y++; | |
2017 | bg_rect.width -= 2; | |
2018 | bg_rect.height -= 2; | |
2019 | ||
2020 | wxRect bg_rect_top(bg_rect); | |
2021 | bg_rect_top.height /= 3; | |
2022 | bg_rect.y += bg_rect_top.height; | |
2023 | bg_rect.height -= bg_rect_top.height; | |
2024 | ||
2025 | if(kind == wxRIBBON_BUTTON_HYBRID) | |
2026 | { | |
2027 | switch(state & wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK) | |
2028 | { | |
2029 | case wxRIBBON_BUTTONBAR_BUTTON_LARGE: | |
2030 | { | |
2031 | int iYBorder = rect.y + bitmap_large.GetHeight() + 4; | |
2032 | wxRect partial_bg(rect); | |
2033 | if(state & wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED) | |
2034 | { | |
2035 | partial_bg.SetBottom(iYBorder - 1); | |
2036 | } | |
2037 | else | |
2038 | { | |
2039 | partial_bg.height -= (iYBorder - partial_bg.y + 1); | |
2040 | partial_bg.y = iYBorder + 1; | |
2041 | } | |
2042 | dc.DrawLine(rect.x, iYBorder, rect.x + rect.width, iYBorder); | |
2043 | bg_rect.Intersect(partial_bg); | |
2044 | bg_rect_top.Intersect(partial_bg); | |
2045 | } | |
2046 | break; | |
2047 | case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM: | |
2048 | { | |
2049 | int iArrowWidth = 9; | |
2050 | if(state & wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED) | |
2051 | { | |
2052 | bg_rect.width -= iArrowWidth; | |
2053 | bg_rect_top.width -= iArrowWidth; | |
2054 | dc.DrawLine(bg_rect_top.x + bg_rect_top.width, | |
2055 | rect.y, bg_rect_top.x + bg_rect_top.width, | |
2056 | rect.y + rect.height); | |
2057 | } | |
2058 | else | |
2059 | { | |
2060 | --iArrowWidth; | |
2061 | bg_rect.x += bg_rect.width - iArrowWidth; | |
2062 | bg_rect_top.x += bg_rect_top.width - iArrowWidth; | |
2063 | bg_rect.width = iArrowWidth; | |
2064 | bg_rect_top.width = iArrowWidth; | |
2065 | dc.DrawLine(bg_rect_top.x - 1, rect.y, | |
2066 | bg_rect_top.x - 1, rect.y + rect.height); | |
2067 | } | |
2068 | } | |
2069 | break; | |
2070 | case wxRIBBON_BUTTONBAR_BUTTON_SMALL: | |
2071 | break; | |
2072 | } | |
2073 | } | |
2074 | ||
2075 | if(state & wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK) | |
2076 | { | |
2077 | dc.GradientFillLinear(bg_rect_top, | |
2078 | m_button_bar_active_background_top_colour, | |
2079 | m_button_bar_active_background_top_gradient_colour, wxSOUTH); | |
2080 | dc.GradientFillLinear(bg_rect, | |
2081 | m_button_bar_active_background_colour, | |
2082 | m_button_bar_active_background_gradient_colour, wxSOUTH); | |
2083 | } | |
2084 | else | |
2085 | { | |
2086 | dc.GradientFillLinear(bg_rect_top, | |
2087 | m_button_bar_hover_background_top_colour, | |
2088 | m_button_bar_hover_background_top_gradient_colour, wxSOUTH); | |
2089 | dc.GradientFillLinear(bg_rect, | |
2090 | m_button_bar_hover_background_colour, | |
2091 | m_button_bar_hover_background_gradient_colour, wxSOUTH); | |
2092 | } | |
2093 | ||
2094 | wxPoint border_points[9]; | |
2095 | border_points[0] = wxPoint(2, 0); | |
2096 | border_points[1] = wxPoint(rect.width - 3, 0); | |
2097 | border_points[2] = wxPoint(rect.width - 1, 2); | |
2098 | border_points[3] = wxPoint(rect.width - 1, rect.height - 3); | |
2099 | border_points[4] = wxPoint(rect.width - 3, rect.height - 1); | |
2100 | border_points[5] = wxPoint(2, rect.height - 1); | |
2101 | border_points[6] = wxPoint(0, rect.height - 3); | |
2102 | border_points[7] = wxPoint(0, 2); | |
2103 | border_points[8] = border_points[0]; | |
2104 | ||
2105 | dc.DrawLines(sizeof(border_points)/sizeof(wxPoint), border_points, | |
2106 | rect.x, rect.y); | |
2107 | } | |
2108 | ||
2109 | dc.SetFont(m_button_bar_label_font); | |
2110 | dc.SetTextForeground(m_button_bar_label_colour); | |
2111 | DrawButtonBarButtonForeground(dc, rect, kind, state, label, bitmap_large, | |
2112 | bitmap_small); | |
2113 | } | |
2114 | ||
2115 | void wxRibbonMSWArtProvider::DrawButtonBarButtonForeground( | |
2116 | wxDC& dc, | |
2117 | const wxRect& rect, | |
2118 | wxRibbonButtonKind kind, | |
2119 | long state, | |
2120 | const wxString& label, | |
2121 | const wxBitmap& bitmap_large, | |
2122 | const wxBitmap& bitmap_small) | |
2123 | { | |
2124 | switch(state & wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK) | |
2125 | { | |
2126 | case wxRIBBON_BUTTONBAR_BUTTON_LARGE: | |
2127 | { | |
2128 | const int padding = 2; | |
2129 | dc.DrawBitmap(bitmap_large, | |
2130 | rect.x + (rect.width - bitmap_large.GetWidth()) / 2, | |
2131 | rect.y + padding, true); | |
2132 | int ypos = rect.y + padding + bitmap_large.GetHeight() + padding; | |
2133 | int arrow_width = kind == wxRIBBON_BUTTON_NORMAL ? 0 : 8; | |
2134 | wxCoord label_w, label_h; | |
2135 | dc.GetTextExtent(label, &label_w, &label_h); | |
2136 | if(label_w + 2 * padding <= rect.width) | |
2137 | { | |
2138 | dc.DrawText(label, rect.x + (rect.width - label_w) / 2, ypos); | |
2139 | if(arrow_width != 0) | |
2140 | { | |
2141 | DrawDropdownArrow(dc, rect.x + rect.width / 2, | |
2142 | ypos + (label_h * 3) / 2, | |
2143 | m_button_bar_label_colour); | |
2144 | } | |
2145 | } | |
2146 | else | |
2147 | { | |
2148 | size_t breaki = label.Len(); | |
2149 | do | |
2150 | { | |
2151 | --breaki; | |
2152 | if(wxRibbonCanLabelBreakAtPosition(label, breaki)) | |
2153 | { | |
2154 | wxString label_top = label.Mid(0, breaki); | |
2155 | dc.GetTextExtent(label_top, &label_w, &label_h); | |
2156 | if(label_w + 2 * padding <= rect.width) | |
2157 | { | |
2158 | dc.DrawText(label_top, | |
2159 | rect.x + (rect.width - label_w) / 2, ypos); | |
2160 | ypos += label_h; | |
2161 | wxString label_bottom = label.Mid(breaki + 1); | |
2162 | dc.GetTextExtent(label_bottom, &label_w, &label_h); | |
2163 | label_w += arrow_width; | |
2164 | int iX = rect.x + (rect.width - label_w) / 2; | |
2165 | dc.DrawText(label_bottom, iX, ypos); | |
2166 | if(arrow_width != 0) | |
2167 | { | |
2168 | DrawDropdownArrow(dc, | |
2169 | iX + 2 +label_w - arrow_width, | |
2170 | ypos + label_h / 2 + 1, | |
2171 | m_button_bar_label_colour); | |
2172 | } | |
2173 | break; | |
2174 | } | |
2175 | } | |
2176 | } while(breaki > 0); | |
2177 | } | |
2178 | } | |
2179 | break; | |
2180 | case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM: | |
2181 | { | |
2182 | int x_cursor = rect.x + 2; | |
2183 | dc.DrawBitmap(bitmap_small, x_cursor, | |
2184 | rect.y + (rect.height - bitmap_small.GetHeight())/2, true); | |
2185 | x_cursor += bitmap_small.GetWidth() + 2; | |
2186 | wxCoord label_w, label_h; | |
2187 | dc.GetTextExtent(label, &label_w, &label_h); | |
2188 | dc.DrawText(label, x_cursor, | |
2189 | rect.y + (rect.height - label_h) / 2); | |
2190 | x_cursor += label_w + 3; | |
2191 | if(kind != wxRIBBON_BUTTON_NORMAL) | |
2192 | { | |
2193 | DrawDropdownArrow(dc, x_cursor, rect.y + rect.height / 2, | |
2194 | m_button_bar_label_colour); | |
2195 | } | |
2196 | break; | |
2197 | } | |
2198 | default: | |
2199 | // TODO | |
2200 | break; | |
2201 | } | |
2202 | } | |
2203 | ||
2204 | void wxRibbonMSWArtProvider::DrawToolBarBackground( | |
2205 | wxDC& dc, | |
2206 | wxWindow* wnd, | |
2207 | const wxRect& rect) | |
2208 | { | |
2209 | DrawPartialPageBackground(dc, wnd, rect); | |
2210 | } | |
2211 | ||
2212 | void wxRibbonMSWArtProvider::DrawToolGroupBackground( | |
2213 | wxDC& dc, | |
2214 | wxWindow* WXUNUSED(wnd), | |
2215 | const wxRect& rect) | |
2216 | { | |
2217 | dc.SetPen(m_toolbar_border_pen); | |
2218 | wxPoint outline[9]; | |
2219 | outline[0] = wxPoint(2, 0); | |
2220 | outline[1] = wxPoint(rect.width - 3, 0); | |
2221 | outline[2] = wxPoint(rect.width - 1, 2); | |
2222 | outline[3] = wxPoint(rect.width - 1, rect.height - 3); | |
2223 | outline[4] = wxPoint(rect.width - 3, rect.height - 1); | |
2224 | outline[5] = wxPoint(2, rect.height - 1); | |
2225 | outline[6] = wxPoint(0, rect.height - 3); | |
2226 | outline[7] = wxPoint(0, 2); | |
2227 | outline[8] = outline[0]; | |
2228 | ||
2229 | dc.DrawLines(sizeof(outline)/sizeof(wxPoint), outline, rect.x, rect.y); | |
2230 | } | |
2231 | ||
2232 | void wxRibbonMSWArtProvider::DrawTool( | |
2233 | wxDC& dc, | |
2234 | wxWindow* WXUNUSED(wnd), | |
2235 | const wxRect& rect, | |
2236 | const wxBitmap& bitmap, | |
2237 | wxRibbonButtonKind kind, | |
2238 | long state) | |
2239 | { | |
2240 | wxRect bg_rect(rect); | |
2241 | bg_rect.Deflate(1); | |
2242 | if((state & wxRIBBON_TOOLBAR_TOOL_LAST) == 0) | |
2243 | bg_rect.width++; | |
2244 | bool is_split_hybrid = (kind == wxRIBBON_BUTTON_HYBRID && (state & | |
2245 | (wxRIBBON_TOOLBAR_TOOL_HOVER_MASK | wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK))); | |
2246 | ||
2247 | // Background | |
2248 | wxRect bg_rect_top(bg_rect); | |
2249 | bg_rect_top.height = (bg_rect_top.height * 2) / 5; | |
2250 | wxRect bg_rect_btm(bg_rect); | |
2251 | bg_rect_btm.y += bg_rect_top.height; | |
2252 | bg_rect_btm.height -= bg_rect_top.height; | |
2253 | wxColour bg_top_colour = m_tool_background_top_colour; | |
2254 | wxColour bg_top_grad_colour = m_tool_background_top_gradient_colour; | |
2255 | wxColour bg_colour = m_tool_background_colour; | |
2256 | wxColour bg_grad_colour = m_tool_background_gradient_colour; | |
2257 | if(state & wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK) | |
2258 | { | |
2259 | bg_top_colour = m_tool_active_background_top_colour; | |
2260 | bg_top_grad_colour = m_tool_active_background_top_gradient_colour; | |
2261 | bg_colour = m_tool_active_background_colour; | |
2262 | bg_grad_colour = m_tool_active_background_gradient_colour; | |
2263 | } | |
2264 | else if(state & wxRIBBON_TOOLBAR_TOOL_HOVER_MASK) | |
2265 | { | |
2266 | bg_top_colour = m_tool_hover_background_top_colour; | |
2267 | bg_top_grad_colour = m_tool_hover_background_top_gradient_colour; | |
2268 | bg_colour = m_tool_hover_background_colour; | |
2269 | bg_grad_colour = m_tool_hover_background_gradient_colour; | |
2270 | } | |
2271 | dc.GradientFillLinear(bg_rect_top, bg_top_colour, bg_top_grad_colour, wxSOUTH); | |
2272 | dc.GradientFillLinear(bg_rect_btm, bg_colour, bg_grad_colour, wxSOUTH); | |
2273 | if(is_split_hybrid) | |
2274 | { | |
2275 | wxRect nonrect(bg_rect); | |
2276 | if(state & (wxRIBBON_TOOLBAR_TOOL_DROPDOWN_HOVERED | | |
2277 | wxRIBBON_TOOLBAR_TOOL_DROPDOWN_ACTIVE)) | |
2278 | { | |
2279 | nonrect.width -= 8; | |
2280 | } | |
2281 | else | |
2282 | { | |
2283 | nonrect.x += nonrect.width - 8; | |
2284 | nonrect.width = 8; | |
2285 | } | |
2286 | wxBrush B(m_tool_hover_background_top_colour); | |
2287 | dc.SetPen(*wxTRANSPARENT_PEN); | |
2288 | dc.SetBrush(B); | |
2289 | dc.DrawRectangle(nonrect.x, nonrect.y, nonrect.width, nonrect.height); | |
2290 | } | |
2291 | ||
2292 | // Border | |
2293 | dc.SetPen(m_toolbar_border_pen); | |
2294 | if(state & wxRIBBON_TOOLBAR_TOOL_FIRST) | |
2295 | { | |
2296 | dc.DrawPoint(rect.x + 1, rect.y + 1); | |
2297 | dc.DrawPoint(rect.x + 1, rect.y + rect.height - 2); | |
2298 | } | |
2299 | else | |
2300 | dc.DrawLine(rect.x, rect.y + 1, rect.x, rect.y + rect.height - 1); | |
2301 | ||
2302 | if(state & wxRIBBON_TOOLBAR_TOOL_LAST) | |
2303 | { | |
2304 | dc.DrawPoint(rect.x + rect.width - 2, rect.y + 1); | |
2305 | dc.DrawPoint(rect.x + rect.width - 2, rect.y + rect.height - 2); | |
2306 | } | |
2307 | ||
2308 | // Foreground | |
2309 | int avail_width = bg_rect.GetWidth(); | |
2310 | if(kind != wxRIBBON_BUTTON_NORMAL) | |
2311 | { | |
2312 | avail_width -= 8; | |
2313 | if(is_split_hybrid) | |
2314 | { | |
2315 | dc.DrawLine(rect.x + avail_width + 1, rect.y, | |
2316 | rect.x + avail_width + 1, rect.y + rect.height); | |
2317 | } | |
2318 | dc.DrawBitmap(m_toolbar_drop_bitmap, bg_rect.x + avail_width + 2, | |
2319 | bg_rect.y + (bg_rect.height / 2) - 2, true); | |
2320 | } | |
2321 | dc.DrawBitmap(bitmap, bg_rect.x + (avail_width - bitmap.GetWidth()) / 2, | |
2322 | bg_rect.y + (bg_rect.height - bitmap.GetHeight()) / 2, true); | |
2323 | } | |
2324 | ||
2325 | void wxRibbonMSWArtProvider::GetBarTabWidth( | |
2326 | wxDC& dc, | |
2327 | wxWindow* WXUNUSED(wnd), | |
2328 | const wxString& label, | |
2329 | const wxBitmap& bitmap, | |
2330 | int* ideal, | |
2331 | int* small_begin_need_separator, | |
2332 | int* small_must_have_separator, | |
2333 | int* minimum) | |
2334 | { | |
2335 | int width = 0; | |
2336 | int min = 0; | |
2337 | if((m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) && !label.IsEmpty()) | |
2338 | { | |
2339 | dc.SetFont(m_tab_label_font); | |
2340 | width += dc.GetTextExtent(label).GetWidth(); | |
2341 | min += wxMin(25, width); // enough for a few chars | |
2342 | if(bitmap.IsOk()) | |
2343 | { | |
2344 | // gap between label and bitmap | |
2345 | width += 4; | |
2346 | min += 2; | |
2347 | } | |
2348 | } | |
2349 | if((m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS) && bitmap.IsOk()) | |
2350 | { | |
2351 | width += bitmap.GetWidth(); | |
2352 | min += bitmap.GetWidth(); | |
2353 | } | |
2354 | ||
2355 | if(ideal != NULL) | |
2356 | { | |
2357 | *ideal = width + 30; | |
2358 | } | |
2359 | if(small_begin_need_separator != NULL) | |
2360 | { | |
2361 | *small_begin_need_separator = width + 20; | |
2362 | } | |
2363 | if(small_must_have_separator != NULL) | |
2364 | { | |
2365 | *small_must_have_separator = width + 10; | |
2366 | } | |
2367 | if(minimum != NULL) | |
2368 | { | |
2369 | *minimum = min; | |
2370 | } | |
2371 | } | |
2372 | ||
2373 | int wxRibbonMSWArtProvider::GetTabCtrlHeight( | |
2374 | wxDC& dc, | |
2375 | wxWindow* WXUNUSED(wnd), | |
2376 | const wxRibbonPageTabInfoArray& pages) | |
2377 | { | |
2378 | int text_height = 0; | |
2379 | int icon_height = 0; | |
2380 | ||
2381 | if(pages.GetCount() <= 1 && (m_flags & wxRIBBON_BAR_ALWAYS_SHOW_TABS) == 0) | |
2382 | { | |
2383 | // To preserve space, a single tab need not be displayed. We still need | |
2384 | // two pixels of border / padding though. | |
2385 | return 2; | |
2386 | } | |
2387 | ||
2388 | if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) | |
2389 | { | |
2390 | dc.SetFont(m_tab_label_font); | |
2391 | text_height = dc.GetTextExtent(wxT("ABCDEFXj")).GetHeight() + 10; | |
2392 | } | |
2393 | if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS) | |
2394 | { | |
2395 | size_t numpages = pages.GetCount(); | |
2396 | for(size_t i = 0; i < numpages; ++i) | |
2397 | { | |
2398 | const wxRibbonPageTabInfo& info = pages.Item(i); | |
2399 | if(info.page->GetIcon().IsOk()) | |
2400 | { | |
2401 | icon_height = wxMax(icon_height, info.page->GetIcon().GetHeight() + 4); | |
2402 | } | |
2403 | } | |
2404 | } | |
2405 | ||
2406 | return wxMax(text_height, icon_height); | |
2407 | } | |
2408 | ||
2409 | wxSize wxRibbonMSWArtProvider::GetScrollButtonMinimumSize( | |
2410 | wxDC& WXUNUSED(dc), | |
2411 | wxWindow* WXUNUSED(wnd), | |
2412 | long WXUNUSED(style)) | |
2413 | { | |
2414 | return wxSize(12, 12); | |
2415 | } | |
2416 | ||
2417 | wxSize wxRibbonMSWArtProvider::GetPanelSize( | |
2418 | wxDC& dc, | |
2419 | const wxRibbonPanel* wnd, | |
2420 | wxSize client_size, | |
2421 | wxPoint* client_offset) | |
2422 | { | |
2423 | dc.SetFont(m_panel_label_font); | |
2424 | wxSize label_size = dc.GetTextExtent(wnd->GetLabel()); | |
2425 | ||
2426 | client_size.IncBy(0, label_size.GetHeight()); | |
2427 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
2428 | client_size.IncBy(4, 8); | |
2429 | else | |
2430 | client_size.IncBy(6, 6); | |
2431 | ||
2432 | if(client_offset != NULL) | |
2433 | { | |
2434 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
2435 | *client_offset = wxPoint(2, 3); | |
2436 | else | |
2437 | *client_offset = wxPoint(3, 2); | |
2438 | } | |
2439 | ||
2440 | return client_size; | |
2441 | } | |
2442 | ||
2443 | wxSize wxRibbonMSWArtProvider::GetPanelClientSize( | |
2444 | wxDC& dc, | |
2445 | const wxRibbonPanel* wnd, | |
2446 | wxSize size, | |
2447 | wxPoint* client_offset) | |
2448 | { | |
2449 | dc.SetFont(m_panel_label_font); | |
2450 | wxSize label_size = dc.GetTextExtent(wnd->GetLabel()); | |
2451 | ||
2452 | size.DecBy(0, label_size.GetHeight()); | |
2453 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
2454 | size.DecBy(4, 8); | |
2455 | else | |
2456 | size.DecBy(6, 6); | |
2457 | ||
2458 | if(client_offset != NULL) | |
2459 | { | |
2460 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
2461 | *client_offset = wxPoint(2, 3); | |
2462 | else | |
2463 | *client_offset = wxPoint(3, 2); | |
2464 | } | |
16eac072 PC |
2465 | if (size.x < 0) size.x = 0; |
2466 | if (size.y < 0) size.y = 0; | |
3c3ead1d PC |
2467 | |
2468 | return size; | |
2469 | } | |
2470 | ||
2471 | wxSize wxRibbonMSWArtProvider::GetGallerySize( | |
2472 | wxDC& WXUNUSED(dc), | |
2473 | const wxRibbonGallery* WXUNUSED(wnd), | |
2474 | wxSize client_size) | |
2475 | { | |
2476 | client_size.IncBy( 2, 1); // Left / top padding | |
2477 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
2478 | client_size.IncBy(1, 16); // Right / bottom padding | |
2479 | else | |
2480 | client_size.IncBy(16, 1); // Right / bottom padding | |
2481 | return client_size; | |
2482 | } | |
2483 | ||
2484 | wxSize wxRibbonMSWArtProvider::GetGalleryClientSize( | |
2485 | wxDC& WXUNUSED(dc), | |
2486 | const wxRibbonGallery* WXUNUSED(wnd), | |
2487 | wxSize size, | |
2488 | wxPoint* client_offset, | |
2489 | wxRect* scroll_up_button, | |
2490 | wxRect* scroll_down_button, | |
2491 | wxRect* extension_button) | |
2492 | { | |
2493 | wxRect scroll_up; | |
2494 | wxRect scroll_down; | |
2495 | wxRect extension; | |
2496 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
2497 | { | |
2498 | // Flow is vertical - put buttons on bottom | |
2499 | scroll_up.y = size.GetHeight() - 15; | |
2500 | scroll_up.height = 15; | |
2501 | scroll_up.x = 0; | |
2502 | scroll_up.width = (size.GetWidth() + 2) / 3; | |
2503 | scroll_down.y = scroll_up.y; | |
2504 | scroll_down.height = scroll_up.height; | |
2505 | scroll_down.x = scroll_up.x + scroll_up.width; | |
2506 | scroll_down.width = scroll_up.width; | |
2507 | extension.y = scroll_down.y; | |
2508 | extension.height = scroll_down.height; | |
2509 | extension.x = scroll_down.x + scroll_down.width; | |
2510 | extension.width = size.GetWidth() - scroll_up.width - scroll_down.width; | |
2511 | size.DecBy(1, 16); | |
2512 | size.DecBy( 2, 1); | |
2513 | } | |
2514 | else | |
2515 | { | |
2516 | // Flow is horizontal - put buttons on right | |
2517 | scroll_up.x = size.GetWidth() - 15; | |
2518 | scroll_up.width = 15; | |
2519 | scroll_up.y = 0; | |
2520 | scroll_up.height = (size.GetHeight() + 2) / 3; | |
2521 | scroll_down.x = scroll_up.x; | |
2522 | scroll_down.width = scroll_up.width; | |
2523 | scroll_down.y = scroll_up.y + scroll_up.height; | |
2524 | scroll_down.height = scroll_up.height; | |
2525 | extension.x = scroll_down.x; | |
2526 | extension.width = scroll_down.width; | |
2527 | extension.y = scroll_down.y + scroll_down.height; | |
2528 | extension.height = size.GetHeight() - scroll_up.height - scroll_down.height; | |
2529 | size.DecBy(16, 1); | |
2530 | size.DecBy( 2, 1); | |
2531 | } | |
2532 | ||
2533 | if(client_offset != NULL) | |
2534 | *client_offset = wxPoint(2, 1); | |
2535 | if(scroll_up_button != NULL) | |
2536 | *scroll_up_button = scroll_up; | |
2537 | if(scroll_down_button != NULL) | |
2538 | *scroll_down_button = scroll_down; | |
2539 | if(extension_button != NULL) | |
2540 | *extension_button = extension; | |
2541 | ||
2542 | return size; | |
2543 | } | |
2544 | ||
2545 | wxRect wxRibbonMSWArtProvider::GetPageBackgroundRedrawArea( | |
2546 | wxDC& WXUNUSED(dc), | |
2547 | const wxRibbonPage* WXUNUSED(wnd), | |
2548 | wxSize page_old_size, | |
2549 | wxSize page_new_size) | |
2550 | { | |
2551 | wxRect new_rect, old_rect; | |
2552 | ||
2553 | if(page_new_size.GetWidth() != page_old_size.GetWidth()) | |
2554 | { | |
2555 | if(page_new_size.GetHeight() != page_old_size.GetHeight()) | |
2556 | { | |
2557 | // Width and height both changed - redraw everything | |
2558 | return wxRect(page_new_size); | |
2559 | } | |
2560 | else | |
2561 | { | |
2562 | // Only width changed - redraw right hand side | |
2563 | const int right_edge_width = 4; | |
2564 | ||
2565 | new_rect = wxRect(page_new_size.GetWidth() - right_edge_width, 0, right_edge_width, page_new_size.GetHeight()); | |
2566 | old_rect = wxRect(page_old_size.GetWidth() - right_edge_width, 0, right_edge_width, page_old_size.GetHeight()); | |
2567 | } | |
2568 | } | |
2569 | else | |
2570 | { | |
2571 | if(page_new_size.GetHeight() == page_old_size.GetHeight()) | |
2572 | { | |
2573 | // Nothing changed (should never happen) - redraw nothing | |
2574 | return wxRect(0, 0, 0, 0); | |
2575 | } | |
2576 | else | |
2577 | { | |
2578 | // Height changed - need to redraw everything (as the background | |
2579 | // gradient is done vertically). | |
2580 | return page_new_size; | |
2581 | } | |
2582 | } | |
2583 | ||
2584 | new_rect.Union(old_rect); | |
2585 | new_rect.Intersect(wxRect(page_new_size)); | |
2586 | return new_rect; | |
2587 | } | |
2588 | ||
2589 | bool wxRibbonMSWArtProvider::GetButtonBarButtonSize( | |
2590 | wxDC& dc, | |
2591 | wxWindow* wnd, | |
2592 | wxRibbonButtonKind kind, | |
2593 | wxRibbonButtonBarButtonState size, | |
2594 | const wxString& label, | |
2595 | wxSize bitmap_size_large, | |
2596 | wxSize bitmap_size_small, | |
2597 | wxSize* button_size, | |
2598 | wxRect* normal_region, | |
2599 | wxRect* dropdown_region) | |
2600 | { | |
2601 | const int drop_button_width = 8; | |
2602 | ||
2603 | dc.SetFont(m_button_bar_label_font); | |
2604 | switch(size & wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK) | |
2605 | { | |
2606 | case wxRIBBON_BUTTONBAR_BUTTON_SMALL: | |
2607 | // Small bitmap, no label | |
2608 | *button_size = bitmap_size_small + wxSize(6, 4); | |
2609 | switch(kind) | |
2610 | { | |
2611 | case wxRIBBON_BUTTON_NORMAL: | |
2612 | *normal_region = wxRect(*button_size); | |
2613 | *dropdown_region = wxRect(0, 0, 0, 0); | |
2614 | break; | |
2615 | case wxRIBBON_BUTTON_DROPDOWN: | |
2616 | *button_size += wxSize(drop_button_width, 0); | |
2617 | *dropdown_region = wxRect(*button_size); | |
2618 | *normal_region = wxRect(0, 0, 0, 0); | |
2619 | break; | |
2620 | case wxRIBBON_BUTTON_HYBRID: | |
2621 | *normal_region = wxRect(*button_size); | |
2622 | *dropdown_region = wxRect(button_size->GetWidth(), 0, | |
2623 | drop_button_width, button_size->GetHeight()); | |
2624 | *button_size += wxSize(drop_button_width, 0); | |
2625 | break; | |
2626 | } | |
2627 | break; | |
2628 | case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM: | |
2629 | // Small bitmap, with label to the right | |
2630 | { | |
2631 | GetButtonBarButtonSize(dc, wnd, kind, wxRIBBON_BUTTONBAR_BUTTON_SMALL, | |
2632 | label, bitmap_size_large, bitmap_size_small, button_size, | |
2633 | normal_region, dropdown_region); | |
2634 | int text_size = dc.GetTextExtent(label).GetWidth(); | |
2635 | button_size->SetWidth(button_size->GetWidth() + text_size); | |
2636 | switch(kind) | |
2637 | { | |
2638 | case wxRIBBON_BUTTON_DROPDOWN: | |
2639 | dropdown_region->SetWidth(dropdown_region->GetWidth() + text_size); | |
2640 | break; | |
2641 | case wxRIBBON_BUTTON_HYBRID: | |
2642 | dropdown_region->SetX(dropdown_region->GetX() + text_size); | |
2643 | // no break | |
2644 | case wxRIBBON_BUTTON_NORMAL: | |
2645 | normal_region->SetWidth(normal_region->GetWidth() + text_size); | |
2646 | break; | |
2647 | } | |
2648 | break; | |
2649 | } | |
2650 | case wxRIBBON_BUTTONBAR_BUTTON_LARGE: | |
2651 | // Large bitmap, with label below (possibly split over 2 lines) | |
2652 | { | |
2653 | wxSize icon_size(bitmap_size_large); | |
2654 | icon_size += wxSize(4, 4); | |
2655 | wxCoord label_height; | |
2656 | wxCoord best_width; | |
2657 | dc.GetTextExtent(label, &best_width, &label_height); | |
3c3ead1d PC |
2658 | int last_line_extra_width = 0; |
2659 | if(kind != wxRIBBON_BUTTON_NORMAL) | |
2660 | { | |
2661 | last_line_extra_width += 8; | |
3c3ead1d PC |
2662 | } |
2663 | size_t i; | |
2664 | for(i = 0; i < label.Len(); ++i) | |
2665 | { | |
2666 | if(wxRibbonCanLabelBreakAtPosition(label, i)) | |
2667 | { | |
2668 | int width = wxMax( | |
2669 | dc.GetTextExtent(label.Mid(0, i - 1)).GetWidth(), | |
2670 | dc.GetTextExtent(label.Mid(i + 1)).GetWidth() + last_line_extra_width); | |
2671 | if(width < best_width) | |
2672 | { | |
2673 | best_width = width; | |
3c3ead1d PC |
2674 | } |
2675 | } | |
2676 | } | |
2677 | label_height *= 2; // Assume two lines even when only one is used | |
2678 | // (to give all buttons a consistent height) | |
2679 | icon_size.SetWidth(wxMax(icon_size.GetWidth(), best_width) + 6); | |
2680 | icon_size.SetHeight(icon_size.GetHeight() + label_height); | |
2681 | *button_size = icon_size; | |
2682 | switch(kind) | |
2683 | { | |
2684 | case wxRIBBON_BUTTON_DROPDOWN: | |
2685 | *dropdown_region = wxRect(icon_size); | |
2686 | break; | |
2687 | case wxRIBBON_BUTTON_HYBRID: | |
2688 | *normal_region = wxRect(icon_size); | |
2689 | normal_region->height -= 2 + label_height; | |
2690 | dropdown_region->x = 0; | |
2691 | dropdown_region->y = normal_region->height; | |
2692 | dropdown_region->width = icon_size.GetWidth(); | |
2693 | dropdown_region->height = icon_size.GetHeight() - normal_region->height; | |
2694 | break; | |
2695 | case wxRIBBON_BUTTON_NORMAL: | |
2696 | *normal_region = wxRect(icon_size); | |
2697 | break; | |
2698 | } | |
2699 | break; | |
2700 | } | |
2701 | }; | |
2702 | return true; | |
2703 | } | |
2704 | ||
2705 | wxSize wxRibbonMSWArtProvider::GetMinimisedPanelMinimumSize( | |
2706 | wxDC& dc, | |
2707 | const wxRibbonPanel* wnd, | |
2708 | wxSize* desired_bitmap_size, | |
2709 | wxDirection* expanded_panel_direction) | |
2710 | { | |
2711 | if(desired_bitmap_size != NULL) | |
2712 | { | |
2713 | *desired_bitmap_size = wxSize(16, 16); | |
2714 | } | |
2715 | if(expanded_panel_direction != NULL) | |
2716 | { | |
2717 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
2718 | *expanded_panel_direction = wxEAST; | |
2719 | else | |
2720 | *expanded_panel_direction = wxSOUTH; | |
2721 | } | |
2722 | wxSize base_size(42, 42); | |
2723 | ||
2724 | dc.SetFont(m_panel_label_font); | |
2725 | wxSize label_size(dc.GetTextExtent(wnd->GetLabel())); | |
2726 | label_size.IncBy(2, 2); // Allow for differences between this DC and a paint DC | |
2727 | label_size.IncBy(6, 0); // Padding | |
2728 | label_size.y *= 2; // Second line for dropdown button | |
2729 | ||
2730 | if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) | |
2731 | { | |
2732 | // Label alongside icon | |
2733 | return wxSize(base_size.x + label_size.x, | |
2734 | wxMax(base_size.y, label_size.y)); | |
2735 | } | |
2736 | else | |
2737 | { | |
2738 | // Label beneath icon | |
2739 | return wxSize(wxMax(base_size.x, label_size.x), | |
2740 | base_size.y + label_size.y); | |
2741 | } | |
2742 | } | |
2743 | ||
2744 | wxSize wxRibbonMSWArtProvider::GetToolSize( | |
2745 | wxDC& WXUNUSED(dc), | |
2746 | wxWindow* WXUNUSED(wnd), | |
2747 | wxSize bitmap_size, | |
2748 | wxRibbonButtonKind kind, | |
2749 | bool WXUNUSED(is_first), | |
2750 | bool is_last, | |
2751 | wxRect* dropdown_region) | |
2752 | { | |
2753 | wxSize size(bitmap_size); | |
2754 | size.IncBy(7, 6); | |
2755 | if(is_last) | |
2756 | size.IncBy(1, 0); | |
2757 | if(kind != wxRIBBON_BUTTON_NORMAL) | |
2758 | { | |
2759 | size.IncBy(8, 0); | |
2760 | if(dropdown_region) | |
2761 | { | |
2762 | if(kind == wxRIBBON_BUTTON_DROPDOWN) | |
2763 | *dropdown_region = size; | |
2764 | else | |
2765 | *dropdown_region = wxRect(size.GetWidth() - 8, 0, 8, size.GetHeight()); | |
2766 | } | |
2767 | } | |
2768 | else | |
2769 | { | |
2770 | if(dropdown_region) | |
2771 | *dropdown_region = wxRect(0, 0, 0, 0); | |
2772 | } | |
2773 | return size; | |
2774 | } | |
2775 | ||
2776 | #endif // wxUSE_RIBBON |