kivio

kivio_page.h

00001 /*
00002  * Kivio - Visual Modelling and Flowcharting
00003  * Copyright (C) 2000-2001 theKompany.com & Dave Marotti
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018  */
00019 #ifndef __kivio_page_h__
00020 #define __kivio_page_h__
00021 
00022 class KivioPage;
00023 class KivioView;
00024 class KivioMap;
00025 class KivioCanvas;
00026 class KivioDoc;
00027 class KoDocumentEntry;
00028 
00029 class QWidget;
00030 class QPainter;
00031 class QDomElement;
00032 
00033 class KivioLayer;
00034 class KoPoint;
00035 class DCOPObject;
00036 
00037 #include <KoDocument.h>
00038 
00039 #include <qpen.h>
00040 #include <qptrlist.h>
00041 #include <qintdict.h>
00042 #include <qmemarray.h>
00043 #include <qrect.h>
00044 #include <qpalette.h>
00045 #include <qwidget.h>
00046 #include <KoPoint.h>
00047 
00048 #include "kivio_stencil.h"
00049 #include <koffice_export.h>
00050 class KivioPainter;
00051 class KPrinter;
00052 class KivioView;
00053 class KoZoomHandler;
00054 class KoRect;
00055 class KoXmlWriter;
00056 class KoStore;
00057 class KoGenStyles;
00058 
00059 #define BORDER_SPACE 1
00060 
00061 struct AlignData
00062 {
00063   enum Align { None, Left, Center, Right, Top, Bottom };
00064   Align v;
00065   Align h;
00066   bool centerOfPage;
00067 };
00068 
00069 struct DistributeData
00070 {
00071   enum Distribute { None, Left, Center, Right, Top, Bottom, Spacing };
00072   enum Extent { Selection, Page };
00073   Distribute v;
00074   Distribute h;
00075   Extent extent;
00076 };
00077 
00078 class KIVIO_EXPORT KivioPage : public QObject
00079 {
00080   Q_OBJECT
00081   public:
00082     KivioPage( KivioMap *_map, const QString &pageName,  const char *_name=0L );
00083     ~KivioPage();
00084 
00085     virtual DCOPObject* dcopObject();
00086 
00087     QString pageName()const { return m_strName; }
00088     bool setPageName( const QString& name, bool init = false );
00089 
00090     virtual QDomElement save( QDomDocument& );
00091     virtual void saveOasis(KoStore* store, KoXmlWriter* docWriter, KoGenStyles* styles);
00092     virtual bool loadXML( const QDomElement& );
00093     bool loadOasis(const QDomElement& page, KoOasisStyles& oasisStyles);
00094     bool isLoading();
00095     
00096     bool isHidden()const { return m_bPageHide; }
00097     void setHidden(bool hidden) { m_bPageHide=hidden; }
00098 
00099     void setMap( KivioMap* _map ) { m_pMap = _map; }
00100 
00101     KivioDoc* doc()const { return m_pDoc; }
00102     KivioMap* map()const { return m_pMap; }
00103 
00104     KivioPage *findPage( const QString & _name );
00105 
00106     void print( QPainter &painter, KPrinter *_printer );
00107     void update();
00108     int id()const { return m_id; }
00109     static KivioPage* find( int _id );
00110 
00111     KoPageLayout paperLayout()const { return m_pPageLayout; }
00112     void setPaperLayout(const KoPageLayout&);
00113 
00114     void paintContent( KivioPainter& painter, const QRect& rect, bool transparent, QPoint, KoZoomHandler*, bool, bool );
00115     void printContent( KivioPainter& painter, int xdpi = 0, int ydpi = 0 );
00116     void printSelected( KivioPainter& painter, int xdpi = 0, int ydpi = 0 );
00117     void printContent(KivioPainter& painter, KoZoomHandler* zoomHandler);
00118 
00119     bool isStencilSelected( KivioStencil * );
00120     void selectAllStencils();
00121     void unselectAllStencils();
00122     bool unselectStencil( KivioStencil * );
00123     void selectStencil( KivioStencil * );
00124     void selectStencils( double, double, double, double );
00125     QPtrList<KivioStencil> *selectedStencils() { return &m_lstSelection; }
00126     bool checkForStencilTypeInSelection(KivioStencilType type);
00127     bool checkForTextBoxesInSelection();
00128 
00129     KoRect getRectForAllSelectedStencils();
00130     KoRect getRectForAllStencils();
00131 
00132     int generateStencilIds( int );
00133 
00134     KivioStencil *checkForStencil( KoPoint *, int *, double, bool);
00135 
00136 
00137     KivioLayer *curLayer()const { return m_pCurLayer; }
00138     void setCurLayer( KivioLayer *pLayer ) { m_pCurLayer=pLayer; }
00139 
00140     QPtrList<KivioLayer> *layers() { return &m_lstLayers; }
00141     KivioLayer *firstLayer();
00142     KivioLayer *nextLayer();
00143     KivioLayer *lastLayer();
00144     KivioLayer *prevLayer();
00145     bool removeCurrentLayer();
00146     void addLayer( KivioLayer * );
00147     void insertLayer( int, KivioLayer * );
00148     KivioLayer *layerAt( int );
00149     void takeLayer( KivioLayer *pLayer );
00150 
00151     /*
00152     * Stencil routines
00153     */
00154     bool addStencil( KivioStencil * );
00155     void alignStencils( AlignData );
00156     void distributeStencils( DistributeData );
00157 
00158     KivioConnectorTarget *connectPointToTarget( KivioConnectorPoint *, double );
00159     KoPoint snapToTarget( const KoPoint& p, double thresh, bool& hit );
00160 
00161     void setHidePage(bool _hide);
00162 
00163     QValueList<double> horizontalGuideLines() const { return m_hGuideLines; }
00164     QValueList<double> verticalGuideLines() const { return m_vGuideLines; }
00165 
00166   public slots:
00167     void deleteSelectedStencils();
00168     void groupSelectedStencils();
00169     void ungroupSelectedStencils();
00170 
00171     void bringToFront();
00172     void sendToBack();
00173 
00174     void copy();
00175     void cut();
00176     void paste(KivioView* view);
00177     
00178     void setPaintSelected(bool paint = true);
00179 
00180     void setGuideLines(const QValueList<double> hGuideLines, const QValueList<double> vGuideLines);
00181     void addGuideLine(Qt::Orientation orientation, double position);
00182 
00183   signals:
00184     void sig_updateView( KivioPage *_page );
00185     void sig_updateView( KivioPage *_page, const QRect& );
00186     void sig_nameChanged( KivioPage* page, const QString& old_name );
00187 
00188     void sig_PageHidden(KivioPage *_page);
00189     void sig_PageShown(KivioPage *_page);
00190 
00191     void sig_pageLayoutChanged(const KoPageLayout&);
00192 
00193   protected:
00194     void printPage( QPainter &_painter, const QRect& page_range, const QRect& view );
00195 
00196     QDomElement saveLayout( QDomDocument & );
00197     bool loadLayout( const QDomElement & );
00198 
00199     void saveGuideLines(QDomElement& element);
00200     void loadGuideLines(const QDomElement& element);
00201 
00202     QString m_strName;
00203 
00204     KivioMap *m_pMap;
00205     KivioDoc *m_pDoc;
00206 
00207     QPtrList<KivioLayer> m_lstLayers;
00208     KivioLayer *m_pCurLayer;
00209 
00210     QPtrList<KivioStencil> m_lstSelection;
00211 
00212     int m_id;
00213     bool m_bPageHide;
00214     static int s_id;
00215     static QIntDict<KivioPage>* s_mapPages;
00216 
00217     KoPageLayout m_pPageLayout;
00218 
00219     DCOPObject* m_dcop;
00220 
00221     QValueList<double> m_hGuideLines;
00222     QValueList<double> m_vGuideLines;
00223 };
00224 
00225 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys