ncursesw-morphos/panel/p_new.c

124 lines
4.5 KiB
C
Raw Normal View History

1998-03-01 12:21:12 +08:00
/****************************************************************************
* Copyright 2020 Thomas E. Dickey *
* Copyright 1998-2009,2010 Free Software Foundation, Inc. *
1998-03-01 12:21:12 +08:00
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included *
* in all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
* *
* Except as contained in this notice, the name(s) of the above copyright *
* holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written *
* authorization. *
****************************************************************************/
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
* and: Juergen Pfeifer 1997-1999 *
* and: Thomas E. Dickey 2000-on *
1998-03-01 12:21:12 +08:00
****************************************************************************/
/* p_new.c
* Creation of a new panel
*/
#include "panel.priv.h"
MODULE_ID("$Id: p_new.c,v 1.17 2020/02/02 23:34:34 tom Exp $")
2000-07-09 10:46:08 +08:00
#ifdef TRACE
2005-10-10 02:41:57 +08:00
static char *stdscr_id;
static char *new_id;
2000-07-09 10:46:08 +08:00
#endif
1998-03-01 12:21:12 +08:00
/*+-------------------------------------------------------------------------
Get root (i.e. stdscr's) panel.
Establish the pseudo panel for stdscr if necessary.
--------------------------------------------------------------------------*/
2005-10-10 02:41:57 +08:00
static PANEL *
root_panel(NCURSES_SP_DCL0)
1998-03-01 12:21:12 +08:00
{
#if NCURSES_SP_FUNCS
struct panelhook *ph = NCURSES_SP_NAME(_nc_panelhook) (sp);
#elif NO_LEAKS
struct panelhook *ph = _nc_panelhook();
#endif
2005-10-10 02:41:57 +08:00
if (_nc_stdscr_pseudo_panel == (PANEL *) 0)
1998-03-01 12:21:12 +08:00
{
2005-10-10 02:41:57 +08:00
assert(SP_PARM && SP_PARM->_stdscr && !_nc_bottom_panel && !_nc_top_panel);
#if NO_LEAKS
ph->destroy = del_panel;
#endif
_nc_stdscr_pseudo_panel = typeMalloc(PANEL, 1);
2005-10-10 02:41:57 +08:00
if (_nc_stdscr_pseudo_panel != 0)
{
PANEL *pan = _nc_stdscr_pseudo_panel;
WINDOW *win = SP_PARM->_stdscr;
2005-10-10 02:41:57 +08:00
pan->win = win;
pan->below = (PANEL *) 0;
pan->above = (PANEL *) 0;
1998-03-01 12:21:12 +08:00
#ifdef TRACE
2005-10-10 02:41:57 +08:00
if (!stdscr_id)
stdscr_id = strdup("stdscr");
pan->user = stdscr_id;
1998-03-01 12:21:12 +08:00
#else
2005-10-10 02:41:57 +08:00
pan->user = (void *)0;
1998-03-01 12:21:12 +08:00
#endif
2005-10-10 02:41:57 +08:00
_nc_bottom_panel = _nc_top_panel = pan;
}
1998-03-01 12:21:12 +08:00
}
return _nc_stdscr_pseudo_panel;
}
2002-10-13 11:35:53 +08:00
NCURSES_EXPORT(PANEL *)
2005-10-10 02:41:57 +08:00
new_panel(WINDOW *win)
1998-03-01 12:21:12 +08:00
{
2005-10-10 02:41:57 +08:00
PANEL *pan = (PANEL *) 0;
GetWindowHook(win);
T((T_CALLED("new_panel(%p)"), (void *)win));
1998-03-01 12:21:12 +08:00
2000-07-09 10:46:08 +08:00
if (!win)
2005-10-10 02:41:57 +08:00
returnPanel(pan);
2000-07-09 10:46:08 +08:00
if (!_nc_stdscr_pseudo_panel)
(void)root_panel(NCURSES_SP_ARG);
1998-03-01 12:21:12 +08:00
assert(_nc_stdscr_pseudo_panel);
if (!(win->_flags & _ISPAD) && (pan = typeMalloc(PANEL, 1)))
1998-03-01 12:21:12 +08:00
{
pan->win = win;
2005-10-10 02:41:57 +08:00
pan->above = (PANEL *) 0;
pan->below = (PANEL *) 0;
1998-03-01 12:21:12 +08:00
#ifdef TRACE
2000-07-09 10:46:08 +08:00
if (!new_id)
new_id = strdup("new");
pan->user = new_id;
1998-03-01 12:21:12 +08:00
#else
pan->user = (char *)0;
#endif
(void)show_panel(pan);
}
2005-10-10 02:41:57 +08:00
returnPanel(pan);
1998-03-01 12:21:12 +08:00
}