kprinter.h
/*
* This file is part of the KDE libraries
* Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be>
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
**/
#ifndef KPRINTER_H
#define KPRINTER_H
#include <qpaintdevice.h>
#include <qprinter.h>
#include <qmap.h>
#include <qstring.h>
#include <qstringlist.h>
#include <qvaluelist.h>
#include <kdemacros.h>
#include <kdelibs_export.h>
#include <kdeprint/kpreloadobject.h>
class KPrinterImpl;
class KPrintDialogPage;
class KPrinterPrivate;
class DrPageSize;
class KDEPRINT_EXPORT KPrinter : public QPaintDevice, public KPReloadObject
{
friend class KPrinterWrapper;
friend class KPrinterImpl;
public:
// Print global settings (set via static functions)
enum StandardPageType { CopiesPage = 0x01, FilesPage = 0x02, Custom = 0x10 };
enum PageSelectionType { ApplicationSide = 0x01, SystemSide = 0x02 };
enum ApplicationType { Dialog = 0x00, StandAlone = 0x01, StandAlonePersistent = 0x02 };
// QPrinter extension
enum PageSetType { AllPages = 0x00, OddPages = 0x01, EvenPages = 0x02 };
enum CollateType { Collate = 0x00, Uncollate = 0x01 };
// from QPrinter class
enum ColorMode { GrayScale = QPrinter::GrayScale, Color = QPrinter::Color };
enum Orientation { Portrait = QPrinter::Portrait, Landscape = QPrinter::Landscape };
enum PageOrder { FirstPageFirst = QPrinter::FirstPageFirst, LastPageFirst = QPrinter::LastPageFirst };
enum PageSize
{
A4 = QPrinter::A4,
B5 = QPrinter::B5,
Letter = QPrinter::Letter,
Legal = QPrinter::Legal,
Executive = QPrinter::Executive,
A0 = QPrinter::A0,
A1 = QPrinter::A1,
A2 = QPrinter::A2,
A3 = QPrinter::A3,
A5 = QPrinter::A5,
A6 = QPrinter::A6,
A7 = QPrinter::A7,
A8 = QPrinter::A8,
A9 = QPrinter::A9,
B0 = QPrinter::B0,
B1 = QPrinter::B1,
B10 = QPrinter::B10,
B2 = QPrinter::B2,
B3 = QPrinter::B3,
B4 = QPrinter::B4,
B6 = QPrinter::B6,
B7 = QPrinter::B7,
B8 = QPrinter::B8,
B9 = QPrinter::B9,
C5E = QPrinter::C5E,
Comm10E = QPrinter::Comm10E,
DLE = QPrinter::DLE,
Folio = QPrinter::Folio,
Ledger = QPrinter::Ledger,
Tabloid = QPrinter::Tabloid,
NPageSize = QPrinter::NPageSize
};
// constructors / destructor
KPrinter(bool restore = true, QPrinter::PrinterMode m = QPrinter::ScreenResolution );
~KPrinter();
// QPrinter interface (+ some extensions)
bool newPage();
bool abort();
bool aborted() const;
bool outputToFile() const;
void setOutputToFile(bool);
QString outputFileName() const;
void setOutputFileName(const QString&);
QString docName() const;
void setDocName(const QString&);
QString creator() const;
void setCreator(const QString&);
bool fullPage() const;
void setFullPage(bool);
ColorMode colorMode() const;
void setColorMode(ColorMode);
int numCopies() const;
void setNumCopies(int n);
Orientation orientation() const;
void setOrientation(Orientation);
PageOrder pageOrder() const;
void setPageOrder(PageOrder);
CollateType collate() const;
void setCollate(CollateType type);
int minPage() const;
int maxPage() const;
void setMinMax(int, int);
int fromPage() const KDE_DEPRECATED;
int toPage() const;
void setFromTo(int, int);
PageSize pageSize() const;
void setPageSize(PageSize);
QString printerName() const;
void setPrinterName(const QString&);
QString printProgram() const;
void setPrintProgram(const QString& cmd);
QString printerSelectionOption() const;
void setPrinterSelectionOption(const QString&);
int currentPage() const;
void setCurrentPage(int p = 0);
PageSetType pageSet() const;
bool setup(QWidget *parent = 0, const QString& caption = QString::null, bool forceExpand = false);
QSize margins() const;
void setMargins(QSize m);
QSize realPageSize() const;
void setRealPageSize( QSize p );
void setRealDrawableArea( const QRect& r );
QRect realDrawableArea() const;
void margins( uint *top, uint *left, uint *bottom, uint *right ) const;
void setMargins( uint top, uint left, uint bottom, uint right );
QValueList<int> pageList() const;
void setPreviewOnly(bool on);
bool previewOnly() const;
void setResolution(int dpi);
int resolution() const;
void setUsePrinterResolution( bool on );
KPrinterImpl* implementation() const;
bool printFiles(const QStringList& files, bool removeafter = false, bool startviewer = true);
static void addDialogPage(KPrintDialogPage* _page);
static void setPageSelection(PageSelectionType _mode);
static PageSelectionType pageSelection();
static void setApplicationType(ApplicationType type);
static ApplicationType applicationType();
static void addStandardPage(int p);
static void removeStandardPage(int p);
//static int addPrinterWizard(QWidget *parent = 0);
const QString& option(const QString& key) const;
void setOption(const QString& key, const QString& value);
const QMap<QString,QString>& options() const;
void setOptions(const QMap<QString,QString>& opts);
void initOptions(const QMap<QString,QString>& opts);
QString searchName() const;
void setSearchName(const QString& n);
QString errorMessage() const;
void setErrorMessage(const QString& msg);
bool autoConfigure(const QString& prname = QString::null, QWidget *parent = 0);
void setDocFileName(const QString& filename);
QString docFileName() const;
void setDocDirectory( const QString& dir );
QString docDirectory() const;
protected:
virtual bool cmd(int, QPainter*, QPDevCmdParam*);
virtual int metric(int) const;
void translateQtOptions();
void loadSettings();
void saveSettings();
void preparePrinting();
void finishPrinting();
void reload();
void init(bool restore = true, QPrinter::PrinterMode m = QPrinter::ScreenResolution);
bool doPreview(const QString& file);
void setRealPageSize(DrPageSize* p);
void setOption( const QString& key, const QString& value, bool broadcast );
protected:
KPrinterPrivate *d;
};
//**************************************************************************************
// Utility functions
KDEPRINT_EXPORT KPrinter::PageSize pageNameToPageSize(const QString& name);
KDEPRINT_EXPORT const char* pageSizeToPageName(KPrinter::PageSize s);
QSize rangeToSize( const QString& );
#endif
KPrinter::ColorMode
ColorMode
Defines the color mode of the printer.
Definition: kprinter.h:152
KPrinter::ApplicationType
ApplicationType
Defines the type of the application, this affects the GUI of the print dialog:
Definition: kprinter.h:126
KPrinter
This class is the main interface to access the KDE print framework.
Definition: kprinter.h:88
KPrinter::PageSetType
PageSetType
Defines the page set to print:
Definition: kprinter.h:137
KPrinter::PageOrder
PageOrder
Defines the page order of the print job.
Definition: kprinter.h:162
KPrinter::PageSelectionType
PageSelectionType
Defines whether the application can perform page selection itself or not.
Definition: kprinter.h:116
KPrintDialogPage
This class is intended to be used as base class for customized print dialog page. ...
Definition: kprintdialogpage.h:90
KPrinter::CollateType
CollateType
Defines the collate property of the printer (if supported by the print system):
Definition: kprinter.h:145
KPrinter::PageSize
PageSize
Defines the paper size to use.
Definition: kprinter.h:167
KPrinter::StandardPageType
StandardPageType
Defines the standard pages available for the print dialog:
Definition: kprinter.h:102
KPrinter::Orientation
Orientation
Defines the orientation of the paper.
Definition: kprinter.h:157

KDE Home | KDE Accessibility Home | Description of Access Keys