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--create a new panel */
32
33 /*LINTLIBRARY*/
34
35 #include <sys/types.h>
36 #include <stdlib.h>
37 #include <curses.h>
38 #include "private.h"
39
40 /* add_top - Put a new or hidden panel on top of the pile */
41 static void
add_top(PANEL * panel)42 add_top(PANEL *panel)
43 {
44 if (!_Top_panel) {
45 panel-> below = 0;
46 _Bottom_panel = panel;
47 } else {
48 _Top_panel -> above = panel;
49 panel -> below = _Top_panel;
50 }
51
52 _Top_panel = panel;
53 panel -> above = 0;
54 panel -> obscured = 0;
55 _Panel_cnt++;
56
57 /* Determine which panels the new panel obscures */
58
59 _intersect_panel(panel);
60 }
61
62 /* new_panel */
63 PANEL *
new_panel(WINDOW * window)64 new_panel(WINDOW *window)
65 {
66 PANEL *panel;
67 int lines, cols;
68
69 /* create a panel */
70
71 if (!window || !_alloc_overlap(_Panel_cnt) ||
72 !(panel = (PANEL *) malloc(sizeof (PANEL))))
73 return ((PANEL *) 0);
74
75 panel -> win = window;
76 getbegyx(window, panel -> wstarty, panel -> wstartx);
77 getmaxyx(window, lines, cols);
78 panel -> wendy = panel->wstarty + lines - 1;
79 panel -> wendx = panel->wstartx + cols - 1;
80 panel -> user = 0;
81
82 /* put the new panel on top of the pile */
83
84 add_top(panel);
85 return (panel);
86 }
87
88 /* show_panel */
89 int
show_panel(PANEL * panel)90 show_panel(PANEL *panel)
91 {
92 /* Allocate the obscured nodes for the new panel */
93
94 if (!panel || panel != panel -> below || !_alloc_overlap(_Panel_cnt))
95 return (ERR);
96
97 /* put the new panel on top of the pile */
98
99 add_top(panel);
100 (void) touchwin(panel -> win);
101 return (OK);
102 }
103