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 /** Circular Gauge Management (Circular Gauge) */ 18 /** */ 19 /**************************************************************************/ 20 21 #define GX_SOURCE_CODE 22 23 24 /* Include necessary system files. */ 25 26 #include "gx_api.h" 27 #include "gx_widget.h" 28 #include "gx_system.h" 29 #include "gx_circular_gauge.h" 30 #include "gx_utility.h" 31 32 33 /**************************************************************************/ 34 /* */ 35 /* FUNCTION RELEASE */ 36 /* */ 37 /* _gx_circular_gauge_needle_rotate PORTABLE C */ 38 /* 6.1 */ 39 /* AUTHOR */ 40 /* */ 41 /* Kenneth Maxwell, Microsoft Corporation */ 42 /* */ 43 /* DESCRIPTION */ 44 /* */ 45 /* This function rotates the needle of the specified circular gauge. */ 46 /* */ 47 /* INPUT */ 48 /* */ 49 /* circular_gauge Circular gauge control block */ 50 /* */ 51 /* OUTPUT */ 52 /* */ 53 /* status Completion status */ 54 /* */ 55 /* CALLS */ 56 /* */ 57 /* _gx_context_pixelmap_get Gets the pixelmap associated */ 58 /* the supplied resource ID. */ 59 /* _gx_utility_pixelmap_rotate Rotate a pixelmap. */ 60 /* */ 61 /* CALLED BY */ 62 /* */ 63 /* Application 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 /* resulting in version 6.1 */ 72 /* */ 73 /**************************************************************************/ _gx_circular_gauge_needle_rotate(GX_CIRCULAR_GAUGE * gauge)74UINT _gx_circular_gauge_needle_rotate(GX_CIRCULAR_GAUGE *gauge) 75 { 76 UINT status = GX_SUCCESS; 77 GX_CIRCULAR_GAUGE_INFO *info; 78 INT xcor; 79 INT ycor; 80 81 82 /* Pick up pointer to the gauge information structure. */ 83 info = &gauge -> gx_circular_gauge_info; 84 85 if (gauge -> gx_circular_gauge_needle_source) 86 { 87 xcor = (INT)(info -> gx_circular_gauge_info_needle_xcor); 88 ycor = (INT)(info -> gx_circular_gauge_info_needle_ycor); 89 90 gauge -> gx_circular_gauge_current_needle_x = info -> gx_circular_gauge_info_needle_xpos; 91 gauge -> gx_circular_gauge_current_needle_y = info -> gx_circular_gauge_info_needle_ypos; 92 93 /* Rotate needle pixelmap. */ 94 95 status = _gx_utility_pixelmap_rotate(gauge -> gx_circular_gauge_needle_source, gauge -> gx_circular_gauge_current_angle, 96 &(gauge -> gx_circular_gauge_needle_rotated), 97 &xcor, &ycor); 98 99 if (status == GX_SUCCESS) 100 { 101 /* Calculate start position of needle pixelmap. */ 102 gauge -> gx_circular_gauge_current_needle_x = gauge -> gx_widget_size.gx_rectangle_left + info -> gx_circular_gauge_info_needle_xpos; 103 104 gauge -> gx_circular_gauge_current_needle_x -= xcor; 105 106 gauge -> gx_circular_gauge_current_needle_y = gauge -> gx_widget_size.gx_rectangle_top + info -> gx_circular_gauge_info_needle_ypos; 107 gauge -> gx_circular_gauge_current_needle_y -= ycor; 108 } 109 } 110 111 return status; 112 } 113 114 /**************************************************************************/ _gx_circular_gauge_needle_rotate_callback(VOID * gauge)115UINT _gx_circular_gauge_needle_rotate_callback(VOID *gauge) 116 { 117 return _gx_circular_gauge_needle_rotate((GX_CIRCULAR_GAUGE *)gauge); 118 } 119 120