1 |
|
|
/*************************************************************************** |
2 |
|
|
* Copyright (c) 2024 Microsoft Corporation |
3 |
|
|
* Copyright (c) 2026-present Eclipse ThreadX contributors |
4 |
|
|
* |
5 |
|
|
* This program and the accompanying materials are made available under the |
6 |
|
|
* terms of the MIT License which is available at |
7 |
|
|
* https://opensource.org/licenses/MIT. |
8 |
|
|
* |
9 |
|
|
* SPDX-License-Identifier: MIT |
10 |
|
|
**************************************************************************/ |
11 |
|
|
|
12 |
|
|
|
13 |
|
|
/**************************************************************************/ |
14 |
|
|
/**************************************************************************/ |
15 |
|
|
/** */ |
16 |
|
|
/** GUIX Component */ |
17 |
|
|
/** */ |
18 |
|
|
/** String Scroll Wheel Management (Scroll Wheel) */ |
19 |
|
|
/** */ |
20 |
|
|
/**************************************************************************/ |
21 |
|
|
|
22 |
|
|
#define GX_SOURCE_CODE |
23 |
|
|
|
24 |
|
|
|
25 |
|
|
/* Include necessary system files. */ |
26 |
|
|
|
27 |
|
|
#include "gx_api.h" |
28 |
|
|
#include "gx_system.h" |
29 |
|
|
#include "gx_window.h" |
30 |
|
|
#include "gx_widget.h" |
31 |
|
|
#include "gx_scroll_wheel.h" |
32 |
|
|
#include "gx_context.h" |
33 |
|
|
#include "gx_canvas.h" |
34 |
|
|
#include "gx_utility.h" |
35 |
|
|
|
36 |
|
|
/**************************************************************************/ |
37 |
|
|
/* */ |
38 |
|
|
/* FUNCTION RELEASE */ |
39 |
|
|
/* */ |
40 |
|
|
/* _gx_text_scroll_wheel_round_text_draw PORTABLE C */ |
41 |
|
|
/* 6.1.10 */ |
42 |
|
|
/* AUTHOR */ |
43 |
|
|
/* */ |
44 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
45 |
|
|
/* */ |
46 |
|
|
/* DESCRIPTION */ |
47 |
|
|
/* */ |
48 |
|
|
/* Internal helper function to draw text to specified area in rounded */ |
49 |
|
|
/* style. */ |
50 |
|
|
/* */ |
51 |
|
|
/* INPUT */ |
52 |
|
|
/* */ |
53 |
|
|
/* wheel Scroll wheel control block */ |
54 |
|
|
/* tColor Text color id */ |
55 |
|
|
/* font_id Font id */ |
56 |
|
|
/* string Text to be draw */ |
57 |
|
|
/* x_pos Draw start xpos */ |
58 |
|
|
/* y_pos Draw start ypos */ |
59 |
|
|
/* width Draw width */ |
60 |
|
|
/* height Draw height */ |
61 |
|
|
/* */ |
62 |
|
|
/* OUTPUT */ |
63 |
|
|
/* */ |
64 |
|
|
/* status Completion status */ |
65 |
|
|
/* */ |
66 |
|
|
/* CALLS */ |
67 |
|
|
/* */ |
68 |
|
|
/* _gx_context_line_color_set Set line color */ |
69 |
|
|
/* _gx_context_fill_color_set Set fill color */ |
70 |
|
|
/* _gx_context_font_set Set font */ |
71 |
|
|
/* _gx_context_brush_get Get brush */ |
72 |
|
|
/* _gx_system_string_width_get Get string width */ |
73 |
|
|
/* _gx_utility_string_to_alphamap Convert string to alphamap */ |
74 |
|
|
/* _gx_utility_pixelmap_resize Resize a pixelmap */ |
75 |
|
|
/* _gx_canvas_pixelmap_draw Draw pixelmap to canvas */ |
76 |
|
|
/* _gx_system_memory_free Application defined memory */ |
77 |
|
|
/* free function */ |
78 |
|
|
/* */ |
79 |
|
|
/* CALLED BY */ |
80 |
|
|
/* */ |
81 |
|
|
/* _gx_text_scroll_wheel_row_draw */ |
82 |
|
|
/* */ |
83 |
|
|
/**************************************************************************/ |
84 |
|
4015 |
static UINT _gx_text_scroll_wheel_round_text_draw(GX_TEXT_SCROLL_WHEEL *wheel, GX_RESOURCE_ID tColor, GX_RESOURCE_ID font_id, |
85 |
|
|
GX_CONST GX_STRING *string, GX_VALUE x_pos, GX_VALUE y_pos, GX_VALUE width, GX_VALUE height) |
86 |
|
|
{ |
87 |
|
4015 |
UINT status = GX_SUCCESS; |
88 |
|
4015 |
GX_VALUE text_width = 0; |
89 |
|
|
GX_VALUE text_height; |
90 |
|
|
GX_BRUSH *brush; |
91 |
|
|
GX_PIXELMAP textmap; |
92 |
|
|
GX_PIXELMAP resized_map; |
93 |
|
|
GX_COLOR old_fill_color; |
94 |
|
|
|
95 |
|
4015 |
_gx_context_line_color_set(tColor); |
96 |
|
4015 |
_gx_context_font_set(font_id); |
97 |
|
4015 |
_gx_context_brush_get(&brush); |
98 |
|
|
|
99 |
✓✓ |
4015 |
if (!brush -> gx_brush_font) |
100 |
|
|
{ |
101 |
|
98 |
return(GX_SUCCESS); |
102 |
|
|
} |
103 |
|
|
|
104 |
|
3917 |
text_height = brush -> gx_brush_font -> gx_font_line_height; |
105 |
|
|
|
106 |
✓✓ |
3917 |
if (wheel -> gx_scroll_wheel_row_height <= 0) |
107 |
|
|
{ |
108 |
|
1 |
return GX_FAILURE; |
109 |
|
|
} |
110 |
|
|
|
111 |
|
3916 |
text_height = (GX_VALUE)(text_height * height / wheel -> gx_scroll_wheel_row_height); |
112 |
|
|
|
113 |
|
3916 |
_gx_system_string_width_get_ext(brush -> gx_brush_font, string, &text_width); |
114 |
|
|
|
115 |
✓✓✓✓
|
3916 |
if (!text_height || !text_width) |
116 |
|
|
{ |
117 |
|
12 |
return(GX_SUCCESS); |
118 |
|
|
} |
119 |
|
|
|
120 |
|
3904 |
y_pos = (GX_VALUE)(y_pos + (height - text_height) / 2); |
121 |
|
|
|
122 |
✓✓✓ |
3904 |
switch (wheel -> gx_widget_style & GX_STYLE_TEXT_ALIGNMENT_MASK) |
123 |
|
|
{ |
124 |
|
16 |
case GX_STYLE_TEXT_RIGHT: |
125 |
|
16 |
x_pos = (GX_VALUE)(x_pos + width - 1); |
126 |
|
16 |
x_pos = (GX_VALUE)(x_pos - text_width); |
127 |
|
16 |
break; |
128 |
|
|
|
129 |
|
16 |
case GX_STYLE_TEXT_LEFT: |
130 |
|
16 |
break; |
131 |
|
|
|
132 |
|
3872 |
case GX_STYLE_TEXT_CENTER: |
133 |
|
|
default: |
134 |
|
3872 |
x_pos = (GX_VALUE)(x_pos + ((width - text_width) / 2)); |
135 |
|
3872 |
break; |
136 |
|
|
} |
137 |
|
|
|
138 |
|
3904 |
status = _gx_utility_string_to_alphamap_ext(string, brush -> gx_brush_font, &textmap); |
139 |
|
|
|
140 |
✓✓ |
3904 |
if (status == GX_SUCCESS) |
141 |
|
|
{ |
142 |
|
3885 |
status = _gx_utility_pixelmap_resize(&textmap, &resized_map, text_width, text_height); |
143 |
|
|
|
144 |
✓✓ |
3885 |
if (status == GX_SUCCESS) |
145 |
|
|
{ |
146 |
|
3883 |
old_fill_color = brush -> gx_brush_fill_color; |
147 |
|
3883 |
_gx_context_fill_color_set(tColor); |
148 |
|
|
#if defined(GX_RENESAS_DAVE2D_DRAW) |
149 |
|
|
resized_map.gx_pixelmap_flags |= GX_PIXELMAP_DYNAMICALLY_ALLOCATED; |
150 |
|
|
#endif |
151 |
|
3883 |
_gx_canvas_pixelmap_draw(x_pos, y_pos, &resized_map); |
152 |
|
3883 |
brush -> gx_brush_fill_color = old_fill_color; |
153 |
|
|
|
154 |
|
|
/* free the resized alphamap memory */ |
155 |
|
3883 |
_gx_system_memory_free((void *)resized_map.gx_pixelmap_data); |
156 |
|
|
} |
157 |
|
|
|
158 |
|
|
/* free the temporary canvas memory */ |
159 |
|
3885 |
_gx_system_memory_free((void *)(textmap.gx_pixelmap_data)); |
160 |
|
|
} |
161 |
|
|
|
162 |
|
3904 |
return status; |
163 |
|
|
} |
164 |
|
|
|
165 |
|
|
/**************************************************************************/ |
166 |
|
|
/* */ |
167 |
|
|
/* FUNCTION RELEASE */ |
168 |
|
|
/* */ |
169 |
|
|
/* _gx_text_scroll_wheel_flat_text_draw PORTABLE C */ |
170 |
|
|
/* 6.1.10 */ |
171 |
|
|
/* AUTHOR */ |
172 |
|
|
/* */ |
173 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
174 |
|
|
/* */ |
175 |
|
|
/* DESCRIPTION */ |
176 |
|
|
/* */ |
177 |
|
|
/* Internal helper function to draw text to specified area in normal */ |
178 |
|
|
/* style. */ |
179 |
|
|
/* */ |
180 |
|
|
/* INPUT */ |
181 |
|
|
/* */ |
182 |
|
|
/* wheel Scroll wheel control block */ |
183 |
|
|
/* tColor Text color id */ |
184 |
|
|
/* font_id Font id */ |
185 |
|
|
/* string Text to be draw */ |
186 |
|
|
/* x_pos Draw start xpos */ |
187 |
|
|
/* y_pos Draw start ypos */ |
188 |
|
|
/* width Draw width */ |
189 |
|
|
/* height Draw height */ |
190 |
|
|
/* */ |
191 |
|
|
/* OUTPUT */ |
192 |
|
|
/* */ |
193 |
|
|
/* status Completion status */ |
194 |
|
|
/* */ |
195 |
|
|
/* CALLS */ |
196 |
|
|
/* */ |
197 |
|
|
/* _gx_context_line_color_set Set line color */ |
198 |
|
|
/* _gx_context_font_set Set font */ |
199 |
|
|
/* _gx_context_brush_get Get brush */ |
200 |
|
|
/* _gx_system_string_width_get Get string width */ |
201 |
|
|
/* _gx_canvas_text_draw Draw text to canvas */ |
202 |
|
|
/* */ |
203 |
|
|
/* CALLED BY */ |
204 |
|
|
/* */ |
205 |
|
|
/* _gx_text_scroll_wheel_row_draw */ |
206 |
|
|
/* */ |
207 |
|
|
/**************************************************************************/ |
208 |
|
1535 |
static UINT _gx_text_scroll_wheel_flat_text_draw(GX_TEXT_SCROLL_WHEEL *wheel, GX_RESOURCE_ID tColor, GX_RESOURCE_ID font_id, |
209 |
|
|
GX_CONST GX_STRING *string, GX_VALUE x_pos, GX_VALUE y_pos, GX_VALUE width, GX_VALUE height) |
210 |
|
|
{ |
211 |
|
1535 |
GX_VALUE text_width = 0; |
212 |
|
|
GX_VALUE text_height; |
213 |
|
|
GX_BRUSH *brush; |
214 |
|
|
|
215 |
|
1535 |
_gx_context_line_color_set(tColor); |
216 |
|
1535 |
_gx_context_font_set(font_id); |
217 |
|
1535 |
_gx_context_brush_get(&brush); |
218 |
|
|
|
219 |
✓✓ |
1535 |
if (!brush -> gx_brush_font) |
220 |
|
|
{ |
221 |
|
2 |
return(GX_SUCCESS); |
222 |
|
|
} |
223 |
|
|
|
224 |
|
1533 |
text_height = brush -> gx_brush_font -> gx_font_line_height; |
225 |
|
|
|
226 |
|
1533 |
y_pos = (GX_VALUE)(y_pos + (height - text_height) / 2); |
227 |
|
|
|
228 |
✓✓✓ |
1533 |
switch (wheel -> gx_widget_style & GX_STYLE_TEXT_ALIGNMENT_MASK) |
229 |
|
|
{ |
230 |
|
14 |
case GX_STYLE_TEXT_RIGHT: |
231 |
|
14 |
_gx_system_string_width_get_ext(brush -> gx_brush_font, string, &text_width); |
232 |
|
14 |
x_pos = (GX_VALUE)(x_pos + width - 1); |
233 |
|
14 |
x_pos = (GX_VALUE)(x_pos - text_width); |
234 |
|
14 |
break; |
235 |
|
|
|
236 |
|
231 |
case GX_STYLE_TEXT_LEFT: |
237 |
|
231 |
break; |
238 |
|
1288 |
case GX_STYLE_TEXT_CENTER: |
239 |
|
|
default: |
240 |
|
1288 |
_gx_system_string_width_get_ext(brush -> gx_brush_font, string, &text_width); |
241 |
|
1288 |
x_pos = (GX_VALUE)(x_pos + ((width - text_width) / 2)); |
242 |
|
1288 |
break; |
243 |
|
|
} |
244 |
|
|
|
245 |
|
|
/* Draw the text. */ |
246 |
|
1533 |
_gx_canvas_text_draw_ext(x_pos, y_pos, string); |
247 |
|
|
|
248 |
|
1533 |
return GX_SUCCESS; |
249 |
|
|
} |
250 |
|
|
|
251 |
|
|
/**************************************************************************/ |
252 |
|
|
/* */ |
253 |
|
|
/* FUNCTION RELEASE */ |
254 |
|
|
/* */ |
255 |
|
|
/* _gx_text_scroll_wheel_row_draw PORTABLE C */ |
256 |
|
|
/* 6.1.4 */ |
257 |
|
|
/* AUTHOR */ |
258 |
|
|
/* */ |
259 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
260 |
|
|
/* */ |
261 |
|
|
/* DESCRIPTION */ |
262 |
|
|
/* */ |
263 |
|
|
/* Internal helper function to draw text to specified area with */ |
264 |
|
|
/* relevant fonts. */ |
265 |
|
|
/* */ |
266 |
|
|
/* INPUT */ |
267 |
|
|
/* */ |
268 |
|
|
/* wheel Scroll wheel control block */ |
269 |
|
|
/* selected_area The area of selected item */ |
270 |
|
|
/* draw_draw The area for drawing */ |
271 |
|
|
/* */ |
272 |
|
|
/* OUTPUT */ |
273 |
|
|
/* */ |
274 |
|
|
/* status Completion status */ |
275 |
|
|
/* */ |
276 |
|
|
/* CALLS */ |
277 |
|
|
/* */ |
278 |
|
|
/* _gx_utility_rectangle_compare Test if rectangles are equal */ |
279 |
|
|
/* _gx_utility_string_length_check Test string length */ |
280 |
|
|
/* _gx_text_scroll_wheel_round_text_draw Draw text in rounded style */ |
281 |
|
|
/* _gx_text_scroll_wheel_flat_text_draw Draw text in normal style */ |
282 |
|
|
/* */ |
283 |
|
|
/* CALLED BY */ |
284 |
|
|
/* */ |
285 |
|
|
/* _gx_text_scroll_wheel_round_draw */ |
286 |
|
|
/* _gx_text_scroll_wheel_flat_draw */ |
287 |
|
|
/* */ |
288 |
|
|
/**************************************************************************/ |
289 |
|
5582 |
static UINT _gx_text_scroll_wheel_row_draw(GX_TEXT_SCROLL_WHEEL *wheel, GX_RECTANGLE *selected_area, GX_RECTANGLE *draw_area, GX_CONST GX_STRING *string) |
290 |
|
|
{ |
291 |
|
5582 |
UINT status = GX_SUCCESS; |
292 |
|
|
GX_RESOURCE_ID text_color; |
293 |
|
|
GX_RESOURCE_ID font; |
294 |
|
|
INT width; |
295 |
|
|
INT height; |
296 |
|
|
UINT (*text_draw)(GX_TEXT_SCROLL_WHEEL *wheel, GX_RESOURCE_ID tColor, GX_RESOURCE_ID font_id, |
297 |
|
|
GX_CONST GX_STRING *string, GX_VALUE x_pos, GX_VALUE y_pos, GX_VALUE width, GX_VALUE height); |
298 |
|
|
|
299 |
|
|
|
300 |
✓✓ |
5582 |
if (string -> gx_string_length == 0) |
301 |
|
|
{ |
302 |
|
32 |
return status; |
303 |
|
|
} |
304 |
|
|
|
305 |
|
5550 |
width = draw_area -> gx_rectangle_right - draw_area -> gx_rectangle_left + 1; |
306 |
|
5550 |
height = draw_area -> gx_rectangle_bottom - draw_area -> gx_rectangle_top + 1; |
307 |
|
|
|
308 |
✓✓ |
5550 |
if (wheel -> gx_widget_style & GX_STYLE_TEXT_SCROLL_WHEEL_ROUND) |
309 |
|
|
{ |
310 |
|
4015 |
text_draw = _gx_text_scroll_wheel_round_text_draw; |
311 |
|
|
} |
312 |
|
|
else |
313 |
|
|
{ |
314 |
|
1535 |
text_draw = _gx_text_scroll_wheel_flat_text_draw; |
315 |
|
|
} |
316 |
|
|
|
317 |
✓✓ |
5550 |
if ((wheel -> gx_widget_status & GX_STATUS_TRACKING_PEN) || |
318 |
✓✓✓✓
|
8819 |
(wheel -> gx_scroll_wheel_animation_steps != 0) || |
319 |
|
3954 |
(!_gx_utility_rectangle_compare(selected_area, draw_area))) |
320 |
|
|
{ |
321 |
✓✓ |
5001 |
if (wheel -> gx_widget_style & GX_STYLE_ENABLED) |
322 |
|
|
{ |
323 |
|
4974 |
text_color = wheel -> gx_text_scroll_wheel_normal_text_color; |
324 |
|
|
} |
325 |
|
|
else |
326 |
|
|
{ |
327 |
|
27 |
text_color = wheel -> gx_text_scroll_wheel_disabled_text_color; |
328 |
|
|
} |
329 |
|
|
|
330 |
|
5001 |
font = wheel -> gx_text_scroll_wheel_normal_font; |
331 |
|
|
} |
332 |
|
|
else |
333 |
|
|
{ |
334 |
✓✓ |
549 |
if (wheel -> gx_widget_style & GX_STYLE_ENABLED) |
335 |
|
|
{ |
336 |
|
543 |
text_color = wheel -> gx_text_scroll_wheel_selected_text_color; |
337 |
|
|
} |
338 |
|
|
else |
339 |
|
|
{ |
340 |
|
6 |
text_color = wheel -> gx_text_scroll_wheel_disabled_text_color; |
341 |
|
|
} |
342 |
|
549 |
font = wheel -> gx_text_scroll_wheel_selected_font; |
343 |
|
|
} |
344 |
|
|
|
345 |
|
|
/* Draw text. */ |
346 |
|
5550 |
status = text_draw(wheel, text_color, font, string, draw_area -> gx_rectangle_left, |
347 |
|
5550 |
draw_area -> gx_rectangle_top, (GX_VALUE)width, (GX_VALUE)height); |
348 |
|
|
|
349 |
|
5550 |
return status; |
350 |
|
|
} |
351 |
|
|
|
352 |
|
|
/**************************************************************************/ |
353 |
|
|
/* */ |
354 |
|
|
/* FUNCTION RELEASE */ |
355 |
|
|
/* */ |
356 |
|
|
/* _gx_text_scroll_wheel_text_get PORTABLE C */ |
357 |
|
|
/* 6.1.10 */ |
358 |
|
|
/* AUTHOR */ |
359 |
|
|
/* */ |
360 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
361 |
|
|
/* */ |
362 |
|
|
/* DESCRIPTION */ |
363 |
|
|
/* */ |
364 |
|
|
/* Internal helper function to retrieve text of sepecified row. */ |
365 |
|
|
/* */ |
366 |
|
|
/* INPUT */ |
367 |
|
|
/* */ |
368 |
|
|
/* wheel Scroll wheel control block */ |
369 |
|
|
/* row Row index */ |
370 |
|
|
/* string String pointer to be return */ |
371 |
|
|
/* */ |
372 |
|
|
/* OUTPUT */ |
373 |
|
|
/* */ |
374 |
|
|
/* status Completion status */ |
375 |
|
|
/* */ |
376 |
|
|
/* CALLS */ |
377 |
|
|
/* */ |
378 |
|
|
/* [gx_text_scroll_wheel_text_get] Retrieve row text */ |
379 |
|
|
/* [_gx_system_memory_allocator] Memory allocator */ |
380 |
|
|
/* _gx_utility_bidi_paragraph_reorder Reorder bidi text */ |
381 |
|
|
/* */ |
382 |
|
|
/* CALLED BY */ |
383 |
|
|
/* */ |
384 |
|
|
/* _gx_text_scroll_wheel_flat_draw */ |
385 |
|
|
/* _gx_text_scroll_wheel_round_draw */ |
386 |
|
|
/* */ |
387 |
|
|
/**************************************************************************/ |
388 |
|
5595 |
static UINT _gx_text_scroll_wheel_text_get(GX_TEXT_SCROLL_WHEEL *wheel, INT row, GX_STRING *string) |
389 |
|
|
{ |
390 |
|
|
#ifdef GX_DYNAMIC_BIDI_TEXT_SUPPORT |
391 |
|
|
GX_BIDI_TEXT_INFO text_info; |
392 |
|
|
GX_BIDI_RESOLVED_TEXT_INFO *resolved_info; |
393 |
|
|
GX_CANVAS *canvas; |
394 |
|
|
GX_DISPLAY *display; |
395 |
|
|
#endif |
396 |
|
|
|
397 |
|
|
#if defined(GX_ENABLE_DEPRECATED_STRING_API) |
398 |
|
|
UINT status; |
399 |
|
|
|
400 |
✓✓ |
5595 |
if (wheel -> gx_text_scroll_wheel_text_get_deprecated) |
401 |
|
|
{ |
402 |
|
47 |
string -> gx_string_ptr = wheel -> gx_text_scroll_wheel_text_get_deprecated(wheel, row); |
403 |
|
|
|
404 |
✓✓ |
47 |
if (string -> gx_string_ptr) |
405 |
|
|
{ |
406 |
|
32 |
status = _gx_utility_string_length_check(string -> gx_string_ptr, &string -> gx_string_length, GX_MAX_STRING_LENGTH); |
407 |
|
|
|
408 |
✓✓ |
32 |
if (status != GX_SUCCESS) |
409 |
|
|
{ |
410 |
|
5 |
return status; |
411 |
|
|
} |
412 |
|
|
} |
413 |
|
|
} |
414 |
|
|
else |
415 |
|
|
{ |
416 |
|
|
#endif |
417 |
|
5548 |
wheel -> gx_text_scroll_wheel_text_get(wheel, row, string); |
418 |
|
|
#if defined(GX_ENABLE_DEPRECATED_STRING_API) |
419 |
|
|
} |
420 |
|
|
#endif |
421 |
|
|
|
422 |
|
|
#ifdef GX_DYNAMIC_BIDI_TEXT_SUPPORT |
423 |
|
|
if (_gx_system_bidi_text_enabled) |
424 |
|
|
{ |
425 |
|
|
if (!_gx_system_memory_allocator) |
426 |
|
|
{ |
427 |
|
|
return GX_SYSTEM_MEMORY_ERROR; |
428 |
|
|
} |
429 |
|
|
|
430 |
|
|
if (!wheel -> gx_text_scroll_wheel_bidi_resolved_text_info) |
431 |
|
|
{ |
432 |
|
|
wheel -> gx_text_scroll_wheel_bidi_resolved_text_info = (GX_BIDI_RESOLVED_TEXT_INFO **)_gx_system_memory_allocator(sizeof(GX_BIDI_RESOLVED_TEXT_INFO *) * (UINT)wheel -> gx_scroll_wheel_total_rows); |
433 |
|
|
|
434 |
|
|
if (!wheel -> gx_text_scroll_wheel_bidi_resolved_text_info) |
435 |
|
|
{ |
436 |
|
|
return GX_SYSTEM_MEMORY_ERROR; |
437 |
|
|
} |
438 |
|
|
|
439 |
|
|
memset(wheel -> gx_text_scroll_wheel_bidi_resolved_text_info, 0, sizeof(GX_BIDI_RESOLVED_TEXT_INFO *) * (UINT)wheel -> gx_scroll_wheel_total_rows); |
440 |
|
|
} |
441 |
|
|
|
442 |
|
|
if (!wheel -> gx_text_scroll_wheel_bidi_resolved_text_info[row]) |
443 |
|
|
{ |
444 |
|
|
text_info.gx_bidi_text_info_text = *string; |
445 |
|
|
text_info.gx_bidi_text_info_font = GX_NULL; |
446 |
|
|
text_info.gx_bidi_text_info_display_width = 0; |
447 |
|
|
GX_UTILITY_TEXT_DIRECTION_GET(text_info.gx_bidi_text_info_direction, wheel, canvas, display); |
448 |
|
|
|
449 |
|
|
if (_gx_utility_bidi_paragraph_reorder_ext(&text_info, &resolved_info) == GX_SUCCESS) |
450 |
|
|
{ |
451 |
|
|
wheel -> gx_text_scroll_wheel_bidi_resolved_text_info[row] = resolved_info; |
452 |
|
|
} |
453 |
|
|
} |
454 |
|
|
|
455 |
|
|
if (wheel -> gx_text_scroll_wheel_bidi_resolved_text_info[row]) |
456 |
|
|
{ |
457 |
|
|
*string = *wheel -> gx_text_scroll_wheel_bidi_resolved_text_info[row] -> gx_bidi_resolved_text_info_text; |
458 |
|
|
} |
459 |
|
|
} |
460 |
|
|
#endif |
461 |
|
|
|
462 |
|
5590 |
return GX_SUCCESS; |
463 |
|
|
} |
464 |
|
|
|
465 |
|
|
/**************************************************************************/ |
466 |
|
|
/* */ |
467 |
|
|
/* FUNCTION RELEASE */ |
468 |
|
|
/* */ |
469 |
|
|
/* _gx_text_scroll_wheel_round_draw PORTABLE C */ |
470 |
|
|
/* 6.1 */ |
471 |
|
|
/* AUTHOR */ |
472 |
|
|
/* */ |
473 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
474 |
|
|
/* */ |
475 |
|
|
/* DESCRIPTION */ |
476 |
|
|
/* */ |
477 |
|
|
/* Internal helper function to draw a scroll wheel, which contain some */ |
478 |
|
|
/* text transformating process. */ |
479 |
|
|
/* */ |
480 |
|
|
/* INPUT */ |
481 |
|
|
/* */ |
482 |
|
|
/* wheel Scroll wheel control block */ |
483 |
|
|
/* */ |
484 |
|
|
/* OUTPUT */ |
485 |
|
|
/* */ |
486 |
|
|
/* status Completion status */ |
487 |
|
|
/* */ |
488 |
|
|
/* CALLS */ |
489 |
|
|
/* */ |
490 |
|
|
/* _gx_context_pixelmap_get Get pixelmap by resource ID */ |
491 |
|
|
/* _gx_window_client_height_get Get window client height */ |
492 |
|
|
/* _gx_window_client_width_get Get window clietn width */ |
493 |
|
|
/* _gx_widget_border_width_get Get widget border width */ |
494 |
|
|
/* _gx_utility_rectangle_define Define a rectangle */ |
495 |
|
|
/* _gx_canvas_pixelmap_tile Title a pixelmap */ |
496 |
|
|
/* _gx_text_scroll_wheel_row_draw Draw text to specified area */ |
497 |
|
|
/* */ |
498 |
|
|
/* CALLED BY */ |
499 |
|
|
/* */ |
500 |
|
|
/* _gx_text_scroll_wheel_draw */ |
501 |
|
|
/* */ |
502 |
|
|
/**************************************************************************/ |
503 |
|
562 |
static UINT _gx_text_scroll_wheel_round_draw(GX_TEXT_SCROLL_WHEEL *wheel) |
504 |
|
|
{ |
505 |
|
562 |
UINT status = GX_SUCCESS; |
506 |
|
|
GX_PIXELMAP *map; |
507 |
|
|
GX_VALUE width; |
508 |
|
|
GX_VALUE height; |
509 |
|
|
GX_VALUE row_height; |
510 |
|
|
INT trans_height; |
511 |
|
|
GX_VALUE xpos; |
512 |
|
|
GX_VALUE ypos; |
513 |
|
|
GX_VALUE ycenter; |
514 |
|
|
GX_VALUE border_width; |
515 |
|
|
GX_RECTANGLE selected_area; |
516 |
|
|
GX_RECTANGLE draw_area; |
517 |
|
|
GX_STRING string; |
518 |
|
|
INT row; |
519 |
|
|
|
520 |
|
|
/* Pickup selected background. */ |
521 |
|
562 |
_gx_context_pixelmap_get(wheel -> gx_scroll_wheel_selected_background, &map); |
522 |
|
|
|
523 |
|
|
/* Pickup client height. */ |
524 |
|
562 |
_gx_window_client_height_get((GX_WINDOW *)wheel, &height); |
525 |
|
562 |
_gx_window_client_width_get((GX_WINDOW *)wheel, &width); |
526 |
|
562 |
_gx_widget_border_width_get((GX_WIDGET *)wheel, &border_width); |
527 |
|
|
|
528 |
✓✓✓✓
|
562 |
if (width <= 0 || height <= 0) |
529 |
|
|
{ |
530 |
|
2 |
return GX_FALSE; |
531 |
|
|
} |
532 |
|
|
|
533 |
|
560 |
row_height = wheel -> gx_scroll_wheel_row_height; |
534 |
|
560 |
xpos = (GX_VALUE)(wheel -> gx_widget_size.gx_rectangle_left + border_width); |
535 |
|
|
|
536 |
|
560 |
ypos = (GX_VALUE)(wheel -> gx_widget_size.gx_rectangle_top + border_width); |
537 |
|
560 |
ypos = (GX_VALUE)(ypos + (height >> 1)); |
538 |
|
560 |
ypos = (GX_VALUE)(ypos - (row_height >> 1)); |
539 |
|
|
|
540 |
|
|
/* Draw selected background. */ |
541 |
|
560 |
_gx_utility_rectangle_define(&selected_area, xpos, ypos, (GX_VALUE)(xpos + width - 1), (GX_VALUE)(ypos + row_height - 1)); |
542 |
|
|
|
543 |
✓✓ |
560 |
if (map) |
544 |
|
|
{ |
545 |
|
554 |
_gx_canvas_pixelmap_tile(&selected_area, map); |
546 |
|
|
} |
547 |
|
|
|
548 |
|
|
/* Draw scroll wheel rows. */ |
549 |
|
|
|
550 |
|
560 |
ycenter = (GX_VALUE)(ypos + row_height / 2); |
551 |
|
560 |
ypos = (GX_VALUE)(ypos + wheel -> gx_scroll_wheel_selected_yshift); |
552 |
|
560 |
row = wheel -> gx_scroll_wheel_selected_row; |
553 |
|
|
|
554 |
✓✓ |
2711 |
while (status == GX_SUCCESS && |
555 |
✓✓ |
2689 |
ypos < wheel -> gx_widget_size.gx_rectangle_bottom - border_width) |
556 |
|
|
{ |
557 |
✓✓ |
2187 |
if (row > (INT)(wheel -> gx_scroll_wheel_total_rows - 1)) |
558 |
|
|
{ |
559 |
✓✓ |
167 |
if (wheel -> gx_widget_style & GX_STYLE_WRAP) |
560 |
|
|
{ |
561 |
|
136 |
row -= wheel -> gx_scroll_wheel_total_rows; |
562 |
|
|
} |
563 |
|
|
else |
564 |
|
|
{ |
565 |
|
31 |
break; |
566 |
|
|
} |
567 |
|
|
} |
568 |
|
|
|
569 |
|
2156 |
status = _gx_text_scroll_wheel_text_get(wheel, row, &string); |
570 |
|
|
|
571 |
✓✓ |
2156 |
if (status != GX_SUCCESS) |
572 |
|
|
{ |
573 |
|
1 |
return status; |
574 |
|
|
} |
575 |
|
|
|
576 |
|
2155 |
trans_height = GX_ABS(ypos + row_height / 2 - ycenter); |
577 |
|
|
|
578 |
✓✓ |
2155 |
if (trans_height == 0) |
579 |
|
|
{ |
580 |
|
364 |
trans_height = row_height; |
581 |
|
|
} |
582 |
|
|
else |
583 |
|
|
{ |
584 |
✓✓ |
1791 |
trans_height = GX_FIXED_VAL_MAKE(GX_ABS(height * 3 / 4 - trans_height)); |
585 |
|
1791 |
trans_height = 120 * trans_height / height; |
586 |
|
|
|
587 |
|
1791 |
trans_height = GX_FIXED_VAL_TO_INT(_gx_utility_math_sin(trans_height) * row_height); |
588 |
|
|
|
589 |
✓✓ |
1791 |
if (trans_height < row_height / 5) |
590 |
|
|
{ |
591 |
|
4 |
break; |
592 |
|
|
} |
593 |
|
|
} |
594 |
|
|
|
595 |
|
2151 |
_gx_utility_rectangle_define(&draw_area, xpos, ypos, (GX_VALUE)(xpos + width - 1), (GX_VALUE)(ypos + trans_height - 1)); |
596 |
|
2151 |
status = _gx_text_scroll_wheel_row_draw((GX_TEXT_SCROLL_WHEEL *)wheel, &selected_area, &draw_area, &string); |
597 |
|
2151 |
ypos = (GX_VALUE)(ypos + trans_height); |
598 |
|
2151 |
row++; |
599 |
|
|
} |
600 |
|
|
|
601 |
|
559 |
ypos = (GX_VALUE)(ycenter - row_height / 2 + wheel -> gx_scroll_wheel_selected_yshift); |
602 |
|
559 |
row = wheel -> gx_scroll_wheel_selected_row - 1; |
603 |
|
|
|
604 |
✓✓ |
2442 |
while (status == GX_SUCCESS && |
605 |
✓✓ |
2420 |
ypos > wheel -> gx_widget_size.gx_rectangle_top + border_width) |
606 |
|
|
{ |
607 |
✓✓ |
1953 |
if (row < 0) |
608 |
|
|
{ |
609 |
✓✓ |
157 |
if (wheel -> gx_widget_style & GX_STYLE_WRAP) |
610 |
|
|
{ |
611 |
|
92 |
row += wheel -> gx_scroll_wheel_total_rows; |
612 |
|
|
} |
613 |
|
|
else |
614 |
|
|
{ |
615 |
|
65 |
break; |
616 |
|
|
} |
617 |
|
|
} |
618 |
|
|
|
619 |
|
1888 |
status = _gx_text_scroll_wheel_text_get(wheel, row, &string); |
620 |
|
|
|
621 |
✓✓ |
1888 |
if (status != GX_SUCCESS) |
622 |
|
|
{ |
623 |
|
1 |
return status; |
624 |
|
|
} |
625 |
|
|
|
626 |
|
1887 |
trans_height = ycenter + (row_height / 2) - ypos; |
627 |
|
|
|
628 |
✓✓ |
1887 |
trans_height = GX_FIXED_VAL_MAKE(GX_ABS(height * 3 / 4 - trans_height)); |
629 |
|
1887 |
trans_height = 120 * trans_height / height; |
630 |
|
|
|
631 |
|
1887 |
trans_height = GX_FIXED_VAL_TO_INT(_gx_utility_math_sin(trans_height) * row_height); |
632 |
|
|
|
633 |
✓✓ |
1887 |
if (trans_height < row_height / 5) |
634 |
|
|
{ |
635 |
|
4 |
break; |
636 |
|
|
} |
637 |
|
|
|
638 |
|
1883 |
_gx_utility_rectangle_define(&draw_area, xpos, (GX_VALUE)(ypos - trans_height), (GX_VALUE)(xpos + width - 1), (GX_VALUE)(ypos - 1)); |
639 |
|
1883 |
status = _gx_text_scroll_wheel_row_draw((GX_TEXT_SCROLL_WHEEL *)wheel, &selected_area, &draw_area, &string); |
640 |
|
1883 |
ypos = (GX_VALUE)(ypos - trans_height); |
641 |
|
1883 |
row--; |
642 |
|
|
} |
643 |
|
|
|
644 |
|
|
/* Draw the overlay pixelmap, if there is one: */ |
645 |
|
|
|
646 |
✓✓ |
558 |
if (wheel -> gx_scroll_wheel_gradient.gx_gradient_pixelmap.gx_pixelmap_data) |
647 |
|
|
{ |
648 |
|
552 |
_gx_canvas_pixelmap_tile(&wheel -> gx_widget_size, &wheel -> gx_scroll_wheel_gradient.gx_gradient_pixelmap); |
649 |
|
|
} |
650 |
|
|
|
651 |
|
558 |
return status; |
652 |
|
|
} |
653 |
|
|
|
654 |
|
|
/**************************************************************************/ |
655 |
|
|
/* */ |
656 |
|
|
/* FUNCTION RELEASE */ |
657 |
|
|
/* */ |
658 |
|
|
/* _gx_text_scroll_wheel_flat_draw PORTABLE C */ |
659 |
|
|
/* 6.1 */ |
660 |
|
|
/* AUTHOR */ |
661 |
|
|
/* */ |
662 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
663 |
|
|
/* */ |
664 |
|
|
/* DESCRIPTION */ |
665 |
|
|
/* */ |
666 |
|
|
/* Internal helper function to draw a scroll wheel in normal case. */ |
667 |
|
|
/* */ |
668 |
|
|
/* INPUT */ |
669 |
|
|
/* */ |
670 |
|
|
/* wheel Scroll wheel control block */ |
671 |
|
|
/* */ |
672 |
|
|
/* OUTPUT */ |
673 |
|
|
/* */ |
674 |
|
|
/* status Completion status */ |
675 |
|
|
/* */ |
676 |
|
|
/* CALLS */ |
677 |
|
|
/* */ |
678 |
|
|
/* _gx_context_pixelmap_get Get pixelmap by resource ID */ |
679 |
|
|
/* _gx_window_client_height_get Get window client height */ |
680 |
|
|
/* _gx_window_client_width_get Get window client width */ |
681 |
|
|
/* _gx_widget_border_width_get Get widget border width */ |
682 |
|
|
/* _gx_utility_rectangle_define Define a rectangle */ |
683 |
|
|
/* _gx_canvas_pixelmap_tile Tile a pixelmap */ |
684 |
|
|
/* _gx_text_scroll_wheel_row_draw Draw text to specified area */ |
685 |
|
|
/* */ |
686 |
|
|
/* CALLED BY */ |
687 |
|
|
/* */ |
688 |
|
|
/* _gx_text_scroll_wheel_draw */ |
689 |
|
|
/* */ |
690 |
|
|
/**************************************************************************/ |
691 |
|
267 |
static UINT _gx_text_scroll_wheel_flat_draw(GX_TEXT_SCROLL_WHEEL *wheel) |
692 |
|
|
{ |
693 |
|
|
GX_PIXELMAP *map; |
694 |
|
|
GX_VALUE width; |
695 |
|
|
GX_VALUE height; |
696 |
|
|
GX_VALUE row_height; |
697 |
|
|
GX_VALUE xpos; |
698 |
|
|
GX_VALUE ypos; |
699 |
|
|
GX_VALUE border_width; |
700 |
|
|
GX_RECTANGLE selected_area; |
701 |
|
|
GX_RECTANGLE draw_area; |
702 |
|
|
GX_STRING string; |
703 |
|
|
INT row; |
704 |
|
|
INT top_rows; |
705 |
|
|
UINT status; |
706 |
|
|
|
707 |
|
|
/* Pickup selected background. */ |
708 |
|
267 |
_gx_context_pixelmap_get(wheel -> gx_scroll_wheel_selected_background, &map); |
709 |
|
|
|
710 |
|
|
/* Pickup client height. */ |
711 |
|
267 |
_gx_window_client_height_get((GX_WINDOW *)wheel, &height); |
712 |
|
267 |
_gx_window_client_width_get((GX_WINDOW *)wheel, &width); |
713 |
|
267 |
_gx_widget_border_width_get((GX_WIDGET *)wheel, &border_width); |
714 |
|
|
|
715 |
|
267 |
row_height = wheel -> gx_scroll_wheel_row_height; |
716 |
|
|
|
717 |
✓✓ |
267 |
if (row_height <= 0) |
718 |
|
|
{ |
719 |
|
2 |
return GX_FALSE; |
720 |
|
|
} |
721 |
|
265 |
xpos = (GX_VALUE)(wheel -> gx_widget_size.gx_rectangle_left + border_width); |
722 |
|
|
|
723 |
|
265 |
ypos = (GX_VALUE)(wheel -> gx_widget_size.gx_rectangle_top + border_width); |
724 |
|
265 |
ypos = (GX_VALUE)(ypos + (height >> 1)); |
725 |
|
265 |
ypos = (GX_VALUE)(ypos - (row_height >> 1)); |
726 |
|
|
|
727 |
|
|
/* Draw selected background. */ |
728 |
|
265 |
_gx_utility_rectangle_define(&selected_area, xpos, ypos, (GX_VALUE)(xpos + width - 1), (GX_VALUE)(ypos + row_height - 1)); |
729 |
|
|
|
730 |
✓✓ |
265 |
if (map) |
731 |
|
|
{ |
732 |
|
194 |
_gx_canvas_pixelmap_tile(&selected_area, map); |
733 |
|
|
} |
734 |
|
|
|
735 |
|
265 |
ypos = (GX_VALUE)(ypos + wheel -> gx_scroll_wheel_selected_yshift); |
736 |
|
|
|
737 |
|
265 |
top_rows = (ypos - wheel -> gx_widget_size.gx_rectangle_top + row_height) / row_height; |
738 |
|
265 |
ypos = (GX_VALUE)(ypos - (top_rows * row_height)); |
739 |
|
|
|
740 |
|
265 |
row = wheel -> gx_scroll_wheel_selected_row - top_rows; |
741 |
|
|
|
742 |
✓✓ |
419 |
while (row < 0) |
743 |
|
|
{ |
744 |
✓✓ |
154 |
if (wheel -> gx_widget_style & GX_STYLE_WRAP) |
745 |
|
|
{ |
746 |
|
67 |
row += wheel -> gx_scroll_wheel_total_rows; |
747 |
|
|
} |
748 |
|
|
else |
749 |
|
|
{ |
750 |
|
87 |
ypos = (GX_VALUE)(ypos - row * row_height); |
751 |
|
87 |
row = 0; |
752 |
|
|
} |
753 |
|
|
} |
754 |
|
|
|
755 |
✓✓ |
1813 |
while (ypos < wheel -> gx_widget_size.gx_rectangle_bottom - border_width) |
756 |
|
|
{ |
757 |
✓✓ |
1556 |
if (row > (INT)(wheel -> gx_scroll_wheel_total_rows - 1)) |
758 |
|
|
{ |
759 |
✓✓ |
158 |
if (wheel -> gx_widget_style & GX_STYLE_WRAP) |
760 |
|
|
{ |
761 |
|
153 |
row -= wheel -> gx_scroll_wheel_total_rows; |
762 |
|
|
} |
763 |
|
|
else |
764 |
|
|
{ |
765 |
|
5 |
break; |
766 |
|
|
} |
767 |
|
|
} |
768 |
|
|
|
769 |
|
1551 |
status = _gx_text_scroll_wheel_text_get(wheel, row, &string); |
770 |
✓✓ |
1551 |
if (status != GX_SUCCESS) |
771 |
|
|
{ |
772 |
|
3 |
return status; |
773 |
|
|
} |
774 |
|
|
|
775 |
|
1548 |
_gx_utility_rectangle_define(&draw_area, xpos, ypos, (GX_VALUE)(xpos + width - 1), (GX_VALUE)(ypos + row_height - 1)); |
776 |
|
1548 |
_gx_text_scroll_wheel_row_draw((GX_TEXT_SCROLL_WHEEL *)wheel, &selected_area, &draw_area, &string); |
777 |
|
1548 |
ypos = (GX_VALUE)(ypos + row_height); |
778 |
|
1548 |
row++; |
779 |
|
|
} |
780 |
|
|
|
781 |
|
|
/* Draw the overlay pixelmap, if there is one: */ |
782 |
|
|
|
783 |
✓✓ |
262 |
if (wheel -> gx_scroll_wheel_gradient.gx_gradient_pixelmap.gx_pixelmap_data) |
784 |
|
|
{ |
785 |
|
235 |
_gx_canvas_pixelmap_tile(&wheel -> gx_widget_size, &wheel -> gx_scroll_wheel_gradient.gx_gradient_pixelmap); |
786 |
|
|
} |
787 |
|
|
|
788 |
|
262 |
return GX_SUCCESS; |
789 |
|
|
} |
790 |
|
|
|
791 |
|
|
/**************************************************************************/ |
792 |
|
|
/* */ |
793 |
|
|
/* FUNCTION RELEASE */ |
794 |
|
|
/* */ |
795 |
|
|
/* _gx_text_scroll_wheel_draw PORTABLE C */ |
796 |
|
|
/* 6.1 */ |
797 |
|
|
/* AUTHOR */ |
798 |
|
|
/* */ |
799 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
800 |
|
|
/* */ |
801 |
|
|
/* DESCRIPTION */ |
802 |
|
|
/* */ |
803 |
|
|
/* This function draws a text scroll wheel widget. */ |
804 |
|
|
/* */ |
805 |
|
|
/* INPUT */ |
806 |
|
|
/* */ |
807 |
|
|
/* wheel Text scroll wheel control */ |
808 |
|
|
/* block */ |
809 |
|
|
/* */ |
810 |
|
|
/* OUTPUT */ |
811 |
|
|
/* */ |
812 |
|
|
/* None */ |
813 |
|
|
/* */ |
814 |
|
|
/* CALLS */ |
815 |
|
|
/* */ |
816 |
|
|
/* _gx_window_draw Draw a window */ |
817 |
|
|
/* _gx_text_scroll_wheel_round_draw Draw round style scroll wheel */ |
818 |
|
|
/* _gx_text_scroll_wheel_flat_draw Draw flat style scroll wheel */ |
819 |
|
|
/* */ |
820 |
|
|
/* CALLED BY */ |
821 |
|
|
/* */ |
822 |
|
|
/* Application Code */ |
823 |
|
|
/* GUIX Internal Code */ |
824 |
|
|
/* */ |
825 |
|
|
/**************************************************************************/ |
826 |
|
854 |
VOID _gx_text_scroll_wheel_draw(GX_TEXT_SCROLL_WHEEL *wheel) |
827 |
|
|
{ |
828 |
|
854 |
_gx_window_draw((GX_WINDOW *)wheel); |
829 |
|
|
|
830 |
✓✓ |
854 |
if (!wheel -> gx_scroll_wheel_total_rows) |
831 |
|
|
{ |
832 |
|
24 |
return; |
833 |
|
|
} |
834 |
|
|
|
835 |
|
|
#if defined(GX_ENABLE_DEPRECATED_STRING_API) |
836 |
✓✓ |
830 |
if ((wheel -> gx_text_scroll_wheel_text_get_deprecated == GX_NULL) && |
837 |
✓✓ |
820 |
(wheel -> gx_text_scroll_wheel_text_get == GX_NULL)) |
838 |
|
|
{ |
839 |
|
1 |
return; |
840 |
|
|
} |
841 |
|
|
#else |
842 |
|
|
if (wheel -> gx_text_scroll_wheel_text_get == GX_NULL) |
843 |
|
|
{ |
844 |
|
|
return; |
845 |
|
|
} |
846 |
|
|
#endif |
847 |
|
|
|
848 |
✓✓ |
829 |
if (wheel -> gx_widget_style & GX_STYLE_TEXT_SCROLL_WHEEL_ROUND) |
849 |
|
|
{ |
850 |
|
562 |
_gx_text_scroll_wheel_round_draw((GX_TEXT_SCROLL_WHEEL *)wheel); |
851 |
|
|
} |
852 |
|
|
else |
853 |
|
|
{ |
854 |
|
267 |
_gx_text_scroll_wheel_flat_draw((GX_TEXT_SCROLL_WHEEL *)wheel); |
855 |
|
|
} |
856 |
|
|
} |
857 |
|
|
|