summaryrefslogtreecommitdiffstats
path: root/superkaramba/src/imagelabel.h
blob: 1346c2e43104b8b6b934e6b8f260c5997bd9b29a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/****************************************************************************
*  imagelabel.h  -  ImageLabel meter
*
*  Copyright (C) 2003 Hans Karlsson <karlsson.h@home.se>
*  Copyright (c) 2004 Petri Damstén <damu@iki.fi>
*
*  This file is part of SuperKaramba.
*
*  SuperKaramba is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  SuperKaramba is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with SuperKaramba; if not, write to the Free Software
*  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
****************************************************************************/

#ifndef IMAGELABEL_H
#define IMAGELABEL_H

#include "meter.h"
#include <kpixmap.h>
#include <tqimage.h>
#include <tqpixmap.h>
#include <tqpainter.h>
#include <tqstring.h>
#include <tqstringlist.h>
#include <kurl.h>
#include <tdeio/netaccess.h>
#include <tqregexp.h>
#include <tqtimer.h>
#include "karamba.h"

class ImageLabel;
namespace TDEIO {
    class CopyJob;
}

// Abstract Effects Baseclass
class Effect : public TQObject
{

Q_OBJECT
  

public:
  Effect(ImageLabel*, int millisec);

  virtual ~Effect();

  virtual KPixmap apply(KPixmap pixmap) = 0;

  void startTimer();

protected:
  ImageLabel* myImage;

  int millisec;
};

// Intensity
class Intensity : public Effect
{
public:
  Intensity(ImageLabel*, float r, int millisec);

  KPixmap apply(KPixmap pixmap);

private:
  float ratio;
};


// ChannelIntensity
class ChannelIntensity : public Effect
{
public:
  ChannelIntensity(ImageLabel*, float r, TQString c, int millisec);

  KPixmap apply(KPixmap pixmap);

private:
  float ratio;
  int channel;
};

// ToGray
class ToGray : public Effect
{
public:
  ToGray(ImageLabel*, int millisec);

  KPixmap apply(KPixmap pixmap);
};

class ImageLabel : public Meter
{

Q_OBJECT
  

public:
  ImageLabel(karamba* k, int ix,int iy,int iw,int ih );
  ImageLabel(karamba* k);
  ~ImageLabel();
  void setValue( TQString imagePath );

  void setValue( long );
  void setValue( TQPixmap& );
  TQString getStringValue() { return imagePath; };
  void scale( int, int );
  void smoothScale( int, int );

  void rotate(int);
  void removeImageTransformations();
  void mUpdate( TQPainter * );
  void mUpdate( TQPainter *, int );
  
  void rolloverImage(TQMouseEvent *e);
  void parseImages( TQString fn, TQString fn_roll, int, int, int, int );
  virtual void show();
  virtual void hide();

  void setTooltip(TQString txt);
  int cblend;
  int background;
  // Pixmap Effects
  void removeEffects();
  void intensity(float ratio, int millisec);
  void channelIntensity(float ratio, TQString channel, int millisec);
  void toGray(int millisec);
  void setBackground(int b);

  void attachClickArea(TQString leftMouseButton, TQString middleMouseButton,
                       TQString rightMouseButton);

  virtual bool click(TQMouseEvent*);

private slots:

  // gets called if a timed effects needs to bee removed
  void slotEffectExpired();
  void slotCopyResult(TDEIO::Job* job);

signals:
  void pixmapLoaded();

private:
  void applyTransformations(bool useSmoothScale = false);
  int pixmapWidth;
  int pixmapHeight;
  int pixmapOffWidth;
  int pixmapOffHeight;
  int pixmapOnWidth;
  int pixmapOnHeight;

  // true if Image has been scaled
  bool doScale;
  // true if Image has been rotated
  bool doRotate;

  // Contains the current Effect or is 0 if no Effect is applied
  Effect* imageEffect;

  // Scale Matrix
  //TQWMatrix scaleMat;
  int scale_w;
  int scale_h;
  // Rotation Matrix
  //TQWMatrix rotMat;
  int rot_angle;

  KPixmap pixmap;
  KPixmap realpixmap;

  TQRect rect_off, rect_on;
  TQRect old_tip_rect;

  bool zoomed;
  //TQString fn, fn_roll;
  bool rollover;
  KPixmap pixmap_off;
  KPixmap pixmap_on;
  int xoff,xon;
  int yoff,yon;
  TQString imagePath;
};

#endif // IMAGELABEL_H