X-Git-Url: https://ncurses.scripts.mit.edu/?a=blobdiff_plain;f=c%2B%2B%2Fcursesp.h;h=f0bd5c9cdfffabf9c25c1d88a159bd4bd1b47a87;hb=f79c210479470378389aab5b8d4d42d4a7f3d9a4;hp=adb54455a1472ea2e6898b0af1c99f00369adb38;hpb=55ccd2b959766810cf7db8d1c4462f338ce0afc8;p=ncurses.git diff --git a/c++/cursesp.h b/c++/cursesp.h index adb54455..f0bd5c9c 100644 --- a/c++/cursesp.h +++ b/c++/cursesp.h @@ -1,6 +1,8 @@ // * This makes emacs happy -*-Mode: C++;-*- +// vile:cppmode /**************************************************************************** - * Copyright (c) 1998-2003,2005 Free Software Foundation, Inc. * + * Copyright 2019-2021,2022 Thomas E. Dickey * + * Copyright 1998-2012,2014 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 * @@ -34,7 +36,7 @@ #ifndef NCURSES_CURSESP_H_incl #define NCURSES_CURSESP_H_incl 1 -// $Id: cursesp.h,v 1.26 2005/08/13 18:09:21 tom Exp $ +// $Id: cursesp.h,v 1.36 2022/08/20 20:52:15 tom Exp $ #include @@ -42,7 +44,7 @@ extern "C" { # include } -class NCURSES_IMPEXP NCursesPanel +class NCURSES_CXX_IMPEXP NCursesPanel : public NCursesWindow { protected: @@ -71,19 +73,22 @@ protected: void set_user(void *user) { UserHook* uptr = UserPointer(); - assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==p); - uptr->m_user = user; + if (uptr != 0 && uptr->m_back==this && uptr->m_owner==p) { + uptr->m_user = user; + } } // Set the user pointer of the panel. void *get_user() { UserHook* uptr = UserPointer(); - assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==p); - return uptr->m_user; + void *result = 0; + if (uptr != 0 && uptr->m_back==this && uptr->m_owner==p) + result = uptr->m_user; + return result; } - void OnError (int err) const THROWS((NCursesPanelException)) + void OnError (int err) const THROW2(NCursesException const, NCursesPanelException) { if (err==ERR) THROW(new NCursesPanelException (this, err)); @@ -128,7 +133,7 @@ public: { } - virtual ~NCursesPanel(); + virtual ~NCursesPanel() THROWS(NCursesException); // basic manipulation inline void hide() @@ -157,7 +162,7 @@ public: // N.B.: The panel associated with ::stdscr is always on the bottom. So // actually bottom() makes the panel the first above ::stdscr. - virtual int mvwin(int y, int x) + virtual int mvwin(int y, int x) NCURSES_OVERRIDE { OnError(::move_panel(p, y, x)); return OK; @@ -190,11 +195,11 @@ public: // Those two are rewrites of the corresponding virtual members of // NCursesWindow - virtual int refresh(); + virtual int refresh() NCURSES_OVERRIDE; // Propagate all panel changes to the virtual screen and update the // physical screen. - virtual int noutrefresh(); + virtual int noutrefresh() NCURSES_OVERRIDE; // Propagate all panel changes to the virtual screen. static void redraw(); @@ -233,22 +238,23 @@ public: : NCursesPanel (nlines, ncols, begin_y, begin_x) { if (p) - set_user (const_cast(p_UserData)); + set_user (const_cast(reinterpret_cast + (p_UserData))); }; // This creates an user panel of the requested size with associated // user data pointed to by p_UserData. - NCursesUserPanel(const T* p_UserData = STATIC_CAST(T*)(0)) : NCursesPanel() + explicit NCursesUserPanel(const T* p_UserData = STATIC_CAST(T*)(0)) : NCursesPanel() { if (p) - set_user(const_cast(p_UserData)); + set_user(const_cast(reinterpret_cast(p_UserData))); }; // This creates an user panel associated with the ::stdscr and user data // pointed to by p_UserData. - virtual ~NCursesUserPanel() {}; + virtual ~NCursesUserPanel() THROWS(NCursesException) {}; - T* UserData (void) const + T* UserData (void) { return reinterpret_cast(get_user ()); }; @@ -257,7 +263,7 @@ public: virtual void setUserData (const T* p_UserData) { if (p) - set_user (const_cast(p_UserData)); + set_user (const_cast(reinterpret_cast(p_UserData))); } // Associate the user panel with the user data pointed to by p_UserData. };