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 /**   Widget Management (Widget)                                          */
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_utility.h"
31 #include "gx_widget.h"
32 
33 
34 /**************************************************************************/
35 /*                                                                        */
36 /*  FUNCTION                                               RELEASE        */
37 /*                                                                        */
38 /*    _gx_widget_children_draw                            PORTABLE C      */
39 /*                                                           6.1          */
40 /*  AUTHOR                                                                */
41 /*                                                                        */
42 /*    Kenneth Maxwell, Microsoft Corporation                              */
43 /*                                                                        */
44 /*  DESCRIPTION                                                           */
45 /*                                                                        */
46 /*    This service draws all children of widget.                          */
47 /*                                                                        */
48 /*  INPUT                                                                 */
49 /*                                                                        */
50 /*    widget                                Pointer to widget             */
51 /*                                                                        */
52 /*  OUTPUT                                                                */
53 /*                                                                        */
54 /*    None                                                                */
55 /*                                                                        */
56 /*  CALLS                                                                 */
57 /*                                                                        */
58 /*    _gx_canvas_drawing_complete           Complete drawing on canvas    */
59 /*    _gx_canvas_drawing_initiate           Initiate drawing on canvas    */
60 /*    _gx_utility_rectangle_overlap_detect  Check for overlap             */
61 /*    [gx_widget_draw_function]             Child widget drawing function */
62 /*                                                                        */
63 /*  CALLED BY                                                             */
64 /*                                                                        */
65 /*    Application Code                                                    */
66 /*    GUIX Internal Code                                                  */
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_children_draw(GX_WIDGET * widget)77 VOID  _gx_widget_children_draw(GX_WIDGET *widget)
78 {
79 UINT             status;
80 GX_WIDGET       *child;
81 GX_CANVAS       *canvas;
82 GX_DRAW_CONTEXT *context;
83 GX_RECTANGLE    *dirty_area;
84 GX_RECTANGLE     overlap;
85 
86     /* Pickup the first child.  */
87     child =   widget -> gx_widget_first_child;
88 
89     if (!child)
90     {
91         return;
92     }
93 
94     /* pick up the current context */
95     context = _gx_system_current_draw_context;
96 
97     /* pickup the current canvas */
98 
99     canvas =  context -> gx_draw_context_canvas;
100     dirty_area = &(context -> gx_draw_context_dirty);
101 
102     /* Draw all the child widgets that overlap the clipping area.  */
103 
104     while (child)
105     {
106         if (child -> gx_widget_status & GX_STATUS_VISIBLE)
107         {
108             if (_gx_utility_rectangle_overlap_detect(&child -> gx_widget_clip, dirty_area, &overlap))
109             {
110                 /* Initiate drawing on this canvas.  */
111                 status = _gx_canvas_drawing_initiate(canvas, child, &overlap);
112 
113                 if (status == GX_SUCCESS)
114                 {
115                     /* Yes, draw the child widget.  */
116                     child -> gx_widget_draw_function(child);
117                     _gx_canvas_drawing_complete(canvas, GX_FALSE);
118                 }
119                 else
120                 {
121                     if (status == GX_NO_VIEWS)
122                     {
123                         /* Complete drawing on this canvas.  */
124                         _gx_canvas_drawing_complete(canvas, GX_FALSE);
125                     }
126                 }
127             }
128         }
129 
130         /* Move to next child.  */
131         child =  child -> gx_widget_next;
132     }
133 }
134 
135