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 /** 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_canvas.h" 29 #include "gx_context.h" 30 #include "gx_text_input_cursor.h" 31 32 /**************************************************************************/ 33 /* */ 34 /* FUNCTION RELEASE */ 35 /* */ 36 /* _gx_text_input_cursor_draw PORTABLE C */ 37 /* 6.1 */ 38 /* AUTHOR */ 39 /* */ 40 /* Kenneth Maxwell, Microsoft Corporation */ 41 /* */ 42 /* DESCRIPTION */ 43 /* */ 44 /* This function calculates the cursor position and draws the cursor */ 45 /* */ 46 /* INPUT */ 47 /* */ 48 /* widget Widget control block */ 49 /* */ 50 /* OUTPUT */ 51 /* */ 52 /* None */ 53 /* */ 54 /* CALLS */ 55 /* */ 56 /* _gx_canvas_line_draw Draw the the specified line */ 57 /* on the current context */ 58 /* */ 59 /* CALLED BY */ 60 /* */ 61 /* Application Code */ 62 /* GUIX Internal Code */ 63 /* */ 64 /* RELEASE HISTORY */ 65 /* */ 66 /* DATE NAME DESCRIPTION */ 67 /* */ 68 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ 69 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */ 70 /* resulting in version 6.1 */ 71 /* */ 72 /**************************************************************************/ _gx_text_input_cursor_draw(GX_TEXT_INPUT_CURSOR * cursor_ptr)73VOID _gx_text_input_cursor_draw(GX_TEXT_INPUT_CURSOR *cursor_ptr) 74 { 75 GX_POINT cursor_pos = cursor_ptr -> gx_text_input_cursor_pos; 76 GX_VALUE y_start; 77 GX_VALUE y_end; 78 79 if(!cursor_ptr->gx_text_input_cursor_height) 80 { 81 return; 82 } 83 84 y_start = (GX_VALUE)(cursor_pos.gx_point_y - (cursor_ptr->gx_text_input_cursor_height >> 1)); 85 y_end = (GX_VALUE)(y_start + cursor_ptr->gx_text_input_cursor_height - 1); 86 87 /* Set brush width to cursor width. */ 88 _gx_context_brush_width_set((UINT)(cursor_ptr -> gx_text_input_cursor_width)); 89 90 /* Draw cursor line. */ 91 _gx_canvas_line_draw(cursor_pos.gx_point_x, y_start, cursor_pos.gx_point_x, y_end); 92 } 93 94