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