Qt 4.8
Macros | Functions | Variables
qprinter.cpp File Reference
#include "qprinter_p.h"
#include "qprinter.h"
#include "qprintengine.h"
#include "qprinterinfo.h"
#include "qlist.h"
#include <qpagesetupdialog.h>
#include <qapplication.h>
#include <qfileinfo.h>
#include "private/qcups_p.h"
#include <private/qprintengine_win_p.h>
#include <private/qprintengine_ps_p.h>
#include <private/qt_x11_p.h>
#include "qprintengine_pdf_p.h"
#include <qpicture.h>
#include <private/qpaintengine_preview_p.h>

Go to the source code of this file.

Macros

#define ABORT_IF_ACTIVE(location)
 

Functions

QPrinter::PaperSize qSizeFTopaperSize (const QSizeF &size)
 
double qt_multiplierForUnit (QPrinter::Unit unit, int resolution)
 return the multiplier of converting from the unit value to postscript-points. More...
 
QSizeF qt_paperSizeToQSizeF (QPrinter::PaperSize size)
 
QSizeF qt_printerPaperSize (QPrinter::Orientation orientation, QPrinter::PaperSize paperSize, QPrinter::Unit unit, int resolution)
 

Variables

static const float qt_paperSizes [][2]
 

Macro Definition Documentation

◆ ABORT_IF_ACTIVE

#define ABORT_IF_ACTIVE (   location)

Function Documentation

◆ qSizeFTopaperSize()

QPrinter::PaperSize qSizeFTopaperSize ( const QSizeF size)

Definition at line 2629 of file qprinter.cpp.

Referenced by QPrinterInfo::supportedPaperSizes().

2630 {
2631  for (int i = 0; i < static_cast<int>(QPrinter::NPaperSize); ++i) {
2632  if (qt_paperSizes[i][0] >= size.width() - 1 &&
2633  qt_paperSizes[i][0] <= size.width() + 1 &&
2634  qt_paperSizes[i][1] >= size.height() - 1 &&
2635  qt_paperSizes[i][1] <= size.height() + 1) {
2636  return QPrinter::PaperSize(i);
2637  }
2638  }
2639 
2640  return QPrinter::Custom;
2641 }
qreal width() const
Returns the width.
Definition: qsize.h:284
qreal height() const
Returns the height.
Definition: qsize.h:287
PaperSize
This enum type specifies what paper size QPrinter should use.
Definition: qprinter.h:91
static const float qt_paperSizes[][2]
Definition: qprinter.cpp:89

◆ qt_multiplierForUnit()

double qt_multiplierForUnit ( QPrinter::Unit  unit,
int  resolution 
)

return the multiplier of converting from the unit value to postscript-points.

Definition at line 123 of file qprinter.cpp.

Referenced by QPageSetupWidget::_q_pageOrientationChanged(), QPrinter::getPageMargins(), QPrinter::pageRect(), QPrinter::paperRect(), QPrinter::paperSize(), qt_printerPaperSize(), QPrinter::setPageMargins(), QPrinter::setPaperSize(), and QPageSetupWidget::unitChanged().

124 {
125  switch(unit) {
127  return 2.83464566929;
128  case QPrinter::Point:
129  return 1.0;
130  case QPrinter::Inch:
131  return 72.0;
132  case QPrinter::Pica:
133  return 12;
134  case QPrinter::Didot:
135  return 1.065826771;
136  case QPrinter::Cicero:
137  return 12.789921252;
139  return 72.0/resolution;
140  }
141  return 1.0;
142 }

◆ qt_paperSizeToQSizeF()

QSizeF qt_paperSizeToQSizeF ( QPrinter::PaperSize  size)

Definition at line 2615 of file qprinter.cpp.

Referenced by QtopiaPrintEngine::paperRect(), QMacPrintEnginePrivate::paperSize(), QPdf::paperSize(), and QMacPrintEnginePrivate::setPaperSize().

2616 {
2617  if (size == QPrinter::Custom) return QSizeF(0, 0);
2618  return QSizeF(qt_paperSizes[size][0], qt_paperSizes[size][1]);
2619 }
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
static const float qt_paperSizes[][2]
Definition: qprinter.cpp:89

◆ qt_printerPaperSize()

QSizeF qt_printerPaperSize ( QPrinter::Orientation  orientation,
QPrinter::PaperSize  paperSize,
QPrinter::Unit  unit,
int  resolution 
)

Definition at line 145 of file qprinter.cpp.

Referenced by QPageSetupWidget::_q_paperSizeChanged(), and QPrinter::paperSize().

149 {
150  int width_index = 0;
151  int height_index = 1;
152  if (orientation == QPrinter::Landscape) {
153  width_index = 1;
154  height_index = 0;
155  }
156  const qreal multiplier = qt_multiplierForUnit(unit, resolution);
157  return QSizeF((qt_paperSizes[paperSize][width_index] * 72 / 25.4) / multiplier,
158  (qt_paperSizes[paperSize][height_index] * 72 / 25.4) / multiplier);
159 }
PaperSize paperSize(QPrinter::PaperSize paperSize)
Definition: qpdf.cpp:905
double qreal
Definition: qglobal.h:1193
double qt_multiplierForUnit(QPrinter::Unit unit, int resolution)
return the multiplier of converting from the unit value to postscript-points.
Definition: qprinter.cpp:123
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
static const float qt_paperSizes[][2]
Definition: qprinter.cpp:89

Variable Documentation

◆ qt_paperSizes

const float qt_paperSizes[][2]
static

Definition at line 89 of file qprinter.cpp.

Referenced by qSizeFTopaperSize(), qt_paperSizeToQSizeF(), and qt_printerPaperSize().