1 /***************************************************************************
2 * Copyright (c) 2024 Microsoft Corporation
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the MIT License which is available at
6 * https://opensource.org/licenses/MIT.
7 *
8 * SPDX-License-Identifier: MIT
9 **************************************************************************/
10
11
12 /**************************************************************************/
13 /**************************************************************************/
14 /** */
15 /** GUIX Component */
16 /** */
17 /** Tree View Management (Tree View) */
18 /** */
19 /**************************************************************************/
20
21 #define GX_SOURCE_CODE
22
23
24 /* Include necessary system files. */
25
26 #include "gx_api.h"
27 #include "gx_widget.h"
28 #include "gx_tree_view.h"
29 #include "gx_system.h"
30 #include "gx_window.h"
31 #include "gx_scrollbar.h"
32
33 /**************************************************************************/
34 /* */
35 /* FUNCTION RELEASE */
36 /* */
37 /* _gx_tree_view_scroll PORTABLE C */
38 /* 6.1 */
39 /* AUTHOR */
40 /* */
41 /* Kenneth Maxwell, Microsoft Corporation */
42 /* */
43 /* DESCRIPTION */
44 /* */
45 /* This service scrolls the tree client area by the specified amount. */
46 /* */
47 /* */
48 /* INPUT */
49 /* */
50 /* tree Pointer to tree view */
51 /* x_scroll Amount to scroll on x-axis */
52 /* y_scroll Amount to scroll on y-axis */
53 /* */
54 /* OUTPUT */
55 /* */
56 /* status Completion status */
57 /* */
58 /* CALLS */
59 /* */
60 /* _gx_widget_scroll_shift Change position of a widget */
61 /* _gx_widget_block_move Move a block of widget area */
62 /* _gx_window_scrollbar_find Find scrollbar for a widget */
63 /* _gx_scrollbar_reset Reset scrollbar information */
64 /* _gx_system_dirty_partial_add Mark partial area of a widget */
65 /* as dirty */
66 /* */
67 /* CALLED BY */
68 /* */
69 /* GUIX Internal Code */
70 /* */
71 /* RELEASE HISTORY */
72 /* */
73 /* DATE NAME DESCRIPTION */
74 /* */
75 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
76 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
77 /* resulting in version 6.1 */
78 /* */
79 /**************************************************************************/
_gx_tree_view_scroll(GX_TREE_VIEW * tree,GX_VALUE x_scroll,GX_VALUE y_scroll)80 UINT _gx_tree_view_scroll(GX_TREE_VIEW *tree, GX_VALUE x_scroll, GX_VALUE y_scroll)
81 {
82 GX_RECTANGLE block;
83 GX_WIDGET *child;
84 GX_SCROLLBAR *scroll;
85
86 block = tree -> gx_window_client;
87
88 if (!(tree -> gx_widget_style & GX_STYLE_TRANSPARENT) &&
89 (tree -> gx_widget_style & GX_STYLE_BORDER_THIN))
90 {
91 /* Widget with think border have a round corner, which have some effects to block move. */
92 block.gx_rectangle_right = (GX_VALUE)(block.gx_rectangle_left + 1);
93 _gx_system_dirty_partial_add((GX_WIDGET *)tree, &block);
94
95 block = tree -> gx_window_client;
96 block.gx_rectangle_bottom = (GX_VALUE)(block.gx_rectangle_top + 1);
97 _gx_system_dirty_partial_add((GX_WIDGET *)tree, &block);
98
99 block = tree -> gx_window_client;
100 block.gx_rectangle_left = (GX_VALUE)(block.gx_rectangle_left + 2);
101 block.gx_rectangle_top = (GX_VALUE)(block.gx_rectangle_top + 2);
102 }
103
104 /* Calculate shift values. */
105 tree -> gx_tree_view_x_shift = (GX_VALUE)(tree -> gx_tree_view_x_shift + x_scroll);
106 tree -> gx_tree_view_y_shift = (GX_VALUE)(tree -> gx_tree_view_y_shift + y_scroll);
107
108 child = tree -> gx_widget_first_child;
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 _gx_widget_block_move((GX_WIDGET *)tree, &block, x_scroll, y_scroll);
119
120 /* if we have a scrollbar, we need to tell it to re-calculate the thumb position */
121
122 scroll = GX_NULL;
123
124 if (x_scroll)
125 {
126 _gx_window_scrollbar_find((GX_WINDOW *)tree, (USHORT)GX_TYPE_HORIZONTAL_SCROLL, &scroll);
127 }
128 else
129 {
130 _gx_window_scrollbar_find((GX_WINDOW *)tree, GX_TYPE_VERTICAL_SCROLL, &scroll);
131 }
132
133 if (scroll)
134 {
135 _gx_scrollbar_reset(scroll, GX_NULL);
136 }
137 return(GX_SUCCESS);
138 }
139
140