• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

KDEPrint

kprinter.h

Go to the documentation of this file.
00001 /*
00002  *  This file is part of the KDE libraries
00003  *  Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be>
00004  *  Copyright (C) 2007 Thomas Zander <zander@kde.org>
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., 51 Franklin Street, Fifth Floor,
00018  *  Boston, MA 02110-1301, USA.
00019  **/
00020 
00021 #ifndef KPRINTER_H
00022 #define KPRINTER_H
00023 
00024 #include <kdeprint_export.h>
00025 #include <kdeprint/kpreloadobject.h>
00026 
00027 #include <QtGui/QPaintDevice>
00028 #include <QtGui/QPrinter>
00029 #include <QtCore/QMap>
00030 #include <QtCore/QString>
00031 #include <QtCore/QStringList>
00032 
00033 class KPrinterImpl;
00034 class KPrintDialogPage;
00035 class KPrinterPrivate;
00036 class DrPageSize;
00037 
00086 class KDEPRINT_EXPORT KPrinter : public QPaintDevice, public KPReloadObject
00087 {
00088 public:
00089     // Print global settings (set via static functions)
00098     enum StandardPageType { CopiesPage = 0x01, FilesPage = 0x02, CustomPage = 0x10 };
00112     enum PageSelectionType { ApplicationSide = 0x01, SystemSide = 0x02 };
00122     enum ApplicationType { Dialog = 0x00, StandAlone = 0x01, StandAlonePersistent = 0x02 };
00123 
00124     // QPrinter extension
00133     enum PageSetType { AllPages = 0x00, OddPages = 0x01, EvenPages = 0x02 };
00141     enum CollateType { Collate = 0x00, Uncollate = 0x01 };
00142 
00143     // from QPrinter class
00148     enum ColorMode { GrayScale = QPrinter::GrayScale, Color = QPrinter::Color };
00153     enum Orientation { Portrait = QPrinter::Portrait, Landscape = QPrinter::Landscape };
00158     enum PageOrder { FirstPageFirst = QPrinter::FirstPageFirst, LastPageFirst = QPrinter::LastPageFirst };
00163     enum PageSize {
00164         A4 = QPrinter::A4,
00165         B5 = QPrinter::B5,
00166         Letter = QPrinter::Letter,
00167         Legal = QPrinter::Legal,
00168         Executive = QPrinter::Executive,
00169         A0 = QPrinter::A0,
00170         A1 = QPrinter::A1,
00171         A2 = QPrinter::A2,
00172         A3 = QPrinter::A3,
00173         A5 = QPrinter::A5,
00174         A6 = QPrinter::A6,
00175         A7 = QPrinter::A7,
00176         A8 = QPrinter::A8,
00177         A9 = QPrinter::A9,
00178         B0 = QPrinter::B0,
00179         B1 = QPrinter::B1,
00180         B10 = QPrinter::B10,
00181         B2 = QPrinter::B2,
00182         B3 = QPrinter::B3,
00183         B4 = QPrinter::B4,
00184         B6 = QPrinter::B6,
00185         B7 = QPrinter::B7,
00186         B8 = QPrinter::B8,
00187         B9 = QPrinter::B9,
00188         C5E = QPrinter::C5E,
00189         Comm10E = QPrinter::Comm10E,
00190         DLE = QPrinter::DLE,
00191         Folio = QPrinter::Folio,
00192         Ledger = QPrinter::Ledger,
00193         Tabloid = QPrinter::Tabloid,
00194         NPageSize = QPrinter::NPageSize,
00195         CustomSize = QPrinter::Custom
00196     };
00197 
00198     // constructors / destructor
00206     explicit KPrinter(bool restore = true, QPrinter::PrinterMode m = QPrinter::ScreenResolution);
00210     virtual ~KPrinter();
00211 
00212     // QPrinter interface (+ some extensions)
00216     bool newPage();
00220     bool abort();
00224     bool aborted() const;
00228     bool outputToFile() const;
00232     void setOutputToFile(bool);
00236     QString outputFileName() const;
00240     void setOutputFileName(const QString&);
00244     QString docName() const;
00248     void setDocName(const QString&);
00252     QString creator() const;
00256     void setCreator(const QString&);
00260     bool fullPage() const;
00264     void setFullPage(bool);
00268     ColorMode colorMode() const;
00272     void setColorMode(ColorMode);
00276     int numCopies() const;
00280     void setNumCopies(int n);
00284     Orientation orientation() const;
00288     void setOrientation(Orientation);
00292     PageOrder pageOrder() const;
00296     void setPageOrder(PageOrder);
00300     CollateType collate() const;
00304     void setCollate(CollateType type);
00308     int minPage() const;
00312     int maxPage() const;
00316     void setMinMax(int min, int max);
00325     KDE_DEPRECATED int fromPage() const;
00334     int toPage() const;
00338     void setFromTo(int, int);
00342     PageSize pageSize() const;
00346     void setPageSize(PageSize);
00350     QString printerName() const;
00354     void setPrinterName(const QString&);
00361     QString printProgram() const;
00390     void setPrintProgram(const QString& cmd);
00394     QString printerSelectionOption() const;
00398     void setPrinterSelectionOption(const QString&);
00403     int currentPage() const;
00431     void setCurrentPage(int p = 0);
00435     PageSetType pageSet() const;
00443     bool setup(QWidget *parent = 0, const QString& caption = QString(), bool forceExpand = false);
00447     QSize margins() const;
00451     void setMargins(QSize m);
00461     KDE_DEPRECATED QSize realPageSize() const;
00466     KDE_DEPRECATED void setRealPageSize(const QSize &p);
00471     KDE_DEPRECATED void setRealDrawableArea(const QRect& r);
00476     KDE_DEPRECATED QRect realDrawableArea() const;
00477 
00478     void margins(uint *top, uint *left, uint *bottom, uint *right) const;
00479     void setMargins(uint top, uint left, uint bottom, uint right);
00480 
00487     QList<int> pageList() const;
00507     void setPreviewOnly(bool on);
00512     bool previewOnly() const;
00521     void setResolution(int dpi);
00527     int resolution() const;
00528 
00539     void setUsePrinterResolution(bool on);
00540 
00544     KPrinterImpl* implementation() const;
00552     bool printFiles(const QStringList& files, bool removeafter = false, bool startviewer = true);
00553 
00563     static void addDialogPage(KPrintDialogPage* _page);
00570     static void setPageSelection(PageSelectionType _mode);
00576     static PageSelectionType pageSelection();
00583     static void setApplicationType(ApplicationType type);
00589     static ApplicationType applicationType();
00596     static void addStandardPage(int p);
00604     static void removeStandardPage(int p);
00611     //static int addPrinterWizard(QWidget *parent = 0);
00612 
00643     QString option(const QString& key) const;
00652     void setOption(const QString& key, const QString& value);
00657     QMap<QString, QString> options() const;
00664     void setOptions(const QMap<QString, QString>& opts);
00671     void initOptions(const QMap<QString, QString>& opts);
00672 
00679     QString searchName() const;
00685     void setSearchName(const QString& n);
00690     QString errorMessage() const;
00695     void setErrorMessage(const QString& msg);
00713     bool autoConfigure(const QString& prname = QString(), QWidget *parent = 0);
00722     void setDocFileName(const QString& filename);
00729     QString docFileName() const;
00737     void setDocDirectory(const QString& dir);
00744     QString docDirectory() const;
00745 
00747     void setOutputFormat(QPrinter::OutputFormat format);
00749     QPrinter::OutputFormat outputFormat() const;
00750 
00752     void setPaperSource(QPrinter::PaperSource papersource);
00754     QPrinter::PaperSource paperSource() const;
00755 
00757     QList< int > supportedResolutions() const;
00758 
00760     void setFontEmbeddingEnabled(bool enable);
00762     bool fontEmbeddingEnabled() const;
00763 
00765     void setDoubleSidedPrinting(bool enable);
00767     bool doubleSidedPrinting() const;
00768 
00770     QRect paperRect() const;
00772     QRect pageRect() const;
00774     QPrinter::PrinterState printerState() const;
00775 
00776 protected:
00777     virtual int devType() const;
00778     virtual QPaintEngine * paintEngine() const;
00779     virtual int metric(PaintDeviceMetric metric) const;
00780     void translateQtOptions();
00781     void loadSettings();
00782     void saveSettings();
00783     void preparePrinting();
00784     void finishPrinting();
00785     void reload();
00786     void init(bool restore = true, QPrinter::PrinterMode m = QPrinter::ScreenResolution);
00787     bool doPreview(const QString& file);
00788     void setRealPageSize(DrPageSize* p);
00789     void setOption(const QString& key, const QString& value, bool broadcast);
00790 
00791 private:
00792     KPrinterPrivate* const d;
00793     friend class KPrinterEngine;
00794     friend class KPrinterImpl;
00795 };
00796 
00797 //**************************************************************************************
00798 
00799 // Utility functions
00800 
00801 KDEPRINT_EXPORT KPrinter::PageSize pageNameToPageSize(const QString& name, bool *ok = 0);
00802 KDEPRINT_EXPORT const char* pageSizeToPageName(KPrinter::PageSize s);
00803 
00804 #endif

KDEPrint

Skip menu "KDEPrint"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  •   KDEPrint
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal