/* * Kivio - Visual Modelling and Flowcharting * Copyright (C) 2000-2001 theKompany.com & Dave Marotti * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef __kivio_page_h__ #define __kivio_page_h__ class KivioPage; class KivioView; class KivioMap; class KivioCanvas; class KivioDoc; class KoDocumentEntry; class TQWidget; class TQPainter; class TQDomElement; class KivioLayer; class KoPoint; class DCOPObject; #include #include #include #include #include #include #include #include #include #include "kivio_stencil.h" #include class KivioPainter; class KPrinter; class KivioView; class KoZoomHandler; class KoRect; class KoXmlWriter; class KoStore; class KoGenStyles; #define BORDER_SPACE 1 struct AlignData { enum Align { None, Left, Center, Right, Top, Bottom }; Align v; Align h; bool centerOfPage; }; struct DistributeData { enum Distribute { None, Left, Center, Right, Top, Bottom, Spacing }; enum Extent { Selection, Page }; Distribute v; Distribute h; Extent extent; }; class KIVIO_EXPORT KivioPage : public TQObject { TQ_OBJECT public: KivioPage( KivioMap *_map, const TQString &pageName, const char *_name=0L ); ~KivioPage(); virtual DCOPObject* dcopObject(); TQString pageName()const { return m_strName; } bool setPageName( const TQString& name, bool init = false ); virtual TQDomElement save( TQDomDocument& ); virtual void saveOasis(KoStore* store, KoXmlWriter* docWriter, KoGenStyles* styles); virtual bool loadXML( const TQDomElement& ); bool loadOasis(const TQDomElement& page, KoOasisStyles& oasisStyles); bool isLoading(); bool isHidden()const { return m_bPageHide; } void setHidden(bool hidden) { m_bPageHide=hidden; } void setMap( KivioMap* _map ) { m_pMap = _map; } KivioDoc* doc()const { return m_pDoc; } KivioMap* map()const { return m_pMap; } KivioPage *findPage( const TQString & _name ); void print( TQPainter &painter, KPrinter *_printer ); void update(); int id()const { return m_id; } static KivioPage* find( int _id ); KoPageLayout paperLayout()const { return m_pPageLayout; } void setPaperLayout(const KoPageLayout&); void paintContent( KivioPainter& painter, const TQRect& rect, bool transparent, TQPoint, KoZoomHandler*, bool, bool ); void printContent( KivioPainter& painter, int xdpi = 0, int ydpi = 0 ); void printSelected( KivioPainter& painter, int xdpi = 0, int ydpi = 0 ); void printContent(KivioPainter& painter, KoZoomHandler* zoomHandler); bool isStencilSelected( KivioStencil * ); void selectAllStencils(); void unselectAllStencils(); bool unselectStencil( KivioStencil * ); void selectStencil( KivioStencil * ); void selectStencils( double, double, double, double ); TQPtrList *selectedStencils() { return &m_lstSelection; } bool checkForStencilTypeInSelection(KivioStencilType type); bool checkForTextBoxesInSelection(); KoRect getRectForAllSelectedStencils(); KoRect getRectForAllStencils(); int generateStencilIds( int ); KivioStencil *checkForStencil( KoPoint *, int *, double, bool); KivioLayer *curLayer()const { return m_pCurLayer; } void setCurLayer( KivioLayer *pLayer ) { m_pCurLayer=pLayer; } TQPtrList *layers() { return &m_lstLayers; } KivioLayer *firstLayer(); KivioLayer *nextLayer(); KivioLayer *lastLayer(); KivioLayer *prevLayer(); bool removeCurrentLayer(); void addLayer( KivioLayer * ); void insertLayer( int, KivioLayer * ); KivioLayer *layerAt( int ); void takeLayer( KivioLayer *pLayer ); /* * Stencil routines */ bool addStencil( KivioStencil * ); void alignStencils( AlignData ); void distributeStencils( DistributeData ); KivioConnectorTarget *connectPointToTarget( KivioConnectorPoint *, double ); KoPoint snapToTarget( const KoPoint& p, double thresh, bool& hit ); void setHidePage(bool _hide); TQValueList horizontalGuideLines() const { return m_hGuideLines; } TQValueList verticalGuideLines() const { return m_vGuideLines; } public slots: void deleteSelectedStencils(); void groupSelectedStencils(); void ungroupSelectedStencils(); void bringToFront(); void sendToBack(); void copy(); void cut(); void paste(KivioView* view); void setPaintSelected(bool paint = true); void setGuideLines(const TQValueList hGuideLines, const TQValueList vGuideLines); void addGuideLine(TQt::Orientation orientation, double position); signals: void sig_updateView( KivioPage *_page ); void sig_updateView( KivioPage *_page, const TQRect& ); void sig_nameChanged( KivioPage* page, const TQString& old_name ); void sig_PageHidden(KivioPage *_page); void sig_PageShown(KivioPage *_page); void sig_pageLayoutChanged(const KoPageLayout&); protected: void printPage( TQPainter &_painter, const TQRect& page_range, const TQRect& view ); TQDomElement saveLayout( TQDomDocument & ); bool loadLayout( const TQDomElement & ); void saveGuideLines(TQDomElement& element); void loadGuideLines(const TQDomElement& element); TQString m_strName; KivioMap *m_pMap; KivioDoc *m_pDoc; TQPtrList m_lstLayers; KivioLayer *m_pCurLayer; TQPtrList m_lstSelection; int m_id; bool m_bPageHide; static int s_id; static TQIntDict* s_mapPages; KoPageLayout m_pPageLayout; DCOPObject* m_dcop; TQValueList m_hGuideLines; TQValueList m_vGuideLines; }; #endif