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 |
|
|
/** List Management (List) */ |
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 |
|
|
|
32 |
|
|
/**************************************************************************/ |
33 |
|
|
/* */ |
34 |
|
|
/* FUNCTION RELEASE */ |
35 |
|
|
/* */ |
36 |
|
|
/* _gx_vertical_list_up_wrap PORTABLE C */ |
37 |
|
|
/* 6.1 */ |
38 |
|
|
/* AUTHOR */ |
39 |
|
|
/* */ |
40 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
41 |
|
|
/* */ |
42 |
|
|
/* DESCRIPTION */ |
43 |
|
|
/* */ |
44 |
|
|
/* This function scrolls up the vertical list. */ |
45 |
|
|
/* */ |
46 |
|
|
/* INPUT */ |
47 |
|
|
/* */ |
48 |
|
|
/* vertical_list Vertical list control block */ |
49 |
|
|
/* */ |
50 |
|
|
/* OUTPUT */ |
51 |
|
|
/* */ |
52 |
|
|
/* None */ |
53 |
|
|
/* */ |
54 |
|
|
/* CALLS */ |
55 |
|
|
/* */ |
56 |
|
|
/* _gx_first_client_child_get Get the first client child */ |
57 |
|
|
/* _gx_last_client_child_get Get the last client child */ |
58 |
|
|
/* _gx_utility_rectangle_shift Move a rectangle */ |
59 |
|
|
/* [gx_vertical_list_callback] Invoke the list callback */ |
60 |
|
|
/* routine */ |
61 |
|
|
/* _gx_widget_resize Resize a widget */ |
62 |
|
|
/* _gx_widget_attach Attach a widget to its parent */ |
63 |
|
|
/* */ |
64 |
|
|
/* CALLED BY */ |
65 |
|
|
/* */ |
66 |
|
|
/* _gx_vertical_list_scroll Vertical list scroll function */ |
67 |
|
|
/* */ |
68 |
|
|
/* RELEASE HISTORY */ |
69 |
|
|
/* */ |
70 |
|
|
/* DATE NAME DESCRIPTION */ |
71 |
|
|
/* */ |
72 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
73 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
74 |
|
|
/* resulting in version 6.1 */ |
75 |
|
|
/* */ |
76 |
|
|
/**************************************************************************/ |
77 |
|
500 |
VOID _gx_vertical_list_up_wrap(GX_VERTICAL_LIST *list) |
78 |
|
|
{ |
79 |
|
|
GX_WIDGET *test; |
80 |
|
|
GX_WIDGET *check; |
81 |
|
500 |
GX_BOOL moving = GX_TRUE; |
82 |
|
|
GX_RECTANGLE newpos; |
83 |
|
|
INT index; |
84 |
|
|
|
85 |
✓✓ |
1384 |
while (moving) |
86 |
|
|
{ |
87 |
|
884 |
moving = GX_FALSE; |
88 |
|
|
|
89 |
✓✓ |
884 |
if ((list -> gx_vertical_list_top_index + list -> gx_vertical_list_child_count < list -> gx_vertical_list_total_rows) || |
90 |
✓✓ |
151 |
(list -> gx_widget_style & GX_STYLE_WRAP)) |
91 |
|
|
{ |
92 |
|
|
/* scrolling up. See if my top widget is already above my |
93 |
|
|
client area: */ |
94 |
|
|
|
95 |
|
836 |
test = _gx_widget_first_client_child_get((GX_WIDGET *)list); |
96 |
✓✗ |
836 |
if (test) |
97 |
|
|
{ |
98 |
✓✓ |
836 |
if (test -> gx_widget_size.gx_rectangle_bottom < list -> gx_widget_size.gx_rectangle_top) |
99 |
|
|
{ |
100 |
|
|
/* top widget is above my client area, move it to the bottom: */ |
101 |
|
384 |
moving = GX_TRUE; |
102 |
|
384 |
check = _gx_widget_last_client_child_get((GX_WIDGET *)list); |
103 |
|
|
|
104 |
|
384 |
_gx_widget_detach(test); |
105 |
|
|
|
106 |
|
384 |
newpos = test -> gx_widget_size; |
107 |
|
384 |
_gx_utility_rectangle_shift(&newpos, 0, (GX_VALUE)(check -> gx_widget_size.gx_rectangle_bottom - newpos.gx_rectangle_top + 1)); |
108 |
|
384 |
_gx_widget_resize(test, &newpos); |
109 |
|
|
|
110 |
|
384 |
index = list -> gx_vertical_list_top_index + list -> gx_vertical_list_child_count; |
111 |
|
|
|
112 |
|
|
/* Wrap index. */ |
113 |
✓✓ |
384 |
if (index >= list -> gx_vertical_list_total_rows) |
114 |
|
|
{ |
115 |
|
73 |
index -= list -> gx_vertical_list_total_rows; |
116 |
|
|
} |
117 |
|
|
|
118 |
|
384 |
list -> gx_vertical_list_callback(list, test, index); |
119 |
✓✓ |
384 |
if (index == list -> gx_vertical_list_selected) |
120 |
|
|
{ |
121 |
|
13 |
test -> gx_widget_style |= GX_STYLE_DRAW_SELECTED; |
122 |
|
|
} |
123 |
|
|
else |
124 |
|
|
{ |
125 |
|
371 |
test -> gx_widget_style &= ~GX_STYLE_DRAW_SELECTED; |
126 |
|
|
} |
127 |
|
384 |
_gx_widget_attach((GX_WIDGET *)list, test); |
128 |
|
384 |
list -> gx_vertical_list_top_index++; |
129 |
|
|
|
130 |
|
|
/* Wrao page index. */ |
131 |
✓✓ |
384 |
if (list -> gx_vertical_list_top_index >= list -> gx_vertical_list_total_rows) |
132 |
|
|
{ |
133 |
|
2 |
list -> gx_vertical_list_top_index -= list -> gx_vertical_list_total_rows; |
134 |
|
|
} |
135 |
|
|
} |
136 |
|
|
} |
137 |
|
|
} |
138 |
|
|
} |
139 |
|
500 |
} |
140 |
|
|
|