KiCad PCB EDA Suite
wx_view_controls.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2012 Torsten Hueter, torstenhtr <at> gmx.de
5  * Copyright (C) 2013 CERN
6  * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
31 #ifndef __WX_VIEW_CONTROLS_H
32 #define __WX_VIEW_CONTROLS_H
33 
34 #include <wx/wx.h>
35 
36 #include <view/view_controls.h>
37 
38 class EDA_DRAW_PANEL_GAL;
39 
40 namespace KIGFX
41 {
46 class WX_VIEW_CONTROLS : public VIEW_CONTROLS, public wxEvtHandler
47 {
48 public:
49  WX_VIEW_CONTROLS( VIEW* aView, wxScrolledCanvas* aParentPanel );
51  {}
52 
54  void onWheel( wxMouseEvent& aEvent );
55  void onMotion( wxMouseEvent& aEvent );
56 #if wxCHECK_VERSION( 3, 1, 0 ) || defined( USE_OSX_MAGNIFY_EVENT )
57  void onMagnify( wxMouseEvent& aEvent );
58 #endif
59  void onButton( wxMouseEvent& aEvent );
60  void onEnter( wxMouseEvent& WXUNUSED( aEvent ) );
61  void onLeave( wxMouseEvent& WXUNUSED( aEvent ) );
62  void onTimer( wxTimerEvent& WXUNUSED( aEvent ) );
63  void onScroll( wxScrollWinEvent& aEvent );
64 
71  void SetGrabMouse( bool aEnabled ) override;
72 
80  VECTOR2I GetMousePosition() const override;
82 
84  VECTOR2D GetCursorPosition() const override;
85 
87  void WarpCursor( const VECTOR2D& aPosition, bool aWorldCoordinates = false,
88  bool aWarpView = false ) const override;
89 
91  void CenterOnCursor() const override;
92 
94  void UpdateScrollbars();
95 
98  static const wxEventType EVT_REFRESH_MOUSE;
99 
100 private:
102  enum STATE
103  {
104  IDLE = 1,
107  };
108 
117  bool handleAutoPanning( const wxMouseEvent& aEvent );
118 
121 
123  wxScrolledCanvas* m_parentPanel;
124 
127 
130 
133 
135  wxLongLong m_timeStamp;
136 
138  wxTimer m_panTimer;
139 
142 
145 };
146 } // namespace KIGFX
147 
148 #endif
VECTOR2D m_lookStartPoint
Stores information about the center of viewport when dragging has started.
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:56
static const wxEventType EVT_REFRESH_MOUSE
Event that forces mouse move event in the dispatcher (eg.
Class WX_VIEW_CONTROLS is a specific implementation of class VIEW_CONTROLS for wxWidgets library...
VIEW_CONTROLS class definition.
void onButton(wxMouseEvent &aEvent)
VECTOR2I GetMousePosition() const override
Function SetAutoPan() Enables/disables autopanning (panning when mouse cursor reaches the panel borde...
VECTOR2D GetCursorPosition() const override
Function GetCursorPosition() Returns the current cursor position in world coordinates.
VECTOR2D m_scrollScale
Ratio used for scaling world coordinates to scrollbar position.
void UpdateScrollbars()
Adjusts the scrollbars position to match the current viewport.
void onWheel(wxMouseEvent &aEvent)
Handler functions.
Panning with mouse button pressed.
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
Definition: view_controls.h:94
STATE
Possible states for WX_VIEW_CONTROLS.
void SetGrabMouse(bool aEnabled) override
Function SetGrabMouse() Enables/disables mouse cursor grabbing (limits the movement field only to the...
void onMotion(wxMouseEvent &aEvent)
wxScrolledCanvas * m_parentPanel
Panel that is affected by VIEW_CONTROLS.
void onTimer(wxTimerEvent &WXUNUSED(aEvent))
VECTOR2D m_panDirection
Current direction of panning (only autopanning mode)
VECTOR2I m_scrollPos
Current scrollbar position.
WX_VIEW_CONTROLS(VIEW *aView, wxScrolledCanvas *aParentPanel)
void WarpCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false) const override
bool handleAutoPanning(const wxMouseEvent &aEvent)
Function handleAutoPanning() Computes new viewport settings while in autopanning mode.
void onEnter(wxMouseEvent &WXUNUSED(aEvent))
VECTOR2D m_dragStartPoint
Stores information about point where dragging has started.
STATE m_state
Current state of VIEW_CONTROLS.
wxLongLong m_timeStamp
Used for determining time intervals between scroll & zoom events.
Class VIEW.
Definition: view.h:58
void CenterOnCursor() const override
Function CenterOnCursor() Sets the viewport center to the current cursor position and warps the curso...
void onScroll(wxScrollWinEvent &aEvent)
void onLeave(wxMouseEvent &WXUNUSED(aEvent))
wxTimer m_panTimer
Timer repsonsible for handling autopanning.