1 // * this is for making emacs happy: -*-Mode: C++;-*-
2 /****************************************************************************
3 * Copyright 2019,2020 Thomas E. Dickey *
4 * Copyright 1998-2007,2008 Free Software Foundation, Inc. *
6 * Permission is hereby granted, free of charge, to any person obtaining a *
7 * copy of this software and associated documentation files (the *
8 * "Software"), to deal in the Software without restriction, including *
9 * without limitation the rights to use, copy, modify, merge, publish, *
10 * distribute, distribute with modifications, sublicense, and/or sell *
11 * copies of the Software, and to permit persons to whom the Software is *
12 * furnished to do so, subject to the following conditions: *
14 * The above copyright notice and this permission notice shall be included *
15 * in all copies or substantial portions of the Software. *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
20 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
23 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
25 * Except as contained in this notice, the name(s) of the above copyright *
26 * holders shall not be used in advertising or otherwise to promote the *
27 * sale, use or other dealings in this Software without prior written *
29 ****************************************************************************/
31 /****************************************************************************
32 * Author: Juergen Pfeifer, 1997 *
33 * and: Thomas E. Dickey *
34 ****************************************************************************/
37 #include "cursesapp.h"
39 MODULE_ID("$Id: cursesapp.cc,v 1.18 2020/07/18 19:57:11 anonymous.maarten Exp $")
42 NCursesApplication::init(bool bColors)
45 NCursesWindow::useColors();
47 if (Root_Window->colors() > 1) {
49 Root_Window->setcolor(1);
50 Root_Window->setpalette(COLOR_YELLOW,COLOR_BLUE);
51 Root_Window->setcolor(2);
52 Root_Window->setpalette(COLOR_CYAN,COLOR_BLUE);
53 Root_Window->setcolor(3);
54 Root_Window->setpalette(COLOR_BLACK,COLOR_BLUE);
55 Root_Window->setcolor(4);
56 Root_Window->setpalette(COLOR_BLACK,COLOR_CYAN);
57 Root_Window->setcolor(5);
58 Root_Window->setpalette(COLOR_BLUE,COLOR_YELLOW);
59 Root_Window->setcolor(6);
60 Root_Window->setpalette(COLOR_BLACK,COLOR_GREEN);
65 Root_Window->bkgd(' '|window_backgrounds());
68 NCursesApplication* NCursesApplication::theApp = 0;
69 NCursesWindow* NCursesApplication::titleWindow = 0;
70 NCursesApplication::SLK_Link* NCursesApplication::slk_stack = 0;
73 NCursesWindow *&NCursesApplication::getTitleWindow() {
77 NCursesApplication::~NCursesApplication() THROWS(NCursesException)
79 Soft_Label_Key_Set* S;
95 NCursesApplication* NCursesApplication::getApplication() {
99 int NCursesApplication::rinit(NCursesWindow& w)
105 void NCursesApplication::push(Soft_Label_Key_Set& S)
107 SLK_Link* L = new SLK_Link;
116 bool NCursesApplication::pop()
119 SLK_Link* L = slk_stack;
120 slk_stack = slk_stack->prev;
123 Soft_Label_Key_Set* xx = top();
128 return (slk_stack ? FALSE : TRUE);
131 Soft_Label_Key_Set* NCursesApplication::top() const
134 return slk_stack->SLKs;
136 return static_cast<Soft_Label_Key_Set*>(0);
139 int NCursesApplication::operator()(void)
141 bool bColors = b_Colors;
142 Soft_Label_Key_Set* S = 0;
144 int ts = titlesize();
146 NCursesWindow::ripoffline(ts,rinit);
147 Soft_Label_Key_Set::Label_Layout fmt = useSLKs();
148 if (fmt!=Soft_Label_Key_Set::None) {
149 S = new Soft_Label_Key_Set(fmt);
154 Root_Window = new NCursesWindow(::stdscr);
159 if (fmt!=Soft_Label_Key_Set::None) {
166 NCursesApplication::NCursesApplication(bool bColors)
171 THROW(new NCursesException("Application object already created."));