/*-----------------------------------------------------------------------*/
/*   FS-MTS  1.0  Ver.                                                   */
/*   Copyright (C) 2000 FIRST SAIL                                       */
/*   All Rights Reserved                                                 */
/*   Warning:                                                            */
/*       This program author is GuoHeng,this system is protected         */
/*   by copyright law and international Treaties . Unauthorized          */
/*   reproduction of  distribution of this  system, or any portion       */
/*   of it , may result in severe civil and criminal penalties ,         */
/*   and will be prosecuted to the maximum extern possible under         */
/*   the law.                                                            */
/*                                                                       */
/*   Update Date:2002-06-25                                              */
/*   Update Time:22:35:00                                                */
/*-----------------------------------------------------------------------*/

#ifndef  _PRINT_H_H_
#define  _PRINT_H_H_
#include <dos.h>
#include <dir.h>

#include <Symbol.h>

#define    REQUERY_IMBOBILE_COUNT  3
#define    REPORT_IMBOBILE_COUNT   6


#ifndef FIRSTSAIL_USER
#define FIRSTSAIL_USER
#endif


//#define  MAX2_TEST_ITEM_COUNT           MAX_TEST_ITEM_COUNT
//128
//===========================================
struct  FIRSTSAIL_DATAMAP
{
	char  strMotorType[24];
	DWORD dwDate;
	DWORD dwTimeEx;
	DWORD dwLine;
	DWORD dwMask1;
	DWORD dwMask2;
	DWORD dwMask3;
	DWORD dwMask4;
	DWORD dwMask5;
	DWORD dwMask6;
	DWORD dwMask7;
	DWORD dwMask8;
	DWORD dwMask9;
	DWORD dwMask10;
	DWORD dwMask11;
	DWORD dwMask12;
	DWORD dwMask13;
	DWORD dwMask14;
	DWORD dwMask15;
	DWORD dwMask16;
	float sfData[MAX_TEST_ITEM_COUNT];
	char  bufBarCode[32];
};

struct  REPORTDATAMAP
{
	DWORD dwTime;
	char  strMotorType[20];
	DWORD dwTotalCount;
	DWORD dwRightCount;
	DWORD dwErrorCount;
	float fRate;
	DWORD dwData[MAX_TEST_ITEM_COUNT];
};

BOOL   GetRecordRange(DWORD *pdwStart,DWORD *pdwEnd,DWORD dwCount);

class CPrint
{
protected:
	DWORD m_dwStartRecord;
	DWORD m_dwEndRecord;
	char  m_strLpt[MAXPATH];
	char  m_strPathFileName[MAXPATH];
public:
	DWORD GetStartRecord(){return(m_dwStartRecord);}
	DWORD GetEndRecord(){return(m_dwEndRecord);}
	void SetStartRecord(DWORD dwRecord){m_dwStartRecord=dwRecord;}
	void SetEndRecord(DWORD dwRecord){m_dwEndRecord=dwRecord;}

	void SetLptName(char *pStr){_fstrcpy(m_strLpt,pStr);};
	void SetPathFileName(char *pStr){_fstrcpy(m_strPathFileName,pStr);};
public:
	virtual BOOL BeginPrint();
	virtual BOOL EndPrint();
	virtual BOOL Printting();
	virtual BOOL Print();
public:
	CPrint();
};

class CRequeryPrint:public CPrint
{

//public:
//#ifdef FIRSTSAIL_USER
//	CRegister* m_pRegister;
//#endif
protected:
	BOOL  m_bEnglish;
private:
	int   m_nPageCount;
	int   m_nPrintStyle;
	int   m_nPageIndex;
	int   m_nExtraCharacterWidth;
	int   m_nExtraColCount;
	int   m_nPageTotalCount;
	int   m_nRowCount;

