X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=c%2B%2B%2Fcursesapp.h;h=0c4010a9e4f62395a4840adafe8d752664b52b12;hp=3eb25d031191626d06995cf2a7ac98da313077f3;hb=cf6a62567b2365c8678b7d561845bdbd1739e5da;hpb=46722468f47c2b77b3987729b4bcf2321cccfd01 diff --git a/c++/cursesapp.h b/c++/cursesapp.h index 3eb25d03..0c4010a9 100644 --- a/c++/cursesapp.h +++ b/c++/cursesapp.h @@ -1,6 +1,7 @@ // * This makes emacs happy -*-Mode: C++;-*- /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright 2019,2020 Thomas E. Dickey * + * Copyright 1998-2005,2011 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -29,17 +30,27 @@ /**************************************************************************** * Author: Juergen Pfeifer, 1997 * - * Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en * ****************************************************************************/ -// $Id: cursesapp.h,v 1.8 2002/07/06 15:47:52 juergen Exp $ +// $Id: cursesapp.h,v 1.16 2020/07/18 19:57:11 anonymous.maarten Exp $ #ifndef NCURSES_CURSESAPP_H_incl #define NCURSES_CURSESAPP_H_incl #include -class NCURSES_IMPEXP NCursesApplication { +#ifdef _WIN32 +# define NCURSES_CXX_MAIN_NAME cursespp_main +# define NCURSES_CXX_MAIN \ + int main(int argc, char *argv[]) { \ + return NCURSES_CXX_MAIN_NAME(argc, argv); \ + } +#else +# define NCURSES_CXX_MAIN_NAME main +#endif +NCURSES_CXX_IMPEXP int NCURSES_CXX_MAIN_NAME(int argc, char *argv[]); + +class NCURSES_CXX_IMPEXP NCursesApplication { public: typedef struct _slk_link { // This structure is used to maintain struct _slk_link* prev; // a stack of SLKs @@ -81,24 +92,38 @@ protected: // This method is called to initialize the SLKs. Default is nothing. // You may rewrite this in your derived class virtual void init_labels(Soft_Label_Key_Set& S) const { + (void) S; } // Your derived class must implement this method. The return value must // be the exit value of your application. virtual int run() = 0; - // The constructor is protected, so you may use it in your derived // class constructor. The argument tells whether or not you want colors. NCursesApplication(bool wantColors = FALSE); + NCursesApplication& operator=(const NCursesApplication& rhs) + { + if (this != &rhs) { + *this = rhs; + } + return *this; + } + + NCursesApplication(const NCursesApplication& rhs) + : b_Colors(rhs.b_Colors), + Root_Window(rhs.Root_Window) + { + } + + static NCursesWindow *&getTitleWindow(); + public: - virtual ~NCursesApplication(); + virtual ~NCursesApplication() THROWS(NCursesException); // Get a pointer to the current application object - static NCursesApplication* getApplication() { - return theApp; - } + static NCursesApplication* getApplication(); // This method runs the application and returns its exit value int operator()(void); @@ -106,6 +131,8 @@ public: // Process the commandline arguments. The default implementation simply // ignores them. Your derived class may rewrite this. virtual void handleArgs(int argc, char* argv[]) { + (void) argc; + (void) argv; } // Does this application use colors? @@ -126,39 +153,39 @@ public: // Attributes to use for menu and forms foregrounds virtual chtype foregrounds() const { - return b_Colors ? COLOR_PAIR(1) : A_BOLD; + return b_Colors ? static_cast(COLOR_PAIR(1)) : A_BOLD; } // Attributes to use for menu and forms backgrounds virtual chtype backgrounds() const { - return b_Colors ? COLOR_PAIR(2) : A_NORMAL; + return b_Colors ? static_cast(COLOR_PAIR(2)) : A_NORMAL; } // Attributes to use for inactive (menu) elements virtual chtype inactives() const { - return b_Colors ? (COLOR_PAIR(3)|A_DIM) : A_DIM; + return b_Colors ? static_cast(COLOR_PAIR(3)|A_DIM) : A_DIM; } // Attributes to use for (form) labels and SLKs virtual chtype labels() const { - return b_Colors ? COLOR_PAIR(4) : A_NORMAL; + return b_Colors ? static_cast(COLOR_PAIR(4)) : A_NORMAL; } // Attributes to use for form backgrounds virtual chtype dialog_backgrounds() const { - return b_Colors ? COLOR_PAIR(4) : A_NORMAL; + return b_Colors ? static_cast(COLOR_PAIR(4)) : A_NORMAL; } // Attributes to use as default for (form) window backgrounds virtual chtype window_backgrounds() const { - return b_Colors ? COLOR_PAIR(5) : A_NORMAL; + return b_Colors ? static_cast(COLOR_PAIR(5)) : A_NORMAL; } // Attributes to use for the title window virtual chtype screen_titles() const { - return b_Colors ? COLOR_PAIR(6) : A_BOLD; + return b_Colors ? static_cast(COLOR_PAIR(6)) : A_BOLD; } }; -#endif // NCURSES_CURSESAPP_H_incl +#endif /* NCURSES_CURSESAPP_H_incl */