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 |
|
|
/** Scroll Wheel Management (Generic 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_widget.h" |
29 |
|
|
#include "gx_window.h" |
30 |
|
|
#include "gx_system.h" |
31 |
|
|
#include "gx_utility.h" |
32 |
|
|
#include "gx_scrollbar.h" |
33 |
|
|
#include "gx_scroll_wheel.h" |
34 |
|
|
|
35 |
|
|
/**************************************************************************/ |
36 |
|
|
/* */ |
37 |
|
|
/* FUNCTION RELEASE */ |
38 |
|
|
/* */ |
39 |
|
|
/* _gx_generic_scroll_wheel_total_rows_set PORTABLE C */ |
40 |
|
|
/* 6.1.7 */ |
41 |
|
|
/* AUTHOR */ |
42 |
|
|
/* */ |
43 |
|
|
/* Ting Zhu, Microsoft Corporation */ |
44 |
|
|
/* */ |
45 |
|
|
/* DESCRIPTION */ |
46 |
|
|
/* */ |
47 |
|
|
/* This function assigns total number of the generic scroll wheel. */ |
48 |
|
|
/* */ |
49 |
|
|
/* INPUT */ |
50 |
|
|
/* */ |
51 |
|
|
/* wheel Scroll Wheel control block */ |
52 |
|
|
/* count Number of rows */ |
53 |
|
|
/* */ |
54 |
|
|
/* OUTPUT */ |
55 |
|
|
/* */ |
56 |
|
|
/* status Completion status */ |
57 |
|
|
/* */ |
58 |
|
|
/* CALLS */ |
59 |
|
|
/* */ |
60 |
|
|
/* _gx_widget_hide Hide a widget */ |
61 |
|
|
/* _gx_widget_first_visible_client_child_get */ |
62 |
|
|
/* Get the first visible client */ |
63 |
|
|
/* _gx_widget_next_visible_client_child_get */ |
64 |
|
|
/* Get the next visible client */ |
65 |
|
|
/* _gx_generic_scroll_wheel_children_position */ |
66 |
|
|
/* Position the children of the */ |
67 |
|
|
/* generic scroll wheel */ |
68 |
|
|
/* _gx_system_dirty_mark Mark the widget dirty */ |
69 |
|
|
/* */ |
70 |
|
|
/* CALLED BY */ |
71 |
|
|
/* */ |
72 |
|
|
/* GUIX Internal Code */ |
73 |
|
|
/* */ |
74 |
|
|
/**************************************************************************/ |
75 |
|
34 |
UINT _gx_generic_scroll_wheel_total_rows_set(GX_GENERIC_SCROLL_WHEEL *wheel, INT count) |
76 |
|
|
{ |
77 |
|
|
INT row; |
78 |
|
|
GX_WIDGET *test; |
79 |
|
|
|
80 |
|
|
/* Update total count of rows. */ |
81 |
|
34 |
wheel -> gx_scroll_wheel_total_rows = count; |
82 |
|
|
|
83 |
|
|
/* Update selected row. */ |
84 |
✓✓ |
34 |
if (count == 0) |
85 |
|
|
{ |
86 |
|
8 |
wheel -> gx_scroll_wheel_selected_row = 0; |
87 |
|
|
} |
88 |
✓✓ |
26 |
else if (wheel -> gx_scroll_wheel_selected_row >= count) |
89 |
|
|
{ |
90 |
|
3 |
wheel -> gx_scroll_wheel_selected_row = count - 1; |
91 |
|
|
} |
92 |
|
|
|
93 |
|
|
/* Rreset child count and make all children visible. */ |
94 |
|
34 |
wheel -> gx_generic_scroll_wheel_child_count = 0; |
95 |
|
|
|
96 |
|
34 |
test = _gx_widget_first_client_child_get((GX_WIDGET *)wheel); |
97 |
|
|
|
98 |
✓✓ |
284 |
while (test) |
99 |
|
|
{ |
100 |
✓✓ |
250 |
if (!(test->gx_widget_status & GX_STATUS_VISIBLE)) |
101 |
|
|
{ |
102 |
|
106 |
_gx_widget_show(test); |
103 |
|
|
} |
104 |
|
|
|
105 |
|
250 |
wheel->gx_generic_scroll_wheel_child_count++; |
106 |
|
|
|
107 |
|
250 |
test = _gx_widget_next_client_child_get(test); |
108 |
|
|
} |
109 |
|
|
|
110 |
|
34 |
test = wheel -> gx_widget_last_child; |
111 |
|
|
|
112 |
|
|
/* Check whether list child count is larger than count. */ |
113 |
✓✓✓✓
|
144 |
while (test && (wheel -> gx_generic_scroll_wheel_child_count > count)) |
114 |
|
|
{ |
115 |
✓✓ |
110 |
if (!(test -> gx_widget_status & GX_STATUS_NONCLIENT)) |
116 |
|
|
{ |
117 |
|
109 |
_gx_widget_hide(test); |
118 |
|
109 |
wheel -> gx_generic_scroll_wheel_child_count--; |
119 |
|
|
} |
120 |
|
|
|
121 |
|
110 |
test = test -> gx_widget_previous; |
122 |
|
|
} |
123 |
|
|
|
124 |
|
34 |
wheel -> gx_generic_scroll_wheel_top_index = 0; |
125 |
|
|
|
126 |
✓✓ |
34 |
if (wheel -> gx_generic_scroll_wheel_callback) |
127 |
|
|
{ |
128 |
|
|
|
129 |
|
|
/* Re-populate list child. */ |
130 |
|
22 |
row = 0; |
131 |
|
|
|
132 |
|
22 |
test = _gx_widget_first_visible_client_child_get((GX_WIDGET *)wheel); |
133 |
|
|
|
134 |
✓✓ |
111 |
while (test) |
135 |
|
|
{ |
136 |
|
|
/* Reset child id. */ |
137 |
|
89 |
test -> gx_widget_style &= ~GX_STYLE_DRAW_SELECTED; |
138 |
|
89 |
wheel -> gx_generic_scroll_wheel_callback(wheel, test, row++); |
139 |
|
|
|
140 |
|
89 |
test = _gx_widget_next_visible_client_child_get(test); |
141 |
|
|
} |
142 |
|
|
} |
143 |
|
|
|
144 |
|
34 |
_gx_generic_scroll_wheel_children_position(wheel); |
145 |
|
|
|
146 |
|
|
/* Refresh screen. */ |
147 |
✓✓ |
34 |
if (wheel -> gx_widget_status & GX_STATUS_VISIBLE) |
148 |
|
|
{ |
149 |
|
32 |
_gx_system_dirty_mark((GX_WIDGET *)wheel); |
150 |
|
|
} |
151 |
|
34 |
return GX_SUCCESS; |
152 |
|
|
} |
153 |
|
|
|