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 |
|
|
/** Slider Management (Slider) */ |
19 |
|
|
/** */ |
20 |
|
|
/**************************************************************************/ |
21 |
|
|
|
22 |
|
|
#define GX_SOURCE_CODE |
23 |
|
|
|
24 |
|
|
/* Include necessary system files. */ |
25 |
|
|
|
26 |
|
|
#include "gx_api.h" |
27 |
|
|
#include "gx_system.h" |
28 |
|
|
#include "gx_canvas.h" |
29 |
|
|
#include "gx_context.h" |
30 |
|
|
#include "gx_widget.h" |
31 |
|
|
#include "gx_slider.h" |
32 |
|
|
|
33 |
|
|
|
34 |
|
|
/**************************************************************************/ |
35 |
|
|
/* */ |
36 |
|
|
/* FUNCTION RELEASE */ |
37 |
|
|
/* */ |
38 |
|
|
/* _gx_pixelmap_slider_draw PORTABLE C */ |
39 |
|
|
/* 6.1 */ |
40 |
|
|
/* AUTHOR */ |
41 |
|
|
/* */ |
42 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
43 |
|
|
/* */ |
44 |
|
|
/* DESCRIPTION */ |
45 |
|
|
/* */ |
46 |
|
|
/* This function draws the specified slider, which is a type of */ |
47 |
|
|
/* of widget designed to allow adjusting or display a value */ |
48 |
|
|
/* graphically */ |
49 |
|
|
/* */ |
50 |
|
|
/* INPUT */ |
51 |
|
|
/* */ |
52 |
|
|
/* slider Slider control block */ |
53 |
|
|
/* */ |
54 |
|
|
/* OUTPUT */ |
55 |
|
|
/* */ |
56 |
|
|
/* None */ |
57 |
|
|
/* */ |
58 |
|
|
/* CALLS */ |
59 |
|
|
/* */ |
60 |
|
|
/* _gx_slider_needle_position_get Get the position of the */ |
61 |
|
|
/* slider needle */ |
62 |
|
|
/* _gx_canvas_pixelmap_tile Tile a pixelmap */ |
63 |
|
|
/* _gx_context_pixelmap_get Retrieve pixelmap image */ |
64 |
|
|
/* _gx_sidget_width_get Obtain the width of a widget */ |
65 |
|
|
/* _gx_wdiget_background_draw Draw widget background */ |
66 |
|
|
/* _gx_canvas_pixelmap_draw Draw pixelmap on canvas */ |
67 |
|
|
/* */ |
68 |
|
|
/* CALLED BY */ |
69 |
|
|
/* */ |
70 |
|
|
/* Application Code */ |
71 |
|
|
/* GUIX Internal Code */ |
72 |
|
|
/* */ |
73 |
|
|
/**************************************************************************/ |
74 |
|
11736 |
VOID _gx_pixelmap_slider_draw(GX_PIXELMAP_SLIDER *slider) |
75 |
|
|
{ |
76 |
|
|
GX_PIXELMAP *map; |
77 |
|
|
GX_PIXELMAP *uppermap; |
78 |
|
|
GX_RECTANGLE fillrect; |
79 |
|
|
GX_SLIDER_INFO *info; |
80 |
|
|
GX_PIXELMAP_SLIDER_INFO *pixinfo; |
81 |
|
|
GX_VALUE space; |
82 |
|
|
GX_RECTANGLE needle_size; |
83 |
|
|
|
84 |
|
11736 |
info = &slider -> gx_slider_info; |
85 |
|
11736 |
pixinfo = &slider -> gx_pixelmap_slider_pixelmap_info; |
86 |
|
|
|
87 |
|
11736 |
_gx_context_pixelmap_get(pixinfo -> gx_pixelmap_slider_info_lower_background_pixelmap, &map); |
88 |
|
11736 |
_gx_context_pixelmap_get(pixinfo -> gx_pixelmap_slider_info_upper_background_pixelmap, &uppermap); |
89 |
|
11736 |
_gx_slider_needle_position_get((GX_SLIDER *)slider, info, &needle_size); |
90 |
|
11736 |
_gx_widget_context_fill_set((GX_WIDGET *)slider); |
91 |
|
|
|
92 |
✓✓✓✓ ✓✓ |
11736 |
if ((slider -> gx_widget_style & GX_STYLE_TILE_BACKGROUND) && map && uppermap) |
93 |
|
|
{ |
94 |
✓✓ |
5890 |
if (slider -> gx_widget_style & GX_STYLE_SLIDER_VERTICAL) |
95 |
|
|
{ |
96 |
|
2418 |
_gx_widget_width_get((GX_WIDGET *)slider, &space); |
97 |
|
2418 |
space = (GX_VALUE)(space - map -> gx_pixelmap_width); |
98 |
|
2418 |
space /= 2; |
99 |
|
2418 |
fillrect.gx_rectangle_top = slider -> gx_widget_size.gx_rectangle_top; |
100 |
|
2418 |
fillrect.gx_rectangle_left = (GX_VALUE)(slider -> gx_widget_size.gx_rectangle_left + space); |
101 |
|
2418 |
fillrect.gx_rectangle_right = (GX_VALUE)(fillrect.gx_rectangle_left + map -> gx_pixelmap_width - 1); |
102 |
|
2418 |
fillrect.gx_rectangle_bottom = (GX_VALUE)(needle_size.gx_rectangle_top + info -> gx_slider_info_needle_hotspot_offset); |
103 |
|
2418 |
_gx_canvas_pixelmap_tile(&fillrect, uppermap); |
104 |
|
|
|
105 |
|
2418 |
fillrect.gx_rectangle_top = (GX_VALUE)(fillrect.gx_rectangle_bottom + 1); |
106 |
|
2418 |
fillrect.gx_rectangle_bottom = slider -> gx_widget_size.gx_rectangle_bottom; |
107 |
|
2418 |
_gx_canvas_pixelmap_tile(&fillrect, map); |
108 |
|
|
} |
109 |
|
|
else |
110 |
|
|
{ |
111 |
|
3472 |
_gx_widget_height_get((GX_WIDGET *)slider, &space); |
112 |
|
3472 |
space = (GX_VALUE)(space - map -> gx_pixelmap_height); |
113 |
|
3472 |
space /= 2; |
114 |
|
3472 |
fillrect.gx_rectangle_top = (GX_VALUE)(slider -> gx_widget_size.gx_rectangle_top + space); |
115 |
|
3472 |
fillrect.gx_rectangle_left = slider -> gx_widget_size.gx_rectangle_left; |
116 |
|
3472 |
fillrect.gx_rectangle_right = (GX_VALUE)(needle_size.gx_rectangle_left + info -> gx_slider_info_needle_hotspot_offset); |
117 |
|
3472 |
fillrect.gx_rectangle_bottom = (GX_VALUE)(fillrect.gx_rectangle_top + map -> gx_pixelmap_height - 1); |
118 |
|
3472 |
_gx_canvas_pixelmap_tile(&fillrect, map); |
119 |
|
|
|
120 |
|
3472 |
fillrect.gx_rectangle_left = (GX_VALUE)(fillrect.gx_rectangle_right + 1); |
121 |
|
3472 |
fillrect.gx_rectangle_right = slider -> gx_widget_size.gx_rectangle_right; |
122 |
|
3472 |
_gx_canvas_pixelmap_tile(&fillrect, uppermap); |
123 |
|
|
} |
124 |
|
|
} |
125 |
|
|
else |
126 |
|
|
{ |
127 |
✓✓ |
5846 |
if (map) |
128 |
|
|
{ |
129 |
✓✓ |
4570 |
if (slider -> gx_widget_style & GX_STYLE_TILE_BACKGROUND) |
130 |
|
|
{ |
131 |
|
629 |
_gx_canvas_pixelmap_tile(&slider -> gx_widget_size, map); |
132 |
|
|
} |
133 |
|
|
else |
134 |
|
|
{ |
135 |
|
3941 |
_gx_canvas_pixelmap_draw(slider -> gx_widget_size.gx_rectangle_left, |
136 |
|
3941 |
slider -> gx_widget_size.gx_rectangle_top, map); |
137 |
|
|
} |
138 |
|
|
} |
139 |
|
|
else |
140 |
|
|
{ |
141 |
✓✓ |
1276 |
if (!(slider -> gx_widget_style & GX_STYLE_TRANSPARENT)) |
142 |
|
|
{ |
143 |
|
647 |
_gx_widget_background_draw((GX_WIDGET *)slider); |
144 |
|
|
} |
145 |
|
|
} |
146 |
|
|
} |
147 |
|
|
|
148 |
|
|
/* Pick up needle pixelmap. */ |
149 |
|
11736 |
_gx_context_pixelmap_get(pixinfo -> gx_pixelmap_slider_info_needle_pixelmap, &map); |
150 |
|
|
|
151 |
✓✓ |
11736 |
if (map) |
152 |
|
|
{ |
153 |
|
|
/* Draw needle pixelmap. */ |
154 |
|
11605 |
_gx_canvas_pixelmap_draw(needle_size.gx_rectangle_left, needle_size.gx_rectangle_top, map); |
155 |
|
|
} |
156 |
|
|
|
157 |
|
11736 |
_gx_widget_children_draw((GX_WIDGET *)slider); |
158 |
|
11736 |
} |
159 |
|
|
|