• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • kdeutils
  • Sitemap
  • Contact Us
 

superkaramba

imagelabel.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 *  imagelabel.h  -  ImageLabel meter
00003 *
00004 *  Copyright (C) 2003 Hans Karlsson <karlsson.h@home.se>
00005 *  Copyright (c) 2004 Petri Damst� <damu@iki.fi>
00006 *
00007 *  This file is part of SuperKaramba.
00008 *
00009 *  SuperKaramba is free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  SuperKaramba is distributed in the hope that it will be useful,
00015 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 *  GNU General Public License for more details.
00018 *
00019 *  You should have received a copy of the GNU General Public License
00020 *  along with SuperKaramba; if not, write to the Free Software
00021 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00022 ****************************************************************************/
00023 
00024 #ifndef IMAGELABEL_H
00025 #define IMAGELABEL_H
00026 
00027 #include <QPainter>
00028 #include <QGraphicsSceneMouseEvent>
00029 
00030 #include <kio/netaccess.h>
00031 #include <kio/copyjob.h>
00032 #include <KSvgRenderer>
00033 
00034 #include "karamba.h"
00035 #include "meter.h"
00036 
00037 class ImageLabel;
00038 
00039 // Abstract Effects Baseclass
00040 class Effect : public QObject
00041 {
00042 
00043     Q_OBJECT
00044 
00045 public:
00046     Effect(ImageLabel*, int millisec);
00047 
00048     virtual ~Effect();
00049 
00050     virtual QPixmap apply(QPixmap pixmap) = 0;
00051 
00052     void startTimer();
00053 
00054 protected:
00055     ImageLabel* myImage;
00056 
00057     int millisec;
00058 };
00059 
00060 // Intensity
00061 class Intensity : public Effect
00062 {
00063 public:
00064     Intensity(ImageLabel*, float r, int millisec);
00065 
00066     QPixmap apply(QPixmap pixmap);
00067 
00068 private:
00069     float ratio;
00070 };
00071 
00072 
00073 // ChannelIntensity
00074 class ChannelIntensity : public Effect
00075 {
00076 public:
00077     ChannelIntensity(ImageLabel*, float r, const QString &c, int millisec);
00078 
00079     QPixmap apply(QPixmap pixmap);
00080 
00081 private:
00082     float ratio;
00083     int channel;
00084 };
00085 
00086 // ToGray
00087 class ToGray : public Effect
00088 {
00089 public:
00090     ToGray(ImageLabel*, int millisec);
00091 
00092     QPixmap apply(QPixmap pixmap);
00093 };
00094 
00095 // ToAlpha
00096 class ToAlpha : public Effect
00097 {
00098 public:
00099     ToAlpha(ImageLabel*, const QColor &alphaColor, int alpha, int millisec);
00100 
00101     QPixmap apply(QPixmap pixmap);
00102 
00103 private:
00104     QColor m_alphaColor;
00105     int m_alpha;
00106 };
00107 
00108 class ImageLabel : public Meter
00109 {
00110 
00111     Q_OBJECT
00112 
00113 public:
00114     ImageLabel(Karamba* k, int ix, int iy, int iw, int ih);
00115     ImageLabel(Karamba* k);
00116     ~ImageLabel();
00117     void setValue(const QString &imagePath);
00118 
00119     void setValue(int);
00120     void setValue(QPixmap&);
00121     QString getStringValue() const
00122     {
00123         return imagePath;
00124     }
00125     void scale(int, int);
00126     void smoothScale(int, int);
00127 
00128     void rotate(int);
00129     void removeImageTransformations();
00130     void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
00131                QWidget *widget);
00132 
00133     void rolloverImage(QGraphicsSceneHoverEvent *e);
00134     void parseImages(const QString &fn, const QString &fn_roll, int, int, int, int);
00135     virtual void show();
00136     virtual void hide();
00137 
00138     void setTooltip(QString txt);
00139     int background;
00140     // Pixmap Effects
00141     void removeEffects();
00142     void intensity(float ratio, int millisec);
00143     void channelIntensity(float ratio, QString channel, int millisec);
00144     void toGray(int millisec);
00145     void toAlpha(const QColor &alphaColor, int alpha, int millisec);
00146     void setBackground(int b);
00147 
00148     void attachClickArea(QString leftMouseButton, QString middleMouseButton,
00149                          QString rightMouseButton);
00150 
00151     bool mouseEvent(QEvent *e);
00152 
00153     void allowClick(bool);
00154     bool clickable();
00155     void setPixel(const QPoint &point, const QColor &pixel);
00156 
00157     bool enableAnimation(bool enable);
00158     bool animationEnabled() const;
00159 
00160     bool drawElement(const QString &element);
00161     QString elementDrawn() const;
00162 
00163 private slots:
00164 
00165     // gets called if a timed effects needs to bee removed
00166     void slotEffectExpired();
00167     void slotCopyResult(KJob* job);
00168     void repaintSvg();
00169 
00170 signals:
00171     void pixmapLoaded();
00172 
00173 private:
00174     void applyTransformations(bool useSmoothScale = false);
00175     int pixmapWidth;
00176     int pixmapHeight;
00177     int pixmapOffWidth;
00178     int pixmapOffHeight;
00179     int pixmapOnWidth;
00180     int pixmapOnHeight;
00181 
00182     bool m_allowClick;
00183 
00184     // true if Image has been scaled
00185     bool doScale;
00186     // true if Image has been rotated
00187     bool doRotate;
00188 
00189     // Contains the current Effect or is 0 if no Effect is applied
00190     Effect* imageEffect;
00191 
00192     // Scale Matrix
00193     //QMatrix scaleMat;
00194     int scale_w;
00195     int scale_h;
00196     // Rotation Matrix
00197     //QMatrix rotMat;
00198     int rot_angle;
00199 
00200     QPixmap pixmap;
00201     QPixmap realpixmap;
00202 
00203     QRect rect_off, rect_on;
00204     QRect old_tip_rect;
00205 
00206     bool zoomed;
00207     //QString fn, fn_roll;
00208     bool rollover;
00209     QPixmap pixmap_off;
00210     QPixmap pixmap_on;
00211     int xoff, xon;
00212     int yoff, yon;
00213     QString imagePath;
00214 
00215     QString m_leftMouseButtonAction;
00216     QString m_middleMouseButtonAction;
00217     QString m_rightMouseButtonAction;
00218 
00219     KSvgRenderer *m_renderer;
00220     bool m_connected;
00221 
00222     QString m_element;
00223 };
00224 
00225 #endif // IMAGELABEL_H

superkaramba

Skip menu "superkaramba"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

kdeutils

Skip menu "kdeutils"
  • ark
  • kcalc
  • kcharselect
  • kdelirc
  • kdessh
  • kdf
  • kfloppy
  • kgpg
  • kjots
  • klaptopdaemon
  • kmilo
  • ksim
  • ktimer
  • kwallet
  • superkaramba
Generated for kdeutils by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal