
#pragma once

/****************************************************************************
	CONST DEFINE
****************************************************************************/
#define E_SUCCESS			0		// no error


//Text Align
#define TEXT_ALIGNMENT_LEFT    0
#define TEXT_ALIGNMENT_CENTER  1
#define TEXT_ALIGNMENT_RIGHT   2

//Text Font
#define TEXT_FONT_A            0
#define TEXT_FONT_B            1
#define TEXT_FONT_C            2

#define TEXT_SIZE_0WIDTH       0
#define TEXT_SIZE_1WIDTH       16
#define TEXT_SIZE_2WIDTH       32
#define TEXT_SIZE_3WIDTH       48
#define TEXT_SIZE_4WIDTH       64
#define TEXT_SIZE_5WIDTH       80
#define TEXT_SIZE_6WIDTH       96
#define TEXT_SIZE_7WIDTH       112

#define TEXT_SIZE_0HEIGHT      0
#define TEXT_SIZE_1HEIGHT      1
#define TEXT_SIZE_2HEIGHT      2
#define TEXT_SIZE_3HEIGHT      3
#define TEXT_SIZE_4HEIGHT      4
#define TEXT_SIZE_5HEIGHT      5
#define TEXT_SIZE_6HEIGHT      6
#define TEXT_SIZE_7HEIGHT      7

#define	TEXT_NORMAL_MODE            0
#define	TEXT_FONT_EMPHASIZED        2
#define	TEXT_FONT_UNDERLINE_MODE    4
#define	TEXT_FONT_REVERSE           8
#define	TEXT_FONT_DH_MODE           16
#define	TEXT_FONT_DW_MODE           32
#define	TEXT_FONT_DW_DH_MODE        48

/* Bar Code Type */
#define BARCODE_UPC_A      65
#define BARCODE_UPC_E	   66
#define BARCODE_EAN13      67
#define BARCODE_JAN13	   67
#define BARCODE_EAN8	   68
#define BARCODE_JAN8       68
#define BARCODE_CODE39     69
#define BARCODE_ITF        70
#define BARCODE_CODABAR    71
#define BARCODE_CODE93     72
#define BARCODE_CODE128    73

#define SYMBOL_STANDARD_PDF417		101
#define SYMBOL_TRUNCATED_PDF417		102
#define	SYMBOL_QRCODE1				103
#define	SYMBOL_QRCODE2				104
//PDF417 Code error correction level
#define PDF417_ERROR_CORRECTION_LEVEL_0  48
#define PDF417_ERROR_CORRECTION_LEVEL_1  49
#define PDF417_ERROR_CORRECTION_LEVEL_2  50
#define PDF417_ERROR_CORRECTION_LEVEL_3  51
#define PDF417_ERROR_CORRECTION_LEVEL_4  52
#define PDF417_ERROR_CORRECTION_LEVEL_5  53
#define PDF417_ERROR_CORRECTION_LEVEL_6  54
#define PDF417_ERROR_CORRECTION_LEVEL_7  55
#define PDF417_ERROR_CORRECTION_LEVEL_8  56

#define BARCODE_HRI_FONT_A  0
#define BARCODE_HRI_FONT_B  1

#define BARCODE_HRI_NONE   0
#define BARCODE_HRI_ABOVE  1
#define BARCODE_HRI_BELOW  2
#define BARCODE_HRI_BOTH   3

//Symbol model
#define SYMBOL_MODEL_1  49
#define SYMBOL_MODEL_2  50
//Symbol error correction level
#define SYMBOL_ERROR_CORRECTION_LEVEL_L  48
#define SYMBOL_ERROR_CORRECTION_LEVEL_M  49
#define SYMBOL_ERROR_CORRECTION_LEVEL_Q  50
#define SYMBOL_ERROR_CORRECTION_LEVEL_H  51
//Print Image Scale Mode
#define PRINT_IMAGE_NORMAL				0
#define PRINT_IMAGE_DOUBLE_WIDTH		1
#define PRINT_IMAGE_DOUBLE_HEIGHT		2
#define PRINT_IMAGE_QUADRUPLE			3

//Character Code Table

#define CHARACTERSET_DEFAULT           0
#define CHARACTERSET_USA               437
#define CHARACTERSET_MULTILINGUAL      850
#define CHARACTERSET_PORTUGUESE        860
#define CHARACTERSET_CANADIAN_FRENCH   863
#define CHARACTERSET_NORDIC            865
#define CHARACTERSET_WPC1252           1252
#define CHARACTERSET_CYRILLIC2         866
#define	CHARACTERSET_LATIN2            852
#define	CHARACTERSET_EURO              858

