/* Filename: Screen.h * Size: 3.20kB * Last Modified: Sat Jun 24 17:36:08 2006 * Author: Ben Hearsum * * This comment was automatically generated by header.pl * http://www.wittydomain.com/software */ #ifndef SCREEN_H #define SCREEN_H #include #include extern "C" { #include "dtio.h" } using namespace std; class Screen; /* an field of text with a certain starting position, length, and editability */ class Field { protected: int row, col, len; bool is_editable; char *d; int c_pos; public: /* constructors/destructors */ Field(int r, int c, int width, const char *s="\0", bool edit=true); Field(const Field &right); Field(); virtual ~Field(); /* overloaded operators */ virtual const Field& operator=(const Field &right); /* required for using STL list */ virtual bool operator==(const Field &right); virtual bool operator!=(const Field &right); /* required for STL list, but is not meaningful */ virtual int operator<(const Field &right) { return 0; }; /* public functions */ virtual void init(int r=0, int c=0, int width=0, const char *s="\0", bool edit=true); virtual void display(); virtual int edit(Screen *sptr=NULL); virtual bool editable()const { return is_editable; }; virtual int getRow()const { return row; }; virtual int getCol()const { return col; }; virtual int getLen()const { return len; }; virtual void *data()const { return d; }; virtual Field *clone()const; virtual void setData(const char *s, int l); virtual void setRow(int r); virtual void setCol(int c); virtual void setLen(int l); private: /* internal functions */ void setcPos(int c); }; #define MAX_FIELDS 50 /* a container for a certain amount of Fields */ class Screen { Field *fields[MAX_FIELDS]; int f_pos; int size; public: /* constructors/destructors */ Screen(int row, int col, int len, const char *s=NULL, bool editable=true); Screen(const Screen &right):f_pos(0),size(0) { *this = right; }; Screen():f_pos(0),size(0) {}; virtual ~Screen(); /* overloaded operators */ Screen& operator=(const Screen &right); Screen& operator+=(const Field &right); /* public functions */ int add(int row, int col, int len, const char *s=NULL, bool editable=true); int add(const Field &f); void display(bool clear=false); int edit(bool clear=false) { return edit(NULL, clear); }; int edit(int *pfield=NULL, bool clear=false); Field *getField(int n); int remove(int n); }; class Label: public Field { char *str; bool dynamic; public: Label(int r, int c, int width, const char *s=NULL); virtual ~Label(); void *data()const { return str; } void display(); Label *clone()const; private: void init(int r, int c, int width, const char *s=NULL); }; class Response: public Field { int d; char *valid_chars; void (*response_f)(Screen *); public: Response(int r, int c, const char *s, int ch=' ', void (*fptr)(Screen*)=NULL); ~Response(); void init(int r, int c, const char *s, int ch=' ', void (*fptr)(Screen *)=NULL); int edit(Screen *sptr=NULL); int data() { return d; } void setData(int c) { d = c; } void display(); Response* clone()const; }; class VField: public Field { int (*validate_f)(char [], Screen *); public: VField(int r, int c, int w, const char *s="\0", int (*fptr)(char [], Screen *)=NULL); ~VField(); int edit(Screen *sptr=NULL); void setData(const char *s, int l); VField* clone()const; private: void init(int r, int c, int w, const char *s="\0", int (*fptr)(char [], Screen *)=NULL); }; #endif