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 |
|
|
/**************************************************************************/ |
71 |
|
17007 |
GX_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 |
|
17007 |
parent = widget -> gx_widget_parent; |
79 |
|
|
|
80 |
✓✓ |
17007 |
if (parent) |
81 |
|
|
{ |
82 |
|
|
/* Is this widget the first child? */ |
83 |
✓✓ |
16941 |
if (parent -> gx_widget_first_child == widget) |
84 |
|
|
{ |
85 |
|
|
/* Yes, unlink and done*/ |
86 |
|
15380 |
parent -> gx_widget_first_child = widget -> gx_widget_next; |
87 |
✓✓ |
15380 |
if (parent -> gx_widget_first_child) |
88 |
|
|
{ |
89 |
|
966 |
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 |
✓✓ |
15380 |
if (parent -> gx_widget_last_child == widget) |
95 |
|
|
{ |
96 |
|
14414 |
parent -> gx_widget_last_child = parent -> gx_widget_first_child; |
97 |
|
|
} |
98 |
|
|
} |
99 |
|
|
else |
100 |
|
|
{ |
101 |
|
1561 |
sibling = parent -> gx_widget_first_child; |
102 |
|
|
|
103 |
✓✓ |
15676 |
while (sibling -> gx_widget_next != widget) |
104 |
|
|
{ |
105 |
|
14115 |
sibling = sibling -> gx_widget_next; |
106 |
|
|
} |
107 |
|
1561 |
sibling -> gx_widget_next = widget -> gx_widget_next; |
108 |
|
|
|
109 |
✓✓ |
1561 |
if (parent -> gx_widget_last_child == widget) |
110 |
|
|
{ |
111 |
|
1111 |
parent -> gx_widget_last_child = sibling; |
112 |
|
|
} |
113 |
|
|
|
114 |
✓✓ |
1561 |
if (sibling -> gx_widget_next) |
115 |
|
|
{ |
116 |
|
450 |
sibling -> gx_widget_next -> gx_widget_previous = sibling; |
117 |
|
|
} |
118 |
|
|
} |
119 |
✓✓ |
16941 |
if (widget -> gx_widget_status & GX_STATUS_VISIBLE) |
120 |
|
|
{ |
121 |
|
144 |
_gx_widget_hide(widget); |
122 |
|
|
} |
123 |
|
16941 |
widget -> gx_widget_parent = GX_NULL; |
124 |
|
16941 |
widget -> gx_widget_next = GX_NULL; |
125 |
|
16941 |
widget -> gx_widget_previous = GX_NULL; |
126 |
|
16941 |
widget -> gx_widget_nav_next = GX_NULL; |
127 |
|
16941 |
widget -> gx_widget_nav_previous = GX_NULL; |
128 |
|
|
} |
129 |
|
|
/* Return widget pointer */ |
130 |
|
17007 |
return(widget); |
131 |
|
|
} |
132 |
|
|
|