/******************************************************************************************
	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(*PrtFormatErrorA)(int error_no, int langid, char* buf, int pos, int buf_size);
typedef int(*PrtFormatErrorW)(int error_no, int langid, wchar_t* buf, int pos, int buf_size);
typedef int(*PrtPrinterCreatorA)(void** phandle, const char* model);
typedef int(*PrtPrinterCreatorW)(void** phandle, const wchar_t* model);
typedef int(*PrtPortOpenA)(void* handle, const char* io_settings);
typedef int(*PrtPortOpenW)(void* handle, const wchar_t* io_settings);
typedef int(*PrtPortClose)(void* handle);
typedef int(*PrtPrinterDestroy)(void* handle);
typedef int(*PrtPrinterInitialize)(void* handle);
typedef int(*PrtCutPaper)(void* handle, int cut_mode, int distance);
typedef int(*PrtPrintTextA)(void* handle, const char* data, int alignment, int attribute, int textsize);
typedef int(*PrtPrintTextW)(void* handle, const wchar_t* data, int alignment, int attribute, int textsize);
typedef int(*PrtFeedLine)(void* handle, int lines);
typedef int(*PrtPrintBarCodeA)(void* handle, int bctype, const char* data, int width, int height, int alignment, int HRI_position);
typedef int(*PrtPrintBarCodeW)(void* handle, int bctype, const wchar_t* data, int width, int height, int alignment, int HRI_position);
typedef int(*PrtPrintSymbolA)(void* handle, int type, const char* data, int err_level, int width, int height, int alignment);
typedef int(*PrtPrintSymbolW)(void* handle, int type, const wchar_t* data, int err_level, int width, int height, int alignment);
typedef int(*PrtPrintImageA)(void* handle, const char* filename, int scalemode);
typedef int(*PrtPrintImageW)(void* handle, const wchar_t* filename, int scalemode);
typedef int(*PrtDefineNVImageCompatibleA)(void* handle, const char** imagepath_list, int imageqty);
typedef int(*PrtDefineNVImageCompatibleW)(void* handle, const wchar_t** imagepath_list, int imageqty);
typedef int(*PrtPrintNVImageCompatible)(void* handle, int imgno, int scalemode);
typedef int(*PrtDefineNVImageA)(void* handle, const char* imagepath, unsigned char kc1, unsigned char kc2);
typedef int(*PrtDefineNVImageW)(void* handle, const wchar_t* imagepath, unsigned char kc1, unsigned char kc2);
typedef int(*PrtPrintNVImage)(void* handle, unsigned char kc1, unsigned char kc2, int horizontal, int vertical);
typedef int(*PrtDefineBufferedImageA)(void* handle, const char* imagepath);
typedef int(*PrtDefineBufferedImageW)(void* handle, const wchar_t* imagepath);
typedef int(*PrtPrintBufferedImage)(void* handle);
typedef int(*PrtDefineDownloadedImageCompatibleA)(void* handle, const char* imagepath);
typedef int(*PrtDefineDownloadedImageCompatibleW)(void* handle, const wchar_t* imagepath);
typedef int(*PrtPrintDownloadedImageCompatible)(void* handle, int scalemode);
typedef int(*PrtOpenDrawer)(void* handle, int pin_mode, int on_time, int off_time);
typedef int(*PrtSelectStandardMode)(void* handle);
typedef int(*PrtSetTextLineSpace)(void* handle, int linespace);
typedef int(*PrtSetTextPosition)(void* handle, int position);
typedef	int(*PrtSelectPageMode)(void* handle);
typedef	int(*PrtSetPrintAreaInPageMode)(void* handle, int horizontal, int vertical, int width, int height);
typedef	int(*PrtCancelPrintDataInPageMoode)(void* handle);
typedef	int(*PrtSelectPrintDirectionInPageMode)(void* handle, int direction);
typedef	int(*PrtSetAbsolutePrintPosition)(void* handle, int position);
typedef	int(*PrtSetAbsoluteVerticalPrintPositionInPageMode)(void* handle, int position);
typedef	int(*PrtPrintAndReturnStandardMode)(void* handle);
typedef	int(*PrtPrintDataInPageMode)(void* handle);
typedef	int(*PrtCheckPrinterState)(void* handle, unsigned int* printer_state);
typedef	int(*PrtDirectIO)(void* handle, unsigned char writedata[], unsigned int writenum, unsigned char readdata[], unsigned int readnum, unsigned int* preadednum);
typedef	int(*PrtSetCharacterSet)(void* handle, int characterset);
typedef	int(*PrtGetPrinterVersion)(void* handle, int* version, int version_len);
typedef int(*PrtPositionNextLabel)(void* handle);

extern void*			hprinter;
extern HMODULE			m_hDll;


extern PrtFormatErrorA									FormatErrorA;
extern PrtFormatErrorW									FormatErrorW;
extern PrtPrinterCreatorA								PrinterCreatorA;
extern PrtPrinterCreatorW								PrinterCreatorW;
extern PrtPortOpenA										PortOpenA;
extern PrtPortOpenW										PortOpenW;
extern PrtPortClose										PortClose;
extern PrtPrinterDestroy								PrinterDestroy;
extern PrtPrinterInitialize							    PrinterInitialize;
extern PrtCutPaper										CutPaper;
extern PrtPrintTextA									PrintTextA;
extern PrtPrintTextW									PrintTextW;
extern PrtFeedLine										FeedLine;
extern PrtPrintBarCodeA									PrintBarCodeA;
extern PrtPrintBarCodeW									PrintBarCodeW;
extern PrtPrintSymbolA									PrintSymbolA;
extern PrtPrintSymbolW									PrintSymbolW;
extern PrtPrintImageA									PrintImageA;
extern PrtPrintImageW									PrintImageW;
extern PrtDefineNVImageCompatibleA						DefineNVImageCompatibleA;
extern PrtDefineNVImageCompatibleW						DefineNVImageCompatibleW;
extern PrtPrintNVImageCompatible						PrintNVImageCompatible;

extern PrtDefineNVImageA								DefineNVImageA;
extern PrtDefineNVImageW								DefineNVImageW;
extern PrtPrintNVImage									PrintNVImage;
extern PrtDefineBufferedImageA							DefineBufferedImageA;
extern PrtDefineBufferedImageW							DefineBufferedImageW;
extern PrtPrintBufferedImage							PrintBufferedImage;
extern PrtDefineDownloadedImageCompatibleA				DefineDownloadedImageCompatibleA;
extern PrtDefineDownloadedImageCompatibleW				DefineDownloadedImageCompatibleW;
extern PrtPrintDownloadedImageCompatible				PrintDownloadedImageCompatible;

extern PrtOpenDrawer									OpenDrawer;
extern PrtSelectStandardMode							SelectStandardMode;
extern PrtSetTextLineSpace								SetTextLineSpace;
extern PrtSetTextPosition								SetTextPosition;
extern PrtSelectPageMode								SelectPageMode;
extern PrtSetPrintAreaInPageMode						SetPrintAreaInPageMode;
extern PrtSelectPrintDirectionInPageMode				SelectPrintDirectionInPageMode;
extern PrtSetAbsolutePrintPosition						SetAbsolutePrintPosition;
extern PrtSetAbsoluteVerticalPrintPositionInPageMode	SetAbsoluteVerticalPrintPositionInPageMode;
extern PrtPrintAndReturnStandardMode					PrintAndReturnStandardMode;
extern PrtPrintDataInPageMode							PrintDataInPageMode;
extern PrtCheckPrinterState								CheckPrinterState;
extern PrtDirectIO										DirectIO;
extern PrtSetCharacterSet								SetCharacterSet;
extern PrtGetPrinterVersion								GetPrinterVersion;
extern PrtPositionNextLabel								PositionNextLabel;

#ifdef _UNICODE
#define TA2CT			W2CT
#define FormatError		FormatErrorW
#define PrinterCreator	PrinterCreatorW
#define PortOpen		PortOpenW
#define PrintText		PrintTextW
#define PrintBarCode	PrintBarCodeW
#define PrintSymbol		PrintSymbolW
#define PrintImage		PrintImageW
#define DefineNVImageCompatible		DefineNVImageCompatibleW
#define DefineBufferedImage			DefineBufferedImageW
#define DefineNVImage				DefineNVImageW
#define DefineDownloadedImageCompatible DefineDownloadedImageCompatibleW
#else
#define TA2CT			A2CT
#define FormatError		FormatErrorA
#define PrinterCreator	PrinterCreatorA
#define PortOpen		PortOpenA
#define PrintText		PrintTextA
#define PrintBarCode	PrintBarCodeA
#define PrintSymbol		PrintSymbolA
#define PrintImage		PrintImageA
#define DefineNVImageCompatible		DefineNVImageCompatibleA
#define DefineBufferedImage			DefineBufferedImageA
#define DefineNVImage				DefineNVImageA
#define DefineDownloadedImageCompatible DefineDownloadedImageCompatibleW
#endif