Eneboo - Documentación para desarrolladores
|
00001 /*************************************************************************** 00002 posprinter.h 00003 ------------------- 00004 begin : Vie Mar 10 2006 00005 copyright : (C) 2006 by InfoSiAL S.L. 00006 email : mail@infosial.com 00007 ***************************************************************************/ 00008 /*************************************************************************** 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; version 2 of the License. * 00012 ***************************************************************************/ 00013 /*************************************************************************** 00014 Este programa es software libre. Puede redistribuirlo y/o modificarlo 00015 bajo los términos de la Licencia Pública General de GNU en su 00016 versión 2, publicada por la Free Software Foundation. 00017 ***************************************************************************/ 00018 00019 #ifndef POSPRINTER_H 00020 #define POSPRINTER_H 00021 00022 #include <qpaintdevice.h> 00023 #include <qpaintdevicemetrics.h> 00024 #include <qprocess.h> 00025 #include <qapplication.h> 00026 #include <qmap.h> 00027 00028 #include <private/qtextengine_p.h> 00029 #include <private/qtextlayout_p.h> 00030 00031 #ifndef AQ_LPR_EXTERNAL 00032 extern "C" int lpr_main(int, char **); 00033 #endif 00034 00035 class FL_EXPORT FLPosPrinter : public QPaintDevice 00036 { 00037 00038 public: 00039 00040 FLPosPrinter(); 00041 ~FLPosPrinter(); 00042 00043 enum PaperWidth { P57_5MM, P69_5MM, P76MM, NPaperWidth = P76MM }; 00044 00045 PaperWidth paperWidth() const { 00046 return paperWidth_; 00047 } 00048 00049 virtual void setPaperWidth(PaperWidth); 00050 00051 const QString &printerName() const { 00052 return printerName_; 00053 } 00054 00055 void setPrinterName(const QString &pName); 00056 00057 void cleanup(); 00058 void flush(); 00059 void send(const QString &str, const int col = -1, const int row = -1); 00060 00061 protected: 00062 00063 bool cmd(int, QPainter *, QPDevCmdParam *); 00064 int metric(int) const; 00065 00066 int paperWidthToCols(); 00067 00068 void sendStr(const char c, const int col = -1, const int row = -1); 00069 void sendEsc(const QString &e, const int col = -1, const int row = -1); 00070 00071 void initFile(); 00072 void initStrBuffer(); 00073 void initEscBuffer(); 00074 00075 private: 00076 00077 PaperWidth paperWidth_; 00078 QFile *file; 00079 QMap< int, char > * strBuffer; 00080 QMap< int, QString > * escBuffer; 00081 int idxBuffer; 00082 QString printerName_; 00083 }; 00084 00085 #endif