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.

1039 lines
41 KiB

16 years ago
16 years ago
16 years ago
16 years ago
7 years ago
16 years ago
7 years ago
7 years ago
16 years ago
8 years ago
16 years ago
17 years ago
17 years ago
16 years ago
16 years ago
7 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
  6. * Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, you may find one here:
  20. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  21. * or you may search the http://www.gnu.org website for the version 2 license,
  22. * or you may write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  24. */
  25. /**
  26. * @file eeschema/onrightclick.cpp
  27. */
  28. #include <fctsys.h>
  29. #include <eeschema_id.h>
  30. #include <sch_draw_panel.h>
  31. #include <confirm.h>
  32. #include <sch_edit_frame.h>
  33. #include <menus_helpers.h>
  34. #include <advanced_config.h>
  35. #include <class_library.h>
  36. #include <general.h>
  37. #include <hotkeys.h>
  38. #include <netlist_object.h>
  39. #include <sch_bus_entry.h>
  40. #include <sch_marker.h>
  41. #include <sch_text.h>
  42. #include <sch_junction.h>
  43. #include <sch_component.h>
  44. #include <sch_line.h>
  45. #include <sch_no_connect.h>
  46. #include <sch_sheet.h>
  47. #include <sch_sheet_path.h>
  48. #include <sch_bitmap.h>
  49. #include <symbol_lib_table.h>
  50. #include <sch_connection.h>
  51. #include <sch_view.h>
  52. #include <iostream>
  53. #include <tools/sch_actions.h>
  54. static void AddMenusForBlock( wxMenu* PopMenu, SCH_EDIT_FRAME* frame );
  55. static void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, SCH_EDIT_FRAME* frame );
  56. static void AddMenusForBus( wxMenu* PopMenu, SCH_LINE* Bus, SCH_EDIT_FRAME* frame );
  57. static void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet );
  58. static void AddMenusForSheetPin( wxMenu* PopMenu, SCH_SHEET_PIN* PinSheet );
  59. static void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text );
  60. static void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label );
  61. static void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel );
  62. static void AddMenusForHLabel( wxMenu* PopMenu, SCH_HIERLABEL* GLabel );
  63. static void AddMenusForEditComponent( wxMenu* PopMenu, SCH_COMPONENT* Component,
  64. SYMBOL_LIB_TABLE* aLibs );
  65. static void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component,
  66. SYMBOL_LIB_TABLE* aLibs );
  67. static void AddMenusForComponentField( wxMenu* PopMenu, SCH_FIELD* Field );
  68. static void AddMenusForMarkers( wxMenu* aPopMenu, SCH_MARKER* aMarker, SCH_EDIT_FRAME* aFrame );
  69. static void AddMenusForBitmap( wxMenu* aPopMenu, SCH_BITMAP * aBitmap );
  70. static void AddMenusForBusEntry( wxMenu* aPopMenu, SCH_BUS_ENTRY_BASE * aBusEntry );
  71. bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
  72. {
  73. SCH_ITEM* item = GetScreen()->GetCurItem();
  74. bool blockActive = GetScreen()->IsBlockActive();
  75. wxString msg;
  76. // Ugly hack, clear any highligthed symbol, because the HIGHLIGHT flag create issues when creating menus
  77. // Will be fixed later
  78. GetCanvas()->GetView()->HighlightItem( nullptr, nullptr );
  79. // Do not start a block command on context menu.
  80. m_canvas->SetCanStartBlock( -1 );
  81. if( blockActive )
  82. {
  83. AddMenusForBlock( PopMenu, this );
  84. PopMenu->AppendSeparator();
  85. // If we have a block containing only one main element we append its edit submenu
  86. if( item != NULL )
  87. {
  88. switch( item->Type() )
  89. {
  90. case SCH_COMPONENT_T:
  91. AddMenusForEditComponent( PopMenu, (SCH_COMPONENT *) item,
  92. Prj().SchSymbolLibTable() );
  93. PopMenu->AppendSeparator();
  94. break;
  95. case SCH_TEXT_T:
  96. msg = AddHotkeyName( _( "Edit Text..." ), g_Schematic_Hotkeys_Descr, HK_EDIT );
  97. AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
  98. PopMenu->AppendSeparator();
  99. break;
  100. case SCH_LABEL_T:
  101. msg = AddHotkeyName( _( "Edit Label..." ), g_Schematic_Hotkeys_Descr, HK_EDIT );
  102. AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
  103. PopMenu->AppendSeparator();
  104. break;
  105. case SCH_GLOBAL_LABEL_T:
  106. msg = AddHotkeyName( _( "Edit Global Label..." ), g_Schematic_Hotkeys_Descr,
  107. HK_EDIT );
  108. AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
  109. PopMenu->AppendSeparator();
  110. break;
  111. case SCH_HIER_LABEL_T:
  112. msg = AddHotkeyName( _( "Edit Hierarchical Label..." ), g_Schematic_Hotkeys_Descr,
  113. HK_EDIT );
  114. AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
  115. PopMenu->AppendSeparator();
  116. break;
  117. case SCH_BITMAP_T:
  118. msg = AddHotkeyName( _( "Edit Image..." ), g_Schematic_Hotkeys_Descr, HK_EDIT );
  119. AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( image_xpm ) );
  120. PopMenu->AppendSeparator();
  121. break;
  122. default:
  123. break;
  124. }
  125. }
  126. return true;
  127. }
  128. // Try to locate items at cursor position.
  129. if( (item == NULL) || (item->GetFlags() == 0) )
  130. {
  131. bool actionCancelled = false;
  132. item = LocateAndShowItem( aPosition, SCH_COLLECTOR::AllItemsButPins, 0, &actionCancelled );
  133. // If the clarify item selection context menu is aborted, don't show the context menu.
  134. if( item == NULL && actionCancelled )
  135. return false;
  136. }
  137. // If a command is in progress: add "cancel" and "end tool" menu
  138. if( GetToolId() != ID_NO_TOOL_SELECTED )
  139. {
  140. if( item && item->GetFlags() )
  141. {
  142. AddMenuItem( PopMenu, ID_CANCEL_CURRENT_COMMAND, _( "Cancel" ),
  143. KiBitmap( cancel_xpm ) );
  144. }
  145. else
  146. {
  147. AddMenuItem( PopMenu, ID_CANCEL_CURRENT_COMMAND, _( "End Tool" ),
  148. KiBitmap( cursor_xpm ) );
  149. }
  150. PopMenu->AppendSeparator();
  151. switch( GetToolId() )
  152. {
  153. case ID_WIRE_BUTT:
  154. AddMenusForWire( PopMenu, NULL, this );
  155. if( item == NULL )
  156. PopMenu->AppendSeparator();
  157. break;
  158. case ID_BUS_BUTT:
  159. AddMenusForBus( PopMenu, NULL, this );
  160. if( item == NULL )
  161. PopMenu->AppendSeparator();
  162. break;
  163. default:
  164. break;
  165. }
  166. }
  167. else
  168. {
  169. if( item && item->GetFlags() )
  170. {
  171. AddMenuItem( PopMenu, ID_CANCEL_CURRENT_COMMAND, _( "Cancel" ),
  172. KiBitmap( cancel_xpm ) );
  173. PopMenu->AppendSeparator();
  174. }
  175. }
  176. if( item == NULL )
  177. {
  178. if( GetToolId() == ID_NO_TOOL_SELECTED && m_blockItems.GetCount() > 0 )
  179. {
  180. msg = AddHotkeyName( _( "&Paste" ), g_Schematic_Hotkeys_Descr, HK_EDIT_PASTE );
  181. AddMenuItem( PopMenu, wxID_PASTE, msg,
  182. _( "Pastes item(s) from the Clipboard" ),
  183. KiBitmap( paste_xpm ) );
  184. PopMenu->AppendSeparator();
  185. }
  186. if( g_CurrentSheet->Last() != g_RootSheet )
  187. {
  188. msg = AddHotkeyName( _( "Leave Sheet" ), g_Schematic_Hotkeys_Descr, HK_LEAVE_SHEET );
  189. AddMenuItem( PopMenu, ID_POPUP_SCH_LEAVE_SHEET, msg,
  190. KiBitmap( leave_sheet_xpm ) );
  191. PopMenu->AppendSeparator();
  192. }
  193. return true;
  194. }
  195. bool is_new = item->IsNew();
  196. switch( item->Type() )
  197. {
  198. case SCH_NO_CONNECT_T:
  199. AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete No Connect" ),
  200. KiBitmap( delete_xpm ) );
  201. break;
  202. case SCH_JUNCTION_T:
  203. addJunctionMenuEntries( PopMenu, (SCH_JUNCTION*) item );
  204. break;
  205. case SCH_BUS_BUS_ENTRY_T:
  206. case SCH_BUS_WIRE_ENTRY_T:
  207. AddMenusForBusEntry( PopMenu, static_cast<SCH_BUS_ENTRY_BASE*>( item ) );
  208. break;
  209. case SCH_MARKER_T:
  210. AddMenusForMarkers( PopMenu, (SCH_MARKER*) item, this );
  211. break;
  212. case SCH_TEXT_T:
  213. AddMenusForText( PopMenu, (SCH_TEXT*) item );
  214. break;
  215. case SCH_LABEL_T:
  216. AddMenusForLabel( PopMenu, (SCH_LABEL*) item );
  217. break;
  218. case SCH_GLOBAL_LABEL_T:
  219. AddMenusForGLabel( PopMenu, (SCH_GLOBALLABEL*) item );
  220. break;
  221. case SCH_HIER_LABEL_T:
  222. AddMenusForHLabel( PopMenu, (SCH_HIERLABEL*) item );
  223. break;
  224. case SCH_FIELD_T:
  225. AddMenusForComponentField( PopMenu, (SCH_FIELD*) item );
  226. break;
  227. case SCH_COMPONENT_T:
  228. AddMenusForComponent( PopMenu, (SCH_COMPONENT*) item, Prj().SchSymbolLibTable() );
  229. break;
  230. case SCH_BITMAP_T:
  231. AddMenusForBitmap( PopMenu, (SCH_BITMAP*) item );
  232. break;
  233. case SCH_LINE_T:
  234. switch( item->GetLayer() )
  235. {
  236. case LAYER_WIRE:
  237. AddMenusForWire( PopMenu, (SCH_LINE*) item, this );
  238. break;
  239. case LAYER_BUS:
  240. AddMenusForBus( PopMenu, (SCH_LINE*) item, this );
  241. break;
  242. default:
  243. if( is_new )
  244. AddMenuItem( PopMenu, ID_POPUP_END_LINE, _( "End Drawing" ),
  245. KiBitmap( checked_ok_xpm ) );
  246. AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, _( "Edit..." ),
  247. KiBitmap( edit_xpm ) );
  248. AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Drawing" ),
  249. KiBitmap( delete_xpm ) );
  250. break;
  251. }
  252. break;
  253. case SCH_SHEET_T:
  254. AddMenusForHierchicalSheet( PopMenu, (SCH_SHEET*) item );
  255. break;
  256. case SCH_SHEET_PIN_T:
  257. AddMenusForSheetPin( PopMenu, (SCH_SHEET_PIN*) item );
  258. break;
  259. default:
  260. wxFAIL_MSG( wxString::Format( wxT( "Cannot create context menu for unknown type %d" ),
  261. item->Type() ) );
  262. break;
  263. }
  264. PopMenu->AppendSeparator();
  265. return true;
  266. }
  267. void AddMenusForComponentField( wxMenu* PopMenu, SCH_FIELD* Field )
  268. {
  269. wxString msg, name;
  270. if( !Field->GetFlags() )
  271. {
  272. switch( Field->GetId() )
  273. {
  274. case REFERENCE: name = _( "Move Reference" ); break;
  275. case VALUE: name = _( "Move Value" ); break;
  276. case FOOTPRINT: name = _( "Move Footprint Field" ); break;
  277. default: name = _( "Move Field" ); break;
  278. }
  279. msg = AddHotkeyName( name, g_Schematic_Hotkeys_Descr,
  280. HK_MOVE_COMPONENT_OR_ITEM );
  281. AddMenuItem( PopMenu, ID_SCH_MOVE_ITEM, msg, KiBitmap( move_xpm ) );
  282. }
  283. switch( Field->GetId() )
  284. {
  285. case REFERENCE: name = _( "Rotate Reference" ); break;
  286. case VALUE: name = _( "Rotate Value" ); break;
  287. case FOOTPRINT: name = _( "Rotate Footprint Field" ); break;
  288. default: name = _( "Rotate Field" ); break;
  289. }
  290. msg = AddHotkeyName( name, g_Schematic_Hotkeys_Descr, HK_ROTATE );
  291. AddMenuItem( PopMenu, ID_SCH_ROTATE_CLOCKWISE, msg, KiBitmap( rotate_cw_xpm ) );
  292. // Ref, value and footprint have specific hotkeys. Show the specific hotkey:
  293. hotkey_id_commnand id;
  294. switch( Field->GetId() )
  295. {
  296. case REFERENCE:
  297. id = HK_EDIT_COMPONENT_REFERENCE;
  298. name = _( "Edit Reference..." );
  299. break;
  300. case VALUE:
  301. id = HK_EDIT_COMPONENT_VALUE;
  302. name = _( "Edit Value..." );
  303. break;
  304. case FOOTPRINT:
  305. id = HK_EDIT_COMPONENT_FOOTPRINT;
  306. name = _( "Edit Footprint Field..." );
  307. break;
  308. case DATASHEET:
  309. id = HK_SHOW_COMPONENT_DATASHEET;
  310. name = _( "Show Datasheet" );
  311. break;
  312. default:
  313. id = HK_EDIT;
  314. name = _( "Edit Field..." );
  315. break;
  316. }
  317. msg = AddHotkeyName( name, g_Schematic_Hotkeys_Descr, id );
  318. AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
  319. }
  320. void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component, SYMBOL_LIB_TABLE* aLibs )
  321. {
  322. if( Component->Type() != SCH_COMPONENT_T )
  323. {
  324. wxASSERT( 0 );
  325. return;
  326. }
  327. wxString msg;
  328. if( !Component->GetFlags() )
  329. {
  330. msg.Printf( _( "Move %s" ), Component->GetField( REFERENCE )->GetText() );
  331. msg = AddHotkeyName( msg, g_Schematic_Hotkeys_Descr, HK_MOVE_COMPONENT_OR_ITEM );
  332. AddMenuItem( PopMenu, ID_SCH_MOVE_ITEM, msg, KiBitmap( move_xpm ) );
  333. msg = AddHotkeyName( _( "Drag" ), g_Schematic_Hotkeys_Descr, HK_DRAG );
  334. AddMenuItem( PopMenu, ID_SCH_DRAG_ITEM, msg, KiBitmap( drag_xpm ) );
  335. }
  336. wxMenu* orientmenu = new wxMenu;
  337. msg = AddHotkeyName( _( "Rotate Clockwise" ), g_Schematic_Hotkeys_Descr, HK_ROTATE );
  338. AddMenuItem( orientmenu, ID_SCH_ROTATE_CLOCKWISE, msg, KiBitmap( rotate_cw_xpm ) );
  339. AddMenuItem( orientmenu, ID_SCH_ROTATE_COUNTERCLOCKWISE, _( "Rotate Counterclockwise" ),
  340. KiBitmap( rotate_ccw_xpm ) );
  341. msg = AddHotkeyName( _( "Mirror Around Horizontal(X) Axis" ), g_Schematic_Hotkeys_Descr,
  342. HK_MIRROR_X );
  343. AddMenuItem( orientmenu, ID_SCH_MIRROR_X, msg, KiBitmap( mirror_v_xpm ) );
  344. msg = AddHotkeyName( _( "Mirror Around Vertical(Y) Axis" ), g_Schematic_Hotkeys_Descr,
  345. HK_MIRROR_Y );
  346. AddMenuItem( orientmenu, ID_SCH_MIRROR_Y, msg, KiBitmap( mirror_h_xpm ) );
  347. msg = AddHotkeyName( _( "Reset to Default" ), g_Schematic_Hotkeys_Descr,
  348. HK_ORIENT_NORMAL_COMPONENT );
  349. AddMenuItem( orientmenu, ID_SCH_ORIENT_NORMAL, msg, KiBitmap( normal_xpm ) );
  350. AddMenuItem( PopMenu, orientmenu, ID_POPUP_SCH_GENERIC_ORIENT_CMP,
  351. _( "Orientation" ), KiBitmap( orient_xpm ) );
  352. AddMenusForEditComponent( PopMenu, Component, aLibs );
  353. if( !Component->GetFlags() )
  354. {
  355. msg = AddHotkeyName( _( "Duplicate" ), g_Schematic_Hotkeys_Descr,
  356. HK_DUPLICATE_ITEM );
  357. AddMenuItem( PopMenu, ID_POPUP_SCH_DUPLICATE_ITEM, msg, KiBitmap( duplicate_xpm ) );
  358. msg = AddHotkeyName( _( "Delete" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
  359. AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE_CMP, msg, KiBitmap( delete_xpm ) );
  360. }
  361. msg = AddHotkeyName( _( "Autoplace Fields" ), g_Schematic_Hotkeys_Descr, HK_AUTOPLACE_FIELDS );
  362. AddMenuItem( PopMenu, ID_AUTOPLACE_FIELDS, msg, KiBitmap( autoplace_fields_xpm ) );
  363. if( !Component->GetField( DATASHEET )->GetFullyQualifiedText().IsEmpty() )
  364. AddMenuItem( PopMenu, ID_POPUP_SCH_DISPLAYDOC_CMP, _( "Open Documentation" ),
  365. KiBitmap( datasheet_xpm ) );
  366. }
  367. void AddMenusForEditComponent( wxMenu* PopMenu, SCH_COMPONENT* Component, SYMBOL_LIB_TABLE* aLibs )
  368. {
  369. if( Component->Type() != SCH_COMPONENT_T )
  370. {
  371. wxASSERT( 0 );
  372. return;
  373. }
  374. wxString msg;
  375. LIB_PART* part = NULL;
  376. LIB_ALIAS* alias = NULL;
  377. try
  378. {
  379. alias = aLibs->LoadSymbol( Component->GetLibId() );
  380. }
  381. catch( ... )
  382. {
  383. }
  384. if( alias )
  385. part = alias->GetPart();
  386. wxMenu* editmenu = new wxMenu;
  387. msg = AddHotkeyName( _( "Edit Properties..." ), g_Schematic_Hotkeys_Descr, HK_EDIT );
  388. AddMenuItem( editmenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( config_xpm ) );
  389. if( part && part->IsNormal() )
  390. {
  391. msg = AddHotkeyName( _( "Edit Value..." ), g_Schematic_Hotkeys_Descr,
  392. HK_EDIT_COMPONENT_VALUE );
  393. AddMenuItem( editmenu, ID_SCH_EDIT_COMPONENT_VALUE, msg,
  394. KiBitmap( edit_comp_value_xpm ) );
  395. msg = AddHotkeyName( _( "Edit Reference..." ), g_Schematic_Hotkeys_Descr,
  396. HK_EDIT_COMPONENT_REFERENCE );
  397. AddMenuItem( editmenu, ID_SCH_EDIT_COMPONENT_REFERENCE, msg,
  398. KiBitmap( edit_comp_ref_xpm ) );
  399. msg = AddHotkeyName( _( "Edit Footprint..." ), g_Schematic_Hotkeys_Descr,
  400. HK_EDIT_COMPONENT_FOOTPRINT );
  401. AddMenuItem( editmenu, ID_SCH_EDIT_COMPONENT_FOOTPRINT, msg,
  402. KiBitmap( edit_comp_footprint_xpm ) );
  403. msg = AddHotkeyName( _( "Show Datasheet" ), g_Schematic_Hotkeys_Descr,
  404. HK_SHOW_COMPONENT_DATASHEET );
  405. AddMenuItem( editmenu, ID_POPUP_SCH_DISPLAYDOC_CMP, msg,
  406. KiBitmap( datasheet_xpm ) );
  407. }
  408. if( part && part->HasConversion() )
  409. AddMenuItem( editmenu, ID_POPUP_SCH_EDIT_CONVERT_CMP, _( "Convert" ),
  410. KiBitmap( component_select_alternate_shape_xpm ) );
  411. if( part && part->GetUnitCount() >= 2 )
  412. {
  413. wxMenu* sel_unit_menu = new wxMenu; int ii;
  414. for( ii = 0; ii < part->GetUnitCount(); ii++ )
  415. {
  416. wxString num_unit;
  417. int unit = Component->GetUnit();
  418. num_unit.Printf( _( "Unit %s" ), GetChars( LIB_PART::SubReference( ii + 1, false ) ) );
  419. wxMenuItem * item = sel_unit_menu->Append( ID_POPUP_SCH_SELECT_UNIT1 + ii,
  420. num_unit, wxEmptyString,
  421. wxITEM_CHECK );
  422. if( unit == ii + 1 )
  423. item->Check(true);
  424. // The ID max for these submenus is ID_POPUP_SCH_SELECT_UNIT_CMP_MAX
  425. // See eeschema_id to modify this value.
  426. if( ii >= (ID_POPUP_SCH_SELECT_UNIT_CMP_MAX - ID_POPUP_SCH_SELECT_UNIT1) )
  427. break; // We have used all IDs for these submenus
  428. }
  429. AddMenuItem( editmenu, sel_unit_menu, ID_POPUP_SCH_SELECT_UNIT_CMP,
  430. _( "Unit" ), KiBitmap( component_select_unit_xpm ) );
  431. }
  432. if( !Component->GetFlags() )
  433. {
  434. msg = AddHotkeyName( _( "Edit with Library Editor" ), g_Schematic_Hotkeys_Descr,
  435. HK_EDIT_COMPONENT_WITH_LIBEDIT );
  436. AddMenuItem( editmenu, ID_POPUP_SCH_CALL_LIBEDIT_AND_LOAD_CMP,
  437. msg, KiBitmap( libedit_xpm ) );
  438. }
  439. AddMenuItem( PopMenu, editmenu, ID_SCH_EDIT_ITEM,
  440. _( "Properties" ), KiBitmap( config_xpm ) );
  441. }
  442. void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel )
  443. {
  444. wxMenu* menu_change_type = new wxMenu;
  445. wxString msg;
  446. if( !GLabel->GetFlags() )
  447. {
  448. msg = AddHotkeyName( _( "Move" ), g_Schematic_Hotkeys_Descr,
  449. HK_MOVE_COMPONENT_OR_ITEM );
  450. AddMenuItem( PopMenu, ID_SCH_MOVE_ITEM, msg, KiBitmap( move_xpm ) );
  451. msg = AddHotkeyName( _( "Drag" ), g_Schematic_Hotkeys_Descr,
  452. HK_DRAG );
  453. AddMenuItem( PopMenu, ID_SCH_DRAG_ITEM, msg, KiBitmap( drag_xpm ) );
  454. msg = AddHotkeyName( _( "Duplicate" ), g_Schematic_Hotkeys_Descr,
  455. HK_DUPLICATE_ITEM );
  456. AddMenuItem( PopMenu, ID_POPUP_SCH_DUPLICATE_ITEM, msg, KiBitmap( duplicate_xpm ) );
  457. }
  458. msg = AddHotkeyName( _( "Rotate Clockwise" ), g_Schematic_Hotkeys_Descr, HK_ROTATE );
  459. AddMenuItem( PopMenu, ID_SCH_ROTATE_CLOCKWISE, msg, KiBitmap( rotate_cw_xpm ) );
  460. msg = AddHotkeyName( _( "Edit..." ), g_Schematic_Hotkeys_Descr, HK_EDIT );
  461. AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
  462. msg = AddHotkeyName( _( "Delete" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
  463. AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, msg, KiBitmap( delete_xpm ) );
  464. // add menu change type text (to label, glabel, text):
  465. AddMenuItem( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL,
  466. _( "Change to Hierarchical Label" ), KiBitmap( label2glabel_xpm ) );
  467. AddMenuItem( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL,
  468. _( "Change to Label" ), KiBitmap( glabel2label_xpm ) );
  469. AddMenuItem( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT,
  470. _( "Change to Text" ), KiBitmap( glabel2text_xpm ) );
  471. AddMenuItem( PopMenu, menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT,
  472. _( "Change Type" ), KiBitmap( gl_change_xpm ) );
  473. }
  474. void AddMenusForHLabel( wxMenu* PopMenu, SCH_HIERLABEL* HLabel )
  475. {
  476. wxMenu* menu_change_type = new wxMenu;
  477. wxString msg;
  478. if( !HLabel->GetFlags() )
  479. {
  480. msg = AddHotkeyName( _( "Move" ), g_Schematic_Hotkeys_Descr,
  481. HK_MOVE_COMPONENT_OR_ITEM );
  482. AddMenuItem( PopMenu, ID_SCH_MOVE_ITEM, msg, KiBitmap( move_xpm ) );
  483. msg = AddHotkeyName( _( "Drag" ), g_Schematic_Hotkeys_Descr, HK_DRAG );
  484. AddMenuItem( PopMenu, ID_SCH_DRAG_ITEM, msg, KiBitmap( drag_xpm ) );
  485. msg = AddHotkeyName( _( "Copy" ), g_Schematic_Hotkeys_Descr,
  486. HK_DUPLICATE_ITEM );
  487. AddMenuItem( PopMenu, ID_POPUP_SCH_DUPLICATE_ITEM, msg, KiBitmap( copy_xpm ) );
  488. }
  489. msg = AddHotkeyName( _( "Rotate Clockwise" ), g_Schematic_Hotkeys_Descr, HK_ROTATE );
  490. AddMenuItem( PopMenu, ID_SCH_ROTATE_CLOCKWISE, msg, KiBitmap( rotate_cw_xpm ) );
  491. msg = AddHotkeyName( _( "Edit..." ), g_Schematic_Hotkeys_Descr, HK_EDIT );
  492. AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
  493. msg = AddHotkeyName( _( "Delete" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
  494. AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, msg, KiBitmap( delete_xpm ) );
  495. // add menu change type text (to label, glabel, text):
  496. AddMenuItem( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL,
  497. _( "Change to Label" ), KiBitmap( glabel2label_xpm ) );
  498. AddMenuItem( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT,
  499. _( "Change to Text" ), KiBitmap( glabel2text_xpm ) );
  500. AddMenuItem( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL,
  501. _( "Change to Global Label" ), KiBitmap( label2glabel_xpm ) );
  502. AddMenuItem( PopMenu, menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT,
  503. _( "Change Type" ), KiBitmap( gl_change_xpm ) );
  504. }
  505. void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label )
  506. {
  507. wxMenu* menu_change_type = new wxMenu;
  508. wxString msg;
  509. if( !Label->GetFlags() )
  510. {
  511. msg = AddHotkeyName( _( "Move" ), g_Schematic_Hotkeys_Descr, HK_MOVE_COMPONENT_OR_ITEM );
  512. AddMenuItem( PopMenu, ID_SCH_MOVE_ITEM, msg, KiBitmap( move_xpm ) );
  513. msg = AddHotkeyName( _( "Drag" ), g_Schematic_Hotkeys_Descr, HK_DRAG );
  514. AddMenuItem( PopMenu, ID_SCH_DRAG_ITEM, msg, KiBitmap( drag_xpm ) );
  515. msg = AddHotkeyName( _( "Duplicate" ), g_Schematic_Hotkeys_Descr, HK_DUPLICATE_ITEM );
  516. AddMenuItem( PopMenu, ID_POPUP_SCH_DUPLICATE_ITEM, msg, KiBitmap( duplicate_xpm ) );
  517. }
  518. msg = AddHotkeyName( _( "Rotate Counterclockwise" ), g_Schematic_Hotkeys_Descr, HK_ROTATE );
  519. AddMenuItem( PopMenu, ID_SCH_ROTATE_CLOCKWISE, msg, KiBitmap( rotate_ccw_xpm ) );
  520. msg = AddHotkeyName( _( "Edit..." ), g_Schematic_Hotkeys_Descr, HK_EDIT );
  521. AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
  522. msg = AddHotkeyName( _( "Delete" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
  523. AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, msg, KiBitmap( delete_xpm ) );
  524. // add menu change type text (to label, glabel, text):
  525. AddMenuItem( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL,
  526. _( "Change to Hierarchical Label" ), KiBitmap( label2glabel_xpm ) );
  527. AddMenuItem( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT,
  528. _( "Change to Text" ), KiBitmap( label2text_xpm ) );
  529. AddMenuItem( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL,
  530. _( "Change to Global Label" ), KiBitmap( label2glabel_xpm ) );
  531. AddMenuItem( PopMenu, menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT,
  532. _( "Change Type" ), KiBitmap( gl_change_xpm ) );
  533. }
  534. void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text )
  535. {
  536. wxString msg;
  537. wxMenu* menu_change_type = new wxMenu;
  538. if( !Text->GetFlags() )
  539. {
  540. msg = AddHotkeyName( _( "Move" ), g_Schematic_Hotkeys_Descr, HK_MOVE_COMPONENT_OR_ITEM );
  541. AddMenuItem( PopMenu, ID_SCH_MOVE_ITEM, msg, KiBitmap( move_xpm ) );
  542. msg = AddHotkeyName( _( "Duplicate" ), g_Schematic_Hotkeys_Descr, HK_DUPLICATE_ITEM );
  543. AddMenuItem( PopMenu, ID_POPUP_SCH_DUPLICATE_ITEM, msg, KiBitmap( duplicate_xpm ) );
  544. }
  545. msg = AddHotkeyName( _( "Rotate Counterclockwise" ), g_Schematic_Hotkeys_Descr, HK_ROTATE );
  546. AddMenuItem( PopMenu, ID_SCH_ROTATE_CLOCKWISE, msg, KiBitmap( rotate_ccw_xpm ) );
  547. msg = AddHotkeyName( _( "Edit..." ), g_Schematic_Hotkeys_Descr, HK_EDIT );
  548. AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
  549. msg = AddHotkeyName( _( "Delete" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
  550. AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, msg, KiBitmap( delete_xpm ) );
  551. /* add menu change type text (to label, glabel, text),
  552. * but only if this is a single line text
  553. */
  554. if( Text->GetText().Find( wxT( "\n" ) ) == wxNOT_FOUND )
  555. {
  556. AddMenuItem( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL,
  557. _( "Change to Label" ), KiBitmap( label2text_xpm ) );
  558. AddMenuItem( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL,
  559. _( "Change to Hierarchical Label" ), KiBitmap( label2glabel_xpm ) );
  560. AddMenuItem( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL,
  561. _( "Change to Global Label" ), KiBitmap( label2glabel_xpm ) );
  562. AddMenuItem( PopMenu, menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT,
  563. _( "Change Type" ), KiBitmap( gl_change_xpm ) );
  564. }
  565. }
  566. void SCH_EDIT_FRAME::addJunctionMenuEntries( wxMenu* aMenu, SCH_JUNCTION* aJunction )
  567. {
  568. wxString msg;
  569. SCH_SCREEN* screen = GetScreen();
  570. msg = AddHotkeyName( _( "Delete Junction" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
  571. AddMenuItem( aMenu, ID_POPUP_SCH_DELETE, msg, KiBitmap( delete_xpm ) );
  572. if( !aJunction->IsNew() )
  573. {
  574. if( m_collectedItems.IsDraggableJunction() )
  575. AddMenuItem( aMenu, ID_SCH_DRAG_ITEM, _( "Drag Junction" ), KiBitmap( drag_xpm ) );
  576. if( screen->GetWire( aJunction->GetPosition(), EXCLUDE_END_POINTS_T ) )
  577. AddMenuItem( aMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ),
  578. KiBitmap( break_line_xpm ) );
  579. }
  580. if( screen->GetWireOrBus( aJunction->GetPosition() ) )
  581. {
  582. AddMenuItem( aMenu, ID_POPUP_SCH_DELETE_NODE, _( "Delete Node" ),
  583. KiBitmap( delete_node_xpm ) );
  584. AddMenuItem( aMenu, ID_POPUP_SCH_DELETE_CONNECTION, _( "Delete Connection" ),
  585. KiBitmap( delete_connection_xpm ) );
  586. }
  587. }
  588. void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, SCH_EDIT_FRAME* frame )
  589. {
  590. SCH_SCREEN* screen = frame->GetScreen();
  591. wxPoint pos = frame->GetCrossHairPosition();
  592. wxString msg;
  593. if( Wire == NULL )
  594. {
  595. msg = AddHotkeyName( _( "Begin Wire" ), g_Schematic_Hotkeys_Descr, HK_BEGIN_WIRE );
  596. AddMenuItem( PopMenu, ID_POPUP_SCH_BEGIN_WIRE, msg, KiBitmap( add_line_xpm ) );
  597. return;
  598. }
  599. if( Wire->IsNew() )
  600. {
  601. msg = AddHotkeyName( _( "Wire End" ), g_Schematic_Hotkeys_Descr, HK_END_CURR_LINEWIREBUS );
  602. AddMenuItem( PopMenu, ID_POPUP_END_LINE, msg, KiBitmap( checked_ok_xpm ) );
  603. return;
  604. }
  605. msg = AddHotkeyName( _( "Drag Wire" ), g_Schematic_Hotkeys_Descr, HK_DRAG );
  606. AddMenuItem( PopMenu, ID_SCH_DRAG_ITEM, msg, KiBitmap( drag_xpm ) );
  607. PopMenu->AppendSeparator();
  608. msg = AddHotkeyName( _( "Delete Wire" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
  609. AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, msg, KiBitmap( delete_xpm ) );
  610. AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE_NODE, _( "Delete Node" ),
  611. KiBitmap( delete_node_xpm ) );
  612. AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, _( "Delete Connection" ),
  613. KiBitmap( delete_connection_xpm ) );
  614. SCH_LINE* line = screen->GetWireOrBus( frame->GetCrossHairPosition() );
  615. if( line && !line->IsEndPoint( frame->GetCrossHairPosition() ) )
  616. AddMenuItem( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ),
  617. KiBitmap( break_line_xpm ) );
  618. PopMenu->AppendSeparator();
  619. msg = AddHotkeyName( _( "Add Junction" ), g_Schematic_Hotkeys_Descr, HK_ADD_JUNCTION );
  620. AddMenuItem( PopMenu, ID_POPUP_SCH_ADD_JUNCTION, msg, KiBitmap( add_junction_xpm ) );
  621. msg = AddHotkeyName( _( "Add Label..." ), g_Schematic_Hotkeys_Descr, HK_ADD_LABEL );
  622. AddMenuItem( PopMenu, ID_POPUP_SCH_ADD_LABEL, msg, KiBitmap( add_line_label_xpm ) );
  623. // Add global label command only if the cursor is over one end of the wire.
  624. if( Wire->IsEndPoint( pos ) )
  625. AddMenuItem( PopMenu, ID_POPUP_SCH_ADD_GLABEL, _( "Add Global Label..." ),
  626. KiBitmap( add_glabel_xpm ) );
  627. }
  628. void AddMenusForBus( wxMenu* PopMenu, SCH_LINE* Bus, SCH_EDIT_FRAME* frame )
  629. {
  630. wxPoint pos = frame->GetCrossHairPosition();
  631. wxString msg;
  632. if( Bus == NULL )
  633. {
  634. msg = AddHotkeyName( _( "Begin Bus" ), g_Schematic_Hotkeys_Descr, HK_BEGIN_BUS );
  635. AddMenuItem( PopMenu, ID_POPUP_SCH_BEGIN_BUS, msg, KiBitmap( add_bus_xpm ) );
  636. return;
  637. }
  638. if( Bus->IsNew() )
  639. {
  640. msg = AddHotkeyName( _( "Bus End" ), g_Schematic_Hotkeys_Descr, HK_END_CURR_LINEWIREBUS );
  641. AddMenuItem( PopMenu, ID_POPUP_END_LINE, msg, KiBitmap( checked_ok_xpm ) );
  642. return;
  643. }
  644. msg = AddHotkeyName( _( "Delete Bus" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
  645. AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, msg, KiBitmap( delete_bus_xpm ) );
  646. AddMenuItem( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Bus" ), KiBitmap( break_bus_xpm ) );
  647. // TODO(JE) remove once real-time is enabled
  648. if( !ADVANCED_CFG::GetCfg().m_realTimeConnectivity )
  649. {
  650. frame->RecalculateConnections();
  651. // Have to pick up the pointer again because it may have been changed by SchematicCleanUp
  652. bool actionCancelled = false;
  653. Bus = dynamic_cast<SCH_LINE*>( frame->LocateAndShowItem( pos, SCH_COLLECTOR::AllItemsButPins,
  654. 0, &actionCancelled ) );
  655. wxASSERT( Bus );
  656. }
  657. // Bus unfolding menu (only available if bus is properly defined)
  658. auto connection = Bus->Connection( *g_CurrentSheet );
  659. if( connection && connection->IsBus() && connection->Members().size() > 0 )
  660. {
  661. int idx = 0;
  662. wxMenu* bus_unfolding_menu = new wxMenu;
  663. PopMenu->AppendSubMenu( bus_unfolding_menu, _( "Unfold Bus" ) );
  664. for( const auto& member : connection->Members() )
  665. {
  666. int id = ID_POPUP_SCH_UNFOLD_BUS + ( idx++ );
  667. auto name = member->Name( true );
  668. if( member->Type() == CONNECTION_BUS )
  669. {
  670. wxMenu* submenu = new wxMenu;
  671. bus_unfolding_menu->AppendSubMenu( submenu, _( name ) );
  672. for( const auto& sub_member : member->Members() )
  673. {
  674. id = ID_POPUP_SCH_UNFOLD_BUS + ( idx++ );
  675. submenu->Append( id, sub_member->Name( true ), wxEmptyString );
  676. // See comment in else clause below
  677. auto sub_item_clone = new wxMenuItem();
  678. sub_item_clone->SetItemLabel( sub_member->Name( true ) );
  679. frame->Bind( wxEVT_COMMAND_MENU_SELECTED, &SCH_EDIT_FRAME::OnUnfoldBus,
  680. frame, id, id, sub_item_clone );
  681. }
  682. }
  683. else
  684. {
  685. bus_unfolding_menu->Append( id, name, wxEmptyString );
  686. // Because Bind() takes ownership of the user data item, we
  687. // make a new menu item here and set its label. Why create a
  688. // menu item instead of just a wxString or something? Because
  689. // Bind() requires a pointer to wxObject rather than a void
  690. // pointer. Maybe at some point I'll think of a better way...
  691. auto item_clone = new wxMenuItem();
  692. item_clone->SetItemLabel( name );
  693. frame->Bind( wxEVT_COMMAND_MENU_SELECTED, &SCH_EDIT_FRAME::OnUnfoldBus,
  694. frame, id, id, item_clone );
  695. }
  696. }
  697. }
  698. PopMenu->AppendSeparator();
  699. msg = AddHotkeyName( _( "Add Junction" ), g_Schematic_Hotkeys_Descr, HK_ADD_JUNCTION );
  700. AddMenuItem( PopMenu, ID_POPUP_SCH_ADD_JUNCTION, msg, KiBitmap( add_junction_xpm ) );
  701. msg = AddHotkeyName( _( "Add Label..." ), g_Schematic_Hotkeys_Descr, HK_ADD_LABEL );
  702. AddMenuItem( PopMenu, ID_POPUP_SCH_ADD_LABEL, msg, KiBitmap( add_line_label_xpm ) );
  703. // Add global label command only if the cursor is over one end of the bus.
  704. if( Bus->IsEndPoint( pos ) )
  705. AddMenuItem( PopMenu, ID_POPUP_SCH_ADD_GLABEL, _( "Add Global Label..." ),
  706. KiBitmap( add_glabel_xpm ) );
  707. }
  708. void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet )
  709. {
  710. wxString msg;
  711. if( !Sheet->GetFlags() )
  712. {
  713. AddMenuItem( PopMenu, ID_POPUP_SCH_ENTER_SHEET, _( "Enter Sheet" ),
  714. KiBitmap( enter_sheet_xpm ) );
  715. PopMenu->AppendSeparator();
  716. msg = AddHotkeyName( _( "Move" ), g_Schematic_Hotkeys_Descr,
  717. HK_MOVE_COMPONENT_OR_ITEM );
  718. AddMenuItem( PopMenu, ID_SCH_MOVE_ITEM, msg, KiBitmap( move_xpm ) );
  719. msg = AddHotkeyName( _( "Drag" ), g_Schematic_Hotkeys_Descr, HK_DRAG );
  720. AddMenuItem( PopMenu, ID_SCH_DRAG_ITEM, msg, KiBitmap( drag_xpm ) );
  721. PopMenu->AppendSeparator();
  722. msg = AddHotkeyName( _( "Select Items On PCB" ), g_Schematic_Hotkeys_Descr,
  723. HK_SELECT_ITEMS_ON_PCB );
  724. AddMenuItem( PopMenu, ID_POPUP_SCH_SELECT_ON_PCB, msg, KiBitmap( select_same_sheet_xpm ) );
  725. PopMenu->AppendSeparator();
  726. wxMenu* orientmenu = new wxMenu;
  727. msg = AddHotkeyName( _( "Rotate Clockwise" ), g_Schematic_Hotkeys_Descr, HK_ROTATE );
  728. AddMenuItem( orientmenu, ID_SCH_ROTATE_CLOCKWISE, msg, KiBitmap( rotate_cw_xpm ) );
  729. AddMenuItem( orientmenu, ID_SCH_ROTATE_COUNTERCLOCKWISE, _( "Rotate Counterclockwise" ),
  730. KiBitmap( rotate_ccw_xpm ) );
  731. msg = AddHotkeyName( _( "Mirror Around Horizontal(X) Axis" ), g_Schematic_Hotkeys_Descr,
  732. HK_MIRROR_X );
  733. AddMenuItem( orientmenu, ID_SCH_MIRROR_X, msg, KiBitmap( mirror_v_xpm ) );
  734. msg = AddHotkeyName( _( "Mirror Around Vertical(Y) Axis" ), g_Schematic_Hotkeys_Descr,
  735. HK_MIRROR_Y );
  736. AddMenuItem( orientmenu, ID_SCH_MIRROR_Y, msg, KiBitmap( mirror_h_xpm ) );
  737. AddMenuItem( PopMenu, orientmenu, ID_POPUP_SCH_GENERIC_ORIENT_CMP,
  738. _( "Orientation" ), KiBitmap( orient_xpm ) );
  739. }
  740. if( Sheet->GetFlags() )
  741. {
  742. AddMenuItem( PopMenu, ID_POPUP_SCH_END_SHEET, _( "Place" ), KiBitmap( checked_ok_xpm ) );
  743. }
  744. else
  745. {
  746. msg = AddHotkeyName( _( "Edit..." ), g_Schematic_Hotkeys_Descr, HK_EDIT );
  747. AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( editor_xpm ) );
  748. AddMenuItem( PopMenu, ID_POPUP_SCH_RESIZE_SHEET, _( "Resize" ),
  749. KiBitmap( resize_sheet_xpm ) );
  750. PopMenu->AppendSeparator();
  751. AddMenuItem( PopMenu, ID_POPUP_IMPORT_HLABEL_TO_SHEETPIN, _( "Import Sheet Pins" ),
  752. KiBitmap( import_hierarchical_label_xpm ) );
  753. if( Sheet->HasUndefinedPins() ) // Sheet has pin labels, and can be cleaned
  754. AddMenuItem( PopMenu, ID_POPUP_SCH_CLEANUP_SHEET, _( "Cleanup Sheet Pins" ),
  755. KiBitmap( options_pinsheet_xpm ) );
  756. PopMenu->AppendSeparator();
  757. msg = AddHotkeyName( _( "Delete" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
  758. AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, msg, KiBitmap( delete_sheet_xpm ) );
  759. }
  760. }
  761. void AddMenusForSheetPin( wxMenu* PopMenu, SCH_SHEET_PIN* PinSheet )
  762. {
  763. wxString msg;
  764. if( !PinSheet->GetFlags() )
  765. {
  766. msg = AddHotkeyName( _( "Move" ), g_Schematic_Hotkeys_Descr, HK_MOVE_COMPONENT_OR_ITEM );
  767. AddMenuItem( PopMenu, ID_SCH_MOVE_ITEM, msg, KiBitmap( move_xpm ) );
  768. }
  769. AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, _( "Edit..." ), KiBitmap( edit_xpm ) );
  770. if( !PinSheet->GetFlags() )
  771. AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete" ), KiBitmap( delete_xpm ) );
  772. }
  773. void AddMenusForBlock( wxMenu* PopMenu, SCH_EDIT_FRAME* frame )
  774. {
  775. wxString msg;
  776. AddMenuItem( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel Block" ),
  777. KiBitmap( cancel_xpm ) );
  778. PopMenu->AppendSeparator();
  779. if( frame->GetScreen()->m_BlockLocate.GetCommand() == BLOCK_MOVE )
  780. AddMenuItem( PopMenu, ID_POPUP_ZOOM_BLOCK, _( "Window Zoom" ), KiBitmap( zoom_area_xpm ) );
  781. AddMenuItem( PopMenu, ID_POPUP_PLACE_BLOCK, _( "Place Block" ), KiBitmap( checked_ok_xpm ) );
  782. // After a block move (that is also a block selection) one can reselect
  783. // a block function.
  784. if( frame->GetScreen()->m_BlockLocate.GetCommand() == BLOCK_MOVE )
  785. {
  786. msg = AddHotkeyName( _( "Cut Block" ), g_Schematic_Hotkeys_Descr,
  787. HK_EDIT_CUT );
  788. AddMenuItem( PopMenu, ID_POPUP_CUT_BLOCK, msg, KiBitmap( cut_xpm ) );
  789. msg = AddHotkeyName( _( "Copy Block" ), g_Schematic_Hotkeys_Descr,
  790. HK_EDIT_COPY );
  791. AddMenuItem( PopMenu, ID_POPUP_COPY_BLOCK, msg, KiBitmap( copy_xpm ) );
  792. AddMenuItem( PopMenu, ID_POPUP_DUPLICATE_BLOCK, _( "Duplicate Block" ),
  793. KiBitmap( duplicate_xpm ) );
  794. msg = AddHotkeyName( _( "Drag Block" ), g_Schematic_Hotkeys_Descr,
  795. HK_MOVEBLOCK_TO_DRAGBLOCK );
  796. AddMenuItem( PopMenu, ID_POPUP_DRAG_BLOCK, msg, KiBitmap( drag_xpm ) );
  797. msg = AddHotkeyName( _( "Delete Block" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
  798. AddMenuItem( PopMenu, ID_POPUP_DELETE_BLOCK, msg, KiBitmap( delete_xpm ) );
  799. msg = AddHotkeyName( _( "Mirror Block Around Vertical(Y) Axis" ), g_Schematic_Hotkeys_Descr,
  800. HK_MIRROR_Y );
  801. AddMenuItem( PopMenu, ID_SCH_MIRROR_Y, msg, KiBitmap( mirror_h_xpm ) );
  802. msg = AddHotkeyName( _( "Mirror Block Around Horizontal(X) Axis" ),
  803. g_Schematic_Hotkeys_Descr, HK_MIRROR_X );
  804. AddMenuItem( PopMenu, ID_SCH_MIRROR_X, msg, KiBitmap( mirror_v_xpm ) );
  805. msg = AddHotkeyName( _( "Rotate Block CCW" ), g_Schematic_Hotkeys_Descr, HK_ROTATE );
  806. AddMenuItem( PopMenu, ID_SCH_ROTATE_CLOCKWISE, msg, KiBitmap( rotate_ccw_xpm ) );
  807. #if 0
  808. #ifdef __WINDOWS__
  809. AddMenuItem( menu_other_block_commands, ID_GEN_COPY_BLOCK_TO_CLIPBOARD,
  810. _( "Copy to Clipboard" ), KiBitmap( copy_xpm ) );
  811. #endif
  812. #endif
  813. }
  814. }
  815. void AddMenusForMarkers( wxMenu* aPopMenu, SCH_MARKER* aMarker, SCH_EDIT_FRAME* aFrame )
  816. {
  817. AddMenuItem( aPopMenu, ID_POPUP_SCH_DELETE, _( "Delete Marker" ), KiBitmap( delete_xpm ) );
  818. AddMenuItem( aPopMenu, ID_POPUP_SCH_GETINFO_MARKER, _( "Marker Error Info" ),
  819. KiBitmap( info_xpm ) );
  820. }
  821. void AddMenusForBitmap( wxMenu* aPopMenu, SCH_BITMAP * aBitmap )
  822. {
  823. wxString msg;
  824. if( aBitmap->GetFlags() == 0 )
  825. {
  826. msg = AddHotkeyName( _( "Move" ), g_Schematic_Hotkeys_Descr,
  827. HK_MOVE_COMPONENT_OR_ITEM );
  828. AddMenuItem( aPopMenu, ID_SCH_MOVE_ITEM, msg, KiBitmap( move_xpm ) );
  829. }
  830. msg = AddHotkeyName( _( "Rotate Counterclockwise" ), g_Schematic_Hotkeys_Descr, HK_ROTATE );
  831. AddMenuItem( aPopMenu, ID_SCH_ROTATE_CLOCKWISE, msg, KiBitmap( rotate_ccw_xpm ) );
  832. msg = AddHotkeyName( _( "Mirror Around Horizontal(X) Axis" ), g_Schematic_Hotkeys_Descr,
  833. HK_MIRROR_X );
  834. AddMenuItem( aPopMenu, ID_SCH_MIRROR_X, msg, KiBitmap( mirror_v_xpm ) );
  835. msg = AddHotkeyName( _( "Mirror Around Vertical(Y) Axis" ), g_Schematic_Hotkeys_Descr,
  836. HK_MIRROR_Y );
  837. AddMenuItem( aPopMenu, ID_SCH_MIRROR_Y, msg, KiBitmap( mirror_h_xpm ) );
  838. msg = AddHotkeyName( _( "Edit Image..." ), g_Schematic_Hotkeys_Descr, HK_EDIT );
  839. AddMenuItem( aPopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( image_xpm ) );
  840. if( aBitmap->GetFlags() == 0 )
  841. {
  842. aPopMenu->AppendSeparator();
  843. msg = AddHotkeyName( _( "Delete" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
  844. AddMenuItem( aPopMenu, ID_POPUP_SCH_DELETE, msg, KiBitmap( delete_xpm ) );
  845. }
  846. }
  847. void AddMenusForBusEntry( wxMenu* aPopMenu, SCH_BUS_ENTRY_BASE* aBusEntry )
  848. {
  849. wxString msg;
  850. if( !aBusEntry->GetFlags() )
  851. {
  852. msg = AddHotkeyName( _( "Move Bus Entry" ), g_Schematic_Hotkeys_Descr,
  853. HK_MOVE_COMPONENT_OR_ITEM );
  854. AddMenuItem( aPopMenu, ID_SCH_MOVE_ITEM, msg, KiBitmap( move_xpm ) );
  855. }
  856. if( aBusEntry->GetBusEntryShape() == '\\' )
  857. AddMenuItem( aPopMenu, ID_POPUP_SCH_ENTRY_SELECT_SLASH,
  858. _( "Set Bus Entry Shape /" ), KiBitmap( change_entry_orient_xpm ) );
  859. else
  860. AddMenuItem( aPopMenu, ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH,
  861. _( "Set Bus Entry Shape \\" ), KiBitmap( change_entry_orient_xpm ) );
  862. msg = AddHotkeyName( _( "Delete Bus Entry" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
  863. AddMenuItem( aPopMenu, ID_POPUP_SCH_DELETE, msg, KiBitmap( delete_xpm ) );
  864. }