summaryrefslogtreecommitdiff
path: root/noncore/decorations/polished/polished.cpp
Side-by-side diff
Diffstat (limited to 'noncore/decorations/polished/polished.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/decorations/polished/polished.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/noncore/decorations/polished/polished.cpp b/noncore/decorations/polished/polished.cpp
index 30f1a84..43179be 100644
--- a/noncore/decorations/polished/polished.cpp
+++ b/noncore/decorations/polished/polished.cpp
@@ -1,73 +1,73 @@
/**********************************************************************
** 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()
{
}
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);
@@ -113,59 +113,61 @@ void PolishedDecoration::drawButton( Button b, QPainter *p, const WindowData *wd
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;
+ else
+ return QS_FALSE;
if ( *iface )
(*iface)->addRef();
return QS_OK;
}
Q_EXPORT_INTERFACE()
{
Q_CREATE_INSTANCE( PolishedDecoration )
}