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 Button Management (Button) */ 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_display.h" 29 #include "gx_context.h" 30 #include "gx_widget.h" 31 #include "gx_button.h" 32 33 /**************************************************************************/ 34 /* */ 35 /* FUNCTION RELEASE */ 36 /* */ 37 /* _gx_text_button_text_draw PORTABLE C */ 38 /* 6.1 */ 39 /* AUTHOR */ 40 /* */ 41 /* Kenneth Maxwell, Microsoft Corporation */ 42 /* */ 43 /* DESCRIPTION */ 44 /* */ 45 /* This function draws the button text */ 46 /* */ 47 /* INPUT */ 48 /* */ 49 /* button Text button control block */ 50 /* */ 51 /* OUTPUT */ 52 /* */ 53 /* None */ 54 /* */ 55 /* CALLS */ 56 /* */ 57 /* _gx_widget_text_id_draw Draw text using resource ID */ 58 /* _gx_widget_text_draw Draw text string */ 59 /* */ 60 /* CALLED BY */ 61 /* */ 62 /* Application Code */ 63 /* GUIX Internal Code */ 64 /* */ 65 /* RELEASE HISTORY */ 66 /* */ 67 /* DATE NAME DESCRIPTION */ 68 /* */ 69 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ 70 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */ 71 /* improved logic, */ 72 /* resulting in version 6.1 */ 73 74 /* */ 75 /**************************************************************************/ _gx_text_button_text_draw(GX_TEXT_BUTTON * button)76VOID _gx_text_button_text_draw(GX_TEXT_BUTTON *button) 77 { 78 GX_WIDGET *widget; 79 INT xtextoffset = 0; 80 INT ytextoffset = 0; 81 GX_RESOURCE_ID color; 82 GX_STRING string; 83 84 /* Setup the button. */ 85 widget = (GX_WIDGET *)button; 86 87 /* draw the text */ 88 89 if (widget -> gx_widget_style & GX_STYLE_ENABLED) 90 { 91 if (widget -> gx_widget_style & GX_STYLE_BUTTON_PUSHED) 92 { 93 xtextoffset = ytextoffset = 1; 94 color = button -> gx_text_button_selected_text_color; 95 } 96 else 97 { 98 color = button -> gx_text_button_normal_text_color; 99 } 100 } 101 else 102 { 103 color = button -> gx_text_button_disabled_text_color; 104 } 105 106 _gx_text_button_text_get_ext(button, &string); 107 108 if (string.gx_string_ptr) 109 { 110 _gx_widget_text_draw_ext(widget, color, 111 button -> gx_text_button_font_id, 112 &string, xtextoffset, ytextoffset); 113 } 114 } 115 116