summaryrefslogtreecommitdiffstats
path: root/kbarcode/zplutils.h
blob: 1c5e0b6f7061e5d23916b954ad176335b4c49072 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/***************************************************************************
                          zplutils.h  -  description
                             -------------------
    begin                : Son Okt 12 2003
    copyright            : (C) 2003 by Dominik Seichter
    email                : domseichter@web.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef ZPLUTILS_H
#define ZPLUTILS_H

#include <tqpaintdevice.h>
#include <tqstring.h>
#include <tqstringlist.h>
#include <tqmap.h>

class TQColor;
class TQFont;
class TQImage;
class TQSize;
class TQTextStream;

class BarcodePrinterDevice : public TQPaintDevice {
    public:
        BarcodePrinterDevice( double dpix, double dpiy );
        
        bool isExtDev() const { return true; }
        bool paintingActive() const { return false; }

        virtual int metric( int e ) const;
        
    private: 
        double m_resolution_x;
        double m_resolution_y;
};

/**
  * This class provides functions
  * to convert KBarcode label data
  * into Zebra Printer Language.
  *
  *@author Dominik Seichter
  */
class ZPLUtils {
    public: 
        static TQString footer();
        static TQString header();
        
        static TQString encoding( const TQString & encoding );
        static TQString fieldData( const TQString & data );
        static TQString fieldOrigin( int x, int y );
        static TQString font( const TQFont & font );

    private:
        static void fillEncodings();
        
    protected:
        static TQMap<TQString,TQString> encodings;
};

/**
  * This class provides functions
  * to convert KBarcode label data
  * into Intermec printer language.
  *
  * Thanks to Erich Kitzmller for providing
  * me with information and an examplefor this stuff.
  *@author Dominik Seichter
  */
class IPLUtils {
    public:
        IPLUtils();
        
        void addValue( const TQString & v );
        int counter();
        
        TQString encoding( const TQString & type );
        TQString footer();
        TQString header();

        TQString field( const TQString & data );
        TQString fieldOrigin( int x, int y );
    
    private:
        int m_counter;
        TQStringList m_values;
        static TQMap<TQString,TQString> encodings;
                
        /** fill the map to match kbarcode encoding types with IPL types */
        void fillEncodings();
};

/**
  * This class provides functions
  * to convert KBarcode label data
  * into Eltron printer control language (EPCL).
  *
  *@author Brian Glass
  */
#define EPCLWidth 646
#define EPCLHeight 1030

class EPCLUtils {
    public:
        static TQString encoding( const TQString & type );
        static TQString footer();
        static TQString header();

        static TQString field( const TQString & data );
        
        
        EPCLUtils( TQTextStream* stream, TQPaintDevice* source );

        void setTextField( int x, int y, int width, int height, const TQString & text );
        void setBarcode( int x, int y, int h, const TQString & value, const TQString & type );
        void setRect( int x, int y, const TQSize size, bool circle, int width );        
        void setImage( int x, int y, const TQImage* image );
        void close();
                
    private:
        static void fillEncodings();
        static TQMap<TQString,TQString> encodings;
        
        inline void setField( const TQString & data );
        void fillImageBuffer( void );
};

#endif