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