#pragma once
#include <afxstr.h>
/****************************************************************************
CONST DEFINE
****************************************************************************/
#define E_SUCCESS			0

#define BARCODE_128         0
#define BARCODE_128A        1
#define BARCODE_128B        2
#define BARCODE_128C        3
#define BARCODE_128E        4
#define BARCODE_39          5
#define BARCODE_39C         6
#define BARCODE_93          7
#define BARCODE_CODABAR     8
#define BARCODE_CODABAR16   9
#define BARCODE_EAN13       10
#define BARCODE_EAN132      11
#define BARCODE_EAN135      12
#define BARCODE_EAN8        13
#define BARCODE_EAN82       14

//rotate
#define ROTATE_NONE         0
#define ROTATE_90           1
#define ROTATE_180          2
#define ROTATE_270          3

//ecc level
#define ECC_LEVEL_L         0
#define ECC_LEVEL_M         1
#define ECC_LEVEL_Q         2
#define ECC_LEVEL_H         3



typedef struct hprt_printer_status_struct
{
	int     cb;
	unsigned char offline;
	unsigned char cover_open;
	unsigned char paper_nearend;
	unsigned char paper_empty;
}printerstatus;
typedef struct hprt_printer_status2_struct
{
	unsigned char offline;
	unsigned char cover_open;
	unsigned char paper_empty;
	unsigned char temperature_too_high;
	unsigned char voltage_error;
	unsigned char isbusy;
}printerstatus2;


char* cstringtocharstring(CString str);
char cstringtochar(CString str);
/******************************************************************************************
IMPORT
******************************************************************************************/
void UnloadDll();
BOOL LoadDll();

#ifdef __cplusplus
#define PRINTER_API extern "C" __declspec(dllimport)
#else
#define PRINTER_WIN32_SDK_API __declspec(dllimport)
#endif

typedef int(*FormatError)(int, int, char*, int, int);
typedef int(*PrinterCreator)(void**, const char*);
typedef int(*PrinterCreatorS)(char*);
typedef int(*PortOpen)(void*, const char*);
typedef int(*PortClose)(void*);
typedef int(*PrinterDestroy)(void*);
typedef int(*DirectIO)(void* handle, unsigned char writedata[], unsigned int writenum, unsigned char readdata[], unsigned int readnum, unsigned int* preadednum);

typedef int(*CPCL_AddLabel)(void* , int , int , int );
typedef int(*CPCL_SetAlign)(void* , int );
typedef int(*CPCL_AddText)(void* , int , int , int , int , int , char*);
typedef int(*CPCL_AddBarCode)(void* , int , int , int , int , int , int , int , const char* );
typedef int(*CPCL_AddBarCodeText)(void* , int , int , int , int );
typedef int(*CPCL_AddQRCode)(void* , int , int , int , int , int , int , const char* );
typedef int(*CPCL_AddPDF417)(void* , int , int , int , int , int , int , int , int , const char* );
typedef int(*CPCL_AddBox)(void* , int , int , int , int , int );
typedef int(*CPCL_AddLine)(void* , int , int , int , int , int );
typedef int(*CPCL_AddImage)(void* , int , int , int , char* );
typedef int(*CPCL_AddImageData)(void* , int , int , int , int , int , byte data[]);
typedef int(*CPCL_SetFontSize)(void* , int , int );
typedef int(*CPCL_SetDensity)(void* , int );
typedef int(*CPCL_SetSpeed)(void* , int );
typedef int(*CPCL_SetTextSpacing)(void* , int );
typedef int(*CPCL_SetLeftMargin)(void* , int );
typedef int(*CPCL_SetTextBold)(void* , int );
typedef int(*CPCL_SetTextUnderline)(void* , int );
typedef int(*CPCL_Abort)(void*);
typedef int(*CPCL_Print)(void*);
typedef int(*CPCL_NextLabelPos)(void* );
typedef int(*CPCL_PreFeed)(void* , int );
typedef int(*CPCL_PostFeed)(void* , int );

extern void* hprinter;

extern HMODULE m_Dll;

extern FormatError                                  DemFormatError;
extern PrinterCreator                               DemPrinterCreator;
extern PrinterCreatorS                              DemPrinterCreatorS;
extern PrinterDestroy                               DemPrinterDestroy;
extern PortOpen                                     DemPortOpen;
extern PortClose                                    DemPortClose;
extern DirectIO                                     DemDirectIO;

extern CPCL_AddLabel                                DemAddLabel;
extern CPCL_SetAlign                                DemSetAlign;
extern CPCL_AddText                                 DemAddText;
extern CPCL_AddBarCode                              DemAddBarCode;
extern CPCL_AddBarCodeText                          DemAddBarCodeText;
extern CPCL_AddQRCode                               DemAddQRCode;
extern CPCL_AddPDF417                               DemAddPDF417;
extern CPCL_AddBox                                  DemAddBox;
extern CPCL_AddLine                                 DemAddLine;
extern CPCL_AddImage                                DemAddImage;
extern CPCL_AddImageData                            DemAddImageData;
extern CPCL_SetFontSize                             DemSetFontSize;
extern CPCL_SetDensity                              DemSetDensity;
extern CPCL_SetSpeed                                DemSetSpeed;
extern CPCL_SetTextSpacing                          DemSetTextSpacing;
extern CPCL_SetLeftMargin                           DemSetLeftMargin;
extern CPCL_SetTextBold                             DemSetTextBold;
extern CPCL_SetTextUnderline                        DemSetTextUnderline;
extern CPCL_Abort                                   DemAbort;
extern CPCL_Print                                   DemPrint;
extern CPCL_NextLabelPos                            DemNextLabelPos;
extern CPCL_PreFeed                                 DemPreFeed;
extern CPCL_PostFeed                                DemPostFeed;