src/gui/styles/qstylehelper_p.h
changeset 30 5dc02b23752f
parent 18 2f34d5167611
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
    39 **
    39 **
    40 ****************************************************************************/
    40 ****************************************************************************/
    41 
    41 
    42 #include <QtCore/qglobal.h>
    42 #include <QtCore/qglobal.h>
    43 #include <QtCore/qpoint.h>
    43 #include <QtCore/qpoint.h>
       
    44 #include <QtCore/qstring.h>
    44 #include <QtGui/qpolygon.h>
    45 #include <QtGui/qpolygon.h>
       
    46 #include <QtCore/qstringbuilder.h>
    45 
    47 
    46 #ifndef QSTYLEHELPER_P_H
    48 #ifndef QSTYLEHELPER_P_H
    47 #define QSTYLEHELPER_P_H
    49 #define QSTYLEHELPER_P_H
    48 
    50 
    49 //
    51 //
    77     void drawBorderPixmap(const QPixmap &pixmap, QPainter *painter, const QRect &rect,
    79     void drawBorderPixmap(const QPixmap &pixmap, QPainter *painter, const QRect &rect,
    78                      int left = 0, int top = 0, int right = 0,
    80                      int left = 0, int top = 0, int right = 0,
    79                      int bottom = 0);
    81                      int bottom = 0);
    80 }
    82 }
    81 
    83 
       
    84 // internal helper. Converts an integer value to an unique string token
       
    85 template <typename T>
       
    86         struct HexString
       
    87 {
       
    88     inline HexString(const T t)
       
    89         : val(t)
       
    90     {}
       
    91 
       
    92     inline void write(QChar *&dest) const
       
    93     {
       
    94         const ushort hexChars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
       
    95         const char *c = reinterpret_cast<const char *>(&val);
       
    96         for (uint i = 0; i < sizeof(T); ++i) {
       
    97             *dest++ = hexChars[*c & 0xf];
       
    98             *dest++ = hexChars[(*c & 0xf0) >> 4];
       
    99             ++c;
       
   100         }
       
   101     }
       
   102     const T val;
       
   103 };
       
   104 
       
   105 // specialization to enable fast concatenating of our string tokens to a string
       
   106 template <typename T>
       
   107         struct QConcatenable<HexString<T> >
       
   108 {
       
   109     typedef HexString<T> type;
       
   110     enum { ExactSize = true };
       
   111     static int size(const HexString<T> &str) { return sizeof(str.val) * 2; }
       
   112     static inline void appendTo(const HexString<T> &str, QChar *&out) { str.write(out); }
       
   113 };
       
   114 
    82 QT_END_NAMESPACE
   115 QT_END_NAMESPACE
    83 
   116 
    84 #endif // QSTYLEHELPER_P_H
   117 #endif // QSTYLEHELPER_P_H