GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_multi_line_text_view_text_id_set.c Lines: 12 12 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
/**   Multi Line Text View Management (Multi Line Text View)              */
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_multi_line_text_view.h"
29
#include "gx_scrollbar.h"
30
#include "gx_utility.h"
31
#include "gx_window.h"
32
#include "gx_widget.h"
33
34
/**************************************************************************/
35
/*                                                                        */
36
/*  FUNCTION                                               RELEASE        */
37
/*                                                                        */
38
/*    _gx_multi_line_text_view_text_id_set                PORTABLE C      */
39
/*                                                           6.1          */
40
/*  AUTHOR                                                                */
41
/*                                                                        */
42
/*    Kenneth Maxwell, Microsoft Corporation                              */
43
/*                                                                        */
44
/*  DESCRIPTION                                                           */
45
/*                                                                        */
46
/*    This function creates a text input widget.                          */
47
/*                                                                        */
48
/*  INPUT                                                                 */
49
/*                                                                        */
50
/*    text_view                             Multi-line view control block */
51
/*    text_id                               Resource ID for the text      */
52
/*                                            string                      */
53
/*                                                                        */
54
/*  OUTPUT                                                                */
55
/*                                                                        */
56
/*    status                                Completion status             */
57
/*                                                                        */
58
/*  CALLS                                                                 */
59
/*                                                                        */
60
/*    _gx_utility_string_length_check       Test string length            */
61
/*    _gx_system_string_get                 Get the string from the ID    */
62
/*    _gx_system_memory_free                Application-defined memory    */
63
/*                                            free function               */
64
/*    _gx_multi_line_text_view_string_total_rows_compute                  */
65
/*                                          Compute the total rows of     */
66
/*                                            of the display text         */
67
/*    _gx_multi_line_text_view_line_cache_update                          */
68
/*                                          Update line cache             */
69
/*    _gx_window_scrollbar_find             Find scrollbar for a window   */
70
/*    _gx_scrollbar_reset                   Reset scrollbar information   */
71
/*    _gx_utility_utf8_string_character_count_get                         */
72
/*                                          Get character count of utf8   */
73
/*                                            string                      */
74
/*    _gx_system_dirty_mark                 Mark a widget as dirty        */
75
/*                                                                        */
76
/*  CALLED BY                                                             */
77
/*                                                                        */
78
/*    Application Code                                                    */
79
/*                                                                        */
80
/*  RELEASE HISTORY                                                       */
81
/*                                                                        */
82
/*    DATE              NAME                      DESCRIPTION             */
83
/*                                                                        */
84
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
85
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
86
/*                                            added logic to delete       */
87
/*                                            dynamic bidi text,          */
88
/*                                            resulting in version 6.1    */
89
/*                                                                        */
90
/**************************************************************************/
91
220
UINT _gx_multi_line_text_view_text_id_set(GX_MULTI_LINE_TEXT_VIEW *text_view,
92
                                          GX_RESOURCE_ID text_id)
93
{
94
220
    if (text_view -> gx_widget_style & GX_STYLE_TEXT_COPY)
95
    {
96
13
        if (text_view -> gx_multi_line_text_view_text.gx_string_ptr)
97
        {
98
1
            _gx_system_memory_free((void *)text_view -> gx_multi_line_text_view_text.gx_string_ptr);
99
        }
100
    }
101
102
220
    text_view -> gx_multi_line_text_view_text_id = text_id;
103
220
    text_view -> gx_multi_line_text_view_text_total_rows = 0;
104
220
    text_view -> gx_multi_line_text_view_line_index_old = GX_TRUE;
105
106
220
    _gx_widget_string_get_ext((GX_WIDGET *)text_view, text_id, &text_view -> gx_multi_line_text_view_text);
107
220
    text_view -> gx_multi_line_text_view_text.gx_string_ptr = GX_NULL;
108
109
#if defined(GX_DYNAMIC_BIDI_TEXT_SUPPORT)
110
    if (text_view -> gx_multi_line_text_view_bidi_resolved_text_info)
111
    {
112
        _gx_utility_bidi_resolved_text_info_delete(&text_view -> gx_multi_line_text_view_bidi_resolved_text_info);
113
    }
114
#endif
115
116
220
    if (text_view -> gx_widget_status & GX_STATUS_VISIBLE)
117
    {
118
219
        _gx_system_dirty_mark((GX_WIDGET *)text_view);
119
    }
120
121
220
    return(GX_SUCCESS);
122
}
123