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