kpresenter

KPrPixmapObject.h

00001 // -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*-
00002 /* This file is part of the KDE project
00003    Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
00004    Copyright (C) 2005 Thorsten Zachmann <zachmann@kde.org>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020 */
00021 
00022 // ### TODO: fix copyright date/authors
00023 
00024 #ifndef kppixmapobject_h
00025 #define kppixmapobject_h
00026 
00027 #include <qdatetime.h>
00028 #include <qvariant.h>
00029 
00030 #include "KPrObject.h"
00031 #include <KoPictureCollection.h>
00032 #include <KoSize.h>
00033 
00034 class QPixmap;
00035 
00036 // ### TODO rename the class (and the related files/classes) to a better name (for example KPPictureObject)
00037 
00038 class KPrPixmapObject : public KPr2DObject
00039 {
00040 
00041 public:
00042     KPrPixmapObject( KoPictureCollection *_imageCollection );
00043     KPrPixmapObject( KoPictureCollection *_imageCollection, const KoPictureKey & key );
00044     virtual ~KPrPixmapObject() {}
00045 
00046     KPrPixmapObject &operator=( const KPrPixmapObject & );
00047 
00048     virtual DCOPObject* dcopObject();
00049 
00054     QString getFileName() const
00055         { return image.getKey().filename(); }
00056 
00057     KoPictureKey getKey() const
00058         { return image.getKey(); }
00059 
00060     QSize originalSize() const
00061         { return image.getOriginalSize(); }
00062 
00064     void setPixmap( const KoPictureKey & key ) KDE_DEPRECATED;
00065     void setPicture( const KoPictureKey & key );
00066 
00067     void reload( void );
00068 
00069     virtual ObjType getType() const
00070         { return OT_PICTURE; }
00071     virtual QString getTypeString() const
00072         { return i18n("Picture"); }
00073 
00074     virtual QDomDocumentFragment save( QDomDocument& doc, double offset );
00075 
00076     virtual double load(const QDomElement &element);
00077     virtual void loadOasis(const QDomElement &element, KoOasisContext & context, KPrLoadingInfo *info);
00078 
00079     virtual void draw( QPainter *_painter, KoTextZoomHandler*_zoomHandler,
00080                        int /* page */, SelectionMode selectionMode, bool drawContour = FALSE );
00081 
00082     QPixmap getOriginalPixmap();
00083     PictureMirrorType getPictureMirrorType() const { return mirrorType; }
00084     int getPictureDepth() const { return depth; }
00085     bool getPictureSwapRGB() const { return swapRGB; }
00086     bool getPictureGrayscal() const { return grayscal; }
00087     int getPictureBright() const { return bright; }
00088 
00089     ImageEffect getImageEffect() const {return m_effect;}
00090     QVariant getIEParam1() const {return m_ie_par1;}
00091     QVariant getIEParam2() const {return m_ie_par2;}
00092     QVariant getIEParam3() const {return m_ie_par3;}
00093     void setImageEffect(ImageEffect eff) { m_effect = eff; }
00094     void setIEParams(QVariant p1, QVariant p2, QVariant p3) {
00095         m_ie_par1=p1;
00096         m_ie_par2=p2;
00097         m_ie_par3=p3;
00098     }
00099 
00100     void setPictureMirrorType(const PictureMirrorType &_mirrorType) { mirrorType = _mirrorType; }
00101     void setPictureDepth(int _depth) { depth = _depth; }
00102     void setPictureSwapRGB(bool _swapRGB) { swapRGB = _swapRGB; }
00103     void setPictureGrayscal(bool _grayscal) { grayscal = _grayscal; }
00104     void setPictureBright(int _bright) { bright = _bright; }
00105 
00106     KoPicture picture() const { return image;}
00107 
00109     void loadImage( const QString & fileName ) KDE_DEPRECATED;
00110     void loadPicture( const QString & fileName );
00111 
00112     virtual void flip(bool horizontal );
00113 
00114 protected:
00115     virtual const char * getOasisElementName() const;
00116     virtual bool saveOasisObjectAttributes( KPOasisSaveContext &sc ) const;
00117 
00118     KPrPixmapObject() {}
00119 
00120     QPixmap changePictureSettings( QPixmap _tmpPixmap );
00121     virtual void saveOasisPictureElement( KoGenStyle &styleobjectauto ) const;
00122     void loadOasisPictureEffect(KoOasisContext & context );
00123     virtual void fillStyle( KoGenStyle& styleObjectAuto, KoGenStyles& mainStyles ) const;
00124 
00129     void drawShadow( QPainter* _painter,  KoZoomHandler* _zoomHandler);
00130 
00131     QPixmap generatePixmap(KoZoomHandler*_zoomHandler);
00132     QString convertValueToPercent( int val ) const;
00133 
00134     KoPictureCollection *imageCollection;
00135     KoPicture image;
00136 
00137     PictureMirrorType mirrorType, m_cachedMirrorType;
00138     int depth, m_cachedDepth;
00139     bool swapRGB, m_cachedSwapRGB;
00140     bool grayscal, m_cachedGrayscal;
00141     int bright, m_cachedBright;
00142 
00143     //image effect and its params
00144     ImageEffect m_effect, m_cachedEffect;
00145     QVariant m_ie_par1, m_cachedPar1;
00146     QVariant m_ie_par2, m_cachedPar2;
00147     QVariant m_ie_par3, m_cachedPar3;
00148 
00149     QPixmap m_cachedPixmap;
00150     QRect m_cachedRect;
00151 };
00152 
00153 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys