1 /**************************************************************************/
2 /* */
3 /* Copyright (c) Microsoft Corporation. All rights reserved. */
4 /* */
5 /* This software is licensed under the Microsoft Software License */
6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */
7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
8 /* and in the root directory of this software. */
9 /* */
10 /**************************************************************************/
11
12
13 /**************************************************************************/
14 /**************************************************************************/
15 /** */
16 /** GUIX Component */
17 /** */
18 /** Widget Management (Widget) */
19 /** */
20 /**************************************************************************/
21
22 #define GX_SOURCE_CODE
23
24
25 /* Include necessary system files. */
26
27 #include "gx_api.h"
28 #include "gx_system.h"
29 #include "gx_utility.h"
30 #include "gx_widget.h"
31
32
33 /**************************************************************************/
34 /* */
35 /* FUNCTION RELEASE */
36 /* */
37 /* _gx_widget_back_move PORTABLE C */
38 /* 6.1 */
39 /* AUTHOR */
40 /* */
41 /* Kenneth Maxwell, Microsoft Corporation */
42 /* */
43 /* DESCRIPTION */
44 /* */
45 /* This function moves a widget to the back in the Z order. */
46 /* */
47 /* INPUT */
48 /* */
49 /* widget Widget control block */
50 /* widget_moved Return flag indicate widget */
51 /* moved */
52 /* */
53 /* OUTPUT */
54 /* */
55 /* status Completion status */
56 /* */
57 /* CALLS */
58 /* */
59 /* _gx_system_dirty_partial_add Add dirty area */
60 /* */
61 /* CALLED BY */
62 /* */
63 /* Application Code */
64 /* GUIX Internal Code */
65 /* */
66 /* RELEASE HISTORY */
67 /* */
68 /* DATE NAME DESCRIPTION */
69 /* */
70 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
71 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
72 /* resulting in version 6.1 */
73 /* */
74 /**************************************************************************/
_gx_widget_back_move(GX_WIDGET * widget,GX_BOOL * widget_moved)75 UINT _gx_widget_back_move(GX_WIDGET *widget, GX_BOOL *widget_moved)
76 {
77 GX_WIDGET *parent;
78
79 /* Pickup parent widget. */
80 parent = widget -> gx_widget_parent;
81
82 /* Check for invalid parent. */
83 if (!parent)
84 {
85 return(GX_PTR_ERROR);
86 }
87
88 /* First check to see if the widget is already in back. */
89 if (parent -> gx_widget_first_child == widget)
90 {
91 /* Yes, widget is already in back, so nothing to do. */
92
93 /* Return no change. */
94 return(GX_NO_CHANGE);
95 }
96
97 /* Relink widget to the end
98 2) unlink and stitch linked list
99 3) relink to the end
100 4) call dirty so that we will get redraw
101 */
102 _gx_system_dirty_partial_add(parent, &widget -> gx_widget_size);
103
104 /* Is the widget last (front) child of parent? */
105 if (parent -> gx_widget_last_child == widget)
106 {
107 /* Yes, the first child, easy remove the first child. */
108 parent -> gx_widget_last_child = widget -> gx_widget_previous;
109 widget -> gx_widget_previous -> gx_widget_next = NULL;
110 }
111 else
112 {
113 /* No, not the first child. Remove from the middle. */
114 widget -> gx_widget_previous -> gx_widget_next = widget -> gx_widget_next;
115 widget -> gx_widget_next -> gx_widget_previous = widget -> gx_widget_previous;
116 }
117
118 /* Link the widget to the back (head) of the list. */
119 widget -> gx_widget_next = parent -> gx_widget_first_child;
120 parent -> gx_widget_first_child -> gx_widget_previous = widget;
121 widget -> gx_widget_previous = GX_NULL;
122 parent -> gx_widget_first_child = widget;
123
124 /* Indicate the widget was moved. */
125
126 if (widget_moved)
127 {
128 *widget_moved = GX_TRUE;
129 }
130
131 /* Return successful completion. */
132 return(GX_SUCCESS);
133 }
134
135