1// qcolor.sip generated by MetaSIP
2//
3// This file is part of the QtGui Python extension module.
4//
5// Copyright (c) 2021 Riverbank Computing Limited <info@riverbankcomputing.com>
6//
7// This file is part of PyQt5.
8//
9// This file may be used under the terms of the GNU General Public License
10// version 3.0 as published by the Free Software Foundation and appearing in
11// the file LICENSE included in the packaging of this file.  Please review the
12// following information to ensure the GNU General Public License version 3.0
13// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
14//
15// If you do not wish to use this file under the terms of the GPL version 3.0
16// then you may purchase a commercial license.  For more information contact
17// info@riverbankcomputing.com.
18//
19// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21
22
23class QColor /TypeHintIn="Union[QColor, Qt.GlobalColor]"/
24{
25%TypeHeaderCode
26#include <qcolor.h>
27%End
28
29%ConvertToTypeCode
30// SIP doesn't support automatic type convertors so we explicitly allow a
31// Qt::GlobalColor to be used whenever a QColor is expected.  Note that SIP
32// must process QColor before QBrush so that the former's QVariant cast
33// operator is applied before the latter's.
34
35if (sipIsErr == NULL)
36    return (PyObject_TypeCheck(sipPy, sipTypeAsPyTypeObject(sipType_Qt_GlobalColor)) ||
37            sipCanConvertToType(sipPy, sipType_QColor, SIP_NO_CONVERTORS));
38
39if (PyObject_TypeCheck(sipPy, sipTypeAsPyTypeObject(sipType_Qt_GlobalColor)))
40{
41    *sipCppPtr = new QColor((Qt::GlobalColor)SIPLong_AsLong(sipPy));
42
43    return sipGetState(sipTransferObj);
44}
45
46*sipCppPtr = reinterpret_cast<QColor *>(sipConvertToType(sipPy, sipType_QColor, sipTransferObj, SIP_NO_CONVERTORS, 0, sipIsErr));
47
48return 0;
49%End
50
51%PickleCode
52    sipRes = Py_BuildValue((char *)"iiii", sipCpp->red(), sipCpp->green(), sipCpp->blue(), sipCpp->alpha());
53%End
54
55public:
56    enum Spec
57    {
58        Invalid,
59        Rgb,
60        Hsv,
61        Cmyk,
62        Hsl,
63%If (Qt_5_14_0 -)
64        ExtendedRgb,
65%End
66    };
67
68    QColor(Qt::GlobalColor color /Constrained/);
69    QColor(QRgb rgb);
70%If (Qt_5_6_0 -)
71    QColor(QRgba64 rgba64);
72%End
73    QColor(const QVariant &variant /GetWrapper/) /NoDerived/;
74%MethodCode
75        if (a0->canConvert<QColor>())
76            sipCpp = new QColor(a0->value<QColor>());
77        else
78            sipError = sipBadCallableArg(0, a0Wrapper);
79%End
80
81    QString name() const;
82    void setNamedColor(const QString &name);
83    static QStringList colorNames();
84    QColor::Spec spec() const;
85    int alpha() const;
86    void setAlpha(int alpha);
87    qreal alphaF() const;
88    void setAlphaF(qreal alpha);
89    int red() const;
90    int green() const;
91    int blue() const;
92    void setRed(int red);
93    void setGreen(int green);
94    void setBlue(int blue);
95    qreal redF() const;
96    qreal greenF() const;
97    qreal blueF() const;
98    void setRedF(qreal red);
99    void setGreenF(qreal green);
100    void setBlueF(qreal blue);
101    void getRgb(int *r, int *g, int *b, int *alpha = 0) const;
102    void setRgb(int r, int g, int b, int alpha = 255);
103    void getRgbF(qreal *r, qreal *g, qreal *b, qreal *alpha = 0) const;
104    void setRgbF(qreal r, qreal g, qreal b, qreal alpha = 1.);
105    QRgb rgba() const;
106    void setRgba(QRgb rgba);
107    QRgb rgb() const;
108    void setRgb(QRgb rgb);
109    int hue() const;
110    int saturation() const;
111    int value() const;
112    qreal hueF() const;
113    qreal saturationF() const;
114    qreal valueF() const;
115    void getHsv(int *h, int *s, int *v, int *alpha = 0) const;
116    void setHsv(int h, int s, int v, int alpha = 255);
117    void getHsvF(qreal *h, qreal *s, qreal *v, qreal *alpha = 0) const;
118    void setHsvF(qreal h, qreal s, qreal v, qreal alpha = 1.);
119    int cyan() const;
120    int magenta() const;
121    int yellow() const;
122    int black() const;
123    qreal cyanF() const;
124    qreal magentaF() const;
125    qreal yellowF() const;
126    qreal blackF() const;
127    void getCmyk(int *c, int *m, int *y, int *k, int *alpha = 0);
128    void setCmyk(int c, int m, int y, int k, int alpha = 255);
129    void getCmykF(qreal *c, qreal *m, qreal *y, qreal *k, qreal *alpha = 0);
130    void setCmykF(qreal c, qreal m, qreal y, qreal k, qreal alpha = 1.);
131    QColor toRgb() const;
132    QColor toHsv() const;
133    QColor toCmyk() const;
134    QColor convertTo(QColor::Spec colorSpec) const;
135    static QColor fromRgb(QRgb rgb);
136    static QColor fromRgba(QRgb rgba);
137    static QColor fromRgb(int r, int g, int b, int alpha = 255);
138    static QColor fromRgbF(qreal r, qreal g, qreal b, qreal alpha = 1.);
139    static QColor fromHsv(int h, int s, int v, int alpha = 255);
140    static QColor fromHsvF(qreal h, qreal s, qreal v, qreal alpha = 1.);
141    static QColor fromCmyk(int c, int m, int y, int k, int alpha = 255);
142    static QColor fromCmykF(qreal c, qreal m, qreal y, qreal k, qreal alpha = 1.);
143    bool operator==(const QColor &c) const;
144    bool operator!=(const QColor &c) const;
145    QColor();
146    QColor(int r, int g, int b, int alpha = 255);
147    QColor(const QString &aname);
148    QColor(const QColor &acolor);
149    bool isValid() const;
150    QColor lighter(int factor = 150) const;
151    QColor darker(int factor = 200) const;
152    int hsvHue() const;
153    int hsvSaturation() const;
154    qreal hsvHueF() const;
155    qreal hsvSaturationF() const;
156    int hslHue() const;
157    int hslSaturation() const;
158    int lightness() const;
159    qreal hslHueF() const;
160    qreal hslSaturationF() const;
161    qreal lightnessF() const;
162    void getHsl(int *h, int *s, int *l, int *alpha = 0) const;
163    void setHsl(int h, int s, int l, int alpha = 255);
164    void getHslF(qreal *h, qreal *s, qreal *l, qreal *alpha = 0) const;
165    void setHslF(qreal h, qreal s, qreal l, qreal alpha = 1.);
166    QColor toHsl() const;
167    static QColor fromHsl(int h, int s, int l, int alpha = 255);
168    static QColor fromHslF(qreal h, qreal s, qreal l, qreal alpha = 1.);
169    static bool isValidColor(const QString &name);
170%If (Qt_5_2_0 -)
171
172    enum NameFormat
173    {
174        HexRgb,
175        HexArgb,
176    };
177
178%End
179%If (Qt_5_2_0 -)
180    QString name(QColor::NameFormat format) const;
181%End
182%If (Qt_5_6_0 -)
183    QRgba64 rgba64() const;
184%End
185%If (Qt_5_6_0 -)
186    void setRgba64(QRgba64 rgba);
187%End
188%If (Qt_5_6_0 -)
189    static QColor fromRgba64(ushort r, ushort g, ushort b, ushort alpha = 65535);
190%End
191%If (Qt_5_6_0 -)
192    static QColor fromRgba64(QRgba64 rgba);
193%End
194%If (Qt_5_14_0 -)
195    QColor toExtendedRgb() const;
196%End
197};
198
199QDataStream &operator<<(QDataStream &, const QColor & /Constrained/) /ReleaseGIL/;
200QDataStream &operator>>(QDataStream &, QColor & /Constrained/) /ReleaseGIL/;
201%If (Qt_5_14_0 -)
202%If (PyQt_CONSTEXPR)
203
204namespace QColorConstants
205{
206%TypeHeaderCode
207#include <qcolor.h>
208%End
209
210    const QColor Color0;
211    const QColor Color1;
212    const QColor Black;
213    const QColor White;
214    const QColor DarkGray;
215    const QColor Gray;
216    const QColor LightGray;
217    const QColor Red;
218    const QColor Green;
219    const QColor Blue;
220    const QColor Cyan;
221    const QColor Magenta;
222    const QColor Yellow;
223    const QColor DarkRed;
224    const QColor DarkGreen;
225    const QColor DarkBlue;
226    const QColor DarkCyan;
227    const QColor DarkMagenta;
228    const QColor DarkYellow;
229    const QColor Transparent;
230
231    namespace Svg
232    {
233%TypeHeaderCode
234#include <qcolor.h>
235%End
236
237        const QColor aliceblue;
238        const QColor antiquewhite;
239        const QColor aqua;
240        const QColor aquamarine;
241        const QColor azure;
242        const QColor beige;
243        const QColor bisque;
244        const QColor black;
245        const QColor blanchedalmond;
246        const QColor blue;
247        const QColor blueviolet;
248        const QColor brown;
249        const QColor burlywood;
250        const QColor cadetblue;
251        const QColor chartreuse;
252        const QColor chocolate;
253        const QColor coral;
254        const QColor cornflowerblue;
255        const QColor cornsilk;
256        const QColor crimson;
257        const QColor cyan;
258        const QColor darkblue;
259        const QColor darkcyan;
260        const QColor darkgoldenrod;
261        const QColor darkgray;
262        const QColor darkgreen;
263        const QColor darkgrey;
264        const QColor darkkhaki;
265        const QColor darkmagenta;
266        const QColor darkolivegreen;
267        const QColor darkorange;
268        const QColor darkorchid;
269        const QColor darkred;
270        const QColor darksalmon;
271        const QColor darkseagreen;
272        const QColor darkslateblue;
273        const QColor darkslategray;
274        const QColor darkslategrey;
275        const QColor darkturquoise;
276        const QColor darkviolet;
277        const QColor deeppink;
278        const QColor deepskyblue;
279        const QColor dimgray;
280        const QColor dimgrey;
281        const QColor dodgerblue;
282        const QColor firebrick;
283        const QColor floralwhite;
284        const QColor forestgreen;
285        const QColor fuchsia;
286        const QColor gainsboro;
287        const QColor ghostwhite;
288        const QColor gold;
289        const QColor goldenrod;
290        const QColor gray;
291        const QColor green;
292        const QColor greenyellow;
293        const QColor grey;
294        const QColor honeydew;
295        const QColor hotpink;
296        const QColor indianred;
297        const QColor indigo;
298        const QColor ivory;
299        const QColor khaki;
300        const QColor lavender;
301        const QColor lavenderblush;
302        const QColor lawngreen;
303        const QColor lemonchiffon;
304        const QColor lightblue;
305        const QColor lightcoral;
306        const QColor lightcyan;
307        const QColor lightgoldenrodyellow;
308        const QColor lightgray;
309        const QColor lightgreen;
310        const QColor lightgrey;
311        const QColor lightpink;
312        const QColor lightsalmon;
313        const QColor lightseagreen;
314        const QColor lightskyblue;
315        const QColor lightslategray;
316        const QColor lightslategrey;
317        const QColor lightsteelblue;
318        const QColor lightyellow;
319        const QColor lime;
320        const QColor limegreen;
321        const QColor linen;
322        const QColor magenta;
323        const QColor maroon;
324        const QColor mediumaquamarine;
325        const QColor mediumblue;
326        const QColor mediumorchid;
327        const QColor mediumpurple;
328        const QColor mediumseagreen;
329        const QColor mediumslateblue;
330        const QColor mediumspringgreen;
331        const QColor mediumturquoise;
332        const QColor mediumvioletred;
333        const QColor midnightblue;
334        const QColor mintcream;
335        const QColor mistyrose;
336        const QColor moccasin;
337        const QColor navajowhite;
338        const QColor navy;
339        const QColor oldlace;
340        const QColor olive;
341        const QColor olivedrab;
342        const QColor orange;
343        const QColor orangered;
344        const QColor orchid;
345        const QColor palegoldenrod;
346        const QColor palegreen;
347        const QColor paleturquoise;
348        const QColor palevioletred;
349        const QColor papayawhip;
350        const QColor peachpuff;
351        const QColor peru;
352        const QColor pink;
353        const QColor plum;
354        const QColor powderblue;
355        const QColor purple;
356        const QColor red;
357        const QColor rosybrown;
358        const QColor royalblue;
359        const QColor saddlebrown;
360        const QColor salmon;
361        const QColor sandybrown;
362        const QColor seagreen;
363        const QColor seashell;
364        const QColor sienna;
365        const QColor silver;
366        const QColor skyblue;
367        const QColor slateblue;
368        const QColor slategray;
369        const QColor slategrey;
370        const QColor snow;
371        const QColor springgreen;
372        const QColor steelblue;
373        const QColor tan;
374        const QColor teal;
375        const QColor thistle;
376        const QColor tomato;
377        const QColor turquoise;
378        const QColor violet;
379        const QColor wheat;
380        const QColor white;
381        const QColor whitesmoke;
382        const QColor yellow;
383        const QColor yellowgreen;
384    };
385};
386
387%End
388%End
389