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.

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