xref: /titanic_41/usr/src/lib/libeti/panel/common/bottom.c (revision 51b564aca190d2a430104dded1983d3a1fff66e2)
1 /*
2  * CDDL HEADER START
3  *
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
7  * with the License.
8  *
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.
13  *
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]
19  *
20  * CDDL HEADER END
21  */
22 /*	Copyright (c) 1988 AT&T	*/
23 /*	  All Rights Reserved  	*/
24 
25 
26 /*
27  *      Copyright (c) 1997, by Sun Microsystems, Inc.
28  *      All rights reserved.
29  */
30 
31 /* A panels subsystem built on curses--Move a panel to the bottom */
32 
33 #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.3	*/
34 
35 /*LINTLIBRARY*/
36 
37 #include <sys/types.h>
38 #include <curses.h>
39 #include "private.h"
40 
41 /*  bottom_panel    */
42 int
43 bottom_panel(PANEL *panel)
44 {
45 	PANEL	*pnl;
46 	_obscured_list	*obs;
47 
48 	if (!panel || panel == panel -> below)
49 		return (ERR);
50 
51 	/* If the panel is already on bottom, there is nothing to do */
52 
53 	if (_Bottom_panel == panel)
54 		return (OK);
55 
56 	/*
57 	 * All the panels that this panel used to obscure now
58 	 * obscure this panel.
59 	 */
60 
61 	for (pnl = panel->below; pnl; pnl = pnl->below) {
62 		if (obs = _unlink_obs(pnl, panel)) {
63 			obs -> panel_p = pnl;
64 			if (panel -> obscured) {
65 				obs -> next = panel -> obscured -> next;
66 				panel->obscured = panel->obscured->next = obs;
67 			}
68 			else
69 				obs -> next = panel -> obscured = obs;
70 		}
71 	}
72 
73 	/* Move the panel to the bottom */
74 
75 	if (panel == _Top_panel)
76 		(_Top_panel = panel -> below) -> above = 0;
77 	else {
78 		panel -> above -> below = panel -> below;
79 		panel -> below -> above = panel -> above;
80 	}
81 
82 	panel -> below = 0;
83 	panel -> above = _Bottom_panel;
84 	_Bottom_panel = _Bottom_panel -> below = panel;
85 	(void) touchwin(panel -> win);
86 
87 	return (OK);
88 }
89