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 /**   Vertical 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 /* #include "gx_scrollbar.h"  */
33 
34 /**************************************************************************/
35 /*                                                                        */
36 /*  FUNCTION                                               RELEASE        */
37 /*                                                                        */
38 /*    _gx_vertical_list_down_wrap                         PORTABLE C      */
39 /*                                                           6.1          */
40 /*  AUTHOR                                                                */
41 /*                                                                        */
42 /*    Kenneth Maxwell, Microsoft Corporation                              */
43 /*                                                                        */
44 /*  DESCRIPTION                                                           */
45 /*                                                                        */
46 /*    This function scrolls down the vertical list.                       */
47 /*                                                                        */
48 /*  INPUT                                                                 */
49 /*                                                                        */
50 /*    list                                  Vertical list control 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_style_remove               Remove a style flag           */
61 /*    _gx_widget_back_attach                Attach a widget to the back   */
62 /*    _gx_widget_shift                      Relocate a widget             */
63 /*    [gx_vertical_list_callback]           Vertical list callback        */
64 /*                                                                        */
65 /*  CALLED BY                                                             */
66 /*                                                                        */
67 /*    GUIX Internal Code                                                  */
68 /*                                                                        */
69 /*  RELEASE HISTORY                                                       */
70 /*                                                                        */
71 /*    DATE              NAME                      DESCRIPTION             */
72 /*                                                                        */
73 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
74 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
75 /*                                            resulting in version 6.1    */
76 /*                                                                        */
77 /**************************************************************************/
_gx_vertical_list_down_wrap(GX_VERTICAL_LIST * list)78 VOID _gx_vertical_list_down_wrap(GX_VERTICAL_LIST *list)
79 {
80 GX_WIDGET   *test;
81 GX_WIDGET   *check;
82 GX_BOOL      moving = GX_TRUE;
83 GX_RECTANGLE newpos;
84 
85     while (moving)
86     {
87         moving = GX_FALSE;
88 
89         if ((list -> gx_vertical_list_top_index > 0) ||
90             (list -> gx_widget_style & GX_STYLE_WRAP))
91         {
92             /* scrolling down, see if my bottom widget can be moved to the top: */
93             test = _gx_widget_last_client_child_get((GX_WIDGET *)list);
94 
95             if (test)
96             {
97                 if ((test -> gx_widget_size.gx_rectangle_top > list -> gx_widget_size.gx_rectangle_bottom))
98                 {
99                     /* bottom widget is below my client area, move it to the top: */
100                     moving = GX_TRUE;
101                     list -> gx_vertical_list_top_index--;
102 
103                     /* Wrap index. */
104                     if (list -> gx_vertical_list_top_index < 0)
105                     {
106                         list -> gx_vertical_list_top_index  = list -> gx_vertical_list_total_rows - 1;
107                     }
108 
109                     check = _gx_widget_first_client_child_get((GX_WIDGET *)list);
110 
111                     if (check)
112                     {
113                         _gx_widget_detach(test);
114                         newpos = test -> gx_widget_size;
115                         _gx_utility_rectangle_shift(&newpos, 0, (GX_VALUE)(-(newpos.gx_rectangle_bottom - check -> gx_widget_size.gx_rectangle_top + 1)));
116                         _gx_widget_resize(test, &newpos);
117 
118                         list -> gx_vertical_list_callback(list, test, list -> gx_vertical_list_top_index);
119                         if (list -> gx_vertical_list_selected == list -> gx_vertical_list_top_index)
120                         {
121                             test -> gx_widget_style |=  GX_STYLE_DRAW_SELECTED;
122                         }
123                         else
124                         {
125                             test -> gx_widget_style &= ~GX_STYLE_DRAW_SELECTED;
126                         }
127                         _gx_widget_back_attach((GX_WIDGET *)list, test);
128                     }
129                     else
130                     {
131                         break;
132                     }
133                 }
134             }
135         }
136     }
137 }
138 
139