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 /** Horizontal List (List) */ 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_horizontal_list_selected_visible PORTABLE C */ 37 /* 6.1 */ 38 /* AUTHOR */ 39 /* */ 40 /* Kenneth Maxwell, Microsoft Corporation */ 41 /* */ 42 /* DESCRIPTION */ 43 /* */ 44 /* This service sets the list entry at the current list index. */ 45 /* */ 46 /* INPUT */ 47 /* */ 48 /* horizontal_list Horizontal list widget */ 49 /* control block */ 50 /* list_entry Pointer to new list entry */ 51 /* */ 52 /* OUTPUT */ 53 /* */ 54 /* status Completion status */ 55 /* */ 56 /* CALLS */ 57 /* */ 58 /* _gx_widget_event_generate Creates a new GX_EVENT */ 59 /* _gx_system_dirty_mark Mark the widget dirty */ 60 /* */ 61 /* CALLED BY */ 62 /* */ 63 /* _gx_horizontal_list_event_process */ 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_horizontal_list_selected_visible(GX_HORIZONTAL_LIST * list,GX_WIDGET * child)74VOID _gx_horizontal_list_selected_visible(GX_HORIZONTAL_LIST *list, GX_WIDGET *child) 75 { 76 GX_SCROLLBAR *pScroll; 77 GX_BOOL update_scroll = GX_FALSE; 78 79 if (child -> gx_widget_size.gx_rectangle_left < list -> gx_window_client.gx_rectangle_left) 80 { 81 /* need to scroll children down */ 82 _gx_horizontal_list_scroll(list, list -> gx_window_client.gx_rectangle_left - child -> gx_widget_size.gx_rectangle_left); 83 update_scroll = GX_TRUE; 84 } 85 else 86 { 87 if (child -> gx_widget_size.gx_rectangle_right > list -> gx_window_client.gx_rectangle_right) 88 { 89 /* need to scroll children up */ 90 _gx_horizontal_list_scroll(list, list -> gx_window_client.gx_rectangle_right - child -> gx_widget_size.gx_rectangle_right); 91 update_scroll = GX_TRUE; 92 } 93 } 94 95 if (update_scroll) 96 { 97 _gx_window_scrollbar_find((GX_WINDOW *)list, GX_TYPE_HORIZONTAL_SCROLL, &pScroll); 98 99 if (pScroll) 100 { 101 _gx_scrollbar_reset(pScroll, GX_NULL); 102 } 103 } 104 } 105 106