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 /** Context Management (Context) */ 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_context.h" 29 30 31 /**************************************************************************/ 32 /* */ 33 /* FUNCTION RELEASE */ 34 /* */ 35 /* _gx_context_color_get PORTABLE C */ 36 /* 6.1 */ 37 /* AUTHOR */ 38 /* */ 39 /* Kenneth Maxwell, Microsoft Corporation */ 40 /* */ 41 /* DESCRIPTION */ 42 /* */ 43 /* This service gets the color associated with the supplied */ 44 /* resource ID from the system color table. */ 45 /* */ 46 /* INPUT */ 47 /* */ 48 /* color_id Resource ID of color */ 49 /* return_color Pointer to destination for */ 50 /* color */ 51 /* */ 52 /* OUTPUT */ 53 /* */ 54 /* status Completion status */ 55 /* */ 56 /* CALLS */ 57 /* */ 58 /* None */ 59 /* */ 60 /* CALLED BY */ 61 /* */ 62 /* Application Code */ 63 /* _gx_context_brush_define */ 64 /* _gx_context_fill_color_set */ 65 /* _gx_context_line_color_set */ 66 /* */ 67 /* RELEASE HISTORY */ 68 /* */ 69 /* DATE NAME DESCRIPTION */ 70 /* */ 71 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ 72 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */ 73 /* resulting in version 6.1 */ 74 /* */ 75 /**************************************************************************/ _gx_context_color_get(GX_RESOURCE_ID color_id,GX_COLOR * return_color)76UINT _gx_context_color_get(GX_RESOURCE_ID color_id, GX_COLOR *return_color) 77 { 78 UINT status; 79 GX_DRAW_CONTEXT *context = _gx_system_current_draw_context; 80 GX_DISPLAY *display; 81 82 display = context -> gx_draw_context_display; 83 84 /* Determine if the ID is within range. */ 85 if (display == GX_NULL) 86 { 87 *return_color = 0; 88 return GX_INVALID_DISPLAY; 89 } 90 91 if ((color_id < display -> gx_display_color_table_size) && (display -> gx_display_color_table != GX_NULL)) 92 { 93 /* Yes, the ID is within range. Perform a table lookup and return the 94 color. */ 95 *return_color = display -> gx_display_color_table[color_id]; 96 status = GX_SUCCESS; 97 } 98 else 99 { 100 *return_color = 0; 101 status = GX_INVALID_RESOURCE_ID; 102 } 103 104 return status; 105 } 106 107