forked from KiCad/kicad-source-mirror
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathonrightclick.cpp
77 lines (65 loc) · 2.26 KB
/
onrightclick.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/********************/
/* onrightclick.cpp */
/********************/
#include <fctsys.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <id.h>
#include <gerbview.h>
#include <menus_helpers.h>
/* Prepare the right-click pullup menu.
* The menu already has a list of zoom commands.
*/
bool GERBVIEW_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
{
GERBER_DRAW_ITEM* DrawStruct = (GERBER_DRAW_ITEM*) GetScreen()->GetCurItem();
wxString msg;
bool BlockActive = !GetScreen()->m_BlockLocate.IsIdle();
bool busy = DrawStruct && DrawStruct->GetFlags();
// Do not initiate a start block validation on menu.
m_canvas->SetCanStartBlock( -1 );
// Simple location of elements where possible.
if( !busy )
{
DrawStruct = Locate( aPosition, CURSEUR_OFF_GRILLE );
busy = DrawStruct && DrawStruct->GetFlags();
}
// If command in progress, end command.
if( GetToolId() != ID_NO_TOOL_SELECTED )
{
if( busy )
AddMenuItem( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND,
_( "Cancel" ), KiBitmap( cancel_xpm ) );
else
AddMenuItem( PopMenu, ID_POPUP_CLOSE_CURRENT_TOOL,
_( "End Tool" ), KiBitmap( cursor_xpm ) );
PopMenu->AppendSeparator();
}
else
{
if( busy || BlockActive )
{
if( BlockActive )
{
AddMenuItem( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND,
_( "Cancel Block" ), KiBitmap( cancel_xpm ) );
PopMenu->AppendSeparator();
AddMenuItem( PopMenu, ID_POPUP_PLACE_BLOCK,
_( "Place Block" ), KiBitmap( apply_xpm ) );
AddMenuItem( PopMenu, ID_POPUP_DELETE_BLOCK,
_( "Delete Block (ctrl + drag mouse)" ), KiBitmap( delete_xpm ) );
}
else
{
AddMenuItem( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND,
_( "Cancel" ), KiBitmap( cancel_xpm ) );
}
PopMenu->AppendSeparator();
}
}
if( BlockActive )
return true;
if( DrawStruct )
GetScreen()->SetCurItem( DrawStruct );
return true;
}