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 /**   System Management (System)                                          */
19 /**                                                                       */
20 /**************************************************************************/
21 
22 #define GX_SOURCE_CODE
23 
24 
25 /* Include necessary system files.  */
26 
27 #include "gx_api.h"
28 #include "gx_widget.h"
29 
30 
31 /**************************************************************************/
32 /*                                                                        */
33 /*  FUNCTION                                               RELEASE        */
34 /*                                                                        */
35 /*    _gx_widget_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 /*    widget                                caller identify               */
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 /*    _gx_widget_canvas_get                 Get canvas pointer            */
60 /*                                                                        */
61 /*  CALLED BY                                                             */
62 /*                                                                        */
63 /*    Application Code                                                    */
64 /*    GUIX default draw funtions                                          */
65 /*                                                                        */
66 /*  RELEASE HISTORY                                                       */
67 /*                                                                        */
68 /*    DATE              NAME                      DESCRIPTION             */
69 /*                                                                        */
70 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
71 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
72 /*                                            resulting in version 6.1    */
73 /*                                                                        */
74 /**************************************************************************/
_gx_widget_color_get(GX_WIDGET * widget,GX_RESOURCE_ID color_id,GX_COLOR * return_color)75 UINT _gx_widget_color_get(GX_WIDGET *widget, GX_RESOURCE_ID color_id, GX_COLOR *return_color)
76 {
77 UINT        status = GX_INVALID_CANVAS;
78 GX_COLOR    colorval = 0;
79 GX_CANVAS  *canvas;
80 GX_DISPLAY *display;
81 
82     if (widget -> gx_widget_status & GX_STATUS_VISIBLE)
83     {
84         _gx_widget_canvas_get(widget, &canvas);
85 
86         if (canvas)
87         {
88             display = canvas -> gx_canvas_display;
89 
90             /* Determine if the ID is within range.  */
91             if (color_id < display -> gx_display_color_table_size)
92             {
93                 /* Yes, the ID is within range. Perform a table lookup and return the
94                    color.  */
95                 colorval = display -> gx_display_color_table[color_id];
96                 status = GX_SUCCESS;
97             }
98             else
99             {
100                 status = GX_INVALID_RESOURCE_ID;
101             }
102         }
103     }
104     *return_color = colorval;
105     return(status);
106 }
107 
108