chalk

kis_part_layer.h
1/*
2 * Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18#ifndef _KIS_PART_LAYER_
19#define _KIS_PART_LAYER_
20
21#include <tqrect.h>
22
23#include <KoDocument.h>
24#include <KoDocumentChild.h>
25
26#include "kis_paint_layer.h"
27#include "kis_types.h"
28#include "kis_doc.h"
29#include "kis_part_layer_iface.h"
30#include "kis_view.h"
31#include "kis_layer_visitor.h"
32
33class KoFrame;
34class KoDocument;
35
36
40class KisChildDoc : public KoDocumentChild
41{
42
43public:
44 KisChildDoc ( KisDoc * kisDoc, const TQRect& rect, KoDocument * childDoc );
45 KisChildDoc ( KisDoc * kisDdoc );
46
47 virtual ~KisChildDoc();
48
49 KisDoc * parent() const { return m_doc; }
50
51 void setPartLayer (KisPartLayerSP layer) { m_partLayer = layer; }
52
53 KisPartLayerSP partLayer() const { return m_partLayer; }
54protected:
55
56 KisDoc * m_doc;
57 KisPartLayerSP m_partLayer;
58};
59
60
74class KisPartLayerImpl : public KisPartLayer {
75 TQ_OBJECT
76
77 typedef KisPartLayer super;
78public:
79 KisPartLayerImpl(KisImageSP img, KisChildDoc * doc);
80 virtual ~KisPartLayerImpl();
81
82 virtual KisLayerSP clone() const;
83
85 virtual void activate() {}
86
88 virtual void deactivate() {}
89
91 virtual KisChildDoc* childDoc() const { return m_doc; }
92
93 void setDocType(const TQString& type) { m_docType = type; }
94 TQString docType() const { return m_docType; }
95
96 virtual void setX(TQ_INT32 x);
97 virtual void setY(TQ_INT32 y);
98 virtual TQ_INT32 x() const { return m_doc->geometry() . x(); }
99 virtual TQ_INT32 y() const { return m_doc->geometry() . y(); } //m_paintLayer->y(); }
100 virtual TQRect extent() const { return m_doc->geometry(); }
101 virtual TQRect exactBounds() const { return m_doc->geometry(); }
102
103 virtual TQImage createThumbnail(TQ_INT32 w, TQ_INT32 h);
104
105 virtual bool accept(KisLayerVisitor& visitor) {
106 return visitor.visit(this);
107 }
108
109 virtual KisPaintDeviceSP prepareProjection(KisPaintDeviceSP projection, const TQRect& r);
110
111 virtual void paintSelection(TQImage &img, TQ_INT32 x, TQ_INT32 y, TQ_INT32 w, TQ_INT32 h);
112
113 virtual bool saveToXML(TQDomDocument doc, TQDomElement elem);
114private slots:
116 //void repaint();
118 void childActivated(KoDocumentChild* child);
119 void childDeactivated(bool activated);
120
121
122private:
123 // KisPaintLayerSP m_paintLayer;
124 KisPaintDeviceSP m_cache;
125 KoFrame * m_frame; // The widget that holds the editable view of the embedded part
126 KisChildDoc * m_doc; // The sub-document
127 TQString m_docType;
128 bool m_activated;
129};
130
134class KisConnectPartLayerVisitor : public KisLayerVisitor {
135 KisImageSP m_img;
136 KisView* m_view;
137 bool m_connect; // connects, or disconnects signals
138public:
139 KisConnectPartLayerVisitor(KisImageSP img, KisView* view, bool mode);
140 virtual ~KisConnectPartLayerVisitor() {}
141
142 virtual bool visit(KisPaintLayer *layer);
143 virtual bool visit(KisGroupLayer *layer);
144 virtual bool visit(KisPartLayer *layer);
145 virtual bool visit(KisAdjustmentLayer *layer);
146};
147
148#endif // _KIS_PART_LAYER_
Class that contains a KisFilter and optionally a KisSelection.
The child document is responsible for saving and loading the embedded layers.
A KisLayer that bundles child layers into a single layer.
This layer is of a type that can be painted on.
virtual TQRect extent() const
Returns an approximation of where the bounds on actual data are in this layer.
virtual TQImage createThumbnail(TQ_INT32 w, TQ_INT32 h)
Returns a thumbnail in requested size.
virtual KisChildDoc * childDoc() const
Returns the childDoc so that we can access the doc from other places, if need be (KisDoc).
virtual void deactivate()
Called when another layer is made inactive.
virtual TQRect exactBounds() const
Returns the exact bounds of where the actual data resides in this layer.
virtual void activate()
Called when the layer is made active.
virtual bool accept(KisLayerVisitor &visitor)
Accept the KisLayerVisitor (for the Visitor design pattern), should call the correct function on the ...
virtual KisLayerSP clone() const
Return a copy of this layer.
virtual void paintSelection(TQImage &img, TQ_INT32 x, TQ_INT32 y, TQ_INT32 w, TQ_INT32 h)
paints a mask where the selection on this layer resides
An interface for the Part Layer so that we can use it in core/, but can implement it in ui/.