# kdeprint Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# kprinter.h

    00001 /*
    00002  *  This file is part of the KDE libraries
    00003  *  Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be>
    00004  *
    00005  *
    00006  *  This library is free software; you can redistribute it and/or
    00007  *  modify it under the terms of the GNU Library General Public
    00008  *  License version 2 as published by the Free Software Foundation.
    00009  *
    00010  *  This library is distributed in the hope that it will be useful,
    00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00013  *  Library General Public License for more details.
    00014  *
    00015  *  You should have received a copy of the GNU Library General Public License
    00016  *  along with this library; see the file COPYING.LIB.  If not, write to
    00017  *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00018  *  Boston, MA 02111-1307, USA.
    00019  **/
    00020
    00021 #ifndef KPRINTER_H
    00022 #define KPRINTER_H
    00023
    00024 #include <qpaintdevice.h>
    00025 #include <qprinter.h>
    00026 #include <qmap.h>
    00027 #include <qstring.h>
    00028 #include <qstringlist.h>
    00029 #include <qvaluelist.h>
    00030 #include <kdemacros.h>
    00031 #include <kdelibs_export.h>
    00032
    00033 #include <kdeprint/kpreloadobject.h>
    00034
    00035 class KPrinterImpl;
    00036 class KPrintDialogPage;
    00037 class KPrinterPrivate;
    00038 class DrPageSize;
    00039
    00088 class KDEPRINT_EXPORT KPrinter : public QPaintDevice, public KPReloadObject
    00089 {
    00090 friend class KPrinterWrapper;
    00091 friend class KPrinterImpl;
    00092 public:
    00093     // Print global settings (set via static functions)
    00102     enum StandardPageType { CopiesPage = 0x01, FilesPage = 0x02, Custom = 0x10 };
    00116     enum PageSelectionType { ApplicationSide = 0x01, SystemSide = 0x02 };
    00126     enum ApplicationType { Dialog = 0x00, StandAlone = 0x01, StandAlonePersistent = 0x02 };
    00127
    00128     // QPrinter extension
    00137     enum PageSetType { AllPages = 0x00, OddPages = 0x01, EvenPages = 0x02 };
    00145     enum CollateType { Collate = 0x00, Uncollate = 0x01 };
    00146
    00147     // from QPrinter class
    00152     enum ColorMode { GrayScale = QPrinter::GrayScale, Color = QPrinter::Color };
    00157     enum Orientation { Portrait = QPrinter::Portrait, Landscape = QPrinter::Landscape };
    00162     enum PageOrder { FirstPageFirst = QPrinter::FirstPageFirst, LastPageFirst = QPrinter::LastPageFirst };
    00167     enum PageSize
    00168     {
    00169         A4 = QPrinter::A4,
    00170         B5 = QPrinter::B5,
    00171         Letter = QPrinter::Letter,
    00172         Legal = QPrinter::Legal,
    00173         Executive = QPrinter::Executive,
    00174         A0 = QPrinter::A0,
    00175         A1 = QPrinter::A1,
    00176         A2 = QPrinter::A2,
    00177         A3 = QPrinter::A3,
    00178         A5 = QPrinter::A5,
    00179         A6 = QPrinter::A6,
    00180         A7 = QPrinter::A7,
    00181         A8 = QPrinter::A8,
    00182         A9 = QPrinter::A9,
    00183         B0 = QPrinter::B0,
    00184         B1 = QPrinter::B1,
    00185         B10 = QPrinter::B10,
    00186         B2 = QPrinter::B2,
    00187         B3 = QPrinter::B3,
    00188         B4 = QPrinter::B4,
    00189         B6 = QPrinter::B6,
    00190         B7 = QPrinter::B7,
    00191         B8 = QPrinter::B8,
    00192         B9 = QPrinter::B9,
    00193         C5E = QPrinter::C5E,
    00194         Comm10E = QPrinter::Comm10E,
    00195         DLE = QPrinter::DLE,
    00196         Folio = QPrinter::Folio,
    00197         Ledger = QPrinter::Ledger,
    00198         Tabloid = QPrinter::Tabloid,
    00199         NPageSize = QPrinter::NPageSize
    00200     };
    00201
    00202     // constructors / destructor
    00210     KPrinter(bool restore = true, QPrinter::PrinterMode m = QPrinter::ScreenResolution );
    00214     ~KPrinter();
    00215
    00216     // QPrinter interface (+ some extensions)
    00220     bool newPage();
    00224     bool abort();
    00228     bool aborted() const;
    00232     bool outputToFile() const;
    00236     void setOutputToFile(bool);
    00240     QString outputFileName() const;
    00244     void setOutputFileName(const QString&);
    00248     QString docName() const;
    00252     void setDocName(const QString&);
    00256     QString creator() const;
    00260     void setCreator(const QString&);
    00264     bool fullPage() const;
    00268     void setFullPage(bool);
    00272     ColorMode colorMode() const;
    00276     void setColorMode(ColorMode);
    00280     int numCopies() const;
    00284     void setNumCopies(int n);
    00288     Orientation orientation() const;
    00292     void setOrientation(Orientation);
    00296     PageOrder pageOrder() const;
    00300     void setPageOrder(PageOrder);
    00304     CollateType collate() const;
    00308     void setCollate(CollateType type);
    00312     int minPage() const;
    00316     int maxPage() const;
    00320     void setMinMax(int, int);
    00329     int fromPage() const KDE_DEPRECATED;
    00338     int toPage() const;
    00342     void setFromTo(int, int);
    00346     PageSize pageSize() const;
    00350     void setPageSize(PageSize);
    00354     QString printerName() const;
    00358     void setPrinterName(const QString&);
    00365     QString printProgram() const;
    00394     void setPrintProgram(const QString& cmd);
    00398     QString printerSelectionOption() const;
    00402     void setPrinterSelectionOption(const QString&);
    00407     int currentPage() const;
    00435     void setCurrentPage(int p = 0);
    00439     PageSetType pageSet() const;
    00447     bool setup(QWidget *parent = 0, const QString& caption = QString::null, bool forceExpand = false);
    00451     QSize margins() const;
    00455     void setMargins(QSize m);
    00465     QSize realPageSize() const;
    00470     void setRealPageSize( QSize p );
    00475     void setRealDrawableArea( const QRect& r );
    00480     QRect realDrawableArea() const;
    00481
    00482     void margins( uint *top, uint *left, uint *bottom, uint *right ) const;
    00483     void setMargins( uint top, uint left, uint bottom, uint right );
    00484
    00491     QValueList<int> pageList() const;
    00511     void setPreviewOnly(bool on);
    00516     bool previewOnly() const;
    00525     void setResolution(int dpi);
    00531     int resolution() const;
    00532
    00543     void setUsePrinterResolution( bool on );
    00544
    00548     KPrinterImpl* implementation() const;
    00556     bool printFiles(const QStringList& files, bool removeafter = false, bool startviewer = true);
    00557
    00567     static void addDialogPage(KPrintDialogPage* _page);
    00574     static void setPageSelection(PageSelectionType _mode);
    00580     static PageSelectionType pageSelection();
    00587     static void setApplicationType(ApplicationType type);
    00593     static ApplicationType applicationType();
    00600     static void addStandardPage(int p);
    00608     static void removeStandardPage(int p);
    00615     //static int addPrinterWizard(QWidget *parent = 0);
    00616
    00647     const QString& option(const QString& key) const;
    00656     void setOption(const QString& key, const QString& value);
    00661     const QMap<QString,QString>& options() const;
    00668     void setOptions(const QMap<QString,QString>& opts);
    00675     void initOptions(const QMap<QString,QString>& opts);
    00676
    00683     QString searchName() const;
    00689     void setSearchName(const QString& n);
    00694     QString errorMessage() const;
    00699     void setErrorMessage(const QString& msg);
    00717     bool autoConfigure(const QString& prname = QString::null, QWidget *parent = 0);
    00726     void setDocFileName(const QString& filename);
    00733     QString docFileName() const;
    00741     void setDocDirectory( const QString& dir );
    00748     QString docDirectory() const;
    00749
    00750 protected:
    00751     virtual bool cmd(int, QPainter*, QPDevCmdParam*);
    00752     virtual int metric(int) const;
    00753     void translateQtOptions();
    00754     void loadSettings();
    00755     void saveSettings();
    00756     void preparePrinting();
    00757     void finishPrinting();
    00758     void reload();
    00759     void init(bool restore = true, QPrinter::PrinterMode m = QPrinter::ScreenResolution);
    00760     bool doPreview(const QString& file);
    00761     void setRealPageSize(DrPageSize* p);
    00762     void setOption( const QString& key, const QString& value, bool broadcast );
    00763
    00764 protected:
    00765     KPrinterPrivate     *d;
    00766 };
    00767
    00768 //**************************************************************************************
    00769
    00770 // Utility functions
    00771
    00772 KDEPRINT_EXPORT KPrinter::PageSize pageNameToPageSize(const QString& name);
    00773 KDEPRINT_EXPORT const char* pageSizeToPageName(KPrinter::PageSize s);
    00778 QSize rangeToSize( const QString& );
    00779
    00780 #endif

This file is part of the documentation for kdeprint Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:31:04 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003