1 |
|
|
/*************************************************************************** |
2 |
|
|
* Copyright (c) 2024 Microsoft Corporation |
3 |
|
|
* Copyright (c) 2026-present Eclipse ThreadX contributors |
4 |
|
|
* |
5 |
|
|
* This program and the accompanying materials are made available under the |
6 |
|
|
* terms of the MIT License which is available at |
7 |
|
|
* https://opensource.org/licenses/MIT. |
8 |
|
|
* |
9 |
|
|
* SPDX-License-Identifier: MIT |
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_widget.h" |
30 |
|
|
#include "gx_utility.h" |
31 |
|
|
|
32 |
|
|
|
33 |
|
|
/**************************************************************************/ |
34 |
|
|
/* */ |
35 |
|
|
/* FUNCTION RELEASE */ |
36 |
|
|
/* */ |
37 |
|
|
/* _gx_widget_create PORTABLE C */ |
38 |
|
|
/* 6.1 */ |
39 |
|
|
/* AUTHOR */ |
40 |
|
|
/* */ |
41 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
42 |
|
|
/* */ |
43 |
|
|
/* DESCRIPTION */ |
44 |
|
|
/* */ |
45 |
|
|
/* This function creates a widget. */ |
46 |
|
|
/* */ |
47 |
|
|
/* INPUT */ |
48 |
|
|
/* */ |
49 |
|
|
/* widget Widget control block */ |
50 |
|
|
/* name Name of widget */ |
51 |
|
|
/* parent Parent widget control block */ |
52 |
|
|
/* style Style of widget */ |
53 |
|
|
/* Id Application-defined ID of the */ |
54 |
|
|
/* the widget */ |
55 |
|
|
/* size Widget size */ |
56 |
|
|
/* */ |
57 |
|
|
/* OUTPUT */ |
58 |
|
|
/* */ |
59 |
|
|
/* status Completion status */ |
60 |
|
|
/* */ |
61 |
|
|
/* CALLS */ |
62 |
|
|
/* */ |
63 |
|
|
/* GX_ENTER_CRITICAL Lock access to GUIX */ |
64 |
|
|
/* _gx_widget_link Link a widget to parent */ |
65 |
|
|
/* GX_EXIT_CRITICAL Release the protection */ |
66 |
|
|
/* */ |
67 |
|
|
/* CALLED BY */ |
68 |
|
|
/* */ |
69 |
|
|
/* Application Code */ |
70 |
|
|
/* GUIX Internal Code */ |
71 |
|
|
/* */ |
72 |
|
|
/**************************************************************************/ |
73 |
|
156277 |
UINT _gx_widget_create(GX_WIDGET *widget, GX_CONST GX_CHAR *name, GX_WIDGET *parent, |
74 |
|
|
ULONG style, USHORT Id, GX_CONST GX_RECTANGLE *size) |
75 |
|
|
{ |
76 |
|
|
|
77 |
|
|
/* lock access to GUIX */ |
78 |
|
156277 |
GX_ENTER_CRITICAL |
79 |
|
|
|
80 |
|
|
/* Setup the widget. */ |
81 |
|
156277 |
widget -> gx_widget_type = GX_TYPE_WIDGET; |
82 |
|
|
|
83 |
|
156277 |
widget -> gx_widget_style = style; |
84 |
|
156277 |
widget -> gx_widget_size = *size; |
85 |
|
156277 |
widget -> gx_widget_clip = widget -> gx_widget_size; |
86 |
|
156277 |
widget -> gx_widget_event_process_function = _gx_widget_event_process; |
87 |
|
156277 |
widget -> gx_widget_draw_function = (VOID (*)(GX_WIDGET *))_gx_widget_draw; |
88 |
|
156277 |
widget -> gx_widget_normal_fill_color = GX_COLOR_ID_WIDGET_FILL; |
89 |
|
156277 |
widget -> gx_widget_selected_fill_color = GX_COLOR_ID_SELECTED_FILL; |
90 |
|
156277 |
widget -> gx_widget_disabled_fill_color = GX_COLOR_ID_DISABLED_FILL; |
91 |
|
156277 |
widget -> gx_widget_id = Id; |
92 |
|
|
|
93 |
|
|
#if defined(GX_BRUSH_ALPHA_SUPPORT) |
94 |
|
156277 |
widget -> gx_widget_alpha = 0xff; |
95 |
|
|
#endif |
96 |
|
|
|
97 |
✓✓ |
156277 |
if (style & GX_STYLE_DYNAMICALLY_ALLOCATED) |
98 |
|
|
{ |
99 |
|
700 |
widget -> gx_widget_status = GX_STATUS_DYNAMICALLY_ALLOCATED; |
100 |
|
|
} |
101 |
|
|
else |
102 |
|
|
{ |
103 |
|
155577 |
widget -> gx_widget_status = 0; |
104 |
|
|
} |
105 |
|
|
|
106 |
✓✓ |
156277 |
if (widget -> gx_widget_style & GX_STYLE_ENABLED) |
107 |
|
|
{ |
108 |
|
110354 |
widget -> gx_widget_status |= (GX_STATUS_ACCEPTS_FOCUS | GX_STATUS_SELECTABLE); |
109 |
|
|
} |
110 |
|
|
|
111 |
✓✓ |
156277 |
if (style & GX_STYLE_TRANSPARENT) |
112 |
|
|
{ |
113 |
|
81086 |
widget -> gx_widget_status |= GX_STATUS_TRANSPARENT; |
114 |
|
|
} |
115 |
|
|
|
116 |
|
|
/* setup linked list */ |
117 |
|
156277 |
widget -> gx_widget_parent = GX_NULL; |
118 |
|
156277 |
widget -> gx_widget_first_child = GX_NULL; |
119 |
|
156277 |
widget -> gx_widget_last_child = GX_NULL; |
120 |
|
156277 |
widget -> gx_widget_next = GX_NULL; |
121 |
|
156277 |
widget -> gx_widget_previous = GX_NULL; |
122 |
|
156277 |
widget -> gx_widget_nav_next = GX_NULL; |
123 |
|
156277 |
widget -> gx_widget_nav_previous = GX_NULL; |
124 |
|
|
|
125 |
|
|
/* Save the widget name. */ |
126 |
|
156277 |
widget -> gx_widget_name = name; |
127 |
|
|
|
128 |
|
|
/* Determine if a parent widget was provided. */ |
129 |
✓✓ |
156277 |
if (parent) |
130 |
|
|
{ |
131 |
|
1 |
_gx_widget_link(parent, widget); |
132 |
|
|
} |
133 |
|
|
|
134 |
|
|
/* Release the protection. */ |
135 |
|
156277 |
GX_EXIT_CRITICAL |
136 |
|
|
|
137 |
|
|
/* Return successful status. */ |
138 |
|
156277 |
return(GX_SUCCESS); |
139 |
|
|
} |
140 |
|
|
|