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 /**   System Management (System)                                          */
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 
29 
30 /**************************************************************************/
31 /*                                                                        */
32 /*  FUNCTION                                               RELEASE        */
33 /*                                                                        */
34 /*    _gx_widget_pixelmap_get                            PORTABLE C       */
35 /*                                                           6.1          */
36 /*  AUTHOR                                                                */
37 /*                                                                        */
38 /*    Kenneth Maxwell, Microsoft Corporation                              */
39 /*                                                                        */
40 /*  DESCRIPTION                                                           */
41 /*                                                                        */
42 /*    This service gets the pixelmap associated with the supplied         */
43 /*      resource ID.                                                      */
44 /*                                                                        */
45 /*  INPUT                                                                 */
46 /*                                                                        */
47 /*    widget                                Called widget control block   */
48 /*    pixelmap_id                           Pixelmap resource ID          */
49 /*    return_pixelmap                       Pointer to pixelmap           */
50 /*                                            destination pointer         */
51 /*                                                                        */
52 /*  OUTPUT                                                                */
53 /*                                                                        */
54 /*    status                                Completion status             */
55 /*                                                                        */
56 /*  CALLS                                                                 */
57 /*                                                                        */
58 /*    _gx_widget_pixelmap_get               Actual widget pixelmap get    */
59 /*                                            function                    */
60 /*                                                                        */
61 /*  CALLED BY                                                             */
62 /*                                                                        */
63 /*    Application Code                                                    */
64 /*    _gx_drop_list_pixelmap_set            Assign pixelmap to drop list  */
65 /*    _gx_icon_pixelmap_update              Update pixelmap in an icon    */
66 /*    _gx_pixelmap_slider_pixelmap_update   Update pixelmap in slider     */
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_widget_pixelmap_get(GX_WIDGET * widget,GX_RESOURCE_ID resource_id,GX_PIXELMAP ** return_pixelmap)77 UINT  _gx_widget_pixelmap_get(GX_WIDGET *widget, GX_RESOURCE_ID resource_id, GX_PIXELMAP **return_pixelmap)
78 {
79 GX_PIXELMAP *map = GX_NULL;
80 UINT         status = GX_INVALID_CANVAS;
81 
82 GX_CANVAS   *canvas;
83 GX_DISPLAY  *display;
84 
85     if (widget -> gx_widget_status & GX_STATUS_VISIBLE)
86     {
87         _gx_widget_canvas_get(widget, &canvas);
88 
89         if (canvas)
90         {
91             display = canvas -> gx_canvas_display;
92 
93             /* Determine if the ID is within range.  */
94             if (resource_id < display -> gx_display_pixelmap_table_size)
95             {
96                 /* Yes, the ID is within range. Perform a table lookup and return the
97                    pixelmap pointer.  */
98                 map = display -> gx_display_pixelmap_table[resource_id];
99                 status = GX_SUCCESS;
100             }
101             else
102             {
103                 status = GX_INVALID_RESOURCE_ID;
104             }
105         }
106     }
107 
108     *return_pixelmap = map;
109     return status;
110 }
111 
112