You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
2.3 KiB

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