113 lines
3.0 KiB
C++
113 lines
3.0 KiB
C++
|
/*
|
||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||
|
*
|
||
|
* Copyright (C) 2013-2013 Jean-Pierre Charras jp.charras at wanadoo.fr
|
||
|
* Copyright (C) 2013-2013 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 pagelayout_editor/controle.cpp
|
||
|
*/
|
||
|
|
||
|
#include <fctsys.h>
|
||
|
#include <common.h>
|
||
|
#include <class_drawpanel.h>
|
||
|
#include <pl_editor_frame.h>
|
||
|
|
||
|
|
||
|
void PL_EDITOR_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition,
|
||
|
int aHotKey )
|
||
|
{
|
||
|
wxRealPoint gridSize;
|
||
|
wxPoint oldpos;
|
||
|
wxPoint pos = aPosition;
|
||
|
|
||
|
pos = GetScreen()->GetNearestGridPosition( pos );
|
||
|
|
||
|
oldpos = GetScreen()->GetCrossHairPosition();
|
||
|
gridSize = GetScreen()->GetGridSize();
|
||
|
|
||
|
switch( aHotKey )
|
||
|
{
|
||
|
case WXK_NUMPAD8:
|
||
|
case WXK_UP:
|
||
|
pos.y -= KiROUND( gridSize.y );
|
||
|
m_canvas->MoveCursor( pos );
|
||
|
break;
|
||
|
|
||
|
case WXK_NUMPAD2:
|
||
|
case WXK_DOWN:
|
||
|
pos.y += KiROUND( gridSize.y );
|
||
|
m_canvas->MoveCursor( pos );
|
||
|
break;
|
||
|
|
||
|
case WXK_NUMPAD4:
|
||
|
case WXK_LEFT:
|
||
|
pos.x -= KiROUND( gridSize.x );
|
||
|
m_canvas->MoveCursor( pos );
|
||
|
break;
|
||
|
|
||
|
case WXK_NUMPAD6:
|
||
|
case WXK_RIGHT:
|
||
|
pos.x += KiROUND( gridSize.x );
|
||
|
m_canvas->MoveCursor( pos );
|
||
|
break;
|
||
|
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
GetScreen()->SetCrossHairPosition( pos );
|
||
|
|
||
|
if( oldpos != GetScreen()->GetCrossHairPosition() )
|
||
|
{
|
||
|
pos = GetScreen()->GetCrossHairPosition();
|
||
|
GetScreen()->SetCrossHairPosition( oldpos );
|
||
|
m_canvas->CrossHairOff( aDC );
|
||
|
GetScreen()->SetCrossHairPosition( pos );
|
||
|
m_canvas->CrossHairOn( aDC );
|
||
|
|
||
|
if( m_canvas->IsMouseCaptured() )
|
||
|
{
|
||
|
#ifdef USE_WX_OVERLAY
|
||
|
wxDCOverlay oDC( m_overlay, (wxWindowDC*)aDC );
|
||
|
oDC.Clear();
|
||
|
m_canvas->CallMouseCapture( aDC, aPosition, false );
|
||
|
#else
|
||
|
m_canvas->CallMouseCapture( aDC, aPosition, true );
|
||
|
#endif
|
||
|
}
|
||
|
#ifdef USE_WX_OVERLAY
|
||
|
else
|
||
|
{
|
||
|
m_overlay.Reset();
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
}
|
||
|
|
||
|
if( aHotKey )
|
||
|
{
|
||
|
OnHotKey( aDC, aHotKey, aPosition );
|
||
|
}
|
||
|
|
||
|
UpdateStatusBar();
|
||
|
}
|