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_attach PORTABLE C */
37 /* 6.1 */
38 /* AUTHOR */
39 /* */
40 /* Kenneth Maxwell, Microsoft Corporation */
41 /* */
42 /* DESCRIPTION */
43 /* */
44 /* This function attached a widget to it's parent, putting the child */
45 /* in front of all siblings. */
46 /* */
47 /* INPUT */
48 /* */
49 /* parent Parent widget control block */
50 /* child child widget control block */
51 /* */
52 /* OUTPUT */
53 /* */
54 /* status Completion status */
55 /* */
56 /* CALLS */
57 /* */
58 /* _gx_system_lock Obtain GUIX system lock */
59 /* _gx_widget_detach Detach from current parent */
60 /* _gx_widget_link Link widget */
61 /* _gx_system_unlock Release GUIX system lock */
62 /* */
63 /* CALLED BY */
64 /* */
65 /* Application Code */
66 /* GUIX Internal Code */
67 /* */
68 /* RELEASE HISTORY */
69 /* */
70 /* DATE NAME DESCRIPTION */
71 /* */
72 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
73 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
74 /* resulting in version 6.1 */
75 /* */
76 /**************************************************************************/
77
_gx_widget_attach(GX_WIDGET * parent,GX_WIDGET * child)78 UINT _gx_widget_attach(GX_WIDGET *parent, GX_WIDGET *child)
79 {
80 /* lock access to GUIX */
81 GX_ENTER_CRITICAL
82
83 if (child -> gx_widget_parent)
84 {
85 _gx_widget_detach(child);
86 }
87 _gx_widget_link(parent, child);
88 child -> gx_widget_status &= ~GX_STATUS_HIDDEN;
89
90 /* Release the protection. */
91 GX_EXIT_CRITICAL
92
93 /* Return successful status. */
94 return(GX_SUCCESS);
95 }
96
97