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 /**   Window Management (Window)                                          */
19 /**                                                                       */
20 /**************************************************************************/
21 
22 #define GX_SOURCE_CODE
23 
24 
25 /* Include necessary system files.  */
26 
27 #include "gx_api.h"
28 #include "gx_widget.h"
29 #include "gx_window.h"
30 #include "gx_system.h"
31 #include "gx_display.h"
32 #include "gx_canvas.h"
33 #include "gx_utility.h"
34 #include "gx_scrollbar.h"
35 
36 /**************************************************************************/
37 /*                                                                        */
38 /*  FUNCTION                                               RELEASE        */
39 /*                                                                        */
40 /*    _gx_window_scroll                                   PORTABLE C      */
41 /*                                                           6.1          */
42 /*  AUTHOR                                                                */
43 /*                                                                        */
44 /*    Kenneth Maxwell, Microsoft Corporation                              */
45 /*                                                                        */
46 /*  DESCRIPTION                                                           */
47 /*                                                                        */
48 /*    This service scrolls the window client area by the specified amount */
49 /*                                                                        */
50 /*                                                                        */
51 /*  INPUT                                                                 */
52 /*                                                                        */
53 /*    window                                Pointer to window             */
54 /*    x_scroll                              Amount to scroll on x-axis    */
55 /*    y_scroll                              Amount to scroll on y-axis    */
56 /*                                                                        */
57 /*  OUTPUT                                                                */
58 /*                                                                        */
59 /*    status                                Completion status             */
60 /*                                                                        */
61 /*  CALLS                                                                 */
62 /*                                                                        */
63 /*    _gx_widget_scroll_shift               Widget scroll shift           */
64 /*    _gx_widget_block_move                 Widget block move             */
65 /*                                                                        */
66 /*  CALLED BY                                                             */
67 /*                                                                        */
68 /*    Application Code                                                    */
69 /*                                                                        */
70 /*  RELEASE HISTORY                                                       */
71 /*                                                                        */
72 /*    DATE              NAME                      DESCRIPTION             */
73 /*                                                                        */
74 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
75 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
76 /*                                            resulting in version 6.1    */
77 /*                                                                        */
78 /**************************************************************************/
_gx_window_scroll(GX_WINDOW * window,GX_VALUE x_scroll,GX_VALUE y_scroll)79 UINT _gx_window_scroll(GX_WINDOW *window, GX_VALUE x_scroll, GX_VALUE y_scroll)
80 {
81 GX_WIDGET *child = window -> gx_widget_first_child;
82 GX_BOOL    has_transparent_nonclient_children = GX_FALSE;
83 
84     /* if this window is not visible than nothing to do */
85 
86     if (!(window -> gx_widget_status & GX_STATUS_VISIBLE))
87     {
88         return(GX_SUCCESS);
89     }
90 
91     /* test to determine if transparent non-client children exist */
92 
93     while (child)
94     {
95         if (child -> gx_widget_status & GX_STATUS_NONCLIENT)
96         {
97             if (child -> gx_widget_style & GX_STYLE_TRANSPARENT)
98             {
99                 has_transparent_nonclient_children = GX_TRUE;
100                 break;
101             }
102         }
103         child = child -> gx_widget_next;
104     }
105 
106     /* reset to first child */
107     child = window -> gx_widget_first_child;
108 
109     while (child)
110     {
111         if (!(child -> gx_widget_status & GX_STATUS_NONCLIENT))
112         {
113             _gx_widget_scroll_shift(child, x_scroll, y_scroll, GX_TRUE);
114         }
115         child = child -> gx_widget_next;
116     }
117 
118     if (has_transparent_nonclient_children)
119     {
120         /* In this case we cannot use block-move. Just shift all child widgets */
121         _gx_system_dirty_partial_add((GX_WIDGET *)window, &window -> gx_window_client);
122     }
123     else
124     {
125         /* here if we can do faster scrolling using block-move function */
126         _gx_widget_block_move((GX_WIDGET *)window, &window -> gx_window_client, x_scroll, y_scroll);
127     }
128 
129     return(GX_SUCCESS);
130 }
131 
132