#if !defined(__alffnaux_h)      // Sentry, use file only if it's not already included.
#define __alffnaux_h
/*  Project Tec3270

	 SUBSYSTEM:    Tec3270.exe (Tec3270 application)
	 FILE:         alffnaux.h
	 AUTHOR:       Alcindo Ferreira Filho

	 OVERVIEW:

    ALFFConnData, Field, PrtField, ALFFPrtData, PrinterBuffer, ScreenPos
    Tec3270 auxiliary classes definition. They are used to store session
    parameters and status (ALFFConnData) and for defining and implementing
    screen and printer 3270 buffer definitions.

    COPYRIGHT:    © 1998-2007
                  Alcindo Ferreira Filho
                  <alcindo@inttec.com.br>

    LICENSE:      Tec3270_License (docs/Tec3270_License.txt)
*/
#include "alffsslcomm.h"
#include "tec3270.rh"
#include "alff3270.rh"
#include <owl\owlpch.h>
#include <dir.h>

////////////////////////////////////////////////////////////////
//
// ALFFConnData: A struct that describes an Tec3270 Session
//
class ALFFConnData
{
 public:
 	ALFFConnData();
 	~ALFFConnData();
   char far* GetClassName() {return "ALFFConnData";}
 	char    connName[SESSNAMELEN];
 	char    sessTitle[SESSNAMELEN];
 	char    hostName[HOSTNAMELEN];
 	int     portNumber;
 	bool    connLog;
 	ALFFSSLComm::ALFFSSLMethod securityMethod;
 	bool 	connReconn;
 	bool 	connExit;
 	bool 	connDoNothing;
 	uint  	actOption;
 	uint  	intvTime;
 	int  	pressKey;
 	bool 	bringTop;
 	bool 	soundAlm;
 	bool 	actYale;
 	uint    monTime;
 	int  	termType;
 	char  terminalNetName[9];
 	int  	codePage;

 	/* Remote Printer Session Config */
 	char    printerNetName[9];
 	bool    printerInact;
 	bool    printerOnly;
 	bool    printerAssociated;
 	bool    printerOnColor;
 	bool    printerDimen;
 	bool    printerIgnoreFF;
 	bool    printerBreakLine;
 	int     printerTabWidth;
 	int		printerCharPerInch;
 	int		printerLinePerInch;
 	int		printerCharPerLine;
 	int		printerLinePerPage;
 	int		printerTimeInact;
 	int		printerTimeConcat;
 	int		printerTimeEnd;
 	bool		printerNullLine;
 	bool		printerNullAsSpace;
 	bool		printerIgnoreAttr;
 	bool		printerFFAsSpace;
 	bool	   printerFFAnyPos;
 	bool		printerEndLineNL;
 	bool		printerEndLineCR;
 	bool		printerSCSErr;
 	bool		printerInheritParm;
 	/* ------------------------------*/
 	bool 	scriptOn;
 	char    	 scriptFile[MAXPATH];
 	COLORREF  scrCharColor;
 	COLORREF  scrBkgdColor;
 	COLORREF  scr3270BkgdColor;
 	COLORREF  scrNormalUnprotTextColor;
 	COLORREF  scrHighlightUnprotTextColor;
 	COLORREF  scrNormalProtTextColor;
 	COLORREF  scrHighlightProtTextColor;
 	COLORREF  neutral;
 	COLORREF  blue;
 	COLORREF  red;
 	COLORREF  pink;
 	COLORREF  green;
 	COLORREF  turquoise;
 	COLORREF  yellow;
 	COLORREF  inverseNeutral; // (white on displays, black on printers)
 	COLORREF  black;
 	COLORREF  deepBlue;
 	COLORREF  orange;
 	COLORREF  purple;
 	COLORREF  paleGreen;
 	COLORREF  paleTurquoise;
 	COLORREF  gray;
 	COLORREF  white;
};


