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