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 /** System Management (System) */ 18 /** */ 19 /**************************************************************************/ 20 21 #define GX_SOURCE_CODE 22 23 24 /* Include necessary system files. */ 25 26 #include "gx_api.h" 27 #include "gx_utility.h" 28 #include "gx_system.h" 29 #include "gx_widget.h" 30 31 32 /**************************************************************************/ 33 /* */ 34 /* FUNCTION RELEASE */ 35 /* */ 36 /* _gx_system_top_widget_find PORTABLE C */ 37 /* 6.1 */ 38 /* AUTHOR */ 39 /* */ 40 /* Kenneth Maxwell, Microsoft Corporation */ 41 /* */ 42 /* DESCRIPTION */ 43 /* */ 44 /* This function finds the top widget that contains the test point. */ 45 /* */ 46 /* INPUT */ 47 /* */ 48 /* root Widget pointer */ 49 /* test_point Point to search for */ 50 /* status Widget status to match */ 51 /* */ 52 /* OUTPUT */ 53 /* */ 54 /* GX_WIDGET Pointer to found widget */ 55 /* */ 56 /* CALLS */ 57 /* */ 58 /* _gx_utility_rectangle_point_detect Detect point in rectangle */ 59 /* */ 60 /* CALLED BY */ 61 /* */ 62 /* _gx_system_event_dispatch Dispatch GUIX events */ 63 /* */ 64 /* RELEASE HISTORY */ 65 /* */ 66 /* DATE NAME DESCRIPTION */ 67 /* */ 68 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ 69 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */ 70 /* resulting in version 6.1 */ 71 /* */ 72 /**************************************************************************/ _gx_system_top_widget_find(GX_WIDGET * root,GX_POINT test_point,ULONG status)73GX_WIDGET *_gx_system_top_widget_find(GX_WIDGET *root, GX_POINT test_point, ULONG status) 74 { 75 76 GX_WIDGET *test; 77 GX_WIDGET *winner = GX_NULL; 78 79 /* Setup test widget pointer to the last child. */ 80 test = root -> gx_widget_last_child; 81 82 /* Loop through the widgets in reverse order. */ 83 while (test) 84 { 85 if (test -> gx_widget_status & GX_STATUS_VISIBLE) 86 { 87 /* Is the point in this widget? */ 88 if (_gx_utility_rectangle_point_detect(&test -> gx_widget_clip, test_point)) 89 { 90 /* Yes, pickup the last child of this widget. */ 91 root = test; 92 test = root -> gx_widget_last_child; 93 94 if (status) 95 { 96 if (root -> gx_widget_status & status) 97 { 98 winner = root; 99 } 100 } 101 else 102 { 103 winner = root; 104 } 105 continue; 106 } 107 } 108 109 /* Move to the previous widget. */ 110 test = test -> gx_widget_previous; 111 } 112 113 /* Return the root widget. */ 114 return(winner); 115 } 116 117