X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=c%2B%2B%2Fcursesf.h;h=abd2a7dcc7dc2ea4667102920d51d2f0d4dcf47f;hp=d90a852081dfa10d943148d75832f620811214ba;hb=46722468f47c2b77b3987729b4bcf2321cccfd01;hpb=661078ddbde3ce0f3b06e95642fbb9b5fef7dca1 diff --git a/c++/cursesf.h b/c++/cursesf.h index d90a8520..abd2a7dc 100644 --- a/c++/cursesf.h +++ b/c++/cursesf.h @@ -1,6 +1,6 @@ // * This makes emacs happy -*-Mode: C++;-*- /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,2000,2001 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -28,15 +28,17 @@ ****************************************************************************/ /**************************************************************************** - * Author: Juergen Pfeifer 1997 * + * Author: Juergen Pfeifer, 1997 * + * Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en * ****************************************************************************/ -// $Id: cursesf.h,v 1.6 1998/02/11 12:13:41 tom Exp $ +// $Id: cursesf.h,v 1.17 2002/07/06 15:47:52 juergen Exp $ -#ifndef _CURSESF_H -#define _CURSESF_H +#ifndef NCURSES_CURSESF_H_incl +#define NCURSES_CURSESF_H_incl 1 #include +#include extern "C" { # include @@ -46,11 +48,11 @@ extern "C" { // The abstract base class for buitin and user defined Fieldtypes. // ------------------------------------------------------------------------- // -class NCursesFormField; // forward declaration +class NCURSES_IMPEXP NCursesFormField; // forward declaration // Class to represent builtin field types as well as C++ written new // fieldtypes (see classes UserDefineFieldType... -class NCursesFieldType { +class NCURSES_IMPEXP NCursesFieldType { friend class NCursesFormField; protected: @@ -79,7 +81,7 @@ public: // The class representing a forms field, wrapping the lowlevel FIELD struct // ------------------------------------------------------------------------- // -class NCursesFormField { +class NCURSES_IMPEXP NCursesFormField { friend class NCursesForm; protected: @@ -91,10 +93,10 @@ protected: if (err != E_OK) THROW(new NCursesFormException (err)); } - + public: // Create a 'Null' field. Can be used to delimit a field list - NCursesFormField() + NCursesFormField() : field((FIELD*)0), ftype((NCursesFieldType*)0) { } @@ -104,14 +106,14 @@ public: int first_row = 0, int first_col = 0, int offscreen_rows = 0, - int additional_buffers = 0) + int additional_buffers = 0) : ftype((NCursesFieldType*)0) { field = ::new_field(rows,cols,first_row,first_col, offscreen_rows, additional_buffers); if (!field) OnError(errno); } - + virtual ~NCursesFormField (); // Duplicate the field at a new position @@ -255,7 +257,7 @@ public: // Return the index of the field in the field array of a form // or -1 if the field is not associated to a form - inline int index() const { + inline int (index)() const { return ::field_index(field); } @@ -264,7 +266,7 @@ public: OnError(::set_field_buffer(field,buffer,val)); } - // Retrieve the value of a fields buffer. The defaukt buffer is nr. 0 + // Retrieve the value of a fields buffer. The default buffer is nr. 0 inline char* value(int buffer = 0) const { return ::field_buffer(field,buffer); } @@ -287,7 +289,7 @@ public: // The class representing a form, wrapping the lowlevel FORM struct // ------------------------------------------------------------------------- // -class NCursesForm : public NCursesPanel { +class NCURSES_IMPEXP NCursesForm : public NCursesPanel { protected: FORM* form; // the lowlevel structure @@ -310,7 +312,7 @@ private: // Get the backward pointer to the C++ object from a FORM static inline NCursesForm* getHook(const FORM *f) { UserHook* hook = (UserHook*)::form_userptr(f); - assert(hook && hook->m_owner==f); + assert(hook != 0 && hook->m_owner==f); return (NCursesForm*)(hook->m_back); } @@ -321,24 +323,24 @@ private: static void frm_term(FORM *); static void fld_init(FORM *); static void fld_term(FORM *); - + // Calculate FIELD* array for the menu FIELD** mapFields(NCursesFormField* nfields[]); -protected: - // internal routines +protected: + // internal routines inline void set_user(void *user) { UserHook* uptr = (UserHook*)::form_userptr (form); - assert (uptr && uptr->m_back==this && uptr->m_owner==form); + assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==form); uptr->m_user = user; } inline void *get_user() { UserHook* uptr = (UserHook*)::form_userptr (form); - assert (uptr && uptr->m_back==this && uptr->m_owner==form); + assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==form); return uptr->m_user; - } - + } + void InitForm (NCursesFormField* Fields[], bool with_frame, bool autoDeleteFields); @@ -353,14 +355,14 @@ protected: // 'Internal' constructor, builds an object without association to a // field array. - NCursesForm( int lines, - int cols, - int begin_y = 0, - int begin_x = 0) - : NCursesPanel(lines,cols,begin_y,begin_x), + NCursesForm( int lines, + int cols, + int begin_y = 0, + int begin_x = 0) + : NCursesPanel(lines,cols,begin_y,begin_x), form ((FORM*)0) { } - + public: // Create form for the default panel. NCursesForm (NCursesFormField* Fields[], @@ -372,9 +374,9 @@ public: // Create a form in a panel with the given position and size. NCursesForm (NCursesFormField* Fields[], - int lines, - int cols, - int begin_y, + int lines, + int cols, + int begin_y, int begin_x, bool with_frame=FALSE, // reserve space for a frame? bool autoDelete_Fields=FALSE) // do automatic cleanup? @@ -397,17 +399,17 @@ public: // Set these fields for the form inline void setFields(NCursesFormField* Fields[]) { - OnError(::set_form_fields(form,mapFields(Fields))); + OnError(::set_form_fields(form,mapFields(Fields))); } // Remove the form from the screen - inline void unpost (void) { - OnError (::unpost_form (form)); + inline void unpost (void) { + OnError (::unpost_form (form)); } - + // Post the form to the screen if flag is true, unpost it otherwise inline void post(bool flag = TRUE) { - OnError (flag ? ::post_form(form) : ::unpost_form (form)); + OnError (flag ? ::post_form(form) : ::unpost_form (form)); } // Decorations @@ -424,7 +426,7 @@ public: else OnError(E_SYSTEM_ERROR); } - + inline void label(const char *topLabel, const char *bottomLabel) { if (b_framed) NCursesPanel::label(topLabel,bottomLabel); @@ -540,7 +542,7 @@ public: // data belongs to some class T. Use T as template argument // to create a UserField. // ------------------------------------------------------------------------- -template class NCursesUserField : public NCursesFormField +template class NCURSES_IMPEXP NCursesUserField : public NCursesFormField { public: NCursesUserField (int rows, @@ -573,23 +575,23 @@ public: // The same mechanism is used to attach user data to a form // ------------------------------------------------------------------------- // -template class NCursesUserForm : public NCursesForm +template class NCURSES_IMPEXP NCursesUserForm : public NCursesForm { protected: // 'Internal' constructor, builds an object without association to a // field array. - NCursesUserForm( int lines, - int cols, - int begin_y = 0, + NCursesUserForm( int lines, + int cols, + int begin_y = 0, int begin_x = 0, - const T* p_UserData = (T*)0) + const T* p_UserData = (T*)0) : NCursesForm(lines,cols,begin_y,begin_x) { if (form) set_user ((void *)p_UserData); } public: - NCursesUserForm (NCursesFormField Fields[], + NCursesUserForm (NCursesFormField Fields[], bool with_frame=FALSE, bool autoDelete_Fields=FALSE) : NCursesForm (Fields, with_frame, autoDelete_Fields) { @@ -603,11 +605,11 @@ public: if (form) set_user ((void *)p_UserData); }; - + NCursesUserForm (NCursesFormField Fields[], - int lines, - int cols, - int begin_y = 0, + int lines, + int cols, + int begin_y = 0, int begin_x = 0, const T* p_UserData = (T*)0, bool with_frame=FALSE, @@ -616,11 +618,11 @@ public: with_frame, autoDelete_Fields) { if (form) set_user ((void *)p_UserData); - }; - + }; + virtual ~NCursesUserForm() { }; - + inline T* UserData (void) const { return (T*)get_user (); }; @@ -636,7 +638,7 @@ public: // Builtin Fieldtypes // ------------------------------------------------------------------------- // -class Alpha_Field : public NCursesFieldType { +class NCURSES_IMPEXP Alpha_Field : public NCursesFieldType { private: int min_field_width; @@ -645,13 +647,13 @@ private: } public: - Alpha_Field(int width) + Alpha_Field(int width) : NCursesFieldType(TYPE_ALPHA), min_field_width(width) { } }; -class Alphanumeric_Field : public NCursesFieldType { +class NCURSES_IMPEXP Alphanumeric_Field : public NCursesFieldType { private: int min_field_width; @@ -660,13 +662,13 @@ private: } public: - Alphanumeric_Field(int width) + Alphanumeric_Field(int width) : NCursesFieldType(TYPE_ALNUM), min_field_width(width) { } }; -class Integer_Field : public NCursesFieldType { +class NCURSES_IMPEXP Integer_Field : public NCursesFieldType { private: int precision; long lower_limit, upper_limit; @@ -678,12 +680,12 @@ private: public: Integer_Field(int prec, long low=0L, long high=0L) - : NCursesFieldType(TYPE_INTEGER), + : NCursesFieldType(TYPE_INTEGER), precision(prec), lower_limit(low), upper_limit(high) { } }; -class Numeric_Field : public NCursesFieldType { +class NCURSES_IMPEXP Numeric_Field : public NCursesFieldType { private: int precision; double lower_limit, upper_limit; @@ -695,12 +697,12 @@ private: public: 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) { } }; -class Regular_Expression_Field : public NCursesFieldType { +class NCURSES_IMPEXP Regular_Expression_Field : public NCursesFieldType { private: char* regex; @@ -711,8 +713,8 @@ private: public: Regular_Expression_Field(const char *expr) : NCursesFieldType(TYPE_REGEXP) { - regex = new char[1+::strlen(expr)]; - strcpy(regex,expr); + regex = new char[1 + ::strlen(expr)]; + (::strcpy)(regex,expr); } ~Regular_Expression_Field() { @@ -720,7 +722,7 @@ public: } }; -class Enumeration_Field : public NCursesFieldType { +class NCURSES_IMPEXP Enumeration_Field : public NCursesFieldType { private: char** list; int case_sensitive; @@ -741,7 +743,7 @@ public: } }; -class IPV4_Address_Field : public NCursesFieldType { +class NCURSES_IMPEXP IPV4_Address_Field : public NCursesFieldType { private: void set(NCursesFormField& f) { OnError(::set_field_type(f.get_field(),fieldtype)); @@ -756,12 +758,12 @@ public: // Abstract base class for User-Defined Fieldtypes // ------------------------------------------------------------------------- // -class UserDefinedFieldType : public NCursesFieldType { - friend class UDF_Init; // Internal helper to set up statics +class NCURSES_IMPEXP UserDefinedFieldType : public NCursesFieldType { + friend class UDF_Init; // Internal helper to set up statics private: // For all C++ defined fieldtypes we need only one generic lowlevel // FIELDTYPE* element. - static FIELDTYPE* generic_fieldtype; + static FIELDTYPE* generic_fieldtype; protected: // This are the functions required by the low level libforms functions @@ -792,10 +794,10 @@ public: // Abstract base class for User-Defined Fieldtypes with Choice functions // ------------------------------------------------------------------------- // -class UserDefinedFieldType_With_Choice : public UserDefinedFieldType { - friend class UDF_Init; // Internal helper to set up statics +class NCURSES_IMPEXP UserDefinedFieldType_With_Choice : public UserDefinedFieldType { + friend class UDF_Init; // Internal helper to set up statics 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. static FIELDTYPE* generic_fieldtype_with_choice; @@ -819,5 +821,5 @@ public: } }; -#endif // _CURSESF_H +#endif // NCURSES_CURSESF_H_incl