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