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 /**************************************************************************/ _gx_multi_line_text_view_text_id_set(GX_MULTI_LINE_TEXT_VIEW * text_view,GX_RESOURCE_ID text_id)91UINT _gx_multi_line_text_view_text_id_set(GX_MULTI_LINE_TEXT_VIEW *text_view, 92 GX_RESOURCE_ID text_id) 93 { 94 if (text_view -> gx_widget_style & GX_STYLE_TEXT_COPY) 95 { 96 if (text_view -> gx_multi_line_text_view_text.gx_string_ptr) 97 { 98 _gx_system_memory_free((void *)text_view -> gx_multi_line_text_view_text.gx_string_ptr); 99 } 100 } 101 102 text_view -> gx_multi_line_text_view_text_id = text_id; 103 text_view -> gx_multi_line_text_view_text_total_rows = 0; 104 text_view -> gx_multi_line_text_view_line_index_old = GX_TRUE; 105 106 _gx_widget_string_get_ext((GX_WIDGET *)text_view, text_id, &text_view -> gx_multi_line_text_view_text); 107 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 if (text_view -> gx_widget_status & GX_STATUS_VISIBLE) 117 { 118 _gx_system_dirty_mark((GX_WIDGET *)text_view); 119 } 120 121 return(GX_SUCCESS); 122 } 123 124