GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_text_button_text_id_set.c Lines: 10 10 100.0 %
Date: 2024-12-05 08:52:37 Branches: 6 6 100.0 %

Line Branch Exec Source
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_system.h"
28
#include "gx_button.h"
29
#include "gx_utility.h"
30
31
/**************************************************************************/
32
/*                                                                        */
33
/*  FUNCTION                                               RELEASE        */
34
/*                                                                        */
35
/*    _gx_text_button_text_id_set                         PORTABLE C      */
36
/*                                                           6.1          */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Kenneth Maxwell, Microsoft Corporation                              */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    This function assigns a text ID to the specified button.            */
44
/*                                                                        */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    button                                Button control block          */
49
/*    text_id                               Resource ID of the text string*/
50
/*                                                                        */
51
/*  OUTPUT                                                                */
52
/*                                                                        */
53
/*    status                                Completion status             */
54
/*                                                                        */
55
/*  CALLS                                                                 */
56
/*                                                                        */
57
/*    _gx_system_dirty_mark                 Mark this prompt as dirty     */
58
/*                                                                        */
59
/*  CALLED BY                                                             */
60
/*                                                                        */
61
/*    Application Cdoe                                                    */
62
/*                                                                        */
63
/*  RELEASE HISTORY                                                       */
64
/*                                                                        */
65
/*    DATE              NAME                      DESCRIPTION             */
66
/*                                                                        */
67
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
68
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
69
/*                                            added logic to delete       */
70
/*                                            dynamic bidi text,          */
71
/*                                            resulting in version 6.1    */
72
/*                                                                        */
73
/**************************************************************************/
74
5
UINT  _gx_text_button_text_id_set(GX_TEXT_BUTTON *button, GX_RESOURCE_ID text_id)
75
{
76
5
    button -> gx_text_button_text_id = text_id;
77
78
5
    if (button -> gx_widget_style & GX_STYLE_TEXT_COPY)
79
    {
80
2
        if (button -> gx_text_button_string.gx_string_ptr)
81
        {
82
1
            _gx_system_memory_free((void *)button -> gx_text_button_string.gx_string_ptr);
83
        }
84
    }
85
86
5
    button -> gx_text_button_string.gx_string_ptr = GX_NULL;
87
5
    button -> gx_text_button_string.gx_string_length = 0;
88
89
#if defined(GX_DYNAMIC_BIDI_TEXT_SUPPORT)
90
    if (button -> gx_text_button_bidi_resolved_text_info)
91
    {
92
        _gx_utility_bidi_resolved_text_info_delete(&button -> gx_text_button_bidi_resolved_text_info);
93
    }
94
#endif
95
96
5
    if (button -> gx_widget_status & GX_STATUS_VISIBLE)
97
    {
98
4
        _gx_system_dirty_mark((GX_WIDGET *)button);
99
    }
100
101
5
    return(GX_SUCCESS);
102
}
103