summaryrefslogtreecommitdiff
path: root/libopie2/opieui/oselector.cpp
Unidiff
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
@@ -33,12 +33,14 @@
33//----------------------------------------------------------------------------- 33//-----------------------------------------------------------------------------
34/* 34/*
35 * 2D value selector. 35 * 2D value selector.
36 * The contents of the selector are drawn by derived class. 36 * The contents of the selector are drawn by derived class.
37 */ 37 */
38 38
39using namespace Opie::Ui;
40
39OXYSelector::OXYSelector( QWidget *parent, const char *name ) 41OXYSelector::OXYSelector( QWidget *parent, const char *name )
40 : QWidget( parent, name ) 42 : QWidget( parent, name )
41{ 43{
42 xPos = 0; 44 xPos = 0;
43 yPos = 0; 45 yPos = 0;
44 minX = 0; 46 minX = 0;
@@ -70,13 +72,13 @@ void OXYSelector::setValues( int _xPos, int _yPos )
70 yPos = _yPos; 72 yPos = _yPos;
71 73
72 if ( xPos > maxX ) 74 if ( xPos > maxX )
73 xPos = maxX; 75 xPos = maxX;
74 else if ( xPos < minX ) 76 else if ( xPos < minX )
75 xPos = minX; 77 xPos = minX;
76 78
77 if ( yPos > maxY ) 79 if ( yPos > maxY )
78 yPos = maxY; 80 yPos = maxY;
79 else if ( yPos < minY ) 81 else if ( yPos < minY )
80 yPos = minY; 82 yPos = minY;
81 83
82 int xp = 2 + (width() - 4) * xPos / (maxX - minX); 84 int xp = 2 + (width() - 4) * xPos / (maxX - minX);
@@ -255,13 +257,13 @@ void OSelector::paintEvent( QPaintEvent * )
255 else 257 else
256 qDrawShadePanel( &painter, 3, 0, width()-6, height()-5, 258 qDrawShadePanel( &painter, 3, 0, width()-6, height()-5,
257 colorGroup(), TRUE, 2, &brush ); 259 colorGroup(), TRUE, 2, &brush );
258 } 260 }
259 261
260 QPoint pos = calcArrowPos( value() ); 262 QPoint pos = calcArrowPos( value() );
261 drawArrow( &painter, TRUE, pos ); 263 drawArrow( &painter, TRUE, pos );
262 264
263 painter.end(); 265 painter.end();
264} 266}
265 267
266void OSelector::mousePressEvent( QMouseEvent *e ) 268void OSelector::mousePressEvent( QMouseEvent *e )
267{ 269{
@@ -285,16 +287,16 @@ void OSelector::valueChange()
285 QPainter painter; 287 QPainter painter;
286 QPoint pos; 288 QPoint pos;
287 289
288 painter.begin( this ); 290 painter.begin( this );
289 291
290 pos = calcArrowPos( prevValue() ); 292 pos = calcArrowPos( prevValue() );
291 drawArrow( &painter, FALSE, pos ); 293 drawArrow( &painter, FALSE, pos );
292 294
293 pos = calcArrowPos( value() ); 295 pos = calcArrowPos( value() );
294 drawArrow( &painter, TRUE, pos ); 296 drawArrow( &painter, TRUE, pos );
295 297
296 painter.end(); 298 painter.end();
297} 299}
298 300
299void OSelector::moveArrow( const QPoint &pos ) 301void OSelector::moveArrow( const QPoint &pos )
300{ 302{
@@ -358,14 +360,14 @@ void OSelector::drawArrow( QPainter *painter, bool show, const QPoint &pos )
358 array.setPoint( 0, pos.x()+0, pos.y()+0 ); 360 array.setPoint( 0, pos.x()+0, pos.y()+0 );
359 array.setPoint( 1, pos.x()+5, pos.y()+5 ); 361 array.setPoint( 1, pos.x()+5, pos.y()+5 );
360 array.setPoint( 2, pos.x()-5, pos.y()+5 ); 362 array.setPoint( 2, pos.x()-5, pos.y()+5 );
361 } 363 }
362 364
363 painter->drawPolygon( array ); 365 painter->drawPolygon( array );
364 } 366 }
365 else 367 else
366 { 368 {
367 if ( orientation() == Vertical ) 369 if ( orientation() == Vertical )
368 { 370 {
369 repaint(pos.x(), pos.y()-5, 6, 11, true); 371 repaint(pos.x(), pos.y()-5, 6, 11, true);
370 } 372 }
371 else 373 else
@@ -397,13 +399,13 @@ OGradientSelector::~OGradientSelector()
397 399
398 400
399void OGradientSelector::init() 401void OGradientSelector::init()
400{ 402{
401 color1.setRgb( 0, 0, 0 ); 403 color1.setRgb( 0, 0, 0 );
402 color2.setRgb( 255, 255, 255 ); 404 color2.setRgb( 255, 255, 255 );
403 405
404 text1 = text2 = ""; 406 text1 = text2 = "";
405} 407}
406 408
407 409
408void OGradientSelector::drawContents( QPainter *painter ) 410void OGradientSelector::drawContents( QPainter *painter )
409{ 411{
@@ -469,13 +471,13 @@ void OGradientSelector::drawContents( QPainter *painter )
469 painter->fontMetrics().width( text2 )) / 2; 471 painter->fontMetrics().width( text2 )) / 2;
470 QPen pen( color2 ); 472 QPen pen( color2 );
471 painter->setPen( pen ); 473 painter->setPen( pen );
472 painter->drawText( xPos, yPos, text2 ); 474 painter->drawText( xPos, yPos, text2 );
473 475
474 yPos = contentsRect().bottom() - painter->fontMetrics().descent() - 2; 476 yPos = contentsRect().bottom() - painter->fontMetrics().descent() - 2;
475 xPos = contentsRect().left() + (contentsRect().width() - 477 xPos = contentsRect().left() + (contentsRect().width() -
476 painter->fontMetrics().width( text1 )) / 2; 478 painter->fontMetrics().width( text1 )) / 2;
477 pen.setColor( color1 ); 479 pen.setColor( color1 );
478 painter->setPen( pen ); 480 painter->setPen( pen );
479 painter->drawText( xPos, yPos, text1 ); 481 painter->drawText( xPos, yPos, text1 );
480 } 482 }
481 else 483 else