src/colors.h

changeset 1217
314e12e23c3a
parent 998
5be0ce31ce60
child 1222
34def2630300
equal deleted inserted replaced
1216:12f9ea615cbc 1217:314e12e23c3a
33 33
34 enum { EntryCount = 512 }; 34 enum { EntryCount = 512 };
35 ColorData(); 35 ColorData();
36 ~ColorData(); 36 ~ColorData();
37 void loadFromLdconfig(); 37 void loadFromLdconfig();
38 bool contains (int code) const; 38 bool contains(int code) const;
39 const Entry& get (int code) const; 39 const Entry& get(int code) const;
40 40
41 private: 41 private:
42 Entry m_data[EntryCount]; 42 Entry m_data[EntryCount];
43 }; 43 };
44 44
45 class LDColor 45 class LDColor
46 { 46 {
47 public: 47 public:
48 LDColor() : m_index (0) {} 48 LDColor() : m_index(0) {}
49 LDColor (qint32 index) : m_index (index) {} 49 LDColor(qint32 index) : m_index(index) {}
50 LDColor (const LDColor& other) : m_index (other.m_index) {} 50 LDColor(const LDColor& other) : m_index(other.m_index) {}
51 51
52 bool isLDConfigColor() const; 52 bool isLDConfigColor() const;
53 bool isValid() const; 53 bool isValid() const;
54 QString name() const; 54 QString name() const;
55 QString hexcode() const; 55 QString hexcode() const;
59 int luma() const; 59 int luma() const;
60 int edgeLuma() const; 60 int edgeLuma() const;
61 bool isDirect() const; 61 bool isDirect() const;
62 QString indexString() const; 62 QString indexString() const;
63 63
64 static LDColor nullColor() { return LDColor (-1); } 64 static LDColor nullColor() { return LDColor(-1); }
65 65
66 LDColor& operator= (qint32 index) { m_index = index; return *this; } 66 LDColor& operator= (qint32 index) { m_index = index; return *this; }
67 LDColor& operator= (LDColor other) { m_index = other.index(); return *this; } 67 LDColor& operator= (LDColor other) { m_index = other.index(); return *this; }
68 LDColor operator++() { return ++m_index; } 68 LDColor operator++() { return ++m_index; }
69 LDColor operator++ (int) { return m_index++; } 69 LDColor operator++(int) { return m_index++; }
70 LDColor operator--() { return --m_index; } 70 LDColor operator--() { return --m_index; }
71 LDColor operator-- (int) { return m_index--; } 71 LDColor operator--(int) { return m_index--; }
72 72
73 bool operator== (LDColor other) const { return index() == other.index(); } 73 bool operator== (LDColor other) const { return index() == other.index(); }
74 bool operator!= (LDColor other) const { return index() != other.index(); } 74 bool operator!= (LDColor other) const { return index() != other.index(); }
75 bool operator< (LDColor other) const { return index() < other.index(); } 75 bool operator<(LDColor other) const { return index() < other.index(); }
76 bool operator<= (LDColor other) const { return index() <= other.index(); } 76 bool operator<= (LDColor other) const { return index() <= other.index(); }
77 bool operator> (LDColor other) const { return index() > other.index(); } 77 bool operator>(LDColor other) const { return index() > other.index(); }
78 bool operator>= (LDColor other) const { return index() >= other.index(); } 78 bool operator>= (LDColor other) const { return index() >= other.index(); }
79 79
80 private: 80 private:
81 const ColorData::Entry& data() const; 81 const ColorData::Entry& data() const;
82 82
87 // Parses ldconfig.ldr 87 // Parses ldconfig.ldr
88 // 88 //
89 class LDConfigParser 89 class LDConfigParser
90 { 90 {
91 public: 91 public:
92 LDConfigParser (QString inText, char sep); 92 LDConfigParser(QString inText, char sep);
93 93
94 bool getToken (QString& val, const int pos); 94 bool getToken(QString& val, const int pos);
95 bool findToken (int& result, char const* needle, int args); 95 bool findToken(int& result, char const* needle, int args);
96 bool compareToken (int inPos, QString text); 96 bool compareToken(int inPos, QString text);
97 bool parseTag (char const* tag, QString& val); 97 bool parseTag(char const* tag, QString& val);
98 98
99 inline QString operator[] (const int idx) 99 inline QString operator[](const int idx)
100 { 100 {
101 return m_tokens[idx]; 101 return m_tokens[idx];
102 } 102 }
103 103
104 private: 104 private:
105 QStringList m_tokens; 105 QStringList m_tokens;
106 int m_pos; 106 int m_pos;
107 }; 107 };
108 108
109 void initColors(); 109 void initColors();
110 int luma (const QColor& col); 110 int luma(const QColor& col);
111 111
112 enum 112 enum
113 { 113 {
114 MainColor = 16, 114 MainColor = 16,
115 EdgeColor = 24, 115 EdgeColor = 24,

mercurial