4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
22 /* Copyright (c) 1988 AT&T */
23 /* All Rights Reserved */
27 * Copyright (c) 1997, by Sun Mircrosystems, Inc.
28 * All rights reserved.
31 #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.6 */
35 #include <sys/types.h>
39 link_col_major(MENU
*m
)
48 for (i
= IthItem(m
, 0), n
= 0; i
; i
= IthItem(m
, ++n
)) {
51 Left(i
) = c
? IthItem(m
, n
-Rows(m
)) : (ITEM
*) NULL
;
52 if (n
+ Rows(m
) >= Nitems(m
)) {
53 Right(i
) = (ITEM
*) NULL
;
55 Right(i
) = IthItem(m
, n
+ Rows(m
));
57 Up(i
) = r
? IthItem(m
, n
-1) : (ITEM
*) NULL
;
58 Down(i
) = (r
== Rows(m
)-1) ? (ITEM
*)0 : IthItem(m
, n
+1);
65 Down(IthItem(m
, n
-1)) = IthItem(m
, n
- Rows(m
));
69 /* Set up left and right links at edge of menu */
71 r
= Rows(m
) * (Nitems(m
)/Rows(m
));
72 for (n
= 0; n
< Rows(m
); n
++) {
74 if (left
>= Nitems(m
)) {
77 Left(IthItem(m
, n
)) = IthItem(m
, left
);
78 Right(IthItem(m
, left
)) = IthItem(m
, n
);
81 /* Setup up and down links at edge of menu */
83 for (n
= 0; n
< Nitems(m
); n
+= Rows(m
)) {
85 if (up
>= Nitems(m
)) {
86 Up(IthItem(m
, n
)) = IthItem(m
, n
-1);
88 Up(IthItem(m
, n
)) = IthItem(m
, up
);
89 Down(IthItem(m
, up
)) = IthItem(m
, n
);
96 link_row_major(MENU
*m
)
105 for (i
= IthItem(m
, 0), n
= 0; i
; i
= IthItem(m
, ++n
)) {
108 Left(i
) = c
? IthItem(m
, n
-1) : (ITEM
*) NULL
;
109 Right(i
) = (c
== Cols(m
)-1 || n
== Nitems(m
)-1) ? (ITEM
*)0 :
111 Up(i
) = r
? IthItem(m
, n
-Cols(m
)) : (ITEM
*) NULL
;
113 if (n
+Cols(m
) < Nitems(m
)) {
114 Down(i
) = IthItem(m
, n
+ Cols(m
));
116 if (r
== Rows(m
)-1) {
117 /* Down is undefined if this is a complete */
119 Down(i
) = (ITEM
*) NULL
;
121 /* Down is set to last item if the last */
122 /* column isn't full */
123 Down(i
) = IthItem(m
, Nitems(m
)-1);
126 if (++c
== Cols(m
)) {
134 /* Setup left and right links at edge of menu */
136 for (n
= 0; n
< Nitems(m
); n
+= Cols(m
)) {
137 left
= n
+ Cols(m
) - 1;
138 if (left
>= Nitems(m
)) {
139 left
= Nitems(m
) - 1;
141 Left(IthItem(m
, n
)) = IthItem(m
, left
);
142 Right(IthItem(m
, left
)) = IthItem(m
, n
);
145 /* Setup up and down links at edge of menu */
147 r
= (Rows(m
) - 1) * Cols(m
);
148 for (n
= 0; n
< Cols(m
); n
++) {
151 /* If there is an incomplete line below this one */
152 /* the point to the last item in the menu. */
154 if (up
>= Nitems(m
)) {
155 Up(IthItem(m
, n
)) = IthItem(m
, Nitems(m
)-1);
157 Up(IthItem(m
, n
)) = IthItem(m
, up
);
158 Down(IthItem(m
, up
)) = IthItem(m
, n
);
167 if (Items(m
) && IthItem(m
, 0)) {