2011-12-29 20:11:42 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1992-2010 <Jean-Pierre Charras>
|
|
|
|
* Copyright (C) 1992-2010 KiCad Developers, see change_log.txt for contributors.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file gerbview/controle.cpp
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <common.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <gerbview.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
void GERBVIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-02-01 15:46:25 +00:00
|
|
|
wxRealPoint gridSize;
|
|
|
|
wxPoint oldpos;
|
|
|
|
wxPoint pos = aPosition;
|
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
pos = GetScreen()->GetNearestGridPosition( pos );
|
2007-09-10 04:51:01 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
oldpos = GetScreen()->GetCrossHairPosition();
|
2011-02-01 15:46:25 +00:00
|
|
|
gridSize = GetScreen()->GetGridSize();
|
2007-10-10 04:45:26 +00:00
|
|
|
|
2011-02-22 16:43:03 +00:00
|
|
|
switch( aHotKey )
|
2007-10-10 04:45:26 +00:00
|
|
|
{
|
2009-11-09 14:00:22 +00:00
|
|
|
case WXK_NUMPAD8:
|
2007-10-10 04:45:26 +00:00
|
|
|
case WXK_UP:
|
2011-02-01 15:46:25 +00:00
|
|
|
pos.y -= wxRound( gridSize.y );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursor( pos );
|
2007-10-10 04:45:26 +00:00
|
|
|
break;
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
case WXK_NUMPAD2:
|
2007-10-10 04:45:26 +00:00
|
|
|
case WXK_DOWN:
|
2011-02-01 15:46:25 +00:00
|
|
|
pos.y += wxRound( gridSize.y );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursor( pos );
|
2007-10-10 04:45:26 +00:00
|
|
|
break;
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
case WXK_NUMPAD4:
|
2007-10-10 04:45:26 +00:00
|
|
|
case WXK_LEFT:
|
2011-02-01 15:46:25 +00:00
|
|
|
pos.x -= wxRound( gridSize.x );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursor( pos );
|
2007-10-10 04:45:26 +00:00
|
|
|
break;
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
case WXK_NUMPAD6:
|
2007-10-10 04:45:26 +00:00
|
|
|
case WXK_RIGHT:
|
2011-02-01 15:46:25 +00:00
|
|
|
pos.x += wxRound( gridSize.x );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursor( pos );
|
2007-10-10 04:45:26 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
GetScreen()->SetCrossHairPosition( pos );
|
2007-10-10 04:45:26 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
if( oldpos != GetScreen()->GetCrossHairPosition() )
|
2007-10-10 04:45:26 +00:00
|
|
|
{
|
2011-02-11 20:48:13 +00:00
|
|
|
pos = GetScreen()->GetCrossHairPosition();
|
|
|
|
GetScreen()->SetCrossHairPosition( oldpos );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->CrossHairOff( aDC );
|
2011-02-11 20:48:13 +00:00
|
|
|
GetScreen()->SetCrossHairPosition( pos );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->CrossHairOn( aDC );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
if( m_canvas->IsMouseCaptured() )
|
2007-10-10 04:45:26 +00:00
|
|
|
{
|
2012-01-24 19:07:35 +00:00
|
|
|
#ifdef USE_WX_OVERLAY
|
|
|
|
wxDCOverlay oDC( m_overlay, (wxWindowDC*)aDC );
|
|
|
|
oDC.Clear();
|
|
|
|
m_canvas->CallMouseCapture( aDC, aPosition, false );
|
|
|
|
#else
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->CallMouseCapture( aDC, aPosition, true );
|
2012-01-24 19:07:35 +00:00
|
|
|
#endif
|
2007-10-10 04:45:26 +00:00
|
|
|
}
|
2012-01-24 19:07:35 +00:00
|
|
|
#ifdef USE_WX_OVERLAY
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_overlay.Reset();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-10-10 04:45:26 +00:00
|
|
|
}
|
|
|
|
|
2011-02-22 16:43:03 +00:00
|
|
|
if( aHotKey )
|
2007-10-10 04:45:26 +00:00
|
|
|
{
|
2011-02-22 16:43:03 +00:00
|
|
|
OnHotKey( aDC, aHotKey, NULL );
|
2007-10-10 04:45:26 +00:00
|
|
|
}
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
UpdateStatusBar();
|
2007-10-10 04:45:26 +00:00
|
|
|
}
|