2011-10-19 20:32:21 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2019-02-12 12:10:30 +00:00
|
|
|
* Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2011-10-19 20:32:21 +00:00
|
|
|
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
|
2019-02-12 12:10:30 +00:00
|
|
|
* Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-19 20:32:21 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
2018-08-03 12:18:26 +00:00
|
|
|
#include <sch_draw_panel.h>
|
2018-01-30 10:49:51 +00:00
|
|
|
#include <sch_edit_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <eeschema_id.h>
|
|
|
|
#include <hotkeys.h>
|
2018-01-30 10:49:51 +00:00
|
|
|
#include <lib_edit_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <viewlib_frame.h>
|
2019-01-07 09:10:37 +00:00
|
|
|
#include <sch_view.h>
|
2009-07-07 17:50:02 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2016-01-20 12:11:17 +00:00
|
|
|
bool SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
|
2008-04-21 06:34:56 +00:00
|
|
|
{
|
2014-06-12 16:12:14 +00:00
|
|
|
// Filter out the 'fake' mouse motion after a keyboard movement
|
|
|
|
if( !aHotKey && m_movingCursorWithKeyboard )
|
|
|
|
{
|
|
|
|
m_movingCursorWithKeyboard = false;
|
2014-08-29 20:23:40 +00:00
|
|
|
return false;
|
2014-06-12 16:12:14 +00:00
|
|
|
}
|
2008-04-21 06:34:56 +00:00
|
|
|
|
2012-08-11 12:52:13 +00:00
|
|
|
// when moving mouse, use the "magnetic" grid, unless the shift+ctrl keys is pressed
|
|
|
|
// for next cursor position
|
|
|
|
// ( shift or ctrl key down are PAN command with mouse wheel)
|
|
|
|
bool snapToGrid = true;
|
2014-08-29 20:23:40 +00:00
|
|
|
|
2012-08-11 12:52:13 +00:00
|
|
|
if( !aHotKey && wxGetKeyState( WXK_SHIFT ) && wxGetKeyState( WXK_CONTROL ) )
|
|
|
|
snapToGrid = false;
|
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
// Cursor is left off grid only if no block in progress
|
|
|
|
if( GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK )
|
|
|
|
snapToGrid = true;
|
|
|
|
|
2014-06-12 16:12:14 +00:00
|
|
|
wxPoint pos = aPosition;
|
2017-10-06 07:23:13 +00:00
|
|
|
bool keyHandled = GeneralControlKeyMovement( aHotKey, &pos, snapToGrid );
|
2008-04-21 06:34:56 +00:00
|
|
|
|
2018-09-07 09:31:05 +00:00
|
|
|
if( GetToolId() == ID_NO_TOOL_SELECTED )
|
|
|
|
m_canvas->CrossHairOff( aDC );
|
|
|
|
else
|
2018-09-07 12:01:01 +00:00
|
|
|
m_canvas->CrossHairOn( aDC );
|
|
|
|
|
2019-02-12 12:10:30 +00:00
|
|
|
GetGalCanvas()->GetViewControls()->SetSnapping( snapToGrid );
|
2018-09-07 12:01:01 +00:00
|
|
|
SetCrossHairPosition( pos, snapToGrid );
|
|
|
|
|
|
|
|
if( m_canvas->IsMouseCaptured() )
|
|
|
|
m_canvas->CallMouseCapture( aDC, aPosition, true );
|
2008-04-21 06:34:56 +00:00
|
|
|
|
2011-02-22 16:43:03 +00:00
|
|
|
if( aHotKey )
|
2008-04-21 06:34:56 +00:00
|
|
|
{
|
2019-01-07 09:10:37 +00:00
|
|
|
if( m_movingCursorWithKeyboard ) // The hotkey was a move crossahir cursor command
|
|
|
|
{
|
|
|
|
// The crossair was moved. move the mouse cursor to the new crosshair position:
|
|
|
|
GetGalCanvas()->GetViewControls()->WarpCursor( GetCrossHairPosition(), true );
|
|
|
|
m_movingCursorWithKeyboard = 0;
|
|
|
|
}
|
2008-04-21 06:34:56 +00:00
|
|
|
else
|
2019-01-07 09:10:37 +00:00
|
|
|
{
|
|
|
|
SCH_SCREEN* screen = GetScreen();
|
|
|
|
bool hk_handled;
|
2017-10-06 07:23:13 +00:00
|
|
|
|
2019-04-22 08:58:06 +00:00
|
|
|
if( screen->GetCurItem() && screen->GetCurItem()->GetEditFlags() )
|
2019-01-07 09:10:37 +00:00
|
|
|
hk_handled = OnHotKey( aDC, aHotKey, aPosition, screen->GetCurItem() );
|
|
|
|
else
|
|
|
|
hk_handled = OnHotKey( aDC, aHotKey, aPosition, NULL );
|
|
|
|
|
|
|
|
if( hk_handled )
|
|
|
|
keyHandled = true;
|
|
|
|
}
|
2008-04-21 06:34:56 +00:00
|
|
|
}
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
UpdateStatusBar(); /* Display cursor coordinates info */
|
2014-08-29 20:23:40 +00:00
|
|
|
|
2017-10-06 07:23:13 +00:00
|
|
|
return keyHandled;
|
2008-04-21 06:34:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-31 10:05:16 +00:00
|
|
|
|
2016-01-20 12:11:17 +00:00
|
|
|
bool LIB_VIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2014-08-29 20:23:40 +00:00
|
|
|
bool eventHandled = true;
|
|
|
|
|
2014-06-12 16:12:14 +00:00
|
|
|
// Filter out the 'fake' mouse motion after a keyboard movement
|
|
|
|
if( !aHotKey && m_movingCursorWithKeyboard )
|
2007-08-14 19:24:48 +00:00
|
|
|
{
|
2014-06-12 16:12:14 +00:00
|
|
|
m_movingCursorWithKeyboard = false;
|
2014-08-29 20:23:40 +00:00
|
|
|
return false;
|
2007-08-14 19:24:48 +00:00
|
|
|
}
|
|
|
|
|
2014-06-12 16:12:14 +00:00
|
|
|
wxPoint pos = aPosition;
|
|
|
|
GeneralControlKeyMovement( aHotKey, &pos, true );
|
2007-08-14 19:24:48 +00:00
|
|
|
|
2014-06-12 16:12:14 +00:00
|
|
|
// Update cursor position.
|
2018-10-30 14:58:08 +00:00
|
|
|
m_canvas->CrossHairOn( aDC );
|
2014-06-12 16:12:14 +00:00
|
|
|
SetCrossHairPosition( pos, true );
|
2007-08-14 19:24:48 +00:00
|
|
|
|
2011-02-22 16:43:03 +00:00
|
|
|
if( aHotKey )
|
2007-08-14 19:24:48 +00:00
|
|
|
{
|
2014-06-12 16:12:14 +00:00
|
|
|
SCH_SCREEN* screen = GetScreen();
|
|
|
|
|
2019-04-22 08:58:06 +00:00
|
|
|
if( screen->GetCurItem() && screen->GetCurItem()->GetEditFlags() )
|
2014-08-29 20:23:40 +00:00
|
|
|
eventHandled = OnHotKey( aDC, aHotKey, aPosition, screen->GetCurItem() );
|
2007-08-14 19:24:48 +00:00
|
|
|
else
|
2014-08-29 20:23:40 +00:00
|
|
|
eventHandled = OnHotKey( aDC, aHotKey, aPosition, NULL );
|
2007-08-14 19:24:48 +00:00
|
|
|
}
|
2007-08-21 19:37:31 +00:00
|
|
|
|
2014-08-29 20:23:40 +00:00
|
|
|
UpdateStatusBar(); // Display cursor coordinates info.
|
|
|
|
|
|
|
|
return eventHandled;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|