| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** Contact: Qt Software Information ([email protected])
|
|---|
| 5 | **
|
|---|
| 6 | ** This file is part of the Qt3Support module of the Qt Toolkit.
|
|---|
| 7 | **
|
|---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 9 | ** Commercial Usage
|
|---|
| 10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 11 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 13 | ** a written agreement between you and Nokia.
|
|---|
| 14 | **
|
|---|
| 15 | ** GNU Lesser General Public License Usage
|
|---|
| 16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 17 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 19 | ** packaging of this file. Please review the following information to
|
|---|
| 20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 22 | **
|
|---|
| 23 | ** In addition, as a special exception, Nokia gives you certain
|
|---|
| 24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
|---|
| 25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
|---|
| 26 | ** package.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you are unsure which license is appropriate for your use, please
|
|---|
| 37 | ** contact the sales department at [email protected].
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | #include "q3paintdevicemetrics.h"
|
|---|
| 43 |
|
|---|
| 44 | QT_BEGIN_NAMESPACE
|
|---|
| 45 |
|
|---|
| 46 | /*!
|
|---|
| 47 | \class Q3PaintDeviceMetrics
|
|---|
| 48 | \brief The Q3PaintDeviceMetrics class provides information about a
|
|---|
| 49 | paint device.
|
|---|
| 50 |
|
|---|
| 51 | \compat
|
|---|
| 52 |
|
|---|
| 53 | Sometimes when drawing graphics it is necessary to obtain
|
|---|
| 54 | information about the physical characteristics of a paint device.
|
|---|
| 55 | This class provides the information. For example, to compute the
|
|---|
| 56 | aspect ratio of a paint device:
|
|---|
| 57 |
|
|---|
| 58 | \snippet doc/src/snippets/code/src_qt3support_painting_q3paintdevicemetrics.cpp 0
|
|---|
| 59 |
|
|---|
| 60 | Q3PaintDeviceMetrics contains methods to provide the width and
|
|---|
| 61 | height of a device in both pixels (width() and height()) and
|
|---|
| 62 | millimeters (widthMM() and heightMM()), the number of colors the
|
|---|
| 63 | device supports (numColors()), the number of bit planes (depth()),
|
|---|
| 64 | and the resolution of the device (logicalDpiX() and
|
|---|
| 65 | logicalDpiY()).
|
|---|
| 66 |
|
|---|
| 67 | It is not always possible for Q3PaintDeviceMetrics to compute the
|
|---|
| 68 | values you ask for, particularly for external devices. The
|
|---|
| 69 | ultimate example is asking for the resolution of of a QPrinter
|
|---|
| 70 | that is set to "print to file": who knows what printer that file
|
|---|
| 71 | will end up on?
|
|---|
| 72 | */
|
|---|
| 73 |
|
|---|
| 74 | /*!
|
|---|
| 75 | \fn Q3PaintDeviceMetrics::Q3PaintDeviceMetrics(const QPaintDevice *pd)
|
|---|
| 76 |
|
|---|
| 77 | Constructs a metric for the paint device \a pd.
|
|---|
| 78 | */
|
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 | /*!
|
|---|
| 82 | \fn int Q3PaintDeviceMetrics::width() const
|
|---|
| 83 |
|
|---|
| 84 | Returns the width of the paint device in default coordinate system
|
|---|
| 85 | units (e.g. pixels for QPixmap and QWidget).
|
|---|
| 86 | */
|
|---|
| 87 |
|
|---|
| 88 | /*!
|
|---|
| 89 | \fn int Q3PaintDeviceMetrics::height() const
|
|---|
| 90 |
|
|---|
| 91 | Returns the height of the paint device in default coordinate
|
|---|
| 92 | system units (e.g. pixels for QPixmap and QWidget).
|
|---|
| 93 | */
|
|---|
| 94 |
|
|---|
| 95 | /*!
|
|---|
| 96 | \fn int Q3PaintDeviceMetrics::widthMM() const
|
|---|
| 97 |
|
|---|
| 98 | Returns the width of the paint device, measured in millimeters.
|
|---|
| 99 | */
|
|---|
| 100 |
|
|---|
| 101 | /*!
|
|---|
| 102 | \fn int Q3PaintDeviceMetrics::heightMM() const
|
|---|
| 103 |
|
|---|
| 104 | Returns the height of the paint device, measured in millimeters.
|
|---|
| 105 | */
|
|---|
| 106 |
|
|---|
| 107 | /*!
|
|---|
| 108 | \fn int Q3PaintDeviceMetrics::numColors() const
|
|---|
| 109 |
|
|---|
| 110 | Returns the number of different colors available for the paint
|
|---|
| 111 | device. Since this value is an int will not be sufficient to represent
|
|---|
| 112 | the number of colors on 32 bit displays, in which case INT_MAX is
|
|---|
| 113 | returned instead.
|
|---|
| 114 | */
|
|---|
| 115 |
|
|---|
| 116 | /*!
|
|---|
| 117 | \fn int Q3PaintDeviceMetrics::depth() const
|
|---|
| 118 |
|
|---|
| 119 | Returns the bit depth (number of bit planes) of the paint device.
|
|---|
| 120 | */
|
|---|
| 121 |
|
|---|
| 122 | /*!
|
|---|
| 123 | \fn int Q3PaintDeviceMetrics::logicalDpiX() const
|
|---|
| 124 |
|
|---|
| 125 | Returns the horizontal resolution of the device in dots per inch,
|
|---|
| 126 | which is used when computing font sizes. For X, this is usually
|
|---|
| 127 | the same as could be computed from widthMM(), but it varies on
|
|---|
| 128 | Windows.
|
|---|
| 129 | */
|
|---|
| 130 |
|
|---|
| 131 | /*!
|
|---|
| 132 | \fn int Q3PaintDeviceMetrics::logicalDpiY() const
|
|---|
| 133 |
|
|---|
| 134 | Returns the vertical resolution of the device in dots per inch,
|
|---|
| 135 | which is used when computing font sizes. For X, this is usually
|
|---|
| 136 | the same as could be computed from heightMM(), but it varies on
|
|---|
| 137 | Windows.
|
|---|
| 138 | */
|
|---|
| 139 |
|
|---|
| 140 | /*!
|
|---|
| 141 | \fn int Q3PaintDeviceMetrics::physicalDpiX() const
|
|---|
| 142 | \internal
|
|---|
| 143 | */
|
|---|
| 144 | /*!
|
|---|
| 145 | \fn int Q3PaintDeviceMetrics::physicalDpiY() const
|
|---|
| 146 | \internal
|
|---|
| 147 | */
|
|---|
| 148 |
|
|---|
| 149 | QT_END_NAMESPACE
|
|---|