lib

KoPicture.h
1/* This file is part of the KDE project
2 Copyright (c) 2001 Simon Hausmann <hausmann@kde.org>
3 Copyright (C) 2002, 2003, 2004 Nicolas GOUTTE <goutte@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#ifndef __koPicture_h__
21#define __koPicture_h__
22
23#include <tqstring.h>
24#include <tqiodevice.h>
25#include <tqpixmap.h>
26#include <koffice_export.h>
27
28#include "KoPictureKey.h"
29
30class KoXmlWriter;
31class TQPainter;
32class TQSize;
33class TQDragObject;
34class KURL;
35
36class KoPictureShared;
37
43class KOFFICECORE_EXPORT KoPicture
44{
45public:
49 KoPicture(void);
50
54 ~KoPicture(void);
55
59 KoPicture(const KoPicture &other);
60
64 KoPicture& operator=(const KoPicture& other);
65
66 KoPictureType::Type getType(void) const;
67
71 KoPictureKey getKey(void) const;
72
76 void setKey(const KoPictureKey& key);
77
81 bool isNull(void) const;
82
97 void draw(TQPainter& painter, int x, int y, int width, int height, int sx = 0, int sy = 0,
98 int sw = -1, int sh = -1, bool fastMode = false);
99
106 TQDragObject* dragObject( TQWidget *dragSource = 0L, const char *name = 0L );
107
108 bool load(TQIODevice* io, const TQString& extension);
109
114 bool save(TQIODevice* io) const;
115
126 bool saveAsBase64( KoXmlWriter& writer ) const;
127
131 TQString getExtension(void) const;
132
136 TQString getMimeType(void) const;
137
141 TQSize getOriginalSize(void) const;
142
148 void clearAndSetMode(const TQString& newMode);
149
153 void clear(void);
154
158 bool loadFromFile(const TQString& fileName);
159
163 bool loadFromBase64(const TQCString& str);
164
168 bool loadXpm(TQIODevice* io);
169
176 TQPixmap generatePixmap(const TQSize& size, bool smoothScale = false);
177
186 bool setKeyAndDownloadPicture(const KURL& url, TQWidget *window);
187
194 TQImage generateImage(const TQSize& size);
195
199 bool hasAlphaBuffer() const;
200
204 void setAlphaBuffer(bool enable);
205
212 TQImage createAlphaMask(int conversion_flags = 0) const;
213
220 void clearCache(void);
221
222 TQString uniquePictureId() const;
223 void assignPictureId( uint _id);
224
225protected:
230 void unlinkSharedData(void);
235 void linkSharedData(void) const;
240 void createSharedData(void);
241 TQString uniqueName() const;
242
243protected:
248 KoPictureKey m_key;
253 KoPictureShared* m_sharedData;
254 static uint uniqueValue;
255
256 TQString m_uniqueName;
257};
258
259#endif /* __koPicture_h__ */
KoPictureKey is the structure describing a picture in a unique way.
TQString getExtension(void) const
bool setKeyAndDownloadPicture(const KURL &url, TQWidget *window)
Download and set the key for a possibly remote file.
bool saveAsBase64(KoXmlWriter &writer) const
OASIS FlatXML support: Save picture as base64-encoded data into an XML writer.
bool loadFromBase64(const TQCString &str)
Load the picture from base64-encoded data.
void clear(void)
Reset the KoPicture (but not the key!).
TQString getMimeType(void) const
void setKey(const KoPictureKey &key)
Set the key structure describing the picture in a unique way.
bool loadFromFile(const TQString &fileName)
Load the picture from a file named fileName.
void clearAndSetMode(const TQString &newMode)
Clear and set the mode of this KoPicture.
bool isNull(void) const
Returns true if the picture is null.
TQSize getOriginalSize(void) const
void clearCache(void)
Clear any cache.
bool save(TQIODevice *io) const
Save picture into a TQIODevice.
void draw(TQPainter &painter, int x, int y, int width, int height, int sx=0, int sy=0, int sw=-1, int sh=-1, bool fastMode=false)
Draw the picture in a painter.
bool loadXpm(TQIODevice *io)
Load a potentially broken XPM file (for old files of KPresenter).
TQPixmap generatePixmap(const TQSize &size, bool smoothScale=false)
KoPictureKey getKey(void) const
Retrieve the key structure describing the picture in a unique way.
KoPicture & operator=(const KoPicture &other)
Assignment operator.
Definition KoPicture.cpp:71
void setAlphaBuffer(bool enable)
Respect the image alpha buffer.
bool hasAlphaBuffer() const
TQDragObject * dragObject(TQWidget *dragSource=0L, const char *name=0L)
Create a dragobject containing this picture.
TQImage generateImage(const TQSize &size)
Generate a TQImage (always in slow mode).
TQImage createAlphaMask(int conversion_flags=0) const
Creates an alpha mask for the picture (first you have to call setAlphaBuffer).
KoPicture(void)
Default constructor.
Definition KoPicture.cpp:36
A class for writing out XML (to any TQIODevice), with a special attention on performance.
Definition KoXmlWriter.h:37