1 |
|
|
/*************************************************************************** |
2 |
|
|
* Copyright (c) 2024 Microsoft Corporation |
3 |
|
|
* |
4 |
|
|
* This program and the accompanying materials are made available under the |
5 |
|
|
* terms of the MIT License which is available at |
6 |
|
|
* https://opensource.org/licenses/MIT. |
7 |
|
|
* |
8 |
|
|
* SPDX-License-Identifier: MIT |
9 |
|
|
**************************************************************************/ |
10 |
|
|
|
11 |
|
|
|
12 |
|
|
/**************************************************************************/ |
13 |
|
|
/**************************************************************************/ |
14 |
|
|
/** */ |
15 |
|
|
/** GUIX Component */ |
16 |
|
|
/** */ |
17 |
|
|
/** Prompt Management (Slider) */ |
18 |
|
|
/** */ |
19 |
|
|
/**************************************************************************/ |
20 |
|
|
|
21 |
|
|
#define GX_SOURCE_CODE |
22 |
|
|
|
23 |
|
|
/* Include necessary system files. */ |
24 |
|
|
|
25 |
|
|
#include "gx_api.h" |
26 |
|
|
#include "gx_system.h" |
27 |
|
|
#include "gx_display.h" |
28 |
|
|
#include "gx_context.h" |
29 |
|
|
#include "gx_widget.h" |
30 |
|
|
#include "gx_utility.h" |
31 |
|
|
#include "gx_slider.h" |
32 |
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
|
|
/**************************************************************************/ |
36 |
|
|
/* */ |
37 |
|
|
/* FUNCTION RELEASE */ |
38 |
|
|
/* */ |
39 |
|
|
/* _gx_slider_needle_position_get PORTABLE C */ |
40 |
|
|
/* 6.1 */ |
41 |
|
|
/* AUTHOR */ |
42 |
|
|
/* */ |
43 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
44 |
|
|
/* */ |
45 |
|
|
/* DESCRIPTION */ |
46 |
|
|
/* */ |
47 |
|
|
/* This service gets the slider needle position. */ |
48 |
|
|
/* */ |
49 |
|
|
/* */ |
50 |
|
|
/* INPUT */ |
51 |
|
|
/* */ |
52 |
|
|
/* slider Slider widget control block */ |
53 |
|
|
/* slider_info Pointer to slider information */ |
54 |
|
|
/* structure defining the */ |
55 |
|
|
/* slider limits, needle size */ |
56 |
|
|
/* and offset, and other */ |
57 |
|
|
/* slider parameters. */ |
58 |
|
|
/* return_position Pointer to destination for */ |
59 |
|
|
/* needle position */ |
60 |
|
|
/* */ |
61 |
|
|
/* OUTPUT */ |
62 |
|
|
/* */ |
63 |
|
|
/* status Completion status */ |
64 |
|
|
/* */ |
65 |
|
|
/* CALLS */ |
66 |
|
|
/* */ |
67 |
|
|
/* _gx_slider_travel_get Gets the slider travel */ |
68 |
|
|
/* */ |
69 |
|
|
/* CALLED BY */ |
70 |
|
|
/* */ |
71 |
|
|
/* Application Code */ |
72 |
|
|
/* GUIX Internal Code */ |
73 |
|
|
/* */ |
74 |
|
|
/* RELEASE HISTORY */ |
75 |
|
|
/* */ |
76 |
|
|
/* DATE NAME DESCRIPTION */ |
77 |
|
|
/* */ |
78 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
79 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
80 |
|
|
/* resulting in version 6.1 */ |
81 |
|
|
/* */ |
82 |
|
|
/**************************************************************************/ |
83 |
|
157107 |
UINT _gx_slider_needle_position_get(GX_SLIDER *slider, GX_SLIDER_INFO *slider_info, GX_RECTANGLE *return_position) |
84 |
|
|
{ |
85 |
|
|
INT mintravel; |
86 |
|
|
INT maxtravel; |
87 |
|
157107 |
INT shift = 0; |
88 |
|
|
GX_VALUE hotspot; |
89 |
|
|
|
90 |
|
|
/* get the limits of the slider travel */ |
91 |
|
157107 |
_gx_slider_travel_get(slider, slider_info, &mintravel, &maxtravel); |
92 |
|
|
|
93 |
|
|
/* calculate shift amount based on value */ |
94 |
|
|
|
95 |
✓✓ |
157107 |
if (slider_info -> gx_slider_info_max_val > slider_info -> gx_slider_info_min_val) |
96 |
|
|
{ |
97 |
|
157104 |
shift = (slider_info -> gx_slider_info_current_val - slider_info -> gx_slider_info_min_val); |
98 |
|
157104 |
shift *= (maxtravel - mintravel); |
99 |
|
157104 |
shift /= (slider_info -> gx_slider_info_max_val - slider_info -> gx_slider_info_min_val); |
100 |
|
157104 |
shift += slider_info -> gx_slider_info_min_travel; |
101 |
|
|
} |
102 |
|
|
|
103 |
|
|
/* calculate needle dimensions */ |
104 |
|
|
|
105 |
✓✓ |
157107 |
if (slider -> gx_widget_style & GX_STYLE_SLIDER_VERTICAL) |
106 |
|
|
{ |
107 |
|
|
/* calculate position of the hotspot */ |
108 |
|
26706 |
hotspot = (GX_VALUE)(slider -> gx_widget_size.gx_rectangle_bottom - shift); |
109 |
|
|
|
110 |
✓✓ |
26706 |
if (return_position) |
111 |
|
|
{ |
112 |
|
26705 |
return_position -> gx_rectangle_left = |
113 |
|
26705 |
(GX_VALUE)(slider -> gx_widget_size.gx_rectangle_left + slider_info -> gx_slider_info_needle_inset); |
114 |
|
26705 |
return_position -> gx_rectangle_top = (GX_VALUE)(hotspot - slider_info -> gx_slider_info_needle_hotspot_offset); |
115 |
✓✓ |
26705 |
if (slider_info -> gx_slider_info_needle_width > 0) |
116 |
|
|
{ |
117 |
|
26703 |
return_position -> gx_rectangle_right = (GX_VALUE)(return_position -> gx_rectangle_left + slider_info -> gx_slider_info_needle_width - 1); |
118 |
|
26703 |
return_position -> gx_rectangle_bottom = (GX_VALUE)(return_position -> gx_rectangle_top + slider_info -> gx_slider_info_needle_height - 1); |
119 |
|
|
} |
120 |
|
|
else |
121 |
|
|
{ |
122 |
|
2 |
return_position -> gx_rectangle_right = slider -> gx_widget_size.gx_rectangle_right; |
123 |
|
2 |
return_position -> gx_rectangle_bottom = return_position -> gx_rectangle_top; |
124 |
|
|
} |
125 |
|
|
} |
126 |
|
|
} |
127 |
|
|
else |
128 |
|
|
{ |
129 |
|
|
/* calculate the position of the hotspot */ |
130 |
|
130401 |
hotspot = (GX_VALUE)(slider -> gx_widget_size.gx_rectangle_left + shift); |
131 |
|
|
|
132 |
✓✓ |
130401 |
if (return_position) |
133 |
|
|
{ |
134 |
|
130400 |
return_position -> gx_rectangle_top = |
135 |
|
130400 |
(GX_VALUE)(slider -> gx_widget_size.gx_rectangle_top + slider_info -> gx_slider_info_needle_inset); |
136 |
|
130400 |
return_position -> gx_rectangle_left = (GX_VALUE)(hotspot - slider_info -> gx_slider_info_needle_hotspot_offset); |
137 |
|
|
|
138 |
✓✓ |
130400 |
if (slider_info -> gx_slider_info_needle_width > 0) |
139 |
|
|
{ |
140 |
|
130387 |
return_position -> gx_rectangle_bottom = (GX_VALUE)(return_position -> gx_rectangle_top + slider_info -> gx_slider_info_needle_height - 1); |
141 |
|
130387 |
return_position -> gx_rectangle_right = (GX_VALUE)(return_position -> gx_rectangle_left + slider_info -> gx_slider_info_needle_width - 1); |
142 |
|
|
} |
143 |
|
|
else |
144 |
|
|
{ |
145 |
|
13 |
return_position -> gx_rectangle_bottom = slider -> gx_widget_size.gx_rectangle_bottom; |
146 |
|
13 |
return_position -> gx_rectangle_right = return_position -> gx_rectangle_left; |
147 |
|
|
} |
148 |
|
|
} |
149 |
|
|
} |
150 |
|
157107 |
return(GX_SUCCESS); |
151 |
|
|
} |
152 |
|
|
|