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.

90 lines
2.9 KiB

  1. /*
  2. * This program source code file is part of KICAD, a free EDA CAD application.
  3. *
  4. * Copyright (C) 1992-2010 jean-pierre.charras
  5. * Copyright (C) 1992-2021 Kicad Developers, see AUTHORS.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. #include <bitmap2cmp_frame.h>
  25. #include <bitmap2cmp_settings.h>
  26. #include <kiface_base.h>
  27. #include <kiway.h>
  28. #include <pgm_base.h>
  29. #include <settings/settings_manager.h>
  30. namespace BMP2CMP {
  31. static struct IFACE : public KIFACE_BASE
  32. {
  33. bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway ) override;
  34. wxWindow* CreateKiWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway,
  35. int aCtlBits = 0 ) override
  36. {
  37. InitSettings( new BITMAP2CMP_SETTINGS );
  38. Pgm().GetSettingsManager().RegisterSettings( KifaceSettings() );
  39. return new BITMAP2CMP_FRAME( aKiway, aParent );
  40. }
  41. /**
  42. * Return a pointer to the requested object.
  43. *
  44. * The safest way to use this is to retrieve a pointer to a static instance of an interface,
  45. * similar to how the KIFACE interface is exported. But if you know what you are doing use
  46. * it to retrieve anything you want.
  47. *
  48. * @param aDataId identifies which object you want the address of.
  49. * @return the object which must be cast into the known type.
  50. */
  51. void* IfaceOrAddress( int aDataId ) override
  52. {
  53. return nullptr;
  54. }
  55. IFACE( const char* aDSOname, KIWAY::FACE_T aType ) :
  56. KIFACE_BASE( aDSOname, aType )
  57. {}
  58. } kiface( "BMP2CMP", KIWAY::FACE_BMP2CMP );
  59. } // namespace BMP2CMP
  60. using namespace BMP2CMP;
  61. KIFACE_BASE& Kiface()
  62. {
  63. return kiface;
  64. }
  65. // KIFACE_GETTER's actual spelling is a substitution macro found in kiway.h.
  66. // KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
  67. KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram )
  68. {
  69. return &kiface;
  70. }
  71. bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway )
  72. {
  73. return start_common( aCtlBits );
  74. }