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 /** Widget Management (Widget) */ 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 29 30 /**************************************************************************/ 31 /* */ 32 /* FUNCTION RELEASE */ 33 /* */ 34 /* _gx_widget_find PORTABLE C */ 35 /* 6.1 */ 36 /* AUTHOR */ 37 /* */ 38 /* Kenneth Maxwell, Microsoft Corporation */ 39 /* */ 40 /* DESCRIPTION */ 41 /* */ 42 /* This service searches for the specified widget. */ 43 /* */ 44 /* INPUT */ 45 /* */ 46 /* parent Pointer to parent widget to */ 47 /* start search from */ 48 /* widget_id Widget ID */ 49 /* search_depth how many generations to search*/ 50 /* return_widget Pointer to destination for */ 51 /* found widget */ 52 /* */ 53 /* OUTPUT */ 54 /* */ 55 /* status Completion status */ 56 /* */ 57 /* CALLS */ 58 /* */ 59 /* _gx_widget_find Find the specified widget */ 60 /* */ 61 /* CALLED BY */ 62 /* */ 63 /* Application Code */ 64 /* GUIX Internal Code */ 65 /* */ 66 /* RELEASE HISTORY */ 67 /* */ 68 /* DATE NAME DESCRIPTION */ 69 /* */ 70 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ 71 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */ 72 /* resulting in version 6.1 */ 73 /* */ 74 /**************************************************************************/ _gx_widget_find(GX_WIDGET * parent,USHORT widget_id,INT search_depth,GX_WIDGET ** return_widget)75UINT _gx_widget_find(GX_WIDGET *parent, USHORT widget_id, INT search_depth, GX_WIDGET **return_widget) 76 { 77 GX_WIDGET *child; 78 79 *return_widget = GX_NULL; 80 81 /* Is there a widget? */ 82 if (parent) 83 { 84 child = parent -> gx_widget_first_child; 85 86 while (child) 87 { 88 if (child -> gx_widget_id == widget_id) 89 { 90 *return_widget = child; 91 return(GX_SUCCESS); 92 } 93 if (search_depth > 0) 94 { 95 if (child -> gx_widget_first_child) 96 { 97 child = child -> gx_widget_first_child; 98 search_depth--; 99 continue; 100 } 101 } 102 103 while ((child -> gx_widget_next == GX_NULL) && (child != parent)) 104 { 105 search_depth++; 106 child = child -> gx_widget_parent; 107 } 108 109 if (child == parent) 110 { 111 break; 112 } 113 114 child = child -> gx_widget_next; 115 } 116 } 117 return(GX_NOT_FOUND); 118 } 119 120