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.

955 lines
38 KiB

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