1 /**************************************************************************/
2 /* */
3 /* Copyright (c) Microsoft Corporation. All rights reserved. */
4 /* */
5 /* This software is licensed under the Microsoft Software License */
6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */
7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
8 /* and in the root directory of this software. */
9 /* */
10 /**************************************************************************/
11
12
13 /**************************************************************************/
14 /**************************************************************************/
15 /** */
16 /** GUIX Component */
17 /** */
18 /** Horizontal List (List) */
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
33 /**************************************************************************/
34 /* */
35 /* FUNCTION RELEASE */
36 /* */
37 /* _gx_horizontal_list_right_wrap PORTABLE C */
38 /* 6.1 */
39 /* AUTHOR */
40 /* */
41 /* Kenneth Maxwell, Microsoft Corporation */
42 /* */
43 /* DESCRIPTION */
44 /* */
45 /* This function scrolls down the horizontal list. */
46 /* */
47 /* INPUT */
48 /* */
49 /* list horizontal list widget control*/
50 /* block */
51 /* */
52 /* OUTPUT */
53 /* */
54 /* None */
55 /* */
56 /* CALLS */
57 /* */
58 /* _gx_last_client_child_get Get the last client child */
59 /* _gx_first_client_child_get Get the first client child */
60 /* _gx_widget_back_attach Attach a widget to the back */
61 /* _gx_widget_shift Relocate a widget */
62 /* [gx_horizontal_list_callback] Horizontal list callback */
63 /* */
64 /* CALLED BY */
65 /* */
66 /* _gx_horizontal_list_scroll */
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 /**************************************************************************/
_gx_horizontal_list_right_wrap(GX_HORIZONTAL_LIST * list)77 VOID _gx_horizontal_list_right_wrap(GX_HORIZONTAL_LIST *list)
78 {
79 GX_WIDGET *test;
80 GX_WIDGET *check;
81 GX_BOOL moving = GX_TRUE;
82 GX_RECTANGLE newpos;
83
84 while (moving)
85 {
86 moving = GX_FALSE;
87
88 if ((list -> gx_horizontal_list_top_index > 0) ||
89 (list -> gx_widget_style & GX_STYLE_WRAP))
90 {
91 /* scrolling down, see if my bottom widget can be moved to the top: */
92 test = _gx_widget_last_client_child_get((GX_WIDGET *)list);
93
94 if (test)
95 {
96 if (test -> gx_widget_size.gx_rectangle_left > list -> gx_widget_size.gx_rectangle_right)
97 {
98 /* right widget is to the right of my client area, move it to the top: */
99 moving = GX_TRUE;
100 list -> gx_horizontal_list_top_index--;
101
102 /* Wrap index. */
103 if (list -> gx_horizontal_list_top_index < 0)
104 {
105 list -> gx_horizontal_list_top_index = list -> gx_horizontal_list_total_columns - 1;
106 }
107
108 check = _gx_widget_first_client_child_get((GX_WIDGET *)list);
109
110 if (check)
111 {
112 _gx_widget_detach(test);
113 newpos = test -> gx_widget_size;
114 _gx_utility_rectangle_shift(&newpos,
115 (GX_VALUE)(-(newpos.gx_rectangle_right -
116 check -> gx_widget_size.gx_rectangle_left + 1)), 0);
117 _gx_widget_resize(test, &newpos);
118
119 list -> gx_horizontal_list_callback(list, test, list -> gx_horizontal_list_top_index);
120 if (list -> gx_horizontal_list_selected == list -> gx_horizontal_list_top_index)
121 {
122 test -> gx_widget_style |= GX_STYLE_DRAW_SELECTED;
123 }
124 else
125 {
126 test -> gx_widget_style &= ~GX_STYLE_DRAW_SELECTED;
127 }
128 _gx_widget_back_attach((GX_WIDGET *)list, test);
129 }
130 else
131 {
132 break;
133 }
134 }
135 }
136 }
137 }
138 }
139
140