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 /**   Pixelmap Prompt Management (Prompt)                                 */
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_canvas.h"
30 #include "gx_context.h"
31 #include "gx_widget.h"
32 #include "gx_prompt.h"
33 #include "gx_pixelmap_prompt.h"
34 
35 
36 /**************************************************************************/
37 /*                                                                        */
38 /*  FUNCTION                                               RELEASE        */
39 /*                                                                        */
40 /*    _gx_pixelmap_prompt_background_draw                 PORTABLE C      */
41 /*                                                           6.1          */
42 /*  AUTHOR                                                                */
43 /*                                                                        */
44 /*    Kenneth Maxwell, Microsoft Corporation                              */
45 /*                                                                        */
46 /*  DESCRIPTION                                                           */
47 /*                                                                        */
48 /*    This function draws the background of a pixelmap prompt widget.     */
49 /*                                                                        */
50 /*  INPUT                                                                 */
51 /*                                                                        */
52 /*    prompt                                Pixelmap prompt control block */
53 /*                                                                        */
54 /*  OUTPUT                                                                */
55 /*                                                                        */
56 /*    None                                                                */
57 /*                                                                        */
58 /*  CALLS                                                                 */
59 /*                                                                        */
60 /*    _gx_widget_background_draw            Draw the widget's background  */
61 /*    _gx_context_pixelmap_get              Retrieve pixelmap image       */
62 /*    _gx_canvas_pixelmap_draw              Draw a pixelmap               */
63 /*    _gx_canvas_pixelmap_tile              Tile a pixelmap               */
64 /*                                                                        */
65 /*  CALLED BY                                                             */
66 /*                                                                        */
67 /*    Application Code                                                    */
68 /*    GUIX Internal Code                                                  */
69 /*                                                                        */
70 /*  RELEASE HISTORY                                                       */
71 /*                                                                        */
72 /*    DATE              NAME                      DESCRIPTION             */
73 /*                                                                        */
74 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
75 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
76 /*                                            resulting in version 6.1    */
77 /*                                                                        */
78 /**************************************************************************/
_gx_pixelmap_prompt_background_draw(GX_PIXELMAP_PROMPT * prompt)79 VOID  _gx_pixelmap_prompt_background_draw(GX_PIXELMAP_PROMPT *prompt)
80 {
81 GX_WIDGET     *widget = (GX_WIDGET *)prompt;
82 GX_RECTANGLE   fill_rect = widget -> gx_widget_size;
83 GX_PIXELMAP   *map;
84 GX_RESOURCE_ID fill_id;
85 GX_RESOURCE_ID left_id;
86 GX_RESOURCE_ID right_id;
87 
88 
89     fill_id = prompt -> gx_normal_fill_pixelmap_id;
90     left_id = prompt -> gx_normal_left_pixelmap_id;
91     right_id = prompt -> gx_normal_right_pixelmap_id;
92 
93     if (prompt -> gx_widget_style & GX_STYLE_DRAW_SELECTED)
94     {
95         if (prompt -> gx_selected_fill_pixelmap_id)
96         {
97             fill_id = prompt -> gx_selected_fill_pixelmap_id;
98         }
99         if (prompt -> gx_selected_left_pixelmap_id)
100         {
101             left_id = prompt -> gx_selected_left_pixelmap_id;
102         }
103         if (prompt -> gx_selected_right_pixelmap_id)
104         {
105             right_id = prompt -> gx_selected_right_pixelmap_id;
106         }
107     }
108 
109 
110     /* draw the background */
111     if (fill_id == 0 &&
112         !(prompt -> gx_widget_style & GX_STYLE_TRANSPARENT))
113     {
114         _gx_widget_background_draw(widget);
115     }
116 
117     /* draw the left-end pixelmap if one was provided */
118     if (left_id)
119     {
120         _gx_context_pixelmap_get(left_id, &map);
121         if (map)
122         {
123             _gx_widget_context_fill_set(widget);
124             _gx_canvas_pixelmap_draw(fill_rect.gx_rectangle_left,
125                                      fill_rect.gx_rectangle_top, map);
126             fill_rect.gx_rectangle_left = (GX_VALUE)(fill_rect.gx_rectangle_left + map -> gx_pixelmap_width);
127         }
128     }
129 
130     /* draw the right end pixelmap, if one was provided */
131     if (right_id)
132     {
133         _gx_context_pixelmap_get(right_id, &map);
134         if (map)
135         {
136             _gx_widget_context_fill_set(widget);
137             _gx_canvas_pixelmap_draw((GX_VALUE)(fill_rect.gx_rectangle_right - map -> gx_pixelmap_width + 1),
138                                      fill_rect.gx_rectangle_top, map);
139             fill_rect.gx_rectangle_right = (GX_VALUE)(fill_rect.gx_rectangle_right - map -> gx_pixelmap_width);
140         }
141     }
142 
143     /* now fill the remaining area with the fill pixelmap */
144     if (fill_id)
145     {
146         _gx_context_pixelmap_get(fill_id, &map);
147         if (map)
148         {
149             _gx_canvas_pixelmap_tile(&fill_rect, map);
150         }
151     }
152 }
153 
154