author | sandman <sandman> | 2002-10-04 00:46:45 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-10-04 00:46:45 (UTC) |
commit | 7f1029811faae4aa88c0c35157a33b95abffaae8 (patch) (unidiff) | |
tree | 3cab1efdd4a88ae832dd29a424b1c9d884679ef4 | |
parent | 4131d24ac051733b2d9ba323b18e6602ae396b85 (diff) | |
download | opie-7f1029811faae4aa88c0c35157a33b95abffaae8.zip opie-7f1029811faae4aa88c0c35157a33b95abffaae8.tar.gz opie-7f1029811faae4aa88c0c35157a33b95abffaae8.tar.bz2 |
Added three window decoration flavours:
- flat from Qtopia 1.6
- polished from Qtopia 1.6
- liquid - this was written by me and resembles the KDE3 liquid look
-rw-r--r-- | noncore/decorations/flat/flat.cpp | 360 | ||||
-rw-r--r-- | noncore/decorations/flat/flat.h | 49 | ||||
-rw-r--r-- | noncore/decorations/flat/flat.pro | 11 | ||||
-rw-r--r-- | noncore/decorations/flat/opie-deco-flat.control | 9 | ||||
-rw-r--r-- | noncore/decorations/liquid/liquid.cpp | 136 | ||||
-rw-r--r-- | noncore/decorations/liquid/liquid.h | 25 | ||||
-rw-r--r-- | noncore/decorations/liquid/liquid.pro | 10 | ||||
-rw-r--r-- | noncore/decorations/liquid/opie-deco-liquid.control | 9 | ||||
-rw-r--r-- | noncore/decorations/polished/opie-deco-polished.control | 9 | ||||
-rw-r--r-- | noncore/decorations/polished/polished.cpp | 171 | ||||
-rw-r--r-- | noncore/decorations/polished/polished.h | 49 | ||||
-rw-r--r-- | noncore/decorations/polished/polished.pro | 11 |
12 files changed, 849 insertions, 0 deletions
diff --git a/noncore/decorations/flat/flat.cpp b/noncore/decorations/flat/flat.cpp new file mode 100644 index 0000000..b6a81a3 --- a/dev/null +++ b/noncore/decorations/flat/flat.cpp | |||
@@ -0,0 +1,360 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of the Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #include "flat.h" | ||
22 | #include <qpainter.h> | ||
23 | #include <qapplication.h> | ||
24 | |||
25 | |||
26 | /* XPM */ | ||
27 | static const char * ok_xpm[] = { | ||
28 | "32 32 3 1", | ||
29 | " c None", | ||
30 | ".c #000000", | ||
31 | "+c #FFFFFF", | ||
32 | " ", | ||
33 | " ", | ||
34 | " ++++++++ ", | ||
35 | " ++++++++++++ ", | ||
36 | " +++++ +++++ ", | ||
37 | " +++ +++ ", | ||
38 | " +++ +++ ", | ||
39 | " +++ +++ ", | ||
40 | " +++ +++ ", | ||
41 | " ++ ++ ", | ||
42 | " ++ +++++ ++ ++ ++ ", | ||
43 | " ++ ++++++++ ++ +++ ++ ", | ||
44 | " +++ +++ +++ ++ +++ +++ ", | ||
45 | " ++ +++ ++ ++ +++ ++ ", | ||
46 | " ++ ++ ++ ++ ++ ++ ", | ||
47 | " ++ ++ ++ +++++ ++ ", | ||
48 | " ++ ++ ++ ++++ ++ ", | ||
49 | " ++ ++ ++ ++ ++ ++ ", | ||
50 | " ++ +++ ++ ++ +++ ++ ", | ||
51 | " +++ +++ +++ ++ +++ +++ ", | ||
52 | " ++ ++++++++ ++ ++ ++ ", | ||
53 | " ++ +++++ ++ ++ ++ ", | ||
54 | " ++ ++ ", | ||
55 | " +++ +++ ", | ||
56 | " +++ +++ ", | ||
57 | " +++ +++ ", | ||
58 | " +++ +++ ", | ||
59 | " +++++ +++++ ", | ||
60 | " ++++++++++++ ", | ||
61 | " ++++++++ ", | ||
62 | " ", | ||
63 | " "}; | ||
64 | |||
65 | |||
66 | /* XPM */ | ||
67 | static const char * close_xpm[] = { | ||
68 | "32 32 3 1", | ||
69 | " c None", | ||
70 | ".c #000000", | ||
71 | "+c #FFFFFF", | ||
72 | " ", | ||
73 | " ", | ||
74 | " ++++++++ ", | ||
75 | " ++++++++++++ ", | ||
76 | " +++++ +++++ ", | ||
77 | " +++ +++ ", | ||
78 | " +++ +++ ", | ||
79 | " +++ +++ ", | ||
80 | " +++ +++ ", | ||
81 | " ++ ++ ++ ++ ", | ||
82 | " ++ +++ +++ ++ ", | ||
83 | " ++ +++ +++ ++ ", | ||
84 | " +++ +++ +++ +++ ", | ||
85 | " ++ +++ +++ ++ ", | ||
86 | " ++ ++++++ ++ ", | ||
87 | " ++ ++++ ++ ", | ||
88 | " ++ ++++ ++ ", | ||
89 | " ++ ++++++ ++ ", | ||
90 | " ++ +++ +++ ++ ", | ||
91 | " +++ +++ +++ +++ ", | ||
92 | " ++ +++ +++ ++ ", | ||
93 | " ++ +++ +++ ++ ", | ||
94 | " ++ ++ ++ ++ ", | ||
95 | " +++ +++ ", | ||
96 | " +++ +++ ", | ||
97 | " +++ +++ ", | ||
98 | " +++ +++ ", | ||
99 | " +++++ +++++ ", | ||
100 | " ++++++++++++ ", | ||
101 | " ++++++++ ", | ||
102 | " ", | ||
103 | " "}; | ||
104 | |||
105 | |||
106 | /* XPM */ | ||
107 | static const char * help_xpm[] = { | ||
108 | "32 32 3 1", | ||
109 | " c None", | ||
110 | ".c #000000", | ||
111 | "+c #FFFFFF", | ||
112 | " ", | ||
113 | " ", | ||
114 | " ++++++++ ", | ||
115 | " ++++++++++++ ", | ||
116 | " +++++ +++++ ", | ||
117 | " +++ +++ ", | ||
118 | " +++ +++ ", | ||
119 | " +++ +++ ", | ||
120 | " +++ +++++ +++ ", | ||
121 | " ++ ++++++++ ++ ", | ||
122 | " ++ ++++ ++++ ++ ", | ||
123 | " ++ +++ +++ ++ ", | ||
124 | " +++ +++ +++ +++ ", | ||
125 | " ++ ++++ ++ ", | ||
126 | " ++ +++++ ++ ", | ||
127 | " ++ +++++ ++ ", | ||
128 | " ++ ++++ ++ ", | ||
129 | " ++ ++++ ++ ", | ||
130 | " ++ +++ ++ ", | ||
131 | " +++ +++ +++ ", | ||
132 | " ++ ++ ", | ||
133 | " ++ ++ ", | ||
134 | " ++ +++ ++ ", | ||
135 | " +++ +++ +++ ", | ||
136 | " +++ +++ ", | ||
137 | " +++ +++ ", | ||
138 | " +++ +++ ", | ||
139 | " +++++ +++++ ", | ||
140 | " ++++++++++++ ", | ||
141 | " ++++++++ ", | ||
142 | " ", | ||
143 | " "}; | ||
144 | |||
145 | |||
146 | /* XPM */ | ||
147 | static const char * maximize_xpm[] = { | ||
148 | "32 32 3 1", | ||
149 | " c None", | ||
150 | ".c #000000", | ||
151 | "+c #FFFFFF", | ||
152 | " ", | ||
153 | " ", | ||
154 | " ++++++++ ", | ||
155 | " ++++++++++++ ", | ||
156 | " +++++ +++++ ", | ||
157 | " +++ +++ ", | ||
158 | " +++ +++ ", | ||
159 | " +++ +++ ", | ||
160 | " +++ ++++++++++++++ +++ ", | ||
161 | " ++ ++++++++++++++ ++ ", | ||
162 | " ++ ++++++++++++++ ++ ", | ||
163 | " ++ +++ +++ ++ ", | ||
164 | " +++ +++ +++ +++ ", | ||
165 | " ++ +++ +++ ++ ", | ||
166 | " ++ +++ +++ ++ ", | ||
167 | " ++ +++ +++ ++ ", | ||
168 | " ++ +++ +++ ++ ", | ||
169 | " ++ +++ +++ ++ ", | ||
170 | " ++ +++ +++ ++ ", | ||
171 | " +++ +++ +++ +++ ", | ||
172 | " ++ +++ +++ ++ ", | ||
173 | " ++ ++++++++++++++ ++ ", | ||
174 | " ++ ++++++++++++++ ++ ", | ||
175 | " +++ ++++++++++++++ +++ ", | ||
176 | " +++ +++ ", | ||
177 | " +++ +++ ", | ||
178 | " +++ +++ ", | ||
179 | " +++++ +++++ ", | ||
180 | " ++++++++++++ ", | ||
181 | " ++++++++ ", | ||
182 | " ", | ||
183 | " "}; | ||
184 | |||
185 | static QImage scaleButton( const QImage &img, int height ) | ||
186 | { | ||
187 | if ( img.height() != height ) { | ||
188 | return img.smoothScale( img.width()*height/img.height(), height ); | ||
189 | } else { | ||
190 | return img; | ||
191 | } | ||
192 | } | ||
193 | |||
194 | static void colorize( QImage &img, const QColor &c, bool rev ) | ||
195 | { | ||
196 | for ( int i = 0; i < img.numColors(); i++ ) { | ||
197 | bool sc = (img.color(i) & 0xff000000); | ||
198 | if ( rev ) sc = !sc; | ||
199 | img.setColor(i, sc ? c.rgb() : 0x00000000 ); | ||
200 | } | ||
201 | } | ||
202 | |||
203 | FlatDecoration::FlatDecoration() : ref(0), buttonCache(16) | ||
204 | { | ||
205 | buttonCache.setAutoDelete(TRUE); | ||
206 | } | ||
207 | |||
208 | FlatDecoration::~FlatDecoration() | ||
209 | { | ||
210 | } | ||
211 | |||
212 | int FlatDecoration::metric( Metric m, const WindowData *wd ) const | ||
213 | { | ||
214 | switch ( m ) { | ||
215 | case TopBorder: | ||
216 | return 1; | ||
217 | break; | ||
218 | case LeftBorder: | ||
219 | case RightBorder: | ||
220 | return 2; | ||
221 | case BottomBorder: | ||
222 | return 4; | ||
223 | case TitleHeight: | ||
224 | if ( QApplication::desktop()->height() > 320 ) | ||
225 | return 20; | ||
226 | else | ||
227 | return 18; | ||
228 | case OKWidth: | ||
229 | case CloseWidth: | ||
230 | case HelpWidth: | ||
231 | case MaximizeWidth: | ||
232 | return metric(TitleHeight,wd); | ||
233 | break; | ||
234 | default: | ||
235 | return WindowDecorationInterface::metric( m, wd ); | ||
236 | break; | ||
237 | } | ||
238 | |||
239 | return 0; | ||
240 | } | ||
241 | |||
242 | void FlatDecoration::drawArea( Area a, QPainter *p, const WindowData *wd ) const | ||
243 | { | ||
244 | int th = metric( TitleHeight, wd ); | ||
245 | QRect r = wd->rect; | ||
246 | |||
247 | switch ( a ) { | ||
248 | case Border: | ||
249 | { | ||
250 | const QColorGroup &cg = wd->palette.active(); | ||
251 | if ( wd->flags & WindowData::Active ) { | ||
252 | p->setBrush( cg.color(QColorGroup::Highlight) ); | ||
253 | } else { | ||
254 | p->setBrush( cg.color(QColorGroup::Background) ); | ||
255 | } | ||
256 | p->setPen( cg.foreground() ); | ||
257 | int lb = metric(LeftBorder,wd); | ||
258 | int rb = metric(RightBorder,wd); | ||
259 | int tb = metric(TopBorder,wd); | ||
260 | int bb = metric(BottomBorder,wd); | ||
261 | p->drawRect( r.x()-lb, r.y()-tb-th, r.width()+lb+rb, | ||
262 | r.height()+th+tb+bb ); | ||
263 | } | ||
264 | break; | ||
265 | case Title: | ||
266 | if ( r.height() < 2 ) { | ||
267 | WindowDecorationInterface::drawArea( a, p, wd ); | ||
268 | } else { | ||
269 | const QColorGroup &cg = wd->palette.active(); | ||
270 | QColor c; | ||
271 | if ( wd->flags & WindowData::Active ) | ||
272 | c = cg.color(QColorGroup::Highlight); | ||
273 | else | ||
274 | c = cg.color(QColorGroup::Background); | ||
275 | p->fillRect( QRect(r.x(),r.y()-th,r.width(),th), c ); | ||
276 | } | ||
277 | break; | ||
278 | case TitleText: | ||
279 | p->drawText( r.left()+3+metric(HelpWidth,wd), r.top()-th, | ||
280 | r.width()-metric(HelpWidth,wd)-metric(CloseWidth,wd), th, | ||
281 | Qt::AlignVCenter, wd->caption ); | ||
282 | break; | ||
283 | default: | ||
284 | FlatDecoration::drawArea( a, p, wd ); | ||
285 | break; | ||
286 | } | ||
287 | } | ||
288 | |||
289 | void FlatDecoration::drawButton( Button b, QPainter *p, const WindowData *wd, int x, int y, int w, int h, QWSButton::State state ) const | ||
290 | { | ||
291 | QColor c; | ||
292 | const QColorGroup &cg = wd->palette.active(); | ||
293 | if ( wd->flags & WindowDecorationInterface::WindowData::Active ) | ||
294 | c = cg.color(QColorGroup::HighlightedText); | ||
295 | else | ||
296 | c = cg.color(QColorGroup::Foreground); | ||
297 | bool r = (state & QWSButton::MouseOver) && (state & QWSButton::Clicked); | ||
298 | int th = metric(TitleHeight, wd); | ||
299 | |||
300 | QString key( "%1-%2-%3-%4" ); | ||
301 | key = key.arg(b).arg(th).arg(c.name()).arg(r ? "1" : "0"); | ||
302 | QImage *img = buttonCache.find( key ); | ||
303 | if ( !img ) { | ||
304 | QImage tmp; | ||
305 | switch ( b ) { | ||
306 | case OK: | ||
307 | tmp = QImage( ok_xpm ); | ||
308 | break; | ||
309 | case Close: | ||
310 | tmp = QImage( close_xpm ); | ||
311 | break; | ||
312 | case Help: | ||
313 | tmp = QImage( help_xpm ); | ||
314 | break; | ||
315 | case Maximize: | ||
316 | tmp = QImage( maximize_xpm ); | ||
317 | break; | ||
318 | } | ||
319 | colorize( tmp, c, r ); | ||
320 | img = new QImage( scaleButton(tmp,th) ); | ||
321 | FlatDecoration *that = (FlatDecoration *)this; | ||
322 | that->buttonCache.insert( key, img, 1 ); | ||
323 | } | ||
324 | |||
325 | p->drawImage( x, y, *img ); | ||
326 | } | ||
327 | |||
328 | QRegion FlatDecoration::mask( const WindowData *wd ) const | ||
329 | { | ||
330 | return WindowDecorationInterface::mask( wd ); | ||
331 | } | ||
332 | |||
333 | QString FlatDecoration::name() const | ||
334 | { | ||
335 | return qApp->translate( "Decoration", "Flat" ); | ||
336 | } | ||
337 | |||
338 | QPixmap FlatDecoration::icon() const | ||
339 | { | ||
340 | return QPixmap(); | ||
341 | } | ||
342 | |||
343 | QRESULT FlatDecoration::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | ||
344 | { | ||
345 | *iface = 0; | ||
346 | if ( uuid == IID_QUnknown ) | ||
347 | *iface = this; | ||
348 | else if ( uuid == IID_WindowDecoration ) | ||
349 | *iface = this; | ||
350 | |||
351 | if ( *iface ) | ||
352 | (*iface)->addRef(); | ||
353 | return QS_OK; | ||
354 | } | ||
355 | |||
356 | Q_EXPORT_INTERFACE() | ||
357 | { | ||
358 | Q_CREATE_INSTANCE( FlatDecoration ) | ||
359 | } | ||
360 | |||
diff --git a/noncore/decorations/flat/flat.h b/noncore/decorations/flat/flat.h new file mode 100644 index 0000000..3d8a18b --- a/dev/null +++ b/noncore/decorations/flat/flat.h | |||
@@ -0,0 +1,49 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of the Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #ifndef FLAT_H | ||
22 | #define FLAT_H | ||
23 | |||
24 | #include <qtopia/windowdecorationinterface.h> | ||
25 | #include <qcache.h> | ||
26 | #include <qimage.h> | ||
27 | |||
28 | class FlatDecoration : public WindowDecorationInterface | ||
29 | { | ||
30 | public: | ||
31 | FlatDecoration(); | ||
32 | virtual ~FlatDecoration(); | ||
33 | |||
34 | virtual int metric( Metric m, const WindowData * ) const; | ||
35 | virtual void drawArea( Area a, QPainter *, const WindowData * ) const; | ||
36 | virtual void drawButton( Button b, QPainter *, const WindowData *, int x, int y, int w, int h, QWSButton::State ) const; | ||
37 | virtual QRegion mask( const WindowData * ) const; | ||
38 | virtual QString name() const; | ||
39 | virtual QPixmap icon() const; | ||
40 | |||
41 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | ||
42 | Q_REFCOUNT | ||
43 | |||
44 | private: | ||
45 | ulong ref; | ||
46 | QCache<QImage> buttonCache; | ||
47 | }; | ||
48 | |||
49 | #endif | ||
diff --git a/noncore/decorations/flat/flat.pro b/noncore/decorations/flat/flat.pro new file mode 100644 index 0000000..32bdb59 --- a/dev/null +++ b/noncore/decorations/flat/flat.pro | |||
@@ -0,0 +1,11 @@ | |||
1 | TEMPLATE= lib | ||
2 | CONFIG += qt warn_on release | ||
3 | HEADERS = flat.h | ||
4 | SOURCES = flat.cpp | ||
5 | TARGET = flat | ||
6 | DESTDIR = $(OPIEDIR)/plugins/decorations | ||
7 | INCLUDEPATH+= $(OPIEDIR)/include | ||
8 | DEPENDPATH += $(OPIEDIR)/include | ||
9 | LIBS += -lqpe | ||
10 | VERSION = 1.0.0 | ||
11 | |||
diff --git a/noncore/decorations/flat/opie-deco-flat.control b/noncore/decorations/flat/opie-deco-flat.control new file mode 100644 index 0000000..93c494c --- a/dev/null +++ b/noncore/decorations/flat/opie-deco-flat.control | |||
@@ -0,0 +1,9 @@ | |||
1 | Files: plugins/decorations/libflat.so* | ||
2 | Priority: optional | ||
3 | Section: opie/decorations | ||
4 | Maintainer: Robert Griebl <sandman@handhelds.org> | ||
5 | Architecture: arm | ||
6 | Version: $QPE_VERSION-$SUB_VERSION.1 | ||
7 | Depends: opie-base ($QPE_VERSION) | ||
8 | Description: OPIE window decoration style | ||
9 | Flat window decoration style for OPIE. | ||
diff --git a/noncore/decorations/liquid/liquid.cpp b/noncore/decorations/liquid/liquid.cpp new file mode 100644 index 0000000..75b1fc9 --- a/dev/null +++ b/noncore/decorations/liquid/liquid.cpp | |||
@@ -0,0 +1,136 @@ | |||
1 | #include "liquid.h" | ||
2 | |||
3 | #include <qapplication.h> | ||
4 | #include <qpainter.h> | ||
5 | #include <qpalette.h> | ||
6 | #include <qdrawutil.h> | ||
7 | |||
8 | |||
9 | LiquidDecoInterface::LiquidDecoInterface ( ) : ref ( 0 ) | ||
10 | { | ||
11 | } | ||
12 | |||
13 | LiquidDecoInterface::~LiquidDecoInterface ( ) | ||
14 | { | ||
15 | } | ||
16 | |||
17 | |||
18 | |||
19 | QString LiquidDecoInterface::name ( ) const | ||
20 | { | ||
21 | return qApp-> translate ( "Decoration", "Liquid" ); | ||
22 | } | ||
23 | |||
24 | |||
25 | QPixmap LiquidDecoInterface::icon ( ) const | ||
26 | { | ||
27 | return QPixmap ( ); | ||
28 | } | ||
29 | |||
30 | void LiquidDecoInterface::drawArea( Area a, QPainter *p, const WindowData *wd ) const | ||
31 | { | ||
32 | QRect r = wd-> rect; | ||
33 | int th = metric ( TitleHeight, wd ); | ||
34 | |||
35 | switch ( a ) { | ||
36 | case WindowDecorationInterface::Border: { | ||
37 | const QColorGroup &cg = wd-> palette. active ( ); | ||
38 | qDrawWinPanel ( p, r. x ( ) - metric ( LeftBorder, wd ), | ||
39 | r. y ( ) - th - metric ( TopBorder, wd ), | ||
40 | r. width ( ) + metric ( LeftBorder, wd ) + metric ( RightBorder, wd ), | ||
41 | r. height ( ) + th + metric ( TopBorder,wd) + metric ( BottomBorder, wd ), | ||
42 | cg, false, &cg. brush ( QColorGroup::Background )); | ||
43 | break; | ||
44 | } | ||
45 | case WindowDecorationInterface::Title: { | ||
46 | const QColorGroup &cg = wd-> palette. active ( ); | ||
47 | |||
48 | QBrush titleBrush; | ||
49 | QPen titleLines1, titleLines2; | ||
50 | |||
51 | titleBrush = cg. brush (( wd-> flags & WindowData::Active ) ? QColorGroup::Highlight : QColorGroup::Background ); | ||
52 | titleLines1 = titleBrush. color ( ). dark ( 105 ); | ||
53 | titleLines2 = titleBrush. color ( ). dark ( 103 ); | ||
54 | |||
55 | p-> fillRect ( r. x ( ), r. y ( ) - th, r. width ( ), th, titleBrush ); | ||
56 | for ( int i = r.y()-th; i < r.y(); i += 4 ) { | ||
57 | p-> setPen ( titleLines1 ); | ||
58 | p-> drawLine ( r. left ( ), i, r. right ( ), i ); | ||
59 | p-> setPen ( titleLines2 ); | ||
60 | p-> drawLine ( r. left ( ), i+1, r. right ( ), i+1 ); | ||
61 | } | ||
62 | break; | ||
63 | } | ||
64 | case WindowDecorationInterface::TitleText: { | ||
65 | QColor textcol = wd-> palette. active ( ). color (( wd-> flags & WindowData::Active ) ? QColorGroup::HighlightedText : QColorGroup::Text ); | ||
66 | QColor shadecol = ( qGray ( textcol. rgb ( ) ) > 128 ) ? textcol. dark ( 230 ) : textcol.light( 300 ); | ||
67 | if ( textcol == shadecol ) { | ||
68 | if ( qGray ( shadecol. rgb ( ) ) < 128 ) | ||
69 | shadecol = QColor ( 225, 225, 225 ); | ||
70 | else | ||
71 | shadecol = QColor ( 30, 30, 30 ); | ||
72 | } | ||
73 | QColor fillcol = wd-> palette. active ( ). color (( wd-> flags & WindowData::Active ) ? QColorGroup::Highlight : QColorGroup::Background ); | ||
74 | QColor bordercol = fillcol. dark ( 110 ); | ||
75 | fillcol = fillcol. light ( 110 ); | ||
76 | |||
77 | QRect tr ( r.x ( ) + 3 + metric ( HelpWidth, wd ), r. top ( ) - th, | ||
78 | r. width ( ) - metric ( OKWidth, wd ) - metric ( CloseWidth, wd ), th ); | ||
79 | |||
80 | QFont f = p-> font ( ); | ||
81 | f. setWeight ( QFont::Bold ); | ||
82 | p-> setFont ( f ); | ||
83 | |||
84 | QRect br = p-> boundingRect ( tr, QPainter::AlignCenter, wd-> caption ); | ||
85 | int trh2 = tr. height ( ) / 2; | ||
86 | |||
87 | int align = QPainter::AlignCenter; | ||
88 | |||
89 | if ( br. width ( ) + 2 * trh2 > tr. width ( ) ) { | ||
90 | br. setLeft ( tr. left ( ) + trh2 ); | ||
91 | br. setWidth ( tr. width ( ) - 2 * trh2 ); | ||
92 | |||
93 | align = QPainter::AlignLeft | QPainter::AlignVCenter; | ||
94 | } | ||
95 | |||
96 | p-> setBrush ( fillcol ); | ||
97 | p-> setPen ( bordercol /*Qt::NoPen*/ ); | ||
98 | p->drawChord ( br. left ( ) - trh2, tr. top ( ), 2 * trh2, tr. height ( ), 90*16, 180*16 ); | ||
99 | p->drawChord ( br. right ( ) + 1 - trh2, tr. top ( ), 2 * trh2, tr. height ( ), 90*16, -180*16 ); | ||
100 | |||
101 | p-> fillRect ( br.left() - 1, tr. top ( ), br. width ( ) + 2, tr. height ( ), fillcol); | ||
102 | |||
103 | p-> setPen ( shadecol ); | ||
104 | p-> drawText ( br, align, wd-> caption ); | ||
105 | p-> setPen ( textcol ); | ||
106 | br. moveBy ( -1, -1 ); | ||
107 | p-> drawText ( br, align, wd-> caption ); | ||
108 | break; | ||
109 | } | ||
110 | default: { | ||
111 | WindowDecorationInterface::drawArea ( a, p, wd ); | ||
112 | break; | ||
113 | } | ||
114 | } | ||
115 | } | ||
116 | |||
117 | QRESULT LiquidDecoInterface::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) | ||
118 | { | ||
119 | *iface = 0; | ||
120 | |||
121 | if ( uuid == IID_QUnknown ) | ||
122 | *iface = this; | ||
123 | else if ( uuid == IID_WindowDecoration ) | ||
124 | *iface = this; | ||
125 | |||
126 | if ( *iface ) | ||
127 | (*iface)-> addRef ( ); | ||
128 | |||
129 | return QS_OK; | ||
130 | } | ||
131 | |||
132 | Q_EXPORT_INTERFACE() | ||
133 | { | ||
134 | Q_CREATE_INSTANCE( LiquidDecoInterface ) | ||
135 | } | ||
136 | |||
diff --git a/noncore/decorations/liquid/liquid.h b/noncore/decorations/liquid/liquid.h new file mode 100644 index 0000000..ec55132 --- a/dev/null +++ b/noncore/decorations/liquid/liquid.h | |||
@@ -0,0 +1,25 @@ | |||
1 | #ifndef __OPIE_LIQUIDDECO_PLUGIN_H__ | ||
2 | #define __OPIE_LIQUIDDECO_PLUGIN_H__ | ||
3 | |||
4 | #include <qpe/windowdecorationinterface.h> | ||
5 | |||
6 | class LiquidSettings; | ||
7 | |||
8 | class LiquidDecoInterface : public WindowDecorationInterface { | ||
9 | public: | ||
10 | LiquidDecoInterface ( ); | ||
11 | virtual ~LiquidDecoInterface ( ); | ||
12 | |||
13 | QRESULT queryInterface ( const QUuid &, QUnknownInterface ** ); | ||
14 | Q_REFCOUNT | ||
15 | |||
16 | virtual void drawArea( Area a, QPainter *, const WindowData * ) const; | ||
17 | |||
18 | virtual QString name ( ) const; | ||
19 | virtual QPixmap icon ( ) const; | ||
20 | |||
21 | private: | ||
22 | ulong ref; | ||
23 | }; | ||
24 | |||
25 | #endif | ||
diff --git a/noncore/decorations/liquid/liquid.pro b/noncore/decorations/liquid/liquid.pro new file mode 100644 index 0000000..25b4fd3 --- a/dev/null +++ b/noncore/decorations/liquid/liquid.pro | |||
@@ -0,0 +1,10 @@ | |||
1 | TEMPLATE = lib | ||
2 | CONFIG = qt embedded release warn_on | ||
3 | SOURCES = liquid.cpp | ||
4 | HEADERS = liquid.h | ||
5 | LIBS += -lqpe | ||
6 | INCLUDEPATH += $(OPIEDIR)/include | ||
7 | DESTDIR = $(OPIEDIR)/plugins/decorations | ||
8 | TARGET = liquid | ||
9 | VERSION = 1.0.0 | ||
10 | |||
diff --git a/noncore/decorations/liquid/opie-deco-liquid.control b/noncore/decorations/liquid/opie-deco-liquid.control new file mode 100644 index 0000000..7d56914 --- a/dev/null +++ b/noncore/decorations/liquid/opie-deco-liquid.control | |||
@@ -0,0 +1,9 @@ | |||
1 | Files: plugins/decorations/libliquid.so* | ||
2 | Priority: optional | ||
3 | Section: opie/decorations | ||
4 | Maintainer: Robert Griebl <sandman@handhelds.org> | ||
5 | Architecture: arm | ||
6 | Version: $QPE_VERSION-$SUB_VERSION.1 | ||
7 | Depends: opie-base ($QPE_VERSION) | ||
8 | Description: OPIE window decoration style | ||
9 | Liquid (KDE3) window decoration style for OPIE. | ||
diff --git a/noncore/decorations/polished/opie-deco-polished.control b/noncore/decorations/polished/opie-deco-polished.control new file mode 100644 index 0000000..b6428c4 --- a/dev/null +++ b/noncore/decorations/polished/opie-deco-polished.control | |||
@@ -0,0 +1,9 @@ | |||
1 | Files: plugins/decorations/libpolished.so* | ||
2 | Priority: optional | ||
3 | Section: opie/decorations | ||
4 | Maintainer: Robert Griebl <sandman@handhelds.org> | ||
5 | Architecture: arm | ||
6 | Version: $QPE_VERSION-$SUB_VERSION.1 | ||
7 | Depends: opie-base ($QPE_VERSION) | ||
8 | Description: OPIE window decoration style | ||
9 | Blended window decoration style for OPIE. | ||
diff --git a/noncore/decorations/polished/polished.cpp b/noncore/decorations/polished/polished.cpp new file mode 100644 index 0000000..30f1a84 --- a/dev/null +++ b/noncore/decorations/polished/polished.cpp | |||
@@ -0,0 +1,171 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of the Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #include "polished.h" | ||
22 | #include <qpainter.h> | ||
23 | #include <qapplication.h> | ||
24 | |||
25 | PolishedDecoration::PolishedDecoration() : ref(0) | ||
26 | { | ||
27 | } | ||
28 | |||
29 | PolishedDecoration::~PolishedDecoration() | ||
30 | { | ||
31 | } | ||
32 | |||
33 | int PolishedDecoration::metric( Metric m, const WindowData *wd ) const | ||
34 | { | ||
35 | switch ( m ) { | ||
36 | case TopBorder: | ||
37 | return 1; | ||
38 | break; | ||
39 | case LeftBorder: | ||
40 | case RightBorder: | ||
41 | return 2; | ||
42 | case BottomBorder: | ||
43 | return 6; | ||
44 | case TitleHeight: | ||
45 | if ( QApplication::desktop()->height() > 320 ) | ||
46 | return 20; | ||
47 | else | ||
48 | return 18; | ||
49 | default: | ||
50 | return WindowDecorationInterface::metric( m, wd ); | ||
51 | break; | ||
52 | } | ||
53 | |||
54 | return 0; | ||
55 | } | ||
56 | |||
57 | void PolishedDecoration::drawArea( Area a, QPainter *p, const WindowData *wd ) const | ||
58 | { | ||
59 | int th = metric( TitleHeight, wd ); | ||
60 | QRect r = wd->rect; | ||
61 | |||
62 | switch ( a ) { | ||
63 | case Border: | ||
64 | { | ||
65 | const QColorGroup &cg = wd->palette.active(); | ||
66 | QColor c; | ||
67 | if ( wd->flags & WindowData::Active ) { | ||
68 | c = cg.color(QColorGroup::Highlight); | ||
69 | } else { | ||
70 | c = cg.color(QColorGroup::Background); | ||
71 | } | ||
72 | drawBlend( p, QRect(r.x(),r.bottom()+1,r.width(),metric(BottomBorder,wd)), c.dark(180), c.light() ); | ||
73 | int lb = metric(LeftBorder,wd); | ||
74 | int rb = metric(RightBorder,wd); | ||
75 | int tb = metric(TopBorder,wd); | ||
76 | int bb = metric(BottomBorder,wd); | ||
77 | p->fillRect( r.x()-lb, r.y()-th-tb, lb, | ||
78 | r.height()+th+tb+bb, c.dark(180) ); | ||
79 | p->fillRect( r.right()+1, r.y()-th-tb, rb, | ||
80 | r.height()+th+tb+bb, c.dark(180) ); | ||
81 | p->fillRect( r.left(), r.y()-th-tb, r.width(), | ||
82 | tb, c.dark(180) ); | ||
83 | } | ||
84 | break; | ||
85 | case Title: | ||
86 | if ( r.height() < 2 ) { | ||
87 | WindowDecorationInterface::drawArea( a, p, wd ); | ||
88 | } else { | ||
89 | const QColorGroup &cg = wd->palette.active(); | ||
90 | QColor c1, c2; | ||
91 | if ( wd->flags & WindowData::Active ) { | ||
92 | c1 = cg.color(QColorGroup::Highlight).light(); | ||
93 | c2 = cg.color(QColorGroup::Highlight).dark(180); | ||
94 | } else { | ||
95 | c1 = cg.color(QColorGroup::Background); | ||
96 | c2 = cg.color(QColorGroup::Background).dark(180); | ||
97 | } | ||
98 | drawBlend( p, QRect(r.x(),r.y()-th,r.width(),th), c2, c1 ); | ||
99 | } | ||
100 | break; | ||
101 | case TitleText: | ||
102 | p->drawText( r.left()+5+metric(HelpWidth,wd), r.top()-th, r.width(), th, | ||
103 | Qt::AlignVCenter, wd->caption ); | ||
104 | break; | ||
105 | default: | ||
106 | PolishedDecoration::drawArea( a, p, wd ); | ||
107 | break; | ||
108 | } | ||
109 | } | ||
110 | |||
111 | void PolishedDecoration::drawButton( Button b, QPainter *p, const WindowData *wd, int x, int y, int w, int h, QWSButton::State state ) const | ||
112 | { | ||
113 | WindowDecorationInterface::drawButton( b, p, wd, x, y, w, h, state ); | ||
114 | } | ||
115 | |||
116 | QRegion PolishedDecoration::mask( const WindowData *wd ) const | ||
117 | { | ||
118 | return WindowDecorationInterface::mask( wd ); | ||
119 | } | ||
120 | |||
121 | QString PolishedDecoration::name() const | ||
122 | { | ||
123 | return qApp->translate( "Decoration", "Polished" ); | ||
124 | } | ||
125 | |||
126 | QPixmap PolishedDecoration::icon() const | ||
127 | { | ||
128 | return QPixmap(); | ||
129 | } | ||
130 | |||
131 | void PolishedDecoration::drawBlend( QPainter *p, const QRect &r, const QColor &c1, const QColor &c2 ) const | ||
132 | { | ||
133 | int h1, h2, s1, s2, v1, v2; | ||
134 | c1.hsv( &h1, &s1, &v1 ); | ||
135 | c2.hsv( &h2, &s2, &v2 ); | ||
136 | |||
137 | int split = r.height()/3; | ||
138 | |||
139 | for ( int j = 0; j < split; j++ ) { | ||
140 | p->setPen( QColor( h1 + ((h2-h1)*(j+split))/(2*split-1), | ||
141 | s1 + ((s2-s1)*(j+split))/(2*split-1), | ||
142 | v1 + ((v2-v1)*(j+split))/(2*split-1), QColor::Hsv ) ); | ||
143 | p->drawLine( r.x(), r.y()+j, r.right(), r.y()+j ); | ||
144 | } | ||
145 | |||
146 | for ( int j = 0; j < r.height()-split; j++ ) { | ||
147 | p->setPen( QColor( h1 + ((h2-h1)*j)/(r.height()-split-1), | ||
148 | s1 + ((s2-s1)*j)/(r.height()-split-1), | ||
149 | v1 + ((v2-v1)*j)/(r.height()-split-1), QColor::Hsv ) ); | ||
150 | p->drawLine( r.x(), r.bottom()-j, r.right(), r.bottom()-j ); | ||
151 | } | ||
152 | } | ||
153 | |||
154 | QRESULT PolishedDecoration::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | ||
155 | { | ||
156 | *iface = 0; | ||
157 | if ( uuid == IID_QUnknown ) | ||
158 | *iface = this; | ||
159 | else if ( uuid == IID_WindowDecoration ) | ||
160 | *iface = this; | ||
161 | |||
162 | if ( *iface ) | ||
163 | (*iface)->addRef(); | ||
164 | return QS_OK; | ||
165 | } | ||
166 | |||
167 | Q_EXPORT_INTERFACE() | ||
168 | { | ||
169 | Q_CREATE_INSTANCE( PolishedDecoration ) | ||
170 | } | ||
171 | |||
diff --git a/noncore/decorations/polished/polished.h b/noncore/decorations/polished/polished.h new file mode 100644 index 0000000..e5c19c0 --- a/dev/null +++ b/noncore/decorations/polished/polished.h | |||
@@ -0,0 +1,49 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of the Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #ifndef POLISHED_H | ||
22 | #define POLISHED_H | ||
23 | |||
24 | #include <qtopia/windowdecorationinterface.h> | ||
25 | |||
26 | class PolishedDecoration : public WindowDecorationInterface | ||
27 | { | ||
28 | public: | ||
29 | PolishedDecoration(); | ||
30 | virtual ~PolishedDecoration(); | ||
31 | |||
32 | virtual int metric( Metric m, const WindowData * ) const; | ||
33 | virtual void drawArea( Area a, QPainter *, const WindowData * ) const; | ||
34 | virtual void drawButton( Button b, QPainter *, const WindowData *, int x, int y, int w, int h, QWSButton::State ) const; | ||
35 | virtual QRegion mask( const WindowData * ) const; | ||
36 | virtual QString name() const; | ||
37 | virtual QPixmap icon() const; | ||
38 | |||
39 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | ||
40 | Q_REFCOUNT | ||
41 | |||
42 | protected: | ||
43 | void PolishedDecoration::drawBlend( QPainter *, const QRect &r, const QColor &c1, const QColor&c2 ) const; | ||
44 | |||
45 | private: | ||
46 | ulong ref; | ||
47 | }; | ||
48 | |||
49 | #endif | ||
diff --git a/noncore/decorations/polished/polished.pro b/noncore/decorations/polished/polished.pro new file mode 100644 index 0000000..43113ef --- a/dev/null +++ b/noncore/decorations/polished/polished.pro | |||
@@ -0,0 +1,11 @@ | |||
1 | TEMPLATE= lib | ||
2 | CONFIG += qt warn_on release | ||
3 | HEADERS = polished.h | ||
4 | SOURCES = polished.cpp | ||
5 | TARGET = polished | ||
6 | DESTDIR = $(OPIEDIR)/plugins/decorations | ||
7 | INCLUDEPATH+= $(OPIEDIR)/include | ||
8 | DEPENDPATH += $(OPIEDIR)/include | ||
9 | LIBS += -lqpe | ||
10 | VERSION = 1.0.0 | ||
11 | |||