cursesapp.h   cursesapp.h 
// * This makes emacs happy -*-Mode: C++;-*- // * This makes emacs happy -*-Mode: C++;-*-
/************************************************************************** ** /************************************************************************** **
* Copyright (c) 1998-2002,2003 Free Software Foundation, Inc. * * Copyright (c) 1998-2003,2005 Free Software Foundation, Inc. *
* * * *
* Permission is hereby granted, free of charge, to any person obtaining a * * Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the * * copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including * * "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, * * without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell * * distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is * * copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: * * furnished to do so, subject to the following conditions: *
* * * *
* The above copyright notice and this permission notice shall be included * * The above copyright notice and this permission notice shall be included *
skipping to change at line 34 skipping to change at line 34
* Except as contained in this notice, the name(s) of the above copyright * * 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 * * holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written * * sale, use or other dealings in this Software without prior written *
* authorization. * * authorization. *
************************************************************************** **/ ************************************************************************** **/
/************************************************************************** ** /************************************************************************** **
* Author: Juergen Pfeifer, 1997 * * Author: Juergen Pfeifer, 1997 *
************************************************************************** **/ ************************************************************************** **/
// $Id: cursesapp.h,v 1.9 2003/10/25 15:04:46 tom Exp $ // $Id: cursesapp.h,v 1.11 2005/05/28 21:57:44 tom Exp $
#ifndef NCURSES_CURSESAPP_H_incl #ifndef NCURSES_CURSESAPP_H_incl
#define NCURSES_CURSESAPP_H_incl #define NCURSES_CURSESAPP_H_incl
#include <ncurses/cursslk.h> #include <ncurses/cursslk.h>
class NCURSES_IMPEXP NCursesApplication { class NCURSES_IMPEXP NCursesApplication {
public: public:
typedef struct _slk_link { // This structure is used to maintain typedef struct _slk_link { // This structure is used to maintain
struct _slk_link* prev; // a stack of SLKs struct _slk_link* prev; // a stack of SLKs
skipping to change at line 93 skipping to change at line 93
} }
// Your derived class must implement this method. The return value must // Your derived class must implement this method. The return value must
// be the exit value of your application. // be the exit value of your application.
virtual int run() = 0; virtual int run() = 0;
// The constructor is protected, so you may use it in your derived // The constructor is protected, so you may use it in your derived
// class constructor. The argument tells whether or not you want colors. // class constructor. The argument tells whether or not you want colors.
NCursesApplication(bool wantColors = FALSE); 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)
{
}
public: public:
virtual ~NCursesApplication(); virtual ~NCursesApplication();
// Get a pointer to the current application object // Get a pointer to the current application object
static NCursesApplication* getApplication() { static NCursesApplication* getApplication() {
return theApp; return theApp;
} }
// This method runs the application and returns its exit value // This method runs the application and returns its exit value
int operator()(void); int operator()(void);
skipping to change at line 162 skipping to change at line 176
return b_Colors ? COLOR_PAIR(5) : A_NORMAL; return b_Colors ? COLOR_PAIR(5) : A_NORMAL;
} }
// Attributes to use for the title window // Attributes to use for the title window
virtual chtype screen_titles() const { virtual chtype screen_titles() const {
return b_Colors ? COLOR_PAIR(6) : A_BOLD; return b_Colors ? COLOR_PAIR(6) : A_BOLD;
} }
}; };
#endif // NCURSES_CURSESAPP_H_incl #endif /* NCURSES_CURSESAPP_H_incl */
 End of changes. 4 change blocks. 
2 lines changed or deleted 16 lines changed or added


 cursesf.h   cursesf.h 
