ncursesw-morphos/c++/cursesm.h

593 lines
17 KiB
C
Raw Normal View History

1997-05-15 12:00:00 +08:00
// * This makes emacs happy -*-Mode: C++;-*-
1998-03-01 12:21:12 +08:00
/****************************************************************************
2000-07-09 10:46:08 +08:00
* Copyright (c) 1998,1999 Free Software Foundation, Inc. *
1998-03-01 12:21:12 +08:00
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included *
* in all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
* *
* Except as contained in this notice, the name(s) of the above copyright *
* holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written *
* authorization. *
****************************************************************************/
/****************************************************************************
1999-10-24 12:32:42 +08:00
* Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1997 *
1998-03-01 12:21:12 +08:00
****************************************************************************/
2000-07-09 10:46:08 +08:00
// $Id: cursesm.h,v 1.13 1999/10/30 23:59:37 tom Exp $
1998-03-01 12:21:12 +08:00
1997-05-15 12:00:00 +08:00
#ifndef _CURSESM_H
#define _CURSESM_H
#include <cursesp.h>
extern "C" {
# include <menu.h>
}
1998-03-01 12:21:12 +08:00
//
// -------------------------------------------------------------------------
1997-05-15 12:00:00 +08:00
// This wraps the ITEM type of <menu.h>
1998-03-01 12:21:12 +08:00
// -------------------------------------------------------------------------
//
class NCursesMenuItem {
1997-05-15 12:00:00 +08:00
friend class NCursesMenu;
1998-03-01 12:21:12 +08:00
1997-05-15 12:00:00 +08:00
protected:
ITEM *item;
1998-03-01 12:21:12 +08:00
inline void OnError (int err) const THROWS(NCursesMenuException) {
1997-05-15 12:00:00 +08:00
if (err != E_OK)
THROW(new NCursesMenuException (err));
}
public:
NCursesMenuItem (const char* p_name = NULL,
1998-03-01 12:21:12 +08:00
const char* p_descript = NULL ) {
1997-05-15 12:00:00 +08:00
item = p_name ? ::new_item (p_name, p_descript) : (ITEM*)0;
if (p_name && !item)
OnError (E_SYSTEM_ERROR);
}
1998-03-01 12:21:12 +08:00
// Create an item. If you pass both parameters as NULL, a delimiting
// item is constructed which can be used to terminate a list of
// NCursesMenu objects.
1997-05-15 12:00:00 +08:00
1998-03-01 12:21:12 +08:00
virtual ~NCursesMenuItem ();
1997-05-15 12:00:00 +08:00
// Release the items memory
1998-03-01 12:21:12 +08:00
inline const char* name () const {
1997-05-15 12:00:00 +08:00
return ::item_name (item);
}
1998-03-01 12:21:12 +08:00
// Name of the item
1997-05-15 12:00:00 +08:00
1998-03-01 12:21:12 +08:00
inline const char* description () const {
1997-05-15 12:00:00 +08:00
return ::item_description (item);
}
1998-03-01 12:21:12 +08:00
// Description of the item
1999-10-24 12:32:42 +08:00
inline int (index) (void) const {
1997-05-15 12:00:00 +08:00
return ::item_index (item);
}
1998-03-01 12:21:12 +08:00
// Index of the item in an item array (or -1)
1997-05-15 12:00:00 +08:00
1998-03-01 12:21:12 +08:00
inline void options_on (Item_Options options) {
1997-05-15 12:00:00 +08:00
OnError (::item_opts_on (item, options));
}
1998-03-01 12:21:12 +08:00
// Switch on the items options
1997-05-15 12:00:00 +08:00
1998-03-01 12:21:12 +08:00
inline void options_off (Item_Options options) {
1997-05-15 12:00:00 +08:00
OnError (::item_opts_off (item, options));
}
1998-03-01 12:21:12 +08:00
// Switch off the item's option
1997-05-15 12:00:00 +08:00
1998-03-01 12:21:12 +08:00
inline Item_Options options () const {
1997-05-15 12:00:00 +08:00
return ::item_opts (item);
}
1998-03-01 12:21:12 +08:00
// Retrieve the items options
1997-05-15 12:00:00 +08:00
1998-03-01 12:21:12 +08:00
inline void set_options (Item_Options options) {
1997-05-15 12:00:00 +08:00
OnError (::set_item_opts (item, options));
}
1998-03-01 12:21:12 +08:00
// Set the items options
1997-05-15 12:00:00 +08:00
1998-03-01 12:21:12 +08:00
inline void set_value (bool f) {
1997-05-15 12:00:00 +08:00
OnError (::set_item_value (item,f));
}
1998-03-01 12:21:12 +08:00
// Set/Reset the items selection state
1997-05-15 12:00:00 +08:00
1998-03-01 12:21:12 +08:00
inline bool value () const {
1997-05-15 12:00:00 +08:00
return ::item_value (item);
}
1998-03-01 12:21:12 +08:00
// Retrieve the items selection state
1997-05-15 12:00:00 +08:00
1998-03-01 12:21:12 +08:00
inline bool visible () const {
1997-05-15 12:00:00 +08:00
return ::item_visible (item);
}
1998-03-01 12:21:12 +08:00
// Retrieve visibility of the item
1997-05-15 12:00:00 +08:00
1998-03-01 12:21:12 +08:00
virtual bool action();
// Perform an action associated with this item; you may use this in an
1997-05-15 12:00:00 +08:00
// user supplied driver for a menu; you may derive from this class and
// overload action() to supply items with different actions.
1998-03-01 12:21:12 +08:00
// If an action returns true, the menu will be exited. The default action
// is to do nothing.
1997-05-15 12:00:00 +08:00
};
// Prototype for an items callback function.
typedef bool ITEMCALLBACK(NCursesMenuItem&);
// 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.
1998-03-01 12:21:12 +08:00
class NCursesMenuCallbackItem : public NCursesMenuItem {
1997-05-15 12:00:00 +08:00
private:
2000-07-09 10:46:08 +08:00
ITEMCALLBACK* p_fct;
1997-05-15 12:00:00 +08:00
public:
2000-07-09 10:46:08 +08:00
NCursesMenuCallbackItem(ITEMCALLBACK* fct = NULL,
1997-05-15 12:00:00 +08:00
const char* p_name = NULL,
const char* p_descript = NULL )
: NCursesMenuItem (p_name, p_descript),
p_fct (fct) {
}
1998-03-01 12:21:12 +08:00
virtual ~NCursesMenuCallbackItem();
1997-05-15 12:00:00 +08:00
1998-03-01 12:21:12 +08:00
bool action();
1997-05-15 12:00:00 +08:00
};
1998-03-01 12:21:12 +08:00
//
// -------------------------------------------------------------------------
// This wraps the MENU type of <menu.h>
// -------------------------------------------------------------------------
//
1997-05-15 12:00:00 +08:00
class NCursesMenu : public NCursesPanel {
protected:
MENU *menu;
private:
NCursesWindow* sub; // the subwindow object
bool b_sub_owner; // is this our own subwindow?
bool b_framed; // has the menu a border?
1998-03-01 12:21:12 +08:00
bool b_autoDelete; // Delete items when deleting menu?
1997-05-15 12:00:00 +08:00
NCursesMenuItem** my_items; // The array of items for this menu
// This structure is used for the menu's user data field to link the
// MENU* to the C++ object and to provide extra space for a user pointer.
typedef struct {
1998-03-01 12:21:12 +08:00
void* m_user; // the pointer for the user's data
1997-05-15 12:00:00 +08:00
const NCursesMenu* m_back; // backward pointer to C++ object
const MENU* m_owner;
} UserHook;
// Get the backward pointer to the C++ object from a MENU
1998-03-01 12:21:12 +08:00
static inline NCursesMenu* getHook(const MENU *m) {
1997-05-15 12:00:00 +08:00
UserHook* hook = (UserHook*)::menu_userptr(m);
2000-07-09 10:46:08 +08:00
assert(hook != 0 && hook->m_owner==m);
1997-05-15 12:00:00 +08:00
return (NCursesMenu*)(hook->m_back);
}
// This are the built-in hook functions in this C++ binding. In C++ we use
// virtual member functions (see below On_..._Init and On_..._Termination)
// to provide this functionality in an object oriented manner.
static void mnu_init(MENU *);
static void mnu_term(MENU *);
static void itm_init(MENU *);
static void itm_term(MENU *);
// Calculate ITEM* array for the menu
ITEM** mapItems(NCursesMenuItem* nitems[]);
protected:
// internal routines
1998-03-01 12:21:12 +08:00
inline void set_user(void *user) {
1997-05-15 12:00:00 +08:00
UserHook* uptr = (UserHook*)::menu_userptr (menu);
2000-07-09 10:46:08 +08:00
assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==menu);
1997-05-15 12:00:00 +08:00
uptr->m_user = user;
}
1998-03-01 12:21:12 +08:00
inline void *get_user() {
1997-05-15 12:00:00 +08:00
UserHook* uptr = (UserHook*)::menu_userptr (menu);
2000-07-09 10:46:08 +08:00
assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==menu);
1997-05-15 12:00:00 +08:00
return uptr->m_user;
1998-03-01 12:21:12 +08:00
}
void InitMenu (NCursesMenuItem* menu[],
bool with_frame,
bool autoDeleteItems);
1997-05-15 12:00:00 +08:00
1998-03-01 12:21:12 +08:00
inline void OnError (int err) const THROWS(NCursesMenuException) {
1997-05-15 12:00:00 +08:00
if (err != E_OK)
THROW(new NCursesMenuException (this, err));
}
// this wraps the menu_driver call.
virtual int driver (int c) ;
1998-03-01 12:21:12 +08:00
// 'Internal' constructor to create a menu without association to
// an array of items.
NCursesMenu( int lines,
int cols,
int begin_y = 0,
int begin_x = 0)
: NCursesPanel(lines,cols,begin_y,begin_x),
menu ((MENU*)0) {
}
1997-05-15 12:00:00 +08:00
public:
1998-03-01 12:21:12 +08:00
// Make a full window size menu
NCursesMenu (NCursesMenuItem* Items[],
bool with_frame=FALSE, // Reserve space for a frame?
bool autoDelete_Items=FALSE) // Autocleanup of Items?
: NCursesPanel() {
InitMenu(Items, with_frame, autoDelete_Items);
}
1997-05-15 12:00:00 +08:00
1998-03-01 12:21:12 +08:00
// Make a menu with a window of this size.
NCursesMenu (NCursesMenuItem* Items[],
1997-05-15 12:00:00 +08:00
int lines,
int cols,
1998-03-01 12:21:12 +08:00
int begin_y = 0,
int begin_x = 0,
bool with_frame=FALSE, // Reserve space for a frame?
bool autoDelete_Items=FALSE) // Autocleanup of Items?
: NCursesPanel(lines, cols, begin_y, begin_x) {
InitMenu(Items, with_frame, autoDelete_Items);
}
1997-05-15 12:00:00 +08:00
virtual ~NCursesMenu ();
// Retrieve the menus subwindow
inline NCursesWindow& subWindow() const {
assert(sub!=NULL);
return *sub;
}
// Set the menus subwindow
void setSubWindow(NCursesWindow& sub);
// Set these items for the menu
1998-03-01 12:21:12 +08:00
inline void setItems(NCursesMenuItem* Items[]) {
OnError(::set_menu_items(menu,mapItems(Items)));
}
1997-05-15 12:00:00 +08:00
// Remove the menu from the screen
1998-03-01 12:21:12 +08:00
inline void unpost (void) {
1997-05-15 12:00:00 +08:00
OnError (::unpost_menu (menu));
}
// Post the menu to the screen if flag is true, unpost it otherwise
1998-03-01 12:21:12 +08:00
inline void post(bool flag = TRUE) {
1997-05-15 12:00:00 +08:00
flag ? OnError (::post_menu(menu)) : OnError (::unpost_menu (menu));
}
// Get the numer of rows and columns for this menu
1998-03-01 12:21:12 +08:00
inline void scale (int& mrows, int& mcols) const {
1997-05-15 12:00:00 +08:00
OnError (::scale_menu (menu, &mrows, &mcols));
}
// Set the format of this menu
1998-03-01 12:21:12 +08:00
inline void set_format(int mrows, int mcols) {
1997-05-15 12:00:00 +08:00
OnError (::set_menu_format(menu, mrows, mcols));
}
// Get the format of this menu
1998-03-01 12:21:12 +08:00
inline void menu_format(int& rows,int& cols) {
1997-05-15 12:00:00 +08:00
::menu_format(menu,&rows,&cols);
}
1998-03-01 12:21:12 +08:00
// Items of the menu
inline NCursesMenuItem* items() const {
1997-05-15 12:00:00 +08:00
return *my_items;
}
// Get the number of items in this menu
1998-03-01 12:21:12 +08:00
inline int count() const {
1997-05-15 12:00:00 +08:00
return ::item_count(menu);
}
// Get the current item (i.e. the one the cursor is located)
1998-03-01 12:21:12 +08:00
inline NCursesMenuItem* current_item() const {
return my_items[::item_index(::current_item(menu))];
1997-05-15 12:00:00 +08:00
}
// Get the marker string
1998-03-01 12:21:12 +08:00
inline const char* mark() const {
1997-05-15 12:00:00 +08:00
return ::menu_mark(menu);
}
// Set the marker string
1998-03-01 12:21:12 +08:00
inline void set_mark(const char *mark) {
1997-05-15 12:00:00 +08:00
OnError (::set_menu_mark (menu, mark));
}
// Get the name of the request code c
1998-03-01 12:21:12 +08:00
inline static const char* request_name(int c) {
1997-05-15 12:00:00 +08:00
return ::menu_request_name(c);
}
// Get the current pattern
1998-03-01 12:21:12 +08:00
inline char* pattern() const {
1997-05-15 12:00:00 +08:00
return ::menu_pattern(menu);
}
// true if there is a pattern match, false otherwise.
bool set_pattern (const char *pat);
// set the default attributes for the menu
// i.e. set fore, back and grey attribute
virtual void setDefaultAttributes();
// Get the menus background attributes
1998-03-01 12:21:12 +08:00
inline chtype back() const {
1997-05-15 12:00:00 +08:00
return ::menu_back(menu);
}
// Get the menus foreground attributes
1998-03-01 12:21:12 +08:00
inline chtype fore() const {
1997-05-15 12:00:00 +08:00
return ::menu_fore(menu);
}
// Get the menus grey attributes (used for unselectable items)
1998-03-01 12:21:12 +08:00
inline chtype grey() const {
1997-05-15 12:00:00 +08:00
return ::menu_grey(menu);
}
// Set the menus background attributes
1998-03-01 12:21:12 +08:00
inline chtype set_background(chtype a) {
1997-05-15 12:00:00 +08:00
return ::set_menu_back(menu,a);
}
// Set the menus foreground attributes
1998-03-01 12:21:12 +08:00
inline chtype set_foreground(chtype a) {
1997-05-15 12:00:00 +08:00
return ::set_menu_fore(menu,a);
}
// Set the menus grey attributes (used for unselectable items)
1998-03-01 12:21:12 +08:00
inline chtype set_grey(chtype a) {
1997-05-15 12:00:00 +08:00
return ::set_menu_grey(menu,a);
}
1998-03-01 12:21:12 +08:00
inline void options_on (Menu_Options opts) {
1997-05-15 12:00:00 +08:00
OnError (::menu_opts_on (menu,opts));
}
1998-03-01 12:21:12 +08:00
inline void options_off(Menu_Options opts) {
1997-05-15 12:00:00 +08:00
OnError (::menu_opts_off(menu,opts));
}
inline Menu_Options options() const {
return ::menu_opts(menu);
}
1998-03-01 12:21:12 +08:00
inline void set_options (Menu_Options opts) {
1997-05-15 12:00:00 +08:00
OnError (::set_menu_opts (menu,opts));
}
1998-03-01 12:21:12 +08:00
inline int pad() const {
1997-05-15 12:00:00 +08:00
return ::menu_pad(menu);
}
1998-03-01 12:21:12 +08:00
inline void set_pad (int padch) {
1997-05-15 12:00:00 +08:00
OnError (::set_menu_pad (menu, padch));
}
1998-03-01 12:21:12 +08:00
1997-05-15 12:00:00 +08:00
// Position the cursor to the current item
1998-03-01 12:21:12 +08:00
inline void position_cursor () const {
1997-05-15 12:00:00 +08:00
OnError (::pos_menu_cursor (menu));
}
// Set the current item
1998-03-01 12:21:12 +08:00
inline void set_current(NCursesMenuItem& I) {
1997-05-15 12:00:00 +08:00
OnError (::set_current_item(menu, I.item));
}
// Get the current top row of the menu
1998-03-01 12:21:12 +08:00
inline int top_row (void) const {
1997-05-15 12:00:00 +08:00
return ::top_row (menu);
}
// Set the current top row of the menu
1998-03-01 12:21:12 +08:00
inline void set_top_row (int row) {
1997-05-15 12:00:00 +08:00
OnError (::set_top_row (menu, row));
}
// spacing control
// Set the spacing for the menu
inline void setSpacing(int spc_description,
int spc_rows,
int spc_columns) {
OnError(::set_menu_spacing(menu,
spc_description,
spc_rows,
spc_columns));
}
1998-03-01 12:21:12 +08:00
1997-05-15 12:00:00 +08:00
// Get the spacing info for the menu
inline void Spacing(int& spc_description,
int& spc_rows,
int& spc_columns) const {
OnError(::menu_spacing(menu,
&spc_description,
&spc_rows,
&spc_columns));
}
// Decorations
1998-03-01 12:21:12 +08:00
inline void frame(const char *title=NULL, const char* btitle=NULL) {
1997-05-15 12:00:00 +08:00
if (b_framed)
NCursesPanel::frame(title,btitle);
else
OnError(E_SYSTEM_ERROR);
}
1998-03-01 12:21:12 +08:00
inline void boldframe(const char *title=NULL, const char* btitle=NULL) {
1997-05-15 12:00:00 +08:00
if (b_framed)
NCursesPanel::boldframe(title,btitle);
else
OnError(E_SYSTEM_ERROR);
}
1998-03-01 12:21:12 +08:00
inline void label(const char *topLabel, const char *bottomLabel) {
1997-05-15 12:00:00 +08:00
if (b_framed)
NCursesPanel::label(topLabel,bottomLabel);
else
OnError(E_SYSTEM_ERROR);
}
// -----
// Hooks
// -----
// Called after the menu gets repositioned in its window.
// This is especially true if the menu is posted.
1998-03-01 12:21:12 +08:00
virtual void On_Menu_Init();
1997-05-15 12:00:00 +08:00
// Called before the menu gets repositioned in its window.
// This is especially true if the menu is unposted.
1998-03-01 12:21:12 +08:00
virtual void On_Menu_Termination();
1997-05-15 12:00:00 +08:00
// Called after the item became the current item
1998-03-01 12:21:12 +08:00
virtual void On_Item_Init(NCursesMenuItem& item);
1997-05-15 12:00:00 +08:00
// Called before this item is left as current item.
1998-03-01 12:21:12 +08:00
virtual void On_Item_Termination(NCursesMenuItem& item);
1997-05-15 12:00:00 +08:00
// Provide a default key virtualization. Translate the keyboard
// code c into a menu request code.
// The default implementation provides a hopefully straightforward
// mapping for the most common keystrokes and menu requests.
virtual int virtualize(int c);
// Operators
1998-03-01 12:21:12 +08:00
inline NCursesMenuItem* operator[](int i) const {
1997-05-15 12:00:00 +08:00
if ( (i < 0) || (i >= ::item_count (menu)) )
OnError (E_BAD_ARGUMENT);
1998-03-01 12:21:12 +08:00
return (my_items[i]);
1997-05-15 12:00:00 +08:00
}
// Perform the menu's operation
1998-03-01 12:21:12 +08:00
// Return the item where you left the selection mark for a single
// selection menu, or NULL for a multivalued menu.
virtual NCursesMenuItem* operator()(void);
1997-05-15 12:00:00 +08:00
// --------------------
// Exception handlers
// Called by operator()
// --------------------
// Called if the request is denied
1998-03-01 12:21:12 +08:00
virtual void On_Request_Denied(int c) const;
1997-05-15 12:00:00 +08:00
// Called if the item is not selectable
1998-03-01 12:21:12 +08:00
virtual void On_Not_Selectable(int c) const;
1997-05-15 12:00:00 +08:00
// Called if pattern doesn't match
1998-03-01 12:21:12 +08:00
virtual void On_No_Match(int c) const;
1997-05-15 12:00:00 +08:00
// Called if the command is unknown
1998-03-01 12:21:12 +08:00
virtual void On_Unknown_Command(int c) const;
1997-05-15 12:00:00 +08:00
1998-03-01 12:21:12 +08:00
};
//
// -------------------------------------------------------------------------
1997-05-15 12:00:00 +08:00
// This is the typical C++ typesafe way to allow to attach
// user data to an item of a menu. Its assumed that the user
// data belongs to some class T. Use T as template argument
// to create a UserItem.
1998-03-01 12:21:12 +08:00
// -------------------------------------------------------------------------
//
1997-05-15 12:00:00 +08:00
template<class T> class NCursesUserItem : public NCursesMenuItem
{
public:
1998-03-01 12:21:12 +08:00
NCursesUserItem (const char* p_name,
const char* p_descript = NULL,
const T* p_UserData = (T*)0)
: NCursesMenuItem (p_name, p_descript) {
if (item)
OnError (::set_item_userptr (item, (void *)p_UserData));
1997-05-15 12:00:00 +08:00
};
virtual ~NCursesUserItem() {};
1998-03-01 12:21:12 +08:00
inline const T* UserData (void) const {
1997-05-15 12:00:00 +08:00
return (const T*)::item_userptr (item);
};
1998-03-01 12:21:12 +08:00
inline virtual void setUserData(const T* p_UserData) {
1997-05-15 12:00:00 +08:00
if (item)
1998-03-01 12:21:12 +08:00
OnError (::set_item_userptr (item, (void *)p_UserData));
1997-05-15 12:00:00 +08:00
}
};
1998-03-01 12:21:12 +08:00
//
// -------------------------------------------------------------------------
1997-05-15 12:00:00 +08:00
// The same mechanism is used to attach user data to a menu
1998-03-01 12:21:12 +08:00
// -------------------------------------------------------------------------
//
1997-05-15 12:00:00 +08:00
template<class T> class NCursesUserMenu : public NCursesMenu
{
1998-03-01 12:21:12 +08:00
protected:
NCursesUserMenu( int lines,
int cols,
int begin_y = 0,
int begin_x = 0,
const T* p_UserData = (T*)0)
: NCursesMenu(lines,cols,begin_y,begin_x) {
if (menu)
set_user ((void *)p_UserData);
}
1997-05-15 12:00:00 +08:00
public:
1998-03-01 12:21:12 +08:00
NCursesUserMenu (NCursesMenuItem Items[],
const T* p_UserData = (T*)0,
bool with_frame=FALSE,
bool autoDelete_Items=FALSE)
: NCursesMenu (Items, with_frame, autoDelete_Items) {
if (menu)
set_user ((void *)p_UserData);
1997-05-15 12:00:00 +08:00
};
1998-03-01 12:21:12 +08:00
NCursesUserMenu (NCursesMenuItem Items[],
1997-05-15 12:00:00 +08:00
int lines,
int cols,
1998-03-01 12:21:12 +08:00
int begin_y = 0,
int begin_x = 0,
const T* p_UserData = (T*)0,
1997-05-15 12:00:00 +08:00
bool with_frame=FALSE)
1998-03-01 12:21:12 +08:00
: NCursesMenu (Items, lines, cols, begin_y, begin_x, with_frame) {
if (menu)
set_user ((void *)p_UserData);
1997-05-15 12:00:00 +08:00
};
1998-03-01 12:21:12 +08:00
virtual ~NCursesUserMenu() {
};
inline T* UserData (void) const {
return (T*)get_user ();
1997-05-15 12:00:00 +08:00
};
1998-03-01 12:21:12 +08:00
inline virtual void setUserData (const T* p_UserData) {
if (menu)
set_user ((void *)p_UserData);
1997-05-15 12:00:00 +08:00
}
};
#endif // _CURSESM_H