summaryrefslogtreecommitdiff
path: root/libopie2/opieui/oselector.cpp
Side-by-side diff
Diffstat (limited to 'libopie2/opieui/oselector.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/oselector.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/libopie2/opieui/oselector.cpp b/libopie2/opieui/oselector.cpp
index 23b3ce3..5f6f10f 100644
--- a/libopie2/opieui/oselector.cpp
+++ b/libopie2/opieui/oselector.cpp
@@ -27,24 +27,26 @@
#include <opie2/oimageeffect.h>
#include <opie2/oselector.h>
#define STORE_W 8
#define STORE_W2 STORE_W * 2
//-----------------------------------------------------------------------------
/*
* 2D value selector.
* The contents of the selector are drawn by derived class.
*/
+using namespace Opie::Ui;
+
OXYSelector::OXYSelector( QWidget *parent, const char *name )
: QWidget( parent, name )
{
xPos = 0;
yPos = 0;
minX = 0;
minY = 0;
maxX = 100;
maxY = 100;
store.setOptimization( QPixmap::BestOptim );
store.resize( STORE_W2, STORE_W2 );
}
@@ -64,25 +66,25 @@ void OXYSelector::setRange( int _minX, int _minY, int _maxX, int _maxY )
maxY = _maxY;
}
void OXYSelector::setValues( int _xPos, int _yPos )
{
xPos = _xPos;
yPos = _yPos;
if ( xPos > maxX )
xPos = maxX;
else if ( xPos < minX )
xPos = minX;
-
+
if ( yPos > maxY )
yPos = maxY;
else if ( yPos < minY )
yPos = minY;
int xp = 2 + (width() - 4) * xPos / (maxX - minX);
int yp = height() - 2 - (height() - 4) * yPos / (maxY - minY);
setPosition( xp, yp );
}
QRect OXYSelector::contentsRect() const
@@ -249,25 +251,25 @@ void OSelector::paintEvent( QPaintEvent * )
if ( indent() )
{
if ( orientation() == Vertical )
qDrawShadePanel( &painter, 0, 3, width()-5, height()-6,
colorGroup(), TRUE, 2, &brush );
else
qDrawShadePanel( &painter, 3, 0, width()-6, height()-5,
colorGroup(), TRUE, 2, &brush );
}
QPoint pos = calcArrowPos( value() );
- drawArrow( &painter, TRUE, pos );
+ drawArrow( &painter, TRUE, pos );
painter.end();
}
void OSelector::mousePressEvent( QMouseEvent *e )
{
moveArrow( e->pos() );
}
void OSelector::mouseMoveEvent( QMouseEvent *e )
{
moveArrow( e->pos() );
@@ -279,28 +281,28 @@ void OSelector::wheelEvent( QWheelEvent *e )
emit valueChanged( val );
setValue( val );
}
void OSelector::valueChange()
{
QPainter painter;
QPoint pos;
painter.begin( this );
pos = calcArrowPos( prevValue() );
- drawArrow( &painter, FALSE, pos );
+ drawArrow( &painter, FALSE, pos );
pos = calcArrowPos( value() );
- drawArrow( &painter, TRUE, pos );
+ drawArrow( &painter, TRUE, pos );
painter.end();
}
void OSelector::moveArrow( const QPoint &pos )
{
int val;
if ( orientation() == Vertical )
val = ( maxValue() - minValue() ) * (height()-pos.y()-3)
/ (height()-10) + minValue();
else
@@ -352,26 +354,26 @@ void OSelector::drawArrow( QPainter *painter, bool show, const QPoint &pos )
array.setPoint( 0, pos.x()+0, pos.y()+0 );
array.setPoint( 1, pos.x()+5, pos.y()+5 );
array.setPoint( 2, pos.x()+5, pos.y()-5 );
}
else
{
array.setPoint( 0, pos.x()+0, pos.y()+0 );
array.setPoint( 1, pos.x()+5, pos.y()+5 );
array.setPoint( 2, pos.x()-5, pos.y()+5 );
}
painter->drawPolygon( array );
- }
- else
+ }
+ else
{
if ( orientation() == Vertical )
{
repaint(pos.x(), pos.y()-5, 6, 11, true);
}
else
{
repaint(pos.x()-5, pos.y(), 11, 6, true);
}
}
}
@@ -391,25 +393,25 @@ OGradientSelector::OGradientSelector( Orientation o, QWidget *parent,
init();
}
OGradientSelector::~OGradientSelector()
{}
void OGradientSelector::init()
{
color1.setRgb( 0, 0, 0 );
color2.setRgb( 255, 255, 255 );
-
+
text1 = text2 = "";
}
void OGradientSelector::drawContents( QPainter *painter )
{
QImage image( contentsRect().width(), contentsRect().height(), 32 );
QColor col;
float scale;
int redDiff = color2.red() - color1.red();
@@ -463,25 +465,25 @@ void OGradientSelector::drawContents( QPainter *painter )
painter->drawPixmap( contentsRect().x(), contentsRect().y(), p );
if ( orientation() == Vertical )
{
int yPos = contentsRect().top() + painter->fontMetrics().ascent() + 2;
int xPos = contentsRect().left() + (contentsRect().width() -
painter->fontMetrics().width( text2 )) / 2;
QPen pen( color2 );
painter->setPen( pen );
painter->drawText( xPos, yPos, text2 );
yPos = contentsRect().bottom() - painter->fontMetrics().descent() - 2;
- xPos = contentsRect().left() + (contentsRect().width() -
+ xPos = contentsRect().left() + (contentsRect().width() -
painter->fontMetrics().width( text1 )) / 2;
pen.setColor( color1 );
painter->setPen( pen );
painter->drawText( xPos, yPos, text1 );
}
else
{
int yPos = contentsRect().bottom()-painter->fontMetrics().descent()-2;
QPen pen( color2 );
painter->setPen( pen );
painter->drawText( contentsRect().left() + 2, yPos, text1 );