// * This makes emacs happy -*-Mode: C++;-*- // * This makes emacs happy -*-Mode: C++;-*-
/************************************************************************** ** /************************************************************************** **
* Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. * * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. *
* * * *
* Permission is hereby granted, free of charge, to any person obtaining a * * Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the * * copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including * * "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, * * without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell * * distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is * * copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: * * furnished to do so, subject to the following conditions: *
* * * *
* The above copyright notice and this permission notice shall be included * * The above copyright notice and this permission notice shall be included *
skipping to change at line 34 skipping to change at line 34
* Except as contained in this notice, the name(s) of the above copyright * * 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 * * holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written * * sale, use or other dealings in this Software without prior written *
* authorization. * * authorization. *
************************************************************************** **/ ************************************************************************** **/
/************************************************************************** ** /************************************************************************** **
* Author: Juergen Pfeifer, 1997 * * Author: Juergen Pfeifer, 1997 *
************************************************************************** **/ ************************************************************************** **/
// $Id: cursesf.h,v 1.19 2004/01/15 00:43:46 tom Exp $ // $Id: cursesf.h,v 1.28 2005/08/13 18:08:24 tom Exp $
#ifndef NCURSES_CURSESF_H_incl #ifndef NCURSES_CURSESF_H_incl
#define NCURSES_CURSESF_H_incl 1 #define NCURSES_CURSESF_H_incl 1
#include <ncurses/cursesp.h> #include <ncurses/cursesp.h>
#ifndef __EXT_QNX
#include <string.h> #include <string.h>
#endif
extern "C" { extern "C" {
# include <ncurses/form.h> # include <ncurses/form.h>
} }
// //
// ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ -
// The abstract base class for buitin and user defined Fieldtypes. // The abstract base class for buitin and user defined Fieldtypes.
// ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ -
// //
class NCURSES_IMPEXP NCursesFormField; // forward declaration class NCURSES_IMPEXP NCursesFormField; // forward declaration
// Class to represent builtin field types as well as C++ written new // Class to represent builtin field types as well as C++ written new
// fieldtypes (see classes UserDefineFieldType... // fieldtypes (see classes UserDefineFieldType...
class NCURSES_IMPEXP NCursesFieldType { class NCURSES_IMPEXP NCursesFieldType
{
friend class NCursesFormField; friend class NCursesFormField;
protected: protected:
FIELDTYPE* fieldtype; FIELDTYPE* fieldtype;
inline void OnError(int err) const THROWS(NCursesFormException) { inline void OnError(int err) const THROWS(NCursesFormException) {
if (err!=E_OK) if (err!=E_OK)
THROW(new NCursesFormException (err)); THROW(new NCursesFormException (err));
} }
NCursesFieldType(FIELDTYPE *f) : fieldtype(f) { NCursesFieldType(FIELDTYPE *f) : fieldtype(f) {
} }
virtual ~NCursesFieldType() {} virtual ~NCursesFieldType() {}
// Set the fields f fieldtype to this one. // Set the fields f fieldtype to this one.
virtual void set(NCursesFormField& f) = 0; virtual void set(NCursesFormField& f) = 0;
public: public:
NCursesFieldType() : fieldtype((FIELDTYPE*)0) { NCursesFieldType()
: fieldtype(STATIC_CAST(FIELDTYPE*)(0))
{
}
NCursesFieldType& operator=(const NCursesFieldType& rhs)
{
if (this != &rhs) {
*this = rhs;
}
return *this;
} }
NCursesFieldType(const NCursesFieldType& rhs)
: fieldtype(rhs.fieldtype)
{
}
}; };
// //
// ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ -
// The class representing a forms field, wrapping the lowlevel FIELD struct // The class representing a forms field, wrapping the lowlevel FIELD struct
// ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ -
// //
class NCURSES_IMPEXP NCursesFormField { class NCURSES_IMPEXP NCursesFormField
{
friend class NCursesForm; friend class NCursesForm;
protected: protected:
FIELD *field; // lowlevel structure FIELD *field; // lowlevel structure
NCursesFieldType* ftype; // Associated field type NCursesFieldType* ftype; // Associated field type
// Error handler // Error handler
inline void OnError (int err) const THROWS(NCursesFormException) { inline void OnError (int err) const THROWS(NCursesFormException) {
if (err != E_OK) if (err != E_OK)
THROW(new NCursesFormException (err)); THROW(new NCursesFormException (err));
} }
public: public:
// Create a 'Null' field. Can be used to delimit a field list // Create a 'Null' field. Can be used to delimit a field list
NCursesFormField() NCursesFormField()
: field((FIELD*)0), ftype((NCursesFieldType*)0) { : field(STATIC_CAST(FIELD*)(0)),
ftype(STATIC_CAST(NCursesFieldType*)(0))
{
} }
// Create a new field // Create a new field
NCursesFormField (int rows, NCursesFormField (int rows,
int cols, int ncols,
int first_row = 0, int first_row = 0,
int first_col = 0, int first_col = 0,
int offscreen_rows = 0, int offscreen_rows = 0,
int additional_buffers = 0) int additional_buffers = 0)
: ftype((NCursesFieldType*)0) { : field(0),
field = ::new_field(rows,cols,first_row,first_col, ftype(STATIC_CAST(NCursesFieldType*)(0))
{
field = ::new_field(rows, ncols, first_row, first_col,
offscreen_rows, additional_buffers); offscreen_rows, additional_buffers);
if (!field) if (!field)
OnError(errno); OnError(errno);
} }
NCursesFormField& operator=(const NCursesFormField& rhs)
{
if (this != &rhs) {
*this = rhs;
}
return *this;
}
NCursesFormField(const NCursesFormField& rhs)
: field(rhs.field), ftype(rhs.ftype)
{
}
virtual ~NCursesFormField (); virtual ~NCursesFormField ();
// Duplicate the field at a new position // Duplicate the field at a new position
inline NCursesFormField* dup(int first_row, int first_col) { inline NCursesFormField* dup(int first_row, int first_col)
{
NCursesFormField* f = new NCursesFormField(); NCursesFormField* f = new NCursesFormField();
if (!f) if (!f)
OnError(E_SYSTEM_ERROR); OnError(E_SYSTEM_ERROR);
else { else {
f->ftype = ftype; f->ftype = ftype;
f->field = ::dup_field(field,first_row,first_col); f->field = ::dup_field(field,first_row,first_col);
if (!f->field) if (!f->field)
OnError(errno); OnError(errno);
} }
return f; return f;
skipping to change at line 152 skipping to change at line 191
} }
return f; return f;
} }
// Get the lowlevel field representation // Get the lowlevel field representation
inline FIELD* get_field() const { inline FIELD* get_field() const {
return field; return field;
} }
// Retrieve info about the field // Retrieve info about the field
inline void info(int& rows, int& cols, inline void info(int& rows, int& ncols,
int& first_row, int& first_col, int& first_row, int& first_col,
int& offscreen_rows, int& additional_buffers) const { int& offscreen_rows, int& additional_buffers) const {
OnError(::field_info(field, &rows, &cols, OnError(::field_info(field, &rows, &ncols,
&first_row, &first_col, &first_row, &first_col,
&offscreen_rows, &additional_buffers)); &offscreen_rows, &additional_buffers));
} }
// Retrieve info about the fields dynamic properties. // Retrieve info about the fields dynamic properties.
inline void dynamic_info(int& dynamic_rows, int& dynamic_cols, inline void dynamic_info(int& dynamic_rows, int& dynamic_cols,
int& max_growth) const { int& max_growth) const {
OnError(::dynamic_field_info(field, &dynamic_rows, &dynamic_cols, OnError(::dynamic_field_info(field, &dynamic_rows, &dynamic_cols,
&max_growth)); &max_growth));
} }
skipping to change at line 198 skipping to change at line 237
// Set the justification for the field // Set the justification for the field
inline void set_justification(int just) { inline void set_justification(int just) {
OnError(::set_field_just(field,just)); OnError(::set_field_just(field,just));
} }
// Retrieve the fields justification // Retrieve the fields justification
inline int justification() const { inline int justification() const {
return ::field_just(field); return ::field_just(field);
} }
// Set the foreground attribute for the field // Set the foreground attribute for the field
inline void set_foreground(chtype fore) { inline void set_foreground(chtype foreground) {
OnError(::set_field_fore(field,fore)); OnError(::set_field_fore(field,foreground));
} }
// Retrieve the fields foreground attribute // Retrieve the fields foreground attribute
inline chtype fore() const { inline chtype fore() const {
return ::field_fore(field); return ::field_fore(field);
} }
// Set the background attribute for the field // Set the background attribute for the field
inline void set_background(chtype back) { inline void set_background(chtype background) {
OnError(::set_field_back(field,back)); OnError(::set_field_back(field,background));
} }
// Retrieve the fields background attribute // Retrieve the fields background attribute
inline chtype back() const { inline chtype back() const {
return ::field_back(field); return ::field_back(field);
} }
// Set the padding character for the field // Set the padding character for the field
inline void set_pad_character(int pad) { inline void set_pad_character(int padding) {
OnError(::set_field_pad(field,pad)); OnError(::set_field_pad(field, padding));
} }
// Retrieve the fields padding character // Retrieve the fields padding character
inline int pad() const { inline int pad() const {
return ::field_pad(field); return ::field_pad(field);
} }
// Switch on the fields options // Switch on the fields options
inline void options_on (Field_Options options) { inline void options_on (Field_Options opts) {
OnError (::field_opts_on (field, options)); OnError (::field_opts_on (field, opts));
} }
// Switch off the fields options // Switch off the fields options
inline void options_off (Field_Options options) { inline void options_off (Field_Options opts) {
OnError (::field_opts_off (field, options)); OnError (::field_opts_off (field, opts));
} }
// Retrieve the fields options // Retrieve the fields options
inline Field_Options options () const { inline Field_Options options () const {
return ::field_opts (field); return ::field_opts (field);
} }
// Set the fields options // Set the fields options
inline void set_options (Field_Options options) { inline void set_options (Field_Options opts) {
OnError (::set_field_opts (field, options)); OnError (::set_field_opts (field, opts));
} }
// Mark the field as changed // Mark the field as changed
inline void set_changed(bool changeFlag = TRUE) { inline void set_changed(bool changeFlag = TRUE) {
OnError(::set_field_status(field,changeFlag)); OnError(::set_field_status(field,changeFlag));
} }
// Test whether or not the field is marked as changed // Test whether or not the field is marked as changed
inline bool changed() const { inline bool changed() const {
return ::field_status(field); return ::field_status(field);
skipping to change at line 286 skipping to change at line 325
f.set(*this); // A good friend may do that... f.set(*this); // A good friend may do that...
} }
// Retrieve the validation type of the field. // Retrieve the validation type of the field.
inline NCursesFieldType* fieldtype() const { inline NCursesFieldType* fieldtype() const {
return ftype; return ftype;
} }
}; };
// This are the built-in hook functions in this C++ binding. In C++ we us
e
// virtual member functions (see below On_..._Init and On_..._Termination
)
// to provide this functionality in an object oriented manner.
extern "C" {
void _nc_xx_frm_init(FORM *);
void _nc_xx_frm_term(FORM *);
void _nc_xx_fld_init(FORM *);
void _nc_xx_fld_term(FORM *);
}
// //
// ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ -
// The class representing a form, wrapping the lowlevel FORM struct // The class representing a form, wrapping the lowlevel FORM struct
// ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ -
// //
class NCURSES_IMPEXP NCursesForm : public NCursesPanel { class NCURSES_IMPEXP NCursesForm : public NCursesPanel
{
protected: protected:
FORM* form; // the lowlevel structure FORM* form; // the lowlevel structure
private: private:
NCursesWindow* sub; // the subwindow object NCursesWindow* sub; // the subwindow object
bool b_sub_owner; // is this our own subwindow? bool b_sub_owner; // is this our own subwindow?
bool b_framed; // has the form a border? bool b_framed; // has the form a border?
bool b_autoDelete; // Delete fields when deleting form? bool b_autoDelete; // Delete fields when deleting form?
NCursesFormField** my_fields; // The array of fields for this form NCursesFormField** my_fields; // The array of fields for this form
// This structure is used for the form's user data field to link the // This structure is used for the form's user data field to link the
// FORM* to the C++ object and to provide extra space for a user pointer. // FORM* to the C++ object and to provide extra space for a user pointer.
typedef struct { typedef struct {
void* m_user; // the pointer for the user's data void* m_user; // the pointer for the user's data
const NCursesForm* m_back; // backward pointer to C++ object const NCursesForm* m_back; // backward pointer to C++ object
const FORM* m_owner; const FORM* m_owner;
} UserHook; } UserHook;
// Get the backward pointer to the C++ object from a FORM // Get the backward pointer to the C++ object from a FORM
static inline NCursesForm* getHook(const FORM *f) { static inline NCursesForm* getHook(const FORM *f) {
UserHook* hook = (UserHook*)::form_userptr(f); UserHook* hook = reinterpret_cast<UserHook*>(::form_userptr(f));
assert(hook != 0 && hook->m_owner==f); assert(hook != 0 && hook->m_owner==f);
return (NCursesForm*)(hook->m_back); return const_cast<NCursesForm*>(hook->m_back);
} }
// This are the built-in hook functions in this C++ binding. In C++ we us friend void _nc_xx_frm_init(FORM *);
e friend void _nc_xx_frm_term(FORM *);
// virtual member functions (see below On_..._Init and On_..._Termination friend void _nc_xx_fld_init(FORM *);
) friend void _nc_xx_fld_term(FORM *);
// to provide this functionality in an object oriented manner.
static void frm_init(FORM *);
static void frm_term(FORM *);
static void fld_init(FORM *);
static void fld_term(FORM *);
// Calculate FIELD* array for the menu // Calculate FIELD* array for the menu
FIELD** mapFields(NCursesFormField* nfields[]); FIELD** mapFields(NCursesFormField* nfields[]);
protected: protected:
// internal routines // internal routines
inline void set_user(void *user) { inline void set_user(void *user) {
UserHook* uptr = (UserHook*)::form_userptr (form); UserHook* uptr = reinterpret_cast<UserHook*>(::form_userptr (form));
assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==form); assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==form);
uptr->m_user = user; uptr->m_user = user;
} }
inline void *get_user() { inline void *get_user() {
UserHook* uptr = (UserHook*)::form_userptr (form); UserHook* uptr = reinterpret_cast<UserHook*>(::form_userptr (form));
assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==form); assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==form);
return uptr->m_user; return uptr->m_user;
} }
void InitForm (NCursesFormField* Fields[], void InitForm (NCursesFormField* Fields[],
bool with_frame, bool with_frame,
bool autoDeleteFields); bool autoDeleteFields);
inline void OnError (int err) const THROWS(NCursesFormException) { inline void OnError (int err) const THROWS(NCursesFormException) {
if (err != E_OK) if (err != E_OK)
THROW(new NCursesFormException (err)); THROW(new NCursesFormException (err));
} }
// this wraps the form_driver call. // this wraps the form_driver call.
virtual int driver (int c) ; virtual int driver (int c) ;
// 'Internal' constructor, builds an object without association to a // 'Internal' constructor, builds an object without association to a
// field array. // field array.
NCursesForm( int lines, NCursesForm( int nlines,
int cols, int ncols,
int begin_y = 0, int begin_y = 0,
int begin_x = 0) int begin_x = 0)
: NCursesPanel(lines,cols,begin_y,begin_x), : NCursesPanel(nlines, ncols, begin_y, begin_x),
form ((FORM*)0) { form (STATIC_CAST(FORM*)(0)),
sub(0),
b_sub_owner(0),
b_framed(0),
b_autoDelete(0),
my_fields(0)
{
} }
public: public:
// Create form for the default panel. // Create form for the default panel.
NCursesForm (NCursesFormField* Fields[], NCursesForm (NCursesFormField* Fields[],
bool with_frame=FALSE, // reserve space for a frame? bool with_frame=FALSE, // reserve space for a frame?
bool autoDelete_Fields=FALSE) // do automatic cleanup? bool autoDelete_Fields=FALSE) // do automatic cleanup?
: NCursesPanel() { : NCursesPanel(),
form(0),
sub(0),
b_sub_owner(0),
b_framed(0),
b_autoDelete(0),
my_fields(0)
{
InitForm(Fields, with_frame, autoDelete_Fields); InitForm(Fields, with_frame, autoDelete_Fields);
} }
// Create a form in a panel with the given position and size. // Create a form in a panel with the given position and size.
NCursesForm (NCursesFormField* Fields[], NCursesForm (NCursesFormField* Fields[],
int lines, int nlines,
int cols, int ncols,
int begin_y, int begin_y,
int begin_x, int begin_x,
bool with_frame=FALSE, // reserve space for a frame? bool with_frame=FALSE, // reserve space for a frame?
bool autoDelete_Fields=FALSE) // do automatic cleanup? bool autoDelete_Fields=FALSE) // do automatic cleanup?
: NCursesPanel(lines, cols, begin_y, begin_x) { : NCursesPanel(nlines, ncols, begin_y, begin_x),
form(0),
sub(0),
b_sub_owner(0),
b_framed(0),
b_autoDelete(0),
my_fields(0)
{
InitForm(Fields, with_frame, autoDelete_Fields); InitForm(Fields, with_frame, autoDelete_Fields);
} }
NCursesForm& operator=(const NCursesForm& rhs)
{
if (this != &rhs) {
*this = rhs;
NCursesPanel::operator=(rhs);
}
return *this;
}
NCursesForm(const NCursesForm& rhs)
: NCursesPanel(rhs),
form(rhs.form),
sub(rhs.sub),
b_sub_owner(rhs.b_sub_owner),
b_framed(rhs.b_framed),
b_autoDelete(rhs.b_autoDelete),
my_fields(rhs.my_fields)
{
}
virtual ~NCursesForm(); virtual ~NCursesForm();
// Set the default attributes for the form // Set the default attributes for the form
virtual void setDefaultAttributes(); virtual void setDefaultAttributes();
// Retrieve current field of the form. // Retrieve current field of the form.
inline NCursesFormField* current_field() const { inline NCursesFormField* current_field() const {
return my_fields[::field_index(::current_field(form))]; return my_fields[::field_index(::current_field(form))];
} }
skipping to change at line 455 skipping to change at line 542
// This is especially true if the form is unposted. // This is especially true if the form is unposted.
virtual void On_Form_Termination(); virtual void On_Form_Termination();
// Called after the field became the current field // Called after the field became the current field
virtual void On_Field_Init(NCursesFormField& field); virtual void On_Field_Init(NCursesFormField& field);
// Called before this field is left as current field. // Called before this field is left as current field.
virtual void On_Field_Termination(NCursesFormField& field); virtual void On_Field_Termination(NCursesFormField& field);
// Calculate required window size for the form. // Calculate required window size for the form.
void scale(int& rows, int& cols) const { void scale(int& rows, int& ncols) const {
OnError(::scale_form(form,&rows,&cols)); OnError(::scale_form(form,&rows,&ncols));
} }
// Retrieve number of fields in the form. // Retrieve number of fields in the form.
int count() const { int count() const {
return ::field_count(form); return ::field_count(form);
} }
// Make the page the current page of the form. // Make the page the current page of the form.
void set_page(int page) { void set_page(int pageNum) {
OnError(::set_form_page(form,page)); OnError(::set_form_page(form, pageNum));
} }
// Retrieve current page number // Retrieve current page number
int page() const { int page() const {
return ::form_page(form); return ::form_page(form);
} }
// Switch on the forms options // Switch on the forms options
inline void options_on (Form_Options options) { inline void options_on (Form_Options opts) {
OnError (::form_opts_on (form, options)); OnError (::form_opts_on (form, opts));
} }
// Switch off the forms options // Switch off the forms options
inline void options_off (Form_Options options) { inline void options_off (Form_Options opts) {
OnError (::form_opts_off (form, options)); OnError (::form_opts_off (form, opts));
} }
// Retrieve the forms options // Retrieve the forms options
inline Form_Options options () const { inline Form_Options options () const {
return ::form_opts (form); return ::form_opts (form);
} }
// Set the forms options // Set the forms options
inline void set_options (Form_Options options) { inline void set_options (Form_Options opts) {
OnError (::set_form_opts (form, options)); OnError (::set_form_opts (form, opts));
} }
// Are there more data in the current field after the data shown // Are there more data in the current field after the data shown
inline bool data_ahead() const { inline bool data_ahead() const {
return ::data_ahead(form); return ::data_ahead(form);
} }
// Are there more data in the current field before the data shown // Are there more data in the current field before the data shown
inline bool data_behind() const { inline bool data_behind() const {
return ::data_behind(form); return ::data_behind(form);
skipping to change at line 548 skipping to change at line 635
// ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ -
// This is the typical C++ typesafe way to allow to attach // This is the typical C++ typesafe way to allow to attach
// user data to a field of a form. Its assumed that the user // user data to a field of a form. Its assumed that the user
// data belongs to some class T. Use T as template argument // data belongs to some class T. Use T as template argument
// to create a UserField. // to create a UserField.
// ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ -
template<class T> class NCURSES_IMPEXP NCursesUserField : public NCursesFor mField template<class T> class NCURSES_IMPEXP NCursesUserField : public NCursesFor mField
{ {
public: public:
NCursesUserField (int rows, NCursesUserField (int rows,
int cols, int ncols,
int first_row = 0, int first_row = 0,
int first_col = 0, int first_col = 0,
const T* p_UserData = (T*)0, const T* p_UserData = STATIC_CAST(T*)(0),
int offscreen_rows = 0, int offscreen_rows = 0,
int additional_buffers = 0) int additional_buffers = 0)
: NCursesFormField (rows, cols, : NCursesFormField (rows, ncols,
first_row, first_col, first_row, first_col,
offscreen_rows, additional_buffers) { offscreen_rows, additional_buffers) {
if (field) if (field)
OnError(::set_field_userptr(field,(void *)p_UserData)); OnError(::set_field_userptr(field, STATIC_CAST(void *)(p_UserData))) ;
} }
virtual ~NCursesUserField() {}; virtual ~NCursesUserField() {};
inline const T* UserData (void) const { inline const T* UserData (void) const {
return (const T*)::field_userptr (field); return reinterpret_cast<const T*>(::field_userptr (field));
} }
inline virtual void setUserData(const T* p_UserData) { inline virtual void setUserData(const T* p_UserData) {
if (field) if (field)
OnError (::set_field_userptr (field, (void *)p_UserData)); OnError (::set_field_userptr (field, STATIC_CAST(void *)(p_UserData)) );
} }
}; };
// //
// ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ -
// The same mechanism is used to attach user data to a form // The same mechanism is used to attach user data to a form
// ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ -
// //
template<class T> class NCURSES_IMPEXP NCursesUserForm : public NCursesForm template<class T> class NCURSES_IMPEXP NCursesUserForm : public NCursesForm
{ {
protected: protected:
// 'Internal' constructor, builds an object without association to a // 'Internal' constructor, builds an object without association to a
// field array. // field array.
NCursesUserForm( int lines, NCursesUserForm( int nlines,
int cols, int ncols,
int begin_y = 0, int begin_y = 0,
int begin_x = 0, int begin_x = 0,
const T* p_UserData = (T*)0) const T* p_UserData = STATIC_CAST(T*)(0))
: NCursesForm(lines,cols,begin_y,begin_x) { : NCursesForm(nlines,ncols,begin_y,begin_x) {
if (form) if (form)
set_user ((void *)p_UserData); set_user (const_cast<void *>(p_UserData));
} }
public: public:
NCursesUserForm (NCursesFormField Fields[], NCursesUserForm (NCursesFormField Fields[],
const T* p_UserData = (T*)0, const T* p_UserData = STATIC_CAST(T*)(0),
bool with_frame=FALSE, bool with_frame=FALSE,
bool autoDelete_Fields=FALSE) bool autoDelete_Fields=FALSE)
: NCursesForm (Fields, with_frame, autoDelete_Fields) { : NCursesForm (Fields, with_frame, autoDelete_Fields) {
if (form) if (form)
set_user ((void *)p_UserData); set_user (const_cast<void *>(p_UserData));
}; };
NCursesUserForm (NCursesFormField Fields[], NCursesUserForm (NCursesFormField Fields[],
int lines, int nlines,
int cols, int ncols,
int begin_y = 0, int begin_y = 0,
int begin_x = 0, int begin_x = 0,
const T* p_UserData = (T*)0, const T* p_UserData = STATIC_CAST(T*)(0),
bool with_frame=FALSE, bool with_frame=FALSE,
bool autoDelete_Fields=FALSE) bool autoDelete_Fields=FALSE)
: NCursesForm (Fields, lines, cols, begin_y, begin_x, : NCursesForm (Fields, nlines, ncols, begin_y, begin_x,
with_frame, autoDelete_Fields) { with_frame, autoDelete_Fields) {
if (form) if (form)
set_user ((void *)p_UserData); set_user (const_cast<void *>(p_UserData));
}; };
virtual ~NCursesUserForm() { virtual ~NCursesUserForm() {
}; };
inline T* UserData (void) const { inline T* UserData (void) const {
return (T*)get_user (); return reinterpret_cast<T*>(get_user ());
}; };
inline virtual void setUserData (const T* p_UserData) { inline virtual void setUserData (const T* p_UserData) {
if (form) if (form)
set_user ((void *)p_UserData); set_user (const_cast<void *>(p_UserData));
} }
}; };
// //
// ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ -
// Builtin Fieldtypes // Builtin Fieldtypes
// ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ -
// //
class NCURSES_IMPEXP Alpha_Field : public NCursesFieldType { class NCURSES_IMPEXP Alpha_Field : public NCursesFieldType
{
private: private:
int min_field_width; int min_field_width;
void set(NCursesFormField& f) { void set(NCursesFormField& f) {
OnError(::set_field_type(f.get_field(),fieldtype,min_field_width)); OnError(::set_field_type(f.get_field(),fieldtype,min_field_width));
} }
public: public:
Alpha_Field(int width) Alpha_Field(int width)
: NCursesFieldType(TYPE_ALPHA), : NCursesFieldType(TYPE_ALPHA),
min_field_width(width) { min_field_width(width) {
} }
}; };
class NCURSES_IMPEXP Alphanumeric_Field : public NCursesFieldType { class NCURSES_IMPEXP Alphanumeric_Field : public NCursesFieldType
{
private: private:
int min_field_width; int min_field_width;
void set(NCursesFormField& f) { void set(NCursesFormField& f) {
OnError(::set_field_type(f.get_field(),fieldtype,min_field_width)); OnError(::set_field_type(f.get_field(),fieldtype,min_field_width));
} }
public: public:
Alphanumeric_Field(int width) Alphanumeric_Field(int width)
: NCursesFieldType(TYPE_ALNUM), : NCursesFieldType(TYPE_ALNUM),
min_field_width(width) { min_field_width(width) {
} }
}; };
class NCURSES_IMPEXP Integer_Field : public NCursesFieldType { class NCURSES_IMPEXP Integer_Field : public NCursesFieldType
{
private: private:
int precision; int precision;
long lower_limit, upper_limit; long lower_limit, upper_limit;
void set(NCursesFormField& f) { void set(NCursesFormField& f) {
OnError(::set_field_type(f.get_field(),fieldtype, OnError(::set_field_type(f.get_field(),fieldtype,
precision,lower_limit,upper_limit)); precision,lower_limit,upper_limit));
} }
public: public:
Integer_Field(int prec, long low=0L, long high=0L) Integer_Field(int prec, long low=0L, long high=0L)
: NCursesFieldType(TYPE_INTEGER), : NCursesFieldType(TYPE_INTEGER),
precision(prec), lower_limit(low), upper_limit(high) { precision(prec), lower_limit(low), upper_limit(high) {
} }
}; };
class NCURSES_IMPEXP Numeric_Field : public NCursesFieldType { class NCURSES_IMPEXP Numeric_Field : public NCursesFieldType
{
private: private:
int precision; int precision;
double lower_limit, upper_limit; double lower_limit, upper_limit;
void set(NCursesFormField& f) { void set(NCursesFormField& f) {
OnError(::set_field_type(f.get_field(),fieldtype, OnError(::set_field_type(f.get_field(),fieldtype,
precision,lower_limit,upper_limit)); precision,lower_limit,upper_limit));
} }
public: public:
Numeric_Field(int prec, double low=0.0, double high=0.0) Numeric_Field(int prec, double low=0.0, double high=0.0)
: NCursesFieldType(TYPE_NUMERIC), : NCursesFieldType(TYPE_NUMERIC),
precision(prec), lower_limit(low), upper_limit(high) { precision(prec), lower_limit(low), upper_limit(high) {
} }
}; };
class NCURSES_IMPEXP Regular_Expression_Field : public NCursesFieldType { class NCURSES_IMPEXP Regular_Expression_Field : public NCursesFieldType
{
private: private:
char* regex; char* regex;
void set(NCursesFormField& f) { void set(NCursesFormField& f) {
OnError(::set_field_type(f.get_field(),fieldtype,regex)); OnError(::set_field_type(f.get_field(),fieldtype,regex));
} }
void copy_regex(const char *source)
{
regex = new char[1 + ::strlen(source)];
(::strcpy)(regex, source);
}
public: public:
Regular_Expression_Field(const char *expr) Regular_Expression_Field(const char *expr)
: NCursesFieldType(TYPE_REGEXP) { : NCursesFieldType(TYPE_REGEXP),
regex = new char[1 + ::strlen(expr)]; regex(NULL)
(::strcpy)(regex,expr); {
copy_regex(expr);
}
Regular_Expression_Field& operator=(const Regular_Expression_Field& rhs)
{
if (this != &rhs) {
*this = rhs;
copy_regex(rhs.regex);
NCursesFieldType::operator=(rhs);
}
return *this;
}
Regular_Expression_Field(const Regular_Expression_Field& rhs)
: NCursesFieldType(rhs),
regex(NULL)
{
copy_regex(rhs.regex);
} }
~Regular_Expression_Field() { ~Regular_Expression_Field() {
delete[] regex; delete[] regex;
} }
}; };
class NCURSES_IMPEXP Enumeration_Field : public NCursesFieldType { class NCURSES_IMPEXP Enumeration_Field : public NCursesFieldType
{
private: private:
const char** list; const char** list;
int case_sensitive; int case_sensitive;
int non_unique_matches; int non_unique_matches;
void set(NCursesFormField& f) { void set(NCursesFormField& f) {
OnError(::set_field_type(f.get_field(),fieldtype, OnError(::set_field_type(f.get_field(),fieldtype,
list,case_sensitive,non_unique_matches)); list,case_sensitive,non_unique_matches));
} }
public: public:
Enumeration_Field(const char* enums[], Enumeration_Field(const char* enums[],
bool case_sens=FALSE, bool case_sens=FALSE,
bool non_unique=FALSE) bool non_unique=FALSE)
: NCursesFieldType(TYPE_ENUM), : NCursesFieldType(TYPE_ENUM),
list(enums), list(enums),
case_sensitive(case_sens?-1:0), case_sensitive(case_sens ? -1 : 0),
non_unique_matches(non_unique?-1:0) { non_unique_matches(non_unique ? -1 : 0) {
}
Enumeration_Field& operator=(const Enumeration_Field& rhs)
{
if (this != &rhs) {
*this = rhs;
NCursesFieldType::operator=(rhs);
}
return *this;
}
Enumeration_Field(const Enumeration_Field& rhs)
: NCursesFieldType(rhs),
list(rhs.list),
case_sensitive(rhs.case_sensitive),
non_unique_matches(rhs.non_unique_matches)
{
} }
}; };
class NCURSES_IMPEXP IPV4_Address_Field : public NCursesFieldType { class NCURSES_IMPEXP IPV4_Address_Field : public NCursesFieldType
{
private: private:
void set(NCursesFormField& f) { void set(NCursesFormField& f) {
OnError(::set_field_type(f.get_field(),fieldtype)); OnError(::set_field_type(f.get_field(),fieldtype));
} }
public: public:
IPV4_Address_Field() : NCursesFieldType(TYPE_IPV4) { IPV4_Address_Field() : NCursesFieldType(TYPE_IPV4) {
} }
}; };
extern "C" {
bool _nc_xx_fld_fcheck(FIELD *, const void*);
bool _nc_xx_fld_ccheck(int c, const void *);
void* _nc_xx_fld_makearg(va_list*);
}
// //
// ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ -
// Abstract base class for User-Defined Fieldtypes // Abstract base class for User-Defined Fieldtypes
// ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ -
// //
class NCURSES_IMPEXP UserDefinedFieldType : public NCursesFieldType { class NCURSES_IMPEXP UserDefinedFieldType : public NCursesFieldType
{
friend class UDF_Init; // Internal helper to set up statics friend class UDF_Init; // Internal helper to set up statics
private: private:
// For all C++ defined fieldtypes we need only one generic lowlevel // For all C++ defined fieldtypes we need only one generic lowlevel
// FIELDTYPE* element. // FIELDTYPE* element.
static FIELDTYPE* generic_fieldtype; static FIELDTYPE* generic_fieldtype;
protected: protected:
// This are the functions required by the low level libforms functions // This are the functions required by the low level libforms functions
// to construct a fieldtype. // to construct a fieldtype.
static bool fcheck(FIELD *, const void*); friend bool _nc_xx_fld_fcheck(FIELD *, const void*);
static bool ccheck(int c, const void *); friend bool _nc_xx_fld_ccheck(int c, const void *);
static void* makearg(va_list*); friend void* _nc_xx_fld_makearg(va_list*);
void set(NCursesFormField& f) { void set(NCursesFormField& f) {
OnError(::set_field_type(f.get_field(),fieldtype,&f)); OnError(::set_field_type(f.get_field(),fieldtype,&f));
} }
protected: protected:
// Redefine this function to do a field validation. The argument // Redefine this function to do a field validation. The argument
// is a reference to the field you should validate. // is a reference to the field you should validate.
virtual bool field_check(NCursesFormField& f) = 0; virtual bool field_check(NCursesFormField& f) = 0;
// Redefine this function to do a character validation. The argument // Redefine this function to do a character validation. The argument
// is the character to be validated. // is the character to be validated.
virtual bool char_check (int c) = 0; virtual bool char_check (int c) = 0;
public: public:
UserDefinedFieldType() : NCursesFieldType(generic_fieldtype) { UserDefinedFieldType() : NCursesFieldType(generic_fieldtype) {
} }
}; };
extern "C" {
bool _nc_xx_next_choice(FIELD*, const void *);
bool _nc_xx_prev_choice(FIELD*, const void *);
}
// //
// ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ -
// Abstract base class for User-Defined Fieldtypes with Choice functions // Abstract base class for User-Defined Fieldtypes with Choice functions
// ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ -
// //
class NCURSES_IMPEXP UserDefinedFieldType_With_Choice : public UserDefinedF class NCURSES_IMPEXP UserDefinedFieldType_With_Choice : public UserDefinedF
ieldType { ieldType
{
friend class UDF_Init; // Internal helper to set up statics friend class UDF_Init; // Internal helper to set up statics
private: private:
// For all C++ defined fieldtypes with choice functions we need only one // For all C++ defined fieldtypes with choice functions we need only one
// generic lowlevel FIELDTYPE* element. // generic lowlevel FIELDTYPE* element.
static FIELDTYPE* generic_fieldtype_with_choice; static FIELDTYPE* generic_fieldtype_with_choice;
// This are the functions required by the low level libforms functions // This are the functions required by the low level libforms functions
// to construct a fieldtype with choice functions. // to construct a fieldtype with choice functions.
static bool next_choice(FIELD*, const void *); friend bool _nc_xx_next_choice(FIELD*, const void *);
static bool prev_choice(FIELD*, const void *); friend bool _nc_xx_prev_choice(FIELD*, const void *);
protected: protected:
// Redefine this function to do the retrieval of the next choice value. // Redefine this function to do the retrieval of the next choice value.
// The argument is a reference to the field tobe examined. // The argument is a reference to the field tobe examined.
virtual bool next (NCursesFormField& f) = 0; virtual bool next (NCursesFormField& f) = 0;
// Redefine this function to do the retrieval of the previous choice valu e. // Redefine this function to do the retrieval of the previous choice valu e.
// The argument is a reference to the field tobe examined. // The argument is a reference to the field tobe examined.
virtual bool previous(NCursesFormField& f) = 0; virtual bool previous(NCursesFormField& f) = 0;
public: public:
UserDefinedFieldType_With_Choice() { UserDefinedFieldType_With_Choice() {
fieldtype = generic_fieldtype_with_choice; fieldtype = generic_fieldtype_with_choice;
} }
}; };
#endif // NCURSES_CURSESF_H_incl #endif /* NCURSES_CURSESF_H_incl */
 End of changes. 79 change blocks. 
102 lines changed or deleted 252 lines changed or added


 cursesm.h   cursesm.h 
// * This makes emacs happy -*-Mode: C++;-*- // * This makes emacs happy -*-Mode: C++;-*-
/************************************************************************** ** /************************************************************************** **
* Copyright (c) 1998-2002,2003 Free Software Foundation, Inc. * * Copyright (c) 1998-2003,2005 Free Software Foundation, Inc. *
* * * *
* Permission is hereby granted, free of charge, to any person obtaining a * * Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the * * copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including * * "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, * * without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell * * distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is * * copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: * * furnished to do so, subject to the following conditions: *
* * * *
* The above copyright notice and this permission notice shall be included * * The above copyright notice and this permission notice shall be included *
skipping to change at line 34 skipping to change at line 34
* Except as contained in this notice, the name(s) of the above copyright * * 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 * * holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written * * sale, use or other dealings in this Software without prior written *
* authorization. * * authorization. *
************************************************************************** **/ ************************************************************************** **/
/************************************************************************** ** /************************************************************************** **
* Author: Juergen Pfeifer, 1997 * * Author: Juergen Pfeifer, 1997 *
************************************************************************** **/ ************************************************************************** **/
// $Id: cursesm.h,v 1.17 2003/10/25 15:04:46 tom Exp $ // $Id: cursesm.h,v 1.25 2005/08/13 18:10:36 tom Exp $
#ifndef NCURSES_CURSESM_H_incl #ifndef NCURSES_CURSESM_H_incl
#define NCURSES_CURSESM_H_incl 1 #define NCURSES_CURSESM_H_incl 1
#include <ncurses/cursesp.h> #include <ncurses/cursesp.h>
extern "C" { extern "C" {
# include <ncurses/menu.h> # include <ncurses/menu.h>
} }
// //
// ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ -
// This wraps the ITEM type of <ncurses/menu.h> // This wraps the ITEM type of <ncurses/menu.h>
// ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ -
// //
class NCURSES_IMPEXP NCursesMenuItem { class NCURSES_IMPEXP NCursesMenuItem
{
friend class NCursesMenu; friend class NCursesMenu;
protected: protected:
ITEM *item; ITEM *item;
inline void OnError (int err) const THROWS(NCursesMenuException) { inline void OnError (int err) const THROWS(NCursesMenuException) {
if (err != E_OK) if (err != E_OK)
THROW(new NCursesMenuException (err)); THROW(new NCursesMenuException (err));
} }
public: public:
NCursesMenuItem (const char* p_name = NULL, NCursesMenuItem (const char* p_name = NULL,
const char* p_descript = NULL ) { const char* p_descript = NULL)
item = p_name ? ::new_item (p_name, p_descript) : (ITEM*)0; : item(0)
{
item = p_name ? ::new_item (p_name, p_descript) : STATIC_CAST(ITEM*)(0)
;
if (p_name && !item) if (p_name && !item)
OnError (E_SYSTEM_ERROR); OnError (E_SYSTEM_ERROR);
} }
// Create an item. If you pass both parameters as NULL, a delimiting // Create an item. If you pass both parameters as NULL, a delimiting
// item is constructed which can be used to terminate a list of // item is constructed which can be used to terminate a list of
// NCursesMenu objects. // NCursesMenu objects.
NCursesMenuItem& operator=(const NCursesMenuItem& rhs)
{
if (this != &rhs) {
*this = rhs;
}
return *this;
}
NCursesMenuItem(const NCursesMenuItem& rhs)
: item(0)
{
}
virtual ~NCursesMenuItem (); virtual ~NCursesMenuItem ();
// Release the items memory // Release the items memory
inline const char* name () const { inline const char* name () const {
return ::item_name (item); return ::item_name (item);
} }
// Name of the item // Name of the item
inline const char* description () const { inline const char* description () const {
return ::item_description (item); return ::item_description (item);
} }
// Description of the item // Description of the item
inline int (index) (void) const { inline int (index) (void) const {
return ::item_index (item); return ::item_index (item);
} }
// Index of the item in an item array (or -1) // Index of the item in an item array (or -1)
inline void options_on (Item_Options options) { inline void options_on (Item_Options opts) {
OnError (::item_opts_on (item, options)); OnError (::item_opts_on (item, opts));
} }
// Switch on the items options // Switch on the items options
inline void options_off (Item_Options options) { inline void options_off (Item_Options opts) {
OnError (::item_opts_off (item, options)); OnError (::item_opts_off (item, opts));
} }
// Switch off the item's option // Switch off the item's option
inline Item_Options options () const { inline Item_Options options () const {
return ::item_opts (item); return ::item_opts (item);
} }
// Retrieve the items options // Retrieve the items options
inline void set_options (Item_Options options) { inline void set_options (Item_Options opts) {
OnError (::set_item_opts (item, options)); OnError (::set_item_opts (item, opts));
} }
// Set the items options // Set the items options
inline void set_value (bool f) { inline void set_value (bool f) {
OnError (::set_item_value (item,f)); OnError (::set_item_value (item,f));
} }
// Set/Reset the items selection state // Set/Reset the items selection state
inline bool value () const { inline bool value () const {
return ::item_value (item); return ::item_value (item);
skipping to change at line 138 skipping to change at line 154
// If an action returns true, the menu will be exited. The default action // If an action returns true, the menu will be exited. The default action
// is to do nothing. // is to do nothing.
}; };
// Prototype for an items callback function. // Prototype for an items callback function.
typedef bool ITEMCALLBACK(NCursesMenuItem&); typedef bool ITEMCALLBACK(NCursesMenuItem&);
// If you don't like to create a child class for individual items to // 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 // overload action(), you may use this class and provide a callback
// function pointer for items. // function pointer for items.
class NCURSES_IMPEXP NCursesMenuCallbackItem : public NCursesMenuItem { class NCURSES_IMPEXP NCursesMenuCallbackItem : public NCursesMenuItem
{
private: private:
ITEMCALLBACK* p_fct; ITEMCALLBACK* p_fct;
public: public:
NCursesMenuCallbackItem(ITEMCALLBACK* fct = NULL, NCursesMenuCallbackItem(ITEMCALLBACK* fct = NULL,
const char* p_name = NULL, const char* p_name = NULL,
const char* p_descript = NULL ) const char* p_descript = NULL )
: NCursesMenuItem (p_name, p_descript), : NCursesMenuItem (p_name, p_descript),
p_fct (fct) { p_fct (fct) {
} }
NCursesMenuCallbackItem& operator=(const NCursesMenuCallbackItem& rhs)
{
if (this != &rhs) {
*this = rhs;
}
return *this;
}
NCursesMenuCallbackItem(const NCursesMenuCallbackItem& rhs)
: NCursesMenuItem(rhs),
p_fct(0)
{
}
virtual ~NCursesMenuCallbackItem(); virtual ~NCursesMenuCallbackItem();
bool action(); bool action();
}; };
// This are the built-in hook functions in this C++ binding. In C++ we us
e
// virtual member functions (see below On_..._Init and On_..._Termination
)
// to provide this functionality in an object oriented manner.
extern "C" {
void _nc_xx_mnu_init(MENU *);
void _nc_xx_mnu_term(MENU *);
void _nc_xx_itm_init(MENU *);
void _nc_xx_itm_term(MENU *);
}
// //
// ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ -
// This wraps the MENU type of <ncurses/menu.h> // This wraps the MENU type of <ncurses/menu.h>
// ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ -
// //
class NCURSES_IMPEXP NCursesMenu : public NCursesPanel { class NCURSES_IMPEXP NCursesMenu : public NCursesPanel
{
protected: protected:
MENU *menu; MENU *menu;
private: private:
NCursesWindow* sub; // the subwindow object NCursesWindow* sub; // the subwindow object
bool b_sub_owner; // is this our own subwindow? bool b_sub_owner; // is this our own subwindow?
bool b_framed; // has the menu a border? bool b_framed; // has the menu a border?
bool b_autoDelete; // Delete items when deleting menu? bool b_autoDelete; // Delete items when deleting menu?
NCursesMenuItem** my_items; // The array of items for this menu NCursesMenuItem** my_items; // The array of items for this menu
skipping to change at line 181 skipping to change at line 224
// This structure is used for the menu's user data field to link the // 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. // MENU* to the C++ object and to provide extra space for a user pointer.
typedef struct { typedef struct {
void* m_user; // the pointer for the user's data void* m_user; // the pointer for the user's data
const NCursesMenu* m_back; // backward pointer to C++ object const NCursesMenu* m_back; // backward pointer to C++ object
const MENU* m_owner; const MENU* m_owner;
} UserHook; } UserHook;
// Get the backward pointer to the C++ object from a MENU // Get the backward pointer to the C++ object from a MENU
static inline NCursesMenu* getHook(const MENU *m) { static inline NCursesMenu* getHook(const MENU *m) {
UserHook* hook = (UserHook*)::menu_userptr(m); UserHook* hook = STATIC_CAST(UserHook*)(::menu_userptr(m));
assert(hook != 0 && hook->m_owner==m); assert(hook != 0 && hook->m_owner==m);
return (NCursesMenu*)(hook->m_back); return const_cast<NCursesMenu*>(hook->m_back);
} }
// This are the built-in hook functions in this C++ binding. In C++ we us friend void _nc_xx_mnu_init(MENU *);
e friend void _nc_xx_mnu_term(MENU *);
// virtual member functions (see below On_..._Init and On_..._Termination friend void _nc_xx_itm_init(MENU *);
) friend void _nc_xx_itm_term(MENU *);
// 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 // Calculate ITEM* array for the menu
ITEM** mapItems(NCursesMenuItem* nitems[]); ITEM** mapItems(NCursesMenuItem* nitems[]);
protected: protected:
// internal routines // internal routines
inline void set_user(void *user) { inline void set_user(void *user) {
UserHook* uptr = (UserHook*)::menu_userptr (menu); UserHook* uptr = STATIC_CAST(UserHook*)(::menu_userptr (menu));
assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==menu); assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==menu);
uptr->m_user = user; uptr->m_user = user;
} }
inline void *get_user() { inline void *get_user() {
UserHook* uptr = (UserHook*)::menu_userptr (menu); UserHook* uptr = STATIC_CAST(UserHook*)(::menu_userptr (menu));
assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==menu); assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==menu);
return uptr->m_user; return uptr->m_user;
} }
void InitMenu (NCursesMenuItem* menu[], void InitMenu (NCursesMenuItem* menu[],
bool with_frame, bool with_frame,
bool autoDeleteItems); bool autoDeleteItems);
inline void OnError (int err) const THROWS(NCursesMenuException) { inline void OnError (int err) const THROWS(NCursesMenuException) {
if (err != E_OK) if (err != E_OK)
THROW(new NCursesMenuException (this, err)); THROW(new NCursesMenuException (this, err));
} }
// this wraps the menu_driver call. // this wraps the menu_driver call.
virtual int driver (int c) ; virtual int driver (int c) ;
// 'Internal' constructor to create a menu without association to // 'Internal' constructor to create a menu without association to
// an array of items. // an array of items.
NCursesMenu( int lines, NCursesMenu( int nlines,
int cols, int ncols,
int begin_y = 0, int begin_y = 0,
int begin_x = 0) int begin_x = 0)
: NCursesPanel(lines,cols,begin_y,begin_x), : NCursesPanel(nlines,ncols,begin_y,begin_x),
menu ((MENU*)0) { menu (STATIC_CAST(MENU*)(0)),
sub(0),
b_sub_owner(0),
b_framed(0),
b_autoDelete(0),
my_items(0)
{
} }
public: public:
// Make a full window size menu // Make a full window size menu
NCursesMenu (NCursesMenuItem* Items[], NCursesMenu (NCursesMenuItem* Items[],
bool with_frame=FALSE, // Reserve space for a frame? bool with_frame=FALSE, // Reserve space for a frame?
bool autoDelete_Items=FALSE) // Autocleanup of Items? bool autoDelete_Items=FALSE) // Autocleanup of Items?
: NCursesPanel() { : NCursesPanel(),
menu(0),
sub(0),
b_sub_owner(0),
b_framed(0),
b_autoDelete(0),
my_items(0)
{
InitMenu(Items, with_frame, autoDelete_Items); InitMenu(Items, with_frame, autoDelete_Items);
} }
// Make a menu with a window of this size. // Make a menu with a window of this size.
NCursesMenu (NCursesMenuItem* Items[], NCursesMenu (NCursesMenuItem* Items[],
int lines, int nlines,
int cols, int ncols,
int begin_y = 0, int begin_y = 0,
int begin_x = 0, int begin_x = 0,
bool with_frame=FALSE, // Reserve space for a frame? bool with_frame=FALSE, // Reserve space for a frame?
bool autoDelete_Items=FALSE) // Autocleanup of Items? bool autoDelete_Items=FALSE) // Autocleanup of Items?
: NCursesPanel(lines, cols, begin_y, begin_x) { : NCursesPanel(nlines, ncols, begin_y, begin_x),
menu(0),
sub(0),
b_sub_owner(0),
b_framed(0),
b_autoDelete(0),
my_items(0)
{
InitMenu(Items, with_frame, autoDelete_Items); InitMenu(Items, with_frame, autoDelete_Items);
} }
NCursesMenu& operator=(const NCursesMenu& rhs)
{
if (this != &rhs) {
*this = rhs;
NCursesPanel::operator=(rhs);
}
return *this;
}
NCursesMenu(const NCursesMenu& rhs)
: NCursesPanel(rhs),
menu(rhs.menu),
sub(rhs.sub),
b_sub_owner(rhs.b_sub_owner),
b_framed(rhs.b_framed),
b_autoDelete(rhs.b_autoDelete),
my_items(rhs.my_items)
{
}
virtual ~NCursesMenu (); virtual ~NCursesMenu ();
// Retrieve the menus subwindow // Retrieve the menus subwindow
inline NCursesWindow& subWindow() const { inline NCursesWindow& subWindow() const {
assert(sub!=NULL); assert(sub!=NULL);
return *sub; return *sub;
} }
// Set the menus subwindow // Set the menus subwindow
void setSubWindow(NCursesWindow& sub); void setSubWindow(NCursesWindow& sub);
skipping to change at line 291 skipping to change at line 371
inline void scale (int& mrows, int& mcols) const { inline void scale (int& mrows, int& mcols) const {
OnError (::scale_menu (menu, &mrows, &mcols)); OnError (::scale_menu (menu, &mrows, &mcols));
} }
// Set the format of this menu // Set the format of this menu
inline void set_format(int mrows, int mcols) { inline void set_format(int mrows, int mcols) {
OnError (::set_menu_format(menu, mrows, mcols)); OnError (::set_menu_format(menu, mrows, mcols));
} }
// Get the format of this menu // Get the format of this menu
inline void menu_format(int& rows,int& cols) { inline void menu_format(int& rows,int& ncols) {
::menu_format(menu,&rows,&cols); ::menu_format(menu,&rows,&ncols);
} }
// Items of the menu // Items of the menu
inline NCursesMenuItem* items() const { inline NCursesMenuItem* items() const {
return *my_items; return *my_items;
} }
// Get the number of items in this menu // Get the number of items in this menu
inline int count() const { inline int count() const {
return ::item_count(menu); return ::item_count(menu);
skipping to change at line 316 skipping to change at line 396
inline NCursesMenuItem* current_item() const { inline NCursesMenuItem* current_item() const {
return my_items[::item_index(::current_item(menu))]; return my_items[::item_index(::current_item(menu))];
} }
// Get the marker string // Get the marker string
inline const char* mark() const { inline const char* mark() const {
return ::menu_mark(menu); return ::menu_mark(menu);
} }
// Set the marker string // Set the marker string
inline void set_mark(const char *mark) { inline void set_mark(const char *marker) {
OnError (::set_menu_mark (menu, mark)); OnError (::set_menu_mark (menu, marker));
} }
// Get the name of the request code c // Get the name of the request code c
inline static const char* request_name(int c) { inline static const char* request_name(int c) {
return ::menu_request_name(c); return ::menu_request_name(c);
} }
// Get the current pattern // Get the current pattern
inline char* pattern() const { inline char* pattern() const {
return ::menu_pattern(menu); return ::menu_pattern(menu);
skipping to change at line 521 skipping to change at line 601
// user data to an item of a menu. Its assumed that the user // user data to an item of a menu. Its assumed that the user
// data belongs to some class T. Use T as template argument // data belongs to some class T. Use T as template argument
// to create a UserItem. // to create a UserItem.
// ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ -
// //
template<class T> class NCURSES_IMPEXP NCursesUserItem : public NCursesMenu Item template<class T> class NCURSES_IMPEXP NCursesUserItem : public NCursesMenu Item
{ {
public: public:
NCursesUserItem (const char* p_name, NCursesUserItem (const char* p_name,
const char* p_descript = NULL, const char* p_descript = NULL,
const T* p_UserData = (T*)0) const T* p_UserData = STATIC_CAST(T*)(0))
: NCursesMenuItem (p_name, p_descript) { : NCursesMenuItem (p_name, p_descript) {
if (item) if (item)
OnError (::set_item_userptr (item, (void *)p_UserData)); OnError (::set_item_userptr (item, const_cast<void *>(reinterpret_ca
}; st<const void*>(p_UserData))));
}
virtual ~NCursesUserItem() {}; virtual ~NCursesUserItem() {}
inline const T* UserData (void) const { inline const T* UserData (void) const {
return (const T*)::item_userptr (item); return reinterpret_cast<const T*>(::item_userptr (item));
}; };
inline virtual void setUserData(const T* p_UserData) { inline virtual void setUserData(const T* p_UserData) {
if (item) if (item)
OnError (::set_item_userptr (item, (void *)p_UserData)); OnError (::set_item_userptr (item, const_cast<void *>(reinterpret_cas t<const void *>(p_UserData))));
} }
}; };
// //
// ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ -
// The same mechanism is used to attach user data to a menu // 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_IMPEXP NCursesUserMenu : public NCursesMenu
{ {
protected: protected:
NCursesUserMenu( int lines, NCursesUserMenu( int nlines,
int cols, int ncols,
int begin_y = 0, int begin_y = 0,
int begin_x = 0, int begin_x = 0,
const T* p_UserData = (T*)0) const T* p_UserData = STATIC_CAST(T*)(0))
: NCursesMenu(lines,cols,begin_y,begin_x) { : NCursesMenu(nlines,ncols,begin_y,begin_x) {
if (menu) if (menu)
set_user ((void *)p_UserData); set_user (const_cast<void *>(p_UserData));
} }
public: public:
NCursesUserMenu (NCursesMenuItem Items[], NCursesUserMenu (NCursesMenuItem Items[],
const T* p_UserData = (T*)0, const T* p_UserData = STATIC_CAST(T*)(0),
bool with_frame=FALSE, bool with_frame=FALSE,
bool autoDelete_Items=FALSE) bool autoDelete_Items=FALSE)
: NCursesMenu (Items, with_frame, autoDelete_Items) { : NCursesMenu (Items, with_frame, autoDelete_Items) {
if (menu) if (menu)
set_user ((void *)p_UserData); set_user (const_cast<void *>(p_UserData));
}; };
NCursesUserMenu (NCursesMenuItem Items[], NCursesUserMenu (NCursesMenuItem Items[],
int lines, int nlines,
int cols, int ncols,
int begin_y = 0, int begin_y = 0,
int begin_x = 0, int begin_x = 0,
const T* p_UserData = (T*)0, const T* p_UserData = STATIC_CAST(T*)(0),
bool with_frame=FALSE) bool with_frame=FALSE)
: NCursesMenu (Items, lines, cols, begin_y, begin_x, with_frame) { : NCursesMenu (Items, nlines, ncols, begin_y, begin_x, with_frame) {
if (menu) if (menu)
set_user ((void *)p_UserData); set_user (const_cast<void *>(p_UserData));
}; };
virtual ~NCursesUserMenu() { virtual ~NCursesUserMenu() {
}; };
inline T* UserData (void) const { inline T* UserData (void) const {
return (T*)get_user (); return reinterpret_cast<T*>(get_user ());
}; };
inline virtual void setUserData (const T* p_UserData) { inline virtual void setUserData (const T* p_UserData) {
if (menu) if (menu)
set_user ((void *)p_UserData); set_user (const_cast<void *>(p_UserData));
} }
}; };
#endif // NCURSES_CURSESM_H_incl #endif /* NCURSES_CURSESM_H_incl */
 End of changes. 42 change blocks. 
58 lines changed or deleted 140 lines changed or added


 cursesp.h   cursesp.h 
// * This makes emacs happy -*-Mode: C++;-*- // * This makes emacs happy -*-Mode: C++;-*-
/************************************************************************** ** /************************************************************************** **
* Copyright (c) 1998-2002,2003 Free Software Foundation, Inc. * * Copyright (c) 1998-2003,2005 Free Software Foundation, Inc. *
* * * *
* Permission is hereby granted, free of charge, to any person obtaining a * * Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the * * copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including * * "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, * * without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell * * distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is * * copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: * * furnished to do so, subject to the following conditions: *
* * * *
* The above copyright notice and this permission notice shall be included * * The above copyright notice and this permission notice shall be included *
skipping to change at line 37 skipping to change at line 37
* authorization. * * authorization. *
************************************************************************** **/ ************************************************************************** **/
/************************************************************************** ** /************************************************************************** **
* Author: Juergen Pfeifer, 1997 * * Author: Juergen Pfeifer, 1997 *
************************************************************************** **/ ************************************************************************** **/
#ifndef NCURSES_CURSESP_H_incl #ifndef NCURSES_CURSESP_H_incl
#define NCURSES_CURSESP_H_incl 1 #define NCURSES_CURSESP_H_incl 1
// $Id: cursesp.h,v 1.18 2003/10/25 15:04:46 tom Exp $ // $Id: cursesp.h,v 1.26 2005/08/13 18:09:21 tom Exp $
#include <ncurses/cursesw.h> #include <ncurses/cursesw.h>
extern "C" { extern "C" {
# include <ncurses/panel.h> # include <ncurses/panel.h>
} }
class NCURSES_IMPEXP NCursesPanel : public NCursesWindow { class NCURSES_IMPEXP NCursesPanel
: public NCursesWindow
{
protected: protected:
PANEL *p; PANEL *p;
static NCursesPanel *dummy; static NCursesPanel *dummy;
private: private:
// This structure is used for the panel's user data field to link the // This structure is used for the panel's user data field to link the
// PANEL* to the C++ object and to provide extra space for a user pointer . // PANEL* to the C++ object and to provide extra space for a user pointer .
typedef struct { typedef struct {
void* m_user; // the pointer for the user's data void* m_user; // the pointer for the user's data
const NCursesPanel* m_back; // backward pointer to C++ object const NCursesPanel* m_back; // backward pointer to C++ object
const PANEL* m_owner; // the panel itself const PANEL* m_owner; // the panel itself
} UserHook; } UserHook;
inline UserHook *UserPointer()
{
UserHook* uptr = reinterpret_cast<UserHook*>(
const_cast<void *>(::panel_userptr (p)));
return uptr;
}
void init(); // Initialize the panel object void init(); // Initialize the panel object
protected: protected:
void set_user(void *user) { void set_user(void *user)
UserHook* uptr = (UserHook*)::panel_userptr (p); {
UserHook* uptr = UserPointer();
assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==p); assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==p);
uptr->m_user = user; uptr->m_user = user;
} }
// Set the user pointer of the panel. // Set the user pointer of the panel.
void *get_user() { void *get_user()
UserHook* uptr = (UserHook*)::panel_userptr (p); {
UserHook* uptr = UserPointer();
assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==p); assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==p);
return uptr->m_user; return uptr->m_user;
} }
void OnError (int err) const THROWS((NCursesPanelException)) { void OnError (int err) const THROWS((NCursesPanelException))
{
if (err==ERR) if (err==ERR)
THROW(new NCursesPanelException (this, err)); THROW(new NCursesPanelException (this, err));
} }
// If err is equal to the curses error indicator ERR, an error handler // If err is equal to the curses error indicator ERR, an error handler
// is called. // is called.
// Get a keystroke. Default implementation calls getch() // Get a keystroke. Default implementation calls getch()
virtual int getKey(void); virtual int getKey(void);
public: public:
NCursesPanel(int lines, NCursesPanel(int nlines,
int cols, int ncols,
int begin_y = 0, int begin_y = 0,
int begin_x = 0) int begin_x = 0)
: NCursesWindow(lines,cols,begin_y,begin_x) { : NCursesWindow(nlines,ncols,begin_y,begin_x), p(0)
init(); {
init();
} }
// Create a panel with this size starting at the requested position. // Create a panel with this size starting at the requested position.
NCursesPanel() : NCursesWindow(::stdscr) { init(); } NCursesPanel()
: NCursesWindow(::stdscr), p(0)
{
init();
}
// This constructor creates the default Panel associated with the // This constructor creates the default Panel associated with the
// ::stdscr window // ::stdscr window
NCursesPanel& operator=(const NCursesPanel& rhs)
{
if (this != &rhs) {
*this = rhs;
NCursesWindow::operator=(rhs);
}
return *this;
}
NCursesPanel(const NCursesPanel& rhs)
: NCursesWindow(rhs),
p(rhs.p)
{
}
virtual ~NCursesPanel(); virtual ~NCursesPanel();
// basic manipulation // basic manipulation
inline void hide() { inline void hide()
{
OnError (::hide_panel(p)); OnError (::hide_panel(p));
} }
// Hide the panel. It stays in the stack but becomes invisible. // Hide the panel. It stays in the stack but becomes invisible.
inline void show() { inline void show()
{
OnError (::show_panel(p)); OnError (::show_panel(p));
} }
// Show the panel, i.e. make it visible. // Show the panel, i.e. make it visible.
inline void top() { inline void top()
{
OnError (::top_panel(p)); OnError (::top_panel(p));
} }
// Make this panel the top panel in the stack. // Make this panel the top panel in the stack.
inline void bottom() { inline void bottom()
{
OnError (::bottom_panel(p)); OnError (::bottom_panel(p));
} }
// Make this panel the bottom panel in the stack. // Make this panel the bottom panel in the stack.
// N.B.: The panel associated with ::stdscr is always on the bottom. So // N.B.: The panel associated with ::stdscr is always on the bottom. So
// actually bottom() makes the panel the first above ::stdscr. // actually bottom() makes the panel the first above ::stdscr.
virtual int mvwin(int y, int x) { virtual int mvwin(int y, int x)
{
OnError(::move_panel(p, y, x)); OnError(::move_panel(p, y, x));
return OK; return OK;
} }
inline bool hidden() const { inline bool hidden() const
{
return (::panel_hidden (p) ? TRUE : FALSE); return (::panel_hidden (p) ? TRUE : FALSE);
} }
// Return TRUE if the panel is hidden, FALSE otherwise. // Return TRUE if the panel is hidden, FALSE otherwise.
/* The functions panel_above() and panel_below() are not reflected in /* The functions panel_above() and panel_below() are not reflected in
the NCursesPanel class. The reason for this is, that we cannot the NCursesPanel class. The reason for this is, that we cannot
assume that a panel retrieved by those operations is one wrapped assume that a panel retrieved by those operations is one wrapped
by a C++ class. Although this situation might be handled, we also by a C++ class. Although this situation might be handled, we also
need a reverse mapping from PANEL to NCursesPanel which needs some need a reverse mapping from PANEL to NCursesPanel which needs some
redesign of the low level stuff. At the moment, we define them in the redesign of the low level stuff. At the moment, we define them in the
interface but they will always produce an error. */ interface but they will always produce an error. */
inline NCursesPanel& above() const { inline NCursesPanel& above() const
{
OnError(ERR); OnError(ERR);
return *dummy; return *dummy;
} }
inline NCursesPanel& below() const { inline NCursesPanel& below() const
{
OnError(ERR); OnError(ERR);
return *dummy; return *dummy;
} }
// Those two are rewrites of the corresponding virtual members of // Those two are rewrites of the corresponding virtual members of
// NCursesWindow // NCursesWindow
virtual int refresh(); virtual int refresh();
// Propagate all panel changes to the virtual screen and update the // Propagate all panel changes to the virtual screen and update the
// physical screen. // physical screen.
skipping to change at line 188 skipping to change at line 228
// Put the label text centered in the specified row. // Put the label text centered in the specified row.
}; };
/* We use templates to provide a typesafe mechanism to associate /* We use templates to provide a typesafe mechanism to associate
* user data with a panel. A NCursesUserPanel<T> is a panel * user data with a panel. A NCursesUserPanel<T> is a panel
* associated with some user data of type T. * associated with some user data of type T.
*/ */
template<class T> class NCursesUserPanel : public NCursesPanel template<class T> class NCursesUserPanel : public NCursesPanel
{ {
public: public:
NCursesUserPanel (int lines, NCursesUserPanel (int nlines,
int cols, int ncols,
int begin_y = 0, int begin_y = 0,
int begin_x = 0, int begin_x = 0,
const T* p_UserData = (T*)0) const T* p_UserData = STATIC_CAST(T*)(0))
: NCursesPanel (lines, cols, begin_y, begin_x) { : NCursesPanel (nlines, ncols, begin_y, begin_x)
{
if (p) if (p)
set_user ((void *)p_UserData); set_user (const_cast<void *>(p_UserData));
}; };
// This creates an user panel of the requested size with associated // This creates an user panel of the requested size with associated
// user data pointed to by p_UserData. // user data pointed to by p_UserData.
NCursesUserPanel(const T* p_UserData = (T*)0) : NCursesPanel() { NCursesUserPanel(const T* p_UserData = STATIC_CAST(T*)(0)) : NCursesPanel
()
{
if (p) if (p)
set_user((void *)p_UserData); set_user(const_cast<void *>(p_UserData));
}; };
// This creates an user panel associated with the ::stdscr and user data // This creates an user panel associated with the ::stdscr and user data
// pointed to by p_UserData. // pointed to by p_UserData.
virtual ~NCursesUserPanel() {}; virtual ~NCursesUserPanel() {};
T* UserData (void) const { T* UserData (void) const
return (T*)get_user (); {
return reinterpret_cast<T*>(get_user ());
}; };
// Retrieve the user data associated with the panel. // Retrieve the user data associated with the panel.
virtual void setUserData (const T* p_UserData) { virtual void setUserData (const T* p_UserData)
{
if (p) if (p)
set_user ((void *)p_UserData); set_user (const_cast<void *>(p_UserData));
} }
// Associate the user panel with the user data pointed to by p_UserData. // Associate the user panel with the user data pointed to by p_UserData.
}; };
#endif // NCURSES_CURSESP_H_incl #endif /* NCURSES_CURSESP_H_incl */
 End of changes. 28 change blocks. 
32 lines changed or deleted 77 lines changed or added


 cursesw.h   cursesw.h 
// * This makes emacs happy -*-Mode: C++;-*- // * This makes emacs happy -*-Mode: C++;-*-
/************************************************************************** ** /************************************************************************** **
* Copyright (c) 1998-2001,2004 Free Software Foundation, Inc. * * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. *
* * * *
* Permission is hereby granted, free of charge, to any person obtaining a * * Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the * * copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including * * "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, * * without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell * * distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is * * copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: * * furnished to do so, subject to the following conditions: *
* * * *
* The above copyright notice and this permission notice shall be included * * The above copyright notice and this permission notice shall be included *
skipping to change at line 33 skipping to change at line 33
* * * *
* Except as contained in this notice, the name(s) of the above copyright * * 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 * * holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written * * sale, use or other dealings in this Software without prior written *
* authorization. * * authorization. *
************************************************************************** **/ ************************************************************************** **/
#ifndef NCURSES_CURSESW_H_incl #ifndef NCURSES_CURSESW_H_incl
#define NCURSES_CURSESW_H_incl 1 #define NCURSES_CURSESW_H_incl 1
// $Id: cursesw.h,v 1.30 2004/02/08 00:11:54 tom Exp $ // $Id: cursesw.h,v 1.38 2005/07/23 20:51:39 tom Exp $
#include <ncurses/etip.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <ncurses/etip.h>
#if HAVE_STRSTREAM_H && (USE_STRSTREAM_VSCAN||USE_STRSTREAM_VSCAN_CAST) #if HAVE_STRSTREAM_H && (USE_STRSTREAM_VSCAN||USE_STRSTREAM_VSCAN_CAST)
#include <strstream.h> #include <strstream.h>
#endif #endif
extern "C" { extern "C" {
# include <ncurses/curses.h> # include <ncurses/curses.h>
} }
/* SCO 3.2v4 curses.h includes term.h, which defines lines as a macro. /* SCO 3.2v4 curses.h includes term.h, which defines lines as a macro.
Undefine it here, because NCursesWindow uses lines as a method. */ Undefine it here, because NCursesWindow uses lines as a method. */
skipping to change at line 310 skipping to change at line 311
#define hline UNDEF(hline) #define hline UNDEF(hline)
#endif #endif
#ifdef inch #ifdef inch
inline chtype UNDEF(inch)() { return inch(); } inline chtype UNDEF(inch)() { return inch(); }
#undef inch #undef inch
#define inch UNDEF(inch) #define inch UNDEF(inch)
#endif #endif
#ifdef insch #ifdef insch
inline int UNDEF(insch)(char c) { return insch(c); } inline int UNDEF(insch)(chtype c) { return insch(c); }
#undef insch #undef insch
#define insch UNDEF(insch) #define insch UNDEF(insch)
#endif #endif
#ifdef insertln #ifdef insertln
inline int UNDEF(insertln)() { return insertln(); } inline int UNDEF(insertln)() { return insertln(); }
#undef insertln #undef insertln
#define insertln UNDEF(insertln) #define insertln UNDEF(insertln)
#endif #endif
skipping to change at line 569 skipping to change at line 570
#endif #endif
#ifdef mvwinch #ifdef mvwinch
inline chtype UNDEF(mvwinch)(WINDOW *win, int y, int x) { inline chtype UNDEF(mvwinch)(WINDOW *win, int y, int x) {
return mvwinch(win, y, x);} return mvwinch(win, y, x);}
#undef mvwinch #undef mvwinch
#define mvwinch UNDEF(mvwinch) #define mvwinch UNDEF(mvwinch)
#endif #endif
#ifdef mvwinsch #ifdef mvwinsch
inline int UNDEF(mvwinsch)(WINDOW *win, int y, int x, char c) inline int UNDEF(mvwinsch)(WINDOW *win, int y, int x, chtype c)
{ return mvwinsch(win, y, x, c); } { return mvwinsch(win, y, x, c); }
#undef mvwinsch #undef mvwinsch
#define mvwinsch UNDEF(mvwinsch) #define mvwinsch UNDEF(mvwinsch)
#endif #endif
#ifdef mvaddch #ifdef mvaddch
inline int UNDEF(mvaddch)(int y, int x, chtype ch) inline int UNDEF(mvaddch)(int y, int x, chtype ch)
{ return mvaddch(y, x, ch); } { return mvaddch(y, x, ch); }
#undef mvaddch #undef mvaddch
#define mvaddch UNDEF(mvaddch) #define mvaddch UNDEF(mvaddch)
skipping to change at line 628 skipping to change at line 629
#define mvgetnstr UNDEF(mvgetnstr) #define mvgetnstr UNDEF(mvgetnstr)
#endif #endif
#ifdef mvinch #ifdef mvinch
inline chtype UNDEF(mvinch)(int y, int x) { return mvinch(y, x);} inline chtype UNDEF(mvinch)(int y, int x) { return mvinch(y, x);}
#undef mvinch #undef mvinch
#define mvinch UNDEF(mvinch) #define mvinch UNDEF(mvinch)
#endif #endif
#ifdef mvinsch #ifdef mvinsch
inline int UNDEF(mvinsch)(int y, int x, char c) inline int UNDEF(mvinsch)(int y, int x, chtype c)
{ return mvinsch(y, x, c); } { return mvinsch(y, x, c); }
#undef mvinsch #undef mvinsch
#define mvinsch UNDEF(mvinsch) #define mvinsch UNDEF(mvinsch)
#endif #endif
#ifdef napms #ifdef napms
inline void UNDEF(napms)(unsigned long x) { napms(x); } inline void UNDEF(napms)(unsigned long x) { napms(x); }
#undef napms #undef napms
#define napms UNDEF(napms) #define napms UNDEF(napms)
#endif #endif
skipping to change at line 692 skipping to change at line 693
#ifdef bkgdset #ifdef bkgdset
inline void UNDEF(bkgdset)(chtype ch) { bkgdset(ch); } inline void UNDEF(bkgdset)(chtype ch) { bkgdset(ch); }
#undef bkgdset #undef bkgdset
#define bkgdset UNDEF(bkgdset) #define bkgdset UNDEF(bkgdset)
#endif #endif
/* /*
* *
* C++ class for windows. * C++ class for windows.
* *
*
*/ */
extern "C" int _nc_ripoffline(int, int (*init)(WINDOW*, int));
extern "C" int _nc_xx_ripoff_init(WINDOW *, int);
extern "C" int _nc_has_mouse(void);
class NCURSES_IMPEXP NCursesWindow class NCURSES_IMPEXP NCursesWindow
{ {
friend class NCursesMenu; friend class NCursesMenu;
friend class NCursesForm; friend class NCursesForm;
private: private:
static bool b_initialized; static bool b_initialized;
static void initialize(); static void initialize();
static int ripoff_init(WINDOW *, int); friend int _nc_xx_ripoff_init(WINDOW *, int);
void init(); void init();
short getcolor(int getback) const; short getcolor(int getback) const;
static int setpalette(short fore, short back, short pair); static int setpalette(short fore, short back, short pair);
static int colorInitialized; static int colorInitialized;
// This private constructor is only used during the initialization // This private constructor is only used during the initialization
// of windows generated by ripoffline() calls. // of windows generated by ripoffline() calls.
NCursesWindow(WINDOW* win, int cols); NCursesWindow(WINDOW* win, int ncols);
protected: protected:
void err_handler(const char *) const THROWS(NCursesException); virtual void err_handler(const char *) const THROWS(NCursesException);
// Signal an error with the given message text. // Signal an error with the given message text.
static long count; // count of all active windows: static long count; // count of all active windows:
// We rely on the c++ promise that // We rely on the c++ promise that
// all otherwise uninitialized // all otherwise uninitialized
// static class vars are set to 0 // static class vars are set to 0
WINDOW* w; // the curses WINDOW WINDOW* w; // the curses WINDOW
bool alloced; // TRUE if we own the WINDOW bool alloced; // TRUE if we own the WINDOW
skipping to change at line 743 skipping to change at line 747
void kill_subwindows(); // disable all subwindows void kill_subwindows(); // disable all subwindows
// Destroy all subwindows. // Destroy all subwindows.
/* Only for use by derived classes. They are then in charge to /* Only for use by derived classes. They are then in charge to
fill the member variables correctly. */ fill the member variables correctly. */
NCursesWindow(); NCursesWindow();
public: public:
NCursesWindow(WINDOW* &window); // useful only for stdscr NCursesWindow(WINDOW* &window); // useful only for stdscr
NCursesWindow(int lines, // number of lines NCursesWindow(int nlines, // number of lines
int cols, // number of columns int ncols, // number of columns
int begin_y, // line origin int begin_y, // line origin
int begin_x); // col origin int begin_x); // col origin
NCursesWindow(NCursesWindow& par,// parent window NCursesWindow(NCursesWindow& par,// parent window
int lines, // number of lines int nlines, // number of lines
int cols, // number of columns int ncols, // number of columns
int begin_y, // absolute or relative int begin_y, // absolute or relative
int begin_x, // origins: int begin_x, // origins:
char absrel = 'a');// if `a', begin_y & begin_x are char absrel = 'a');// if `a', begin_y & begin_x are
// absolute screen pos, else if `r', they are relative to par origin // absolute screen pos, else if `r', they are relative to par origin
NCursesWindow(NCursesWindow& par,// parent window NCursesWindow(NCursesWindow& par,// parent window
bool do_box = TRUE); bool do_box = TRUE);
// this is the very common case that we want to create the subwindow that // this is the very common case that we want to create the subwindow that
// is two lines and two columns smaller and begins at (1,1). // is two lines and two columns smaller and begins at (1,1).
// We may automatically request the box around it. // We may automatically request the box around it.
NCursesWindow& operator=(const NCursesWindow& rhs)
{
if (this != &rhs)
*this = rhs;
return *this;
}
NCursesWindow(const NCursesWindow& rhs)
: w(rhs.w), alloced(rhs.alloced), par(rhs.par), subwins(rhs.subwins), s
ib(rhs.sib)
{
}
virtual ~NCursesWindow(); virtual ~NCursesWindow();
NCursesWindow Clone(); NCursesWindow Clone();
// Make an exact copy of the window. // Make an exact copy of the window.
// Initialization. // Initialization.
static void useColors(void); static void useColors(void);
// Call this routine very early if you want to have colors. // Call this routine very early if you want to have colors.
static int ripoffline(int ripoff_lines, static int ripoffline(int ripoff_lines,
skipping to change at line 981 skipping to change at line 997
// negative, it is ignored. // negative, it is ignored.
int insstr(int y, int x, const char *s, int n=-1) { int insstr(int y, int x, const char *s, int n=-1) {
return ::mvwinsnstr(w, y, x, s, n); } return ::mvwinsnstr(w, y, x, s, n); }
// Move the cursor to the requested position and then perform the insstr( ) // Move the cursor to the requested position and then perform the insstr( )
// as described above. // as described above.
int attron (chtype at) { return ::wattron (w, at); } int attron (chtype at) { return ::wattron (w, at); }
// Switch on the window attributes; // Switch on the window attributes;
int attroff(chtype at) { return ::wattroff(w, (int) at); } int attroff(chtype at) { return ::wattroff(w, static_cast<int> (at)); }
// Switch off the window attributes; // Switch off the window attributes;
int attrset(chtype at) { return ::wattrset(w, (int) at); } int attrset(chtype at) { return ::wattrset(w, static_cast<int> (at)); }
// Set the window attributes; // Set the window attributes;
int color_set(short color_pair_number, void* opts=NULL) { int color_set(short color_pair_number, void* opts=NULL) {
return ::wcolor_set(w, color_pair_number, opts); } return ::wcolor_set(w, color_pair_number, opts); }
// Set the window color attribute; // Set the window color attribute;
int chgat(int n, attr_t attr, short color, const void *opts=NU LL) { int chgat(int n, attr_t attr, short color, const void *opts=NU LL) {
return ::wchgat(w, n, attr, color, opts); } return ::wchgat(w, n, attr, color, opts); }
// Change the attributes of the next n characters in the current line. If // Change the attributes of the next n characters in the current line. If
// n is negative or greater than the number of remaining characters in th e // n is negative or greater than the number of remaining characters in th e
skipping to change at line 1113 skipping to change at line 1129
// If bf is TRUE, use insert/delete character hardware support if possibl e. // If bf is TRUE, use insert/delete character hardware support if possibl e.
// Otherwise do it in software. // Otherwise do it in software.
int touchwin() { return ::wtouchln(w, 0, height(), 1); } int touchwin() { return ::wtouchln(w, 0, height(), 1); }
// Mark the whole window as modified. // Mark the whole window as modified.
int untouchwin() { return ::wtouchln(w, 0, height(), 0); } int untouchwin() { return ::wtouchln(w, 0, height(), 0); }
// Mark the whole window as unmodified. // Mark the whole window as unmodified.
int touchln(int s, int cnt, bool changed=TRUE) { int touchln(int s, int cnt, bool changed=TRUE) {
return ::wtouchln(w, s, cnt, (int)(changed?1:0)); } return ::wtouchln(w, s, cnt, static_cast<int>(changed ? 1 : 0)); }
// Mark cnt lines beginning from line s as changed or unchanged, dependin g // Mark cnt lines beginning from line s as changed or unchanged, dependin g
// on the value of the changed flag. // on the value of the changed flag.
bool is_linetouched(int line) const { bool is_linetouched(int line) const {
return (::is_linetouched(w, line) ? TRUE:FALSE); } return (::is_linetouched(w, line) ? TRUE:FALSE); }
// Return TRUE if line is marked as changed, FALSE otherwise // Return TRUE if line is marked as changed, FALSE otherwise
bool is_wintouched() const { bool is_wintouched() const {
return (::is_wintouched(w) ? TRUE:FALSE); } return (::is_wintouched(w) ? TRUE:FALSE); }
// Return TRUE if window is marked as changed, FALSE otherwise // Return TRUE if window is marked as changed, FALSE otherwise
skipping to change at line 1197 skipping to change at line 1213
return ::overlay(w, win.w); } return ::overlay(w, win.w); }
// Overlay this window over win. // Overlay this window over win.
int overwrite(NCursesWindow& win) { int overwrite(NCursesWindow& win) {
return ::overwrite(w, win.w); } return ::overwrite(w, win.w); }
// Overwrite win with this window. // Overwrite win with this window.
int copywin(NCursesWindow& win, int copywin(NCursesWindow& win,
int sminrow, int smincol, int sminrow, int smincol,
int dminrow, int dmincol, int dminrow, int dmincol,
int dmaxrow, int dmaxcol, bool overlay=TRUE) { int dmaxrow, int dmaxcol, bool overlaywin=TRUE) {
return ::copywin(w, win.w, sminrow, smincol, dminrow, dmincol, return ::copywin(w, win.w, sminrow, smincol, dminrow, dmincol,
dmaxrow, dmaxcol, (int)(overlay?1:0)); } dmaxrow, dmaxcol, static_cast<int>(overlaywin ? 1 : 0)) ; }
// Overlay or overwrite the rectangle in win given by dminrow,dmincol, // Overlay or overwrite the rectangle in win given by dminrow,dmincol,
// dmaxrow,dmaxcol with the rectangle in this window beginning at // dmaxrow,dmaxcol with the rectangle in this window beginning at
// sminrow,smincol. // sminrow,smincol.
// ---------------------------------------------------------------------- --- // ---------------------------------------------------------------------- ---
// Mouse related // Mouse related
// ---------------------------------------------------------------------- --- // ---------------------------------------------------------------------- ---
bool has_mouse() const; bool has_mouse() const;
// Return TRUE if terminal supports a mouse, FALSE otherwise // Return TRUE if terminal supports a mouse, FALSE otherwise
skipping to change at line 1229 skipping to change at line 1245
NCursesWindow* parent() { return par; } NCursesWindow* parent() { return par; }
// Get my parent. // Get my parent.
bool isDescendant(NCursesWindow& win); bool isDescendant(NCursesWindow& win);
// Return TRUE if win is a descendant of this. // Return TRUE if win is a descendant of this.
}; };
// ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ -
// We leave this here for compatibility reasons. // We leave this here for compatibility reasons.
// ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ -
class NCURSES_IMPEXP NCursesColorWindow : public NCursesWindow { class NCURSES_IMPEXP NCursesColorWindow : public NCursesWindow
{
public: public:
NCursesColorWindow(WINDOW* &window) // useful only for stdscr NCursesColorWindow(WINDOW* &window) // useful only for stdscr
: NCursesWindow(window) { : NCursesWindow(window) {
useColors(); } useColors(); }
NCursesColorWindow(int lines, // number of lines NCursesColorWindow(int nlines, // number of lines
int cols, // number of columns int ncols, // number of columns
int begin_y, // line origin int begin_y, // line origin
int begin_x) // col origin int begin_x) // col origin
: NCursesWindow(lines, cols, begin_y, begin_x) { : NCursesWindow(nlines, ncols, begin_y, begin_x) {
useColors(); } useColors(); }
NCursesColorWindow(NCursesWindow& par,// parent window NCursesColorWindow(NCursesWindow& parentWin,// parent window
int lines, // number of lines int nlines, // number of lines
int cols, // number of columns int ncols, // number of columns
int begin_y, // absolute or relative int begin_y, // absolute or relative
int begin_x, // origins: int begin_x, // origins:
char absrel = 'a') // if `a', by & bx are char absrel = 'a') // if `a', by & bx are
: NCursesWindow(par, lines, cols, // absolute screen pos, : NCursesWindow(parentWin,
nlines, ncols, // absolute screen pos,
begin_y, begin_x, // else if `r', they are begin_y, begin_x, // else if `r', they are
absrel ) { // relative to par origin absrel ) { // relative to par origin
useColors(); } useColors(); }
}; };
// These enum definitions really belong inside the NCursesPad class, but on ly // These enum definitions really belong inside the NCursesPad class, but on ly
// recent compilers support that feature. // recent compilers support that feature.
typedef enum { typedef enum {
REQ_PAD_REFRESH = KEY_MAX + 1, REQ_PAD_REFRESH = KEY_MAX + 1,
skipping to change at line 1273 skipping to change at line 1291
REQ_PAD_EXIT REQ_PAD_EXIT
} Pad_Request; } Pad_Request;
const Pad_Request PAD_LOW = REQ_PAD_REFRESH; // lowest op-code const Pad_Request PAD_LOW = REQ_PAD_REFRESH; // lowest op-code
const Pad_Request PAD_HIGH = REQ_PAD_EXIT; // highest op-code const Pad_Request PAD_HIGH = REQ_PAD_EXIT; // highest op-code
// ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ -
// Pad Support. We allow an association of a pad with a "real" window // Pad Support. We allow an association of a pad with a "real" window
// through which the pad may be viewed. // through which the pad may be viewed.
// ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ -
class NCURSES_IMPEXP NCursesPad : public NCursesWindow { class NCURSES_IMPEXP NCursesPad : public NCursesWindow
{
private: private:
NCursesWindow* viewWin; // the "viewport" window NCursesWindow* viewWin; // the "viewport" window
NCursesWindow* viewSub; // the "viewport" subwindow NCursesWindow* viewSub; // the "viewport" subwindow
int h_gridsize, v_gridsize; int h_gridsize, v_gridsize;
protected: protected:
int min_row, min_col; // top left row/col of the pads display are a int min_row, min_col; // top left row/col of the pads display are a
NCursesWindow* Win(void) const { NCursesWindow* Win(void) const {
skipping to change at line 1315 skipping to change at line 1334
::beep(); ::beep();
} }
// This is called if a navigation request couldn't be satisfied // This is called if a navigation request couldn't be satisfied
virtual void OnOperation(int pad_req) { virtual void OnOperation(int pad_req) {
}; };
// OnOperation is called if a Pad_Operation was executed and just before // OnOperation is called if a Pad_Operation was executed and just before
// the refresh() operation is done. // the refresh() operation is done.
public: public:
NCursesPad(int lines, int cols); NCursesPad(int nlines, int ncols);
// create a pad with the given size // create a pad with the given size
NCursesPad& operator=(const NCursesPad& rhs)
{
if (this != &rhs) {
*this = rhs;
NCursesWindow::operator=(rhs);
}
return *this;
}
NCursesPad(const NCursesPad& rhs)
: NCursesWindow(rhs),
viewWin(rhs.viewWin),
viewSub(rhs.viewSub),
h_gridsize(rhs.h_gridsize),
v_gridsize(rhs.v_gridsize),
min_row(rhs.min_row),
min_col(rhs.min_col)
{
}
virtual ~NCursesPad() {} virtual ~NCursesPad() {}
int echochar(const chtype ch) { return ::pechochar(w, ch); } int echochar(const chtype ch) { return ::pechochar(w, ch); }
// Put the attributed character onto the pad and immediately do a // Put the attributed character onto the pad and immediately do a
// prefresh(). // prefresh().
int refresh(); int refresh();
// If a viewport is defined the pad is displayed in this window, otherwis e // If a viewport is defined the pad is displayed in this window, otherwis e
// this is a noop. // this is a noop.
skipping to change at line 1365 skipping to change at line 1404
// The full viewport window is usually used to provide some decorations // The full viewport window is usually used to provide some decorations
// like frames, titles etc. // like frames, titles etc.
virtual void operator() (void); virtual void operator() (void);
// Perform Pad's operation // Perform Pad's operation
}; };
// A FramedPad is constructed always with a viewport window. This viewport // A FramedPad is constructed always with a viewport window. This viewport
// will be framed (by a box() command) and the interior of the box is the // will be framed (by a box() command) and the interior of the box is the
// viewport subwindow. On the frame we display scrollbar sliders. // viewport subwindow. On the frame we display scrollbar sliders.
class NCURSES_IMPEXP NCursesFramedPad : public NCursesPad { class NCURSES_IMPEXP NCursesFramedPad : public NCursesPad
{
protected: protected:
virtual void OnOperation(int pad_req); virtual void OnOperation(int pad_req);
public: public:
NCursesFramedPad(NCursesWindow& win, int lines, int cols, NCursesFramedPad(NCursesWindow& win, int nlines, int ncols,
int v_grid = 1, int h_grid = 1) int v_grid = 1, int h_grid = 1)
: NCursesPad(lines, cols) { : NCursesPad(nlines, ncols) {
NCursesPad::setWindow(win, v_grid, h_grid); NCursesPad::setWindow(win, v_grid, h_grid);
NCursesPad::setSubWindow(*(new NCursesWindow(win))); NCursesPad::setSubWindow(*(new NCursesWindow(win)));
} }
// Construct the FramedPad with the given Window win as viewport. // Construct the FramedPad with the given Window win as viewport.
virtual ~NCursesFramedPad() { virtual ~NCursesFramedPad() {
delete getSubWindow(); delete getSubWindow();
} }
void setWindow(NCursesWindow& view, int v_grid = 1, int h_grid = 1) { void setWindow(NCursesWindow& view, int v_grid = 1, int h_grid = 1) {
skipping to change at line 1394 skipping to change at line 1434
} }
// Disable this call; the viewport is already defined // Disable this call; the viewport is already defined
void setSubWindow(NCursesWindow& sub) { void setSubWindow(NCursesWindow& sub) {
err_handler("Operation not allowed"); err_handler("Operation not allowed");
} }
// Disable this call; the viewport subwindow is already defined // Disable this call; the viewport subwindow is already defined
}; };
#endif // NCURSES_CURSESW_H_incl #endif /* NCURSES_CURSESW_H_incl */
 End of changes. 32 change blocks. 
32 lines changed or deleted 73 lines changed or added


 cursslk.h   cursslk.h 
// * this is for making emacs happy: -*-Mode: C++;-*- // * this is for making emacs happy: -*-Mode: C++;-*-
/************************************************************************** ** /************************************************************************** **
* Copyright (c) 1998-2002,2003 Free Software Foundation, Inc. * * Copyright (c) 1998-2003,2005 Free Software Foundation, Inc. *
* * * *
* Permission is hereby granted, free of charge, to any person obtaining a * * Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the * * copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including * * "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, * * without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell * * distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is * * copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: * * furnished to do so, subject to the following conditions: *
* * * *
* The above copyright notice and this permission notice shall be included * * The above copyright notice and this permission notice shall be included *
skipping to change at line 34 skipping to change at line 34
* Except as contained in this notice, the name(s) of the above copyright * * 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 * * holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written * * sale, use or other dealings in this Software without prior written *
* authorization. * * authorization. *
************************************************************************** **/ ************************************************************************** **/
/************************************************************************** ** /************************************************************************** **
* Author: Juergen Pfeifer, 1997 * * Author: Juergen Pfeifer, 1997 *
************************************************************************** **/ ************************************************************************** **/
// $Id: cursslk.h,v 1.9 2003/10/25 15:04:46 tom Exp $ // $Id: cursslk.h,v 1.13 2005/05/28 21:58:18 tom Exp $
#ifndef NCURSES_CURSSLK_H_incl #ifndef NCURSES_CURSSLK_H_incl
#define NCURSES_CURSSLK_H_incl #define NCURSES_CURSSLK_H_incl
#include <ncurses/cursesw.h> #include <ncurses/cursesw.h>
class NCURSES_IMPEXP Soft_Label_Key_Set { class NCURSES_IMPEXP Soft_Label_Key_Set {
public: public:
// This inner class represents the attributes of a Soft Label Key (SLK) // This inner class represents the attributes of a Soft Label Key (SLK)
class NCURSES_IMPEXP Soft_Label_Key { class NCURSES_IMPEXP Soft_Label_Key {
friend class Soft_Label_Key_Set; friend class Soft_Label_Key_Set;
public: public:
typedef enum { Left=0, Center=1, Right=2 } Justification; typedef enum { Left=0, Center=1, Right=2 } Justification;
private: private:
char *label; // The Text of the Label char *label; // The Text of the Label
Justification format; // The Justification Justification format; // The Justification
int num; // The number of the Label int num; // The number of the Label
Soft_Label_Key() : label((char*)0),format(Left),num(-1) { Soft_Label_Key() : label(NULL), format(Left), num(-1) {
} }
virtual ~Soft_Label_Key() { virtual ~Soft_Label_Key() {
delete[] label; delete[] label;
}; };
public: public:
// Set the text of the Label // Set the text of the Label
void operator=(char *text); Soft_Label_Key& operator=(char *text);
// Set the Justification of the Label // Set the Justification of the Label
inline void operator=(Justification just) { Soft_Label_Key& operator=(Justification just) {
format = just; format = just;
return *this;
} }
// Retrieve the text of the label // Retrieve the text of the label
inline char* operator()(void) const { inline char* operator()(void) const {
return label; return label;
} }
Soft_Label_Key& operator=(const Soft_Label_Key& rhs)
{
if (this != &rhs) {
*this = rhs;
}
return *this;
}
Soft_Label_Key(const Soft_Label_Key& rhs)
: label(NULL),
format(rhs.format),
num(rhs.num)
{
*this = rhs.label;
}
}; };
public: public:
typedef enum { typedef enum {
None = -1, None = -1,
Three_Two_Three = 0, Three_Two_Three = 0,
Four_Four = 1, Four_Four = 1,
PC_Style = 2, PC_Style = 2,
PC_Style_With_Index = 3 PC_Style_With_Index = 3
} Label_Layout; } Label_Layout;
skipping to change at line 131 skipping to change at line 148
// Construct a Key Set, use the most comfortable layout as default. // Construct a Key Set, use the most comfortable layout as default.
// You must create a Soft_Label_Key_Set before you create any object of // You must create a Soft_Label_Key_Set before you create any object of
// the NCursesWindow, NCursesPanel or derived classes. (Actually before // the NCursesWindow, NCursesPanel or derived classes. (Actually before
// ::initscr() is called). // ::initscr() is called).
Soft_Label_Key_Set(Label_Layout fmt); Soft_Label_Key_Set(Label_Layout fmt);
// This constructor assumes, that you already constructed a Key Set // This constructor assumes, that you already constructed a Key Set
// with a layout by the constructor above. This layout will be reused. // with a layout by the constructor above. This layout will be reused.
NCURSES_IMPEXP Soft_Label_Key_Set(); NCURSES_IMPEXP Soft_Label_Key_Set();
Soft_Label_Key_Set& operator=(const Soft_Label_Key_Set& rhs)
{
if (this != &rhs) {
*this = rhs;
init(); // allocate a new slk_array[]
}
return *this;
}
Soft_Label_Key_Set(const Soft_Label_Key_Set& rhs)
: b_attrInit(rhs.b_attrInit),
slk_array(NULL)
{
init(); // allocate a new slk_array[]
}
virtual ~Soft_Label_Key_Set(); virtual ~Soft_Label_Key_Set();
// Get Label# i. Label counting starts with 1! // Get Label# i. Label counting starts with 1!
NCURSES_IMPEXP Soft_Label_Key& operator[](int i); NCURSES_IMPEXP Soft_Label_Key& operator[](int i);
// Retrieve number of Labels // Retrieve number of Labels
inline int labels() const { return num_labels; } inline int labels() const { return num_labels; }
// Refresh the SLK portion of the screen // Refresh the SLK portion of the screen
inline void refresh() { inline void refresh() {
skipping to change at line 205 skipping to change at line 238
inline void color(short color_pair_number) { inline void color(short color_pair_number) {
if (ERR==::slk_color(color_pair_number)) if (ERR==::slk_color(color_pair_number))
Error("slk_color"); Error("slk_color");
} }
inline attr_t attr() const { inline attr_t attr() const {
return ::slk_attr(); return ::slk_attr();
} }
}; };
#endif // NCURSES_CURSSLK_H_incl #endif /* NCURSES_CURSSLK_H_incl */
 End of changes. 9 change blocks. 
5 lines changed or deleted 38 lines changed or added


 etip.h   etip.h 
// * This makes emacs happy -*-Mode: C++;-*- // * This makes emacs happy -*-Mode: C++;-*-
/************************************************************************** ** /************************************************************************** **
* Copyright (c) 1998,1999,2000,2001 Free Software Foundation, Inc. * * Copyright (c) 1998-2003,2005 Free Software Foundation, Inc. *
* * * *
* Permission is hereby granted, free of charge, to any person obtaining a * * Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the * * copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including * * "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, * * without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell * * distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is * * copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: * * furnished to do so, subject to the following conditions: *
* * * *
* The above copyright notice and this permission notice shall be included * * The above copyright notice and this permission notice shall be included *
skipping to change at line 34 skipping to change at line 34
* Except as contained in this notice, the name(s) of the above copyright * * 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 * * holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written * * sale, use or other dealings in this Software without prior written *
* authorization. * * authorization. *
************************************************************************** **/ ************************************************************************** **/
/************************************************************************** ** /************************************************************************** **
* Author: Juergen Pfeifer, 1997 * * Author: Juergen Pfeifer, 1997 *
************************************************************************** **/ ************************************************************************** **/
// $Id: etip.h.in,v 1.25 2003/10/25 15:05:58 tom Exp $ // $Id: etip.h.in,v 1.32 2005/08/06 19:55:57 tom Exp $
#ifndef NCURSES_ETIP_H_incl #ifndef NCURSES_ETIP_H_incl
#define NCURSES_ETIP_H_incl 1 #define NCURSES_ETIP_H_incl 1
// These are substituted at configure/build time // These are substituted at configure/build time
#ifndef HAVE_BUILTIN_H #ifndef HAVE_BUILTIN_H
#define HAVE_BUILTIN_H 0 #define HAVE_BUILTIN_H 0
#endif #endif
#ifndef HAVE_GXX_BUILTIN_H #ifndef HAVE_GXX_BUILTIN_H
skipping to change at line 76 skipping to change at line 76
#endif #endif
#ifndef ETIP_NEEDS_MATH_EXCEPTION #ifndef ETIP_NEEDS_MATH_EXCEPTION
#define ETIP_NEEDS_MATH_EXCEPTION 0 #define ETIP_NEEDS_MATH_EXCEPTION 0
#endif #endif
#ifndef CPP_HAS_PARAM_INIT #ifndef CPP_HAS_PARAM_INIT
#define CPP_HAS_PARAM_INIT 0 #define CPP_HAS_PARAM_INIT 0
#endif #endif
#ifndef CPP_HAS_STATIC_CAST
#define CPP_HAS_STATIC_CAST 1
#endif
#ifndef USE_STRSTREAM_VSCAN #ifndef USE_STRSTREAM_VSCAN
#define USE_STRSTREAM_VSCAN 0 #define USE_STRSTREAM_VSCAN 0
#endif #endif
#ifndef USE_STRSTREAM_VSCAN_CAST #ifndef USE_STRSTREAM_VSCAN_CAST
#define USE_STRSTREAM_VSCAN 0 #define USE_STRSTREAM_VSCAN 0
#endif #endif
#ifdef __GNUG__ #ifdef __GNUG__
# if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8)) # if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
skipping to change at line 114 skipping to change at line 118
# include <gpp/builtin.h> # include <gpp/builtin.h>
# elif HAVE_GXX_BUILTIN_H # elif HAVE_GXX_BUILTIN_H
# include <g++/builtin.h> # include <g++/builtin.h>
# else # else
# include <builtin.h> # include <builtin.h>
# endif # endif
# undef exception # undef exception
# endif # endif
#elif defined (__SUNPRO_CC) #elif defined (__SUNPRO_CC)
# include <generic.h> # include <generic.h>
# include <string.h>
#else
# include <string.h>
#endif #endif
#include <ncurses/ncurses_dll.h> #include <ncurses/ncurses_dll.h>
extern "C" { extern "C" {
#if HAVE_VALUES_H #if HAVE_VALUES_H
# include <values.h> # include <values.h>
#endif #endif
#include <assert.h> #include <assert.h>
skipping to change at line 138 skipping to change at line 139
#include <errno.h> #include <errno.h>
} }
// Language features // Language features
#if CPP_HAS_PARAM_INIT #if CPP_HAS_PARAM_INIT
#define NCURSES_PARAM_INIT(value) = value #define NCURSES_PARAM_INIT(value) = value
#else #else
#define NCURSES_PARAM_INIT(value) /*nothing*/ #define NCURSES_PARAM_INIT(value) /*nothing*/
#endif #endif
#if CPP_HAS_STATIC_CAST
#define STATIC_CAST(s) static_cast<s>
#else
#define STATIC_CAST(s) (s)
#endif
// Forward Declarations // Forward Declarations
class NCURSES_IMPEXP NCursesPanel; class NCURSES_IMPEXP NCursesPanel;
class NCURSES_IMPEXP NCursesMenu; class NCURSES_IMPEXP NCursesMenu;
class NCURSES_IMPEXP NCursesForm; class NCURSES_IMPEXP NCursesForm;
class NCURSES_IMPEXP NCursesException class NCURSES_IMPEXP NCursesException
{ {
public: public:
const char *message; const char *message;
int errorno; int errorno;
NCursesException (const char* msg, int err) NCursesException (const char* msg, int err)
: message(msg), errorno (err) : message(msg), errorno (err)
{}; {};
NCursesException (const char* msg) NCursesException (const char* msg)
: message(msg), errorno (E_SYSTEM_ERROR) : message(msg), errorno (E_SYSTEM_ERROR)
{}; {};
NCursesException& operator=(const NCursesException& rhs)
{
errorno = rhs.errorno;
return *this;
}
NCursesException(const NCursesException& rhs)
: message(rhs.message), errorno(rhs.errorno)
{
}
virtual const char *classname() const { virtual const char *classname() const {
return "NCursesWindow"; return "NCursesWindow";
} }
virtual ~NCursesException()
{
}
}; };
class NCURSES_IMPEXP NCursesPanelException : public NCursesException class NCURSES_IMPEXP NCursesPanelException : public NCursesException
{ {
public: public:
const NCursesPanel* p; const NCursesPanel* p;
NCursesPanelException (const char *msg, int err) : NCursesPanelException (const char *msg, int err) :
NCursesException (msg, err), NCursesException (msg, err),
p ((NCursesPanel*)0) p (NULL)
{}; {};
NCursesPanelException (const NCursesPanel* panel, NCursesPanelException (const NCursesPanel* panel,
const char *msg, const char *msg,
int err) : int err) :
NCursesException (msg, err), NCursesException (msg, err),
p (panel) p (panel)
{}; {};
NCursesPanelException (int err) : NCursesPanelException (int err) :
NCursesException ("panel library error", err), NCursesException ("panel library error", err),
p ((NCursesPanel*)0) p (NULL)
{}; {};
NCursesPanelException (const NCursesPanel* panel, NCursesPanelException (const NCursesPanel* panel,
int err) : int err) :
NCursesException ("panel library error", err), NCursesException ("panel library error", err),
p (panel) p (panel)
{}; {};
NCursesPanelException& operator=(const NCursesPanelException& rhs)
{
if (this != &rhs) {
NCursesException::operator=(rhs);
p = rhs.p;
}
return *this;
}
NCursesPanelException(const NCursesPanelException& rhs)
: NCursesException(rhs), p(rhs.p)
{
}
virtual const char *classname() const { virtual const char *classname() const {
return "NCursesPanel"; return "NCursesPanel";
} }
virtual ~NCursesPanelException()
{
}
}; };
class NCURSES_IMPEXP NCursesMenuException : public NCursesException class NCURSES_IMPEXP NCursesMenuException : public NCursesException
{ {
public: public:
const NCursesMenu* m; const NCursesMenu* m;
NCursesMenuException (const char *msg, int err) : NCursesMenuException (const char *msg, int err) :
NCursesException (msg, err), NCursesException (msg, err),
m ((NCursesMenu *)0) m (NULL)
{}; {};
NCursesMenuException (const NCursesMenu* menu, NCursesMenuException (const NCursesMenu* menu,
const char *msg, const char *msg,
int err) : int err) :
NCursesException (msg, err), NCursesException (msg, err),
m (menu) m (menu)
{}; {};
NCursesMenuException (int err) : NCursesMenuException (int err) :
NCursesException ("menu library error", err), NCursesException ("menu library error", err),
m ((NCursesMenu *)0) m (NULL)
{}; {};
NCursesMenuException (const NCursesMenu* menu, NCursesMenuException (const NCursesMenu* menu,
int err) : int err) :
NCursesException ("menu library error", err), NCursesException ("menu library error", err),
m (menu) m (menu)
{}; {};
NCursesMenuException& operator=(const NCursesMenuException& rhs)
{
if (this != &rhs) {
NCursesException::operator=(rhs);
m = rhs.m;
}
return *this;
}
NCursesMenuException(const NCursesMenuException& rhs)
: NCursesException(rhs), m(rhs.m)
{
}
virtual const char *classname() const { virtual const char *classname() const {
return "NCursesMenu"; return "NCursesMenu";
} }
virtual ~NCursesMenuException()
{
}
}; };
class NCURSES_IMPEXP NCursesFormException : public NCursesException class NCURSES_IMPEXP NCursesFormException : public NCursesException
{ {
public: public:
const NCursesForm* f; const NCursesForm* f;
NCursesFormException (const char *msg, int err) : NCursesFormException (const char *msg, int err) :
NCursesException (msg, err), NCursesException (msg, err),
f ((NCursesForm*)0) f (NULL)
{}; {};
NCursesFormException (const NCursesForm* form, NCursesFormException (const NCursesForm* form,
const char *msg, const char *msg,
int err) : int err) :
NCursesException (msg, err), NCursesException (msg, err),
f (form) f (form)
{}; {};
NCursesFormException (int err) : NCursesFormException (int err) :
NCursesException ("form library error", err), NCursesException ("form library error", err),
f ((NCursesForm*)0) f (NULL)
{}; {};
NCursesFormException (const NCursesForm* form, NCursesFormException (const NCursesForm* form,
int err) : int err) :
NCursesException ("form library error", err), NCursesException ("form library error", err),
f (form) f (form)
{}; {};
NCursesFormException& operator=(const NCursesFormException& rhs)
{
if (this != &rhs) {
NCursesException::operator=(rhs);
f = rhs.f;
}
return *this;
}
NCursesFormException(const NCursesFormException& rhs)
: NCursesException(rhs), f(rhs.f)
{
}
virtual const char *classname() const { virtual const char *classname() const {
return "NCursesForm"; return "NCursesForm";
} }
virtual ~NCursesFormException()
{
}
}; };
#if !((defined(__GNUG__) && defined(__EXCEPTIONS)) || defined(__SUNPRO_CC)) #if !((defined(__GNUG__) && defined(__EXCEPTIONS)) || defined(__SUNPRO_CC))
# include <iostream.h> # include <iostream.h>
extern "C" void exit(int); extern "C" void exit(int);
#endif #endif
inline void THROW(const NCursesException *e) { inline void THROW(const NCursesException *e) {
#if defined(__GNUG__) && defined(__EXCEPTIONS) #if defined(__GNUG__) && defined(__EXCEPTIONS)
# if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8)) # if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
skipping to change at line 291 skipping to change at line 364
#endif #endif
#else #else
if (e) if (e)
cerr << e->message << endl; cerr << e->message << endl;
exit(0); exit(0);
#endif #endif
} }
#define THROWS(s) #define THROWS(s)
#endif // NCURSES_ETIP_H_incl #endif /* NCURSES_ETIP_H_incl */
 End of changes. 20 change blocks. 
11 lines changed or deleted 84 lines changed or added


 form.h   form.h 
/************************************************************************** ** /************************************************************************** **
* Copyright (c) 1998-2002,2003 Free Software Foundation, Inc. * * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* * * *
* Permission is hereby granted, free of charge, to any person obtaining a * * Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the * * copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including * * "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, * * without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell * * distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is * * copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: * * furnished to do so, subject to the following conditions: *
* * * *
* The above copyright notice and this permission notice shall be included * * The above copyright notice and this permission notice shall be included *
skipping to change at line 33 skipping to change at line 33
* Except as contained in this notice, the name(s) of the above copyright * * 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 * * holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written * * sale, use or other dealings in this Software without prior written *
* authorization. * * authorization. *
************************************************************************** **/ ************************************************************************** **/
/************************************************************************** ** /************************************************************************** **
* Author: Juergen Pfeifer, 1995,1997 * * Author: Juergen Pfeifer, 1995,1997 *
************************************************************************** **/ ************************************************************************** **/
/* $Id: form.h,v 0.17 2003/11/08 20:39:08 tom Exp $ */ /* $Id: form.h,v 0.20 2004/12/04 22:22:10 tom Exp $ */
#ifndef FORM_H #ifndef FORM_H
#define FORM_H #define FORM_H
#include <ncurses/curses.h> #include <ncurses/curses.h>
#include <ncurses/eti.h> #include <ncurses/eti.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#ifndef FORM_PRIV_H
typedef void *FIELD_CELL;
#endif
#ifndef NCURSES_FIELD_INTERNALS
#define NCURSES_FIELD_INTERNALS /* nothing */
#endif
typedef int Form_Options; typedef int Form_Options;
typedef int Field_Options; typedef int Field_Options;
/********** /**********
* _PAGE * * _PAGE *
**********/ **********/
typedef struct { typedef struct {
short pmin; /* index of first field on page */ short pmin; /* index of first field on page */
short pmax; /* index of last field on page */ short pmax; /* index of last field on page */
short smin; /* index of top leftmost field on page */ short smin; /* index of top leftmost field on page */
short smax; /* index of bottom rightmost field on page */ short smax; /* index of bottom rightmost field on page */
} _PAGE; } _PAGE;
/********** /**********
* FIELD * * FIELD *
**********/ **********/
typedef struct fieldnode { typedef struct fieldnode {
unsigned short status; /* flags */ unsigned short status; /* flags */
short rows; /* size in rows */ short rows; /* size in rows
short cols; /* size in cols */ */
short frow; /* first row */ short cols; /* size in cols
short fcol; /* first col */ */
int drows; /* dynamic rows */ short frow; /* first row
int dcols; /* dynamic cols */ */
int maxgrow; /* maximum field growth */ short fcol; /* first col
int nrow; /* off-screen rows */ */
short nbuf; /* additional buffers */ int drows; /* dynamic rows */
short just; /* justification */ int dcols; /* dynamic cols */
short page; /* page on form */ int maxgrow; /* maximum field growth */
short index; /* into form -> field */ int nrow; /* off-screen rows */
int pad; /* pad character */ short nbuf; /* additional buffers
chtype fore; /* foreground attribute */ */
chtype back; /* background attribute */ short just; /* justification
Field_Options opts; /* options */ */
struct fieldnode * snext; /* sorted order pointer */ short page; /* page on form
struct fieldnode * sprev; /* sorted order pointer */ */
struct fieldnode * link; /* linked field chain */ short index; /* into form -> field
struct formnode * form; /* containing form */ */
struct typenode * type; /* field type */ int pad; /* pad character */
void * arg; /* argument for type */ chtype fore; /* foreground attribute */
char * buf; /* field buffers */ chtype back; /* background attribute */
void * usrptr; /* user pointer */ Field_Options opts; /* options
*/
struct fieldnode * snext; /* sorted order pointer */
struct fieldnode * sprev; /* sorted order pointer */
struct fieldnode * link; /* linked field chain */
struct formnode * form; /* containing form */
struct typenode * type; /* field type */
void * arg; /* argument for type */
FIELD_CELL * buf; /* field buffers */
void * usrptr; /* user pointer */
/*
* The wide-character configuration requires extra information. Because
* there are existing applications that manipulate the members of FIELD
* directly, we cannot make the struct opaque. Offsets of members up to
* this point are the same in the narrow- and wide-character configuratio
n.
* But note that the type of buf depends on the configuration, and is mad
e
* opaque for that reason.
*/
NCURSES_FIELD_INTERNALS
} FIELD; } FIELD;
/************** /**************
* FIELDTYPE * * FIELDTYPE *
**************/ **************/
typedef struct typenode { typedef struct typenode {
unsigned short status; /* flags */ unsigned short status; /* flags */
long ref; /* reference count */ long ref; /* reference count */
struct typenode * left; /* ptr to operand for | */ struct typenode * left; /* ptr to operand for | */
struct typenode * right; /* ptr to operand for | */ struct typenode * right; /* ptr to operand for | */
void* (*makearg)(va_list *); /* make fieldtype arg */ void* (*makearg)(va_list *); /* make fieldtype arg */
void* (*copyarg)(const void *); /* copy fieldtype arg */ void* (*copyarg)(const void *); /* copy fieldtype arg */
void (*freearg)(void *); /* free fieldtype arg */ void (*freearg)(void *); /* free fieldtype arg */
bool (*fcheck)(FIELD *,const void *); /* field validation */ bool (*fcheck)(FIELD *,const void *); /* field validation */
bool (*ccheck)(int,const void *); /* character validation */ bool (*ccheck)(int,const void *); /* character validation */
bool (*next)(FIELD *,const void *); /* enumerate next value */ bool (*next)(FIELD *,const void *); /* enumerate next value */
bool (*prev)(FIELD *,const void *); /* enumerate prev value */ bool (*prev)(FIELD *,const void *); /* enumerate prev value */
} FIELDTYPE; } FIELDTYPE;
/********* /*********
* FORM * * FORM *
*********/ *********/
typedef struct formnode { typedef struct formnode {
unsigned short status; /* flags */ unsigned short status; /* flags */
short rows; /* size in rows */ short rows; /* size in rows
short cols; /* size in cols */ */
int currow; /* current row in field window*/ short cols; /* size in cols
int curcol; /* current col in field window*/ */
int toprow; /* in scrollable field window */ int currow; /* current row in field window */
int begincol; /* in horiz. scrollable field */ int curcol; /* current col in field window */
short maxfield; /* number of fields */ int toprow; /* in scrollable field window */
short maxpage; /* number of pages */ int begincol; /* in horiz. scrollable field */
short curpage; /* index into page */ short maxfield; /* number of fields
Form_Options opts; /* options */ */
WINDOW * win; /* window */ short maxpage; /* number of pages
WINDOW * sub; /* subwindow */ */
WINDOW * w; /* window for current field */ short curpage; /* index into page
FIELD ** field; /* field [maxfield] */ */
FIELD * current; /* current field */ Form_Options opts; /* options */
_PAGE * page; /* page [maxpage] */ WINDOW * win; /* window */
void * usrptr; /* user pointer */ WINDOW * sub; /* subwindow */
WINDOW * w; /* window for current field */
FIELD ** field; /* field [maxfield] */
FIELD * current; /* current field */
_PAGE * page; /* page [maxpage] */
void * usrptr; /* user pointer */
void (*forminit)(struct formnode *); void (*forminit)(struct formnode *);
void (*formterm)(struct formnode *); void (*formterm)(struct formnode *);
void (*fieldinit)(struct formnode *); void (*fieldinit)(struct formnode *);
void (*fieldterm)(struct formnode *); void (*fieldterm)(struct formnode *);
} FORM; } FORM;
typedef void (*Form_Hook)(FORM *); typedef void (*Form_Hook)(FORM *);
/*************************** /***************************
* miscellaneous #defines * * miscellaneous #defines *
***************************/ ***************************/
/* field justification */ /* field justification */
#define NO_JUSTIFICATION (0) #define NO_JUSTIFICATION (0)
#define JUSTIFY_LEFT (1) #define JUSTIFY_LEFT (1)
#define JUSTIFY_CENTER (2) #define JUSTIFY_CENTER (2)
#define JUSTIFY_RIGHT (3) #define JUSTIFY_RIGHT (3)
/* field options */ /* field options */
#define O_VISIBLE (0x0001) #define O_VISIBLE (0x0001U)
#define O_ACTIVE (0x0002) #define O_ACTIVE (0x0002U)
#define O_PUBLIC (0x0004) #define O_PUBLIC (0x0004U)
#define O_EDIT (0x0008) #define O_EDIT (0x0008U)
#define O_WRAP (0x0010) #define O_WRAP (0x0010U)
#define O_BLANK (0x0020) #define O_BLANK (0x0020U)
#define O_AUTOSKIP (0x0040) #define O_AUTOSKIP (0x0040U)
#define O_NULLOK (0x0080) #define O_NULLOK (0x0080U)
#define O_PASSOK (0x0100) #define O_PASSOK (0x0100U)
#define O_STATIC (0x0200) #define O_STATIC (0x0200U)
/* form options */ /* form options */
#define O_NL_OVERLOAD (0x0001) #define O_NL_OVERLOAD (0x0001U)
#define O_BS_OVERLOAD (0x0002) #define O_BS_OVERLOAD (0x0002U)
/* form driver commands */ /* form driver commands */
#define REQ_NEXT_PAGE (KEY_MAX + 1) /* move to next page */ #define REQ_NEXT_PAGE (KEY_MAX + 1) /* move to next page */
#define REQ_PREV_PAGE (KEY_MAX + 2) /* move to previous page */ #define REQ_PREV_PAGE (KEY_MAX + 2) /* move to previous page */
#define REQ_FIRST_PAGE (KEY_MAX + 3) /* move to first page */ #define REQ_FIRST_PAGE (KEY_MAX + 3) /* move to first page */
#define REQ_LAST_PAGE (KEY_MAX + 4) /* move to last page */ #define REQ_LAST_PAGE (KEY_MAX + 4) /* move to last page */
#define REQ_NEXT_FIELD (KEY_MAX + 5) /* move to next field */ #define REQ_NEXT_FIELD (KEY_MAX + 5) /* move to next field */
#define REQ_PREV_FIELD (KEY_MAX + 6) /* move to previous field */ #define REQ_PREV_FIELD (KEY_MAX + 6) /* move to previous field */
#define REQ_FIRST_FIELD (KEY_MAX + 7) /* move to first field */ #define REQ_FIRST_FIELD (KEY_MAX + 7) /* move to first field */
skipping to change at line 222 skipping to change at line 239
#define REQ_DEL_WORD (KEY_MAX + 37) /* delete word at cursor */ #define REQ_DEL_WORD (KEY_MAX + 37) /* delete word at cursor */
#define REQ_CLR_EOL (KEY_MAX + 38) /* clear to end of line */ #define REQ_CLR_EOL (KEY_MAX + 38) /* clear to end of line */
#define REQ_CLR_EOF (KEY_MAX + 39) /* clear to end of field */ #define REQ_CLR_EOF (KEY_MAX + 39) /* clear to end of field */
#define REQ_CLR_FIELD (KEY_MAX + 40) /* clear entire field */ #define REQ_CLR_FIELD (KEY_MAX + 40) /* clear entire field */
#define REQ_OVL_MODE (KEY_MAX + 41) /* begin overlay mode */ #define REQ_OVL_MODE (KEY_MAX + 41) /* begin overlay mode */
#define REQ_INS_MODE (KEY_MAX + 42) /* begin insert mode */ #define REQ_INS_MODE (KEY_MAX + 42) /* begin insert mode */
#define REQ_SCR_FLINE (KEY_MAX + 43) /* scroll field forward a line */ #define REQ_SCR_FLINE (KEY_MAX + 43) /* scroll field forward a line */
#define REQ_SCR_BLINE (KEY_MAX + 44) /* scroll field backward a line */ #define REQ_SCR_BLINE (KEY_MAX + 44) /* scroll field backward a line */
#define REQ_SCR_FPAGE (KEY_MAX + 45) /* scroll field forward a page */ #define REQ_SCR_FPAGE (KEY_MAX + 45) /* scroll field forward a page */
#define REQ_SCR_BPAGE (KEY_MAX + 46) /* scroll field backward a page */ #define REQ_SCR_BPAGE (KEY_MAX + 46) /* scroll field backward a page */
#define REQ_SCR_FHPAGE (KEY_MAX + 47) /* scroll field forward half page #define REQ_SCR_FHPAGE (KEY_MAX + 47) /* scroll field forward half page *
*/ /
#define REQ_SCR_BHPAGE (KEY_MAX + 48) /* scroll field backward half page #define REQ_SCR_BHPAGE (KEY_MAX + 48) /* scroll field backward half page *
*/ /
#define REQ_SCR_FCHAR (KEY_MAX + 49) /* horizontal scroll char #define REQ_SCR_FCHAR (KEY_MAX + 49) /* horizontal scroll char */
*/ #define REQ_SCR_BCHAR (KEY_MAX + 50) /* horizontal scroll char */
#define REQ_SCR_BCHAR (KEY_MAX + 50) /* horizontal scroll char #define REQ_SCR_HFLINE (KEY_MAX + 51) /* horizontal scroll line */
*/ #define REQ_SCR_HBLINE (KEY_MAX + 52) /* horizontal scroll line */
#define REQ_SCR_HFLINE (KEY_MAX + 51) /* horizontal scroll line #define REQ_SCR_HFHALF (KEY_MAX + 53) /* horizontal scroll half line */
*/ #define REQ_SCR_HBHALF (KEY_MAX + 54) /* horizontal scroll half line */
#define REQ_SCR_HBLINE (KEY_MAX + 52) /* horizontal scroll line
*/
#define REQ_SCR_HFHALF (KEY_MAX + 53) /* horizontal scroll half line
*/
#define REQ_SCR_HBHALF (KEY_MAX + 54) /* horizontal scroll half line
*/
#define REQ_VALIDATION (KEY_MAX + 55) /* validate field */ #define REQ_VALIDATION (KEY_MAX + 55) /* validate field */
#define REQ_NEXT_CHOICE (KEY_MAX + 56) /* display next field choice */ #define REQ_NEXT_CHOICE (KEY_MAX + 56) /* display next field choice */
#define REQ_PREV_CHOICE (KEY_MAX + 57) /* display prev field choice */ #define REQ_PREV_CHOICE (KEY_MAX + 57) /* display prev field choice */
#define MIN_FORM_COMMAND (KEY_MAX + 1) /* used by form_driver */ #define MIN_FORM_COMMAND (KEY_MAX + 1) /* used by form_driver */
#define MAX_FORM_COMMAND (KEY_MAX + 57) /* used by form_driver */ #define MAX_FORM_COMMAND (KEY_MAX + 57) /* used by form_driver */
#if defined(MAX_COMMAND) #if defined(MAX_COMMAND)
# if (MAX_FORM_COMMAND > MAX_COMMAND) # if (MAX_FORM_COMMAND > MAX_COMMAND)
skipping to change at line 258 skipping to change at line 275
/************************* /*************************
* standard field types * * standard field types *
*************************/ *************************/
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_ALPHA; extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_ALPHA;
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_ALNUM; extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_ALNUM;
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_ENUM; extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_ENUM;
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_INTEGER; extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_INTEGER;
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_NUMERIC; extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_NUMERIC;
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_REGEXP; extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_REGEXP;
/************************************ /************************************
* built-in additional field types * * built-in additional field types *
* They are not defined in SVr4 * * They are not defined in SVr4 *
************************************/ ************************************/
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_IPV4; /* Internet IP Versi on 4 address */ extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_IPV4; /* Internet IP Versi on 4 address */
/*********************** /***********************
* Default objects * * Default objects *
***********************/ ***********************/
extern NCURSES_EXPORT_VAR(FORM *) _nc_Default_Form; extern NCURSES_EXPORT_VAR(FORM *) _nc_Default_Form;
extern NCURSES_EXPORT_VAR(FIELD *) _nc_Default_Field; extern NCURSES_EXPORT_VAR(FIELD *) _nc_Default_Field;
/*********************** /***********************
* FIELDTYPE routines * * FIELDTYPE routines *
***********************/ ***********************/
extern NCURSES_EXPORT(FIELDTYPE *) new_fieldtype ( extern NCURSES_EXPORT(FIELDTYPE *) new_fieldtype (
bool (* const field_check)(FIELD *,const void *), bool (* const field_check)(FIELD *,const void *),
bool (* const char_check)(int,const void *)), bool (* const char_check)(int,const void *));
*link_fieldtype(FIELDTYPE *,FIELDTYPE *); extern NCURSES_EXPORT(FIELDTYPE *) link_fieldtype(
FIELDTYPE *, FIELDTYPE *);
extern NCURSES_EXPORT(int) free_fieldtype (FIELDTYPE *); extern NCURSES_EXPORT(int) free_fieldtype (FIELDTYPE *);
extern NCURSES_EXPORT(int) set_fieldtype_arg (FIELDTYPE *, extern NCURSES_EXPORT(int) set_fieldtype_arg (FIELDTYPE *,
void * (* const make_arg)(va_list *), void * (* const make_arg)(va_list *),
void * (* const copy_arg)(const void *), void * (* const copy_arg)(const void *),
void (* const free_arg)(void *)); void (* const free_arg)(void *));
extern NCURSES_EXPORT(int) set_fieldtype_choice (FIELDTYPE *, extern NCURSES_EXPORT(int) set_fieldtype_choice (FIELDTYPE *,
bool (* const next_choice)(FIELD *,const void *), bool (* const next_choice)(FIELD *,const void *),
bool (* const prev_choice)(FIELD *,const void *)); bool (* const prev_choice)(FIELD *,const void *));
 End of changes. 18 change blocks. 
99 lines changed or deleted 127 lines changed or added


 term.h   term.h 
skipping to change at line 45 skipping to change at line 45
/* $Id: MKterm.h.awk.in,v 1.42 2003/12/27 19:09:16 tom Exp $ */ /* $Id: MKterm.h.awk.in,v 1.42 2003/12/27 19:09:16 tom Exp $ */
/* /*
** term.h -- Definition of struct term ** term.h -- Definition of struct term
*/ */
#ifndef NCURSES_TERM_H_incl #ifndef NCURSES_TERM_H_incl
#define NCURSES_TERM_H_incl 1 #define NCURSES_TERM_H_incl 1
#undef NCURSES_VERSION #undef NCURSES_VERSION
#define NCURSES_VERSION "5.4" #define NCURSES_VERSION "5.5"
#include <ncurses/ncurses_dll.h> #include <ncurses/ncurses_dll.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* Make this file self-contained by providing defaults for the HAVE_TERMIO[ S]_H /* Make this file self-contained by providing defaults for the HAVE_TERMIO[ S]_H
* definition (based on the system for which this was configured). * definition (based on the system for which this was configured).
*/ */
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 termcap.h   termcap.h 
skipping to change at line 40 skipping to change at line 40
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> * * and: Eric S. Raymond <esr@snark.thyrsus.com> *
************************************************************************** **/ ************************************************************************** **/
/* $Id: termcap.h.in,v 1.16 2001/03/24 21:53:27 tom Exp $ */ /* $Id: termcap.h.in,v 1.16 2001/03/24 21:53:27 tom Exp $ */
#ifndef NCURSES_TERMCAP_H_incl #ifndef NCURSES_TERMCAP_H_incl
#define NCURSES_TERMCAP_H_incl 1 #define NCURSES_TERMCAP_H_incl 1
#undef NCURSES_VERSION #undef NCURSES_VERSION
#define NCURSES_VERSION "5.4" #define NCURSES_VERSION "5.5"
#include <ncurses/ncurses_dll.h> #include <ncurses/ncurses_dll.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#endif /* __cplusplus */ #endif /* __cplusplus */
#include <sys/types.h> #include <sys/types.h>
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 unctrl.h   unctrl.h 
skipping to change at line 48 skipping to change at line 48
* Control characters are displayed in caret notation (^x), DELETE is displ ayed * Control characters are displayed in caret notation (^x), DELETE is displ ayed
* as ^?. Printable characters are displayed as is. * as ^?. Printable characters are displayed as is.
*/ */
/* $Id: unctrl.h.in,v 1.10 2001/03/24 21:53:25 tom Exp $ */ /* $Id: unctrl.h.in,v 1.10 2001/03/24 21:53:25 tom Exp $ */
#ifndef NCURSES_UNCTRL_H_incl #ifndef NCURSES_UNCTRL_H_incl
#define NCURSES_UNCTRL_H_incl 1 #define NCURSES_UNCTRL_H_incl 1
#undef NCURSES_VERSION #undef NCURSES_VERSION
#define NCURSES_VERSION "5.4" #define NCURSES_VERSION "5.5"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include <ncurses/curses.h> #include <ncurses/curses.h>
#undef unctrl #undef unctrl
NCURSES_EXPORT(NCURSES_CONST char *) unctrl (chtype); NCURSES_EXPORT(NCURSES_CONST char *) unctrl (chtype);
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/