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 |
|
|
/** Widget Management (Widget) */ |
18 |
|
|
/** */ |
19 |
|
|
/**************************************************************************/ |
20 |
|
|
|
21 |
|
|
#define GX_SOURCE_CODE |
22 |
|
|
|
23 |
|
|
|
24 |
|
|
/* Include necessary system files. */ |
25 |
|
|
|
26 |
|
|
#include "gx_api.h" |
27 |
|
|
#include "gx_system.h" |
28 |
|
|
#include "gx_widget.h" |
29 |
|
|
|
30 |
|
|
|
31 |
|
|
/**************************************************************************/ |
32 |
|
|
/* */ |
33 |
|
|
/* FUNCTION RELEASE */ |
34 |
|
|
/* */ |
35 |
|
|
/* _gx_widget_nav_order_initialize PORTABLE C */ |
36 |
|
|
/* 6.1 */ |
37 |
|
|
/* AUTHOR */ |
38 |
|
|
/* */ |
39 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
40 |
|
|
/* */ |
41 |
|
|
/* DESCRIPTION */ |
42 |
|
|
/* */ |
43 |
|
|
/* This function configures next/previous navigation order. */ |
44 |
|
|
/* */ |
45 |
|
|
/* INPUT */ |
46 |
|
|
/* */ |
47 |
|
|
/* widget Widget control block */ |
48 |
|
|
/* */ |
49 |
|
|
/* OUTPUT */ |
50 |
|
|
/* */ |
51 |
|
|
/* status Completion status */ |
52 |
|
|
/* */ |
53 |
|
|
/* CALLS */ |
54 |
|
|
/* */ |
55 |
|
|
/* */ |
56 |
|
|
/* CALLED BY */ |
57 |
|
|
/* */ |
58 |
|
|
/* GUIX Internal Code */ |
59 |
|
|
/* */ |
60 |
|
|
/* RELEASE HISTORY */ |
61 |
|
|
/* */ |
62 |
|
|
/* DATE NAME DESCRIPTION */ |
63 |
|
|
/* */ |
64 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
65 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
66 |
|
|
/* resulting in version 6.1 */ |
67 |
|
|
/* */ |
68 |
|
|
/**************************************************************************/ |
69 |
|
7520 |
VOID _gx_widget_nav_order_initialize(GX_WIDGET *widget) |
70 |
|
|
{ |
71 |
|
|
GX_WIDGET *winner; |
72 |
|
|
GX_WIDGET *child; |
73 |
|
7520 |
GX_WIDGET *first_stop = NULL; |
74 |
|
7520 |
GX_WIDGET *last_stop = NULL; |
75 |
|
7520 |
GX_BOOL assign_default_focus = GX_TRUE; |
76 |
|
|
|
77 |
|
7520 |
child = widget -> gx_widget_first_child; |
78 |
|
|
|
79 |
|
|
/* test to see if any child already has default focus status flag */ |
80 |
✓✓ |
46273 |
while (child) |
81 |
|
|
{ |
82 |
✓✓ |
38753 |
if (assign_default_focus) |
83 |
|
|
{ |
84 |
✓✓ |
30438 |
if (child -> gx_widget_status & GX_STATUS_DEFAULT_FOCUS) |
85 |
|
|
{ |
86 |
|
2657 |
assign_default_focus = GX_FALSE; |
87 |
|
|
} |
88 |
|
|
} |
89 |
|
|
else |
90 |
|
|
{ |
91 |
|
|
/* make sure only one child has default focus flag */ |
92 |
|
8315 |
child -> gx_widget_status &= ~GX_STATUS_DEFAULT_FOCUS; |
93 |
|
|
} |
94 |
|
|
|
95 |
|
38753 |
child -> gx_widget_nav_next = GX_NULL; |
96 |
|
38753 |
child -> gx_widget_nav_previous = GX_NULL; |
97 |
|
38753 |
child = child -> gx_widget_next; |
98 |
|
|
} |
99 |
|
|
|
100 |
|
|
/* loop through child widgets looking for |
101 |
|
|
the top-left child and assigning the navigation order |
102 |
|
|
in left-to-right top-to-bottom order. |
103 |
|
|
*/ |
104 |
|
|
|
105 |
|
|
do |
106 |
|
|
{ |
107 |
|
33026 |
child = widget -> gx_widget_first_child; |
108 |
|
33026 |
winner = GX_NULL; |
109 |
|
|
|
110 |
✓✓ |
422730 |
while (child) |
111 |
|
|
{ |
112 |
✓✓✓✓
|
389704 |
if (child == last_stop || (child -> gx_widget_status & GX_STATUS_VISIBLE) == 0) |
113 |
|
|
{ |
114 |
|
35504 |
child = child -> gx_widget_next; |
115 |
|
35504 |
continue; |
116 |
|
|
} |
117 |
|
|
|
118 |
✓✓ |
354200 |
if (!child -> gx_widget_nav_next) |
119 |
|
|
{ |
120 |
✓✓ |
229136 |
if ((child -> gx_widget_status & GX_STATUS_ACCEPTS_FOCUS) && |
121 |
✓✓ |
150581 |
!(child -> gx_widget_status & GX_STATUS_NONCLIENT)) |
122 |
|
|
{ |
123 |
✓✓ |
150570 |
if (winner) |
124 |
|
|
{ |
125 |
✓✓ |
125064 |
if (child -> gx_widget_size.gx_rectangle_top < winner -> gx_widget_size.gx_rectangle_top) |
126 |
|
|
{ |
127 |
|
14407 |
winner = child; |
128 |
|
|
} |
129 |
|
|
else |
130 |
|
|
{ |
131 |
✓✓ |
110657 |
if (child -> gx_widget_size.gx_rectangle_top == winner -> gx_widget_size.gx_rectangle_top && |
132 |
✓✓ |
9607 |
child -> gx_widget_size.gx_rectangle_left < winner -> gx_widget_size.gx_rectangle_left) |
133 |
|
|
{ |
134 |
|
543 |
winner = child; |
135 |
|
|
} |
136 |
|
|
} |
137 |
|
|
} |
138 |
|
|
else |
139 |
|
|
{ |
140 |
|
25506 |
winner = child; |
141 |
|
|
} |
142 |
|
|
} |
143 |
|
|
} |
144 |
|
|
|
145 |
|
354200 |
child = child -> gx_widget_next; |
146 |
|
|
} |
147 |
|
|
|
148 |
✓✓ |
33026 |
if (winner) |
149 |
|
|
{ |
150 |
✓✓ |
25506 |
if (!first_stop) |
151 |
|
|
{ |
152 |
|
5748 |
first_stop = winner; |
153 |
|
|
|
154 |
✓✓ |
5748 |
if (assign_default_focus) |
155 |
|
|
{ |
156 |
|
3220 |
first_stop -> gx_widget_status |= GX_STATUS_DEFAULT_FOCUS; |
157 |
|
|
} |
158 |
|
|
} |
159 |
|
|
|
160 |
✓✓ |
25506 |
if (last_stop) |
161 |
|
|
{ |
162 |
|
19758 |
winner -> gx_widget_nav_previous = last_stop; |
163 |
|
19758 |
last_stop -> gx_widget_nav_next = winner; |
164 |
|
|
} |
165 |
|
25506 |
last_stop = winner; |
166 |
|
|
} |
167 |
✓✓ |
33026 |
} while (winner); |
168 |
|
|
|
169 |
|
|
/* loop the last in the order back to the first */ |
170 |
✓✓ |
7520 |
if (last_stop) |
171 |
|
|
{ |
172 |
|
5748 |
last_stop -> gx_widget_nav_next = first_stop; |
173 |
|
5748 |
first_stop -> gx_widget_nav_previous = last_stop; |
174 |
|
|
} |
175 |
|
7520 |
} |
176 |
|
|
|