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.

79 lines
2.5 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2010 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 2014 KiCad Developers, see CHANGELOG.TXT for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. /*
  25. * @file events_called_functions.cpp
  26. */
  27. #include <fctsys.h>
  28. #include <gr_basic.h>
  29. #include <class_drawpanel.h>
  30. #include <general.h>
  31. #include <kicad_device_context.h>
  32. #include <schframe.h>
  33. #include <sch_component.h>
  34. #include <sch_text.h>
  35. void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event )
  36. {
  37. SCH_ITEM * curr_item = GetScreen()->GetCurItem();
  38. if( !curr_item || curr_item->GetFlags() )
  39. return;
  40. INSTALL_UNBUFFERED_DC( dc, m_canvas );
  41. switch( curr_item->Type() )
  42. {
  43. case SCH_COMPONENT_T:
  44. {
  45. SCH_COMPONENT* newitem;
  46. newitem = new SCH_COMPONENT( *( (SCH_COMPONENT*) curr_item ) );
  47. newitem->SetTimeStamp( GetNewTimeStamp() );
  48. newitem->ClearAnnotation( NULL );
  49. newitem->SetFlags( IS_NEW );
  50. // Draw the new part, MoveItem() expects it to be already on screen.
  51. newitem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
  52. PrepareMoveItem( newitem, &dc );
  53. }
  54. break;
  55. case SCH_TEXT_T:
  56. case SCH_LABEL_T:
  57. case SCH_GLOBAL_LABEL_T:
  58. case SCH_HIERARCHICAL_LABEL_T:
  59. {
  60. SCH_TEXT* newitem = (SCH_TEXT*) curr_item->Clone();
  61. newitem->SetFlags( IS_NEW );
  62. // Draw the new item, MoveItem() expects it to be already on screen.
  63. newitem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
  64. PrepareMoveItem( newitem, &dc );
  65. }
  66. break;
  67. default:
  68. break;
  69. }
  70. }