Eneboo - Documentación para desarrolladores
|
00001 /*************************************************************************** 00002 FLCodBar.h 00003 ------------------- 00004 begin : Mar Jun 17 2003 00005 copyright : (C) 2003-2005 by InfoSiAL S.L. 00006 email : mail@infosial.com 00007 ***************************************************************************/ 00008 /*************************************************************************** 00009 mybarcode.h 00010 ------------------- 00011 begin : Die Apr 23 2002 00012 copyright : (C) 2002,2003 by Dominik Seichter 00013 email : domseichter@web.de 00014 ***************************************************************************/ 00015 /*************************************************************************** 00016 * This program is free software; you can redistribute it and/or modify * 00017 * it under the terms of the GNU General Public License as published by * 00018 * the Free Software Foundation; version 2 of the License. * 00019 ***************************************************************************/ 00020 /*************************************************************************** 00021 Este programa es software libre. Puede redistribuirlo y/o modificarlo 00022 bajo los términos de la Licencia Pública General de GNU en su 00023 versión 2, publicada por la Free Software Foundation. 00024 ***************************************************************************/ 00025 00026 #ifndef FLCODBAR_H 00027 #define FLCODBAR_H 00028 00029 #include <qapplication.h> 00030 #include <qobject.h> 00031 #include <qfont.h> 00032 #include <qpainter.h> 00033 #include <qstring.h> 00034 #include <qprocess.h> 00035 #include <qpixmapcache.h> 00036 00037 class barcodeFormat; 00038 00039 class barcodeData 00040 { 00041 public: 00042 00043 barcodeData() {} 00044 QString value; 00045 int type; 00046 int margin; 00047 int rotation; 00048 double scale; 00049 double cut; 00050 bool text; 00051 bool valid; 00052 QColor fg; 00053 QColor bg; 00054 QString caption; 00055 int x; 00056 int y; 00057 int res; 00058 }; 00059 00060 class FLCodBar : public QObject 00061 { 00062 Q_OBJECT 00063 00064 public: 00065 00066 FLCodBar(const QString &value, int type, int margin, double scale, double cut, int rotation, 00067 bool text_flag = false, QColor fg = Qt::black, QColor bg = Qt::white, int res = 72); 00068 00069 FLCodBar(barcodeData *data); 00070 00071 FLCodBar(); 00072 00073 ~FLCodBar(); 00074 00075 QPixmap pixmap(); 00076 00077 QPixmap pixmapError(); 00078 00079 QString value() { 00080 return barcode.value; 00081 } 00082 int type() { 00083 return barcode.type; 00084 } 00085 int margin() { 00086 return barcode.margin; 00087 } 00088 double scale() { 00089 return barcode.scale; 00090 } 00091 double cut() { 00092 return barcode.cut; 00093 } 00094 bool text() { 00095 return barcode.text; 00096 } 00097 int rotation() { 00098 return barcode.rotation; 00099 } 00100 QColor fg() { 00101 return barcode.fg; 00102 } 00103 QColor bg() { 00104 return barcode.bg; 00105 } 00106 int res() { 00107 return barcode.res; 00108 } 00109 void setData(barcodeData *d) { 00110 barcode = *d; 00111 } 00112 bool validBarcode() { 00113 return barcode.valid; 00114 } 00115 00116 void setCaption(const QString &caption) { 00117 barcode.caption = caption; 00118 } 00119 QString caption() { 00120 return barcode.caption; 00121 } 00122 00123 void setValue(const QString &value) { 00124 barcode.value = value; 00125 } 00126 void setType(const int type) { 00127 barcode.type = type; 00128 } 00129 void setMargin(const int margin) { 00130 barcode.margin = margin; 00131 } 00132 void setScale(const double scale) { 00133 barcode.scale = scale; 00134 } 00135 void setCut(const double cut) { 00136 barcode.cut = cut; 00137 } 00138 void setText(const bool text) { 00139 barcode.text = text; 00140 } 00141 void setRotation(const int rotation) { 00142 barcode.rotation = rotation; 00143 } 00144 void setFg(const QColor &fg) { 00145 barcode.fg = fg; 00146 } 00147 void setBg(const QColor &bg) { 00148 barcode.bg = bg; 00149 } 00150 void setRes(const int res) { 00151 barcode.res = res; 00152 } 00153 barcodeData data() { 00154 return barcode; 00155 } 00156 00157 void fillDefault(barcodeData *data); 00158 void cleanUp(); 00159 00160 static int nameToType(const QString &name); 00161 static QString typeToName(const int type); 00162 00163 protected slots: 00164 00165 void readPixmapStdout(); 00166 void writingStdoutFinished(); 00167 00168 private: 00169 00170 void createBarcode(); 00171 void copyBarcode(barcodeData *src, barcodeData *dest); 00172 00173 QPixmap p; 00174 QPixmap pError; 00175 barcodeData barcode; 00176 QProcess *proc; 00177 bool readingStdout; 00178 bool writingStdout; 00179 }; 00180 00181 #endif