krita

kis_part_layer.h

00001 /*
00002  *  Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org>
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 #ifndef _KIS_PART_LAYER_
00019 #define _KIS_PART_LAYER_
00020 
00021 #include <qrect.h>
00022 
00023 #include <KoDocument.h>
00024 #include <KoDocumentChild.h>
00025 
00026 #include "kis_paint_layer.h"
00027 #include "kis_types.h"
00028 #include "kis_doc.h"
00029 #include "kis_part_layer_iface.h"
00030 #include "kis_view.h"
00031 #include "kis_layer_visitor.h"
00032 
00033 class KoFrame;
00034 class KoDocument;
00035 
00036 
00040 class KisChildDoc : public KoDocumentChild
00041 {
00042 
00043 public:
00044     KisChildDoc ( KisDoc * kisDoc, const QRect& rect, KoDocument * childDoc );
00045     KisChildDoc ( KisDoc * kisDdoc );
00046 
00047     virtual ~KisChildDoc();
00048 
00049     KisDoc * parent() const { return m_doc; }
00050 
00051     void setPartLayer (KisPartLayerSP layer) { m_partLayer = layer; }
00052 
00053     KisPartLayerSP partLayer() const { return m_partLayer; }
00054 protected:
00055 
00056     KisDoc * m_doc;
00057     KisPartLayerSP m_partLayer;
00058 };
00059 
00060 
00074 class KisPartLayerImpl : public KisPartLayer {
00075     Q_OBJECT
00076     typedef KisPartLayer super;
00077 public:
00078     KisPartLayerImpl(KisImageSP img, KisChildDoc * doc);
00079     virtual ~KisPartLayerImpl();
00080 
00081     virtual KisLayerSP clone() const;
00082 
00084     virtual void activate() {}
00085 
00087     virtual void deactivate() {}
00088 
00090     virtual KisChildDoc* childDoc() const { return m_doc; }
00091 
00092     void setDocType(const QString& type) { m_docType = type; }
00093     QString docType() const { return m_docType; }
00094 
00095     virtual void setX(Q_INT32 x);
00096     virtual void setY(Q_INT32 y);
00097     virtual Q_INT32 x() const { return m_doc->geometry() . x(); }
00098     virtual Q_INT32 y() const { return m_doc->geometry() . y(); } //m_paintLayer->y(); }
00099     virtual QRect extent() const { return m_doc->geometry(); }
00100     virtual QRect exactBounds() const { return m_doc->geometry(); }
00101 
00102     virtual QImage createThumbnail(Q_INT32 w, Q_INT32 h);
00103 
00104     virtual bool accept(KisLayerVisitor& visitor) {
00105         return visitor.visit(this);
00106     }
00107 
00108     virtual KisPaintDeviceSP prepareProjection(KisPaintDeviceSP projection, const QRect& r);
00109 
00110     virtual void paintSelection(QImage &img, Q_INT32 x, Q_INT32 y, Q_INT32 w, Q_INT32 h);
00111 
00112     virtual bool saveToXML(QDomDocument doc, QDomElement elem);
00113 private slots:
00115     //void repaint();
00117     void childActivated(KoDocumentChild* child);
00118     void childDeactivated(bool activated);
00119 
00120 
00121 private:
00122     // KisPaintLayerSP m_paintLayer;
00123     KisPaintDeviceSP m_cache;
00124     KoFrame * m_frame; // The widget that holds the editable view of the embedded part
00125     KisChildDoc * m_doc; // The sub-document
00126     QString m_docType;
00127     bool m_activated;
00128 };
00129 
00133 class KisConnectPartLayerVisitor : public KisLayerVisitor {
00134     KisImageSP m_img;
00135     KisView* m_view;
00136     bool m_connect; // connects, or disconnects signals
00137 public:
00138     KisConnectPartLayerVisitor(KisImageSP img, KisView* view, bool mode);
00139     virtual ~KisConnectPartLayerVisitor() {}
00140 
00141     virtual bool visit(KisPaintLayer *layer);
00142     virtual bool visit(KisGroupLayer *layer);
00143     virtual bool visit(KisPartLayer *layer);
00144     virtual bool visit(KisAdjustmentLayer *layer);
00145 };
00146 
00147 #endif // _KIS_PART_LAYER_
KDE Home | KDE Accessibility Home | Description of Access Keys