// * This makes emacs happy -*-Mode: C++;-*-
/****************************************************************************
- * Copyright (c) 1998-2005,2011 Free Software Foundation, Inc. *
+ * Copyright 2019-2020,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 *
* Author: Juergen Pfeifer, 1997 *
****************************************************************************/
-// $Id: cursesm.h,v 1.26 2011/04/09 18:07:08 Alexander.Kolesen Exp $
+// $Id: cursesm.h,v 1.35 2022/08/20 20:52:15 tom Exp $
#ifndef NCURSES_CURSESM_H_incl
#define NCURSES_CURSESM_H_incl 1
// This wraps the ITEM type of <menu.h>
// -------------------------------------------------------------------------
//
-class NCURSES_IMPEXP NCursesMenuItem
+class NCURSES_CXX_IMPEXP NCursesMenuItem
{
friend class NCursesMenu;
protected:
ITEM *item;
- inline void OnError (int err) const THROWS(NCursesMenuException) {
+ inline void OnError (int err) const THROW2(NCursesException const, NCursesMenuException) {
if (err != E_OK)
THROW(new NCursesMenuException (err));
}
NCursesMenuItem(const NCursesMenuItem& rhs)
: item(0)
{
+ (void) rhs;
}
- virtual ~NCursesMenuItem ();
+ virtual ~NCursesMenuItem () THROWS(NCursesException);
// Release the items memory
inline const char* name () const {
// If you don't like to create a child class for individual items to
// overload action(), you may use this class and provide a callback
// function pointer for items.
-class NCURSES_IMPEXP NCursesMenuCallbackItem : public NCursesMenuItem
+class NCURSES_CXX_IMPEXP NCursesMenuCallbackItem : public NCursesMenuItem
{
private:
ITEMCALLBACK* p_fct;
{
}
- virtual ~NCursesMenuCallbackItem();
+ virtual ~NCursesMenuCallbackItem() THROWS(NCursesException);
- bool action();
+ bool action() NCURSES_OVERRIDE;
};
// This are the built-in hook functions in this C++ binding. In C++ we use
// This wraps the MENU type of <menu.h>
// -------------------------------------------------------------------------
//
-class NCURSES_IMPEXP NCursesMenu : public NCursesPanel
+class NCURSES_CXX_IMPEXP NCursesMenu : public NCursesPanel
{
protected:
MENU *menu;
bool with_frame,
bool autoDeleteItems);
- inline void OnError (int err) const THROWS(NCursesMenuException) {
+ inline void OnError (int err) const THROW2(NCursesException const, NCursesMenuException) {
if (err != E_OK)
THROW(new NCursesMenuException (this, err));
}
{
}
- virtual ~NCursesMenu ();
+ virtual ~NCursesMenu () THROWS(NCursesException);
// Retrieve the menus subwindow
inline NCursesWindow& subWindow() const {
flag ? OnError (::post_menu(menu)) : OnError (::unpost_menu (menu));
}
- // Get the numer of rows and columns for this menu
+ // Get the number of rows and columns for this menu
inline void scale (int& mrows, int& mcols) const {
OnError (::scale_menu (menu, &mrows, &mcols));
}
}
// Decorations
- inline void frame(const char *title=NULL, const char* btitle=NULL) {
+ inline void frame(const char *title=NULL, const char* btitle=NULL) NCURSES_OVERRIDE {
if (b_framed)
NCursesPanel::frame(title,btitle);
else
OnError(E_SYSTEM_ERROR);
}
- inline void boldframe(const char *title=NULL, const char* btitle=NULL) {
+ inline void boldframe(const char *title=NULL, const char* btitle=NULL) NCURSES_OVERRIDE {
if (b_framed)
NCursesPanel::boldframe(title,btitle);
else
OnError(E_SYSTEM_ERROR);
}
- inline void label(const char *topLabel, const char *bottomLabel) {
+ inline void label(const char *topLabel, const char *bottomLabel) NCURSES_OVERRIDE {
if (b_framed)
NCursesPanel::label(topLabel,bottomLabel);
else
// to create a UserItem.
// -------------------------------------------------------------------------
//
-template<class T> class NCURSES_IMPEXP NCursesUserItem : public NCursesMenuItem
+template<class T> class NCURSES_CXX_IMPEXP NCursesUserItem : public NCursesMenuItem
{
public:
NCursesUserItem (const char* p_name,
OnError (::set_item_userptr (item, const_cast<void *>(reinterpret_cast<const void*>(p_UserData))));
}
- virtual ~NCursesUserItem() {}
+ virtual ~NCursesUserItem() THROWS(NCursesException) {}
inline const T* UserData (void) const {
return reinterpret_cast<const T*>(::item_userptr (item));
// The same mechanism is used to attach user data to a menu
// -------------------------------------------------------------------------
//
-template<class T> class NCURSES_IMPEXP NCursesUserMenu : public NCursesMenu
+template<class T> class NCURSES_CXX_IMPEXP NCursesUserMenu : public NCursesMenu
{
protected:
NCursesUserMenu( int nlines,
const T* p_UserData = STATIC_CAST(T*)(0))
: NCursesMenu(nlines,ncols,begin_y,begin_x) {
if (menu)
- set_user (const_cast<void *>(p_UserData));
+ set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
}
public:
- NCursesUserMenu (NCursesMenuItem Items[],
+ NCursesUserMenu (NCursesMenuItem* Items[],
const T* p_UserData = STATIC_CAST(T*)(0),
bool with_frame=FALSE,
bool autoDelete_Items=FALSE)
- : NCursesMenu (&Items, with_frame, autoDelete_Items) {
+ : NCursesMenu (Items, with_frame, autoDelete_Items) {
if (menu)
- set_user (const_cast<void *>(p_UserData));
+ set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
};
- NCursesUserMenu (NCursesMenuItem Items[],
+ NCursesUserMenu (NCursesMenuItem* Items[],
int nlines,
int ncols,
int begin_y = 0,
int begin_x = 0,
const T* p_UserData = STATIC_CAST(T*)(0),
bool with_frame=FALSE)
- : NCursesMenu (&Items, nlines, ncols, begin_y, begin_x, with_frame) {
+ : NCursesMenu (Items, nlines, ncols, begin_y, begin_x, with_frame) {
if (menu)
- set_user (const_cast<void *>(p_UserData));
+ set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
};
- virtual ~NCursesUserMenu() {
+ virtual ~NCursesUserMenu() THROWS(NCursesException) {
};
- inline T* UserData (void) const {
+ inline T* UserData (void) {
return reinterpret_cast<T*>(get_user ());
};
inline virtual void setUserData (const T* p_UserData) {
if (menu)
- set_user (const_cast<void *>(p_UserData));
+ set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
}
};