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 
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _gx_system_view_split                               PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Kenneth Maxwell, Microsoft Corporation                              */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This splits a rectangle into over and under views                   */
45 /*                                                                        */
46 /*  INPUT                                                                 */
47 /*                                                                        */
48 /*    over                                  Pointer to window on top      */
49 /*    root                                  Pointer to root window        */
50 /*    original                              Rectangle to split into       */
51 /*                                            smaller chunks              */
52 /*                                                                        */
53 /*  OUTPUT                                                                */
54 /*                                                                        */
55 /*    None                                                                */
56 /*                                                                        */
57 /*  CALLS                                                                 */
58 /*                                                                        */
59 /*    gx_system_root_view_add               Add viewport to root window   */
60 /*                                                                        */
61 /*  CALLED BY                                                             */
62 /*                                                                        */
63 /*    _gx_system_root_view_add              Add view to a root window     */
64 /*                                                                        */
65 /*  RELEASE HISTORY                                                       */
66 /*                                                                        */
67 /*    DATE              NAME                      DESCRIPTION             */
68 /*                                                                        */
69 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
70 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
71 /*                                            resulting in version 6.1    */
72 /*                                                                        */
73 /**************************************************************************/
74 
_gx_system_view_split(GX_WINDOW * over,GX_WINDOW_ROOT * root,GX_RECTANGLE * original)75 VOID _gx_system_view_split(GX_WINDOW *over, GX_WINDOW_ROOT *root, GX_RECTANGLE *original)
76 {
77 GX_RECTANGLE split;
78 GX_RECTANGLE oversize = over -> gx_widget_size;
79 
80     /* check to see if any area on top is exposed */
81     if (oversize.gx_rectangle_top > original -> gx_rectangle_top)
82     {
83         split.gx_rectangle_left = original -> gx_rectangle_left;
84         split.gx_rectangle_right = original -> gx_rectangle_right;
85         split.gx_rectangle_top = original -> gx_rectangle_top;
86         split.gx_rectangle_bottom = (GX_VALUE)(oversize.gx_rectangle_top - 1);
87 
88         /* try to add this piece to the 'under' window's viewports */
89         _gx_system_root_view_add(root, &split);
90     }
91 
92     /* check to see if any area on bottom is exposed */
93     if (oversize.gx_rectangle_bottom < original -> gx_rectangle_bottom)
94     {
95         split.gx_rectangle_left = original -> gx_rectangle_left;
96         split.gx_rectangle_right = original -> gx_rectangle_right;
97         split.gx_rectangle_top = (GX_VALUE)(oversize.gx_rectangle_bottom + 1);
98         split.gx_rectangle_bottom = original -> gx_rectangle_bottom;
99 
100         /* try to add this piece to the 'under' window's viewports */
101         _gx_system_root_view_add(root, &split);
102     }
103 
104     /* check to see if any area on left is exposed */
105     if (oversize.gx_rectangle_left > original -> gx_rectangle_left)
106     {
107         split.gx_rectangle_left = original -> gx_rectangle_left;
108         split.gx_rectangle_right = (GX_VALUE)(oversize.gx_rectangle_left - 1);
109 
110         if (original -> gx_rectangle_top > oversize.gx_rectangle_top)
111         {
112             split.gx_rectangle_top = original -> gx_rectangle_top;
113         }
114         else
115         {
116             split.gx_rectangle_top = oversize.gx_rectangle_top;
117         }
118 
119         if (original -> gx_rectangle_bottom < oversize.gx_rectangle_bottom)
120         {
121             split.gx_rectangle_bottom = original -> gx_rectangle_bottom;
122         }
123         else
124         {
125             split.gx_rectangle_bottom = oversize.gx_rectangle_bottom;
126         }
127 
128         /* try to add this piece to the 'under' window's viewports */
129         _gx_system_root_view_add(root, &split);
130     }
131 
132     /* check to see if any area on right is exposed */
133     if (oversize.gx_rectangle_right < original -> gx_rectangle_right)
134     {
135         split.gx_rectangle_left = (GX_VALUE)(oversize.gx_rectangle_right + 1);
136         split.gx_rectangle_right = original -> gx_rectangle_right;
137 
138         if (original -> gx_rectangle_top > oversize.gx_rectangle_top)
139         {
140             split.gx_rectangle_top = original -> gx_rectangle_top;
141         }
142         else
143         {
144             split.gx_rectangle_top = oversize.gx_rectangle_top;
145         }
146 
147         if (original -> gx_rectangle_bottom < oversize.gx_rectangle_bottom)
148         {
149             split.gx_rectangle_bottom = original -> gx_rectangle_bottom;
150         }
151         else
152         {
153             split.gx_rectangle_bottom = oversize.gx_rectangle_bottom;
154         }
155         /* try to add this piece to the 'under' window's viewports */
156         _gx_system_root_view_add(root, &split);
157     }
158 }
159 
160