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.

110 lines
3.4 KiB

16 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
  1. /********************************************/
  2. /* library editor: undo and redo functions */
  3. /********************************************/
  4. #include "fctsys.h"
  5. #include "class_drawpanel.h"
  6. #include "common.h"
  7. #include "program.h"
  8. #include "general.h"
  9. #include "protos.h"
  10. #include "libeditframe.h"
  11. #include "class_libentry.h"
  12. /*************************************************************************/
  13. void WinEDA_LibeditFrame::SaveCopyInUndoList( EDA_BaseStruct* ItemToCopy,
  14. int unused_flag )
  15. /*************************************************************************/
  16. {
  17. LIB_COMPONENT* CopyItem;
  18. PICKED_ITEMS_LIST* lastcmd;
  19. CopyItem = new LIB_COMPONENT( *( (LIB_COMPONENT*) ItemToCopy ) );
  20. if( CopyItem == NULL )
  21. return;
  22. lastcmd = new PICKED_ITEMS_LIST();
  23. ITEM_PICKER wrapper(CopyItem, UR_LIBEDIT);
  24. lastcmd->PushItem(wrapper);
  25. GetScreen()->PushCommandToUndoList( lastcmd );
  26. /* Clear current flags (which can be temporary set by a current edit
  27. * command) */
  28. CopyItem->ClearStatus();
  29. /* Clear redo list, because after new save there is no redo to do */
  30. GetScreen()->ClearUndoORRedoList( GetScreen()->m_RedoList );
  31. }
  32. /*************************************************************************/
  33. void WinEDA_LibeditFrame::GetComponentFromRedoList(wxCommandEvent& event)
  34. /*************************************************************************/
  35. /* Redo the last edition:
  36. * - Place the current edited library component in undo list
  37. * - Get old version of the current edited library component
  38. */
  39. {
  40. if ( GetScreen()->GetRedoCommandCount() <= 0 )
  41. return;
  42. PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST();
  43. ITEM_PICKER wrapper(m_component, UR_LIBEDIT);
  44. lastcmd->PushItem(wrapper);
  45. GetScreen()->PushCommandToUndoList( lastcmd );
  46. lastcmd = GetScreen()->PopCommandFromRedoList( );
  47. wrapper = lastcmd->PopItem();
  48. m_component = (LIB_COMPONENT*) wrapper.m_PickedItem;
  49. if( m_component )
  50. m_component->SetNext( NULL );
  51. m_drawItem = NULL;
  52. UpdateAliasSelectList();
  53. UpdatePartSelectList();
  54. if( m_component )
  55. SetShowDeMorgan( m_component->HasConversion() );
  56. DisplayLibInfos();
  57. DisplayCmpDoc();
  58. OnModify( );
  59. DrawPanel->Refresh();
  60. }
  61. /************************************************************************/
  62. void WinEDA_LibeditFrame::GetComponentFromUndoList(wxCommandEvent& event)
  63. /************************************************************************/
  64. /** Undo the last edition:
  65. * - Place the current edited library component in Redo list
  66. * - Get old version of the current edited library component
  67. */
  68. {
  69. if ( GetScreen()->GetUndoCommandCount() <= 0 )
  70. return;
  71. PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST();
  72. ITEM_PICKER wrapper(m_component, UR_LIBEDIT);
  73. lastcmd->PushItem(wrapper);
  74. GetScreen()->PushCommandToRedoList( lastcmd );
  75. lastcmd = GetScreen()->PopCommandFromUndoList( );
  76. wrapper = lastcmd->PopItem();
  77. m_component = (LIB_COMPONENT*) wrapper.m_PickedItem;
  78. if( m_component )
  79. m_component->SetNext( NULL );
  80. m_drawItem = NULL;
  81. UpdateAliasSelectList();
  82. UpdatePartSelectList();
  83. if( m_component )
  84. SetShowDeMorgan( m_component->HasConversion() );
  85. DisplayLibInfos();
  86. DisplayCmpDoc();
  87. OnModify( );
  88. DrawPanel->Refresh();
  89. }