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_widget.h"
29 #include "gx_system.h"
30 #include "gx_window.h"
31
32
33 /**************************************************************************/
34 /* */
35 /* FUNCTION RELEASE */
36 /* */
37 /* _gx_widget_style_set PORTABLE C */
38 /* 6.1 */
39 /* AUTHOR */
40 /* */
41 /* Kenneth Maxwell, Microsoft Corporation */
42 /* */
43 /* DESCRIPTION */
44 /* */
45 /* This function updates the style of the specified widget. */
46 /* */
47 /* INPUT */
48 /* */
49 /* widget Widget control block */
50 /* style New style */
51 /* */
52 /* OUTPUT */
53 /* */
54 /* status Completion status */
55 /* */
56 /* CALLS */
57 /* */
58 /* _gx_window_view_update_detect Detect if views changed */
59 /* _gx_system_dirty_mark Mark the widget as dirty */
60 /* */
61 /* CALLED BY */
62 /* */
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 /**************************************************************************/
_gx_widget_style_set(GX_WIDGET * widget,ULONG style)74 UINT _gx_widget_style_set(GX_WIDGET *widget, ULONG style)
75 {
76 GX_WINDOW *window;
77 GX_EVENT my_event;
78 ULONG old_style = widget -> gx_widget_style;
79
80 /* Update the widget style. */
81 widget -> gx_widget_style = style;
82
83 if (style & GX_STYLE_TRANSPARENT)
84 {
85 if (!(widget -> gx_widget_status & GX_STATUS_TRANSPARENT))
86 {
87 /* If we are changing a window transparency and the window is visible,
88 we have to check to see if viewports need to be updated
89 */
90 if (widget -> gx_widget_type >= GX_TYPE_WINDOW &&
91 widget -> gx_widget_status & GX_STATUS_VISIBLE)
92 {
93 window = (GX_WINDOW *)widget;
94 _gx_window_view_update_detect(window);
95 }
96 widget -> gx_widget_status |= GX_STATUS_TRANSPARENT;
97 }
98 }
99 else
100 {
101 if (widget -> gx_widget_status & GX_STATUS_TRANSPARENT)
102 {
103 /* If we are changing a window transparency and the window is visible,
104 we have to check to see if viewports need to be updated
105 */
106 if (widget -> gx_widget_type >= GX_TYPE_WINDOW &&
107 widget -> gx_widget_status & GX_STATUS_VISIBLE)
108 {
109 window = (GX_WINDOW *)widget;
110 _gx_window_view_update_detect(window);
111 }
112 widget -> gx_widget_status &= ~GX_STATUS_TRANSPARENT;
113 }
114 }
115
116 if (widget -> gx_widget_style & GX_STYLE_ENABLED)
117 {
118 _gx_widget_status_add(widget, GX_STATUS_SELECTABLE);
119 }
120 else
121 {
122 _gx_widget_status_remove(widget, GX_STATUS_SELECTABLE);
123 }
124
125 if (widget -> gx_widget_status & GX_STATUS_VISIBLE)
126 {
127 _gx_system_dirty_mark(widget);
128 }
129
130 /* notify widget of style modification */
131 memset(&my_event, 0, sizeof(GX_EVENT));
132 my_event.gx_event_payload.gx_event_ulongdata = old_style;
133 my_event.gx_event_type = GX_EVENT_STYLE_CHANGED;
134 my_event.gx_event_target = widget;
135 _gx_system_event_fold(&my_event);
136
137 return(GX_SUCCESS);
138 }
139
140