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 /** Vertical List (Lists) */ 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_scrollbar.h" 31 32 /**************************************************************************/ 33 /* */ 34 /* FUNCTION RELEASE */ 35 /* */ 36 /* _gx_vertical_list_selected_widget_get PORTABLE C */ 37 /* 6.1 */ 38 /* AUTHOR */ 39 /* */ 40 /* Kenneth Maxwell, Microsoft Corporation */ 41 /* */ 42 /* DESCRIPTION */ 43 /* */ 44 /* This service gets the list entry at the current list index. */ 45 /* */ 46 /* INPUT */ 47 /* */ 48 /* vertical_list Vertical list widget control */ 49 /* block */ 50 /* return_list_entry Destination for return list */ 51 /* entry widget */ 52 /* */ 53 /* OUTPUT */ 54 /* */ 55 /* status Completion status */ 56 /* */ 57 /* CALLS */ 58 /* */ 59 /* None */ 60 /* */ 61 /* CALLED BY */ 62 /* */ 63 /* Application Code */ 64 /* */ 65 /* RELEASE HISTORY */ 66 /* */ 67 /* DATE NAME DESCRIPTION */ 68 /* */ 69 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ 70 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */ 71 /* resulting in version 6.1 */ 72 /* */ 73 /**************************************************************************/ _gx_vertical_list_selected_widget_get(GX_VERTICAL_LIST * vertical_list,GX_WIDGET ** return_list_entry)74UINT _gx_vertical_list_selected_widget_get(GX_VERTICAL_LIST *vertical_list, 75 GX_WIDGET **return_list_entry) 76 { 77 INT page_index; 78 GX_WIDGET *child = _gx_widget_first_client_child_get((GX_WIDGET *)vertical_list); 79 80 if (vertical_list -> gx_vertical_list_selected < vertical_list -> gx_vertical_list_top_index) 81 { 82 page_index = vertical_list -> gx_vertical_list_total_rows - vertical_list -> gx_vertical_list_top_index; 83 page_index += vertical_list -> gx_vertical_list_selected; 84 } 85 else 86 { 87 page_index = vertical_list -> gx_vertical_list_selected - vertical_list -> gx_vertical_list_top_index; 88 } 89 while (child && page_index > 0) 90 { 91 child = _gx_widget_next_client_child_get(child); 92 page_index--; 93 } 94 95 *return_list_entry = child; 96 97 if (child) 98 { 99 return GX_SUCCESS; 100 } 101 return GX_FAILURE; 102 } 103 104