From a02709c8085ffe640561ede28330cfd018202fe9 Mon Sep 17 00:00:00 2001 From: Carsten Niehaus Date: Sun, 22 May 2005 19:34:03 +0000 Subject: [PATCH] add gradients to kalzium svn path=/trunk/KDE/kdeedu/kalzium/src/element.cpp; revision=417088 --- kalzium/src/element.cpp | 36 ++++++++++++++++++++++++++++++++++++ kalzium/src/element.h | 7 +++++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/kalzium/src/element.cpp b/kalzium/src/element.cpp index b9f82db..9c4b959 100644 --- a/kalzium/src/element.cpp +++ b/kalzium/src/element.cpp @@ -335,6 +335,42 @@ void Element::drawHighlight( QPainter* p, int coordinate, bool horizontal ) drawSelf( p, false ); } +void Element::drawGradient( QPainter* p, const QString& value, const QColor c) +{ + //the height of a "line" inside an element + int h_small = 15; //the size for the small units like elementnumber + + //The X-coordiante + int X = 0; + + X = ( x-1 )*ELEMENTSIZE; + + //The Y-coordinate + int Y = ( y-1 )*ELEMENTSIZE; + Y += ELEMENTSIZE; + + p->setPen( c ); + p->fillRect( X+3, Y+3,ELEMENTSIZE-6,ELEMENTSIZE-6, c ); + p->drawRoundRect( X+2, Y+2,ELEMENTSIZE-4,ELEMENTSIZE-4 ); + + p->setPen( Qt::black ); + QFont symbol_font = p->font(); + symbol_font.setPointSize( 18 ); + QFont f = p->font(); + f.setPointSize( 9 ); + + p->setFont( f ); + + p->drawText( X+5,Y+ELEMENTSIZE-h_small , ELEMENTSIZE-2, h_small,Qt::AlignLeft, value ); + + p->setFont( symbol_font ); + p->drawText( X+5,Y+2, ELEMENTSIZE,ELEMENTSIZE,Qt::AlignCenter, symbol() ); + + //border + p->setPen( Qt::black ); + p->drawRoundRect( X+1, Y+1,ELEMENTSIZE-2,ELEMENTSIZE-2); +} + void Element::drawSelf( QPainter* p, bool useSimpleView ) { //the height of a "line" inside an element diff --git a/kalzium/src/element.h b/kalzium/src/element.h index cbe74a8..9a52fed 100644 --- a/kalzium/src/element.h +++ b/kalzium/src/element.h @@ -28,6 +28,7 @@ #include class Element; +class QColor; struct coordinate; @@ -300,12 +301,12 @@ class Element{ RADIUS = 0, WEIGHT, DENSITY, - DATE, BOILINGPOINT, MELTINGPOINT, IE, + EN, IE2, - EN + DATE }; @@ -364,6 +365,8 @@ class Element{ * draw the recatangle with the information * @param showFullInformation if True more information will be shown */ + virtual void drawGradient( QPainter* p, const QString& value, const QColor ); + virtual void drawSelf( QPainter* p, bool showFullInformation ); /** -- 2.47.3