summaryrefslogtreecommitdiffstats
path: root/kbarcode/purepostscript.h
blob: b6f56b0f95ab1ab366ba6e7933866eec0b96b197 (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
/***************************************************************************
                          purepostscript.h  -  description
                             -------------------
    begin                : Mon Jan 2 2006
    copyright            : (C) 2006 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 PURE_POSTSCRIPT_H
#define PURE_POSTSCRIPT_H

#include "pixmapbarcode.h"
#include "barkode.h"

#include <tqcstring.h>

class PurePostscriptOptions : public BarkodeEngineOptions {
    public:
        PurePostscriptOptions();

        const BarkodeEngineOptions& operator=( const BarkodeEngineOptions & ps );
        void defaults();

        void load( const TQDomElement* tag );
        void save( TQDomElement* tag );  

        inline bool checksum() const { return m_check; }
        inline void setChecksum( bool b ) { m_check = b; }

    private: 
        bool m_check;
};

class PurePostscriptBarcode : public PixmapBarcode {
 public:
    PurePostscriptBarcode();
    ~PurePostscriptBarcode();

    /** Initialize PurePostscriptBarcode and set the path to
     *  the postscript program file or to TQString() if it cannot be found
     */
    static void init(); 

    static void initInfo( TBarcodeInfoList* info );

    static bool hasPurePostscriptBarcode();

    inline EEngine engine() const;

    inline BarkodeEngineOptions* options();

 private:
    virtual bool createPostscript( char** postscript, long* postscript_size );
    virtual TQRect bbox( const char* postscript, long postscript_size );

    /** Create a program which can be executed by ghostscript from
     *  m_program and the barcodes data.
     *  \param prg the program will be written to this string
     */
    void createProgram( TQString & prg );

 private:
    PurePostscriptOptions m_options;

    TQString m_program;

    static TQString s_path;
};

EEngine PurePostscriptBarcode::engine() const
{
    return PURE_POSTSCRIPT;
}

BarkodeEngineOptions* PurePostscriptBarcode::options()
{
    return &m_options;
}

#endif /* PURE_POSTSCRIPT_H */