1 | /****************************************************************************
|
---|
2 | ** $Id: qpaintdevicemetrics.cpp 2 2005-11-16 15:49:26Z dmik $
|
---|
3 | **
|
---|
4 | ** Implementation of QPaintDeviceMetrics class
|
---|
5 | **
|
---|
6 | ** Created : 941109
|
---|
7 | **
|
---|
8 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
|
---|
9 | **
|
---|
10 | ** This file is part of the kernel module of the Qt GUI Toolkit.
|
---|
11 | **
|
---|
12 | ** This file may be distributed under the terms of the Q Public License
|
---|
13 | ** as defined by Trolltech AS of Norway and appearing in the file
|
---|
14 | ** LICENSE.QPL included in the packaging of this file.
|
---|
15 | **
|
---|
16 | ** This file may be distributed and/or modified under the terms of the
|
---|
17 | ** GNU General Public License version 2 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
19 | ** packaging of this file.
|
---|
20 | **
|
---|
21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
---|
22 | ** licenses may use this file in accordance with the Qt Commercial License
|
---|
23 | ** Agreement provided with the Software.
|
---|
24 | **
|
---|
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
27 | **
|
---|
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
29 | ** information about Qt Commercial License Agreements.
|
---|
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
---|
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
32 | **
|
---|
33 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
34 | ** not clear to you.
|
---|
35 | **
|
---|
36 | **********************************************************************/
|
---|
37 |
|
---|
38 | #include "qpaintdevicemetrics.h"
|
---|
39 |
|
---|
40 | /*!
|
---|
41 | \class QPaintDeviceMetrics qpaintdevicemetrics.h
|
---|
42 | \brief The QPaintDeviceMetrics class provides information about a
|
---|
43 | paint device.
|
---|
44 |
|
---|
45 | \ingroup graphics
|
---|
46 | \ingroup images
|
---|
47 |
|
---|
48 | Sometimes when drawing graphics it is necessary to obtain
|
---|
49 | information about the physical characteristics of a paint device.
|
---|
50 | This class provides the information. For example, to compute the
|
---|
51 | aspect ratio of a paint device:
|
---|
52 |
|
---|
53 | \code
|
---|
54 | QPaintDeviceMetrics pdm( myWidget );
|
---|
55 | double aspect = (double)pdm.widthMM() / (double)pdm.heightMM();
|
---|
56 | \endcode
|
---|
57 |
|
---|
58 | QPaintDeviceMetrics contains methods to provide the width and
|
---|
59 | height of a device in both pixels (width() and height()) and
|
---|
60 | millimeters (widthMM() and heightMM()), the number of colors the
|
---|
61 | device supports (numColors()), the number of bit planes (depth()),
|
---|
62 | and the resolution of the device (logicalDpiX() and
|
---|
63 | logicalDpiY()).
|
---|
64 |
|
---|
65 | It is not always possible for QPaintDeviceMetrics to compute the
|
---|
66 | values you ask for, particularly for external devices. The
|
---|
67 | ultimate example is asking for the resolution of of a QPrinter
|
---|
68 | that is set to "print to file": who knows what printer that file
|
---|
69 | will end up on?
|
---|
70 | */
|
---|
71 |
|
---|
72 | /*!
|
---|
73 | Constructs a metric for the paint device \a pd.
|
---|
74 | */
|
---|
75 | QPaintDeviceMetrics::QPaintDeviceMetrics( const QPaintDevice *pd )
|
---|
76 | {
|
---|
77 | pdev = (QPaintDevice *)pd;
|
---|
78 | }
|
---|
79 |
|
---|
80 |
|
---|
81 | /*!
|
---|
82 | \fn int QPaintDeviceMetrics::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 QPaintDeviceMetrics::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 QPaintDeviceMetrics::widthMM() const
|
---|
97 |
|
---|
98 | Returns the width of the paint device, measured in millimeters.
|
---|
99 | */
|
---|
100 |
|
---|
101 | /*!
|
---|
102 | \fn int QPaintDeviceMetrics::heightMM() const
|
---|
103 |
|
---|
104 | Returns the height of the paint device, measured in millimeters.
|
---|
105 | */
|
---|
106 |
|
---|
107 | /*!
|
---|
108 | \fn int QPaintDeviceMetrics::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 QPaintDeviceMetrics::depth() const
|
---|
118 |
|
---|
119 | Returns the bit depth (number of bit planes) of the paint device.
|
---|
120 | */
|
---|
121 |
|
---|
122 | /*!
|
---|
123 | \fn int QPaintDeviceMetrics::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 QPaintDeviceMetrics::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 QPaintDeviceMetrics::physicalDpiX() const
|
---|
142 | \internal
|
---|
143 | */
|
---|
144 | /*!
|
---|
145 | \fn int QPaintDeviceMetrics::physicalDpiY() const
|
---|
146 | \internal
|
---|
147 | */
|
---|
148 |
|
---|