150276Speter/**************************************************************************** 2184989Srafan * Copyright (c) 1998-2005,2008 Free Software Foundation, Inc. * 350276Speter * * 450276Speter * Permission is hereby granted, free of charge, to any person obtaining a * 550276Speter * copy of this software and associated documentation files (the * 650276Speter * "Software"), to deal in the Software without restriction, including * 750276Speter * without limitation the rights to use, copy, modify, merge, publish, * 850276Speter * distribute, distribute with modifications, sublicense, and/or sell * 950276Speter * copies of the Software, and to permit persons to whom the Software is * 1050276Speter * furnished to do so, subject to the following conditions: * 1150276Speter * * 1250276Speter * The above copyright notice and this permission notice shall be included * 1350276Speter * in all copies or substantial portions of the Software. * 1450276Speter * * 1550276Speter * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 1650276Speter * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 1750276Speter * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 1850276Speter * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 1950276Speter * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 2050276Speter * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 2150276Speter * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 2250276Speter * * 2350276Speter * Except as contained in this notice, the name(s) of the above copyright * 2450276Speter * holders shall not be used in advertising or otherwise to promote the * 2550276Speter * sale, use or other dealings in this Software without prior written * 2650276Speter * authorization. * 2750276Speter ****************************************************************************/ 2850276Speter 2950276Speter/**************************************************************************** 3050276Speter * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1995 * 3150276Speter * and: Eric S. Raymond <esr@snark.thyrsus.com> * 32184989Srafan * and: Juergen Pfeifer 1997-1999 * 33184989Srafan * and: Thomas E. Dickey 2000-on * 3450276Speter ****************************************************************************/ 3550276Speter 3650276Speter/* p_new.c 3750276Speter * Creation of a new panel 3850276Speter */ 3950276Speter#include "panel.priv.h" 4050276Speter 41184989SrafanMODULE_ID("$Id: p_new.c,v 1.10 2008/08/04 18:25:48 tom Exp $") 4250276Speter 4362449Speter#ifdef TRACE 44166124Srafanstatic char *stdscr_id; 45166124Srafanstatic char *new_id; 4662449Speter#endif 4762449Speter 4850276Speter/*+------------------------------------------------------------------------- 4950276Speter Get root (i.e. stdscr's) panel. 5050276Speter Establish the pseudo panel for stdscr if necessary. 5150276Speter--------------------------------------------------------------------------*/ 52166124Srafanstatic PANEL * 5350276Speterroot_panel(void) 5450276Speter{ 55166124Srafan if (_nc_stdscr_pseudo_panel == (PANEL *) 0) 5650276Speter { 57166124Srafan 5850276Speter assert(stdscr && !_nc_bottom_panel && !_nc_top_panel); 59184989Srafan#if NO_LEAKS 60184989Srafan _nc_panelhook()->destroy = del_panel; 61184989Srafan#endif 62166124Srafan _nc_stdscr_pseudo_panel = (PANEL *) malloc(sizeof(PANEL)); 63166124Srafan if (_nc_stdscr_pseudo_panel != 0) 64166124Srafan { 65166124Srafan PANEL *pan = _nc_stdscr_pseudo_panel; 66166124Srafan WINDOW *win = stdscr; 67166124Srafan 68166124Srafan pan->win = win; 69166124Srafan pan->below = (PANEL *) 0; 70166124Srafan pan->above = (PANEL *) 0; 7150276Speter#ifdef TRACE 72166124Srafan if (!stdscr_id) 73166124Srafan stdscr_id = strdup("stdscr"); 74166124Srafan pan->user = stdscr_id; 7550276Speter#else 76166124Srafan pan->user = (void *)0; 7750276Speter#endif 78166124Srafan _nc_bottom_panel = _nc_top_panel = pan; 79166124Srafan } 8050276Speter } 8150276Speter return _nc_stdscr_pseudo_panel; 8250276Speter} 8350276Speter 8476726SpeterNCURSES_EXPORT(PANEL *) 85166124Srafannew_panel(WINDOW *win) 8650276Speter{ 87166124Srafan PANEL *pan = (PANEL *) 0; 8850276Speter 89166124Srafan T((T_CALLED("new_panel(%p)"), win)); 90166124Srafan 9162449Speter if (!win) 92166124Srafan returnPanel(pan); 9362449Speter 9462449Speter if (!_nc_stdscr_pseudo_panel) 9562449Speter (void)root_panel(); 9650276Speter assert(_nc_stdscr_pseudo_panel); 9750276Speter 98166124Srafan if (!(win->_flags & _ISPAD) && (pan = (PANEL *) malloc(sizeof(PANEL)))) 9950276Speter { 10050276Speter pan->win = win; 101166124Srafan pan->above = (PANEL *) 0; 102166124Srafan pan->below = (PANEL *) 0; 10350276Speter#ifdef TRACE 10462449Speter if (!new_id) 10562449Speter new_id = strdup("new"); 10662449Speter pan->user = new_id; 10750276Speter#else 10850276Speter pan->user = (char *)0; 10950276Speter#endif 11050276Speter (void)show_panel(pan); 11150276Speter } 112166124Srafan returnPanel(pan); 11350276Speter} 114