	BYTE  m_scxItem[REQUERY_IMBOBILE_COUNT+MAX_TEST_ITEM_COUNT];
	BYTE  m_sbySymbol[15*2];
public:
	int   GetExtraCharacterWidth(){return(m_nExtraCharacterWidth);}
	int   GetExtraColCount(){return(m_nExtraColCount);}
	void  SetExtraCharacterWidth(int nCount){m_nExtraCharacterWidth=nCount;}
	void  SetExtraColCount(int nCount){m_nExtraColCount=nCount;}
	int   ModifyExtraColCount(int nStartIndex);
	int   GetTotalSection();
	void  GetBeginAndEnd(int nSection,int *pnBegin,int *pnEnd);
	BOOL  IsHealCol(int nCol);
	BOOL  IsLastHealCol(int nCol);
	int   GetLeaveCharacter();
public:
	BOOL GetEnglish(){return(m_bEnglish);}
	void SetEnglish(BOOL bEnglish);
public:
	void  SetItemLength(int nIndex,int nLength){m_scxItem[nIndex]=(BYTE)nLength;}
	char* AddString(char *pStr1,char *pStr2,int nCount=1);
	void  SetPrintStyle(int nStyle){m_nPrintStyle=nStyle;}
public:
	virtual BOOL Printting();
public:
	int   ModifyIndex(int nIndex);
	void  PrintCaption(FILE *pFile);
	void  PrintHead(FILE *pFile);
	BOOL  PrintData(FILE *);
public:
	void AddItem(int nRowState,int nCol,DWORD dwData,char *pStr,int nOriIndex=0);
	void AddItem(int nRowState,int nCol,float fData,char *pStr,int nOriIndex=0);
	void AddItem(int nRowState,int nCol,char *strData,char *pStr,int nAlign=VK_RIGHT,int nOriIndex=0);

public:
	CRequeryPrint();
#ifdef FIRSTSAIL_USER
	~CRequeryPrint();
#endif
};

class CReportPrint:public CPrint
{
//public:
//#ifdef FIRSTSAIL_USER
//	CRegister* m_pRegister;
//#endif
protected:
	BOOL  m_bEnglish;
private:
	int   m_nPageCount;
	int   m_nPrintStyle;
	int   m_nPageIndex;
	int   m_nExtraCharacterWidth;
	int   m_nExtraColCount;
	int   m_nPageTotalCount;
	int   m_nRowCount;
	BYTE  m_scxItem[REPORT_IMBOBILE_COUNT+MAX_TEST_ITEM_COUNT];
	BYTE  m_sbySymbol[15*2];
public:
	BOOL GetEnglish(){return(m_bEnglish);}
	void SetEnglish(BOOL bEnglish);
public:
	int   GetExtraCharacterWidth(){return(m_nExtraCharacterWidth);}
	int   GetExtraColCount(){return(m_nExtraColCount);}
	void  SetExtraCharacterWidth(int nCount){m_nExtraCharacterWidth=nCount;}
	void  SetExtraColCount(int nCount){m_nExtraColCount=nCount;}
	int   ModifyExtraColCount(int nStartIndex);
	int   GetTotalSection();
	void  GetBeginAndEnd(int nSection,int *pnBegin,int *pnEnd);
	BOOL  IsHealCol(int nCol);
	BOOL  IsLastHealCol(int nCol);
	int   GetLeaveCharacter();
public:
	void  SetItemLength(int nIndex,int nLength){m_scxItem[nIndex]=(BYTE)nLength;}
	char* AddString(char *pStr1,char *pStr2,int nCount=1);
	void  SetPrintStyle(int nStyle){m_nPrintStyle=nStyle;}
public:
	virtual BOOL Printting();
public:
	int   ModifyIndex(int nIndex);
	void  PrintCaption(FILE *pFile);
	void  PrintHead(FILE *pFile);
	BOOL  PrintData(FILE *);
public:
	void AddItem(int nRowState,int nCol,DWORD dwData,char *pStr,int nOriIndex=0);
	void AddItem(int nRowState,int nCol,float fData,char *pStr,int nOriIndex=0);
	void AddItem(int nRowState,int nCol,char *strData,char *pStr,int nAlign=VK_RIGHT,int nOriIndex=0);

public:
	CReportPrint();
#ifdef FIRSTSAIL_USER
	~CReportPrint();
#endif
};
#endif