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_fold                                PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Kenneth Maxwell, Microsoft Corporation                              */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function combines adjcent views.                               */
45 /*                                                                        */
46 /*                                                                        */
47 /*  INPUT                                                                 */
48 /*                                                                        */
49 /*    win                                   Window to add view to         */
50 /*    view                                  Rectangle defining new view   */
51 /*                                                                        */
52 /*  OUTPUT                                                                */
53 /*                                                                        */
54 /*    GX_TRUE | GX_FALSE                                                  */
55 /*                                                                        */
56 /*  CALLS                                                                 */
57 /*                                                                        */
58 /*    None                                                                */
59 /*                                                                        */
60 /*  CALLED BY                                                             */
61 /*                                                                        */
62 /*    _gx_system_view_add                   Link a view to window's view  */
63 /*                                            list                        */
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 /**************************************************************************/
_gx_system_view_fold(GX_WINDOW * win,GX_RECTANGLE * view)74 GX_BOOL _gx_system_view_fold(GX_WINDOW *win, GX_RECTANGLE *view)
75 {
76 GX_VIEW *oldview = win -> gx_window_views;
77 
78     while (oldview)
79     {
80         /* check for two views stacked vertically:*/
81 
82         if ((oldview -> gx_view_rectangle.gx_rectangle_left == view -> gx_rectangle_left) &&
83             (oldview -> gx_view_rectangle.gx_rectangle_right == view -> gx_rectangle_right))
84         {
85             if (oldview -> gx_view_rectangle.gx_rectangle_bottom == (view -> gx_rectangle_top - 1))
86             {
87                 /* New view is right below existing view, expand bottom of
88                    existing: */
89                 oldview -> gx_view_rectangle.gx_rectangle_bottom = view -> gx_rectangle_bottom;
90                 return GX_TRUE;
91             }
92 
93             if (oldview -> gx_view_rectangle.gx_rectangle_top == (view -> gx_rectangle_bottom + 1))
94             {
95                 /* new view is right above existing view, just expand existing
96                    view top: */
97                 oldview -> gx_view_rectangle.gx_rectangle_top = view -> gx_rectangle_top;
98                 return GX_TRUE;
99             }
100         }
101         else
102         {
103             /* check for views right beside each other horizontally: */
104             if (oldview -> gx_view_rectangle.gx_rectangle_top == view -> gx_rectangle_top &&
105                 oldview -> gx_view_rectangle.gx_rectangle_bottom == view -> gx_rectangle_bottom)
106             {
107                 if (oldview -> gx_view_rectangle.gx_rectangle_right == (view -> gx_rectangle_left - 1))
108                 {
109                     /* new view is to the right of existing view, expand right side of
110                        existing:*/
111                     oldview -> gx_view_rectangle.gx_rectangle_right = view -> gx_rectangle_right;
112                     return GX_TRUE;
113                 }
114 
115                 if (oldview -> gx_view_rectangle.gx_rectangle_left == (view -> gx_rectangle_right + 1))
116                 {
117                     /* new view is to the left of existing view, expand left side of
118                        existing view: */
119                     oldview -> gx_view_rectangle.gx_rectangle_left = view -> gx_rectangle_left;
120                     return GX_TRUE;
121                 }
122             }
123         }
124         oldview = oldview -> gx_view_next;
125     }
126     return GX_FALSE;
127 }
128 
129