kpresenter

KPrPixmapObject.h
1/* This file is part of the KDE project
2 Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
3 Copyright (C) 2005 Thorsten Zachmann <zachmann@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21// ### TODO: fix copyright date/authors
22
23#ifndef kppixmapobject_h
24#define kppixmapobject_h
25
26#include <tqdatetime.h>
27#include <tqvariant.h>
28
29#include "KPrObject.h"
30#include <KoPictureCollection.h>
31#include <KoSize.h>
32
33class TQPixmap;
34
35// ### TODO rename the class (and the related files/classes) to a better name (for example KPPictureObject)
36
37class KPrPixmapObject : public KPr2DObject
38{
39
40public:
41 KPrPixmapObject( KoPictureCollection *_imageCollection );
42 KPrPixmapObject( KoPictureCollection *_imageCollection, const KoPictureKey & key );
43 virtual ~KPrPixmapObject() {}
44
45 KPrPixmapObject &operator=( const KPrPixmapObject & );
46
47 virtual DCOPObject* dcopObject();
48
53 TQString getFileName() const
54 { return image.getKey().filename(); }
55
56 KoPictureKey getKey() const
57 { return image.getKey(); }
58
59 TQSize originalSize() const
60 { return image.getOriginalSize(); }
61
63 void setPixmap( const KoPictureKey & key ) TDE_DEPRECATED;
64 void setPicture( const KoPictureKey & key );
65
66 void reload( void );
67
68 virtual ObjType getType() const
69 { return OT_PICTURE; }
70 virtual TQString getTypeString() const
71 { return i18n("Picture"); }
72
73 virtual TQDomDocumentFragment save( TQDomDocument& doc, double offset );
74
75 virtual double load(const TQDomElement &element);
76 virtual void loadOasis(const TQDomElement &element, KoOasisContext & context, KPrLoadingInfo *info);
77
78 virtual void draw( TQPainter *_painter, KoTextZoomHandler*_zoomHandler,
79 int /* page */, SelectionMode selectionMode, bool drawContour = false );
80
81 TQPixmap getOriginalPixmap();
82 PictureMirrorType getPictureMirrorType() const { return mirrorType; }
83 int getPictureDepth() const { return depth; }
84 bool getPictureSwapRGB() const { return swapRGB; }
85 bool getPictureGrayscal() const { return grayscal; }
86 int getPictureBright() const { return bright; }
87
88 ImageEffect getImageEffect() const {return m_effect;}
89 TQVariant getIEParam1() const {return m_ie_par1;}
90 TQVariant getIEParam2() const {return m_ie_par2;}
91 TQVariant getIEParam3() const {return m_ie_par3;}
92 void setImageEffect(ImageEffect eff) { m_effect = eff; }
93 void setIEParams(TQVariant p1, TQVariant p2, TQVariant p3) {
94 m_ie_par1=p1;
95 m_ie_par2=p2;
96 m_ie_par3=p3;
97 }
98
99 void setPictureMirrorType(const PictureMirrorType &_mirrorType) { mirrorType = _mirrorType; }
100 void setPictureDepth(int _depth) { depth = _depth; }
101 void setPictureSwapRGB(bool _swapRGB) { swapRGB = _swapRGB; }
102 void setPictureGrayscal(bool _grayscal) { grayscal = _grayscal; }
103 void setPictureBright(int _bright) { bright = _bright; }
104
105 KoPicture picture() const { return image;}
106
108 void loadImage( const TQString & fileName ) TDE_DEPRECATED;
109 void loadPicture( const TQString & fileName );
110
111 virtual void flip(bool horizontal );
112
113protected:
114 virtual const char * getOasisElementName() const;
115 virtual bool saveOasisObjectAttributes( KPOasisSaveContext &sc ) const;
116
117 KPrPixmapObject() {}
118
119 TQPixmap changePictureSettings( TQPixmap _tmpPixmap );
120 virtual void saveOasisPictureElement( KoGenStyle &styleobjectauto ) const;
121 void loadOasisPictureEffect(KoOasisContext & context );
122 virtual void fillStyle( KoGenStyle& styleObjectAuto, KoGenStyles& mainStyles ) const;
123
128 void drawShadow( TQPainter* _painter, KoZoomHandler* _zoomHandler);
129
130 TQPixmap generatePixmap(KoZoomHandler*_zoomHandler);
131 TQString convertValueToPercent( int val ) const;
132
133 KoPictureCollection *imageCollection;
134 KoPicture image;
135
136 PictureMirrorType mirrorType, m_cachedMirrorType;
137 int depth, m_cachedDepth;
138 bool swapRGB, m_cachedSwapRGB;
139 bool grayscal, m_cachedGrayscal;
140 int bright, m_cachedBright;
141
142 //image effect and its params
143 ImageEffect m_effect, m_cachedEffect;
144 TQVariant m_ie_par1, m_cachedPar1;
145 TQVariant m_ie_par2, m_cachedPar2;
146 TQVariant m_ie_par3, m_cachedPar3;
147
148 TQPixmap m_cachedPixmap;
149 TQRect m_cachedRect;
150};
151
152#endif