p_above.c revision 302408
1202878Srdivacky/**************************************************************************** 2202878Srdivacky * Copyright (c) 1998-2010,2012 Free Software Foundation, Inc. * 3202878Srdivacky * * 4202878Srdivacky * Permission is hereby granted, free of charge, to any person obtaining a * 5202878Srdivacky * copy of this software and associated documentation files (the * 6202878Srdivacky * "Software"), to deal in the Software without restriction, including * 7202878Srdivacky * without limitation the rights to use, copy, modify, merge, publish, * 8202878Srdivacky * distribute, distribute with modifications, sublicense, and/or sell * 9202878Srdivacky * copies of the Software, and to permit persons to whom the Software is * 10202878Srdivacky * furnished to do so, subject to the following conditions: * 11202878Srdivacky * * 12202878Srdivacky * The above copyright notice and this permission notice shall be included * 13202878Srdivacky * in all copies or substantial portions of the Software. * 14202878Srdivacky * * 15202878Srdivacky * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 16202878Srdivacky * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 17202878Srdivacky * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 18202878Srdivacky * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 19202878Srdivacky * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 20203954Srdivacky * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 21202878Srdivacky * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 22202878Srdivacky * * 23203954Srdivacky * Except as contained in this notice, the name(s) of the above copyright * 24203954Srdivacky * holders shall not be used in advertising or otherwise to promote the * 25203954Srdivacky * sale, use or other dealings in this Software without prior written * 26203954Srdivacky * authorization. * 27203954Srdivacky ****************************************************************************/ 28203954Srdivacky 29203954Srdivacky/**************************************************************************** 30203954Srdivacky * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1995 * 31203954Srdivacky * and: Eric S. Raymond <esr@snark.thyrsus.com> * 32203954Srdivacky * and: Juergen Pfeifer 1997-1999,2008 * 33203954Srdivacky ****************************************************************************/ 34203954Srdivacky 35203954Srdivacky/* p_above.c 36203954Srdivacky */ 37203954Srdivacky#include "panel.priv.h" 38203954Srdivacky 39203954SrdivackyMODULE_ID("$Id: p_above.c,v 1.9 2012/03/10 23:43:41 tom Exp $") 40203954Srdivacky 41203954Srdivacky#if NCURSES_SP_FUNCS 42202878SrdivackyNCURSES_EXPORT(PANEL *) 43202878Srdivackyground_panel(SCREEN * sp) 44202878Srdivacky{ 45203954Srdivacky T((T_CALLED("ground_panel(%p)"), (void *)sp)); 46202878Srdivacky if (sp) 47202878Srdivacky { 48202878Srdivacky struct panelhook *ph = NCURSES_SP_NAME(_nc_panelhook) (sp); 49202878Srdivacky 50202878Srdivacky if (_nc_bottom_panel) /* this is the pseudo panel */ 51 returnPanel(_nc_bottom_panel->above); 52 else 53 returnPanel(0); 54 } 55 else 56 { 57 if (0 == CURRENT_SCREEN) 58 returnPanel(0); 59 else 60 returnPanel(ground_panel(CURRENT_SCREEN)); 61 } 62} 63#endif 64 65NCURSES_EXPORT(PANEL *) 66panel_above(const PANEL * pan) 67{ 68 PANEL *result; 69 70 T((T_CALLED("panel_above(%p)"), (const void *)pan)); 71 if (pan) 72 result = pan->above; 73 else 74 { 75#if NCURSES_SP_FUNCS 76 result = ground_panel(CURRENT_SCREEN); 77#else 78 /* if top and bottom are equal, we have no or only the pseudo panel; 79 if not, we return the panel above the pseudo panel */ 80 result = EMPTY_STACK()? (PANEL *) 0 : _nc_bottom_panel->above; 81#endif 82 } 83 returnPanel(result); 84} 85