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_left_wrap PORTABLE C */ 38 /* 6.1 */ 39 /* AUTHOR */ 40 /* */ 41 /* Kenneth Maxwell, Microsoft Corporation */ 42 /* */ 43 /* DESCRIPTION */ 44 /* */ 45 /* This function scrolls up 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_first_client_child_get Get the first client child */ 59 /* _gx_last_client_child_get Get the last client child */ 60 /* _gx_widget_front_move Move widget to the front */ 61 /* _gx_widget_shift Shift 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_left_wrap(GX_HORIZONTAL_LIST * list)77VOID _gx_horizontal_list_left_wrap(GX_HORIZONTAL_LIST *list) 78 { 79 GX_WIDGET *test; 80 GX_WIDGET *check; 81 GX_RECTANGLE newpos; 82 GX_BOOL moving = GX_TRUE; 83 INT index; 84 85 while (moving) 86 { 87 moving = GX_FALSE; 88 89 if ((list -> gx_horizontal_list_top_index + list -> gx_horizontal_list_child_count < list -> gx_horizontal_list_total_columns) || 90 (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 test = _gx_widget_first_client_child_get((GX_WIDGET *)list); 96 if (test) 97 { 98 if (test -> gx_widget_size.gx_rectangle_right < list -> gx_widget_size.gx_rectangle_left) 99 { 100 /* left widget is left of my client area, move it to the right: */ 101 102 moving = GX_TRUE; 103 check = _gx_widget_last_client_child_get((GX_WIDGET *)list); 104 105 _gx_widget_detach(test); 106 107 newpos = test -> gx_widget_size; 108 _gx_utility_rectangle_shift(&newpos, 109 (GX_VALUE)(check -> gx_widget_size.gx_rectangle_right - 110 test -> gx_widget_size.gx_rectangle_left + 1), 111 0); 112 _gx_widget_resize(test, &newpos); 113 114 index = list -> gx_horizontal_list_top_index + list -> gx_horizontal_list_child_count; 115 116 /* Wrap index. */ 117 if (index >= list -> gx_horizontal_list_total_columns) 118 { 119 index -= list -> gx_horizontal_list_total_columns; 120 } 121 122 list -> gx_horizontal_list_callback(list, test, index); 123 if (index == list -> gx_horizontal_list_selected) 124 { 125 test -> gx_widget_style |= GX_STYLE_DRAW_SELECTED; 126 } 127 else 128 { 129 test -> gx_widget_style &= ~GX_STYLE_DRAW_SELECTED; 130 } 131 _gx_widget_attach((GX_WIDGET *)list, test); 132 list -> gx_horizontal_list_top_index++; 133 134 /* Wrap page index. */ 135 if (list -> gx_horizontal_list_top_index >= list -> gx_horizontal_list_total_columns) 136 { 137 list -> gx_horizontal_list_top_index -= list -> gx_horizontal_list_total_columns; 138 } 139 } 140 } 141 } 142 } 143 } 144 145