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_back_link                                PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Kenneth Maxwell, Microsoft Corporation                              */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function links a widget to the back of the parent child list   */
45 /*                                                                        */
46 /*  INPUT                                                                 */
47 /*                                                                        */
48 /*    parent                                Parent widget control block   */
49 /*    widget                                Widget control block          */
50 /*                                                                        */
51 /*  OUTPUT                                                                */
52 /*                                                                        */
53 /*    status                                Completion status             */
54 /*                                                                        */
55 /*  CALLS                                                                 */
56 /*                                                                        */
57 /*    _gx_widget_unlink                     Unlink the widget             */
58 /*    _gx_widget_show                       Show the widget               */
59 /*                                                                        */
60 /*  CALLED BY                                                             */
61 /*                                                                        */
62 /*    GUIX Internal Code                                                  */
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_widget_back_link(GX_WIDGET * parent,GX_WIDGET * widget)73 VOID _gx_widget_back_link(GX_WIDGET *parent, GX_WIDGET *widget)
74 {
75 GX_WIDGET *sibling;
76 
77     /* Determine if a parent widget was provided.  */
78     if (parent)
79     {
80         /* Yes, is there already a child for this parent?  */
81         if (parent -> gx_widget_first_child)
82         {
83             /* Yes, find the last child.  */
84             sibling =  parent -> gx_widget_first_child;
85             widget -> gx_widget_next = sibling;
86             sibling -> gx_widget_previous = widget;
87         }
88         else
89         {
90             widget -> gx_widget_next = NULL;
91             parent -> gx_widget_last_child = widget;
92         }
93 
94         parent -> gx_widget_first_child =  widget;
95 
96         /* Setup the last child pointer and remember the parent widget.  */
97         widget -> gx_widget_parent = parent;
98 
99         if (parent -> gx_widget_status & GX_STATUS_VISIBLE)
100         {
101             _gx_widget_show(widget);
102             if (widget -> gx_widget_status & GX_STATUS_ACCEPTS_FOCUS)
103             {
104                 _gx_widget_nav_order_initialize(parent);
105             }
106         }
107     }
108 }
109 
110