kivio_page.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_page_h__
20#define __kivio_page_h__
21
22class KivioPage;
23class KivioView;
24class KivioMap;
25class KivioCanvas;
26class KivioDoc;
27class KoDocumentEntry;
28
29class TQWidget;
30class TQPainter;
31class TQDomElement;
32
33class KivioLayer;
34class KoPoint;
35class DCOPObject;
36
37#include <KoDocument.h>
38
39#include <tqpen.h>
40#include <tqptrlist.h>
41#include <tqintdict.h>
42#include <tqmemarray.h>
43#include <tqrect.h>
44#include <tqpalette.h>
45#include <tqwidget.h>
46#include <KoPoint.h>
47
48#include "kivio_stencil.h"
49#include <koffice_export.h>
50class KivioPainter;
51class KPrinter;
52class KivioView;
53class KoZoomHandler;
54class KoRect;
55class KoXmlWriter;
56class KoStore;
57class KoGenStyles;
58
59#define BORDER_SPACE 1
60
61struct AlignData
62{
63 enum Align { None, Left, Center, Right, Top, Bottom };
64 Align v;
65 Align h;
66 bool centerOfPage;
67};
68
69struct DistributeData
70{
71 enum Distribute { None, Left, Center, Right, Top, Bottom, Spacing };
72 enum Extent { Selection, Page };
73 Distribute v;
74 Distribute h;
75 Extent extent;
76};
77
78class KIVIO_EXPORT KivioPage : public TQObject
79{
80 TQ_OBJECT
81
82 public:
83 KivioPage( KivioMap *_map, const TQString &pageName, const char *_name=0L );
84 ~KivioPage();
85
86 virtual DCOPObject* dcopObject();
87
88 TQString pageName()const { return m_strName; }
89 bool setPageName( const TQString& name, bool init = false );
90
91 virtual TQDomElement save( TQDomDocument& );
92 virtual void saveOasis(KoStore* store, KoXmlWriter* docWriter, KoGenStyles* styles);
93 virtual bool loadXML( const TQDomElement& );
94 bool loadOasis(const TQDomElement& page, KoOasisStyles& oasisStyles);
95 bool isLoading();
96
97 bool isHidden()const { return m_bPageHide; }
98 void setHidden(bool hidden) { m_bPageHide=hidden; }
99
100 void setMap( KivioMap* _map ) { m_pMap = _map; }
101
102 KivioDoc* doc()const { return m_pDoc; }
103 KivioMap* map()const { return m_pMap; }
104
105 KivioPage *findPage( const TQString & _name );
106
107 void print( TQPainter &painter, KPrinter *_printer );
108 void update();
109 int id()const { return m_id; }
110 static KivioPage* find( int _id );
111
112 KoPageLayout paperLayout()const { return m_pPageLayout; }
113 void setPaperLayout(const KoPageLayout&);
114
115 void paintContent( KivioPainter& painter, const TQRect& rect, bool transparent, TQPoint, KoZoomHandler*, bool, bool );
116 void printContent( KivioPainter& painter, int xdpi = 0, int ydpi = 0 );
117 void printSelected( KivioPainter& painter, int xdpi = 0, int ydpi = 0 );
118 void printContent(KivioPainter& painter, KoZoomHandler* zoomHandler);
119
120 bool isStencilSelected( KivioStencil * );
121 void selectAllStencils();
122 void unselectAllStencils();
123 bool unselectStencil( KivioStencil * );
124 void selectStencil( KivioStencil * );
125 void selectStencils( double, double, double, double );
126 TQPtrList<KivioStencil> *selectedStencils() { return &m_lstSelection; }
127 bool checkForStencilTypeInSelection(KivioStencilType type);
128 bool checkForTextBoxesInSelection();
129
130 KoRect getRectForAllSelectedStencils();
131 KoRect getRectForAllStencils();
132
133 int generateStencilIds( int );
134
135 KivioStencil *checkForStencil( KoPoint *, int *, double, bool);
136
137
138 KivioLayer *curLayer()const { return m_pCurLayer; }
139 void setCurLayer( KivioLayer *pLayer ) { m_pCurLayer=pLayer; }
140
141 TQPtrList<KivioLayer> *layers() { return &m_lstLayers; }
142 KivioLayer *firstLayer();
143 KivioLayer *nextLayer();
144 KivioLayer *lastLayer();
145 KivioLayer *prevLayer();
146 bool removeCurrentLayer();
147 void addLayer( KivioLayer * );
148 void insertLayer( int, KivioLayer * );
149 KivioLayer *layerAt( int );
150 void takeLayer( KivioLayer *pLayer );
151
152 /*
153 * Stencil routines
154 */
155 bool addStencil( KivioStencil * );
156 void alignStencils( AlignData );
157 void distributeStencils( DistributeData );
158
159 KivioConnectorTarget *connectPointToTarget( KivioConnectorPoint *, double );
160 KoPoint snapToTarget( const KoPoint& p, double thresh, bool& hit );
161
162 void setHidePage(bool _hide);
163
164 TQValueList<double> horizontalGuideLines() const { return m_hGuideLines; }
165 TQValueList<double> verticalGuideLines() const { return m_vGuideLines; }
166
167 public slots:
168 void deleteSelectedStencils();
169 void groupSelectedStencils();
170 void ungroupSelectedStencils();
171
172 void bringToFront();
173 void sendToBack();
174
175 void copy();
176 void cut();
177 void paste(KivioView* view);
178
179 void setPaintSelected(bool paint = true);
180
181 void setGuideLines(const TQValueList<double> hGuideLines, const TQValueList<double> vGuideLines);
182 void addGuideLine(TQt::Orientation orientation, double position);
183
184 signals:
185 void sig_updateView( KivioPage *_page );
186 void sig_updateView( KivioPage *_page, const TQRect& );
187 void sig_nameChanged( KivioPage* page, const TQString& old_name );
188
189 void sig_PageHidden(KivioPage *_page);
190 void sig_PageShown(KivioPage *_page);
191
192 void sig_pageLayoutChanged(const KoPageLayout&);
193
194 protected:
195 void printPage( TQPainter &_painter, const TQRect& page_range, const TQRect& view );
196
197 TQDomElement saveLayout( TQDomDocument & );
198 bool loadLayout( const TQDomElement & );
199
200 void saveGuideLines(TQDomElement& element);
201 void loadGuideLines(const TQDomElement& element);
202
203 TQString m_strName;
204
205 KivioMap *m_pMap;
206 KivioDoc *m_pDoc;
207
208 TQPtrList<KivioLayer> m_lstLayers;
209 KivioLayer *m_pCurLayer;
210
211 TQPtrList<KivioStencil> m_lstSelection;
212
213 int m_id;
214 bool m_bPageHide;
215 static int s_id;
216 static TQIntDict<KivioPage>* s_mapPages;
217
218 KoPageLayout m_pPageLayout;
219
220 DCOPObject* m_dcop;
221
222 TQValueList<double> m_hGuideLines;
223 TQValueList<double> m_vGuideLines;
224};
225
226#endif