1 /****************************************************************************
2 **
3 ** DQt - D bindings for the Qt Toolkit
4 **
5 ** GNU Lesser General Public License Usage
6 ** This file may be used under the terms of the GNU Lesser
7 ** General Public License version 3 as published by the Free Software
8 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
9 ** packaging of this file. Please review the following information to
10 ** ensure the GNU Lesser General Public License version 3 requirements
11 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
12 **
13 ****************************************************************************/
14 module qt.gui.pagesize;
15 extern(C++):
16 
17 import qt.config;
18 import qt.core.rect;
19 import qt.core.shareddata;
20 import qt.core.size;
21 import qt.core.string;
22 import qt.core.typeinfo;
23 import qt.helpers;
24 
25 /+ #if defined(B0)
26 #undef B0 // Terminal hang-up.  We assume that you do not want that.
27 #endif +/
28 
29 extern(C++, class) struct QPageSizePrivate;
30 /+ class QString;
31 class QSize;
32 class QSizeF; +/
33 
34 @Q_MOVABLE_TYPE extern(C++, class) struct /+ Q_GUI_EXPORT +/ QPageSize
35 {
36 public:
37 
38     // ### Qt6 Re-order and remove duplicates
39     // NOTE: Must keep in sync with QPagedPrintEngine and QPrinter
40     enum PageSizeId {
41         // Existing Qt sizes
42         A4,
43         B5,
44         Letter,
45         Legal,
46         Executive,
47         A0,
48         A1,
49         A2,
50         A3,
51         A5,
52         A6,
53         A7,
54         A8,
55         A9,
56         B0,
57         B1,
58         B10,
59         B2,
60         B3,
61         B4,
62         B6,
63         B7,
64         B8,
65         B9,
66         C5E,
67         Comm10E,
68         DLE,
69         Folio,
70         Ledger,
71         Tabloid,
72         Custom,
73 
74         // New values derived from PPD standard
75         A10,
76         A3Extra,
77         A4Extra,
78         A4Plus,
79         A4Small,
80         A5Extra,
81         B5Extra,
82 
83         JisB0,
84         JisB1,
85         JisB2,
86         JisB3,
87         JisB4,
88         JisB5,
89         JisB6,
90         JisB7,
91         JisB8,
92         JisB9,
93         JisB10,
94 
95         // AnsiA = Letter,
96         // AnsiB = Ledger,
97         AnsiC,
98         AnsiD,
99         AnsiE,
100         LegalExtra,
101         LetterExtra,
102         LetterPlus,
103         LetterSmall,
104         TabloidExtra,
105 
106         ArchA,
107         ArchB,
108         ArchC,
109         ArchD,
110         ArchE,
111 
112         Imperial7x9,
113         Imperial8x10,
114         Imperial9x11,
115         Imperial9x12,
116         Imperial10x11,
117         Imperial10x13,
118         Imperial10x14,
119         Imperial12x11,
120         Imperial15x11,
121 
122         ExecutiveStandard,
123         Note,
124         Quarto,
125         Statement,
126         SuperA,
127         SuperB,
128         Postcard,
129         DoublePostcard,
130         Prc16K,
131         Prc32K,
132         Prc32KBig,
133 
134         FanFoldUS,
135         FanFoldGerman,
136         FanFoldGermanLegal,
137 
138         EnvelopeB4,
139         EnvelopeB5,
140         EnvelopeB6,
141         EnvelopeC0,
142         EnvelopeC1,
143         EnvelopeC2,
144         EnvelopeC3,
145         EnvelopeC4,
146         // EnvelopeC5 = C5E,
147         EnvelopeC6,
148         EnvelopeC65,
149         EnvelopeC7,
150         // EnvelopeDL = DLE,
151 
152         Envelope9,
153         // Envelope10 = Comm10E,
154         Envelope11,
155         Envelope12,
156         Envelope14,
157         EnvelopeMonarch,
158         EnvelopePersonal,
159 
160         EnvelopeChou3,
161         EnvelopeChou4,
162         EnvelopeInvite,
163         EnvelopeItalian,
164         EnvelopeKaku2,
165         EnvelopeKaku3,
166         EnvelopePrc1,
167         EnvelopePrc2,
168         EnvelopePrc3,
169         EnvelopePrc4,
170         EnvelopePrc5,
171         EnvelopePrc6,
172         EnvelopePrc7,
173         EnvelopePrc8,
174         EnvelopePrc9,
175         EnvelopePrc10,
176         EnvelopeYou4,
177 
178         // Last item, with commonly used synynoms from QPagedPrintEngine / QPrinter
179         LastPageSize = PageSizeId.EnvelopeYou4,
180         NPageSize = PageSizeId.LastPageSize,
181         NPaperSize = PageSizeId.LastPageSize,
182 
183         // Convenience overloads for naming consistency
184         AnsiA = PageSizeId.Letter,
185         AnsiB = PageSizeId.Ledger,
186         EnvelopeC5 = PageSizeId.C5E,
187         EnvelopeDL = PageSizeId.DLE,
188         Envelope10 = PageSizeId.Comm10E
189     }
190 
191     // NOTE: Must keep in sync with QPageLayout::Unit and QPrinter::Unit
192     enum Unit {
193         Millimeter,
194         Point,
195         Inch,
196         Pica,
197         Didot,
198         Cicero
199     }
200 
201     enum SizeMatchPolicy {
202         FuzzyMatch,
203         FuzzyOrientationMatch,
204         ExactMatch
205     }
206 
207     @disable this();
208     pragma(mangle, defaultConstructorMangling(__traits(identifier, typeof(this))))
209     ref typeof(this) rawConstructor();
210     static typeof(this) create()
211     {
212         typeof(this) r = typeof(this).init;
213         r.rawConstructor();
214         return r;
215     }
216 
217     /+ explicit +/this(PageSizeId pageSizeId);
218     /+ explicit +/this(ref const(QSize) pointSize,
219                            ref const(QString) name = globalInitVar!QString,
220                            SizeMatchPolicy matchPolicy = SizeMatchPolicy.FuzzyMatch);
221     /+ explicit +/this(ref const(QSizeF) size, Unit units,
222                            ref const(QString) name = globalInitVar!QString,
223                            SizeMatchPolicy matchPolicy = SizeMatchPolicy.FuzzyMatch);
224     @disable this(this);
225     this(ref const(QPageSize) other);
226     /+ QPageSize &operator=(QPageSize &&other) noexcept { swap(other); return *this; } +/
227     /+ref QPageSize operator =(ref const(QPageSize) other);+/
228     ~this();
229 
230 
231     /+ void swap(QPageSize &other) noexcept { qSwap(d, other.d); } +/
232 
233     /+ friend Q_GUI_EXPORT bool operator==(const QPageSize &lhs, const QPageSize &rhs); +/
234     bool isEquivalentTo(ref const(QPageSize) other) const;
235 
236     bool isValid() const;
237 
238     QString key() const;
239     QString name() const;
240 
241     PageSizeId id() const;
242 
243     int windowsId() const;
244 
245     QSizeF definitionSize() const;
246     Unit definitionUnits() const;
247 
248     QSizeF size(Unit units) const;
249     QSize sizePoints() const;
250     QSize sizePixels(int resolution) const;
251 
252     QRectF rect(Unit units) const;
253     QRect rectPoints() const;
254     QRect rectPixels(int resolution) const;
255 
256     static QString key(PageSizeId pageSizeId);
257     static QString name(PageSizeId pageSizeId);
258 
259     static PageSizeId id(ref const(QSize) pointSize,
260                              SizeMatchPolicy matchPolicy = SizeMatchPolicy.FuzzyMatch);
261     static PageSizeId id(ref const(QSizeF) size, Unit units,
262                              SizeMatchPolicy matchPolicy = SizeMatchPolicy.FuzzyMatch);
263 
264     static PageSizeId id(int windowsId);
265     static int windowsId(PageSizeId pageSizeId);
266 
267     static QSizeF definitionSize(PageSizeId pageSizeId);
268     static Unit definitionUnits(PageSizeId pageSizeId);
269 
270     static QSizeF size(PageSizeId pageSizeId, Unit units);
271     static QSize sizePoints(PageSizeId pageSizeId);
272     static QSize sizePixels(PageSizeId pageSizeId, int resolution);
273 
274 private:
275     /+ friend class QPageSizePrivate; +/
276     /+ friend class QPlatformPrintDevice; +/
277     this(ref const(QString) key, ref const(QSize) pointSize, ref const(QString) name);
278     this(int windowsId, ref const(QSize) pointSize, ref const(QString) name);
279     this(ref QPageSizePrivate dd);
280     QSharedDataPointer!(QPageSizePrivate) d;
281 }
282 
283 /+ Q_DECLARE_SHARED(QPageSize) +/
284 
285 /+/+ Q_GUI_EXPORT +/ bool operator ==(ref const(QPageSize) lhs, ref const(QPageSize) rhs);+/
286 /+pragma(inline, true) bool operator !=(ref const(QPageSize) lhs, ref const(QPageSize) rhs)
287 { return !operator==(lhs, rhs); }+/
288 
289 /+ #ifndef QT_NO_DEBUG_STREAM
290 Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QPageSize &pageSize);
291 #endif
292 
293 
294 Q_DECLARE_METATYPE(QPageSize)
295 Q_DECLARE_METATYPE(QPageSize::PageSizeId)
296 Q_DECLARE_METATYPE(QPageSize::Unit) +/
297