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_scrollbar.h" 32 33 /**************************************************************************/ 34 /* */ 35 /* FUNCTION RELEASE */ 36 /* */ 37 /* _gx_vertical_list_page_index_set PORTABLE C */ 38 /* 6.1 */ 39 /* AUTHOR */ 40 /* */ 41 /* Kenneth Maxwell, Microsoft Corporation */ 42 /* */ 43 /* DESCRIPTION */ 44 /* */ 45 /* This service sets the starting page index for vertical list. */ 46 /* */ 47 /* INPUT */ 48 /* */ 49 /* vertical_list Vertical list widget control */ 50 /* block */ 51 /* index The new top index */ 52 /* */ 53 /* OUTPUT */ 54 /* */ 55 /* status Completion status */ 56 /* */ 57 /* CALLS */ 58 /* */ 59 /* CALLED BY */ 60 /* */ 61 /* _gx_vertical_list_selected_set Process drop list event */ 62 /* */ 63 /* RELEASE HISTORY */ 64 /* */ 65 /* DATE NAME DESCRIPTION */ 66 /* */ 67 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ 68 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */ 69 /* resulting in version 6.1 */ 70 /* */ 71 /**************************************************************************/ _gx_vertical_list_page_index_set(GX_VERTICAL_LIST * list,INT index)72UINT _gx_vertical_list_page_index_set(GX_VERTICAL_LIST *list, INT index) 73 { 74 GX_WIDGET *child; 75 GX_SCROLLBAR *pScroll; 76 INT scroll_value; 77 78 if ((list -> gx_vertical_list_total_rows > 0) && 79 ((index <= list -> gx_vertical_list_total_rows - list -> gx_vertical_list_visible_rows) || (list -> gx_widget_style & GX_STYLE_WRAP))) 80 { 81 child = _gx_widget_first_client_child_get((GX_WIDGET *)list); 82 83 if (child) 84 { 85 scroll_value = child -> gx_widget_size.gx_rectangle_top; 86 scroll_value += (index - list -> gx_vertical_list_top_index) * list -> gx_vertical_list_child_height; 87 scroll_value = list -> gx_window_client.gx_rectangle_top - scroll_value; 88 89 /* Scroll to make index as the first visible entry. */ 90 _gx_vertical_list_scroll(list, scroll_value); 91 92 _gx_window_scrollbar_find((GX_WINDOW *)list, GX_TYPE_VERTICAL_SCROLL, &pScroll); 93 94 if (pScroll) 95 { 96 _gx_scrollbar_reset(pScroll, GX_NULL); 97 } 98 } 99 } 100 101 return GX_SUCCESS; 102 } 103 104