00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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 #include <kdeprint/kpreloadobject.h>
00033
00034 class KPrinterImpl;
00035 class KPrintDialogPage;
00036 class KPrinterPrivate;
00037 class DrPageSize;
00038
00087 class KDEPRINT_EXPORT KPrinter : public QPaintDevice, public KPReloadObject
00088 {
00089 friend class KPrinterWrapper;
00090 friend class KPrinterImpl;
00091 public:
00092
00101 enum StandardPageType { CopiesPage = 0x01, FilesPage = 0x02, Custom = 0x10 };
00115 enum PageSelectionType { ApplicationSide = 0x01, SystemSide = 0x02 };
00125 enum ApplicationType { Dialog = 0x00, StandAlone = 0x01, StandAlonePersistent = 0x02 };
00126
00127
00136 enum PageSetType { AllPages = 0x00, OddPages = 0x01, EvenPages = 0x02 };
00144 enum CollateType { Collate = 0x00, Uncollate = 0x01 };
00145
00146
00151 enum ColorMode { GrayScale = QPrinter::GrayScale, Color = QPrinter::Color };
00156 enum Orientation { Portrait = QPrinter::Portrait, Landscape = QPrinter::Landscape };
00161 enum PageOrder { FirstPageFirst = QPrinter::FirstPageFirst, LastPageFirst = QPrinter::LastPageFirst };
00166 enum PageSize
00167 {
00168 A4 = QPrinter::A4,
00169 B5 = QPrinter::B5,
00170 Letter = QPrinter::Letter,
00171 Legal = QPrinter::Legal,
00172 Executive = QPrinter::Executive,
00173 A0 = QPrinter::A0,
00174 A1 = QPrinter::A1,
00175 A2 = QPrinter::A2,
00176 A3 = QPrinter::A3,
00177 A5 = QPrinter::A5,
00178 A6 = QPrinter::A6,
00179 A7 = QPrinter::A7,
00180 A8 = QPrinter::A8,
00181 A9 = QPrinter::A9,
00182 B0 = QPrinter::B0,
00183 B1 = QPrinter::B1,
00184 B10 = QPrinter::B10,
00185 B2 = QPrinter::B2,
00186 B3 = QPrinter::B3,
00187 B4 = QPrinter::B4,
00188 B6 = QPrinter::B6,
00189 B7 = QPrinter::B7,
00190 B8 = QPrinter::B8,
00191 B9 = QPrinter::B9,
00192 C5E = QPrinter::C5E,
00193 Comm10E = QPrinter::Comm10E,
00194 DLE = QPrinter::DLE,
00195 Folio = QPrinter::Folio,
00196 Ledger = QPrinter::Ledger,
00197 Tabloid = QPrinter::Tabloid,
00198 NPageSize = QPrinter::NPageSize
00199 };
00200
00201
00209 KPrinter(bool restore = true, QPrinter::PrinterMode m = QPrinter::ScreenResolution );
00213 ~KPrinter();
00214
00215
00219 bool newPage();
00223 bool abort();
00227 bool aborted() const;
00231 bool outputToFile() const;
00235 void setOutputToFile(bool);
00239 QString outputFileName() const;
00243 void setOutputFileName(const QString&);
00247 QString docName() const;
00251 void setDocName(const QString&);
00255 QString creator() const;
00259 void setCreator(const QString&);
00263 bool fullPage() const;
00267 void setFullPage(bool);
00271 ColorMode colorMode() const;
00275 void setColorMode(ColorMode);
00279 int numCopies() const;
00283 void setNumCopies(int n);
00287 Orientation orientation() const;
00291 void setOrientation(Orientation);
00295 PageOrder pageOrder() const;
00299 void setPageOrder(PageOrder);
00303 CollateType collate() const;
00307 void setCollate(CollateType type);
00311 int minPage() const;
00315 int maxPage() const;
00319 void setMinMax(int, int);
00328 int fromPage() const KDE_DEPRECATED;
00337 int toPage() const;
00341 void setFromTo(int, int);
00345 PageSize pageSize() const;
00349 void setPageSize(PageSize);
00353 QString printerName() const;
00357 void setPrinterName(const QString&);
00364 QString printProgram() const;
00393 void setPrintProgram(const QString& cmd);
00397 QString printerSelectionOption() const;
00401 void setPrinterSelectionOption(const QString&);
00406 int currentPage() const;
00434 void setCurrentPage(int p = 0);
00438 PageSetType pageSet() const;
00446 bool setup(QWidget *parent = 0, const QString& caption = QString::null, bool forceExpand = false);
00450 QSize margins() const;
00454 void setMargins(QSize m);
00464 QSize realPageSize() const;
00469 void setRealPageSize( QSize p );
00474 void setRealDrawableArea( const QRect& r );
00479 QRect realDrawableArea() const;
00480
00481 void margins( uint *top, uint *left, uint *bottom, uint *right ) const;
00482 void setMargins( uint top, uint left, uint bottom, uint right );
00483
00490 QValueList<int> pageList() const;
00510 void setPreviewOnly(bool on);
00515 bool previewOnly() const;
00524 void setResolution(int dpi);
00530 int resolution() const;
00531
00542 void setUsePrinterResolution( bool on );
00543
00547 KPrinterImpl* implementation() const;
00555 bool printFiles(const QStringList& files, bool removeafter = false, bool startviewer = true);
00556
00566 static void addDialogPage(KPrintDialogPage* _page);
00573 static void setPageSelection(PageSelectionType _mode);
00579 static PageSelectionType pageSelection();
00586 static void setApplicationType(ApplicationType type);
00592 static ApplicationType applicationType();
00599 static void addStandardPage(int p);
00607 static void removeStandardPage(int p);
00614
00615
00646 const QString& option(const QString& key) const;
00655 void setOption(const QString& key, const QString& value);
00660 const QMap<QString,QString>& options() const;
00667 void setOptions(const QMap<QString,QString>& opts);
00674 void initOptions(const QMap<QString,QString>& opts);
00675
00682 QString searchName() const;
00688 void setSearchName(const QString& n);
00693 QString errorMessage() const;
00698 void setErrorMessage(const QString& msg);
00716 bool autoConfigure(const QString& prname = QString::null, QWidget *parent = 0);
00725 void setDocFileName(const QString& filename);
00732 QString docFileName() const;
00740 void setDocDirectory( const QString& dir );
00747 QString docDirectory() const;
00748
00749 protected:
00750 virtual bool cmd(int, QPainter*, QPDevCmdParam*);
00751 virtual int metric(int) const;
00752 void translateQtOptions();
00753 void loadSettings();
00754 void saveSettings();
00755 void preparePrinting();
00756 void finishPrinting();
00757 void reload();
00758 void init(bool restore = true, QPrinter::PrinterMode m = QPrinter::ScreenResolution);
00759 bool doPreview(const QString& file);
00760 void setRealPageSize(DrPageSize* p);
00761 void setOption( const QString& key, const QString& value, bool broadcast );
00762
00763 protected:
00764 KPrinterPrivate *d;
00765 };
00766
00767
00768
00769
00770
00771 KDEPRINT_EXPORT KPrinter::PageSize pageNameToPageSize(const QString& name);
00772 KDEPRINT_EXPORT const char* pageSizeToPageName(KPrinter::PageSize s);
00777 QSize rangeToSize( const QString& );
00778
00779 #endif