summaryrefslogtreecommitdiff
authorsandman <sandman>2002-10-04 00:46:45 (UTC)
committer sandman <sandman>2002-10-04 00:46:45 (UTC)
commit7f1029811faae4aa88c0c35157a33b95abffaae8 (patch) (side-by-side diff)
tree3cab1efdd4a88ae832dd29a424b1c9d884679ef4
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 (more/less context) (show whitespace changes)
-rw-r--r--noncore/decorations/flat/flat.cpp360
-rw-r--r--noncore/decorations/flat/flat.h49
-rw-r--r--noncore/decorations/flat/flat.pro11
-rw-r--r--noncore/decorations/flat/opie-deco-flat.control9
-rw-r--r--noncore/decorations/liquid/liquid.cpp136
-rw-r--r--noncore/decorations/liquid/liquid.h25
-rw-r--r--noncore/decorations/liquid/liquid.pro10
-rw-r--r--noncore/decorations/liquid/opie-deco-liquid.control9
-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
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 @@
+/**********************************************************************
+** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
+**
+** This file is part of the Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include "flat.h"
+#include <qpainter.h>
+#include <qapplication.h>
+
+
+/* XPM */
+static const char * ok_xpm[] = {
+"32 32 3 1",
+" c None",
+". c #000000",
+"+ c #FFFFFF",
+" ",
+" ",
+" ++++++++ ",
+" ++++++++++++ ",
+" +++++ +++++ ",
+" +++ +++ ",
+" +++ +++ ",
+" +++ +++ ",
+" +++ +++ ",
+" ++ ++ ",
+" ++ +++++ ++ ++ ++ ",
+" ++ ++++++++ ++ +++ ++ ",
+" +++ +++ +++ ++ +++ +++ ",
+" ++ +++ ++ ++ +++ ++ ",
+" ++ ++ ++ ++ ++ ++ ",
+" ++ ++ ++ +++++ ++ ",
+" ++ ++ ++ ++++ ++ ",
+" ++ ++ ++ ++ ++ ++ ",
+" ++ +++ ++ ++ +++ ++ ",
+" +++ +++ +++ ++ +++ +++ ",
+" ++ ++++++++ ++ ++ ++ ",
+" ++ +++++ ++ ++ ++ ",
+" ++ ++ ",
+" +++ +++ ",
+" +++ +++ ",
+" +++ +++ ",
+" +++ +++ ",
+" +++++ +++++ ",
+" ++++++++++++ ",
+" ++++++++ ",
+" ",
+" "};
+
+
+/* XPM */
+static const char * close_xpm[] = {
+"32 32 3 1",
+" c None",
+". c #000000",
+"+ c #FFFFFF",
+" ",
+" ",
+" ++++++++ ",
+" ++++++++++++ ",
+" +++++ +++++ ",
+" +++ +++ ",
+" +++ +++ ",
+" +++ +++ ",
+" +++ +++ ",
+" ++ ++ ++ ++ ",
+" ++ +++ +++ ++ ",
+" ++ +++ +++ ++ ",
+" +++ +++ +++ +++ ",
+" ++ +++ +++ ++ ",
+" ++ ++++++ ++ ",
+" ++ ++++ ++ ",
+" ++ ++++ ++ ",
+" ++ ++++++ ++ ",
+" ++ +++ +++ ++ ",
+" +++ +++ +++ +++ ",
+" ++ +++ +++ ++ ",
+" ++ +++ +++ ++ ",
+" ++ ++ ++ ++ ",
+" +++ +++ ",
+" +++ +++ ",
+" +++ +++ ",
+" +++ +++ ",
+" +++++ +++++ ",
+" ++++++++++++ ",
+" ++++++++ ",
+" ",
+" "};
+
+
+/* XPM */
+static const char * help_xpm[] = {
+"32 32 3 1",
+" c None",
+". c #000000",
+"+ c #FFFFFF",
+" ",
+" ",
+" ++++++++ ",
+" ++++++++++++ ",
+" +++++ +++++ ",
+" +++ +++ ",
+" +++ +++ ",
+" +++ +++ ",
+" +++ +++++ +++ ",
+" ++ ++++++++ ++ ",
+" ++ ++++ ++++ ++ ",
+" ++ +++ +++ ++ ",
+" +++ +++ +++ +++ ",
+" ++ ++++ ++ ",
+" ++ +++++ ++ ",
+" ++ +++++ ++ ",
+" ++ ++++ ++ ",
+" ++ ++++ ++ ",
+" ++ +++ ++ ",
+" +++ +++ +++ ",
+" ++ ++ ",
+" ++ ++ ",
+" ++ +++ ++ ",
+" +++ +++ +++ ",
+" +++ +++ ",
+" +++ +++ ",
+" +++ +++ ",
+" +++++ +++++ ",
+" ++++++++++++ ",
+" ++++++++ ",
+" ",
+" "};
+
+
+/* XPM */
+static const char * maximize_xpm[] = {
+"32 32 3 1",
+" c None",
+". c #000000",
+"+ c #FFFFFF",
+" ",
+" ",
+" ++++++++ ",
+" ++++++++++++ ",
+" +++++ +++++ ",
+" +++ +++ ",
+" +++ +++ ",
+" +++ +++ ",
+" +++ ++++++++++++++ +++ ",
+" ++ ++++++++++++++ ++ ",
+" ++ ++++++++++++++ ++ ",
+" ++ +++ +++ ++ ",
+" +++ +++ +++ +++ ",
+" ++ +++ +++ ++ ",
+" ++ +++ +++ ++ ",
+" ++ +++ +++ ++ ",
+" ++ +++ +++ ++ ",
+" ++ +++ +++ ++ ",
+" ++ +++ +++ ++ ",
+" +++ +++ +++ +++ ",
+" ++ +++ +++ ++ ",
+" ++ ++++++++++++++ ++ ",
+" ++ ++++++++++++++ ++ ",
+" +++ ++++++++++++++ +++ ",
+" +++ +++ ",
+" +++ +++ ",
+" +++ +++ ",
+" +++++ +++++ ",
+" ++++++++++++ ",
+" ++++++++ ",
+" ",
+" "};
+
+static QImage scaleButton( const QImage &img, int height )
+{
+ if ( img.height() != height ) {
+ return img.smoothScale( img.width()*height/img.height(), height );
+ } else {
+ return img;
+ }
+}
+
+static void colorize( QImage &img, const QColor &c, bool rev )
+{
+ for ( int i = 0; i < img.numColors(); i++ ) {
+ bool sc = (img.color(i) & 0xff000000);
+ if ( rev ) sc = !sc;
+ img.setColor(i, sc ? c.rgb() : 0x00000000 );
+ }
+}
+
+FlatDecoration::FlatDecoration() : ref(0), buttonCache(16)
+{
+ buttonCache.setAutoDelete(TRUE);
+}
+
+FlatDecoration::~FlatDecoration()
+{
+}
+
+int FlatDecoration::metric( Metric m, const WindowData *wd ) const
+{
+ switch ( m ) {
+ case TopBorder:
+ return 1;
+ break;
+ case LeftBorder:
+ case RightBorder:
+ return 2;
+ case BottomBorder:
+ return 4;
+ case TitleHeight:
+ if ( QApplication::desktop()->height() > 320 )
+ return 20;
+ else
+ return 18;
+ case OKWidth:
+ case CloseWidth:
+ case HelpWidth:
+ case MaximizeWidth:
+ return metric(TitleHeight,wd);
+ break;
+ default:
+ return WindowDecorationInterface::metric( m, wd );
+ break;
+ }
+
+ return 0;
+}
+
+void FlatDecoration::drawArea( Area a, QPainter *p, const WindowData *wd ) const
+{
+ int th = metric( TitleHeight, wd );
+ QRect r = wd->rect;
+
+ switch ( a ) {
+ case Border:
+ {
+ const QColorGroup &cg = wd->palette.active();
+ if ( wd->flags & WindowData::Active ) {
+ p->setBrush( cg.color(QColorGroup::Highlight) );
+ } else {
+ p->setBrush( cg.color(QColorGroup::Background) );
+ }
+ p->setPen( cg.foreground() );
+ int lb = metric(LeftBorder,wd);
+ int rb = metric(RightBorder,wd);
+ int tb = metric(TopBorder,wd);
+ int bb = metric(BottomBorder,wd);
+ p->drawRect( r.x()-lb, r.y()-tb-th, r.width()+lb+rb,
+ r.height()+th+tb+bb );
+ }
+ break;
+ case Title:
+ if ( r.height() < 2 ) {
+ WindowDecorationInterface::drawArea( a, p, wd );
+ } else {
+ const QColorGroup &cg = wd->palette.active();
+ QColor c;
+ if ( wd->flags & WindowData::Active )
+ c = cg.color(QColorGroup::Highlight);
+ else
+ c = cg.color(QColorGroup::Background);
+ p->fillRect( QRect(r.x(),r.y()-th,r.width(),th), c );
+ }
+ break;
+ case TitleText:
+ p->drawText( r.left()+3+metric(HelpWidth,wd), r.top()-th,
+ r.width()-metric(HelpWidth,wd)-metric(CloseWidth,wd), th,
+ Qt::AlignVCenter, wd->caption );
+ break;
+ default:
+ FlatDecoration::drawArea( a, p, wd );
+ break;
+ }
+}
+
+void FlatDecoration::drawButton( Button b, QPainter *p, const WindowData *wd, int x, int y, int w, int h, QWSButton::State state ) const
+{
+ QColor c;
+ const QColorGroup &cg = wd->palette.active();
+ if ( wd->flags & WindowDecorationInterface::WindowData::Active )
+ c = cg.color(QColorGroup::HighlightedText);
+ else
+ c = cg.color(QColorGroup::Foreground);
+ bool r = (state & QWSButton::MouseOver) && (state & QWSButton::Clicked);
+ int th = metric(TitleHeight, wd);
+
+ QString key( "%1-%2-%3-%4" );
+ key = key.arg(b).arg(th).arg(c.name()).arg(r ? "1" : "0");
+ QImage *img = buttonCache.find( key );
+ if ( !img ) {
+ QImage tmp;
+ switch ( b ) {
+ case OK:
+ tmp = QImage( ok_xpm );
+ break;
+ case Close:
+ tmp = QImage( close_xpm );
+ break;
+ case Help:
+ tmp = QImage( help_xpm );
+ break;
+ case Maximize:
+ tmp = QImage( maximize_xpm );
+ break;
+ }
+ colorize( tmp, c, r );
+ img = new QImage( scaleButton(tmp,th) );
+ FlatDecoration *that = (FlatDecoration *)this;
+ that->buttonCache.insert( key, img, 1 );
+ }
+
+ p->drawImage( x, y, *img );
+}
+
+QRegion FlatDecoration::mask( const WindowData *wd ) const
+{
+ return WindowDecorationInterface::mask( wd );
+}
+
+QString FlatDecoration::name() const
+{
+ return qApp->translate( "Decoration", "Flat" );
+}
+
+QPixmap FlatDecoration::icon() const
+{
+ return QPixmap();
+}
+
+QRESULT FlatDecoration::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
+{
+ *iface = 0;
+ if ( uuid == IID_QUnknown )
+ *iface = this;
+ else if ( uuid == IID_WindowDecoration )
+ *iface = this;
+
+ if ( *iface )
+ (*iface)->addRef();
+ return QS_OK;
+}
+
+Q_EXPORT_INTERFACE()
+{
+ Q_CREATE_INSTANCE( FlatDecoration )
+}
+
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 @@
+/**********************************************************************
+** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
+**
+** This file is part of the Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#ifndef FLAT_H
+#define FLAT_H
+
+#include <qtopia/windowdecorationinterface.h>
+#include <qcache.h>
+#include <qimage.h>
+
+class FlatDecoration : public WindowDecorationInterface
+{
+public:
+ FlatDecoration();
+ virtual ~FlatDecoration();
+
+ virtual int metric( Metric m, const WindowData * ) const;
+ virtual void drawArea( Area a, QPainter *, const WindowData * ) const;
+ virtual void drawButton( Button b, QPainter *, const WindowData *, int x, int y, int w, int h, QWSButton::State ) const;
+ virtual QRegion mask( const WindowData * ) const;
+ virtual QString name() const;
+ virtual QPixmap icon() const;
+
+ QRESULT queryInterface( const QUuid&, QUnknownInterface** );
+ Q_REFCOUNT
+
+private:
+ ulong ref;
+ QCache<QImage> buttonCache;
+};
+
+#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 @@
+TEMPLATE = lib
+CONFIG += qt warn_on release
+HEADERS = flat.h
+SOURCES = flat.cpp
+TARGET = flat
+DESTDIR = $(OPIEDIR)/plugins/decorations
+INCLUDEPATH += $(OPIEDIR)/include
+DEPENDPATH += $(OPIEDIR)/include
+LIBS += -lqpe
+VERSION = 1.0.0
+
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 @@
+Files: plugins/decorations/libflat.so*
+Priority: optional
+Section: opie/decorations
+Maintainer: Robert Griebl <sandman@handhelds.org>
+Architecture: arm
+Version: $QPE_VERSION-$SUB_VERSION.1
+Depends: opie-base ($QPE_VERSION)
+Description: OPIE window decoration style
+ 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 @@
+#include "liquid.h"
+
+#include <qapplication.h>
+#include <qpainter.h>
+#include <qpalette.h>
+#include <qdrawutil.h>
+
+
+LiquidDecoInterface::LiquidDecoInterface ( ) : ref ( 0 )
+{
+}
+
+LiquidDecoInterface::~LiquidDecoInterface ( )
+{
+}
+
+
+
+QString LiquidDecoInterface::name ( ) const
+{
+ return qApp-> translate ( "Decoration", "Liquid" );
+}
+
+
+QPixmap LiquidDecoInterface::icon ( ) const
+{
+ return QPixmap ( );
+}
+
+void LiquidDecoInterface::drawArea( Area a, QPainter *p, const WindowData *wd ) const
+{
+ QRect r = wd-> rect;
+ int th = metric ( TitleHeight, wd );
+
+ switch ( a ) {
+ case WindowDecorationInterface::Border: {
+ const QColorGroup &cg = wd-> palette. active ( );
+ qDrawWinPanel ( p, r. x ( ) - metric ( LeftBorder, wd ),
+ r. y ( ) - th - metric ( TopBorder, wd ),
+ r. width ( ) + metric ( LeftBorder, wd ) + metric ( RightBorder, wd ),
+ r. height ( ) + th + metric ( TopBorder,wd) + metric ( BottomBorder, wd ),
+ cg, false, &cg. brush ( QColorGroup::Background ));
+ break;
+ }
+ case WindowDecorationInterface::Title: {
+ const QColorGroup &cg = wd-> palette. active ( );
+
+ QBrush titleBrush;
+ QPen titleLines1, titleLines2;
+
+ titleBrush = cg. brush (( wd-> flags & WindowData::Active ) ? QColorGroup::Highlight : QColorGroup::Background );
+ titleLines1 = titleBrush. color ( ). dark ( 105 );
+ titleLines2 = titleBrush. color ( ). dark ( 103 );
+
+ p-> fillRect ( r. x ( ), r. y ( ) - th, r. width ( ), th, titleBrush );
+ for ( int i = r.y()-th; i < r.y(); i += 4 ) {
+ p-> setPen ( titleLines1 );
+ p-> drawLine ( r. left ( ), i, r. right ( ), i );
+ p-> setPen ( titleLines2 );
+ p-> drawLine ( r. left ( ), i+1, r. right ( ), i+1 );
+ }
+ break;
+ }
+ case WindowDecorationInterface::TitleText: {
+ QColor textcol = wd-> palette. active ( ). color (( wd-> flags & WindowData::Active ) ? QColorGroup::HighlightedText : QColorGroup::Text );
+ QColor shadecol = ( qGray ( textcol. rgb ( ) ) > 128 ) ? textcol. dark ( 230 ) : textcol.light( 300 );
+ if ( textcol == shadecol ) {
+ if ( qGray ( shadecol. rgb ( ) ) < 128 )
+ shadecol = QColor ( 225, 225, 225 );
+ else
+ shadecol = QColor ( 30, 30, 30 );
+ }
+ QColor fillcol = wd-> palette. active ( ). color (( wd-> flags & WindowData::Active ) ? QColorGroup::Highlight : QColorGroup::Background );
+ QColor bordercol = fillcol. dark ( 110 );
+ fillcol = fillcol. light ( 110 );
+
+ QRect tr ( r.x ( ) + 3 + metric ( HelpWidth, wd ), r. top ( ) - th,
+ r. width ( ) - metric ( OKWidth, wd ) - metric ( CloseWidth, wd ), th );
+
+ QFont f = p-> font ( );
+ f. setWeight ( QFont::Bold );
+ p-> setFont ( f );
+
+ QRect br = p-> boundingRect ( tr, QPainter::AlignCenter, wd-> caption );
+ int trh2 = tr. height ( ) / 2;
+
+ int align = QPainter::AlignCenter;
+
+ if ( br. width ( ) + 2 * trh2 > tr. width ( ) ) {
+ br. setLeft ( tr. left ( ) + trh2 );
+ br. setWidth ( tr. width ( ) - 2 * trh2 );
+
+ align = QPainter::AlignLeft | QPainter::AlignVCenter;
+ }
+
+ p-> setBrush ( fillcol );
+ p-> setPen ( bordercol /*Qt::NoPen*/ );
+ p-> drawChord ( br. left ( ) - trh2, tr. top ( ), 2 * trh2, tr. height ( ), 90*16, 180*16 );
+ p-> drawChord ( br. right ( ) + 1 - trh2, tr. top ( ), 2 * trh2, tr. height ( ), 90*16, -180*16 );
+
+ p-> fillRect ( br.left() - 1, tr. top ( ), br. width ( ) + 2, tr. height ( ), fillcol);
+
+ p-> setPen ( shadecol );
+ p-> drawText ( br, align, wd-> caption );
+ p-> setPen ( textcol );
+ br. moveBy ( -1, -1 );
+ p-> drawText ( br, align, wd-> caption );
+ break;
+ }
+ default: {
+ WindowDecorationInterface::drawArea ( a, p, wd );
+ break;
+ }
+ }
+}
+
+QRESULT LiquidDecoInterface::queryInterface ( const QUuid &uuid, QUnknownInterface **iface )
+{
+ *iface = 0;
+
+ if ( uuid == IID_QUnknown )
+ *iface = this;
+ else if ( uuid == IID_WindowDecoration )
+ *iface = this;
+
+ if ( *iface )
+ (*iface)-> addRef ( );
+
+ return QS_OK;
+}
+
+Q_EXPORT_INTERFACE()
+{
+ Q_CREATE_INSTANCE( LiquidDecoInterface )
+}
+
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 @@
+#ifndef __OPIE_LIQUIDDECO_PLUGIN_H__
+#define __OPIE_LIQUIDDECO_PLUGIN_H__
+
+#include <qpe/windowdecorationinterface.h>
+
+class LiquidSettings;
+
+class LiquidDecoInterface : public WindowDecorationInterface {
+public:
+ LiquidDecoInterface ( );
+ virtual ~LiquidDecoInterface ( );
+
+ QRESULT queryInterface ( const QUuid &, QUnknownInterface ** );
+ Q_REFCOUNT
+
+ virtual void drawArea( Area a, QPainter *, const WindowData * ) const;
+
+ virtual QString name ( ) const;
+ virtual QPixmap icon ( ) const;
+
+private:
+ ulong ref;
+};
+
+#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 @@
+TEMPLATE = lib
+CONFIG = qt embedded release warn_on
+SOURCES = liquid.cpp
+HEADERS = liquid.h
+LIBS += -lqpe
+INCLUDEPATH += $(OPIEDIR)/include
+DESTDIR = $(OPIEDIR)/plugins/decorations
+TARGET = liquid
+VERSION = 1.0.0
+
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 @@
+Files: plugins/decorations/libliquid.so*
+Priority: optional
+Section: opie/decorations
+Maintainer: Robert Griebl <sandman@handhelds.org>
+Architecture: arm
+Version: $QPE_VERSION-$SUB_VERSION.1
+Depends: opie-base ($QPE_VERSION)
+Description: OPIE window decoration style
+ 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 @@
+Files: plugins/decorations/libpolished.so*
+Priority: optional
+Section: opie/decorations
+Maintainer: Robert Griebl <sandman@handhelds.org>
+Architecture: arm
+Version: $QPE_VERSION-$SUB_VERSION.1
+Depends: opie-base ($QPE_VERSION)
+Description: OPIE window decoration style
+ 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 @@
+/**********************************************************************
+** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
+**
+** This file is part of the Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include "polished.h"
+#include <qpainter.h>
+#include <qapplication.h>
+
+PolishedDecoration::PolishedDecoration() : ref(0)
+{
+}
+
+PolishedDecoration::~PolishedDecoration()
+{
+}
+
+int PolishedDecoration::metric( Metric m, const WindowData *wd ) const
+{
+ switch ( m ) {
+ case TopBorder:
+ return 1;
+ break;
+ case LeftBorder:
+ case RightBorder:
+ return 2;
+ case BottomBorder:
+ return 6;
+ case TitleHeight:
+ if ( QApplication::desktop()->height() > 320 )
+ return 20;
+ else
+ return 18;
+ default:
+ return WindowDecorationInterface::metric( m, wd );
+ break;
+ }
+
+ return 0;
+}
+
+void PolishedDecoration::drawArea( Area a, QPainter *p, const WindowData *wd ) const
+{
+ int th = metric( TitleHeight, wd );
+ QRect r = wd->rect;
+
+ switch ( a ) {
+ case Border:
+ {
+ const QColorGroup &cg = wd->palette.active();
+ QColor c;
+ if ( wd->flags & WindowData::Active ) {
+ c = cg.color(QColorGroup::Highlight);
+ } else {
+ c = cg.color(QColorGroup::Background);
+ }
+ drawBlend( p, QRect(r.x(),r.bottom()+1,r.width(),metric(BottomBorder,wd)), c.dark(180), c.light() );
+ int lb = metric(LeftBorder,wd);
+ int rb = metric(RightBorder,wd);
+ int tb = metric(TopBorder,wd);
+ int bb = metric(BottomBorder,wd);
+ p->fillRect( r.x()-lb, r.y()-th-tb, lb,
+ r.height()+th+tb+bb, c.dark(180) );
+ p->fillRect( r.right()+1, r.y()-th-tb, rb,
+ r.height()+th+tb+bb, c.dark(180) );
+ p->fillRect( r.left(), r.y()-th-tb, r.width(),
+ tb, c.dark(180) );
+ }
+ break;
+ case Title:
+ if ( r.height() < 2 ) {
+ WindowDecorationInterface::drawArea( a, p, wd );
+ } else {
+ const QColorGroup &cg = wd->palette.active();
+ QColor c1, c2;
+ if ( wd->flags & WindowData::Active ) {
+ c1 = cg.color(QColorGroup::Highlight).light();
+ c2 = cg.color(QColorGroup::Highlight).dark(180);
+ } else {
+ c1 = cg.color(QColorGroup::Background);
+ c2 = cg.color(QColorGroup::Background).dark(180);
+ }
+ drawBlend( p, QRect(r.x(),r.y()-th,r.width(),th), c2, c1 );
+ }
+ break;
+ case TitleText:
+ p->drawText( r.left()+5+metric(HelpWidth,wd), r.top()-th, r.width(), th,
+ Qt::AlignVCenter, wd->caption );
+ break;
+ default:
+ PolishedDecoration::drawArea( a, p, wd );
+ break;
+ }
+}
+
+void PolishedDecoration::drawButton( Button b, QPainter *p, const WindowData *wd, int x, int y, int w, int h, QWSButton::State state ) const
+{
+ WindowDecorationInterface::drawButton( b, p, wd, x, y, w, h, state );
+}
+
+QRegion PolishedDecoration::mask( const WindowData *wd ) const
+{
+ return WindowDecorationInterface::mask( wd );
+}
+
+QString PolishedDecoration::name() const
+{
+ return qApp->translate( "Decoration", "Polished" );
+}
+
+QPixmap PolishedDecoration::icon() const
+{
+ return QPixmap();
+}
+
+void PolishedDecoration::drawBlend( QPainter *p, const QRect &r, const QColor &c1, const QColor &c2 ) const
+{
+ int h1, h2, s1, s2, v1, v2;
+ c1.hsv( &h1, &s1, &v1 );
+ c2.hsv( &h2, &s2, &v2 );
+
+ int split = r.height()/3;
+
+ for ( int j = 0; j < split; j++ ) {
+ p->setPen( QColor( h1 + ((h2-h1)*(j+split))/(2*split-1),
+ s1 + ((s2-s1)*(j+split))/(2*split-1),
+ v1 + ((v2-v1)*(j+split))/(2*split-1), QColor::Hsv ) );
+ p->drawLine( r.x(), r.y()+j, r.right(), r.y()+j );
+ }
+
+ for ( int j = 0; j < r.height()-split; j++ ) {
+ p->setPen( QColor( h1 + ((h2-h1)*j)/(r.height()-split-1),
+ s1 + ((s2-s1)*j)/(r.height()-split-1),
+ v1 + ((v2-v1)*j)/(r.height()-split-1), QColor::Hsv ) );
+ p->drawLine( r.x(), r.bottom()-j, r.right(), r.bottom()-j );
+ }
+}
+
+QRESULT PolishedDecoration::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
+{
+ *iface = 0;
+ if ( uuid == IID_QUnknown )
+ *iface = this;
+ else if ( uuid == IID_WindowDecoration )
+ *iface = this;
+
+ if ( *iface )
+ (*iface)->addRef();
+ return QS_OK;
+}
+
+Q_EXPORT_INTERFACE()
+{
+ Q_CREATE_INSTANCE( PolishedDecoration )
+}
+
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 @@
+/**********************************************************************
+** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
+**
+** This file is part of the Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#ifndef POLISHED_H
+#define POLISHED_H
+
+#include <qtopia/windowdecorationinterface.h>
+
+class PolishedDecoration : public WindowDecorationInterface
+{
+public:
+ PolishedDecoration();
+ virtual ~PolishedDecoration();
+
+ virtual int metric( Metric m, const WindowData * ) const;
+ virtual void drawArea( Area a, QPainter *, const WindowData * ) const;
+ virtual void drawButton( Button b, QPainter *, const WindowData *, int x, int y, int w, int h, QWSButton::State ) const;
+ virtual QRegion mask( const WindowData * ) const;
+ virtual QString name() const;
+ virtual QPixmap icon() const;
+
+ QRESULT queryInterface( const QUuid&, QUnknownInterface** );
+ Q_REFCOUNT
+
+protected:
+ void PolishedDecoration::drawBlend( QPainter *, const QRect &r, const QColor &c1, const QColor&c2 ) const;
+
+private:
+ ulong ref;
+};
+
+#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 @@
+TEMPLATE = lib
+CONFIG += qt warn_on release
+HEADERS = polished.h
+SOURCES = polished.cpp
+TARGET = polished
+DESTDIR = $(OPIEDIR)/plugins/decorations
+INCLUDEPATH += $(OPIEDIR)/include
+DEPENDPATH += $(OPIEDIR)/include
+LIBS += -lqpe
+VERSION = 1.0.0
+