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_system.h" 28 #include "gx_widget.h" 29 #include "gx_utility.h" 30 31 32 /**************************************************************************/ 33 /* */ 34 /* FUNCTION RELEASE */ 35 /* */ 36 /* _gx_widget_unlink PORTABLE C */ 37 /* 6.1 */ 38 /* AUTHOR */ 39 /* */ 40 /* Kenneth Maxwell, Microsoft Corporation */ 41 /* */ 42 /* DESCRIPTION */ 43 /* */ 44 /* This function unlinks a widget. */ 45 /* */ 46 /* INPUT */ 47 /* */ 48 /* widget Widget control block */ 49 /* */ 50 /* OUTPUT */ 51 /* */ 52 /* GX_WIDET * Widget being unlinked */ 53 /* */ 54 /* CALLS */ 55 /* */ 56 /* None */ 57 /* */ 58 /* CALLED BY */ 59 /* */ 60 /* GUIX Internal Code */ 61 /* */ 62 /* RELEASE HISTORY */ 63 /* */ 64 /* DATE NAME DESCRIPTION */ 65 /* */ 66 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ 67 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */ 68 /* resulting in version 6.1 */ 69 /* */ 70 /**************************************************************************/ _gx_widget_unlink(GX_WIDGET * widget)71GX_WIDGET *_gx_widget_unlink(GX_WIDGET *widget) 72 { 73 74 GX_WIDGET *sibling; 75 GX_WIDGET *parent; 76 77 /* Determine if the widget has a parent. */ 78 parent = widget -> gx_widget_parent; 79 80 if (parent) 81 { 82 /* Is this widget the first child? */ 83 if (parent -> gx_widget_first_child == widget) 84 { 85 /* Yes, unlink and done*/ 86 parent -> gx_widget_first_child = widget -> gx_widget_next; 87 if (parent -> gx_widget_first_child) 88 { 89 parent -> gx_widget_first_child -> gx_widget_previous = GX_NULL; 90 } 91 92 /* if last was also pointing at this widget, then it was the only 93 child. Update last pointer: */ 94 if (parent -> gx_widget_last_child == widget) 95 { 96 parent -> gx_widget_last_child = parent -> gx_widget_first_child; 97 } 98 } 99 else 100 { 101 sibling = parent -> gx_widget_first_child; 102 103 while (sibling -> gx_widget_next != widget) 104 { 105 sibling = sibling -> gx_widget_next; 106 } 107 sibling -> gx_widget_next = widget -> gx_widget_next; 108 109 if (parent -> gx_widget_last_child == widget) 110 { 111 parent -> gx_widget_last_child = sibling; 112 } 113 114 if (sibling -> gx_widget_next) 115 { 116 sibling -> gx_widget_next -> gx_widget_previous = sibling; 117 } 118 } 119 if (widget -> gx_widget_status & GX_STATUS_VISIBLE) 120 { 121 _gx_widget_hide(widget); 122 } 123 widget -> gx_widget_parent = GX_NULL; 124 widget -> gx_widget_next = GX_NULL; 125 widget -> gx_widget_previous = GX_NULL; 126 widget -> gx_widget_nav_next = GX_NULL; 127 widget -> gx_widget_nav_previous = GX_NULL; 128 } 129 /* Return widget pointer */ 130 return(widget); 131 } 132 133