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_utility.h" |
29 |
|
|
#include "gx_widget.h" |
30 |
|
|
|
31 |
|
|
|
32 |
|
|
/**************************************************************************/ |
33 |
|
|
/* */ |
34 |
|
|
/* FUNCTION RELEASE */ |
35 |
|
|
/* */ |
36 |
|
|
/* _gx_widget_back_move PORTABLE C */ |
37 |
|
|
/* 6.1 */ |
38 |
|
|
/* AUTHOR */ |
39 |
|
|
/* */ |
40 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
41 |
|
|
/* */ |
42 |
|
|
/* DESCRIPTION */ |
43 |
|
|
/* */ |
44 |
|
|
/* This function moves a widget to the back in the Z order. */ |
45 |
|
|
/* */ |
46 |
|
|
/* INPUT */ |
47 |
|
|
/* */ |
48 |
|
|
/* widget Widget control block */ |
49 |
|
|
/* widget_moved Return flag indicate widget */ |
50 |
|
|
/* moved */ |
51 |
|
|
/* */ |
52 |
|
|
/* OUTPUT */ |
53 |
|
|
/* */ |
54 |
|
|
/* status Completion status */ |
55 |
|
|
/* */ |
56 |
|
|
/* CALLS */ |
57 |
|
|
/* */ |
58 |
|
|
/* _gx_system_dirty_partial_add Add dirty area */ |
59 |
|
|
/* */ |
60 |
|
|
/* CALLED BY */ |
61 |
|
|
/* */ |
62 |
|
|
/* Application Code */ |
63 |
|
|
/* GUIX Internal Code */ |
64 |
|
|
/* */ |
65 |
|
|
/* RELEASE HISTORY */ |
66 |
|
|
/* */ |
67 |
|
|
/* DATE NAME DESCRIPTION */ |
68 |
|
|
/* */ |
69 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
70 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
71 |
|
|
/* resulting in version 6.1 */ |
72 |
|
|
/* */ |
73 |
|
|
/**************************************************************************/ |
74 |
|
14 |
UINT _gx_widget_back_move(GX_WIDGET *widget, GX_BOOL *widget_moved) |
75 |
|
|
{ |
76 |
|
|
GX_WIDGET *parent; |
77 |
|
|
|
78 |
|
|
/* Pickup parent widget. */ |
79 |
|
14 |
parent = widget -> gx_widget_parent; |
80 |
|
|
|
81 |
|
|
/* Check for invalid parent. */ |
82 |
✓✓ |
14 |
if (!parent) |
83 |
|
|
{ |
84 |
|
1 |
return(GX_PTR_ERROR); |
85 |
|
|
} |
86 |
|
|
|
87 |
|
|
/* First check to see if the widget is already in back. */ |
88 |
✓✓ |
13 |
if (parent -> gx_widget_first_child == widget) |
89 |
|
|
{ |
90 |
|
|
/* Yes, widget is already in back, so nothing to do. */ |
91 |
|
|
|
92 |
|
|
/* Return no change. */ |
93 |
|
2 |
return(GX_NO_CHANGE); |
94 |
|
|
} |
95 |
|
|
|
96 |
|
|
/* Relink widget to the end |
97 |
|
|
2) unlink and stitch linked list |
98 |
|
|
3) relink to the end |
99 |
|
|
4) call dirty so that we will get redraw |
100 |
|
|
*/ |
101 |
|
11 |
_gx_system_dirty_partial_add(parent, &widget -> gx_widget_size); |
102 |
|
|
|
103 |
|
|
/* Is the widget last (front) child of parent? */ |
104 |
✓✓ |
11 |
if (parent -> gx_widget_last_child == widget) |
105 |
|
|
{ |
106 |
|
|
/* Yes, the first child, easy remove the first child. */ |
107 |
|
10 |
parent -> gx_widget_last_child = widget -> gx_widget_previous; |
108 |
|
10 |
widget -> gx_widget_previous -> gx_widget_next = NULL; |
109 |
|
|
} |
110 |
|
|
else |
111 |
|
|
{ |
112 |
|
|
/* No, not the first child. Remove from the middle. */ |
113 |
|
1 |
widget -> gx_widget_previous -> gx_widget_next = widget -> gx_widget_next; |
114 |
|
1 |
widget -> gx_widget_next -> gx_widget_previous = widget -> gx_widget_previous; |
115 |
|
|
} |
116 |
|
|
|
117 |
|
|
/* Link the widget to the back (head) of the list. */ |
118 |
|
11 |
widget -> gx_widget_next = parent -> gx_widget_first_child; |
119 |
|
11 |
parent -> gx_widget_first_child -> gx_widget_previous = widget; |
120 |
|
11 |
widget -> gx_widget_previous = GX_NULL; |
121 |
|
11 |
parent -> gx_widget_first_child = widget; |
122 |
|
|
|
123 |
|
|
/* Indicate the widget was moved. */ |
124 |
|
|
|
125 |
✓✓ |
11 |
if (widget_moved) |
126 |
|
|
{ |
127 |
|
7 |
*widget_moved = GX_TRUE; |
128 |
|
|
} |
129 |
|
|
|
130 |
|
|
/* Return successful completion. */ |
131 |
|
11 |
return(GX_SUCCESS); |
132 |
|
|
} |
133 |
|
|
|