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.

103 lines
3.1 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-2019 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_gui.h>
  25. #include <bitmap2cmp_settings.h>
  26. #include <kiface_i.h>
  27. #include <kiway.h>
  28. #include <pgm_base.h>
  29. #include <settings/settings_manager.h>
  30. //-----<KIFACE>-----------------------------------------------------------------
  31. namespace BMP2CMP {
  32. static struct IFACE : public KIFACE_I
  33. {
  34. bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) override;
  35. wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) override
  36. {
  37. InitSettings( new BITMAP2CMP_SETTINGS );
  38. Pgm().GetSettingsManager().RegisterSettings( KifaceSettings() );
  39. return new BM2CMP_FRAME( aKiway, aParent );
  40. }
  41. /**
  42. * Function IfaceOrAddress
  43. * return a pointer to the requested object. The safest way to use this
  44. * is to retrieve a pointer to a static instance of an interface, similar to
  45. * how the KIFACE interface is exported. But if you know what you are doing
  46. * use it to retrieve anything you want.
  47. *
  48. * @param aDataId identifies which object you want the address of.
  49. *
  50. * @return void* - and must be cast into the know type.
  51. */
  52. void* IfaceOrAddress( int aDataId ) override
  53. {
  54. return NULL;
  55. }
  56. IFACE( const char* aDSOname, KIWAY::FACE_T aType ) :
  57. KIFACE_I( aDSOname, aType )
  58. {}
  59. } kiface( "BMP2CMP", KIWAY::FACE_BMP2CMP );
  60. } // namespace BMP2CMP
  61. using namespace BMP2CMP;
  62. static PGM_BASE* process;
  63. KIFACE_I& Kiface()
  64. {
  65. return kiface;
  66. }
  67. // KIFACE_GETTER's actual spelling is a substitution macro found in kiway.h.
  68. // KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
  69. KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram )
  70. {
  71. process = (PGM_BASE*) aProgram;
  72. return &kiface;
  73. }
  74. #if defined(BUILD_KIWAY_DLLS)
  75. PGM_BASE& Pgm()
  76. {
  77. wxASSERT( process ); // KIFACE_GETTER has already been called.
  78. return *process;
  79. }
  80. #endif
  81. bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
  82. {
  83. return start_common( aCtlBits );
  84. }