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 Pixelmap 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_numeric_pixelmap_prompt.h"
28 #include "gx_system.h"
29 #include "gx_utility.h"
30 
31 /**************************************************************************/
32 /*                                                                        */
33 /*  FUNCTION                                               RELEASE        */
34 /*                                                                        */
35 /*    _gx_numeric_pixelmap_prompt_value_set               PORTABLE C      */
36 /*                                                           6.1          */
37 /*  AUTHOR                                                                */
38 /*                                                                        */
39 /*    Kenneth Maxwell, Microsoft Corporation                              */
40 /*                                                                        */
41 /*  DESCRIPTION                                                           */
42 /*                                                                        */
43 /*    This function sets an integer for a numeric pixelmap prompt widget. */
44 /*                                                                        */
45 /*  INPUT                                                                 */
46 /*                                                                        */
47 /*    prompt                                Numeric pixelmap prompt       */
48 /*                                            control block               */
49 /*    value                                 Prompt value to be set        */
50 /*                                                                        */
51 /*  OUTPUT                                                                */
52 /*                                                                        */
53 /*    status                                Completion status             */
54 /*                                                                        */
55 /*  CALLS                                                                 */
56 /*                                                                        */
57 /*    [gx_numeric_pixelmap_prompt_format_function]                        */
58 /*                                          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 /*                                                                        */
75 /**************************************************************************/
_gx_numeric_pixelmap_prompt_value_set(GX_NUMERIC_PIXELMAP_PROMPT * prompt,INT value)76 UINT _gx_numeric_pixelmap_prompt_value_set(GX_NUMERIC_PIXELMAP_PROMPT *prompt, INT value)
77 {
78 UINT status = GX_SUCCESS;
79 UINT length = 0;
80 
81     /* Format int value to string. */
82     prompt -> gx_prompt_string.gx_string_ptr = prompt -> gx_numeric_pixelmap_prompt_buffer;
83     prompt -> gx_numeric_pixelmap_prompt_format_function(prompt, value);
84     status = _gx_utility_string_length_check(prompt->gx_prompt_string.gx_string_ptr, &length, GX_NUMERIC_PROMPT_BUFFER_SIZE - 1);
85     if (status != GX_SUCCESS)
86     {
87         return status;
88     }
89 
90     prompt -> gx_prompt_string.gx_string_length = length;
91 
92     prompt -> gx_prompt_text_id = 0;
93 
94 #if defined(GX_DYNAMIC_BIDI_TEXT_SUPPORT)
95     if (prompt -> gx_prompt_bidi_resolved_text_info)
96     {
97         _gx_utility_bidi_resolved_text_info_delete(&prompt->gx_prompt_bidi_resolved_text_info);
98     }
99 #endif
100 
101     if (prompt -> gx_widget_status & GX_STATUS_VISIBLE)
102     {
103         /* Mark widget as dirty. */
104         status = _gx_system_dirty_mark((GX_WIDGET *)prompt);
105     }
106 
107     return status;
108 }
109 
110