src/gui/painting/qbrush.cpp
changeset 33 3e2da88830cd
parent 30 5dc02b23752f
equal deleted inserted replaced
30:5dc02b23752f 33:3e2da88830cd
    46 #include "qdatastream.h"
    46 #include "qdatastream.h"
    47 #include "qvariant.h"
    47 #include "qvariant.h"
    48 #include "qline.h"
    48 #include "qline.h"
    49 #include "qdebug.h"
    49 #include "qdebug.h"
    50 #include <QtCore/qcoreapplication.h>
    50 #include <QtCore/qcoreapplication.h>
       
    51 #include "private/qstylehelper_p.h"
    51 
    52 
    52 QT_BEGIN_NAMESPACE
    53 QT_BEGIN_NAMESPACE
    53 
    54 
    54 const uchar *qt_patternForBrush(int brushStyle, bool invert)
    55 const uchar *qt_patternForBrush(int brushStyle, bool invert)
    55 {
    56 {
    94     return pat_tbl[brushStyle - Qt::Dense1Pattern];
    95     return pat_tbl[brushStyle - Qt::Dense1Pattern];
    95 }
    96 }
    96 
    97 
    97 QPixmap qt_pixmapForBrush(int brushStyle, bool invert)
    98 QPixmap qt_pixmapForBrush(int brushStyle, bool invert)
    98 {
    99 {
       
   100 
    99     QPixmap pm;
   101     QPixmap pm;
   100     QString key = QLatin1String("$qt-brush$") + QString::number(brushStyle)
   102     QString key = QLatin1Literal("$qt-brush$")
   101                   + QString::number((int)invert);
   103                   % HexString<uint>(brushStyle)
       
   104                   % QLatin1Char(invert ? '1' : '0');
   102     if (!QPixmapCache::find(key, pm)) {
   105     if (!QPixmapCache::find(key, pm)) {
   103         pm = QBitmap::fromData(QSize(8, 8), qt_patternForBrush(brushStyle, invert),
   106         pm = QBitmap::fromData(QSize(8, 8), qt_patternForBrush(brushStyle, invert),
   104                                QImage::Format_MonoLSB);
   107                                QImage::Format_MonoLSB);
   105         QPixmapCache::insert(key, pm);
   108         QPixmapCache::insert(key, pm);
   106     }
   109     }
   327     currently set pen) when drawing shapes. Use \l {Qt::NoPen}{\c
   330     currently set pen) when drawing shapes. Use \l {Qt::NoPen}{\c
   328     painter.setPen(Qt::NoPen)} to disable this behavior.
   331     painter.setPen(Qt::NoPen)} to disable this behavior.
   329 
   332 
   330     \endtable
   333     \endtable
   331 
   334 
   332     For more information about painting in general, see \l{The Paint
   335     For more information about painting in general, see the \l{Paint
   333     System} documentation.
   336     System}.
   334 
   337 
   335     \sa Qt::BrushStyle, QPainter, QColor
   338     \sa Qt::BrushStyle, QPainter, QColor
   336 */
   339 */
   337 
   340 
   338 #ifndef QT_NO_THREAD
   341 #ifndef QT_NO_THREAD
  1011     \relates QBrush
  1014     \relates QBrush
  1012 
  1015 
  1013     Writes the given \a brush to the given \a stream and returns a
  1016     Writes the given \a brush to the given \a stream and returns a
  1014     reference to the \a stream.
  1017     reference to the \a stream.
  1015 
  1018 
  1016     \sa {Format of the QDataStream Operators}
  1019     \sa {Serializing Qt Data Types}
  1017 */
  1020 */
  1018 
  1021 
  1019 QDataStream &operator<<(QDataStream &s, const QBrush &b)
  1022 QDataStream &operator<<(QDataStream &s, const QBrush &b)
  1020 {
  1023 {
  1021     quint8 style = (quint8) b.style();
  1024     quint8 style = (quint8) b.style();
  1079     \relates QBrush
  1082     \relates QBrush
  1080 
  1083 
  1081     Reads the given \a brush from the given \a stream and returns a
  1084     Reads the given \a brush from the given \a stream and returns a
  1082     reference to the \a stream.
  1085     reference to the \a stream.
  1083 
  1086 
  1084     \sa {Format of the QDataStream Operators}
  1087     \sa {Serializing Qt Data Types}
  1085 */
  1088 */
  1086 
  1089 
  1087 QDataStream &operator>>(QDataStream &s, QBrush &b)
  1090 QDataStream &operator>>(QDataStream &s, QBrush &b)
  1088 {
  1091 {
  1089     quint8 style;
  1092     quint8 style;