annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/ncursesw/cursesapp.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 // * This makes emacs happy -*-Mode: C++;-*-
jpayne@69 2 /****************************************************************************
jpayne@69 3 * Copyright 2019-2020,2021 Thomas E. Dickey *
jpayne@69 4 * Copyright 1998-2005,2011 Free Software Foundation, Inc. *
jpayne@69 5 * *
jpayne@69 6 * Permission is hereby granted, free of charge, to any person obtaining a *
jpayne@69 7 * copy of this software and associated documentation files (the *
jpayne@69 8 * "Software"), to deal in the Software without restriction, including *
jpayne@69 9 * without limitation the rights to use, copy, modify, merge, publish, *
jpayne@69 10 * distribute, distribute with modifications, sublicense, and/or sell *
jpayne@69 11 * copies of the Software, and to permit persons to whom the Software is *
jpayne@69 12 * furnished to do so, subject to the following conditions: *
jpayne@69 13 * *
jpayne@69 14 * The above copyright notice and this permission notice shall be included *
jpayne@69 15 * in all copies or substantial portions of the Software. *
jpayne@69 16 * *
jpayne@69 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
jpayne@69 18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
jpayne@69 19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
jpayne@69 20 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
jpayne@69 21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
jpayne@69 22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
jpayne@69 23 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
jpayne@69 24 * *
jpayne@69 25 * Except as contained in this notice, the name(s) of the above copyright *
jpayne@69 26 * holders shall not be used in advertising or otherwise to promote the *
jpayne@69 27 * sale, use or other dealings in this Software without prior written *
jpayne@69 28 * authorization. *
jpayne@69 29 ****************************************************************************/
jpayne@69 30
jpayne@69 31 /****************************************************************************
jpayne@69 32 * Author: Juergen Pfeifer, 1997 *
jpayne@69 33 ****************************************************************************/
jpayne@69 34
jpayne@69 35 // $Id: cursesapp.h,v 1.18 2021/06/17 21:26:02 tom Exp $
jpayne@69 36
jpayne@69 37 #ifndef NCURSES_CURSESAPP_H_incl
jpayne@69 38 #define NCURSES_CURSESAPP_H_incl
jpayne@69 39
jpayne@69 40 #include <ncursesw/cursslk.h>
jpayne@69 41
jpayne@69 42 #if (defined(_WIN32) || defined(_WIN64))
jpayne@69 43 # define NCURSES_CXX_MAIN_NAME cursespp_main
jpayne@69 44 # define NCURSES_CXX_MAIN \
jpayne@69 45 int main(int argc, char *argv[]) { \
jpayne@69 46 return NCURSES_CXX_MAIN_NAME(argc, argv); \
jpayne@69 47 }
jpayne@69 48 #else
jpayne@69 49 # define NCURSES_CXX_MAIN_NAME main
jpayne@69 50 #endif
jpayne@69 51 NCURSES_CXX_IMPEXP int NCURSES_CXX_MAIN_NAME(int argc, char *argv[]);
jpayne@69 52
jpayne@69 53 class NCURSES_CXX_IMPEXP NCursesApplication {
jpayne@69 54 public:
jpayne@69 55 typedef struct _slk_link { // This structure is used to maintain
jpayne@69 56 struct _slk_link* prev; // a stack of SLKs
jpayne@69 57 Soft_Label_Key_Set* SLKs;
jpayne@69 58 } SLK_Link;
jpayne@69 59 private:
jpayne@69 60 static int rinit(NCursesWindow& w); // Internal Init function for title
jpayne@69 61 static NCursesApplication* theApp; // Global ref. to the application
jpayne@69 62
jpayne@69 63 static SLK_Link* slk_stack;
jpayne@69 64
jpayne@69 65 protected:
jpayne@69 66 static NCursesWindow* titleWindow; // The Title Window (if any)
jpayne@69 67
jpayne@69 68 bool b_Colors; // Is this a color application?
jpayne@69 69 NCursesWindow* Root_Window; // This is the stdscr equiv.
jpayne@69 70
jpayne@69 71 // Initialization of attributes;
jpayne@69 72 // Rewrite this in your derived class if you prefer other settings
jpayne@69 73 virtual void init(bool bColors);
jpayne@69 74
jpayne@69 75 // The number of lines for the title window. Default is no title window
jpayne@69 76 // You may rewrite this in your derived class
jpayne@69 77 virtual int titlesize() const {
jpayne@69 78 return 0;
jpayne@69 79 }
jpayne@69 80
jpayne@69 81 // This method is called to put something into the title window initially
jpayne@69 82 // You may rewrite this in your derived class
jpayne@69 83 virtual void title() {
jpayne@69 84 }
jpayne@69 85
jpayne@69 86 // The layout used for the Soft Label Keys. Default is to have no SLKs.
jpayne@69 87 // You may rewrite this in your derived class
jpayne@69 88 virtual Soft_Label_Key_Set::Label_Layout useSLKs() const {
jpayne@69 89 return Soft_Label_Key_Set::None;
jpayne@69 90 }
jpayne@69 91
jpayne@69 92 // This method is called to initialize the SLKs. Default is nothing.
jpayne@69 93 // You may rewrite this in your derived class
jpayne@69 94 virtual void init_labels(Soft_Label_Key_Set& S) const {
jpayne@69 95 (void) S;
jpayne@69 96 }
jpayne@69 97
jpayne@69 98 // Your derived class must implement this method. The return value must
jpayne@69 99 // be the exit value of your application.
jpayne@69 100 virtual int run() = 0;
jpayne@69 101
jpayne@69 102 // The constructor is protected, so you may use it in your derived
jpayne@69 103 // class constructor. The argument tells whether or not you want colors.
jpayne@69 104 NCursesApplication(bool wantColors = FALSE);
jpayne@69 105
jpayne@69 106 NCursesApplication& operator=(const NCursesApplication& rhs)
jpayne@69 107 {
jpayne@69 108 if (this != &rhs) {
jpayne@69 109 *this = rhs;
jpayne@69 110 }
jpayne@69 111 return *this;
jpayne@69 112 }
jpayne@69 113
jpayne@69 114 NCursesApplication(const NCursesApplication& rhs)
jpayne@69 115 : b_Colors(rhs.b_Colors),
jpayne@69 116 Root_Window(rhs.Root_Window)
jpayne@69 117 {
jpayne@69 118 }
jpayne@69 119
jpayne@69 120 static NCursesWindow *&getTitleWindow();
jpayne@69 121
jpayne@69 122 public:
jpayne@69 123 virtual ~NCursesApplication() THROWS(NCursesException);
jpayne@69 124
jpayne@69 125 // Get a pointer to the current application object
jpayne@69 126 static NCursesApplication* getApplication();
jpayne@69 127
jpayne@69 128 // This method runs the application and returns its exit value
jpayne@69 129 int operator()(void);
jpayne@69 130
jpayne@69 131 // Process the commandline arguments. The default implementation simply
jpayne@69 132 // ignores them. Your derived class may rewrite this.
jpayne@69 133 virtual void handleArgs(int argc, char* argv[]) {
jpayne@69 134 (void) argc;
jpayne@69 135 (void) argv;
jpayne@69 136 }
jpayne@69 137
jpayne@69 138 // Does this application use colors?
jpayne@69 139 inline bool useColors() const {
jpayne@69 140 return b_Colors;
jpayne@69 141 }
jpayne@69 142
jpayne@69 143 // Push the Key Set S onto the SLK Stack. S then becomes the current set
jpayne@69 144 // of Soft Labelled Keys.
jpayne@69 145 void push(Soft_Label_Key_Set& S);
jpayne@69 146
jpayne@69 147 // Throw away the current set of SLKs and make the previous one the
jpayne@69 148 // new current set.
jpayne@69 149 bool pop();
jpayne@69 150
jpayne@69 151 // Retrieve the current set of Soft Labelled Keys.
jpayne@69 152 Soft_Label_Key_Set* top() const;
jpayne@69 153
jpayne@69 154 // Attributes to use for menu and forms foregrounds
jpayne@69 155 virtual chtype foregrounds() const {
jpayne@69 156 return b_Colors ? static_cast<chtype>(COLOR_PAIR(1)) : A_BOLD;
jpayne@69 157 }
jpayne@69 158
jpayne@69 159 // Attributes to use for menu and forms backgrounds
jpayne@69 160 virtual chtype backgrounds() const {
jpayne@69 161 return b_Colors ? static_cast<chtype>(COLOR_PAIR(2)) : A_NORMAL;
jpayne@69 162 }
jpayne@69 163
jpayne@69 164 // Attributes to use for inactive (menu) elements
jpayne@69 165 virtual chtype inactives() const {
jpayne@69 166 return b_Colors ? static_cast<chtype>(COLOR_PAIR(3)|A_DIM) : A_DIM;
jpayne@69 167 }
jpayne@69 168
jpayne@69 169 // Attributes to use for (form) labels and SLKs
jpayne@69 170 virtual chtype labels() const {
jpayne@69 171 return b_Colors ? static_cast<chtype>(COLOR_PAIR(4)) : A_NORMAL;
jpayne@69 172 }
jpayne@69 173
jpayne@69 174 // Attributes to use for form backgrounds
jpayne@69 175 virtual chtype dialog_backgrounds() const {
jpayne@69 176 return b_Colors ? static_cast<chtype>(COLOR_PAIR(4)) : A_NORMAL;
jpayne@69 177 }
jpayne@69 178
jpayne@69 179 // Attributes to use as default for (form) window backgrounds
jpayne@69 180 virtual chtype window_backgrounds() const {
jpayne@69 181 return b_Colors ? static_cast<chtype>(COLOR_PAIR(5)) : A_NORMAL;
jpayne@69 182 }
jpayne@69 183
jpayne@69 184 // Attributes to use for the title window
jpayne@69 185 virtual chtype screen_titles() const {
jpayne@69 186 return b_Colors ? static_cast<chtype>(COLOR_PAIR(6)) : A_BOLD;
jpayne@69 187 }
jpayne@69 188
jpayne@69 189 };
jpayne@69 190
jpayne@69 191 #endif /* NCURSES_CURSESAPP_H_incl */