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 |
|
|
/** Scroll Wheel Management (Scroll Wheel) */ |
18 |
|
|
/** */ |
19 |
|
|
/**************************************************************************/ |
20 |
|
|
|
21 |
|
|
#define GX_SOURCE_CODE |
22 |
|
|
|
23 |
|
|
|
24 |
|
|
/* Include necessary system files. */ |
25 |
|
|
|
26 |
|
|
#include "gx_api.h" |
27 |
|
|
#include "gx_scroll_wheel.h" |
28 |
|
|
|
29 |
|
|
/**************************************************************************/ |
30 |
|
|
/* */ |
31 |
|
|
/* FUNCTION RELEASE */ |
32 |
|
|
/* */ |
33 |
|
|
/* _gx_scroll_wheel_selected_row_calculate PORTABLE C */ |
34 |
|
|
/* 6.1.7 */ |
35 |
|
|
/* AUTHOR */ |
36 |
|
|
/* */ |
37 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
38 |
|
|
/* */ |
39 |
|
|
/* DESCRIPTION */ |
40 |
|
|
/* */ |
41 |
|
|
/* This function calculates the current selected row for scroll wheel */ |
42 |
|
|
/* widget. */ |
43 |
|
|
/* */ |
44 |
|
|
/* INPUT */ |
45 |
|
|
/* */ |
46 |
|
|
/* wheel Scroll wheel control block */ |
47 |
|
|
/* */ |
48 |
|
|
/* OUTPUT */ |
49 |
|
|
/* */ |
50 |
|
|
/* status Completion status */ |
51 |
|
|
/* */ |
52 |
|
|
/* CALLS */ |
53 |
|
|
/* */ |
54 |
|
|
/* None */ |
55 |
|
|
/* */ |
56 |
|
|
/* CALLED BY */ |
57 |
|
|
/* */ |
58 |
|
|
/* _gx_text_scroll_wheel_scroll */ |
59 |
|
|
/* */ |
60 |
|
|
/* RELEASE HISTORY */ |
61 |
|
|
/* */ |
62 |
|
|
/* DATE NAME DESCRIPTION */ |
63 |
|
|
/* */ |
64 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
65 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
66 |
|
|
/* resulting in version 6.1 */ |
67 |
|
|
/* 06-02-2021 Ting Zhu Modified comment(s), */ |
68 |
|
|
/* modified wrap style test */ |
69 |
|
|
/* logic, */ |
70 |
|
|
/* resulting in version 6.1.7 */ |
71 |
|
|
/* */ |
72 |
|
|
/**************************************************************************/ |
73 |
|
559 |
UINT _gx_scroll_wheel_selected_row_calculate(GX_SCROLL_WHEEL *wheel) |
74 |
|
|
{ |
75 |
|
|
INT yshift; |
76 |
|
|
INT selected_row; |
77 |
|
559 |
GX_VALUE half_row_height = (wheel -> gx_scroll_wheel_row_height >> 1); |
78 |
|
|
|
79 |
|
559 |
yshift = wheel -> gx_scroll_wheel_selected_yshift; |
80 |
|
559 |
selected_row = wheel -> gx_scroll_wheel_selected_row; |
81 |
|
|
|
82 |
✓✓ |
559 |
if (wheel -> gx_scroll_wheel_wrap_style_check(wheel)) |
83 |
|
|
{ |
84 |
✓✓ |
228 |
while (yshift > half_row_height) |
85 |
|
|
{ |
86 |
|
|
/* Scroll Down. */ |
87 |
|
69 |
yshift -= wheel -> gx_scroll_wheel_row_height; |
88 |
|
69 |
selected_row--; |
89 |
|
|
} |
90 |
|
|
|
91 |
✓✓ |
206 |
while (yshift < -half_row_height) |
92 |
|
|
{ |
93 |
|
|
/* Scroll Up. */ |
94 |
|
47 |
yshift += wheel -> gx_scroll_wheel_row_height; |
95 |
|
47 |
selected_row++; |
96 |
|
|
} |
97 |
|
|
|
98 |
✓✓ |
169 |
while (selected_row > wheel -> gx_scroll_wheel_total_rows - 1) |
99 |
|
|
{ |
100 |
|
10 |
selected_row -= wheel -> gx_scroll_wheel_total_rows; |
101 |
|
|
} |
102 |
|
|
|
103 |
✓✓ |
172 |
while (selected_row < 0) |
104 |
|
|
{ |
105 |
|
13 |
selected_row += wheel -> gx_scroll_wheel_total_rows; |
106 |
|
|
} |
107 |
|
|
} |
108 |
|
|
else |
109 |
|
|
{ |
110 |
✓✓✓✓
|
484 |
while ((yshift > half_row_height) && |
111 |
|
|
(selected_row > 0)) |
112 |
|
|
{ |
113 |
|
|
/* Scroll Down. */ |
114 |
|
84 |
yshift -= wheel -> gx_scroll_wheel_row_height; |
115 |
|
84 |
selected_row--; |
116 |
|
|
} |
117 |
|
|
|
118 |
✓✓ |
497 |
while ((yshift < -half_row_height) && |
119 |
✓✓ |
109 |
(selected_row < wheel -> gx_scroll_wheel_total_rows - 1)) |
120 |
|
|
{ |
121 |
|
|
/* Scroll Up. */ |
122 |
|
97 |
yshift += wheel -> gx_scroll_wheel_row_height; |
123 |
|
97 |
selected_row++; |
124 |
|
|
} |
125 |
|
|
} |
126 |
|
|
|
127 |
|
559 |
wheel -> gx_scroll_wheel_selected_row = selected_row; |
128 |
|
559 |
wheel -> gx_scroll_wheel_selected_yshift = (GX_VALUE)yshift; |
129 |
|
|
|
130 |
|
559 |
return GX_SUCCESS; |
131 |
|
|
} |
132 |
|
|
|