1 /**************************************************************************/
2 /* */
3 /* Copyright (c) Microsoft Corporation. All rights reserved. */
4 /* */
5 /* This software is licensed under the Microsoft Software License */
6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */
7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
8 /* and in the root directory of this software. */
9 /* */
10 /**************************************************************************/
11
12
13 /**************************************************************************/
14 /**************************************************************************/
15 /** */
16 /** GUIX Component */
17 /** */
18 /** Multi Line Text View Management (Multi Line Text View) */
19 /** */
20 /**************************************************************************/
21
22 #define GX_SOURCE_CODE
23
24
25 /* Include necessary system files. */
26
27 #include "gx_api.h"
28 #include "gx_multi_line_text_view.h"
29 #include "gx_window.h"
30 #include "gx_system.h"
31 #include "gx_utility.h"
32
33 /**************************************************************************/
34 /* */
35 /* FUNCTION RELEASE */
36 /* */
37 /* _gx_multi_line_text_view_event_process PORTABLE C */
38 /* 6.1 */
39 /* AUTHOR */
40 /* */
41 /* Kenneth Maxwell, Microsoft Corporation */
42 /* */
43 /* DESCRIPTION */
44 /* */
45 /* This service processes an event for a multi-line text view widget. */
46 /* */
47 /* INPUT */
48 /* */
49 /* text_view Multi-line text view widget */
50 /* control block */
51 /* event_ptr Point to event to process */
52 /* */
53 /* OUTPUT */
54 /* */
55 /* status Completion status */
56 /* */
57 /* CALLS */
58 /* */
59 /* _gx_multi_line_text_view_text_id_set Set new text id */
60 /* _gx_multi_line_text_view_scroll Scroll the text view window */
61 /* _gx_window_event_process Window event process */
62 /* */
63 /* CALLED BY */
64 /* */
65 /* Application Code */
66 /* */
67 /* RELEASE HISTORY */
68 /* */
69 /* DATE NAME DESCRIPTION */
70 /* */
71 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
72 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
73 /* added delete event handle, */
74 /* added logic to handle new */
75 /* events, */
76 /* resulting in version 6.1 */
77 /* */
78 /**************************************************************************/
79
_gx_multi_line_text_view_event_process(GX_MULTI_LINE_TEXT_VIEW * text_view,GX_EVENT * event_ptr)80 UINT _gx_multi_line_text_view_event_process(GX_MULTI_LINE_TEXT_VIEW *text_view, GX_EVENT *event_ptr)
81 {
82 switch (event_ptr -> gx_event_type)
83 {
84 case GX_EVENT_SHOW:
85 _gx_window_event_process((GX_WINDOW *)text_view, event_ptr);
86
87 /* If the text view text ID is specified.*/
88 if (text_view -> gx_multi_line_text_view_text_id)
89 {
90 _gx_multi_line_text_view_text_id_set(text_view, text_view -> gx_multi_line_text_view_text_id);
91 }
92
93 /* Get visible rows. */
94 _gx_multi_line_text_view_visible_rows_compute(text_view);
95 break;
96
97 case GX_EVENT_RESIZED:
98 if (text_view -> gx_widget_status & GX_STATUS_VISIBLE)
99 {
100 text_view -> gx_multi_line_text_view_line_index_old = GX_TRUE;
101
102 #if defined(GX_DYNAMIC_BIDI_TEXT_SUPPORT)
103 if (text_view -> gx_multi_line_text_view_bidi_resolved_text_info)
104 {
105 /* Widget size changed, clear reorderd bidi text so that it will be recreated when needed. */
106 _gx_utility_bidi_resolved_text_info_delete(&text_view -> gx_multi_line_text_view_bidi_resolved_text_info);
107 }
108 #endif
109 }
110 break;
111
112 case GX_EVENT_CLIENT_UPDATED:
113 if (text_view -> gx_widget_status & GX_STATUS_VISIBLE)
114 {
115 text_view -> gx_multi_line_text_view_line_index_old = GX_TRUE;
116 _gx_system_dirty_mark((GX_WIDGET *)text_view);
117 }
118 break;
119
120 case GX_EVENT_STYLE_CHANGED:
121 if (text_view -> gx_widget_status & GX_STATUS_VISIBLE)
122 {
123 if ((event_ptr -> gx_event_payload.gx_event_ulongdata & GX_STYLE_BORDER_MASK) !=
124 (text_view -> gx_widget_style & GX_STYLE_BORDER_MASK))
125 {
126 text_view -> gx_multi_line_text_view_line_index_old = GX_TRUE;
127 }
128 }
129 break;
130
131 case GX_EVENT_LANGUAGE_CHANGE:
132 if (text_view -> gx_multi_line_text_view_text_id)
133 {
134 _gx_multi_line_text_view_text_id_set(text_view, text_view -> gx_multi_line_text_view_text_id);
135 }
136 break;
137
138 #if defined(GX_DYNAMIC_BIDI_TEXT_SUPPORT)
139 case GX_EVENT_DYNAMIC_BIDI_TEXT_ENABLE:
140 case GX_EVENT_DYNAMIC_BIDI_TEXT_DISABLE:
141 text_view -> gx_multi_line_text_view_line_index_old = GX_TRUE;
142 break;
143 #endif
144
145 case GX_EVENT_DELETE:
146 if ((text_view -> gx_widget_style & GX_STYLE_TEXT_COPY) &&
147 text_view -> gx_multi_line_text_view_text.gx_string_ptr &&
148 text_view -> gx_multi_line_text_view_text_id == 0)
149 {
150 if (!_gx_system_memory_free)
151 {
152 return GX_SYSTEM_MEMORY_ERROR;
153 }
154 _gx_system_memory_free((void *)text_view -> gx_multi_line_text_view_text.gx_string_ptr);
155 text_view -> gx_multi_line_text_view_text.gx_string_ptr = GX_NULL;
156 text_view -> gx_multi_line_text_view_text.gx_string_length = 0;
157 }
158
159 #if defined(GX_DYNAMIC_BIDI_TEXT_SUPPORT)
160 if (text_view -> gx_multi_line_text_view_bidi_resolved_text_info)
161 {
162 _gx_utility_bidi_resolved_text_info_delete(&text_view -> gx_multi_line_text_view_bidi_resolved_text_info);
163 }
164 #endif
165 break;
166
167 case GX_EVENT_VERTICAL_SCROLL:
168 _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]));
169 return 0;
170 }
171
172 return(_gx_window_event_process((GX_WINDOW *)text_view, event_ptr));
173 }
174
175