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 /** Text Button Management (Button) */
18 /** */
19 /**************************************************************************/
20
21 #define GX_SOURCE_CODE
22
23
24 /* Include necessary system files. */
25
26 #include "gx_api.h"
27 #include "gx_widget.h"
28 #include "gx_button.h"
29
30
31 /**************************************************************************/
32 /* */
33 /* FUNCTION RELEASE */
34 /* */
35 /* _gx_text_button_create PORTABLE C */
36 /* 6.1 */
37 /* AUTHOR */
38 /* */
39 /* Kenneth Maxwell, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* This function creates a text button, which is a special type of */
44 /* button (widget). */
45 /* */
46 /* INPUT */
47 /* */
48 /* button Button control block */
49 /* name Name of button */
50 /* parent Parent widget control block */
51 /* text_id text resource id */
52 /* style Style of button */
53 /* size Button size */
54 /* */
55 /* OUTPUT */
56 /* */
57 /* status Completion status */
58 /* */
59 /* CALLS */
60 /* */
61 /* memset Set control block to zero */
62 /* _gx_button_create Create the underlying button */
63 /* _gx_widget_link Link the button to its parent */
64 /* */
65 /* CALLED BY */
66 /* */
67 /* Application Code */
68 /* */
69 /* RELEASE HISTORY */
70 /* */
71 /* DATE NAME DESCRIPTION */
72 /* */
73 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
74 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
75 /* set new event process, */
76 /* added logic to init new */
77 /* structure member for */
78 /* dynamic bidi text support, */
79 /* resulting in version 6.1 */
80 /* */
81 /**************************************************************************/
_gx_text_button_create(GX_TEXT_BUTTON * button,GX_CONST GX_CHAR * name,GX_WIDGET * parent,GX_RESOURCE_ID text_id,ULONG style,USHORT Id,GX_CONST GX_RECTANGLE * size)82 UINT _gx_text_button_create(GX_TEXT_BUTTON *button, GX_CONST GX_CHAR *name,
83 GX_WIDGET *parent, GX_RESOURCE_ID text_id, ULONG style, USHORT Id,
84 GX_CONST GX_RECTANGLE *size)
85 {
86
87 /* Call the prompt create function. */
88 _gx_button_create((GX_BUTTON *)button, name, GX_NULL, style, Id, size);
89
90 /* Populate the rest of button control block - overriding as necessary. */
91 button -> gx_widget_type = GX_TYPE_TEXT_BUTTON;
92 button -> gx_text_button_text_id = text_id;
93 button -> gx_text_button_string.gx_string_ptr = GX_NULL;
94 button -> gx_text_button_string.gx_string_length = 0;
95 button -> gx_widget_draw_function = (VOID (*)(GX_WIDGET *))_gx_text_button_draw;
96 button -> gx_widget_event_process_function = (UINT(*)(GX_WIDGET*, GX_EVENT*))_gx_text_button_event_process;
97 button -> gx_text_button_normal_text_color = GX_COLOR_ID_BUTTON_TEXT;
98 button -> gx_text_button_selected_text_color = GX_COLOR_ID_BUTTON_TEXT;
99 button -> gx_text_button_disabled_text_color = GX_COLOR_ID_DISABLED_TEXT;
100 button -> gx_widget_disabled_fill_color = GX_COLOR_ID_DISABLED_FILL;
101 button -> gx_text_button_font_id = GX_FONT_ID_BUTTON;
102
103 #if defined(GX_DYNAMIC_BIDI_TEXT_SUPPORT)
104 button -> gx_text_button_bidi_resolved_text_info = GX_NULL;
105 #endif
106
107 /* Determine if a parent widget was provided. */
108 if (parent)
109 {
110 _gx_widget_link(parent, (GX_WIDGET *)button);
111 }
112
113 /* Return the status from button create. */
114 return(GX_SUCCESS);
115 }
116
117