1 // * This makes emacs happy -*-Mode: C++;-*-
2 /****************************************************************************
3 * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
5 * Permission is hereby granted, free of charge, to any person obtaining a *
6 * copy of this software and associated documentation files (the *
7 * "Software"), to deal in the Software without restriction, including *
8 * without limitation the rights to use, copy, modify, merge, publish, *
9 * distribute, distribute with modifications, sublicense, and/or sell *
10 * copies of the Software, and to permit persons to whom the Software is *
11 * furnished to do so, subject to the following conditions: *
13 * The above copyright notice and this permission notice shall be included *
14 * in all copies or substantial portions of the Software. *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
19 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
22 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
24 * Except as contained in this notice, the name(s) of the above copyright *
25 * holders shall not be used in advertising or otherwise to promote the *
26 * sale, use or other dealings in this Software without prior written *
28 ****************************************************************************/
30 /****************************************************************************
31 * Author: Juergen Pfeifer, 1997 *
32 * Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en *
33 ****************************************************************************/
35 // $Id: cursesapp.h,v 1.8 2002/07/06 15:47:52 juergen Exp $
37 #ifndef NCURSES_CURSESAPP_H_incl
38 #define NCURSES_CURSESAPP_H_incl
42 class NCURSES_IMPEXP NCursesApplication {
44 typedef struct _slk_link { // This structure is used to maintain
45 struct _slk_link* prev; // a stack of SLKs
46 Soft_Label_Key_Set* SLKs;
49 static int rinit(NCursesWindow& w); // Internal Init function for title
50 static NCursesApplication* theApp; // Global ref. to the application
52 static SLK_Link* slk_stack;
55 static NCursesWindow* titleWindow; // The Title Window (if any)
57 bool b_Colors; // Is this a color application?
58 NCursesWindow* Root_Window; // This is the stdscr equiv.
60 // Initialization of attributes;
61 // Rewrite this in your derived class if you prefer other settings
62 virtual void init(bool bColors);
64 // The number of lines for the title window. Default is no title window
65 // You may rewrite this in your derived class
66 virtual int titlesize() const {
70 // This method is called to put something into the title window initially
71 // You may rewrite this in your derived class
72 virtual void title() {
75 // The layout used for the Soft Label Keys. Default is to have no SLKs.
76 // You may rewrite this in your derived class
77 virtual Soft_Label_Key_Set::Label_Layout useSLKs() const {
78 return Soft_Label_Key_Set::None;
81 // This method is called to initialize the SLKs. Default is nothing.
82 // You may rewrite this in your derived class
83 virtual void init_labels(Soft_Label_Key_Set& S) const {
86 // Your derived class must implement this method. The return value must
87 // be the exit value of your application.
88 virtual int run() = 0;
91 // The constructor is protected, so you may use it in your derived
92 // class constructor. The argument tells whether or not you want colors.
93 NCursesApplication(bool wantColors = FALSE);
96 virtual ~NCursesApplication();
98 // Get a pointer to the current application object
99 static NCursesApplication* getApplication() {
103 // This method runs the application and returns its exit value
104 int operator()(void);
106 // Process the commandline arguments. The default implementation simply
107 // ignores them. Your derived class may rewrite this.
108 virtual void handleArgs(int argc, char* argv[]) {
111 // Does this application use colors?
112 inline bool useColors() const {
116 // Push the Key Set S onto the SLK Stack. S then becomes the current set
117 // of Soft Labelled Keys.
118 void push(Soft_Label_Key_Set& S);
120 // Throw away the current set of SLKs and make the previous one the
124 // Retrieve the current set of Soft Labelled Keys.
125 Soft_Label_Key_Set* top() const;
127 // Attributes to use for menu and forms foregrounds
128 virtual chtype foregrounds() const {
129 return b_Colors ? COLOR_PAIR(1) : A_BOLD;
132 // Attributes to use for menu and forms backgrounds
133 virtual chtype backgrounds() const {
134 return b_Colors ? COLOR_PAIR(2) : A_NORMAL;
137 // Attributes to use for inactive (menu) elements
138 virtual chtype inactives() const {
139 return b_Colors ? (COLOR_PAIR(3)|A_DIM) : A_DIM;
142 // Attributes to use for (form) labels and SLKs
143 virtual chtype labels() const {
144 return b_Colors ? COLOR_PAIR(4) : A_NORMAL;
147 // Attributes to use for form backgrounds
148 virtual chtype dialog_backgrounds() const {
149 return b_Colors ? COLOR_PAIR(4) : A_NORMAL;
152 // Attributes to use as default for (form) window backgrounds
153 virtual chtype window_backgrounds() const {
154 return b_Colors ? COLOR_PAIR(5) : A_NORMAL;
157 // Attributes to use for the title window
158 virtual chtype screen_titles() const {
159 return b_Colors ? COLOR_PAIR(6) : A_BOLD;
164 #endif // NCURSES_CURSESAPP_H_incl