chalk

kis_doc.h
1/*
2 * Copyright (c) 1999-2000 Matthias Elter <me@kde.org>
3 * Copyright (c) 2001 Toshitaka Fujioka <fujioka@kde.org>
4 * Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20#ifndef KIS_DOC_H_
21#define KIS_DOC_H_
22
23#include <kdebug.h>
24
25#include <KoDocument.h>
26
27#include "kis_types.h"
28#include "kis_undo_adapter.h"
29
30#include <koffice_export.h>
31
32class TQImage;
33class TQString;
34
35class DCOPObject;
36class KCommand;
37
38class KoCommandHistory;
39class KMacroCommand;
40
41class KisProfile;
42class KisView;
43class KisNameServer;
44class KisChildDoc;
45class KisColorSpace;
46class KisColor;
47class KisCompositeOp;
48
49class KRITACORE_EXPORT KisDoc : public KoDocument, private KisUndoAdapter {
50
51 typedef KoDocument super;
52 TQ_OBJECT
53
54
55public:
56 KisDoc(TQWidget *parentWidget = 0, const char *widgetName = 0, TQObject* parent = 0, const char* name = 0, bool singleViewMode = false);
57 virtual ~KisDoc();
58
59public:
60 // Overide KoDocument
61 virtual bool wantExportConfirmation() const { return false; };
62 virtual bool completeLoading(KoStore *store);
63 virtual bool completeSaving(KoStore*);
64 virtual DCOPObject* dcopObject();
65 virtual bool initDoc(InitDocFlags flags, TQWidget* parentWidget=0);
66 virtual bool loadOasis( const TQDomDocument&, KoOasisStyles&, const TQDomDocument&, KoStore* );
67 virtual bool saveOasis( KoStore*, KoXmlWriter* );
68 virtual bool loadChildren( KoStore* store);
69 virtual bool loadXML(TQIODevice *, const TQDomDocument& doc);
70 virtual TQCString mimeType() const;
71 virtual TQWidget* createCustomDocumentWidget(TQWidget *parent);
72 virtual KoDocument* hitTest(const TQPoint &pos, const TQWMatrix& matrix = TQWMatrix());
73
81 virtual void paintContent(TQPainter& painter, const TQRect& rect, bool /*transparent*/, double /*zoomX*/, double /*zoomY*/);
82
83 virtual TQDomDocument saveXML();
84
85public slots:
86
87
92 virtual void initEmpty();
93
94private: // Undo adapter
95
96 virtual void setCommandHistoryListener(const KisCommandHistoryListener *);
97 virtual void removeCommandHistoryListener(const KisCommandHistoryListener *);
98
99 virtual KCommand * presentCommand();
100 virtual void addCommand(KCommand *cmd);
101 virtual void setUndo(bool undo);
102 virtual bool undo() const;
103 virtual void beginMacro(const TQString& macroName);
104 virtual void endMacro();
105
106
107public:
108
109
110 TQ_INT32 undoLimit() const;
111 void setUndoLimit(TQ_INT32 limit);
112
113 TQ_INT32 redoLimit() const;
114 void setRedoLimit(TQ_INT32 limit);
115
120 bool newImage(const TQString& name, TQ_INT32 width, TQ_INT32 height, KisColorSpace * cs, const KisColor &bgColor, const TQString &imgDescription, const double imgResolution);
121
126 KisImageSP newImage(const TQString& name, TQ_INT32 width, TQ_INT32 height, KisColorSpace * colorstrategy);
127
128 void renameImage(const TQString& oldName, const TQString& newName);
129
130
136 KisChildDoc * createChildDoc( const TQRect& rect, KoDocument* childDoc );
137
141 void prepareForImport();
142
143 KisImageSP currentImage();
144
148 void setCurrentImage(KisImageSP image);
149
150 KisUndoAdapter * undoAdapter() { return this; }
151
152public slots:
153 void slotImageUpdated();
154 void slotImageUpdated(const TQRect& rect);
155 void slotDocumentRestored();
156 void slotCommandExecuted(KCommand *command);
157
158signals:
159 void docUpdated();
160 void docUpdated(TQRect rect);
161 void loadingFinished();
162
163 /*
164 * Emitted every time a command is added to the undo history, or executed
165 * due to an undo or redo action.
166 */
167 void sigCommandExecuted();
168
169protected:
170 // Overide KoDocument
171 virtual KoView* createViewInstance(TQWidget *parent, const char *name);
172
173protected slots:
174 // Overide KoDocument
175 virtual void openExistingFile(const TQString& file);
176 virtual void openTemplate(const TQString& file);
177
178private slots:
179 void slotUpdate(KisImageSP img, TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 w, TQ_UINT32 h);
180 void slotIOProgress(TQ_INT8 percentage);
181
182private:
183
184 TQDomElement saveImage(TQDomDocument& doc, KisImageSP img);
185 KisImageSP loadImage(const TQDomElement& elem);
186 void loadLayers(const TQDomElement& element, KisImageSP img, KisGroupLayerSP parent);
187 KisLayerSP loadLayer(const TQDomElement& elem, KisImageSP img);
188 KisLayerSP loadPaintLayer(const TQDomElement& elem, KisImageSP img,
189 TQString name, TQ_INT32 x, TQ_INT32 y, TQ_INT32 opacity, bool visible, bool locked,
190 KisCompositeOp compositeOp);
191 KisGroupLayerSP loadGroupLayer(const TQDomElement& elem, KisImageSP img,
192 TQString name, TQ_INT32 x, TQ_INT32 y, TQ_INT32 opacity, bool visible, bool locked,
193 KisCompositeOp compositeOp);
194 KisAdjustmentLayerSP loadAdjustmentLayer(const TQDomElement& elem, KisImageSP img,
195 TQString name, TQ_INT32 x, TQ_INT32 y, TQ_INT32 opacity, bool visible, bool locked,
196 KisCompositeOp compositeOp);
197 KisPartLayerSP loadPartLayer(const TQDomElement& elem, KisImageSP img,
198 TQString name, TQ_INT32 x, TQ_INT32 y, TQ_INT32 opacity,
199 bool visible, bool locked, KisCompositeOp compositeOp);
200 bool init();
201
202 void setIOSteps(TQ_INT32 nsteps);
203 void IOCompletedStep();
204 void IODone();
205
206private:
207
208 bool m_undo;
209 KoCommandHistory *m_cmdHistory;
210 TQPtrList<KisCommandHistoryListener> m_undoListeners;
211 KisImageSP m_currentImage;
212 DCOPObject *m_dcop;
213 KisNameServer *m_nserver;
214 KMacroCommand *m_currentMacro;
215 TQ_INT32 m_macroNestDepth;
216 TQ_INT32 m_conversionDepth;
217 int m_ioProgressTotalSteps;
218 int m_ioProgressBase;
219 TQMap<KisLayerSP, TQString> m_layerFilenames; // temp storage during load
220
221};
222
223#endif // KIS_DOC_H_
224
The child document is responsible for saving and loading the embedded layers.
A colorspace is the definition of a certain color model in Chalk.
A KisColor describes a color in a certain colorspace.
Definition kis_color.h:33