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 /** Numeric Prompt Management (Prompt) */
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_prompt.h"
29 #include "gx_numeric_prompt.h"
30 #include "gx_system.h"
31 #include "gx_utility.h"
32
33 /**************************************************************************/
34 /* */
35 /* FUNCTION RELEASE */
36 /* */
37 /* _gx_numeric_prompt_value_set PORTABLE C */
38 /* 6.2.0 */
39 /* AUTHOR */
40 /* */
41 /* Kenneth Maxwell, Microsoft Corporation */
42 /* */
43 /* DESCRIPTION */
44 /* */
45 /* This function sets an integer for a numeric prompt widget */
46 /* */
47 /* INPUT */
48 /* */
49 /* prompt Numeric prompt control block */
50 /* value Prompt value to be set */
51 /* */
52 /* OUTPUT */
53 /* */
54 /* status Completion status */
55 /* */
56 /* CALLS */
57 /* */
58 /* [gx_numeric_prompt_format_function] Value format callback */
59 /* _gx_system_dirty_mark Mark a widget as dirty */
60 /* */
61 /* CALLED BY */
62 /* */
63 /* Application 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 /* added logic to delete */
72 /* dynamic bidi text, */
73 /* resulting in version 6.1 */
74 /* 10-31-2022 Kenneth Maxwell Modified comment(s), */
75 /* added line to insure */
76 /* TEXT_COPY style is not set, */
77 /* resulting in version 6.2.0 */
78 /* */
79 /**************************************************************************/
_gx_numeric_prompt_value_set(GX_NUMERIC_PROMPT * prompt,INT value)80 UINT _gx_numeric_prompt_value_set(GX_NUMERIC_PROMPT *prompt, INT value)
81 {
82 UINT status = GX_SUCCESS;
83 UINT length;
84
85 /* Format int value to string. */
86 prompt -> gx_prompt_string.gx_string_ptr = prompt -> gx_numeric_prompt_buffer;
87 prompt -> gx_widget_style &= ~GX_STYLE_TEXT_COPY;
88 prompt -> gx_numeric_prompt_format_function(prompt, value);
89
90 status = _gx_utility_string_length_check(prompt->gx_prompt_string.gx_string_ptr, &length, GX_NUMERIC_PROMPT_BUFFER_SIZE - 1);
91 if (status != GX_SUCCESS)
92 {
93 return status;
94 }
95 prompt -> gx_prompt_string.gx_string_length = length;
96 prompt -> gx_prompt_text_id = 0;
97
98 #if defined(GX_DYNAMIC_BIDI_TEXT_SUPPORT)
99 if (prompt -> gx_prompt_bidi_resolved_text_info)
100 {
101 _gx_utility_bidi_resolved_text_info_delete(&prompt->gx_prompt_bidi_resolved_text_info);
102 }
103 #endif
104
105 if (prompt -> gx_widget_status & GX_STATUS_VISIBLE)
106 {
107 /* Mark widget as dirty. */
108 status = _gx_system_dirty_mark((GX_WIDGET *)prompt);
109 }
110
111 return status;
112 }
113
114