imagelabel.h

00001 /****************************************************************************
00002 *  imagelabel.h  -  ImageLabel meter
00003 *
00004 *  Copyright (C) 2003 Hans Karlsson <karlsson.h@home.se>
00005 *  Copyright (c) 2004 Petri Damstén <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 "meter.h"
00028 #include <kpixmap.h>
00029 #include <qimage.h>
00030 #include <qpixmap.h>
00031 #include <qpainter.h>
00032 #include <qstring.h>
00033 #include <qstringlist.h>
00034 #include <kurl.h>
00035 #include <kio/netaccess.h>
00036 #include <qregexp.h>
00037 #include <qtimer.h>
00038 #include "karamba.h"
00039 
00040 class ImageLabel;
00041 class KIO::CopyJob;
00042 
00043 // Abstract Effects Baseclass
00044 class Effect : public QObject
00045 {
00046 
00047 Q_OBJECT
00048 
00049 public:
00050   Effect(ImageLabel*, int millisec);
00051 
00052   virtual ~Effect();
00053 
00054   virtual KPixmap apply(KPixmap pixmap) = 0;
00055 
00056   void startTimer();
00057 
00058 protected:
00059   ImageLabel* myImage;
00060 
00061   int millisec;
00062 };
00063 
00064 // Intensity
00065 class Intensity : public Effect
00066 {
00067 public:
00068   Intensity(ImageLabel*, float r, int millisec);
00069 
00070   KPixmap apply(KPixmap pixmap);
00071 
00072 private:
00073   float ratio;
00074 };
00075 
00076 
00077 // ChannelIntensity
00078 class ChannelIntensity : public Effect
00079 {
00080 public:
00081   ChannelIntensity(ImageLabel*, float r, QString c, int millisec);
00082 
00083   KPixmap apply(KPixmap pixmap);
00084 
00085 private:
00086   float ratio;
00087   int channel;
00088 };
00089 
00090 // ToGray
00091 class ToGray : public Effect
00092 {
00093 public:
00094   ToGray(ImageLabel*, int millisec);
00095 
00096   KPixmap apply(KPixmap pixmap);
00097 };
00098 
00099 class ImageLabel : public Meter
00100 {
00101 
00102 Q_OBJECT
00103 
00104 public:
00105   ImageLabel(karamba* k, int ix,int iy,int iw,int ih );
00106   ImageLabel(karamba* k);
00107   ~ImageLabel();
00108   void setValue( QString imagePath );
00109 
00110   void setValue( long );
00111   void setValue( QPixmap& );
00112   QString getStringValue() { return imagePath; };
00113   void scale( int, int );
00114   void smoothScale( int, int );
00115 
00116   void rotate(int);
00117   void removeImageTransformations();
00118   void mUpdate( QPainter * );
00119   void mUpdate( QPainter *, int );
00120   
00121   void rolloverImage(QMouseEvent *e);
00122   void parseImages( QString fn, QString fn_roll, int, int, int, int );
00123   virtual void show();
00124   virtual void hide();
00125 
00126   void setTooltip(QString txt);
00127   int cblend;
00128   int background;
00129   // Pixmap Effects
00130   void removeEffects();
00131   void intensity(float ratio, int millisec);
00132   void channelIntensity(float ratio, QString channel, int millisec);
00133   void toGray(int millisec);
00134   void setBackground(int b);
00135 
00136   void attachClickArea(QString leftMouseButton, QString middleMouseButton,
00137                        QString rightMouseButton);
00138 
00139   virtual bool click(QMouseEvent*);
00140 
00141 private slots:
00142 
00143   // gets called if a timed effects needs to bee removed
00144   void slotEffectExpired();
00145   void slotCopyResult(KIO::Job* job);
00146 
00147 signals:
00148   void pixmapLoaded();
00149 
00150 private:
00151   void applyTransformations(bool useSmoothScale = false);
00152   int pixmapWidth;
00153   int pixmapHeight;
00154   int pixmapOffWidth;
00155   int pixmapOffHeight;
00156   int pixmapOnWidth;
00157   int pixmapOnHeight;
00158 
00159   // true if Image has been scaled
00160   bool doScale;
00161   // true if Image has been rotated
00162   bool doRotate;
00163 
00164   // Contains the current Effect or is 0 if no Effect is applied
00165   Effect* imageEffect;
00166 
00167   // Scale Matrix
00168   //QWMatrix scaleMat;
00169   int scale_w;
00170   int scale_h;
00171   // Rotation Matrix
00172   //QWMatrix rotMat;
00173   int rot_angle;
00174 
00175   KPixmap pixmap;
00176   KPixmap realpixmap;
00177 
00178   QRect rect_off, rect_on;
00179   QRect old_tip_rect;
00180 
00181   bool zoomed;
00182   //QString fn, fn_roll;
00183   bool rollover;
00184   KPixmap pixmap_off;
00185   KPixmap pixmap_on;
00186   int xoff,xon;
00187   int yoff,yon;
00188   QString imagePath;
00189 };
00190 
00191 #endif // IMAGELABEL_H
KDE Home | KDE Accessibility Home | Description of Access Keys