Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

qlabpdf.h

00001 #ifndef QLABPDF_H
00002 #define QLABPDF_H
00003 
00004 #include <qobject.h>
00005 #include <qvariant.h>
00006 
00007 // Constant definitions. Never change them.
00008 #define PDFVERSION "PDF 1.3"
00009 
00010 // Forward class declarations
00011 class QlabPdf_priv ;            // Our internal private class
00012 class QlabPdfFont ;                     // Pdf Font Definitions
00013 class QlabPdfColor ;            // Pdf Color definitions
00014 class QStringList ;                     // Needed for Font List
00015 
00016 // Module definitions
00017 typedef struct {
00018         double top ;
00019         double left ;
00020         double bottom ;
00021         double right ;
00022 } PdfMargins ;
00023 
00024 typedef QMap< QString, QlabPdfFont * > PdfFonts ;
00025 typedef QMap< QString, QlabPdfColor * > PdfPalette ;
00026 
00027 class Q_EXPORT QlabPdf : public QObject
00028 {
00029         Q_OBJECT ;
00030 
00031         Q_ENUMS( PdfEncodings ) ;
00032         Q_ENUMS( PdfMetrics ) ;
00033         Q_ENUMS( PdfPageSize ) ;
00034         Q_ENUMS( PdfPageCrop ) ;
00035         Q_ENUMS( PdfPageOrientation ) ;
00036         Q_ENUMS( PdfResolver ) ;
00037         Q_ENUMS( PdfColorModes ) ;
00038         Q_ENUMS( PdfErrors ) ;
00039         Q_ENUMS( PdfWarnings ) ;
00040 
00041         Q_PROPERTY( QString fileName READ fileName WRITE setFileName ) ;
00042         Q_PROPERTY( QString documentTitle READ documentTitle WRITE setDocumentTitle ) ;
00043         Q_PROPERTY( PdfEncodings documentEncoding READ documentEncoding WRITE setDocumentEncoding ) ;
00044         Q_PROPERTY( QString documentAuthor READ documentAuthor WRITE setDocumentAuthor ) ;
00045 
00046 
00047 public :
00053         enum PdfEncodings { HostEncoding,               
00054                                                 WinAnsiEncoding,        
00055                                                 MacEncoding,            
00056                                                 EbcdicEncoding          
00057                                           } ;
00062         enum PdfMetrics { DotMetrics,                   
00063                                           DecipointMetrics,             
00064                                           CentimeterMetrics,    
00065                                           MillimeterMetrics,    
00066                                           InchMetrics,                  
00067                                           Inch10Metrics                 
00068                                         } ;
00076         enum PdfPageSize { A0, A1, A2, A3, A4, A5, A6, B5, Letter, Legal,
00077                                            Ledger, LedgerL, UserDefinedPage } ;
00083         enum PdfPageCrop { DefaultCrop,                 
00084                                            MediaBox,                    
00085                                            CropBox,                             
00086                                            TrimBox,                             
00087                                            ArtBox,                              
00088                                            BleedBox                             
00089                                          } ;
00090         /*
00091                 \enum
00092                 \brief Page Orientation
00093         */
00094         enum PdfPageOrientation { Portrait,             
00095                                                           Landscape             
00096                                                         } ;
00101         enum PdfResolver { TopLeft,                             
00102                                            BottomLeft                   
00103                                          } ;
00108         enum PdfColorModes { Gray,                              
00109                                                  Rgb,                           
00110                                                  Cmyk                           
00111                                            } ;
00112 
00113         enum PdfErrors { ParameterError                 
00114                                    } ;
00115         enum PdfWarnings { UndefinedColor               
00116                                          } ;
00117         QlabPdf( const QString & fileName = 0, QObject * parent = 0, char * name = 0 ) ;
00118         ~QlabPdf() ;
00119 
00120         void setParameter( const QString & pname, const QVariant & value ) ;
00121         QVariant parameter( const QString & pname ) const ;
00122 
00123 public slots :
00124         QString fileName() const ;
00125         void setFileName( const QString & f ) ;
00126         QString documentTitle() const ;
00127         void setDocumentTitle( const QString & docTitle ) ;
00128         PdfEncodings documentEncoding() const ;
00129         void setDocumentEncoding( PdfEncodings newEncoding ) ;
00130         QString documentAuthor() const ;
00131         void setDocumentAuthor( const QString & docAuthor ) ;
00132         PdfPageSize pageSize() const ;
00133         void setPageSize( PdfPageSize newSize ) ;
00134         void setPdfPageSize( uint width, uint height ) ;
00135         void setPageCrop( PdfPageCrop newCrop ) ;
00136         void pageCrop() const ;
00137         PdfPageOrientation pageOrientation() const ;
00138         void setPageOrientation( PdfPageOrientation orient ) ;
00139         void setMargins( double top, double left, double bottom, double right ) ;
00140         QlabPdfColor color() const ;
00141         void setColor( const QString & color ) ;
00142         void setColor( PdfColorModes newMode = Gray, double color0 = 0.0,
00143                                    double color1 = 0.0, double color2 = 0.0, double color3 = 0.0 ) ;
00144 
00145         void drawLine( double xstart, double ystart, double xend, double yend,
00146                                    uint width = 1, const QString & color = 0 ) ;
00147         void drawRectangle( double top, double left, double bottom, double right,
00148                                                 uint width = 1, const QString & color = 0 ) ;
00149         void drawFilledRectangle( double top, double left, double bottom, double right,
00150                                                           uint width = 1, const QString & color = 0 ) ;
00151         void startNewPage( bool closePage = TRUE ) ;
00152         QString closeDocument() ;
00153         QStringList internalFonts() const ;
00154 
00155 signals :
00156         error( uint errNum, const QString & errMsg ) ;
00157         warning( uint warnNum, const QString & wanrMsg ) ;
00158 
00159 protected :
00160 
00161 protected slots :
00162         double scale() const ;
00163         void setScale( double newScale ) ;
00164 
00165 private :
00166         void buildDefaultPalette() ;
00167 
00168         QString file ;                          
00169         QString title ;                         
00170         PdfEncodings encoding ;         
00171         QString author ;                        
00172         double activeScale ;            
00173         double savedScale ;                     
00174         PdfMetrics metrics;                     
00175         PdfPageSize pageSizeCode ;      
00176         PdfPageCrop pageCropping ;      
00177         PdfPageOrientation orientation ;        
00178         PdfMargins documentMargins ;    
00179         PdfResolver resolver ;          
00180         PdfFonts fonts ;                        
00181         PdfPalette palette ;            
00183         QlabPdf_priv * document ;       
00184         uint pageWidth ;                        
00185         uint pageHeight ;                       
00186         PdfMargins pageMargins ;        
00187         uint pageNo ;                           
00188         QlabPdfFont * activeFont ;      
00189         bool pageWritten ;                      
00190         QlabPdfColor * activeColor ;    
00192 } ;
00193 
00194 #endif // QLABPDF_H

 

L.A.B. Project © 2001-2004 LAB Project & DJ Anubis