(empty message)
[qanava.git] / src / can / canCanvasView.h
blob4ef363e06aa20bab911771a28dd6288ac60b59a7
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 canCanvasView.h
24 // \author Benoit Autheman (authem_b@epita.fr)
25 // \date 2003 August 13
26 //-----------------------------------------------------------------------------
29 #ifndef canCanvasView_h
30 #define canCanvasView_h
33 // Qanava headers
34 #include "canCanvas.h"
35 #include "canGraphView.h"
38 // STD headers
39 #include <map>
42 // QT headers
43 #include <qobject.h>
44 #include <qcanvas.h>
45 #include <qcursor.h>
48 //-----------------------------------------------------------------------------
49 namespace qan { // ::qan
50 namespace can { // ::qan::can
52 //! Provide a view on a specific canvas and manage user interaction with this canvas.
53 /*!
54 \nosubgrouping
56 class CanvasView : public QCanvasView
58 Q_OBJECT
60 /*! \name CanvasView Constructor/Destructor *///---------------------------
61 //@{
62 public:
64 CanvasView( QCanvas&, QWidget* parent = 0, const char* name = 0, WFlags f = 0 );
65 //@}
66 //---------------------------------------------------------------------
70 /*! \name Tooltip Management *///--------------------------------------
71 //@{
72 signals:
74 void nodeTipped( la::Node* node, QPoint p );
76 void nodeSelected( la::Node* node );
78 protected slots:
80 void tipTimeout( );
82 private:
84 QCanvasItem* _tipItem;
86 QPoint _tipPos;
88 QTimer* _timer;
89 //@}
90 //---------------------------------------------------------------------
94 /*! \name Keyboard Navigation Management *///--------------------------
95 //@{
96 protected:
98 //! Enable or disable keyboard navigation (with arrow keys).
99 void setKeyboardNavigation( bool state );
101 //! Get the current keyboard navigation state.
102 bool getKeyboardNavigation( ) const { return _keyboardNavigation; }
104 virtual void keyPressEvent( QKeyEvent* e );
106 private:
108 //! Keyboard navigation state.
109 bool _keyboardNavigation;
111 //! Keyboard navigation intensity.
112 double _keyboardNavigationIntensity;
113 //@}
114 //---------------------------------------------------------------------
118 /*! \name Mouse Navigation Management *///-----------------------------
119 //@{
120 protected:
122 virtual void contentsMousePressEvent( QMouseEvent* e );
124 virtual void contentsMouseReleaseEvent( QMouseEvent* e );
126 virtual void contentsMouseMoveEvent( QMouseEvent* e );
128 virtual void contentsMouseDoubleClickEvent( QMouseEvent* e );
130 //! Enable or disable canvas dragging by mouse.
131 void setCanvasDrag( bool state ) { _canvasDrag = state; }
133 private:
135 QCanvasItem* _dragItem;
137 QCanvasItem* _currentItem;
139 QPoint _dragStart;
141 bool _mousePressed;
143 QPoint _mousePressedStart;
145 //! Canvas dragging enable state.
146 bool _canvasDrag;
147 //@}
148 //---------------------------------------------------------------------
152 /*! \name Resize and Zoom Management *///------------------------------
153 //@{
154 protected:
156 virtual void viewportResizeEvent( QResizeEvent* e );
158 //! Set the maximum zoom factor that can be sets with the setZoomValue() method.
159 void setZoomMaxFactor( double zoomMaxFactor ) { _zoomMaxFactor = zoomMaxFactor; }
161 public slots:
163 //! Set the current zoom factor value in percents (from 1 to 100, 100 sets the maximum zoom factor).
164 void setZoom( int value );
166 private:
168 //! Maximum zoom factor (default = 2).
169 double _zoomMaxFactor;
170 //@}
171 //---------------------------------------------------------------------
173 } // ::qan::can
174 } // ::qan
175 //-----------------------------------------------------------------------------
178 #endif // canCanvasView_h