// Header for module TMenu, generated by p2c 1.21alpha-07.Dec.93
#ifndef TMENU_H
#define TMENU_H




#ifndef STRTYPE_H
#include "/software/include/p2c/strtype.h"
#endif

#ifndef KEYCONST_H
#include "/software/include/p2c/keyconst.h"
#endif

#include <curses.h>


#ifdef TMENU_G
# define vextern
#else
# define vextern extern
#endif


#define _CRLF_          "\n"

                                
#ifdef WITH_X_COLORS

  #define fmShadowColor		0x03   // dark cyan on black
  #define fmInputColor		0x06   // yellow on black 
  
  #define pgMenuColor		0x030
  #define pgMenuHighColor	0x037
  #define pgMenuDisplayColor	0x031
  #define pgFrameColor		0x017
  #define pgFrameHighColor	0x016
  #define pgFrameDisplayColor	0x010

#else       // PC-Style-Colors                    

  #define fmShadowColor		0x08   // darkgray on black    
  #define fmInputColor		0x0c   // lightred on black 

  #define pgMenuColor		0x030
  #define pgMenuHighColor	0x03f
  #define pgMenuDisplayColor	0x03e
  #define pgFrameColor		0x01f
  #define pgFrameHighColor	0x01f
  #define pgFrameDisplayColor	0x01f

#endif

#define NoCursor()	curs_set(0)
#define CursorOn()	curs_set(1)
#define BigCursor()	curs_set(2)

#define fmSpecialUp     '\200'
#define fmSpecialDown   '\201'
#define fmSpecialLeft   '\202'
#define fmSpecialRight  '\203'
#define fmRightButton   '\377'
#define fmLeftButton    '\376'
#define fmDoubleLeft    '\375'
#define fmBothButton    '\374'

#define MaxMenu         30
#define MaxItem         30

#define black           0
#define blue            1
#define green           2
#define cyan            3
#define red             4
#define magenta         5
#define brown           6
#define lightgray       7
#define darkgray        8
#define lightblue       9
#define lightgreen      10
#define lightcyan       11
#define lightred        12
#define lightmagenta    13
#define yellow          14
#define white           15


#define font8x8         256
#define mono            7
#define co80            3
#define co40            1
#define bw80            2
#define bw40            0


enum AreaType {
  Horiz, Vert, VertAsk
};

struct MenuInitRecType {
  uchar X, Y, NC, HiC, AsC, Tp;
  char ST[256];
};

typedef char InitStringType[256];

struct CA_Type {
   unsigned char a;
   chtype _ec;
};

struct WBuf_Type {
   unsigned char x1,y1,w,h;
   unsigned short Size;
   CA_Type* Buf; 
};




class TextViewType {
public:
  struct {
    uchar x1, y1, x2, y2, w, h;
  } Coord;

  struct {
    unsigned short WMin, WMax, XY;
    uchar Attr;
  } Other;

  WINDOW *w_save,*w_self,*w_in;
//  FILE *tmpfile /* ,*savefile */ ;
//  char BufName[256] /* ,SaveName[256]  */ ; 
  WBuf_Type BackStore;
//  CA_Type* BackStore_Buf;

  uchar BC, Tp;
  boolean Hidden;
  uchar HeapNr;
  
  struct {
     unsigned char X,Y;
  } Last;   

  void Init(uchar, uchar, uchar, uchar, uchar);
  void Frame(void);
  void Shadow(void);
  virtual void Hide(void);
  virtual void Show(void);
  virtual void Activate(void);
  virtual void RestorePrevWin(void);
  void Done(void);
};

class TextWindowType : public TextViewType {
public:
  int LinesWritten;
  uchar NormColor, TitleColor;
  char TitleStr[256];



  void Init(uchar, uchar, uchar, uchar, uchar, uchar, uchar, uchar, char *);
  virtual void Show(void);
  virtual void Activate(void);
  void SaveState(void);
  virtual void _write_C(char);
  void WriteChr(char);
  void WriteStr(char *);
  void WriteLnStr(char *);
  void ClrEol(void);
  void ClrEOF(void);
  void Clear(void);
  void ScrollUp(char *);
  void ScrollDown(char *);
};

struct _REC_Box {
  unsigned short x1, x2, y1, y2;
  char scan, ctrl;
};

struct _REC_DSP {
  struct {
     unsigned char x,y;
  } V;
  uchar VL;
};

class TextMenuType : public TextViewType {
public:
  boolean ScanCode;
  uchar MouseB, Size, NormColor, HiColor, LastBoxIndex, AskColor;
  AreaType MenuType;
  char st[256];
  _REC_Box Box[MaxItem];
  _REC_DSP DSP[MaxItem];
  struct {
    unsigned short WasX, WasY, PressCount;
    boolean Filled, WasKey;
  } Event;

  //---------private----------
  void Init(uchar, uchar, uchar, uchar, uchar, uchar, char *);
  virtual void Show(void);
  void ReadInt(uchar, int &);
  void ReadWord(uchar, unsigned short &);
  void ReadLong(uchar, long &);
  void ReadByte(uchar, uchar &);
  void ClearEvent(void);
  virtual void Idle(void);
  boolean ReadStr(uchar, char *);
  char GetEvent(void);
  boolean EventAvail(void);
  void Display(uchar, char *, uchar);
  char *GetString(char *, uchar);
};

class TextBrowseType {
public:
  FILE *F;
  int i, h;
  long L1, L2;
  Str79 FileName;

  TextWindowType Frame;
  TextMenuType Menu;


  void Init(uchar, uchar, uchar, uchar, char *, char *);
  void Exec(void);
  virtual void Idle(void);
  void PopUp(unsigned short);
  char *SeekBack(char *, long &);
  char *SeekFor(char *, long &);
  void Done(void);
  void WriteUp(void);
  void WriteDown(void);
  char F_NAME[_FNSIZE];
};






vextern struct {
  uchar Width, Height;
} _Display_;


extern void TextMode(int);
extern void Noise(void);
extern char GetCharAbs(uchar, uchar);
extern void WriteCharAbs(uchar, uchar, uchar, char);
extern void ChangeAttr(uchar, uchar, uchar, uchar, uchar);
extern unsigned short GetCurs(void);
extern void SetCursAbs(uchar, uchar);
extern void GetStringFast(uchar, uchar, uchar, char *);
extern void WriteStringFast(uchar, uchar, uchar, char *);
extern void ClrEOL(void);
extern void ClrScr(void);
extern void SetCurs(unsigned short);


extern void InstallTMenuExit(void);


vextern boolean Hercules;


#undef vextern

#endif /*TMENU_H*/

// End.
