src/gui/painting/qcolor.cpp File Reference

#include "qcolor.h"
#include "qcolor_p.h"
#include "qnamespace.h"
#include "qcolormap.h"
#include "qdatastream.h"
#include "qvariant.h"
#include "qdebug.h"
#include <math.h>
#include <stdio.h>
#include <limits.h>

Include dependency graph for qcolor.cpp:

Go to the source code of this file.

Defines

#define QCOLOR_INT_RANGE_CHECK(fn, var)
#define QCOLOR_REAL_RANGE_CHECK(fn, var)
#define QRGB(r, g, b)   QRgb(((0xff << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff)))
#define QRGBA(r, g, b, a)   QRgb(((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff))
#define Q_MAX_3(a, b, c)   ( ( a > b && a > c) ? a : (b > c ? b : c) )
#define Q_MIN_3(a, b, c)   ( ( a < b && a < c) ? a : (b < c ? b : c) )

Functions

QDebug operator<< (QDebug dbg, const QColor &c)
QDataStreamoperator<< (QDataStream &stream, const QColor &color)
QDataStreamoperator>> (QDataStream &stream, QColor &color)


Define Documentation

#define Q_MAX_3 ( a,
b,
 )     ( ( a > b && a > c) ? a : (b > c ? b : c) )

Definition at line 1323 of file qcolor.cpp.

Referenced by QColor::toHsv().

#define Q_MIN_3 ( a,
b,
 )     ( ( a < b && a < c) ? a : (b < c ? b : c) )

Definition at line 1324 of file qcolor.cpp.

Referenced by QColor::toHsv().

#define QCOLOR_INT_RANGE_CHECK ( fn,
var   ) 

Value:

do { \
        if (var < 0 || var > 255) { \
            qWarning(#fn": invalid value %d", var); \
            var = qMax(0, qMin(var, 255)); \
        } \
    } while (0)

Definition at line 249 of file qcolor.cpp.

Referenced by QColor::setAlpha(), QColor::setBlue(), QColor::setGreen(), and QColor::setRed().

#define QCOLOR_REAL_RANGE_CHECK ( fn,
var   ) 

Value:

do { \
        if (var < qreal(0.0) || var > qreal(1.0)) { \
            qWarning(#fn": invalid value %g", var); \
            var = qMax(qreal(0.0), qMin(var, qreal(1.0)));      \
        } \
    } while (0)

Definition at line 257 of file qcolor.cpp.

Referenced by QColor::setAlphaF(), QColor::setBlueF(), QColor::setGreenF(), and QColor::setRedF().

#define QRGB ( r,
g,
 )     QRgb(((0xff << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff)))

#define QRGBA ( r,
g,
b,
 )     QRgb(((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff))

Referenced by QColor::QColor().


Function Documentation

QDataStream& operator<< ( QDataStream stream,
const QColor color 
)

Definition at line 1973 of file qcolor.cpp.

01974 {
01975     if (stream.version() < 7) {
01976         quint32 p = (quint32)color.rgb();
01977         if (stream.version() == 1) // Swap red and blue
01978             p = ((p << 16) & 0xff0000) | ((p >> 16) & 0xff) | (p & 0xff00ff00);
01979         return stream << p;
01980     }
01981 
01982     qint8   s = color.cspec;
01983     quint16 a = color.ct.argb.alpha;
01984     quint16 r = color.ct.argb.red;
01985     quint16 g = color.ct.argb.green;
01986     quint16 b = color.ct.argb.blue;
01987     quint16 p = color.ct.argb.pad;
01988 
01989     stream << s;
01990     stream << a;
01991     stream << r;
01992     stream << g;
01993     stream << b;
01994     stream << p;
01995 
01996     return stream;
01997 }

QDebug operator<< ( QDebug  dbg,
const QColor c 
)

Definition at line 1942 of file qcolor.cpp.

01943 {
01944 #ifndef Q_BROKEN_DEBUG_STREAM
01945     if (!c.isValid())
01946         dbg.nospace() << "QColor(Invalid)";
01947     else if (c.spec() == QColor::Rgb)
01948         dbg.nospace() << "QColor(ARGB " << c.alphaF() << ", " << c.redF() << ", " << c.greenF() << ", " << c.blueF() << ")";
01949     else if (c.spec() == QColor::Hsv)
01950         dbg.nospace() << "QColor(AHSV " << c.alphaF() << ", " << c.hueF() << ", " << c.saturationF() << ", " << c.valueF() << ")";
01951     else if (c.spec() == QColor::Cmyk)
01952         dbg.nospace() << "QColor(ACMYK " << c.alphaF() << ", " << c.cyanF() << ", " << c.magentaF() << ", " << c.yellowF() << ", "
01953                       << c.blackF()<< ")";
01954 
01955     return dbg.space();
01956 #else
01957     qWarning("This compiler doesn't support streaming QColor to QDebug");
01958     return dbg;
01959     Q_UNUSED(c);
01960 #endif
01961 }

QDataStream& operator>> ( QDataStream stream,
QColor color 
)

Definition at line 2007 of file qcolor.cpp.

02008 {
02009     if (stream.version() < 7) {
02010         quint32 p;
02011         stream >> p;
02012         if (stream.version() == 1) // Swap red and blue
02013             p = ((p << 16) & 0xff0000) | ((p >> 16) & 0xff) | (p & 0xff00ff00);
02014         color.setRgb(p);
02015         return stream;
02016     }
02017 
02018     qint8 s;
02019     quint16 a, r, g, b, p;
02020     stream >> s;
02021     stream >> a;
02022     stream >> r;
02023     stream >> g;
02024     stream >> b;
02025     stream >> p;
02026 
02027     color.cspec = QColor::Spec(s);
02028     color.ct.argb.alpha = a;
02029     color.ct.argb.red   = r;
02030     color.ct.argb.green = g;
02031     color.ct.argb.blue  = b;
02032     color.ct.argb.pad   = p;
02033 
02034     return stream;
02035 }


Generated on Thu Mar 15 13:32:15 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1