summaryrefslogtreecommitdiffstats
path: root/kpresenter/KPrPixmapObject.h
blob: 4534af09a598641b3b5de5ecb83f7c0d176312ef (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
/* This file is part of the KDE project
   Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
   Copyright (C) 2005 Thorsten Zachmann <zachmann@kde.org>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library 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
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
*/

// ### TODO: fix copyright date/authors

#ifndef kppixmapobject_h
#define kppixmapobject_h

#include <tqdatetime.h>
#include <tqvariant.h>

#include "KPrObject.h"
#include <KoPictureCollection.h>
#include <KoSize.h>

class TQPixmap;

// ### TODO rename the class (and the related files/classes) to a better name (for example KPPictureObject)

class KPrPixmapObject : public KPr2DObject
{

public:
    KPrPixmapObject( KoPictureCollection *_imageCollection );
    KPrPixmapObject( KoPictureCollection *_imageCollection, const KoPictureKey & key );
    virtual ~KPrPixmapObject() {}

    KPrPixmapObject &operator=( const KPrPixmapObject & );

    virtual DCOPObject* dcopObject();

    /**
     * Only used as a default value in the filedialog, in changePicture
     * \warning Do not use for anything else
     */
    TQString getFileName() const
        { return image.getKey().filename(); }

    KoPictureKey getKey() const
        { return image.getKey(); }

    TQSize originalSize() const
        { return image.getOriginalSize(); }

    /// Deprecated, please use KPrPixmapObject::setPicture
    void setPixmap( const KoPictureKey & key ) KDE_DEPRECATED;
    void setPicture( const KoPictureKey & key );

    void reload( void );

    virtual ObjType getType() const
        { return OT_PICTURE; }
    virtual TQString getTypeString() const
        { return i18n("Picture"); }

    virtual TQDomDocumentFragment save( TQDomDocument& doc, double offset );

    virtual double load(const TQDomElement &element);
    virtual void loadOasis(const TQDomElement &element, KoOasisContext & context, KPrLoadingInfo *info);

    virtual void draw( TQPainter *_painter, KoTextZoomHandler*_zoomHandler,
                       int /* page */, SelectionMode selectionMode, bool drawContour = FALSE );

    TQPixmap getOriginalPixmap();
    PictureMirrorType getPictureMirrorType() const { return mirrorType; }
    int getPictureDepth() const { return depth; }
    bool getPictureSwapRGB() const { return swapRGB; }
    bool getPictureGrayscal() const { return grayscal; }
    int getPictureBright() const { return bright; }

    ImageEffect getImageEffect() const {return m_effect;}
    TQVariant getIEParam1() const {return m_ie_par1;}
    TQVariant getIEParam2() const {return m_ie_par2;}
    TQVariant getIEParam3() const {return m_ie_par3;}
    void setImageEffect(ImageEffect eff) { m_effect = eff; }
    void setIEParams(TQVariant p1, TQVariant p2, TQVariant p3) {
        m_ie_par1=p1;
        m_ie_par2=p2;
        m_ie_par3=p3;
    }

    void setPictureMirrorType(const PictureMirrorType &_mirrorType) { mirrorType = _mirrorType; }
    void setPictureDepth(int _depth) { depth = _depth; }
    void setPictureSwapRGB(bool _swapRGB) { swapRGB = _swapRGB; }
    void setPictureGrayscal(bool _grayscal) { grayscal = _grayscal; }
    void setPictureBright(int _bright) { bright = _bright; }

    KoPicture picture() const { return image;}

    /// Deprecated, please use KPrPixmapObject::loadPicture
    void loadImage( const TQString & fileName ) KDE_DEPRECATED;
    void loadPicture( const TQString & fileName );

    virtual void flip(bool horizontal );

protected:
    virtual const char * getOasisElementName() const;
    virtual bool saveOasisObjectAttributes( KPOasisSaveContext &sc ) const;

    KPrPixmapObject() {}

    TQPixmap changePictureSettings( TQPixmap _tmpPixmap );
    virtual void saveOasisPictureElement( KoGenStyle &styleobjectauto ) const;
    void loadOasisPictureEffect(KoOasisContext & context );
    virtual void fillStyle( KoGenStyle& styleObjectAuto, KoGenStyles& mainStyles ) const;

    /**
     * @internal
     * Draws the shadow
     */
    void drawShadow( TQPainter* _painter,  KoZoomHandler* _zoomHandler);

    TQPixmap generatePixmap(KoZoomHandler*_zoomHandler);
    TQString convertValueToPercent( int val ) const;

    KoPictureCollection *imageCollection;
    KoPicture image;

    PictureMirrorType mirrorType, m_cachedMirrorType;
    int depth, m_cachedDepth;
    bool swapRGB, m_cachedSwapRGB;
    bool grayscal, m_cachedGrayscal;
    int bright, m_cachedBright;

    //image effect and its params
    ImageEffect m_effect, m_cachedEffect;
    TQVariant m_ie_par1, m_cachedPar1;
    TQVariant m_ie_par2, m_cachedPar2;
    TQVariant m_ie_par3, m_cachedPar3;

    TQPixmap m_cachedPixmap;
    TQRect m_cachedRect;
};

#endif