Qt 4.8
Functions
qcolor_p.h File Reference
#include "QtCore/qglobal.h"
#include "QtGui/qrgb.h"
#include "QtCore/qstringlist.h"

Go to the source code of this file.

Functions

QStringList qt_get_colornames ()
 
bool qt_get_hex_rgb (const char *, QRgb *)
 
bool qt_get_hex_rgb (const QChar *, int len, QRgb *)
 
bool qt_get_named_rgb (const char *, QRgb *)
 
bool qt_get_named_rgb (const QChar *, int len, QRgb *)
 
uint qt_get_rgb_val (const char *name)
 

Function Documentation

◆ qt_get_colornames()

QStringList qt_get_colornames ( )

Definition at line 344 of file qcolor_p.cpp.

Referenced by QColor::colorNames(), and qt_get_colornames().

345 {
346  int i = 0;
347  QStringList lst;
348  for (i = 0; i < rgbTblSize; i++)
349  lst << QLatin1String(rgbTbl[i].name);
350  return lst;
351 }
static const struct RGBData rgbTbl[]
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
const char * name
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
static const int rgbTblSize
Definition: qcolor_p.cpp:286

◆ qt_get_hex_rgb() [1/2]

bool qt_get_hex_rgb ( const char *  ,
QRgb  
)

Definition at line 76 of file qcolor_p.cpp.

Referenced by qt_get_hex_rgb(), read_xpm_body(), and QColor::setColorFromString().

77 {
78  if(name[0] != '#')
79  return false;
80  name++;
81  int len = qstrlen(name);
82  int r, g, b;
83  if (len == 12) {
84  r = hex2int(name);
85  g = hex2int(name + 4);
86  b = hex2int(name + 8);
87  } else if (len == 9) {
88  r = hex2int(name);
89  g = hex2int(name + 3);
90  b = hex2int(name + 6);
91  } else if (len == 6) {
92  r = hex2int(name);
93  g = hex2int(name + 2);
94  b = hex2int(name + 4);
95  } else if (len == 3) {
96  r = hex2int(name[0]);
97  g = hex2int(name[1]);
98  b = hex2int(name[2]);
99  } else {
100  r = g = b = -1;
101  }
102  if ((uint)r > 255 || (uint)g > 255 || (uint)b > 255) {
103  *rgb = 0;
104  return false;
105  }
106  *rgb = qRgb(r, g ,b);
107  return true;
108 }
const char * name
unsigned int uint
Definition: qglobal.h:996
#define rgb(r, g, b)
Definition: qcolor_p.cpp:130
QRgb qRgb(int r, int g, int b)
Returns the ARGB quadruplet (255, {r}, {g}, {b}).
Definition: qrgb.h:69
uint qstrlen(const char *str)
Definition: qbytearray.h:79
static int hex2int(const char *s)
Definition: qcolor_p.cpp:65

◆ qt_get_hex_rgb() [2/2]

bool qt_get_hex_rgb ( const QChar ,
int  len,
QRgb  
)

Definition at line 110 of file qcolor_p.cpp.

111 {
112  if (len > 13)
113  return false;
114  char tmp[16];
115  for(int i = 0; i < len; ++i)
116  tmp[i] = str[i].toLatin1();
117  tmp[len] = 0;
118  return qt_get_hex_rgb(tmp, rgb);
119 }
#define rgb(r, g, b)
Definition: qcolor_p.cpp:130
bool qt_get_hex_rgb(const char *name, QRgb *rgb)
Definition: qcolor_p.cpp:76

◆ qt_get_named_rgb() [1/2]

bool qt_get_named_rgb ( const char *  ,
QRgb  
)

Definition at line 306 of file qcolor_p.cpp.

Referenced by qt_get_colornames(), qt_get_rgb_val(), and QColor::setColorFromString().

307 {
308  int len = int(strlen(name));
309  if(len > 255)
310  return false;
311  char name_no_space[256];
312  int pos = 0;
313  for(int i = 0; i < len; i++) {
314  if(name[i] != '\t' && name[i] != ' ')
315  name_no_space[pos++] = name[i];
316  }
317  name_no_space[pos] = 0;
318 
319  return get_named_rgb(name_no_space, rgb);
320 }
static bool get_named_rgb(const char *name_no_space, QRgb *rgb)
Definition: qcolor_p.cpp:295
const char * name
#define rgb(r, g, b)
Definition: qcolor_p.cpp:130

◆ qt_get_named_rgb() [2/2]

bool qt_get_named_rgb ( const QChar ,
int  len,
QRgb  
)

Definition at line 322 of file qcolor_p.cpp.

323 {
324  if(len > 255)
325  return false;
326  char name_no_space[256];
327  int pos = 0;
328  for(int i = 0; i < len; i++) {
329  if(name[i] != QLatin1Char('\t') && name[i] != QLatin1Char(' '))
330  name_no_space[pos++] = name[i].toLatin1();
331  }
332  name_no_space[pos] = 0;
333  return get_named_rgb(name_no_space, rgb);
334 }
static bool get_named_rgb(const char *name_no_space, QRgb *rgb)
Definition: qcolor_p.cpp:295
const char * name
#define rgb(r, g, b)
Definition: qcolor_p.cpp:130
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ qt_get_rgb_val()

uint qt_get_rgb_val ( const char *  name)

Definition at line 337 of file qcolor_p.cpp.

Referenced by qt_get_colornames().

338 {
339  QRgb r = 0;
341  return r;
342 }
unsigned int QRgb
Definition: qrgb.h:53
bool qt_get_named_rgb(const char *name, QRgb *rgb)
Definition: qcolor_p.cpp:306
const char * name