Open main menu

CDOT Wiki β

Console Framework Classes 20103 - OOP344

Revision as of 13:03, 8 November 2010 by Fardad (talk | contribs) (FWLineEdit)

The Frame work

General Internal Header file

#ifndef ___CONFW_H__
#define ___CONFW_H__

 #ifndef _CRT_SECURE_NO_DEPRECATE
 #define _CRT_SECURE_NO_DEPRECATE
 #endif
 #ifndef _CRT_SECURE_NO_WARNINGS
 #define _CRT_SECURE_NO_WARNINGS
 #endif
#include <string.h>

extern "C"{
 #include "iol.h"
};

#define FW_BORDER_CHARS  "/-\\|/-\\|"

#define FW_MAX_NO_FIELDS 100
#define FW_BUTTON_HIT 1
#define FW_MAX_LINE_CHARS  (1024u)

#define FW_REFRESH -2
#define FW_FULL_FRAME -1
#define FW_NO_REFRESH 0


enum MessageStatus{ClearMessage,SetMessage};


#ifdef NO_HELPFUNC
# undef NO_HELPFUNC
#endif
#define NO_HELPFUNC ((void(*)(MessageStatus, FWDialog&))(0))
#ifdef NO_VALDFUNC
# undef NO_VALDFUNC
#endif
#define NO_VALDFUNC ((bool(*)(const char*, FWDialog&))(0))

#endif

Classes

FWBorder

Class Definition

class FWBorder {
  int _row;
  int _col;
  int _height;
  int _width;
  char _border[9];
  bool _visible;
  FWBorder* _container;

protected:
  int absRow()const;
  int absCol()const;
public:
  FWBorder(int Row=-1, int Col=-1, int Width=-1,int Height=-1,
    bool Visible = false, 
    const char* Border=FW_BORDER_CHARS,
    FWBorder* Container = (FWBorder*)0);

  virtual void draw(int refresh = FW_NO_REFRESH)const;
  virtual ~FWBorder();
  
  void visible(bool val);
  bool visible()const;

  void container(FWBorder* theContainer);
  FWBorder* container();

  bool fullscreen()const;

  void row(int val);
  int row()const;

  void col(int val);
  int col()const;

  void size(int height, int width);
  int height()const;
  int width()const;
};

Border Tester

BorederTester.cpp

FWField

class FWField: public FWBorder{
protected:
  void* _data;
public:
  FWField(int Row = 0, int Col = 0, 
         int Width = 0, int Height =0,
         void* Data = (void*) 0, 
         bool Bordered = false,
         const char* Border=FW_BORDER_CHARS);
  ~FWField();
  virtual int edit() = 0;
  virtual bool editable() const = 0;
 
  
  virtual void set(const void* data) = 0;
  virtual void* data();

  void container(FWDialog* theOwner);
  FWDialog* container();
};

FWLabel

 class  FWLabel: public FWField{
   int _length;
   void aloCpy(const char* str, int len = -1);
 public:
   FWLabel(const char *Str, int Row, int Col, 
     int Len = -1);
   FWLabel(int Row, int Col, int Len);
   ~FWLabel();
   void draw(int Refresh = FW_NO_REFRESH) const;
   int edit();
   bool editable()const;
   void set(const void* str);
 };

FWDialog

Class Definition

class FWDialog: public FWBorder{
  private:
  int _fnum;
  int _curidx;
  FWField* _fld[FW_MAX_NO_FIELDS];
  bool _dyn[FW_MAX_NO_FIELDS];
  bool _editable;
  public:
  FWDialog(FWBorder *Container = (FWBorder*)0,
           int Row = -1, int Col = -1, 
           int Width = -1, int Height = -1, 
           bool Borderd = false,
           const char* Border=FW_BORDER_CHARS);
  virtual ~FWDialog();
  void draw(int fn = FW_NO_REFRESH)const;
  int edit(int fn = FW_NO_REFRESH);


  int add(FWField* field, bool dynamic = true);
  int add(FWField& field, bool dynamic = false);
  FWDialog& operator<<(FWField* field);
  FWDialog& operator<<(FWField& field);


  bool editable();
  int fieldNum()const;
  int curIndex()const;


  FWField& operator[](unsigned int index);
  FWField& curField();
};

Dialog and Label Tester

Test2DialogAndLabel.cpp

FWLineEdit

Class Definition

class FWLineEdit: public FWField{
  bool _dyn;
  int _maxdatalen;
  int* _insertmode;
  int _curpos;
  int _offset;
public:
  FWLineEdit(char* Str, int Row, int Col, int Width,
    int Maxdatalen, int* Insertmode, 
    bool Bordered = false,
          const char* Border=FW_BORDER_CHARS);
  FWLineEdit(int Row, int Col, int Width,
    int Maxdatalen, int* Insertmode, 
    bool Bordered = false,
          const char* Border=FW_BORDER_CHARS);
  ~FWLineEdit();
  void draw(int Refresh = FW_NO_REFRESH)const;
 
  int edit();
  bool editable()const;

  void  set(const void* Str);
};

Dialog and Line editor Tester

DialogAndLineEditor.cpp

FWButton

 class  FWButton: public FWField{
   int _length;
 public:
   FWButton(const char *Str, int Row, int Col, 
            bool Bordered = true,
            const char* Border=FW_BORDER_CHARS);
   virtual ~FWButton();
   void draw(int Refresh = FW_NO_REFRESH) const;
   int edit();
   bool editable()const;
   void set(const void* str);
 };

FWCHECK

class FWCheck : public FWLabel {
  int _flag;
  int _radio;
  char _format[4];
public:
  FWCheck(bool Checked,const char* Format, const char* Text, int Row, int Col, bool IsRadio = false);
  void draw(int Refresh = FW_NO_REFRESH) const;
  int edit();
  bool editable()const;
  void set(const void* flag);
  void *data();
};

FWValEdit

class FWValEdit: public FWLineEdit{
  void (*_help)(MessageStatus, FWDialog&);
  bool (*_validate)(const char*, FWDialog&);
public:
  FWValEdit(char* Str, int Row, int Col, int Width,
        int Maxdatalen, int* Insertmode,
        bool (*Validate)(const char* , FWDialog&) = NO_VALDFUNC, 
        void (*Help)(MessageStatus, FWDialog&) = NO_HELPFUNC,
        bool Bordered = false,
        const char* Border=FW_BORDER_CHARS);
  FWValEdit(int Row, int Col, int Width,
        int Maxdatalen, int* Insertmode,
        bool (*Validate)(const char* , FWDialog&) = NO_VALDFUNC, 
        void (*Help)(MessageStatus, FWDialog&) = NO_HELPFUNC,
        bool Bordered = false,
        const char* Border=FW_BORDER_CHARS);
  int edit();
};