kivio_layer.h
1/*
2 * Kivio - Visual Modelling and Flowcharting
3 * Copyright (C) 2000-2001 theKompany.com & Dave Marotti
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program 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
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19#ifndef KIVIO_LAYER_H
20#define KIVIO_LAYER_H
21
22#include <tqdom.h>
23#include <tqptrlist.h>
24#include <tqobject.h>
25#include <KoPoint.h>
26class KivioConnectorPoint;
27class KivioConnectorTarget;
28class KivioPage;
29class KivioPainter;
30class KoPoint;
31class DCOPObject;
32class KoZoomHandler;
33class TQDomElement;
34class KoStore;
35class KoXmlWriter;
36
37#include "kivio_stencil.h"
38
39#define FLOW_LAYER_VISIBLE 0x0001
40#define FLOW_LAYER_CONNECTABLE 0x0002
41#define FLOW_LAYER_NOT_EDITABLE 0x0004
42#define FLOW_LAYER_NOT_PRINTABLE 0x0008
43
44class KivioLayer
45{
46protected:
47 friend class KivioGroupStencil;
48
49 int m_flags;
50 TQPtrList <KivioStencil> *m_pStencilList;
51 TQPtrList <KivioStencil> *m_pDeletedStencilList;
52 TQString m_name;
53 KivioPage *m_pPage;
54 DCOPObject* m_dcop;
55
56 KivioStencil *loadSMLStencil( const TQDomElement & );
57 KivioStencil *loadGroupStencil( const TQDomElement & );
58 KivioStencil *loadPluginStencil( const TQDomElement & );
59
60
61public:
62 KivioLayer( KivioPage * );
63 virtual ~KivioLayer();
64
65 KivioPage *page()const{return m_pPage;}
66
67 virtual DCOPObject* dcopObject();
68
69 TQPtrList<KivioStencil> *stencilList() { return m_pStencilList; }
70
71 bool visible() { return (m_flags & FLOW_LAYER_VISIBLE); }
72 void setVisible( bool f );
73
74 bool connectable() { return (m_flags & FLOW_LAYER_CONNECTABLE); }
75 void setConnectable( bool f );
76
77 void setEditable(bool f);
78 bool editable() { return !(m_flags & FLOW_LAYER_NOT_EDITABLE); }
79
80 void setPrintable(bool f);
81 bool printable() { return !(m_flags & FLOW_LAYER_NOT_PRINTABLE); }
82
83 TQString name() const { return m_name; }
84 void setName( const TQString &n ) { m_name = TQString(n); }
85
86 bool addStencil( KivioStencil * );
87 bool removeStencil( KivioStencil * );
88
89 bool loadXML( const TQDomElement & );
90 void loadOasis(const TQDomElement& layer);
91 TQDomElement saveXML( TQDomDocument & );
92 void saveOasis(KoXmlWriter* layerWriter);
93
94 KivioStencil *checkForStencil( KoPoint *, int *, float, bool );
95
96 void printContent( KivioPainter& painter, int xdpi = 0, int ydpi = 0 );
97 void printContent(KivioPainter& painter, KoZoomHandler* zoomHandler);
98 void paintContent( KivioPainter& painter, const TQRect& rect, bool transparent, TQPoint p0,
99 KoZoomHandler* zoom );
100 void paintConnectorTargets( KivioPainter& painter, const TQRect& rect, bool transparent,
101 TQPoint p0, KoZoomHandler* zoom );
102 void paintSelectionHandles( KivioPainter& painter, const TQRect& rect, bool transparent,
103 TQPoint p0, KoZoomHandler* zoom );
104
105 KivioStencil *firstStencil() { return m_pStencilList->first(); }
106 KivioStencil *nextStencil() { return m_pStencilList->next(); }
107 KivioStencil *prevStencil() { return m_pStencilList->prev(); }
108 KivioStencil *takeStencil() { return m_pStencilList->take(); }
109 KivioStencil *currentStencil() { return m_pStencilList->current(); }
110 KivioStencil *lastStencil() { return m_pStencilList->last(); }
111
112 KivioStencil *takeStencil( KivioStencil * );
113
114 KivioConnectorTarget *connectPointToTarget( KivioConnectorPoint *, float );
115
116 KoPoint snapToTarget( const KoPoint& p, double thresh, bool& hit );
117
118 int generateStencilIds( int );
119
120 void searchForConnections( KivioPage * );
121 void takeStencilFromList( KivioStencil *pStencil );
122 void insertStencil( KivioStencil *pStencil );
123
124};
125
126#endif
127
128