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

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

	 OVERVIEW:

    ALFFPrinter, ALFFPrinterSetup, ALFFPrintDialog, ALFFPrintOut,
    Classes Definition, Tec3270 printing function specific classes.

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

    LICENSE:      Tec3270_License (docs/Tec3270_License.txt)
*/
#include <owl\owlpch.h>
#include <alffmsgs.h>
#include "alff3270.h"
#include "alffntsc.h"
#include "alffnaux.h"

class
ALFFPrinter: public TPrinter
{
 public:
	 ALFFPrinter (TApplication* appl);
	 ~ALFFPrinter();
    void GetWindowsDefaultPrinter() { GetDefaultPrinter(); }
    void InitPrinter(char* prtDriver, char* prtDevice, char* prtOutput)
                    { SetPrinter(prtDriver, prtDevice, prtOutput); }
 protected:
};

class
ALFFPrinterSetup: public ALFFDialog
{
 public:
	 ALFFPrinterSetup (TWindow* parent, const int titleId,
                      ALFFPrinter* pPrt, ALFFPrtData* pData,
                      bool remote=true);
	 ~ALFFPrinterSetup();
    char far* GetClassName() {return "ALFFPrinterSetup";}
 protected:
	 void 		SetupWindow();
    bool			LoadAllPrinters();
    bool       SetPrinterInfo(char* newPrinterName = NULL);
    void       SetPrinterName();
    bool       SetPrinterLocalInfo(char* lName, int maxLen);
	 void       CmOk();
    void       CmCancel();
	 void       CmHelp();
	 LRESULT    EvCommand(uint controlId, HWND , uint notifyCode);
	 ALFFMsgs*     pMsgs;
	 ALFFPrinter*  pPrinter;
	 TWindow*      pParent;
	 ALFFPrtData*  prtData;
	 TPrintDialog::TData* tPrintData;

    /* Printers Info             */
#define PRINTERINFOBUFFERSIZE 8192
#define MAXPRINTERNAME 256 
    ulong   		numberOfPrinters;
    BYTE*   		printersInfo;
    char*         actualPrinter;
	 char*         savedPrinter;
    
    /* Dialog Controls */
	 TComboBox* 	printerName;
 	 TStatic* 	   printerStatus;
  	 TStatic* 	   printerType;
  	 TStatic* 	   printerLocal;
  	 TStatic* 	   printerComments;
    TButton*      printerConfig;


	 /* Printing Options Objects */
	 TCheckBox*		printToFile;
    TCheckBox*    printToSeparateFiles;
    TStatic*      printerFileTit;
	 TEdit*		   printerFileName;
    TButton*      printerFileFind;

    /* Temporary Fields */
    char*         prtFileName;
    bool          prtToFile;
    bool          prtToSeparateFiles;
    bool          remotePrinter;
};

class
ALFFPrintDialog: public ALFFDialog
{
 public:
	 ALFFPrintDialog (TWindow*, ALFFPrinter*, ALFFPrtData*, TResId);
	 ~ALFFPrintDialog();
    char far* GetClassName() {return "ALFFPrintDialog";}
 protected:
	 void 		SetupWindow();
	 void       SetPrinterName();
    bool       SetPrinterLocalInfo(char* prtOutInfo, const char* lName, int maxLen);
	 void       CmOk();
	 void       CmHelp();
	 LRESULT    EvCommand(uint controlId, HWND , uint notifyCode);
	 ALFFMsgs*     pMsgs;
	 ALFFPrinter*  pPrinter;
	 TWindow*      pdParent;
	 ALFFPrtData* prtData;
	 TPrintDialog::TData* tPrintData;

	 TStatic* 	   printerName;

	 TGroupBox*    prtRngGroup;
	 TRadioButton* prtAllPg;
	 TRadioButton* prtSelPg;
	 TEdit*        prtFromPg;
	 TEdit*        prtToPg;
	 TStatic*      txtFromPg;
	 TStatic*      txtToPg;

	 TGroupBox*    printGroup;
	 TRadioButton* prtScreen;
	 TRadioButton* prtSelTxt;

	 TGroupBox*    pageGroup;
	 TRadioButton* oneScrPage;
	 TRadioButton* maxScrPage;

	 /* Print/Store Group Objects */
	 TGroupBox*    prtStorGroup;
	 TRadioButton*	storeScr;
	 TRadioButton*	printStor;
	 TRadioButton*	printScr;
	 TRadioButton*	printClr;

	 /* Printing Options Objects */
	 TCheckBox*		hdrPage;
	 TStatic*      hdrShowText;
	 TCheckBox*    prtColor;
	 TEdit*		   numCopies;
    bool          hdrActive;

};

class
ALFFPrintOut : public TPrintout
{
 public:
	 ALFFPrintOut (ALFFPrinter *printer,
                  ALFFPrinterBuffer*  prtBuf,
                  const char far *title,
						TWindow* window,
						ALFFPrtData* prtFlg,
                  ALFFConnData* cnnData,
						bool prtPreview = false);
	 ~ALFFPrintOut();
    char far* GetClassName() {return "ALFFPrintOut";}
    void SetPrintParams(TPrintDC* dc, TSize pageSize);
	 void GetDialogInfo (int& minPage, int& maxPage, int& selFromPage, int& selToPage);
	 void BeginPrinting ();
	 void EndPrinting ();
	 void PrintPage (int page, TRect& rect, unsigned flags);
	 void SetBanding (bool b)   { Banding = b; }
	 bool HasPage (int pageNumber);
	 void SetMappingMode(TDC& dc);
	 void Paginate();
	 bool NextLine(int& line, const int begLine, const int endLine,
						const int offset=1);
	 bool NextCol(int& col, const int lineSize, const int offset=1);
	 bool PrintField(TDC&  dc,
						  const Field* field,
						  const TColor bgColor,
						  const int lineSize,
						  const int scrBegLine,
						  const int scrEndLine,
                    const int xOffSet=0,
						  const int yOffset=0);
    unsigned int    GetPrintedLines() { return printedLines; }
    void            ResetPrintedLines() { printedLines = 0; }

 protected:
	 ALFFPrtData* 		   prtData;
    ALFFConnData*       connData;
	 TWindow*            Window;
	 ALFFPrinter*        Printer;
    ALFFPrinterBuffer*  printerBuf;
	 PrtField*           fdPrint;
	 HFONT               hFont;
    TFont*              remotePrtFont;
    unsigned int        printedLines;
	 bool             	Scale;
	 int              	fCharWidth;
	 int						fCharHeight;
	 int          			MapMode;
	 int          			OldVExt, OldWExt;
	 TRect        			OrgR;
	 TColor       			OldBkgdColor;
	 TColor       			OldTextColor;
};
#endif          // __alffprnt_h sentry.
