2007-08-14 19:24:48 +00:00
|
|
|
/****************/
|
|
|
|
/* controle.cpp */
|
|
|
|
/****************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "eda_dde.h"
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "wxEeschemaStruct.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "eeschema_id.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "general.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "protos.h"
|
2010-02-16 16:21:52 +00:00
|
|
|
#include "libeditframe.h"
|
|
|
|
#include "viewlib_frame.h"
|
2010-10-08 20:40:57 +00:00
|
|
|
#include "lib_draw_item.h"
|
2010-10-22 12:11:52 +00:00
|
|
|
#include "lib_pin.h"
|
2010-11-11 21:10:27 +00:00
|
|
|
#include "sch_sheet.h"
|
|
|
|
#include "sch_sheet_path.h"
|
|
|
|
#include "sch_marker.h"
|
|
|
|
#include "sch_component.h"
|
2009-07-07 17:50:02 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
2011-02-02 19:01:21 +00:00
|
|
|
* Function LocateAndShowItem
|
|
|
|
* search the schematic at \a aPosition in logical (drawing) units for any item.
|
|
|
|
* <p>
|
|
|
|
* The search is first performed at \a aPosition which may be off grid. If no item is
|
|
|
|
* found at \a aPosition, the search is repeated for the nearest grid position to \a
|
|
|
|
* aPosition.
|
2009-01-31 10:05:16 +00:00
|
|
|
*
|
2011-02-02 19:01:21 +00:00
|
|
|
* The search order is as follows:
|
|
|
|
* <ul>
|
|
|
|
* <li>Marker</li>
|
|
|
|
* <li>No Connect</li>
|
|
|
|
* <li>Junction</li>
|
|
|
|
* <li>Wire, bus, or entry</li>
|
|
|
|
* <li>Label</li>
|
|
|
|
* <li>Pin</li>
|
|
|
|
* <li>Component</li>
|
|
|
|
* </ul></p>
|
|
|
|
* @param aPosition The wxPoint on the schematic to search.
|
|
|
|
* @param aIncludePin = true to search for pins, false to ignore them
|
|
|
|
* @return A SCH_ITEM pointer on the item or NULL if no item found
|
2007-08-14 19:24:48 +00:00
|
|
|
*/
|
2011-02-02 19:01:21 +00:00
|
|
|
SCH_ITEM* SCH_EDIT_FRAME::LocateAndShowItem( const wxPoint& aPosition, bool aIncludePin )
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2011-02-02 19:01:21 +00:00
|
|
|
SCH_ITEM* item;
|
2009-01-31 10:05:16 +00:00
|
|
|
wxString msg;
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_PIN* Pin = NULL;
|
2008-03-20 01:50:21 +00:00
|
|
|
SCH_COMPONENT* LibItem = NULL;
|
2011-02-02 19:01:21 +00:00
|
|
|
wxPoint gridPosition = GetScreen()->GetNearestGridPosition( aPosition );
|
2007-08-14 19:24:48 +00:00
|
|
|
|
2011-02-02 19:01:21 +00:00
|
|
|
item = LocateItem( aPosition, aIncludePin );
|
2011-02-01 15:46:25 +00:00
|
|
|
|
2011-02-02 19:01:21 +00:00
|
|
|
if( !item && aPosition != gridPosition )
|
|
|
|
item = LocateItem( gridPosition, aIncludePin );
|
2011-02-01 15:46:25 +00:00
|
|
|
|
2011-02-02 19:01:21 +00:00
|
|
|
if( !item )
|
2007-08-14 19:24:48 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* Cross probing to pcbnew if a pin or a component is found */
|
2011-02-02 19:01:21 +00:00
|
|
|
switch( item->Type() )
|
2007-08-14 19:24:48 +00:00
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_FIELD_T:
|
|
|
|
case LIB_FIELD_T:
|
2011-02-02 19:01:21 +00:00
|
|
|
LibItem = (SCH_COMPONENT*) item->GetParent();
|
|
|
|
SendMessageToPCBNEW( item, LibItem );
|
2007-08-14 19:24:48 +00:00
|
|
|
break;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_COMPONENT_T:
|
2011-02-11 20:48:13 +00:00
|
|
|
Pin = GetScreen()->GetPin( GetScreen()->GetCrossHairPosition(), &LibItem );
|
2011-02-02 19:01:21 +00:00
|
|
|
|
2007-08-14 19:24:48 +00:00
|
|
|
if( Pin )
|
2009-11-03 13:26:31 +00:00
|
|
|
break; // Priority is probing a pin first
|
2011-02-02 19:01:21 +00:00
|
|
|
|
|
|
|
LibItem = (SCH_COMPONENT*) item;
|
|
|
|
SendMessageToPCBNEW( item, LibItem );
|
2007-08-14 19:24:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2011-02-11 20:48:13 +00:00
|
|
|
Pin = GetScreen()->GetPin( GetScreen()->GetCrossHairPosition(), &LibItem );
|
2007-08-14 19:24:48 +00:00
|
|
|
break;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case LIB_PIN_T:
|
2011-02-02 19:01:21 +00:00
|
|
|
Pin = (LIB_PIN*) item;
|
2007-08-14 19:24:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( Pin )
|
|
|
|
{
|
2011-02-02 19:01:21 +00:00
|
|
|
// Force display pin information (the previous display could be a component info)
|
2009-04-17 08:51:02 +00:00
|
|
|
Pin->DisplayInfo( this );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2007-08-14 19:24:48 +00:00
|
|
|
if( LibItem )
|
2009-10-14 19:43:31 +00:00
|
|
|
AppendMsgPanel( LibItem->GetRef( GetSheet() ),
|
|
|
|
LibItem->GetField( VALUE )->m_Text, DARKCYAN );
|
2007-08-14 19:24:48 +00:00
|
|
|
|
2011-02-02 19:01:21 +00:00
|
|
|
// Cross probing:2 - pin found, and send a locate pin command to pcbnew (highlight net)
|
2008-02-29 20:35:11 +00:00
|
|
|
SendMessageToPCBNEW( Pin, LibItem );
|
2007-08-14 19:24:48 +00:00
|
|
|
}
|
2011-02-02 19:01:21 +00:00
|
|
|
|
|
|
|
return item;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
2011-02-02 19:01:21 +00:00
|
|
|
* Function LocateItem
|
|
|
|
* searches for an item at \a aPosition.
|
|
|
|
* @param aPosition The wxPoint location where to search.
|
|
|
|
* @param aIncludePin True to search for pins, false to ignore them.
|
|
|
|
* @return The SCH_ITEM pointer of the item or NULL if no item found.
|
2007-08-14 19:24:48 +00:00
|
|
|
*/
|
2011-02-02 19:01:21 +00:00
|
|
|
SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, bool aIncludePin )
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2011-02-02 19:01:21 +00:00
|
|
|
SCH_ITEM* item;
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_PIN* Pin;
|
2008-03-20 01:50:21 +00:00
|
|
|
SCH_COMPONENT* LibItem;
|
2009-01-31 10:05:16 +00:00
|
|
|
wxString Text;
|
|
|
|
wxString msg;
|
2007-08-14 19:24:48 +00:00
|
|
|
|
2011-02-02 19:01:21 +00:00
|
|
|
item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), MARKER_T );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2011-02-02 19:01:21 +00:00
|
|
|
if( item )
|
2009-07-10 12:29:31 +00:00
|
|
|
{
|
2011-02-02 19:01:21 +00:00
|
|
|
item->DisplayInfo( this );
|
|
|
|
return item;
|
2009-07-10 12:29:31 +00:00
|
|
|
}
|
2010-04-06 14:09:52 +00:00
|
|
|
|
2011-02-02 19:01:21 +00:00
|
|
|
item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), NO_CONNECT_T );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2011-02-02 19:01:21 +00:00
|
|
|
if( item )
|
2007-08-14 19:24:48 +00:00
|
|
|
{
|
2009-10-14 19:43:31 +00:00
|
|
|
ClearMsgPanel();
|
2011-02-02 19:01:21 +00:00
|
|
|
return item;
|
2007-08-14 19:24:48 +00:00
|
|
|
}
|
|
|
|
|
2011-02-02 19:01:21 +00:00
|
|
|
item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), JUNCTION_T );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2011-02-02 19:01:21 +00:00
|
|
|
if( item )
|
2007-08-14 19:24:48 +00:00
|
|
|
{
|
2009-10-14 19:43:31 +00:00
|
|
|
ClearMsgPanel();
|
2011-02-02 19:01:21 +00:00
|
|
|
return item;
|
2007-08-14 19:24:48 +00:00
|
|
|
}
|
|
|
|
|
2011-02-02 19:01:21 +00:00
|
|
|
item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), WIRE_T | BUS_T | BUS_ENTRY_T );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2011-02-02 19:01:21 +00:00
|
|
|
if( item ) // We have found a wire: Search for a connected pin at the same location
|
2007-08-14 19:24:48 +00:00
|
|
|
{
|
2011-02-02 19:01:21 +00:00
|
|
|
Pin = GetScreen()->GetPin( aPosition, &LibItem );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2007-08-14 19:24:48 +00:00
|
|
|
if( Pin )
|
|
|
|
{
|
2009-04-17 08:51:02 +00:00
|
|
|
Pin->DisplayInfo( this );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2007-08-14 19:24:48 +00:00
|
|
|
if( LibItem )
|
2009-10-14 19:43:31 +00:00
|
|
|
AppendMsgPanel( LibItem->GetRef( GetSheet() ),
|
|
|
|
LibItem->GetField( VALUE )->m_Text, DARKCYAN );
|
2007-08-14 19:24:48 +00:00
|
|
|
}
|
|
|
|
else
|
2009-10-14 19:43:31 +00:00
|
|
|
ClearMsgPanel();
|
2009-12-02 21:44:03 +00:00
|
|
|
|
2011-02-02 19:01:21 +00:00
|
|
|
return item;
|
2007-08-14 19:24:48 +00:00
|
|
|
}
|
|
|
|
|
2011-02-10 19:39:18 +00:00
|
|
|
item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), DRAW_ITEM_T );
|
|
|
|
if( item )
|
|
|
|
{
|
|
|
|
ClearMsgPanel();
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
2011-02-02 19:01:21 +00:00
|
|
|
item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), FIELD_T );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2011-02-02 19:01:21 +00:00
|
|
|
if( item )
|
2007-08-14 19:24:48 +00:00
|
|
|
{
|
2011-02-02 19:01:21 +00:00
|
|
|
SCH_FIELD* Field = (SCH_FIELD*) item;
|
2008-11-24 06:53:43 +00:00
|
|
|
LibItem = (SCH_COMPONENT*) Field->GetParent();
|
2009-04-17 08:51:02 +00:00
|
|
|
LibItem->DisplayInfo( this );
|
2007-08-14 19:24:48 +00:00
|
|
|
|
2011-02-02 19:01:21 +00:00
|
|
|
return item;
|
2007-08-14 19:24:48 +00:00
|
|
|
}
|
|
|
|
|
2011-02-02 19:01:21 +00:00
|
|
|
item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), LABEL_T | TEXT_T );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2011-02-02 19:01:21 +00:00
|
|
|
if( item )
|
2010-07-21 01:37:34 +00:00
|
|
|
{
|
|
|
|
ClearMsgPanel();
|
2011-02-02 19:01:21 +00:00
|
|
|
return item;
|
2010-07-21 01:37:34 +00:00
|
|
|
}
|
|
|
|
|
2007-08-14 19:24:48 +00:00
|
|
|
/* search for a pin */
|
2011-02-02 19:01:21 +00:00
|
|
|
Pin = GetScreen()->GetPin( aPosition, &LibItem );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2007-08-14 19:24:48 +00:00
|
|
|
if( Pin )
|
|
|
|
{
|
2009-04-17 08:51:02 +00:00
|
|
|
Pin->DisplayInfo( this );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2007-08-14 19:24:48 +00:00
|
|
|
if( LibItem )
|
2009-10-14 19:43:31 +00:00
|
|
|
AppendMsgPanel( LibItem->GetRef( GetSheet() ),
|
|
|
|
LibItem->GetField( VALUE )->m_Text, DARKCYAN );
|
2011-02-02 19:01:21 +00:00
|
|
|
if( aIncludePin )
|
2007-08-14 19:24:48 +00:00
|
|
|
return LibItem;
|
|
|
|
}
|
|
|
|
|
2011-02-02 19:01:21 +00:00
|
|
|
item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), COMPONENT_T );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2011-02-02 19:01:21 +00:00
|
|
|
if( item )
|
2007-08-14 19:24:48 +00:00
|
|
|
{
|
2011-02-02 19:01:21 +00:00
|
|
|
item = LocateSmallestComponent( GetScreen() );
|
|
|
|
LibItem = (SCH_COMPONENT*) item;
|
2009-04-17 08:51:02 +00:00
|
|
|
LibItem->DisplayInfo( this );
|
2011-02-02 19:01:21 +00:00
|
|
|
return item;
|
2007-08-14 19:24:48 +00:00
|
|
|
}
|
|
|
|
|
2011-02-02 19:01:21 +00:00
|
|
|
item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), SHEET_T );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2011-02-02 19:01:21 +00:00
|
|
|
if( item )
|
2007-08-14 19:24:48 +00:00
|
|
|
{
|
2011-02-02 19:01:21 +00:00
|
|
|
( (SCH_SHEET*) item )->DisplayInfo( this );
|
|
|
|
return item;
|
2007-08-14 19:24:48 +00:00
|
|
|
}
|
|
|
|
|
2011-02-02 19:01:21 +00:00
|
|
|
item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), NO_FILTER_T );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2011-02-02 19:01:21 +00:00
|
|
|
if( item )
|
|
|
|
return item;
|
2007-08-14 19:24:48 +00:00
|
|
|
|
2009-10-14 19:43:31 +00:00
|
|
|
ClearMsgPanel();
|
2007-08-14 19:24:48 +00:00
|
|
|
return NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-02 19:01:21 +00:00
|
|
|
void SCH_EDIT_FRAME::GeneralControle( wxDC* aDC, const wxPoint& aPosition )
|
2008-04-21 06:34:56 +00:00
|
|
|
{
|
2011-02-01 15:46:25 +00:00
|
|
|
wxRealPoint gridSize;
|
2009-01-31 10:05:16 +00:00
|
|
|
SCH_SCREEN* screen = GetScreen();
|
2011-02-01 15:46:25 +00:00
|
|
|
wxPoint oldpos;
|
2009-01-31 10:05:16 +00:00
|
|
|
int hotkey = 0;
|
2011-02-01 15:46:25 +00:00
|
|
|
wxPoint pos = aPosition;
|
2008-04-21 06:34:56 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
pos = screen->GetNearestGridPosition( pos );
|
|
|
|
oldpos = screen->GetCrossHairPosition();
|
2011-02-01 15:46:25 +00:00
|
|
|
gridSize = screen->GetGridSize();
|
2008-04-21 06:34:56 +00:00
|
|
|
|
|
|
|
switch( g_KeyPressed )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
case WXK_NUMPAD8:
|
2008-04-21 06:34:56 +00:00
|
|
|
case WXK_UP:
|
2011-02-01 15:46:25 +00:00
|
|
|
pos.y -= wxRound( gridSize.y );
|
|
|
|
DrawPanel->MoveCursor( pos );
|
2008-04-21 06:34:56 +00:00
|
|
|
break;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
case WXK_NUMPAD2:
|
2008-04-21 06:34:56 +00:00
|
|
|
case WXK_DOWN:
|
2011-02-01 15:46:25 +00:00
|
|
|
pos.y += wxRound( gridSize.y );
|
|
|
|
DrawPanel->MoveCursor( pos );
|
2008-04-21 06:34:56 +00:00
|
|
|
break;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
case WXK_NUMPAD4:
|
2008-04-21 06:34:56 +00:00
|
|
|
case WXK_LEFT:
|
2011-02-01 15:46:25 +00:00
|
|
|
pos.x -= wxRound( gridSize.x );
|
|
|
|
DrawPanel->MoveCursor( pos );
|
2008-04-21 06:34:56 +00:00
|
|
|
break;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
case WXK_NUMPAD6:
|
2008-04-21 06:34:56 +00:00
|
|
|
case WXK_RIGHT:
|
2011-02-01 15:46:25 +00:00
|
|
|
pos.x += wxRound( gridSize.x );
|
|
|
|
DrawPanel->MoveCursor( pos );
|
2008-04-21 06:34:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
hotkey = g_KeyPressed;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-02-01 15:46:25 +00:00
|
|
|
// Update cursor position.
|
2011-02-11 20:48:13 +00:00
|
|
|
screen->SetCrossHairPosition( pos );
|
2008-04-21 06:34:56 +00:00
|
|
|
|
|
|
|
if( screen->IsRefreshReq() )
|
|
|
|
{
|
2011-02-21 13:54:29 +00:00
|
|
|
DrawPanel->Refresh();
|
2010-01-13 13:43:36 +00:00
|
|
|
wxSafeYield();
|
2008-04-21 06:34:56 +00:00
|
|
|
}
|
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
if( oldpos != screen->GetCrossHairPosition() )
|
2008-04-21 06:34:56 +00:00
|
|
|
{
|
2011-02-11 20:48:13 +00:00
|
|
|
pos = screen->GetCrossHairPosition();
|
|
|
|
screen->SetCrossHairPosition( oldpos );
|
|
|
|
DrawPanel->CrossHairOff( aDC );
|
|
|
|
screen->SetCrossHairPosition( pos );
|
|
|
|
DrawPanel->CrossHairOn( aDC );
|
2008-04-21 06:34:56 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
if( DrawPanel->IsMouseCaptured() )
|
2008-04-21 06:34:56 +00:00
|
|
|
{
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->m_mouseCaptureCallback( DrawPanel, aDC, aPosition, TRUE );
|
2008-04-21 06:34:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( hotkey )
|
|
|
|
{
|
2009-01-17 20:31:19 +00:00
|
|
|
if( screen->GetCurItem() && screen->GetCurItem()->m_Flags )
|
2011-02-02 19:01:21 +00:00
|
|
|
OnHotKey( aDC, hotkey, aPosition, screen->GetCurItem() );
|
2008-04-21 06:34:56 +00:00
|
|
|
else
|
2011-02-02 19:01:21 +00:00
|
|
|
OnHotKey( aDC, hotkey, aPosition, NULL );
|
2008-04-21 06:34:56 +00:00
|
|
|
}
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
UpdateStatusBar(); /* Display cursor coordinates info */
|
2008-04-21 06:34:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-02 19:01:21 +00:00
|
|
|
void LIB_EDIT_FRAME::GeneralControle( wxDC* aDC, const wxPoint& aPosition )
|
2008-04-21 06:34:56 +00:00
|
|
|
{
|
2011-02-01 15:46:25 +00:00
|
|
|
wxRealPoint gridSize;
|
2009-01-31 10:05:16 +00:00
|
|
|
SCH_SCREEN* screen = GetScreen();
|
2011-02-01 15:46:25 +00:00
|
|
|
wxPoint oldpos;
|
2009-01-31 10:05:16 +00:00
|
|
|
int hotkey = 0;
|
2011-02-01 15:46:25 +00:00
|
|
|
wxPoint pos = aPosition;
|
2008-04-21 06:34:56 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
pos = screen->GetNearestGridPosition( pos );
|
|
|
|
oldpos = screen->GetCrossHairPosition();
|
2011-02-01 15:46:25 +00:00
|
|
|
gridSize = screen->GetGridSize();
|
2008-04-21 06:34:56 +00:00
|
|
|
|
|
|
|
switch( g_KeyPressed )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
case WXK_NUMPAD8:
|
2008-04-21 06:34:56 +00:00
|
|
|
case WXK_UP:
|
2011-02-01 15:46:25 +00:00
|
|
|
pos.y -= wxRound( gridSize.y );
|
|
|
|
DrawPanel->MoveCursor( pos );
|
2008-04-21 06:34:56 +00:00
|
|
|
break;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
case WXK_NUMPAD2:
|
2008-04-21 06:34:56 +00:00
|
|
|
case WXK_DOWN:
|
2011-02-01 15:46:25 +00:00
|
|
|
pos.y += wxRound( gridSize.y );
|
|
|
|
DrawPanel->MoveCursor( pos );
|
2008-04-21 06:34:56 +00:00
|
|
|
break;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
case WXK_NUMPAD4:
|
2008-04-21 06:34:56 +00:00
|
|
|
case WXK_LEFT:
|
2011-02-01 15:46:25 +00:00
|
|
|
pos.x -= wxRound( gridSize.x );
|
|
|
|
DrawPanel->MoveCursor( pos );
|
2008-04-21 06:34:56 +00:00
|
|
|
break;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
case WXK_NUMPAD6:
|
2008-04-21 06:34:56 +00:00
|
|
|
case WXK_RIGHT:
|
2011-02-01 15:46:25 +00:00
|
|
|
pos.x += wxRound( gridSize.x );
|
|
|
|
DrawPanel->MoveCursor( pos );
|
2008-04-21 06:34:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
hotkey = g_KeyPressed;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-02-01 15:46:25 +00:00
|
|
|
// Update the cursor position.
|
2011-02-11 20:48:13 +00:00
|
|
|
screen->SetCrossHairPosition( pos );
|
2008-04-21 06:34:56 +00:00
|
|
|
|
|
|
|
if( screen->IsRefreshReq() )
|
|
|
|
{
|
2010-01-13 13:43:36 +00:00
|
|
|
DrawPanel->Refresh( );
|
|
|
|
wxSafeYield();
|
2008-04-21 06:34:56 +00:00
|
|
|
}
|
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
if( oldpos != screen->GetCrossHairPosition() )
|
2008-04-21 06:34:56 +00:00
|
|
|
{
|
2011-02-11 20:48:13 +00:00
|
|
|
pos = screen->GetCrossHairPosition();
|
|
|
|
screen->SetCrossHairPosition( oldpos );
|
|
|
|
DrawPanel->CrossHairOff( aDC );
|
|
|
|
screen->SetCrossHairPosition( pos );
|
|
|
|
DrawPanel->CrossHairOn( aDC );
|
2008-04-21 06:34:56 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
if( DrawPanel->IsMouseCaptured() )
|
2008-04-21 06:34:56 +00:00
|
|
|
{
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->m_mouseCaptureCallback( DrawPanel, aDC, aPosition, TRUE );
|
2008-04-21 06:34:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( hotkey )
|
|
|
|
{
|
2009-01-17 20:31:19 +00:00
|
|
|
if( screen->GetCurItem() && screen->GetCurItem()->m_Flags )
|
2011-02-02 19:01:21 +00:00
|
|
|
OnHotKey( aDC, hotkey, aPosition, screen->GetCurItem() );
|
2008-04-21 06:34:56 +00:00
|
|
|
else
|
2011-02-02 19:01:21 +00:00
|
|
|
OnHotKey( aDC, hotkey, aPosition, NULL );
|
2008-04-21 06:34:56 +00:00
|
|
|
}
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
UpdateStatusBar();
|
2008-04-21 06:34:56 +00:00
|
|
|
}
|
|
|
|
|
2009-01-31 10:05:16 +00:00
|
|
|
|
2011-02-02 19:01:21 +00:00
|
|
|
void LIB_VIEW_FRAME::GeneralControle( wxDC* aDC, const wxPoint& aPosition )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-02-01 15:46:25 +00:00
|
|
|
wxRealPoint gridSize;
|
2009-01-31 10:05:16 +00:00
|
|
|
SCH_SCREEN* screen = GetScreen();
|
2011-02-01 15:46:25 +00:00
|
|
|
wxPoint oldpos;
|
2009-01-31 10:05:16 +00:00
|
|
|
int hotkey = 0;
|
2011-02-01 15:46:25 +00:00
|
|
|
wxPoint pos = aPosition;
|
2007-08-14 19:24:48 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
pos = screen->GetNearestGridPosition( pos );
|
|
|
|
oldpos = screen->GetCrossHairPosition();
|
2011-02-01 15:46:25 +00:00
|
|
|
gridSize = screen->GetGridSize();
|
2007-08-14 19:24:48 +00:00
|
|
|
|
|
|
|
switch( g_KeyPressed )
|
|
|
|
{
|
2007-08-30 08:15:05 +00:00
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
case WXK_NUMPAD8:
|
2007-08-14 19:24:48 +00:00
|
|
|
case WXK_UP:
|
2011-02-01 15:46:25 +00:00
|
|
|
pos.y -= wxRound( gridSize.y );
|
|
|
|
DrawPanel->MoveCursor( pos );
|
2007-08-14 19:24:48 +00:00
|
|
|
break;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
case WXK_NUMPAD2:
|
2007-08-14 19:24:48 +00:00
|
|
|
case WXK_DOWN:
|
2011-02-01 15:46:25 +00:00
|
|
|
pos.y += wxRound( gridSize.y );
|
|
|
|
DrawPanel->MoveCursor( pos );
|
2007-08-14 19:24:48 +00:00
|
|
|
break;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
case WXK_NUMPAD4:
|
2007-08-14 19:24:48 +00:00
|
|
|
case WXK_LEFT:
|
2011-02-01 15:46:25 +00:00
|
|
|
pos.x -= wxRound( gridSize.x );
|
|
|
|
DrawPanel->MoveCursor( pos );
|
2007-08-14 19:24:48 +00:00
|
|
|
break;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
case WXK_NUMPAD6:
|
2007-08-14 19:24:48 +00:00
|
|
|
case WXK_RIGHT:
|
2011-02-01 15:46:25 +00:00
|
|
|
pos.x += wxRound( gridSize.x );
|
|
|
|
DrawPanel->MoveCursor( pos );
|
2007-08-14 19:24:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
hotkey = g_KeyPressed;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-02-01 15:46:25 +00:00
|
|
|
// Update cursor position.
|
2011-02-11 20:48:13 +00:00
|
|
|
screen->SetCrossHairPosition( pos );
|
2007-08-14 19:24:48 +00:00
|
|
|
|
2008-02-29 20:35:11 +00:00
|
|
|
if( screen->IsRefreshReq() )
|
2007-08-14 19:24:48 +00:00
|
|
|
{
|
2010-01-13 13:43:36 +00:00
|
|
|
DrawPanel->Refresh( );
|
|
|
|
wxSafeYield();
|
2007-08-14 19:24:48 +00:00
|
|
|
}
|
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
if( oldpos != screen->GetCrossHairPosition() )
|
2007-08-14 19:24:48 +00:00
|
|
|
{
|
2011-02-11 20:48:13 +00:00
|
|
|
pos = screen->GetCrossHairPosition();
|
|
|
|
screen->SetCrossHairPosition( oldpos );
|
|
|
|
DrawPanel->CrossHairOff( aDC );
|
|
|
|
screen->SetCrossHairPosition( pos );
|
|
|
|
DrawPanel->CrossHairOn( aDC );
|
2007-08-14 19:24:48 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
if( DrawPanel->IsMouseCaptured() )
|
2007-08-14 19:24:48 +00:00
|
|
|
{
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->m_mouseCaptureCallback( DrawPanel, aDC, aPosition, TRUE );
|
2007-08-14 19:24:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( hotkey )
|
|
|
|
{
|
2009-01-17 20:31:19 +00:00
|
|
|
if( screen->GetCurItem() && screen->GetCurItem()->m_Flags )
|
2011-02-02 19:01:21 +00:00
|
|
|
OnHotKey( aDC, hotkey, aPosition, screen->GetCurItem() );
|
2007-08-14 19:24:48 +00:00
|
|
|
else
|
2011-02-02 19:01:21 +00:00
|
|
|
OnHotKey( aDC, hotkey, aPosition, NULL );
|
2007-08-14 19:24:48 +00:00
|
|
|
}
|
2007-08-21 19:37:31 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
UpdateStatusBar();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|