summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/styles/theme/ogfxeffect.cpp6
-rw-r--r--noncore/styles/theme/othemestyle.cpp6
2 files changed, 9 insertions, 3 deletions
diff --git a/noncore/styles/theme/ogfxeffect.cpp b/noncore/styles/theme/ogfxeffect.cpp
index 2071a67..90b45fe 100644
--- a/noncore/styles/theme/ogfxeffect.cpp
+++ b/noncore/styles/theme/ogfxeffect.cpp
@@ -1,64 +1,65 @@
/* This file is part of the KDE libraries
Copyright (C) 1998, 1999 Christian Tibirna <ctibirna@total.net>
(C) 1998, 1999 Daniel M. Duley <mosfet@kde.org>
(C) 1998, 1999 Dirk A. Mueller <mueller@kde.org>
*/
// $Id$
#include <qimage.h>
#include <qpainter.h>
#include <qpe/qmath.h>
#include "ogfxeffect.h"
#include <cstdlib>
#include <cmath>
//======================================================================
//
// Gradient effects
//
//======================================================================
QPixmap& OGfxEffect::gradient(QPixmap &pixmap, const QColor &ca,
const QColor &cb, GradientType eff, int ncols)
{
+ if ( !pixmap. isNull ( )) {
QImage image = gradient(pixmap.size(), ca, cb, eff, ncols);
pixmap.convertFromImage(image);
-
+ }
return pixmap;
}
QImage OGfxEffect::gradient(const QSize &size, const QColor &ca,
const QColor &cb, GradientType eff, int /*ncols*/)
{
int rDiff, gDiff, bDiff;
int rca, gca, bca, rcb, gcb, bcb;
QImage image(size, 32);
if (size.width() == 0 || size.height() == 0) {
qDebug ( "WARNING: OGfxEffect::gradient: invalid image" );
return image;
}
register int x, y;
rDiff = (rcb = cb.red()) - (rca = ca.red());
gDiff = (gcb = cb.green()) - (gca = ca.green());
bDiff = (bcb = cb.blue()) - (bca = ca.blue());
if( eff == VerticalGradient || eff == HorizontalGradient ){
uint *p;
uint rgb;
register int rl = rca << 16;
register int gl = gca << 16;
register int bl = bca << 16;
if( eff == VerticalGradient ) {
@@ -251,72 +252,73 @@ QImage OGfxEffect::gradient(const QSize &size, const QColor &ca,
(int)sqrt((xtable[2][x]*xtable[2][x] +
ytable[2][y]*ytable[2][y])*2.0));
}
sl1[x] = sl2[x] = rgb;
sl1[x2] = sl2[x2] = rgb;
}
}
}
delete [] xtable[0];
delete [] xtable[1];
delete [] xtable[2];
delete [] ytable[0];
delete [] ytable[1];
delete [] ytable[2];
}
return image;
}
//======================================================================
//
// Blend effects
//
//======================================================================
QPixmap& OGfxEffect::blend(QPixmap &pixmap, float initial_intensity,
const QColor &bgnd, GradientType eff,
bool anti_dir, int /*ncols*/)
{
+ if ( !pixmap. isNull ( )) {
QImage image = pixmap.convertToImage();
OGfxEffect::blend(image, initial_intensity, bgnd, eff, anti_dir);
if ( pixmap. depth ( ) <= 8 )
image. convertDepth ( pixmap. depth ( ));
pixmap.convertFromImage(image);
-
+ }
return pixmap;
}
QImage& OGfxEffect::blend(QImage &image, float initial_intensity,
const QColor &bgnd, GradientType eff,
bool anti_dir)
{
if (image.width() == 0 || image.height() == 0) {
qDebug ( "Invalid image\n" );
return image;
}
int r_bgnd = bgnd.red(), g_bgnd = bgnd.green(), b_bgnd = bgnd.blue();
int r, g, b;
int ind;
unsigned int xi, xf, yi, yf;
unsigned int a;
// check the boundaries of the initial intesity param
float unaffected = 1;
if (initial_intensity > 1) initial_intensity = 1;
if (initial_intensity < -1) initial_intensity = -1;
if (initial_intensity < 0) {
unaffected = 1. + initial_intensity;
initial_intensity = 0;
}
float intensity = initial_intensity;
float var = 1. - initial_intensity;
diff --git a/noncore/styles/theme/othemestyle.cpp b/noncore/styles/theme/othemestyle.cpp
index a820efb..98e7253 100644
--- a/noncore/styles/theme/othemestyle.cpp
+++ b/noncore/styles/theme/othemestyle.cpp
@@ -220,105 +220,109 @@ void OThemeStyle::unPolish( QWidget* w )
|| w->inherits( "QButton" )
|| w->inherits( "QProgressBar" )
) {
w->setBackgroundOrigin( QWidget::WidgetOrigin );
}
}
if ( w->inherits( "QPopupMenu" ) )
w->unsetPalette();
else if ( w->inherits( "QCheckBox" ) )
w->unsetPalette();
else if ( w->inherits( "QRadioButton" ) )
w->unsetPalette();
else if ( w-> inherits ( "QProgressBar" ) )
w-> removeEventFilter ( this );
}
bool OThemeStyle::eventFilter ( QObject *obj, QEvent *ev )
{
// only QProgressBar so far
if ( ev-> type ( ) == QEvent::Paint ) {
HackProgressBar *pb = (HackProgressBar *) obj;
pb-> paint ((QPaintEvent *) ev, this );
return true;
}
return false;
}
void OThemeStyle::drawBaseButton( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken, bool
rounded, WidgetType type, const QBrush * )
{
+ if ( w <= 0 || h <= 0 )
+ return;
+
int offset = borderPixmap( type ) ? 0 : decoWidth( type );
QPen oldPen = p->pen();
// handle reverse bevel here since it uses decowidth differently
if ( gradientHint( type ) == GrReverseBevel ) {
int i;
bitBlt( p->device(), x, y, scalePixmap( w, h, type ), 0, 0, w, h,
Qt::CopyROP, true );
p->setPen( g.text() );
for ( i = 0; i < borderWidth( type ); ++i, ++x, ++y, w -= 2, h -= 2 )
p->drawRect( x, y, w, h );
}
// same with KDE style borders
else if ( !borderPixmap( type ) && shade() == KDE ) {
qDrawWinButton( p, x, y, w, h, g, sunken );
if ( isPixmap( type ) )
p->drawTiledPixmap( x + 4, y + 4, w - 6, h - 6,
*scalePixmap( w - 6, h - 6,
type ) );
else
p->fillRect( x + 4, y + 4, w - 6, h - offset * 6,
g.brush( QColorGroup::Button ) );
}
else {
if ( ( w - offset * 2 ) > 0 && ( h - offset * 2 ) > 0 ) {
if ( isPixmap( type ) )
if ( rounded )
p->drawTiledPixmap( x, y, w, h, *scalePixmap( w, h, type ) );
else
p->drawTiledPixmap( x + offset, y + offset, w - offset * 2,
h - offset * 2,
*scalePixmap( w - offset * 2, h - offset * 2,
type ) );
else
p->fillRect( x + offset, y + offset, w - offset * 2, h - offset * 2,
g.brush( QColorGroup::Button ) );
}
- if ( borderPixmap( type ) )
+ if ( borderPixmap( type ) ) {
bitBlt( p->device(), x, y, scaleBorder( w, h, type ), 0, 0, w, h,
Qt::CopyROP, false );
+ }
else
drawShade( p, x, y, w, h, g, sunken, rounded,
highlightWidth( type ), borderWidth( type ), shade() );
}
p->setPen( oldPen );
}
void OThemeStyle::drawButton( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken,
const QBrush *fill )
{
drawBaseButton( p, x, y, w, h, g, sunken, roundButton(), sunken ?
PushButtonDown : PushButton, fill );
}
void OThemeStyle::drawPushButton( QPushButton* btn, QPainter *p )
{
bool sunken = btn->isOn() || btn->isDown();
int diw = buttonDefaultIndicatorWidth();
drawBaseButton( p, diw, diw, btn->width() - 2 * diw, btn->height() - 2 * diw,
*colorGroup( btn->colorGroup(), sunken ? PushButtonDown :
PushButton ), sunken, roundButton(),
sunken ? PushButtonDown : PushButton, NULL );
// TODO if diw, draw fancy default button indicator
}
void OThemeStyle::drawBaseMask( QPainter *p, int x, int y, int w, int h,
bool round )
{
// round edge fills
static const QCOORD btm_left_fill[] = {
0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1,