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.

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