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_system.h"
29 #include "gx_utility.h"
30 #include "gx_widget.h"
31 
32 
33 /**************************************************************************/
34 /*                                                                        */
35 /*  FUNCTION                                               RELEASE        */
36 /*                                                                        */
37 /*    _gx_system_root_view_add                            PORTABLE C      */
38 /*                                                           6.1          */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    Kenneth Maxwell, Microsoft Corporation                              */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*    Adds a view to a root window, checking to detect if the view is     */
46 /*    obscured by a child window                                          */
47 /*                                                                        */
48 /*  INPUT                                                                 */
49 /*                                                                        */
50 /*    root                                  Root window that we want to   */
51 /*                                            add the view to.            */
52 /*    inrect                                Rectangle defining the view   */
53 /*                                            that we want to add.        */
54 /*                                                                        */
55 /*  OUTPUT                                                                */
56 /*                                                                        */
57 /*    view is added to root window or split into smaller views.           */
58 /*                                                                        */
59 /*  CALLS                                                                 */
60 /*                                                                        */
61 /*    _gx_system_view_split                 Split a view                  */
62 /*    _gx_system_view_add                   Add view to window            */
63 /*    _gx_utility_rectangle_overlap_detect  Detect overlap of rectangles  */
64 /*                                                                        */
65 /*  CALLED BY                                                             */
66 /*                                                                        */
67 /*    GUIX Internal Code                                                  */
68 /*                                                                        */
69 /*  RELEASE HISTORY                                                       */
70 /*                                                                        */
71 /*    DATE              NAME                      DESCRIPTION             */
72 /*                                                                        */
73 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
74 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
75 /*                                            resulting in version 6.1    */
76 /*                                                                        */
77 /**************************************************************************/
_gx_system_root_view_add(GX_WINDOW_ROOT * root,GX_RECTANGLE * inrect)78 VOID _gx_system_root_view_add(GX_WINDOW_ROOT *root, GX_RECTANGLE *inrect)
79 {
80 GX_RECTANGLE overlap;
81 GX_WINDOW   *win = GX_NULL;
82 GX_WIDGET   *widget;
83 
84     /* pick up pointer to frontmost child window */
85     widget = root -> gx_widget_last_child;
86 
87     while (widget)
88     {
89         if (widget -> gx_widget_type >= GX_TYPE_WINDOW &&
90             (widget -> gx_widget_status & GX_STATUS_VISIBLE))
91         {
92             /* if this window is non-transparent, give it views */
93             if (!(widget -> gx_widget_status & GX_STATUS_TRANSPARENT))
94             {
95                 win = (GX_WINDOW *)widget;
96                 if (_gx_utility_rectangle_overlap_detect(inrect, &win -> gx_widget_size, &overlap))
97                 {
98                     /* split the viewport into pieces */
99                     _gx_system_view_split(win, root, inrect);
100 
101                     /* add the overlap to the over window: */
102                     _gx_system_view_add(win, &overlap);
103                     return;
104                 }
105             }
106         }
107         widget = widget -> gx_widget_previous;
108     }
109 
110     /* if we didn't split the view, then add it here */
111     _gx_system_view_add((GX_WINDOW *)root, inrect);
112 }
113 
114