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 Input */ 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_input.h" 30 #include "gx_multi_line_text_view.h" 31 #include "gx_text_input_cursor.h" 32 33 /**************************************************************************/ 34 /* */ 35 /* FUNCTION RELEASE */ 36 /* */ 37 /* _gx_multi_line_text_input_home PORTABLE C */ 38 /* 6.1 */ 39 /* AUTHOR */ 40 /* */ 41 /* Kenneth Maxwell, Microsoft Corporation */ 42 /* */ 43 /* DESCRIPTION */ 44 /* */ 45 /* This function move the cursor to the position */ 46 /* before the first character. */ 47 /* */ 48 /* INPUT */ 49 /* */ 50 /* text_input Multi line text input */ 51 /* control block */ 52 /* */ 53 /* OUTPUT */ 54 /* */ 55 /* None */ 56 /* */ 57 /* CALLS */ 58 /* */ 59 /* _gx_multi_line_text_input_cursor_pos_calculate */ 60 /* Calculate cursor position */ 61 /* according to click point */ 62 /* _gx_multi_line_text_input_cursor_rectangle_define */ 63 /* Define a rectangle for the */ 64 /* cursor */ 65 /* _gx_system_dirty_partial_add Add one dirty area to */ 66 /* dirty list */ 67 /* */ 68 /* CALLED BY */ 69 /* */ 70 /* _gx_multi_line_text_input_keydown_process */ 71 /* */ 72 /* RELEASE HISTORY */ 73 /* */ 74 /* DATE NAME DESCRIPTION */ 75 /* */ 76 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ 77 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */ 78 /* resulting in version 6.1 */ 79 /* */ 80 /**************************************************************************/ _gx_multi_line_text_input_home(GX_MULTI_LINE_TEXT_INPUT * text_input)81UINT _gx_multi_line_text_input_home(GX_MULTI_LINE_TEXT_INPUT *text_input) 82 { 83 GX_TEXT_INPUT_CURSOR *cursor_ptr = &text_input -> gx_multi_line_text_input_cursor_instance; 84 GX_POINT cur_pos; 85 GX_RECTANGLE cur_rect; 86 87 if (text_input -> gx_multi_line_text_input_start_mark != text_input -> gx_multi_line_text_input_end_mark) 88 { 89 _gx_multi_line_text_input_left_arrow(text_input); 90 } 91 92 cur_pos = cursor_ptr -> gx_text_input_cursor_pos; 93 94 _gx_text_input_cursor_dirty_rectangle_get(&text_input -> gx_multi_line_text_input_cursor_instance, &cur_rect); 95 96 cur_pos.gx_point_x = (GX_VALUE)(text_input -> gx_window_client.gx_rectangle_left + 97 text_input -> gx_multi_line_text_view_whitespace); 98 99 /* Calculate new cursor position. */ 100 _gx_multi_line_text_input_cursor_pos_calculate(text_input, cur_pos); 101 102 if (cur_rect.gx_rectangle_left != cursor_ptr -> gx_text_input_cursor_pos.gx_point_x) 103 { 104 /* Mark old cursor rectangle dirty. */ 105 _gx_system_dirty_partial_add((GX_WIDGET *)text_input, &cur_rect); 106 107 /* Mark new cursor rectangle dirty. */ 108 _gx_text_input_cursor_dirty_rectangle_get(&text_input -> gx_multi_line_text_input_cursor_instance, &cur_rect); 109 _gx_system_dirty_partial_add((GX_WIDGET *)text_input, &cur_rect); 110 } 111 112 return GX_SUCCESS; 113 } 114 115