author | sandman <sandman> | 2002-10-04 00:46:45 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-10-04 00:46:45 (UTC) |
commit | 7f1029811faae4aa88c0c35157a33b95abffaae8 (patch) (side-by-side diff) | |
tree | 3cab1efdd4a88ae832dd29a424b1c9d884679ef4 /noncore/decorations/liquid | |
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/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 |
4 files changed, 180 insertions, 0 deletions
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. |