[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/plasma
From:       Aaron J. Seigo <aseigo () kde ! org>
Date:       2008-12-23 18:32:00
Message-ID: 1230057120.398008.21364.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 900826 by aseigo:

allow defining the font to use with the shadow text


 M  +10 -2     paintutils.cpp  
 M  +8 -0      paintutils.h  


--- trunk/KDE/kdelibs/plasma/paintutils.cpp #900825:900826
@@ -47,19 +47,27 @@
     p.end();
 }
 
+//TODO: we should have shadowText methods that paint the results directly into a \
QPainter passed in  QPixmap shadowText(QString text, QColor textColor, QColor \
shadowColor, QPoint offset, int radius)  {
+    return shadowText(text, qApp->font(), textColor, shadowColor, offset, radius);
+}
+
+QPixmap shadowText(QString text, const QFont &font, QColor textColor, QColor \
shadowColor, QPoint offset, int radius) +{
     //don't try to paint stuff on a future null pixmap because the text is empty
     if (text.isEmpty()) {
         return QPixmap();
     }
+
     // Draw text
-    QFontMetrics fm(text);
+    QFontMetrics fm(font);
     QRect textRect = fm.boundingRect(text);
-    QPixmap textPixmap(textRect.size());
+    QPixmap textPixmap(textRect.width(), fm.height());
     textPixmap.fill(Qt::transparent);
     QPainter p(&textPixmap);
     p.setPen(textColor);
+    p.setFont(font);
     p.drawText(textPixmap.rect(), Qt::AlignLeft, text);
     p.end();
 
--- trunk/KDE/kdelibs/plasma/paintutils.h #900825:900826
@@ -21,6 +21,7 @@
 #ifndef PLASMA_PAINTUTILS_H
 #define PLASMA_PAINTUTILS_H
 
+#include <QtGui/QApplication>
 #include <QtGui/QGraphicsItem>
 #include <QtGui/QPainterPath>
 
@@ -48,11 +49,18 @@
  * Text and shadow colors default to Plasma::Theme colors.
  */
 PLASMA_EXPORT QPixmap shadowText(QString text,
+    const QFont &font,
     QColor textColor = \
                Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor),
     QColor shadowColor = \
Plasma::Theme::defaultTheme()->color(Plasma::Theme::BackgroundColor),  QPoint offset \
= QPoint(1,1),  int radius = 2);
 
+PLASMA_EXPORT QPixmap shadowText(QString text,
+    QColor textColor = \
Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor), +    QColor \
shadowColor = Plasma::Theme::defaultTheme()->color(Plasma::Theme::BackgroundColor), + \
QPoint offset = QPoint(1,1), +    int radius = 2);
+
 /**
  * Returns a nicely rounded rectanglular path for painting.
  */


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic