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