////////////////////////////////////////////////////////////////
//
// Field: A class that implements an screen field, that is,
//        a sequence of characters with color, effects,
//        and others screen characteristics
//
class Field
{
 public:
  Field();
  Field(bool fdFmtd, const TPoint& fdPos, const COLORREF fdTxtCol,
		  const COLORREF  fdBkgCol, unsigned char fdHiLit,
		  unsigned char fdBkTransp, unsigned char fdValid,
		  unsigned char fdOut,  int cPos, const char* fdTxt);
  Field(const Field& fdCopy);
  ~Field();
  char far* GetClassName() {return "Field";}
  void   Reset();
  Field& operator = (const Field& equals);
  int operator == (const Field& fdTest) const;
  bool            fdFormatted;
  TPoint          fdPosition;
  COLORREF          fdTextColor;
  COLORREF          fdBkgdColor;
  unsigned char   fdEffects;
  unsigned char   fdBkgdTransparency;
  unsigned char   fdValidation;
  unsigned char   fdOutlining;
  int             cursorPos;
  char*           fdText;
};

typedef TArray<Field> Screen;
typedef TArrayIterator<Field> FieldIterator;


////////////////////////////////////////////////////////////
//
// Printer Field:
//
// Derived from Field to have screen characteristics like
// Line Size, Number of Lines, and Screen Number in printer
// Buffer
//
//
class PrtField : public Field
{
 public:
  PrtField();
  PrtField(const PrtField& fdCopy);
  ~PrtField();
  char far* GetClassName() {return "PrtField";}
  void Reset();
  PrtField& operator = (const PrtField& equals);
  PrtField& operator = (const Field& equals);
  int operator == (const PrtField& fdTest) const;
  int  scrLineSize;
  int  scrPrtBegLine;
  int  scrPrtEndLine;
  int  scrNumber;
  int  prtPageNumber;
  int  scrPrtPageOffset;
};

//////////////////////////////////////////////////////////
//
//  ALFFPrtData
//
class ALFFPrtData
{
 public:
   ALFFPrtData();
   ~ALFFPrtData();
   char far* GetClassName() {return "ALFFPrtData";}
	 /* Auxiliary Variables for retaining print options */
    char*      prtDriver;
    char*      prtDevice;
    char*      prtOutput;
    bool       defaultPrt;
	 PrtField*  fdHdr;
	 char*      hdrText;
    bool       hdrStored;
	 bool       printAllPages;
	 bool     	printWholeScr;
	 bool     	oneScrPerPage;
	 int     	printOption;
    bool       printOnColor;
	 bool     	printToFile;
    bool       printToSeparateFiles;
    char*      printerFileName;
    bool     	groupCopies;
	 int        Copies;
	 int			FromPage;
	 int			ToPage;
	 int			MinPage;
    int			MaxPage;
	 int        numScreens;
	 int        scrPageOffset;
	 int        topMargin;
    int        bottomMargin;
	 int        leftMargin;
	 int        rightMargin;
    int			interScrSpace;
	 TFont*     currPrtFont;
};

typedef TArray<PrtField> PrinterBuffer;


/////////////////////////////////////////////////////////////////
//
//  ALFFPrinterBuffer: A class that implements an printer buffer
//       and all related methods
//
class ALFFPrinterBuffer : public PrinterBuffer
{
  public:
   ALFFPrinterBuffer(int upper, int lower = 0, int delta = 0);
   ~ALFFPrinterBuffer();
   char far* GetClassName() {return "ALFFPrinterBuffer";}
   int   StorePrtField (PrtField* fdStore);
   void  PrintToFile   (TWindow* caller, ALFFPrtData*  prtData, ALFFMsgs* pMsgs);

  protected:
   ofstream 			prtFile;

};

/////////////////////////////////////////////////////////////
//
//  ScreenPos: A class that implements a 3270 buffer position
//             and describes all characteristics of an 3270
//             field.
//
class ScreenPos
{
  public:
	ScreenPos();
	~ScreenPos();
   char far* GetClassName() {return "ScreenPos";}
	ScreenPos& operator = (const ScreenPos&);
	int operator == (const ScreenPos& test) const;
	unsigned char   posAttr;
	unsigned char   fieldAttr;
	unsigned char   extendedHighLight;
	unsigned char   charSet;
	unsigned char   charColor;
	unsigned char   bkgdColor;
	unsigned char   bgTransparency;
	unsigned char   fieldValidation;
	unsigned char   fieldOutlining;
	unsigned int    fieldBeginAt;
};

/*
 * Define a Type for Terminal Screen Buffer
 */
typedef TVectorImp<ScreenPos> ScreenBuffer;

/*
 * Define a Type for Terminal Screen Buffer Iterator
 */
typedef TVectorIteratorImp<ScreenPos> ScreenPosIterator;

#endif         // __alffnaux_h sentry.
