summaryrefslogtreecommitdiff
path: root/noncore/decorations/polished
authorsandman <sandman>2002-10-04 00:46:45 (UTC)
committer sandman <sandman>2002-10-04 00:46:45 (UTC)
commit7f1029811faae4aa88c0c35157a33b95abffaae8 (patch) (unidiff)
tree3cab1efdd4a88ae832dd29a424b1c9d884679ef4 /noncore/decorations/polished
parent4131d24ac051733b2d9ba323b18e6602ae396b85 (diff)
downloadopie-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
Diffstat (limited to 'noncore/decorations/polished') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/decorations/polished/opie-deco-polished.control9
-rw-r--r--noncore/decorations/polished/polished.cpp171
-rw-r--r--noncore/decorations/polished/polished.h49
-rw-r--r--noncore/decorations/polished/polished.pro11
4 files changed, 240 insertions, 0 deletions
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 @@
1Files: plugins/decorations/libpolished.so*
2Priority: optional
3Section: opie/decorations
4Maintainer: Robert Griebl <sandman@handhelds.org>
5Architecture: arm
6Version: $QPE_VERSION-$SUB_VERSION.1
7Depends: opie-base ($QPE_VERSION)
8Description: 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
25PolishedDecoration::PolishedDecoration() : ref(0)
26{
27}
28
29PolishedDecoration::~PolishedDecoration()
30{
31}
32
33int 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
57void 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
111void 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
116QRegion PolishedDecoration::mask( const WindowData *wd ) const
117{
118 return WindowDecorationInterface::mask( wd );
119}
120
121QString PolishedDecoration::name() const
122{
123 return qApp->translate( "Decoration", "Polished" );
124}
125
126QPixmap PolishedDecoration::icon() const
127{
128 return QPixmap();
129}
130
131void 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
154QRESULT 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
167Q_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
26class PolishedDecoration : public WindowDecorationInterface
27{
28public:
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
42protected:
43 void PolishedDecoration::drawBlend( QPainter *, const QRect &r, const QColor &c1, const QColor&c2 ) const;
44
45private:
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
8DEPENDPATH += $(OPIEDIR)/include
9LIBS += -lqpe
10 VERSION = 1.0.0
11