1 |
|
|
/*************************************************************************** |
2 |
|
|
* Copyright (c) 2024 Microsoft Corporation |
3 |
|
|
* Copyright (c) 2026-present Eclipse ThreadX contributors |
4 |
|
|
* |
5 |
|
|
* This program and the accompanying materials are made available under the |
6 |
|
|
* terms of the MIT License which is available at |
7 |
|
|
* https://opensource.org/licenses/MIT. |
8 |
|
|
* |
9 |
|
|
* SPDX-License-Identifier: MIT |
10 |
|
|
**************************************************************************/ |
11 |
|
|
|
12 |
|
|
|
13 |
|
|
/**************************************************************************/ |
14 |
|
|
/**************************************************************************/ |
15 |
|
|
/** */ |
16 |
|
|
/** GUIX Component */ |
17 |
|
|
/** */ |
18 |
|
|
/** Tree View Management (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_menu.h" |
29 |
|
|
#include "gx_widget.h" |
30 |
|
|
#include "gx_system.h" |
31 |
|
|
#include "gx_tree_view.h" |
32 |
|
|
#include "gx_window.h" |
33 |
|
|
#include "gx_scrollbar.h" |
34 |
|
|
|
35 |
|
|
/**************************************************************************/ |
36 |
|
|
/* */ |
37 |
|
|
/* FUNCTION RELEASE */ |
38 |
|
|
/* */ |
39 |
|
|
/* _gx_tree_view_position PORTABLE C */ |
40 |
|
|
/* 6.1 */ |
41 |
|
|
/* AUTHOR */ |
42 |
|
|
/* */ |
43 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
44 |
|
|
/* */ |
45 |
|
|
/* DESCRIPTION */ |
46 |
|
|
/* */ |
47 |
|
|
/* This function positions a tree menu. */ |
48 |
|
|
/* */ |
49 |
|
|
/* INPUT */ |
50 |
|
|
/* */ |
51 |
|
|
/* tree Tree view control block */ |
52 |
|
|
/* */ |
53 |
|
|
/* OUTPUT */ |
54 |
|
|
/* */ |
55 |
|
|
/* status Completion status */ |
56 |
|
|
/* */ |
57 |
|
|
/* CALLS */ |
58 |
|
|
/* */ |
59 |
|
|
/* _gx_widget_first_client_child_get Get the first client child */ |
60 |
|
|
/* _gx_widget_next_client_child_get Get the next client child */ |
61 |
|
|
/* _gx_widget_height_get Get widget height */ |
62 |
|
|
/* _gx_widget_width_get Get widget width */ |
63 |
|
|
/* _gx_widget_resize Resize a widget */ |
64 |
|
|
/* _gx_menu_position Position a menu widget */ |
65 |
|
|
/* _gx_window_scrollbar_find Find scrollbar for a window */ |
66 |
|
|
/* _gx_scrollbar_reset Reset scrollbar information */ |
67 |
|
|
/* _gx_widget_hide Hide a widget */ |
68 |
|
|
/* _gx_widget_show Show a widget */ |
69 |
|
|
/* */ |
70 |
|
|
/* CALLED BY */ |
71 |
|
|
/* */ |
72 |
|
|
/* Application Code */ |
73 |
|
|
/* GUIX Internal Code */ |
74 |
|
|
/* */ |
75 |
|
|
/**************************************************************************/ |
76 |
|
68 |
UINT _gx_tree_view_position(GX_TREE_VIEW *tree) |
77 |
|
|
{ |
78 |
|
|
GX_WIDGET *child; |
79 |
|
|
GX_RECTANGLE size; |
80 |
|
|
GX_RECTANGLE *client; |
81 |
|
|
GX_VALUE height; |
82 |
|
|
GX_VALUE width; |
83 |
|
|
GX_VALUE bottom; |
84 |
|
68 |
GX_VALUE max_right = 0; |
85 |
|
|
GX_MENU_LIST *list; |
86 |
|
|
GX_SCROLLBAR *scroll; |
87 |
|
|
|
88 |
|
68 |
client = &tree -> gx_window_client; |
89 |
|
|
|
90 |
|
68 |
size.gx_rectangle_left = (GX_VALUE)(client -> gx_rectangle_left + tree -> gx_tree_view_indentation + tree -> gx_tree_view_x_shift); |
91 |
|
68 |
bottom = (GX_VALUE)(client -> gx_rectangle_top - 1 + tree -> gx_tree_view_y_shift); |
92 |
|
|
|
93 |
|
68 |
child = _gx_widget_first_client_child_get((GX_WIDGET *)tree); |
94 |
|
|
|
95 |
|
|
/* Reposition tree view items. */ |
96 |
✓✓ |
447 |
while (child) |
97 |
|
|
{ |
98 |
✓✓ |
379 |
if (child -> gx_widget_type == GX_TYPE_MENU_LIST) |
99 |
|
|
{ |
100 |
|
35 |
child = _gx_widget_next_client_child_get(child); |
101 |
|
35 |
continue; |
102 |
|
|
} |
103 |
|
|
|
104 |
|
344 |
_gx_widget_height_get(child, &height); |
105 |
|
344 |
_gx_widget_width_get(child, &width); |
106 |
|
344 |
size.gx_rectangle_top = (GX_VALUE)(bottom + 1); |
107 |
|
344 |
size.gx_rectangle_bottom = (GX_VALUE)(size.gx_rectangle_top + height - 1); |
108 |
|
344 |
size.gx_rectangle_right = (GX_VALUE)(size.gx_rectangle_left + width - 1); |
109 |
|
|
|
110 |
|
344 |
_gx_widget_resize((GX_WIDGET *)child, &size); |
111 |
|
|
|
112 |
✓✓ |
344 |
if (child -> gx_widget_type == GX_TYPE_MENU) |
113 |
|
|
{ |
114 |
|
271 |
_gx_menu_position((GX_MENU *)child, tree -> gx_tree_view_indentation); |
115 |
|
|
|
116 |
|
271 |
list = &((GX_MENU *)child) -> gx_menu_list; |
117 |
|
|
|
118 |
✓✓✓✓
|
271 |
if (list -> gx_widget_parent && list -> gx_widget_first_child) |
119 |
|
|
{ |
120 |
|
28 |
bottom = list -> gx_widget_size.gx_rectangle_bottom; |
121 |
|
|
|
122 |
✓✓ |
28 |
if (list -> gx_widget_size.gx_rectangle_right > max_right) |
123 |
|
|
{ |
124 |
|
27 |
max_right = list -> gx_widget_size.gx_rectangle_right; |
125 |
|
|
} |
126 |
|
|
} |
127 |
|
|
else |
128 |
|
|
{ |
129 |
✓✓ |
243 |
if (list -> gx_widget_parent) |
130 |
|
|
{ |
131 |
|
1 |
_gx_widget_detach((GX_WIDGET *)list); |
132 |
|
|
} |
133 |
|
|
|
134 |
|
243 |
bottom = size.gx_rectangle_bottom; |
135 |
|
|
|
136 |
✓✓ |
243 |
if (size.gx_rectangle_right > max_right) |
137 |
|
|
{ |
138 |
|
57 |
max_right = size.gx_rectangle_right; |
139 |
|
|
} |
140 |
|
|
} |
141 |
|
|
} |
142 |
|
|
else |
143 |
|
|
{ |
144 |
|
73 |
bottom = size.gx_rectangle_bottom; |
145 |
|
|
} |
146 |
|
|
|
147 |
|
344 |
child -> gx_widget_status &= (ULONG)(~GX_STATUS_ACCEPTS_FOCUS); |
148 |
|
344 |
child = _gx_widget_next_client_child_get(child); |
149 |
|
|
} |
150 |
|
|
|
151 |
|
68 |
tree -> gx_tree_view_tree_width = (GX_VALUE)(max_right - (client -> gx_rectangle_left + tree -> gx_tree_view_x_shift) + 1); |
152 |
|
68 |
tree -> gx_tree_view_tree_height = (GX_VALUE)(bottom - (client -> gx_rectangle_top + tree -> gx_tree_view_y_shift) + 1); |
153 |
|
|
|
154 |
|
68 |
_gx_window_scrollbar_find((GX_WINDOW *)tree, (USHORT)GX_TYPE_HORIZONTAL_SCROLL, &scroll); |
155 |
|
|
|
156 |
|
68 |
width = (GX_VALUE)(client -> gx_rectangle_right - client -> gx_rectangle_left + 1); |
157 |
|
68 |
height = (GX_VALUE)(client -> gx_rectangle_bottom - client -> gx_rectangle_top + 1); |
158 |
|
|
|
159 |
✓✓ |
68 |
if (scroll) |
160 |
|
|
{ |
161 |
|
66 |
_gx_scrollbar_reset(scroll, GX_NULL); |
162 |
|
|
|
163 |
✓✓ |
66 |
if (tree -> gx_tree_view_tree_width <= width) |
164 |
|
|
{ |
165 |
|
56 |
_gx_widget_hide((GX_WIDGET *)scroll); |
166 |
|
|
} |
167 |
|
|
else |
168 |
|
|
{ |
169 |
|
10 |
_gx_widget_show((GX_WIDGET *)scroll); |
170 |
|
|
} |
171 |
|
|
} |
172 |
|
|
|
173 |
|
68 |
_gx_window_scrollbar_find((GX_WINDOW *)tree, GX_TYPE_VERTICAL_SCROLL, &scroll); |
174 |
|
|
|
175 |
✓✓ |
68 |
if (scroll) |
176 |
|
|
{ |
177 |
|
66 |
_gx_scrollbar_reset(scroll, GX_NULL); |
178 |
|
|
|
179 |
✓✓ |
66 |
if (tree -> gx_tree_view_tree_height <= height) |
180 |
|
|
{ |
181 |
|
59 |
_gx_widget_hide((GX_WIDGET *)scroll); |
182 |
|
|
} |
183 |
|
|
else |
184 |
|
|
{ |
185 |
|
7 |
_gx_widget_show((GX_WIDGET *)scroll); |
186 |
|
|
} |
187 |
|
|
} |
188 |
|
|
|
189 |
✓✓ |
68 |
if ((tree -> gx_widget_style & GX_STYLE_TREE_VIEW_SHOW_ROOT_LINES) && |
190 |
✓✓ |
63 |
(tree -> gx_widget_status & GX_STATUS_VISIBLE)) |
191 |
|
|
{ |
192 |
|
62 |
_gx_system_dirty_mark((GX_WIDGET *)tree); |
193 |
|
|
} |
194 |
|
|
|
195 |
|
|
/* Return completion status code. */ |
196 |
|
68 |
return(GX_SUCCESS); |
197 |
|
|
} |
198 |
|
|
|