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
34 #include "canCanvas.h"
35 #include "canGraphView.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.
56 class CanvasView
: public QCanvasView
60 /*! \name CanvasView Constructor/Destructor *///---------------------------
64 CanvasView( QCanvas
&, QWidget
* parent
= 0, const char* name
= 0, WFlags f
= 0 );
66 //---------------------------------------------------------------------
70 /*! \name Tooltip Management *///--------------------------------------
74 void nodeTipped( la::Node
* node
, QPoint p
);
76 void nodeSelected( la::Node
* node
);
84 QCanvasItem
* _tipItem
;
90 //---------------------------------------------------------------------
94 /*! \name Keyboard Navigation Management *///--------------------------
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
);
108 //! Keyboard navigation state.
109 bool _keyboardNavigation
;
111 //! Keyboard navigation intensity.
112 double _keyboardNavigationIntensity
;
114 //---------------------------------------------------------------------
118 /*! \name Mouse Navigation Management *///-----------------------------
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
; }
135 QCanvasItem
* _dragItem
;
137 QCanvasItem
* _currentItem
;
143 QPoint _mousePressedStart
;
145 //! Canvas dragging enable state.
148 //---------------------------------------------------------------------
152 /*! \name Resize and Zoom Management *///------------------------------
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
; }
163 //! Set the current zoom factor value in percents (from 1 to 100, 100 sets the maximum zoom factor).
164 void setZoom( int value
);
168 //! Maximum zoom factor (default = 2).
169 double _zoomMaxFactor
;
171 //---------------------------------------------------------------------
175 //-----------------------------------------------------------------------------
178 #endif // canCanvasView_h