/*************************************************************************** * Copyright (C) 2005 by David Saxton * * david@bluehaze.org * * * * 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. * ***************************************************************************/ #ifndef ICNDOCUMENT_H #define ICNDOCUMENT_H #include "itemdocument.h" class Cells; class CNItem; class CNItemGroup; class Connector; class ECNode; class FlowContainer; class Node; class NodeGroup; typedef TQValueList > ConnectorList; typedef TQValueList > NodeList; typedef TQValueList NodeGroupList; typedef TQValueList > GuardedNodeGroupList; /** @author David Saxton */ class ICNDocument : public ItemDocument { Q_OBJECT public: ICNDocument( const TQString &caption, KTechlab *ktechlab, const char *name ); virtual ~ICNDocument(); enum hit_score { hs_none = 0, hs_connector = 4, hs_item = 1000 }; virtual View *createView( ViewContainer *viewContainer, uint viewAreaId, const char *name = 0l ); /** * Will attempt to create an item with the given id at position p. Some item * (such as PIC/START) have restrictions, and can only have one instance of * themselves on the canvas, and adds the operation to the undo list */ virtual Item* addItem( const TQString &id, const TQPoint &p, bool newItem ); /** * Creates a connector between two nodes, and returns a pointer to it * and adds the operation to the undo list */ Connector* createConnector( const TQString &startNodeId, const TQString &endNodeId, TQPointList *pointList = 0L ); /** * short for casting whatever itemWithID(id) returns */ CNItem* cnItemWithID( const TQString &id ); /** * Returns a pointer to a node on the canvas with the given id, * or NULL if no such node exists */ Node* nodeWithID( const TQString &id ); /** * Returns a pointer to a Connector on the canvas with the given id, * or NULL if no such Connector exists */ Connector* connectorWithID( const TQString &id ); /** * Adds a TQCanvasItem to the delete list to be deleted, * when flushDeleteList() is called */ virtual void appendDeleteList( TQCanvasItem *qcanvasItem ); /** * Permantly deletes all items that have been added to the delete list with * the appendDeleteList( TQCanvasItem *qcanvasItem ) function. */ virtual void flushDeleteList(); /** * Reinherit this function to perform special checks on whether the two * given TQCanvasItems (either nodes or connectors or both) can be * connected together. */ virtual bool canConnect( TQCanvasItem *qcanvasItem1, TQCanvasItem *qcanvasItem2 ) const; virtual void copy(); virtual void selectAll(); virtual bool registerItem( TQCanvasItem *qcanvasItem ); /** * Returns a pointer to the 2-dimension array of ICNDocument cells. */ Cells *cells() const { return m_cells; } /** * Returns true if the cell-reference given by x and y is valid (i.e. * greater than 0, but within the m_cells boundary) */ inline bool isValidCellReference( const uint x, const uint y ) const { return ( xm_leftArrow; } static TQPixmap rightArrow() { return self()->m_rightArrow; } static TQPixmap upArrow() { return self()->m_upArrow; } static TQPixmap downArrow() { return self()->m_downArrow; } protected: DirCursor(); void initCursors(); static DirCursor *m_self; TQPixmap m_leftArrow; TQPixmap m_rightArrow; TQPixmap m_upArrow; TQPixmap m_downArrow; }; #endif