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 /** Progress Bar Management (Progress Bar) */
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_progress_bar.h"
29
30
31 /**************************************************************************/
32 /* */
33 /* FUNCTION RELEASE */
34 /* */
35 /* _gx_progress_bar_create PORTABLE C */
36 /* 6.1 */
37 /* AUTHOR */
38 /* */
39 /* Kenneth Maxwell, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* This service creates a progress bar. */
44 /* */
45 /* INPUT */
46 /* */
47 /* progress_bar Progress Bar control block */
48 /* name Name of prompt */
49 /* parent Parent widget control block */
50 /* progress_bar_info Pointer to progress bar info */
51 /* style Style of progress bar */
52 /* progress_bar_id Application-defined ID of */
53 /* progress bar */
54 /* size Dimensions of progress bar */
55 /* */
56 /* OUTPUT */
57 /* */
58 /* status Completion status */
59 /* */
60 /* CALLS */
61 /* */
62 /* _gx_widget_create Create the underlying widget */
63 /* _gx_widget_link Link the widget 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 /* resulting in version 6.1 */
76 /* */
77 /**************************************************************************/
_gx_progress_bar_create(GX_PROGRESS_BAR * progress_bar,GX_CONST GX_CHAR * name,GX_WIDGET * parent,GX_PROGRESS_BAR_INFO * progress_bar_info,ULONG style,USHORT progress_bar_id,GX_CONST GX_RECTANGLE * size)78 UINT _gx_progress_bar_create(GX_PROGRESS_BAR *progress_bar,
79 GX_CONST GX_CHAR *name, GX_WIDGET *parent,
80 GX_PROGRESS_BAR_INFO *progress_bar_info, ULONG style,
81 USHORT progress_bar_id,
82 GX_CONST GX_RECTANGLE *size)
83 {
84
85 /* Call the widget create function. */
86 _gx_widget_create((GX_WIDGET *)progress_bar, name, GX_NULL, style, progress_bar_id, size);
87
88 /* Populate the rest of progress bar control block - overriding as necessary. */
89 progress_bar -> gx_widget_type = GX_TYPE_PROGRESS_BAR;
90 progress_bar -> gx_widget_draw_function = (VOID (*)(GX_WIDGET *))_gx_progress_bar_draw;
91 progress_bar -> gx_widget_event_process_function = (UINT (*)(GX_WIDGET *, GX_EVENT *))_gx_progress_bar_event_process;
92
93 if (progress_bar_info)
94 {
95 progress_bar -> gx_progress_bar_info = *progress_bar_info;
96 }
97 else
98 {
99 progress_bar -> gx_progress_bar_info.gx_progress_bar_info_max_val = 100;
100 progress_bar -> gx_progress_bar_info.gx_progress_bar_info_min_val = 0;
101 progress_bar -> gx_progress_bar_info.gx_progress_bar_info_current_val = 0;
102 progress_bar -> gx_progress_bar_info.gx_progress_bar_font_id = GX_FONT_ID_DEFAULT;
103 progress_bar -> gx_progress_bar_info.gx_progress_bar_normal_text_color = GX_COLOR_ID_TEXT;
104 progress_bar -> gx_progress_bar_info.gx_progress_bar_selected_text_color = GX_COLOR_ID_SELECTED_TEXT;
105 progress_bar -> gx_progress_bar_info.gx_progress_bar_disabled_text_color = GX_COLOR_ID_DISABLED_TEXT;
106 progress_bar -> gx_progress_bar_info.gx_progress_bar_fill_pixelmap = GX_PIXELMAP_NULL;
107 }
108
109 /* Determine if a parent widget was provided. */
110 if (parent)
111 {
112 _gx_widget_link(parent, (GX_WIDGET *)progress_bar);
113 }
114
115 /* Return the completion status from widget create. */
116 return(GX_SUCCESS);
117 }
118
119