| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/painting/qcolor_p.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||||||||||||||
| 2 | ** | - | ||||||||||||||||||||||||
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||||||||||||||
| 4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||||||||||||||
| 5 | ** | - | ||||||||||||||||||||||||
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | - | ||||||||||||||||||||||||
| 7 | ** | - | ||||||||||||||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||||||||
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||||||||
| 15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||||||||||||||
| 16 | ** | - | ||||||||||||||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||||||||
| 19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||||||||||||||
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||||||||||||||
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||||||||||||||
| 22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||||||||||||||
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||||||||||||||
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||||||||||||||
| 25 | ** | - | ||||||||||||||||||||||||
| 26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||||||||||||||
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||||||||||||||
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||||||||||||||
| 29 | ** | - | ||||||||||||||||||||||||
| 30 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||||||||
| 31 | ** | - | ||||||||||||||||||||||||
| 32 | ****************************************************************************/ | - | ||||||||||||||||||||||||
| 33 | - | |||||||||||||||||||||||||
| 34 | #include "qglobal.h" | - | ||||||||||||||||||||||||
| 35 | #include "qrgb.h" | - | ||||||||||||||||||||||||
| 36 | #include "qstringlist.h" | - | ||||||||||||||||||||||||
| 37 | #include "private/qtools_p.h" | - | ||||||||||||||||||||||||
| 38 | - | |||||||||||||||||||||||||
| 39 | #include <algorithm> | - | ||||||||||||||||||||||||
| 40 | - | |||||||||||||||||||||||||
| 41 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||
| 42 | - | |||||||||||||||||||||||||
| 43 | /*! | - | ||||||||||||||||||||||||
| 44 | \internal | - | ||||||||||||||||||||||||
| 45 | If s[0..1] is a valid hex number, returns its integer value, | - | ||||||||||||||||||||||||
| 46 | otherwise returns -1. | - | ||||||||||||||||||||||||
| 47 | */ | - | ||||||||||||||||||||||||
| 48 | static inline int hex2int(const char *s) | - | ||||||||||||||||||||||||
| 49 | { | - | ||||||||||||||||||||||||
| 50 | const int hi = QtMiscUtils::fromHex(s[0]); | - | ||||||||||||||||||||||||
| 51 | if (hi < 0)
| 0 | ||||||||||||||||||||||||
| 52 | return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
| 53 | const int lo = QtMiscUtils::fromHex(s[1]); | - | ||||||||||||||||||||||||
| 54 | if (lo < 0)
| 0 | ||||||||||||||||||||||||
| 55 | return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
| 56 | return (hi << 4) | lo; never executed: return (hi << 4) | lo; | 0 | ||||||||||||||||||||||||
| 57 | } | - | ||||||||||||||||||||||||
| 58 | - | |||||||||||||||||||||||||
| 59 | /*! | - | ||||||||||||||||||||||||
| 60 | \internal | - | ||||||||||||||||||||||||
| 61 | If s is a valid hex digit, returns its integer value, | - | ||||||||||||||||||||||||
| 62 | multiplied by 0x11, otherwise returns -1. | - | ||||||||||||||||||||||||
| 63 | */ | - | ||||||||||||||||||||||||
| 64 | static inline int hex2int(char s) | - | ||||||||||||||||||||||||
| 65 | { | - | ||||||||||||||||||||||||
| 66 | const int h = QtMiscUtils::fromHex(s); | - | ||||||||||||||||||||||||
| 67 | return h < 0 ? h : (h << 4) | h; never executed: return h < 0 ? h : (h << 4) | h;
| 0 | ||||||||||||||||||||||||
| 68 | } | - | ||||||||||||||||||||||||
| 69 | - | |||||||||||||||||||||||||
| 70 | bool qt_get_hex_rgb(const char *name, QRgb *rgb) | - | ||||||||||||||||||||||||
| 71 | { | - | ||||||||||||||||||||||||
| 72 | if(name[0] != '#')
| 0 | ||||||||||||||||||||||||
| 73 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 74 | name++; | - | ||||||||||||||||||||||||
| 75 | int len = qstrlen(name); | - | ||||||||||||||||||||||||
| 76 | int a, r, g, b; | - | ||||||||||||||||||||||||
| 77 | a = 255; | - | ||||||||||||||||||||||||
| 78 | if (len == 12) {
| 0 | ||||||||||||||||||||||||
| 79 | r = hex2int(name); | - | ||||||||||||||||||||||||
| 80 | g = hex2int(name + 4); | - | ||||||||||||||||||||||||
| 81 | b = hex2int(name + 8); | - | ||||||||||||||||||||||||
| 82 | } else if (len == 9) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 83 | r = hex2int(name); | - | ||||||||||||||||||||||||
| 84 | g = hex2int(name + 3); | - | ||||||||||||||||||||||||
| 85 | b = hex2int(name + 6); | - | ||||||||||||||||||||||||
| 86 | } else if (len == 8) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 87 | a = hex2int(name); | - | ||||||||||||||||||||||||
| 88 | r = hex2int(name + 2); | - | ||||||||||||||||||||||||
| 89 | g = hex2int(name + 4); | - | ||||||||||||||||||||||||
| 90 | b = hex2int(name + 6); | - | ||||||||||||||||||||||||
| 91 | } else if (len == 6) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 92 | r = hex2int(name); | - | ||||||||||||||||||||||||
| 93 | g = hex2int(name + 2); | - | ||||||||||||||||||||||||
| 94 | b = hex2int(name + 4); | - | ||||||||||||||||||||||||
| 95 | } else if (len == 3) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 96 | r = hex2int(name[0]); | - | ||||||||||||||||||||||||
| 97 | g = hex2int(name[1]); | - | ||||||||||||||||||||||||
| 98 | b = hex2int(name[2]); | - | ||||||||||||||||||||||||
| 99 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 100 | r = g = b = -1; | - | ||||||||||||||||||||||||
| 101 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 102 | if ((uint)r > 255 || (uint)g > 255 || (uint)b > 255 || (uint)a > 255) {
| 0 | ||||||||||||||||||||||||
| 103 | *rgb = 0; | - | ||||||||||||||||||||||||
| 104 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 105 | } | - | ||||||||||||||||||||||||
| 106 | *rgb = qRgba(r, g ,b, a); | - | ||||||||||||||||||||||||
| 107 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
| 108 | } | - | ||||||||||||||||||||||||
| 109 | - | |||||||||||||||||||||||||
| 110 | bool qt_get_hex_rgb(const QChar *str, int len, QRgb *rgb) | - | ||||||||||||||||||||||||
| 111 | { | - | ||||||||||||||||||||||||
| 112 | if (len > 13)
| 0 | ||||||||||||||||||||||||
| 113 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 114 | char tmp[16]; | - | ||||||||||||||||||||||||
| 115 | for(int i = 0; i < len; ++i)
| 0 | ||||||||||||||||||||||||
| 116 | tmp[i] = str[i].toLatin1(); never executed: tmp[i] = str[i].toLatin1(); | 0 | ||||||||||||||||||||||||
| 117 | tmp[len] = 0; | - | ||||||||||||||||||||||||
| 118 | return qt_get_hex_rgb(tmp, rgb); never executed: return qt_get_hex_rgb(tmp, rgb); | 0 | ||||||||||||||||||||||||
| 119 | } | - | ||||||||||||||||||||||||
| 120 | - | |||||||||||||||||||||||||
| 121 | #ifndef QT_NO_COLORNAMES | - | ||||||||||||||||||||||||
| 122 | - | |||||||||||||||||||||||||
| 123 | /* | - | ||||||||||||||||||||||||
| 124 | CSS color names = SVG 1.0 color names + transparent (rgba(0,0,0,0)) | - | ||||||||||||||||||||||||
| 125 | */ | - | ||||||||||||||||||||||||
| 126 | - | |||||||||||||||||||||||||
| 127 | #ifdef rgb | - | ||||||||||||||||||||||||
| 128 | # undef rgb | - | ||||||||||||||||||||||||
| 129 | #endif | - | ||||||||||||||||||||||||
| 130 | #define rgb(r,g,b) (0xff000000 | (r << 16) | (g << 8) | b) | - | ||||||||||||||||||||||||
| 131 | - | |||||||||||||||||||||||||
| 132 | static const struct RGBData { | - | ||||||||||||||||||||||||
| 133 | const char name[21]; | - | ||||||||||||||||||||||||
| 134 | uint value; | - | ||||||||||||||||||||||||
| 135 | } rgbTbl[] = { | - | ||||||||||||||||||||||||
| 136 | { "aliceblue", rgb(240, 248, 255) }, | - | ||||||||||||||||||||||||
| 137 | { "antiquewhite", rgb(250, 235, 215) }, | - | ||||||||||||||||||||||||
| 138 | { "aqua", rgb( 0, 255, 255) }, | - | ||||||||||||||||||||||||
| 139 | { "aquamarine", rgb(127, 255, 212) }, | - | ||||||||||||||||||||||||
| 140 | { "azure", rgb(240, 255, 255) }, | - | ||||||||||||||||||||||||
| 141 | { "beige", rgb(245, 245, 220) }, | - | ||||||||||||||||||||||||
| 142 | { "bisque", rgb(255, 228, 196) }, | - | ||||||||||||||||||||||||
| 143 | { "black", rgb( 0, 0, 0) }, | - | ||||||||||||||||||||||||
| 144 | { "blanchedalmond", rgb(255, 235, 205) }, | - | ||||||||||||||||||||||||
| 145 | { "blue", rgb( 0, 0, 255) }, | - | ||||||||||||||||||||||||
| 146 | { "blueviolet", rgb(138, 43, 226) }, | - | ||||||||||||||||||||||||
| 147 | { "brown", rgb(165, 42, 42) }, | - | ||||||||||||||||||||||||
| 148 | { "burlywood", rgb(222, 184, 135) }, | - | ||||||||||||||||||||||||
| 149 | { "cadetblue", rgb( 95, 158, 160) }, | - | ||||||||||||||||||||||||
| 150 | { "chartreuse", rgb(127, 255, 0) }, | - | ||||||||||||||||||||||||
| 151 | { "chocolate", rgb(210, 105, 30) }, | - | ||||||||||||||||||||||||
| 152 | { "coral", rgb(255, 127, 80) }, | - | ||||||||||||||||||||||||
| 153 | { "cornflowerblue", rgb(100, 149, 237) }, | - | ||||||||||||||||||||||||
| 154 | { "cornsilk", rgb(255, 248, 220) }, | - | ||||||||||||||||||||||||
| 155 | { "crimson", rgb(220, 20, 60) }, | - | ||||||||||||||||||||||||
| 156 | { "cyan", rgb( 0, 255, 255) }, | - | ||||||||||||||||||||||||
| 157 | { "darkblue", rgb( 0, 0, 139) }, | - | ||||||||||||||||||||||||
| 158 | { "darkcyan", rgb( 0, 139, 139) }, | - | ||||||||||||||||||||||||
| 159 | { "darkgoldenrod", rgb(184, 134, 11) }, | - | ||||||||||||||||||||||||
| 160 | { "darkgray", rgb(169, 169, 169) }, | - | ||||||||||||||||||||||||
| 161 | { "darkgreen", rgb( 0, 100, 0) }, | - | ||||||||||||||||||||||||
| 162 | { "darkgrey", rgb(169, 169, 169) }, | - | ||||||||||||||||||||||||
| 163 | { "darkkhaki", rgb(189, 183, 107) }, | - | ||||||||||||||||||||||||
| 164 | { "darkmagenta", rgb(139, 0, 139) }, | - | ||||||||||||||||||||||||
| 165 | { "darkolivegreen", rgb( 85, 107, 47) }, | - | ||||||||||||||||||||||||
| 166 | { "darkorange", rgb(255, 140, 0) }, | - | ||||||||||||||||||||||||
| 167 | { "darkorchid", rgb(153, 50, 204) }, | - | ||||||||||||||||||||||||
| 168 | { "darkred", rgb(139, 0, 0) }, | - | ||||||||||||||||||||||||
| 169 | { "darksalmon", rgb(233, 150, 122) }, | - | ||||||||||||||||||||||||
| 170 | { "darkseagreen", rgb(143, 188, 143) }, | - | ||||||||||||||||||||||||
| 171 | { "darkslateblue", rgb( 72, 61, 139) }, | - | ||||||||||||||||||||||||
| 172 | { "darkslategray", rgb( 47, 79, 79) }, | - | ||||||||||||||||||||||||
| 173 | { "darkslategrey", rgb( 47, 79, 79) }, | - | ||||||||||||||||||||||||
| 174 | { "darkturquoise", rgb( 0, 206, 209) }, | - | ||||||||||||||||||||||||
| 175 | { "darkviolet", rgb(148, 0, 211) }, | - | ||||||||||||||||||||||||
| 176 | { "deeppink", rgb(255, 20, 147) }, | - | ||||||||||||||||||||||||
| 177 | { "deepskyblue", rgb( 0, 191, 255) }, | - | ||||||||||||||||||||||||
| 178 | { "dimgray", rgb(105, 105, 105) }, | - | ||||||||||||||||||||||||
| 179 | { "dimgrey", rgb(105, 105, 105) }, | - | ||||||||||||||||||||||||
| 180 | { "dodgerblue", rgb( 30, 144, 255) }, | - | ||||||||||||||||||||||||
| 181 | { "firebrick", rgb(178, 34, 34) }, | - | ||||||||||||||||||||||||
| 182 | { "floralwhite", rgb(255, 250, 240) }, | - | ||||||||||||||||||||||||
| 183 | { "forestgreen", rgb( 34, 139, 34) }, | - | ||||||||||||||||||||||||
| 184 | { "fuchsia", rgb(255, 0, 255) }, | - | ||||||||||||||||||||||||
| 185 | { "gainsboro", rgb(220, 220, 220) }, | - | ||||||||||||||||||||||||
| 186 | { "ghostwhite", rgb(248, 248, 255) }, | - | ||||||||||||||||||||||||
| 187 | { "gold", rgb(255, 215, 0) }, | - | ||||||||||||||||||||||||
| 188 | { "goldenrod", rgb(218, 165, 32) }, | - | ||||||||||||||||||||||||
| 189 | { "gray", rgb(128, 128, 128) }, | - | ||||||||||||||||||||||||
| 190 | { "green", rgb( 0, 128, 0) }, | - | ||||||||||||||||||||||||
| 191 | { "greenyellow", rgb(173, 255, 47) }, | - | ||||||||||||||||||||||||
| 192 | { "grey", rgb(128, 128, 128) }, | - | ||||||||||||||||||||||||
| 193 | { "honeydew", rgb(240, 255, 240) }, | - | ||||||||||||||||||||||||
| 194 | { "hotpink", rgb(255, 105, 180) }, | - | ||||||||||||||||||||||||
| 195 | { "indianred", rgb(205, 92, 92) }, | - | ||||||||||||||||||||||||
| 196 | { "indigo", rgb( 75, 0, 130) }, | - | ||||||||||||||||||||||||
| 197 | { "ivory", rgb(255, 255, 240) }, | - | ||||||||||||||||||||||||
| 198 | { "khaki", rgb(240, 230, 140) }, | - | ||||||||||||||||||||||||
| 199 | { "lavender", rgb(230, 230, 250) }, | - | ||||||||||||||||||||||||
| 200 | { "lavenderblush", rgb(255, 240, 245) }, | - | ||||||||||||||||||||||||
| 201 | { "lawngreen", rgb(124, 252, 0) }, | - | ||||||||||||||||||||||||
| 202 | { "lemonchiffon", rgb(255, 250, 205) }, | - | ||||||||||||||||||||||||
| 203 | { "lightblue", rgb(173, 216, 230) }, | - | ||||||||||||||||||||||||
| 204 | { "lightcoral", rgb(240, 128, 128) }, | - | ||||||||||||||||||||||||
| 205 | { "lightcyan", rgb(224, 255, 255) }, | - | ||||||||||||||||||||||||
| 206 | { "lightgoldenrodyellow", rgb(250, 250, 210) }, | - | ||||||||||||||||||||||||
| 207 | { "lightgray", rgb(211, 211, 211) }, | - | ||||||||||||||||||||||||
| 208 | { "lightgreen", rgb(144, 238, 144) }, | - | ||||||||||||||||||||||||
| 209 | { "lightgrey", rgb(211, 211, 211) }, | - | ||||||||||||||||||||||||
| 210 | { "lightpink", rgb(255, 182, 193) }, | - | ||||||||||||||||||||||||
| 211 | { "lightsalmon", rgb(255, 160, 122) }, | - | ||||||||||||||||||||||||
| 212 | { "lightseagreen", rgb( 32, 178, 170) }, | - | ||||||||||||||||||||||||
| 213 | { "lightskyblue", rgb(135, 206, 250) }, | - | ||||||||||||||||||||||||
| 214 | { "lightslategray", rgb(119, 136, 153) }, | - | ||||||||||||||||||||||||
| 215 | { "lightslategrey", rgb(119, 136, 153) }, | - | ||||||||||||||||||||||||
| 216 | { "lightsteelblue", rgb(176, 196, 222) }, | - | ||||||||||||||||||||||||
| 217 | { "lightyellow", rgb(255, 255, 224) }, | - | ||||||||||||||||||||||||
| 218 | { "lime", rgb( 0, 255, 0) }, | - | ||||||||||||||||||||||||
| 219 | { "limegreen", rgb( 50, 205, 50) }, | - | ||||||||||||||||||||||||
| 220 | { "linen", rgb(250, 240, 230) }, | - | ||||||||||||||||||||||||
| 221 | { "magenta", rgb(255, 0, 255) }, | - | ||||||||||||||||||||||||
| 222 | { "maroon", rgb(128, 0, 0) }, | - | ||||||||||||||||||||||||
| 223 | { "mediumaquamarine", rgb(102, 205, 170) }, | - | ||||||||||||||||||||||||
| 224 | { "mediumblue", rgb( 0, 0, 205) }, | - | ||||||||||||||||||||||||
| 225 | { "mediumorchid", rgb(186, 85, 211) }, | - | ||||||||||||||||||||||||
| 226 | { "mediumpurple", rgb(147, 112, 219) }, | - | ||||||||||||||||||||||||
| 227 | { "mediumseagreen", rgb( 60, 179, 113) }, | - | ||||||||||||||||||||||||
| 228 | { "mediumslateblue", rgb(123, 104, 238) }, | - | ||||||||||||||||||||||||
| 229 | { "mediumspringgreen", rgb( 0, 250, 154) }, | - | ||||||||||||||||||||||||
| 230 | { "mediumturquoise", rgb( 72, 209, 204) }, | - | ||||||||||||||||||||||||
| 231 | { "mediumvioletred", rgb(199, 21, 133) }, | - | ||||||||||||||||||||||||
| 232 | { "midnightblue", rgb( 25, 25, 112) }, | - | ||||||||||||||||||||||||
| 233 | { "mintcream", rgb(245, 255, 250) }, | - | ||||||||||||||||||||||||
| 234 | { "mistyrose", rgb(255, 228, 225) }, | - | ||||||||||||||||||||||||
| 235 | { "moccasin", rgb(255, 228, 181) }, | - | ||||||||||||||||||||||||
| 236 | { "navajowhite", rgb(255, 222, 173) }, | - | ||||||||||||||||||||||||
| 237 | { "navy", rgb( 0, 0, 128) }, | - | ||||||||||||||||||||||||
| 238 | { "oldlace", rgb(253, 245, 230) }, | - | ||||||||||||||||||||||||
| 239 | { "olive", rgb(128, 128, 0) }, | - | ||||||||||||||||||||||||
| 240 | { "olivedrab", rgb(107, 142, 35) }, | - | ||||||||||||||||||||||||
| 241 | { "orange", rgb(255, 165, 0) }, | - | ||||||||||||||||||||||||
| 242 | { "orangered", rgb(255, 69, 0) }, | - | ||||||||||||||||||||||||
| 243 | { "orchid", rgb(218, 112, 214) }, | - | ||||||||||||||||||||||||
| 244 | { "palegoldenrod", rgb(238, 232, 170) }, | - | ||||||||||||||||||||||||
| 245 | { "palegreen", rgb(152, 251, 152) }, | - | ||||||||||||||||||||||||
| 246 | { "paleturquoise", rgb(175, 238, 238) }, | - | ||||||||||||||||||||||||
| 247 | { "palevioletred", rgb(219, 112, 147) }, | - | ||||||||||||||||||||||||
| 248 | { "papayawhip", rgb(255, 239, 213) }, | - | ||||||||||||||||||||||||
| 249 | { "peachpuff", rgb(255, 218, 185) }, | - | ||||||||||||||||||||||||
| 250 | { "peru", rgb(205, 133, 63) }, | - | ||||||||||||||||||||||||
| 251 | { "pink", rgb(255, 192, 203) }, | - | ||||||||||||||||||||||||
| 252 | { "plum", rgb(221, 160, 221) }, | - | ||||||||||||||||||||||||
| 253 | { "powderblue", rgb(176, 224, 230) }, | - | ||||||||||||||||||||||||
| 254 | { "purple", rgb(128, 0, 128) }, | - | ||||||||||||||||||||||||
| 255 | { "red", rgb(255, 0, 0) }, | - | ||||||||||||||||||||||||
| 256 | { "rosybrown", rgb(188, 143, 143) }, | - | ||||||||||||||||||||||||
| 257 | { "royalblue", rgb( 65, 105, 225) }, | - | ||||||||||||||||||||||||
| 258 | { "saddlebrown", rgb(139, 69, 19) }, | - | ||||||||||||||||||||||||
| 259 | { "salmon", rgb(250, 128, 114) }, | - | ||||||||||||||||||||||||
| 260 | { "sandybrown", rgb(244, 164, 96) }, | - | ||||||||||||||||||||||||
| 261 | { "seagreen", rgb( 46, 139, 87) }, | - | ||||||||||||||||||||||||
| 262 | { "seashell", rgb(255, 245, 238) }, | - | ||||||||||||||||||||||||
| 263 | { "sienna", rgb(160, 82, 45) }, | - | ||||||||||||||||||||||||
| 264 | { "silver", rgb(192, 192, 192) }, | - | ||||||||||||||||||||||||
| 265 | { "skyblue", rgb(135, 206, 235) }, | - | ||||||||||||||||||||||||
| 266 | { "slateblue", rgb(106, 90, 205) }, | - | ||||||||||||||||||||||||
| 267 | { "slategray", rgb(112, 128, 144) }, | - | ||||||||||||||||||||||||
| 268 | { "slategrey", rgb(112, 128, 144) }, | - | ||||||||||||||||||||||||
| 269 | { "snow", rgb(255, 250, 250) }, | - | ||||||||||||||||||||||||
| 270 | { "springgreen", rgb( 0, 255, 127) }, | - | ||||||||||||||||||||||||
| 271 | { "steelblue", rgb( 70, 130, 180) }, | - | ||||||||||||||||||||||||
| 272 | { "tan", rgb(210, 180, 140) }, | - | ||||||||||||||||||||||||
| 273 | { "teal", rgb( 0, 128, 128) }, | - | ||||||||||||||||||||||||
| 274 | { "thistle", rgb(216, 191, 216) }, | - | ||||||||||||||||||||||||
| 275 | { "tomato", rgb(255, 99, 71) }, | - | ||||||||||||||||||||||||
| 276 | { "transparent", 0 }, | - | ||||||||||||||||||||||||
| 277 | { "turquoise", rgb( 64, 224, 208) }, | - | ||||||||||||||||||||||||
| 278 | { "violet", rgb(238, 130, 238) }, | - | ||||||||||||||||||||||||
| 279 | { "wheat", rgb(245, 222, 179) }, | - | ||||||||||||||||||||||||
| 280 | { "white", rgb(255, 255, 255) }, | - | ||||||||||||||||||||||||
| 281 | { "whitesmoke", rgb(245, 245, 245) }, | - | ||||||||||||||||||||||||
| 282 | { "yellow", rgb(255, 255, 0) }, | - | ||||||||||||||||||||||||
| 283 | { "yellowgreen", rgb(154, 205, 50) } | - | ||||||||||||||||||||||||
| 284 | }; | - | ||||||||||||||||||||||||
| 285 | - | |||||||||||||||||||||||||
| 286 | static const int rgbTblSize = sizeof(rgbTbl) / sizeof(RGBData); | - | ||||||||||||||||||||||||
| 287 | - | |||||||||||||||||||||||||
| 288 | #undef rgb | - | ||||||||||||||||||||||||
| 289 | - | |||||||||||||||||||||||||
| 290 | #if defined(Q_CC_MSVC) && _MSC_VER < 1600 | - | ||||||||||||||||||||||||
| 291 | inline bool operator<(const RGBData &data1, const RGBData &data2) | - | ||||||||||||||||||||||||
| 292 | { return qstrcmp(data1.name, data2.name) < 0; } | - | ||||||||||||||||||||||||
| 293 | #endif | - | ||||||||||||||||||||||||
| 294 | - | |||||||||||||||||||||||||
| 295 | inline bool operator<(const char *name, const RGBData &data) | - | ||||||||||||||||||||||||
| 296 | { never executed: return qstrcmp(name, data.name) < 0; }return qstrcmp(name, data.name) < 0;never executed: return qstrcmp(name, data.name) < 0; | 0 | ||||||||||||||||||||||||
| 297 | inline bool operator<(const RGBData &data, const char *name) | - | ||||||||||||||||||||||||
| 298 | { never executed: return qstrcmp(data.name, name) < 0; }return qstrcmp(data.name, name) < 0;never executed: return qstrcmp(data.name, name) < 0; | 0 | ||||||||||||||||||||||||
| 299 | - | |||||||||||||||||||||||||
| 300 | static bool get_named_rgb(const char *name_no_space, QRgb *rgb) | - | ||||||||||||||||||||||||
| 301 | { | - | ||||||||||||||||||||||||
| 302 | const RGBData *r = std::lower_bound(rgbTbl, rgbTbl + rgbTblSize, name_no_space); | - | ||||||||||||||||||||||||
| 303 | if ((r != rgbTbl + rgbTblSize) && !(name_no_space < *r)) {
| 0 | ||||||||||||||||||||||||
| 304 | *rgb = r->value; | - | ||||||||||||||||||||||||
| 305 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
| 306 | } | - | ||||||||||||||||||||||||
| 307 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 308 | } | - | ||||||||||||||||||||||||
| 309 | - | |||||||||||||||||||||||||
| 310 | bool qt_get_named_rgb(const char *name, QRgb* rgb) | - | ||||||||||||||||||||||||
| 311 | { | - | ||||||||||||||||||||||||
| 312 | int len = int(strlen(name)); | - | ||||||||||||||||||||||||
| 313 | if(len > 255)
| 0 | ||||||||||||||||||||||||
| 314 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 315 | char name_no_space[256]; | - | ||||||||||||||||||||||||
| 316 | int pos = 0; | - | ||||||||||||||||||||||||
| 317 | for(int i = 0; i < len; i++) {
| 0 | ||||||||||||||||||||||||
| 318 | if(name[i] != '\t' && name[i] != ' ')
| 0 | ||||||||||||||||||||||||
| 319 | name_no_space[pos++] = QChar::toLower(name[i]); never executed: name_no_space[pos++] = QChar::toLower(name[i]); | 0 | ||||||||||||||||||||||||
| 320 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 321 | name_no_space[pos] = 0; | - | ||||||||||||||||||||||||
| 322 | - | |||||||||||||||||||||||||
| 323 | return get_named_rgb(name_no_space, rgb); never executed: return get_named_rgb(name_no_space, rgb); | 0 | ||||||||||||||||||||||||
| 324 | } | - | ||||||||||||||||||||||||
| 325 | - | |||||||||||||||||||||||||
| 326 | bool qt_get_named_rgb(const QChar *name, int len, QRgb *rgb) | - | ||||||||||||||||||||||||
| 327 | { | - | ||||||||||||||||||||||||
| 328 | if(len > 255)
| 0 | ||||||||||||||||||||||||
| 329 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 330 | char name_no_space[256]; | - | ||||||||||||||||||||||||
| 331 | int pos = 0; | - | ||||||||||||||||||||||||
| 332 | for(int i = 0; i < len; i++) {
| 0 | ||||||||||||||||||||||||
| 333 | if(name[i] != QLatin1Char('\t') && name[i] != QLatin1Char(' '))
| 0 | ||||||||||||||||||||||||
| 334 | name_no_space[pos++] = name[i].toLower().toLatin1(); never executed: name_no_space[pos++] = name[i].toLower().toLatin1(); | 0 | ||||||||||||||||||||||||
| 335 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 336 | name_no_space[pos] = 0; | - | ||||||||||||||||||||||||
| 337 | return get_named_rgb(name_no_space, rgb); never executed: return get_named_rgb(name_no_space, rgb); | 0 | ||||||||||||||||||||||||
| 338 | } | - | ||||||||||||||||||||||||
| 339 | - | |||||||||||||||||||||||||
| 340 | - | |||||||||||||||||||||||||
| 341 | uint qt_get_rgb_val(const char *name) | - | ||||||||||||||||||||||||
| 342 | { | - | ||||||||||||||||||||||||
| 343 | QRgb r = 0; | - | ||||||||||||||||||||||||
| 344 | qt_get_named_rgb(name,&r); | - | ||||||||||||||||||||||||
| 345 | return r; never executed: return r; | 0 | ||||||||||||||||||||||||
| 346 | } | - | ||||||||||||||||||||||||
| 347 | - | |||||||||||||||||||||||||
| 348 | QStringList qt_get_colornames() | - | ||||||||||||||||||||||||
| 349 | { | - | ||||||||||||||||||||||||
| 350 | int i = 0; | - | ||||||||||||||||||||||||
| 351 | QStringList lst; | - | ||||||||||||||||||||||||
| 352 | lst.reserve(rgbTblSize); | - | ||||||||||||||||||||||||
| 353 | for (i = 0; i < rgbTblSize; i++)
| 0 | ||||||||||||||||||||||||
| 354 | lst << QLatin1String(rgbTbl[i].name); never executed: lst << QLatin1String(rgbTbl[i].name); | 0 | ||||||||||||||||||||||||
| 355 | return lst; never executed: return lst; | 0 | ||||||||||||||||||||||||
| 356 | } | - | ||||||||||||||||||||||||
| 357 | - | |||||||||||||||||||||||||
| 358 | #else | - | ||||||||||||||||||||||||
| 359 | - | |||||||||||||||||||||||||
| 360 | bool qt_get_named_rgb(const char *, QRgb*) | - | ||||||||||||||||||||||||
| 361 | { | - | ||||||||||||||||||||||||
| 362 | return false; | - | ||||||||||||||||||||||||
| 363 | } | - | ||||||||||||||||||||||||
| 364 | - | |||||||||||||||||||||||||
| 365 | uint qt_get_rgb_val(const char *) | - | ||||||||||||||||||||||||
| 366 | { | - | ||||||||||||||||||||||||
| 367 | return 0; | - | ||||||||||||||||||||||||
| 368 | } | - | ||||||||||||||||||||||||
| 369 | QStringList qt_get_colornames() | - | ||||||||||||||||||||||||
| 370 | { | - | ||||||||||||||||||||||||
| 371 | return QStringList(); | - | ||||||||||||||||||||||||
| 372 | } | - | ||||||||||||||||||||||||
| 373 | #endif // QT_NO_COLORNAMES | - | ||||||||||||||||||||||||
| 374 | - | |||||||||||||||||||||||||
| 375 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||
| Source code | Switch to Preprocessed file |