Diffstat (limited to 'noncore/settings/appearance2/exceptlistitem.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/appearance2/exceptlistitem.h | 199 |
1 files changed, 199 insertions, 0 deletions
diff --git a/noncore/settings/appearance2/exceptlistitem.h b/noncore/settings/appearance2/exceptlistitem.h new file mode 100644 index 0000000..5eda79c --- a/dev/null +++ b/noncore/settings/appearance2/exceptlistitem.h | |||
@@ -0,0 +1,199 @@ | |||
1 | /* | ||
2 | =. This file is part of the OPIE Project | ||
3 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This file is free software; you can | ||
6 | .> <`_, > . <= redistribute it and/or modify it under | ||
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This file is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | ||
17 | ..}^=.= = ; Public License for more details. | ||
18 | ++= -. .` .: | ||
19 | : = ...= . :.=- You should have received a copy of the GNU | ||
20 | -. .:....=;==+<; General Public License along with this file; | ||
21 | -_. . . )=. = see the file COPYING. If not, write to the | ||
22 | -- :-=` Free Software Foundation, Inc., | ||
23 | 59 Temple Place - Suite 330, | ||
24 | Boston, MA 02111-1307, USA. | ||
25 | |||
26 | */ | ||
27 | |||
28 | #ifndef EXCEPTLISTITEM_H | ||
29 | #define EXCEPTLISTITEM_H | ||
30 | |||
31 | #include <qlistview.h> | ||
32 | #include <qpixmap.h> | ||
33 | #include <qimage.h> | ||
34 | #include <qpainter.h> | ||
35 | |||
36 | class ExceptListItem : public QListViewItem { | ||
37 | public: | ||
38 | ExceptListItem ( QListView *lv, const QString &t, bool nostyle = true, bool nofont = true, bool nodeco = true ) : QListViewItem ( lv ) | ||
39 | { | ||
40 | m_text = t; | ||
41 | |||
42 | m_nofont = nofont; | ||
43 | m_nostyle = nostyle; | ||
44 | m_nodeco = nodeco; | ||
45 | |||
46 | init ( ); | ||
47 | } | ||
48 | |||
49 | virtual ~ExceptListItem ( ) | ||
50 | { | ||
51 | } | ||
52 | |||
53 | static void overlay ( QImage &img, const QImage &ovl ) | ||
54 | { | ||
55 | if (( img. size ( ) != ovl. size ( )) || | ||
56 | ( img. depth ( ) != ovl. depth ( ))) | ||
57 | return; | ||
58 | |||
59 | for ( int y = 0; y != img. height ( ); y++ ) { | ||
60 | QRgb *iline = (QRgb *) img. scanLine ( y ); | ||
61 | QRgb *oline = (QRgb *) ovl. scanLine ( y ); | ||
62 | |||
63 | for ( int x = 0; x != img. width ( ); x++ ) { | ||
64 | QRgb i = *iline; | ||
65 | QRgb o = *oline; | ||
66 | |||
67 | *iline = qRgba (( qRed ( i ) + qRed ( o )) / 2, | ||
68 | ( qGreen ( i ) + qGreen ( o )) / 2, | ||
69 | ( qBlue ( i ) + qBlue ( o )) / 2, | ||
70 | ( qAlpha ( i ) + qAlpha ( o )) / 2 ); | ||
71 | iline++; | ||
72 | oline++; | ||
73 | } | ||
74 | } | ||
75 | } | ||
76 | |||
77 | static void init ( ) | ||
78 | { | ||
79 | static bool init = false; | ||
80 | |||
81 | if ( init ) | ||
82 | return; | ||
83 | |||
84 | QImage noimg = Resource::loadImage ( "appearance/no.png" ); | ||
85 | QImage fontimg = Resource::loadImage ( "appearance/font.png" ); | ||
86 | QImage styleimg = Resource::loadImage ( "appearance/style.png" ); | ||
87 | QImage decoimg = Resource::loadImage ( "appearance/deco.png" ); | ||
88 | |||
89 | s_fontpix [0] = new QPixmap ( ); | ||
90 | s_fontpix [0]-> convertFromImage ( fontimg ); | ||
91 | overlay ( fontimg, noimg ); | ||
92 | s_fontpix [1] = new QPixmap ( ); | ||
93 | s_fontpix [1]-> convertFromImage ( fontimg ); | ||
94 | |||
95 | s_stylepix [0] = new QPixmap ( ); | ||
96 | s_stylepix [0]-> convertFromImage ( styleimg ); | ||
97 | overlay ( styleimg, noimg ); | ||
98 | s_stylepix [1] = new QPixmap ( ); | ||
99 | s_stylepix [1]-> convertFromImage ( styleimg ); | ||
100 | |||
101 | s_decopix [0] = new QPixmap ( ); | ||
102 | s_decopix [0]-> convertFromImage ( decoimg ); | ||
103 | overlay ( decoimg, noimg ); | ||
104 | s_decopix [1] = new QPixmap ( ); | ||
105 | s_decopix [1]-> convertFromImage ( decoimg ); | ||
106 | |||
107 | init = true; | ||
108 | } | ||
109 | |||
110 | bool noFont ( ) const | ||
111 | { | ||
112 | return m_nofont; | ||
113 | } | ||
114 | |||
115 | bool noStyle ( ) const | ||
116 | { | ||
117 | return m_nostyle; | ||
118 | } | ||
119 | |||
120 | bool noDeco ( ) const | ||
121 | { | ||
122 | return m_nodeco; | ||
123 | } | ||
124 | |||
125 | void setNoDeco ( bool b ) | ||
126 | { | ||
127 | if ( b != m_nodeco ) { | ||
128 | m_nodeco = b; | ||
129 | repaint ( ); | ||
130 | } | ||
131 | } | ||
132 | |||
133 | void setNoStyle ( bool b ) | ||
134 | { | ||
135 | if ( b != m_nostyle ) { | ||
136 | m_nostyle = b; | ||
137 | repaint ( ); | ||
138 | } | ||
139 | } | ||
140 | |||
141 | void setNoFont ( bool b ) | ||
142 | { | ||
143 | if ( b != m_nofont ) { | ||
144 | m_nofont = b; | ||
145 | repaint ( ); | ||
146 | } | ||
147 | } | ||
148 | |||
149 | QString pattern ( ) const | ||
150 | { | ||
151 | return m_text; | ||
152 | } | ||
153 | |||
154 | void setPattern ( const QString &s ) | ||
155 | { | ||
156 | if ( s != m_text ) { | ||
157 | m_text = s; | ||
158 | widthChanged ( 3 ); | ||
159 | repaint ( ); | ||
160 | } | ||
161 | } | ||
162 | |||
163 | QString text ( int i ) const | ||
164 | { | ||
165 | if ( i == 3 ) | ||
166 | return m_text; | ||
167 | else | ||
168 | return QString::null; | ||
169 | |||
170 | } | ||
171 | |||
172 | const QPixmap *pixmap ( int i ) const | ||
173 | { | ||
174 | if ( i == 0 ) | ||
175 | return (const QPixmap *) s_stylepix [m_nostyle ? 1 : 0]; | ||
176 | else if ( i == 1 ) | ||
177 | return (const QPixmap *) s_fontpix [m_nofont ? 1 : 0]; | ||
178 | else if ( i == 2 ) | ||
179 | return (const QPixmap *) s_decopix [m_nodeco ? 1 : 0]; | ||
180 | else | ||
181 | return 0; | ||
182 | } | ||
183 | |||
184 | private: | ||
185 | QString m_text; | ||
186 | bool m_nofont; | ||
187 | bool m_nostyle; | ||
188 | bool m_nodeco; | ||
189 | |||
190 | static QPixmap *s_stylepix [2]; | ||
191 | static QPixmap *s_fontpix [2]; | ||
192 | static QPixmap *s_decopix [2]; | ||
193 | }; | ||
194 | |||
195 | QPixmap *ExceptListItem::s_stylepix [2] = { 0, 0 }; | ||
196 | QPixmap *ExceptListItem::s_fontpix [2] = { 0, 0 }; | ||
197 | QPixmap *ExceptListItem::s_decopix [2] = { 0, 0 }; | ||
198 | |||
199 | #endif | ||