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 /**   Tree View Management (Tree View)                                    */
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_tree_view.h"
30 #include "gx_system.h"
31 #include "gx_window.h"
32 #include "gx_scrollbar.h"
33 
34 /**************************************************************************/
35 /*                                                                        */
36 /*  FUNCTION                                               RELEASE        */
37 /*                                                                        */
38 /*    _gx_tree_view_scroll                                PORTABLE C      */
39 /*                                                           6.1          */
40 /*  AUTHOR                                                                */
41 /*                                                                        */
42 /*    Kenneth Maxwell, Microsoft Corporation                              */
43 /*                                                                        */
44 /*  DESCRIPTION                                                           */
45 /*                                                                        */
46 /*    This service scrolls the tree client area by the specified amount.  */
47 /*                                                                        */
48 /*                                                                        */
49 /*  INPUT                                                                 */
50 /*                                                                        */
51 /*    tree                                  Pointer to tree view          */
52 /*    x_scroll                              Amount to scroll on x-axis    */
53 /*    y_scroll                              Amount to scroll on y-axis    */
54 /*                                                                        */
55 /*  OUTPUT                                                                */
56 /*                                                                        */
57 /*    status                                Completion status             */
58 /*                                                                        */
59 /*  CALLS                                                                 */
60 /*                                                                        */
61 /*    _gx_widget_scroll_shift               Change position of a widget   */
62 /*    _gx_widget_block_move                 Move a block of widget area   */
63 /*    _gx_window_scrollbar_find             Find scrollbar for a widget   */
64 /*    _gx_scrollbar_reset                   Reset scrollbar information   */
65 /*    _gx_system_dirty_partial_add          Mark partial area of a widget */
66 /*                                            as dirty                    */
67 /*                                                                        */
68 /*  CALLED BY                                                             */
69 /*                                                                        */
70 /*    GUIX Internal Code                                                  */
71 /*                                                                        */
72 /*  RELEASE HISTORY                                                       */
73 /*                                                                        */
74 /*    DATE              NAME                      DESCRIPTION             */
75 /*                                                                        */
76 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
77 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
78 /*                                            resulting in version 6.1    */
79 /*                                                                        */
80 /**************************************************************************/
_gx_tree_view_scroll(GX_TREE_VIEW * tree,GX_VALUE x_scroll,GX_VALUE y_scroll)81 UINT _gx_tree_view_scroll(GX_TREE_VIEW *tree, GX_VALUE x_scroll, GX_VALUE y_scroll)
82 {
83 GX_RECTANGLE  block;
84 GX_WIDGET    *child;
85 GX_SCROLLBAR *scroll;
86 
87     block = tree -> gx_window_client;
88 
89     if (!(tree -> gx_widget_style & GX_STYLE_TRANSPARENT) &&
90         (tree -> gx_widget_style & GX_STYLE_BORDER_THIN))
91     {
92         /* Widget with think border have a round corner, which have some effects to block move. */
93         block.gx_rectangle_right = (GX_VALUE)(block.gx_rectangle_left + 1);
94         _gx_system_dirty_partial_add((GX_WIDGET *)tree, &block);
95 
96         block = tree -> gx_window_client;
97         block.gx_rectangle_bottom = (GX_VALUE)(block.gx_rectangle_top + 1);
98         _gx_system_dirty_partial_add((GX_WIDGET *)tree, &block);
99 
100         block = tree -> gx_window_client;
101         block.gx_rectangle_left = (GX_VALUE)(block.gx_rectangle_left + 2);
102         block.gx_rectangle_top = (GX_VALUE)(block.gx_rectangle_top + 2);
103     }
104 
105     /* Calculate shift values. */
106     tree -> gx_tree_view_x_shift = (GX_VALUE)(tree -> gx_tree_view_x_shift + x_scroll);
107     tree -> gx_tree_view_y_shift = (GX_VALUE)(tree -> gx_tree_view_y_shift + y_scroll);
108 
109     child = tree -> gx_widget_first_child;
110     while (child)
111     {
112         if (!(child -> gx_widget_status & GX_STATUS_NONCLIENT))
113         {
114             _gx_widget_scroll_shift(child, x_scroll, y_scroll, GX_TRUE);
115         }
116         child = child -> gx_widget_next;
117     }
118 
119     _gx_widget_block_move((GX_WIDGET *)tree, &block, x_scroll, y_scroll);
120 
121     /* if we have a scrollbar, we need to tell it to re-calculate the thumb position */
122 
123     scroll = GX_NULL;
124 
125     if (x_scroll)
126     {
127         _gx_window_scrollbar_find((GX_WINDOW *)tree, (USHORT)GX_TYPE_HORIZONTAL_SCROLL, &scroll);
128     }
129     else
130     {
131         _gx_window_scrollbar_find((GX_WINDOW *)tree, GX_TYPE_VERTICAL_SCROLL, &scroll);
132     }
133 
134     if (scroll)
135     {
136         _gx_scrollbar_reset(scroll, GX_NULL);
137     }
138     return(GX_SUCCESS);
139 }
140 
141