2009-11-09 14:00:22 +00:00
|
|
|
/********************/
|
|
|
|
/* onrightclick.cpp */
|
|
|
|
/********************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <id.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gerbview.h>
|
2012-04-09 09:16:47 +00:00
|
|
|
#include <menus_helpers.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-04-03 19:38:24 +00:00
|
|
|
/* Prepare the right-click pullup menu.
|
|
|
|
* The menu already has a list of zoom commands.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2011-03-12 09:50:21 +00:00
|
|
|
bool GERBVIEW_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2012-04-25 19:33:24 +00:00
|
|
|
EDA_ITEM* DrawStruct = GetScreen()->GetCurItem();
|
2009-11-09 14:00:22 +00:00
|
|
|
wxString msg;
|
2012-03-26 23:47:08 +00:00
|
|
|
bool BlockActive = !GetScreen()->m_BlockLocate.IsIdle();
|
2012-03-20 14:17:58 +00:00
|
|
|
bool busy = DrawStruct && DrawStruct->GetFlags();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
// Do not initiate a start block validation on menu.
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetCanStartBlock( -1 );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
// Simple location of elements where possible.
|
2012-03-20 14:17:58 +00:00
|
|
|
if( !busy )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-02-21 13:54:29 +00:00
|
|
|
DrawStruct = Locate( aPosition, CURSEUR_OFF_GRILLE );
|
2012-03-20 14:17:58 +00:00
|
|
|
busy = DrawStruct && DrawStruct->GetFlags();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
// If command in progress, end command.
|
2011-02-24 20:22:12 +00:00
|
|
|
if( GetToolId() != ID_NO_TOOL_SELECTED )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2012-03-20 14:17:58 +00:00
|
|
|
if( busy )
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND,
|
2011-09-08 05:58:45 +00:00
|
|
|
_( "Cancel" ), KiBitmap( cancel_xpm ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
else
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_CLOSE_CURRENT_TOOL,
|
2012-03-20 14:17:58 +00:00
|
|
|
_( "End Tool" ), KiBitmap( cursor_xpm ) );
|
2011-02-24 20:22:12 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
PopMenu->AppendSeparator();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-03-20 14:17:58 +00:00
|
|
|
if( busy || BlockActive )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
if( BlockActive )
|
|
|
|
{
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND,
|
2011-09-08 05:58:45 +00:00
|
|
|
_( "Cancel Block" ), KiBitmap( cancel_xpm ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
PopMenu->AppendSeparator();
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_PLACE_BLOCK,
|
2011-09-08 05:58:45 +00:00
|
|
|
_( "Place Block" ), KiBitmap( apply_xpm ) );
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_DELETE_BLOCK,
|
2011-09-08 05:58:45 +00:00
|
|
|
_( "Delete Block (ctrl + drag mouse)" ), KiBitmap( delete_xpm ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
2011-09-01 12:54:34 +00:00
|
|
|
{
|
|
|
|
AddMenuItem( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND,
|
2011-09-08 05:58:45 +00:00
|
|
|
_( "Cancel" ), KiBitmap( cancel_xpm ) );
|
2011-09-01 12:54:34 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
PopMenu->AppendSeparator();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( BlockActive )
|
2007-10-07 18:24:15 +00:00
|
|
|
return true;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-03-20 14:17:58 +00:00
|
|
|
if( DrawStruct )
|
2012-04-25 19:33:24 +00:00
|
|
|
GetScreen()->SetCurItem( (BOARD_ITEM*)DrawStruct );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
return true;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|