GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_multi_line_text_view_event_process.c Lines: 41 41 100.0 %
Date: 2024-12-05 08:52:37 Branches: 28 28 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_multi_line_text_view.h"
28
#include "gx_window.h"
29
#include "gx_system.h"
30
#include "gx_utility.h"
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _gx_multi_line_text_view_event_process              PORTABLE C      */
37
/*                                                           6.1          */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Kenneth Maxwell, Microsoft Corporation                              */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This service processes an event for a multi-line text view widget.  */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    text_view                             Multi-line text view widget   */
49
/*                                            control block               */
50
/*    event_ptr                             Point to event to process     */
51
/*                                                                        */
52
/*  OUTPUT                                                                */
53
/*                                                                        */
54
/*    status                                Completion status             */
55
/*                                                                        */
56
/*  CALLS                                                                 */
57
/*                                                                        */
58
/*    _gx_multi_line_text_view_text_id_set  Set new text id               */
59
/*    _gx_multi_line_text_view_scroll       Scroll the text view window   */
60
/*    _gx_window_event_process              Window event process          */
61
/*                                                                        */
62
/*  CALLED BY                                                             */
63
/*                                                                        */
64
/*    Application Code                                                    */
65
/*                                                                        */
66
/*  RELEASE HISTORY                                                       */
67
/*                                                                        */
68
/*    DATE              NAME                      DESCRIPTION             */
69
/*                                                                        */
70
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
71
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
72
/*                                            added delete event handle,  */
73
/*                                            added logic to handle new   */
74
/*                                            events,                     */
75
/*                                            resulting in version 6.1    */
76
/*                                                                        */
77
/**************************************************************************/
78
79
2619
UINT _gx_multi_line_text_view_event_process(GX_MULTI_LINE_TEXT_VIEW *text_view, GX_EVENT *event_ptr)
80
{
81


2619
    switch (event_ptr -> gx_event_type)
82
    {
83
177
    case GX_EVENT_SHOW:
84
177
        _gx_window_event_process((GX_WINDOW *)text_view, event_ptr);
85
86
        /* If the text view text ID is specified.*/
87
177
        if (text_view -> gx_multi_line_text_view_text_id)
88
        {
89
167
            _gx_multi_line_text_view_text_id_set(text_view, text_view -> gx_multi_line_text_view_text_id);
90
        }
91
92
        /* Get visible rows. */
93
177
        _gx_multi_line_text_view_visible_rows_compute(text_view);
94
177
        break;
95
96
72
    case GX_EVENT_RESIZED:
97
72
        if (text_view -> gx_widget_status & GX_STATUS_VISIBLE)
98
        {
99
71
            text_view -> gx_multi_line_text_view_line_index_old = GX_TRUE;
100
101
#if defined(GX_DYNAMIC_BIDI_TEXT_SUPPORT)
102
            if (text_view -> gx_multi_line_text_view_bidi_resolved_text_info)
103
            {
104
                /* Widget size changed, clear reorderd bidi text so that it will be recreated when needed. */
105
                _gx_utility_bidi_resolved_text_info_delete(&text_view -> gx_multi_line_text_view_bidi_resolved_text_info);
106
            }
107
#endif
108
        }
109
72
        break;
110
111
83
    case GX_EVENT_CLIENT_UPDATED:
112
83
        if (text_view -> gx_widget_status & GX_STATUS_VISIBLE)
113
        {
114
82
            text_view -> gx_multi_line_text_view_line_index_old = GX_TRUE;
115
82
            _gx_system_dirty_mark((GX_WIDGET *)text_view);
116
        }
117
83
        break;
118
119
318
    case GX_EVENT_STYLE_CHANGED:
120
318
        if (text_view -> gx_widget_status & GX_STATUS_VISIBLE)
121
        {
122
314
            if ((event_ptr -> gx_event_payload.gx_event_ulongdata & GX_STYLE_BORDER_MASK) !=
123
314
                (text_view -> gx_widget_style & GX_STYLE_BORDER_MASK))
124
            {
125
1
                text_view -> gx_multi_line_text_view_line_index_old = GX_TRUE;
126
            }
127
        }
128
318
        break;
129
130
7
    case GX_EVENT_LANGUAGE_CHANGE:
131
7
        if (text_view -> gx_multi_line_text_view_text_id)
132
        {
133
6
            _gx_multi_line_text_view_text_id_set(text_view, text_view -> gx_multi_line_text_view_text_id);
134
        }
135
7
        break;
136
137
#if defined(GX_DYNAMIC_BIDI_TEXT_SUPPORT)
138
    case GX_EVENT_DYNAMIC_BIDI_TEXT_ENABLE:
139
    case GX_EVENT_DYNAMIC_BIDI_TEXT_DISABLE:
140
        text_view -> gx_multi_line_text_view_line_index_old = GX_TRUE;
141
        break;
142
#endif
143
144
10
    case GX_EVENT_DELETE:
145
10
        if ((text_view -> gx_widget_style & GX_STYLE_TEXT_COPY) &&
146
6
            text_view -> gx_multi_line_text_view_text.gx_string_ptr &&
147
5
            text_view -> gx_multi_line_text_view_text_id == 0)
148
        {
149
4
            if (!_gx_system_memory_free)
150
            {
151
1
                return GX_SYSTEM_MEMORY_ERROR;
152
            }
153
3
            _gx_system_memory_free((void *)text_view -> gx_multi_line_text_view_text.gx_string_ptr);
154
3
            text_view -> gx_multi_line_text_view_text.gx_string_ptr = GX_NULL;
155
3
            text_view -> gx_multi_line_text_view_text.gx_string_length = 0;
156
        }
157
158
#if defined(GX_DYNAMIC_BIDI_TEXT_SUPPORT)
159
        if (text_view -> gx_multi_line_text_view_bidi_resolved_text_info)
160
        {
161
            _gx_utility_bidi_resolved_text_info_delete(&text_view -> gx_multi_line_text_view_bidi_resolved_text_info);
162
        }
163
#endif
164
9
         break;
165
166
1116
    case GX_EVENT_VERTICAL_SCROLL:
167
1116
        _gx_multi_line_text_view_scroll(text_view, (GX_VALUE)(event_ptr -> gx_event_payload.gx_event_intdata[1] - event_ptr -> gx_event_payload.gx_event_intdata[0]));
168
1116
        return 0;
169
    }
170
171
1502
    return(_gx_window_event_process((GX_WINDOW *)text_view, event_ptr));
172
}
173