(empty message)
[qanava.git] / src / can / canItemImpl.h
blob41b95b0a7456df357dd7f428293f982575548228
1 /*
2 Qanava - Graph drawing library for QT
3 Copyright (C) 2005 Benoit AUTHEMAN
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.
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.
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.
20 //-----------------------------------------------------------------------------
21 // This file is a part of the Qanava software.
23 // \file canItemImpl.h
24 // \author Benoit Autheman (benoit@faktiss.net)
25 // \date 2003 August 05
26 //-----------------------------------------------------------------------------
29 #ifndef canItemImpl_h
30 #define canItemImpl_h
33 // Qanava headers
34 #include "canItem.h"
37 //-----------------------------------------------------------------------------
38 namespace qan { // ::qan
39 namespace can { // ::qan::can
41 //! Model a concrete element on a canvas, implemented as QCanvasItem subclasse.
42 /*!
43 <p>The concrete QCanvasItem class type is given as this class parameter (either QCanvasPolygon or
44 QCanvasRectangle for example). This class connect the abstract Qanava can::Item classe to a
45 concrete QCanvasItem graphical object.</p>
47 <p>Coherency between the QT interface (methods from QCanvasItem) and the can::Item one is
48 maintained by ItemImpl, and the two interfaces can be used simultaneously to move the item or
49 get its position.</p>
51 \sa can::Item
52 \nosubgrouping
54 template < class CanvasItem >
55 class ItemImpl : public Item, public CanvasItem
57 /*! \name Item Constructor/Destructor *///-----------------
58 //@{
59 public:
61 //! Item constructor.
62 ItemImpl( ID id, Canvas& canvas );
64 //! Item virtual destructor.
65 virtual ~ItemImpl( ) { }
66 //@}
67 //-----------------------------------------------------------------
71 /*! \name Sub items management *///-------------------------------
72 //@{
73 public:
75 //! Resize the canvas of this item to ensure that the canvas is large enought to contain the item bounding rectangle.
76 void refreshCanvasSize( );
78 //! Hide an item.
79 virtual void hideItem( );
81 //! Show an item that has previously been hidden.
82 virtual void showItem( );
84 //! Move this item (but not the hierarcy of sub items).
85 virtual void moveItem( double x, double y );
87 //! Move this item and its hierarchy of sub item by a position delta.
88 virtual void moveItemBy( double dx, double dy );
90 //! Get this item hierarchy bounding rectangle.
91 QRect getBoundingRect( ) const;
93 //! Move this item but not its sub items.
94 virtual void move( double x, double y );
96 //! Move this item of delta[x/y] and its sub items.
97 virtual void moveBy( double dx, double dy );
99 //! Update the node according to the given style.
100 virtual void updateStyle( const AdvStyle& ) { }
102 protected:
104 //! Get the item canvas.
105 Canvas& getCanvas( ) { return _canvas; }
107 private:
109 //! Item canvas.
110 Canvas& _canvas;
111 //@}
112 //-----------------------------------------------------------------
115 #include "canItemImpl.hpp"
117 } // ::qan::can
118 } // ::qan
119 //-----------------------------------------------------------------------------
121 #endif // canItem_h