From 0d6560a2182e1d70c563b7272cc6386319be02a7 Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Sat, 19 Apr 2014 13:47:20 -0500 Subject: [PATCH] *) Switch kicad.exe to using KIFACE modules for all major top level windows. Eeschema, Pcbnew, and Cvpcb all run under the same process now, FOR THE VERY FIRST TIME! *) Added KIWAY::PlayerCreate(), PlayerClose(), and PlayersClose(). *) Factored FRAME_T into from ID_DRAWFRAME_TYPE. *) Found that the following command line is helpful for collecting all the *.kiface files into the /kicad/ directory so that kicad can find them. $ cp `find . -name '*.kiface'` kicad/ Maybe somebody will want to rework how the CMake files are organized so all the binaries can go into the same place. See python-a-mingw-us. *) This might fix the problem on the Mac where child process windows were not coming to the front. See ->Raise() in kicad/mainframe.cpp. *) You can set USE_KIFACE to 0 in kicad/mainframe.cpp to chain load child exes instead of using the KIFACE modules directly, i.e. revert. --- 3d-viewer/3d_frame.cpp | 2 +- common/basicframe.cpp | 2 +- common/draw_frame.cpp | 2 +- common/kiway.cpp | 140 ++++++++++++++++++++++--- common/single_top.cpp | 8 +- cvpcb/CMakeLists.txt | 2 +- cvpcb/class_DisplayFootprintsFrame.cpp | 2 +- cvpcb/cvframe.cpp | 2 +- cvpcb/cvpcb.cpp | 2 +- eeschema/CMakeLists.txt | 4 +- eeschema/eeschema.cpp | 4 +- eeschema/lib_pin.cpp | 2 +- eeschema/libeditframe.cpp | 2 +- eeschema/sch_base_frame.cpp | 2 +- eeschema/schframe.cpp | 4 +- eeschema/viewlib_frame.cpp | 2 +- gerbview/CMakeLists.txt | 2 +- gerbview/gerbview.cpp | 2 +- gerbview/gerbview_frame.cpp | 2 +- include/draw_frame.h | 2 +- include/frame_type.h | 32 ++++++ include/kiway.h | 92 +++++++++++++--- include/kiway_player.h | 4 +- include/sch_base_frame.h | 2 +- include/wxBasePcbFrame.h | 2 +- include/wxstruct.h | 27 +---- kicad/kicad.cpp | 16 ++- kicad/mainframe.cpp | 88 ++++++++++------ pagelayout_editor/CMakeLists.txt | 2 +- pagelayout_editor/pl_editor.cpp | 2 +- pagelayout_editor/pl_editor_frame.cpp | 2 +- pcbnew/CMakeLists.txt | 4 +- pcbnew/basepcbframe.cpp | 2 +- pcbnew/dialogs/dialog_set_grid.cpp | 2 +- pcbnew/edit.cpp | 6 +- pcbnew/editmod.cpp | 2 +- pcbnew/edtxtmod.cpp | 4 +- pcbnew/footprint_wizard_frame.cpp | 2 +- pcbnew/modedit.cpp | 2 +- pcbnew/moduleframe.cpp | 2 +- pcbnew/modview_frame.cpp | 2 +- pcbnew/pcbframe.cpp | 2 +- pcbnew/pcbnew.cpp | 6 +- pcbnew/printout_controler.cpp | 2 +- 44 files changed, 357 insertions(+), 140 deletions(-) create mode 100644 include/frame_type.h diff --git a/3d-viewer/3d_frame.cpp b/3d-viewer/3d_frame.cpp index 55058bc911..c1fabb0b7a 100644 --- a/3d-viewer/3d_frame.cpp +++ b/3d-viewer/3d_frame.cpp @@ -81,7 +81,7 @@ END_EVENT_TABLE() EDA_3D_FRAME::EDA_3D_FRAME( KIWAY* aKiway, PCB_BASE_FRAME* aParent, const wxString& aTitle, long style ) : - KIWAY_PLAYER( aKiway, aParent, DISPLAY3D_FRAME_TYPE, aTitle, + KIWAY_PLAYER( aKiway, aParent, FRAME_PCB_DISPLAY3D, aTitle, wxDefaultPosition, wxDefaultSize, style, wxT( "Frame3D" ) ) { m_canvas = NULL; diff --git a/common/basicframe.cpp b/common/basicframe.cpp index f8a170211a..a19fbd96cf 100644 --- a/common/basicframe.cpp +++ b/common/basicframe.cpp @@ -62,7 +62,7 @@ static const wxChar entryPerspective[] = wxT( "Perspective" ); -EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, ID_DRAWFRAME_TYPE aFrameType, +EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType, const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize, long aStyle, const wxString& aFrameName ) : wxFrame( aParent, wxID_ANY, aTitle, aPos, aSize, aStyle, aFrameName ) diff --git a/common/draw_frame.cpp b/common/draw_frame.cpp index 13fc21d68a..578520263e 100644 --- a/common/draw_frame.cpp +++ b/common/draw_frame.cpp @@ -90,7 +90,7 @@ END_EVENT_TABLE() EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, - ID_DRAWFRAME_TYPE aFrameType, + FRAME_T aFrameType, const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize, long aStyle, const wxString & aFrameName ) : diff --git a/common/kiway.cpp b/common/kiway.cpp index 390586a24b..eaf3fcf14d 100644 --- a/common/kiway.cpp +++ b/common/kiway.cpp @@ -24,21 +24,29 @@ #include +#include #include +#include #include #include #include -KIWAY::KIWAY() +KIFACE* KIWAY::m_kiface[KIWAY_FACE_COUNT]; +int KIWAY::m_kiface_version[KIWAY_FACE_COUNT]; + + +KIWAY::KIWAY( PGM_BASE* aProgram, wxFrame* aTop ): + m_program( aProgram ), + m_top( aTop ) { - memset( &m_kiface, 0, sizeof( m_kiface ) ); + memset( m_player, 0, sizeof( m_player ) ); } const wxString KIWAY::dso_full_path( FACE_T aFaceId ) { - const wxChar* name = wxT(""); + const wxChar* name; switch( aFaceId ) { @@ -68,22 +76,24 @@ PROJECT& KIWAY::Prj() const } -KIFACE* KIWAY::KiFACE( PGM_BASE* aProgram, FACE_T aFaceId, bool doLoad ) +KIFACE* KIWAY::KiFACE( FACE_T aFaceId, bool doLoad ) { - switch( aFaceId ) + // Since this will be called from python, cannot assume that code will + // not pass a bad aFaceId. + if( unsigned( aFaceId ) >= DIM( m_kiface ) ) { - // case FACE_SCH: - case FACE_PCB: - if( m_kiface[aFaceId] ) - return m_kiface[aFaceId]; - break; + // @todo : throw an exception here for python's benefit, at least that + // way it gets some explanatory text. - default: wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFaceId" ) ); return NULL; } - // DSO with KIFACE has not been loaded yet, does user want to load it? + // return the previously loaded KIFACE, if it was. + if( m_kiface[aFaceId] ) + return m_kiface[aFaceId]; + + // DSO with KIFACE has not been loaded yet, does caller want to load it? if( doLoad ) { wxString dname = dso_full_path( aFaceId ); @@ -108,7 +118,7 @@ KIFACE* KIWAY::KiFACE( PGM_BASE* aProgram, FACE_T aFaceId, bool doLoad ) { KIFACE_GETTER_FUNC* getter = (KIFACE_GETTER_FUNC*) addr; - KIFACE* kiface = getter( &m_kiface_version[aFaceId], KIFACE_VERSION, aProgram ); + KIFACE* kiface = getter( &m_kiface_version[aFaceId], KIFACE_VERSION, m_program ); // KIFACE_GETTER_FUNC function comment (API) says the non-NULL is unconditional. wxASSERT_MSG( kiface, @@ -116,7 +126,7 @@ KIFACE* KIWAY::KiFACE( PGM_BASE* aProgram, FACE_T aFaceId, bool doLoad ) // Give the DSO a single chance to do its "process level" initialization. // "Process level" specifically means stay away from any projects in there. - if( kiface->OnKifaceStart( aProgram, KFCTL_PROJECT_SUITE ) ) + if( kiface->OnKifaceStart( m_program, KFCTL_PROJECT_SUITE ) ) { // Tell dso's wxDynamicLibrary destructor not to Unload() the program image. (void) dso.Detach(); @@ -131,3 +141,105 @@ KIFACE* KIWAY::KiFACE( PGM_BASE* aProgram, FACE_T aFaceId, bool doLoad ) return NULL; } + + +KIWAY::FACE_T KIWAY::KifaceType( FRAME_T aFrameType ) +{ + switch( aFrameType ) + { + case FRAME_SCH: + case FRAME_SCH_LIB_EDITOR: + case FRAME_SCH_VIEWER: + return FACE_SCH; + + case FRAME_PCB: + case FRAME_PCB_MODULE_EDITOR: + case FRAME_PCB_MODULE_VIEWER: + case FRAME_PCB_FOOTPRINT_WIZARD: + case FRAME_PCB_DISPLAY3D: + return FACE_PCB; + + case FRAME_CVPCB: + case FRAME_CVPCB_DISPLAY: + return FACE_CVPCB; + + case FRAME_GERBER: + return FACE_GERBVIEW; + + case FRAME_PL_EDITOR: + return FACE_PL_EDITOR; + + default: + return FACE_T( -1 ); + } +} + + +KIWAY_PLAYER* KIWAY::PlayerCreate( FRAME_T aFrameType ) +{ + // Since this will be called from python, cannot assume that code will + // not pass a bad aFrameType. + if( unsigned( aFrameType ) >= DIM( m_player ) ) + { + // @todo : throw an exception here for python's benefit, at least that + // way it gets some explanatory text. + + wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFrameType" ) ); + return NULL; + } + + // return the previously opened window + if( m_player[aFrameType] ) + return m_player[aFrameType]; + + FACE_T face_type = KifaceType( aFrameType ); + + wxASSERT( face_type != FACE_T(-1) ); + + KIFACE* kiface = KiFACE( face_type ); + + KIWAY_PLAYER* frame = (KIWAY_PLAYER*) kiface->CreateWindow( m_top, aFrameType, this, KFCTL_PROJECT_SUITE ); + + return m_player[aFrameType] = frame; +} + + +bool KIWAY::PlayerClose( FRAME_T aFrameType, bool doForce ) +{ + // Since this will be called from python, cannot assume that code will + // not pass a bad aFrameType. + if( unsigned( aFrameType ) >= DIM( m_player ) ) + { + // @todo : throw an exception here for python's benefit, at least that + // way it gets some explanatory text. + + wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFrameType" ) ); + return false; + } + + if( m_player[aFrameType] ) + { + if( m_player[aFrameType]->Close( doForce ) ) + { + m_player[aFrameType] = 0; + return true; + } + + return false; + } + + return true; // window is closed already. +} + + +bool KIWAY::PlayersClose( bool doForce ) +{ + bool ret = true; + + for( unsigned i=0; i < DIM( m_player ); ++i ) + { + ret = ret && PlayerClose( FRAME_T( i ), doForce ); + } + + return ret; +} diff --git a/common/single_top.cpp b/common/single_top.cpp index b1d925c99c..0200170b10 100644 --- a/common/single_top.cpp +++ b/common/single_top.cpp @@ -121,7 +121,7 @@ static const wxString dso_full_path( const wxString& aAbsoluteArgv0 ) // Only a single KIWAY is supported in this single_top top level component, // which is dedicated to loading only a single DSO. -static KIWAY kiway; +KIWAY Kiway( &Pgm() ); // implement a PGM_BASE and a wxApp side by side: @@ -304,17 +304,17 @@ bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp ) // Use KIFACE to create a top window that the KIFACE knows about. // TOP_FRAME is passed on compiler command line from CMake, and is one of - // the types in ID_DRAWFRAME_TYPE. + // the types in FRAME_T. // KIFACE::CreateWindow() is a virtual so we don't need to link to it. // Remember its in the *.kiface DSO. #if 0 // this pulls in EDA_DRAW_FRAME type info, which we don't want in // the single_top link image. KIWAY_PLAYER* frame = dynamic_cast( kiface->CreateWindow( - NULL, TOP_FRAME, &kiway, KFCTL_STANDALONE ) ); + NULL, TOP_FRAME, &Kiway, KFCTL_STANDALONE ) ); #else KIWAY_PLAYER* frame = (KIWAY_PLAYER*) kiface->CreateWindow( - NULL, TOP_FRAME, &kiway, KFCTL_STANDALONE ); + NULL, TOP_FRAME, &Kiway, KFCTL_STANDALONE ); #endif App().SetTopWindow( frame ); // wxApp gets a face. diff --git a/cvpcb/CMakeLists.txt b/cvpcb/CMakeLists.txt index 2e89204780..f36d47ee56 100644 --- a/cvpcb/CMakeLists.txt +++ b/cvpcb/CMakeLists.txt @@ -81,7 +81,7 @@ if( USE_KIWAY_DLLS ) ${CVPCB_RESOURCES} ) set_source_files_properties( ../common/single_top.cpp PROPERTIES - COMPILE_DEFINITIONS "TOP_FRAME=CVPCB_FRAME_TYPE;PGM_DATA_FILE_EXT=\"net\";BUILD_KIWAY_DLL" + COMPILE_DEFINITIONS "TOP_FRAME=FRAME_CVPCB;PGM_DATA_FILE_EXT=\"net\";BUILD_KIWAY_DLL" ) target_link_libraries( cvpcb #singletop # replaces common, giving us restrictive control and link warnings. diff --git a/cvpcb/class_DisplayFootprintsFrame.cpp b/cvpcb/class_DisplayFootprintsFrame.cpp index 4f9730ea4f..e1a0ab36dc 100644 --- a/cvpcb/class_DisplayFootprintsFrame.cpp +++ b/cvpcb/class_DisplayFootprintsFrame.cpp @@ -72,7 +72,7 @@ END_EVENT_TABLE() DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, CVPCB_MAINFRAME* aParent ) : - PCB_BASE_FRAME( aKiway, aParent, CVPCB_DISPLAY_FRAME_TYPE, _( "Footprint Viewer" ), + PCB_BASE_FRAME( aKiway, aParent, FRAME_CVPCB_DISPLAY, _( "Footprint Viewer" ), wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, FOOTPRINTVIEWER_FRAME_NAME ) { diff --git a/cvpcb/cvframe.cpp b/cvpcb/cvframe.cpp index c878e61201..4adba22292 100644 --- a/cvpcb/cvframe.cpp +++ b/cvpcb/cvframe.cpp @@ -107,7 +107,7 @@ END_EVENT_TABLE() CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) : - KIWAY_PLAYER( aKiway, aParent, CVPCB_FRAME_TYPE, wxT( "CvPCB" ), wxDefaultPosition, + KIWAY_PLAYER( aKiway, aParent, FRAME_CVPCB, wxT( "CvPCB" ), wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, CVPCB_MAINFRAME_NAME ) { m_FrameName = CVPCB_MAINFRAME_NAME; diff --git a/cvpcb/cvpcb.cpp b/cvpcb/cvpcb.cpp index 266674667d..78fbebf619 100644 --- a/cvpcb/cvpcb.cpp +++ b/cvpcb/cvpcb.cpp @@ -108,7 +108,7 @@ static struct IFACE : public KIFACE_I { switch( aClassId ) { - case CVPCB_FRAME_TYPE: + case FRAME_CVPCB: { CVPCB_MAINFRAME* frame = new CVPCB_MAINFRAME( aKiway, aParent ); return frame; diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 87b71aa5f5..b139726841 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -251,7 +251,7 @@ if( USE_KIWAY_DLLS ) ${EESCHEMA_RESOURCES} ) set_source_files_properties( ../common/single_top.cpp PROPERTIES - COMPILE_DEFINITIONS "TOP_FRAME=SCHEMATIC_FRAME_TYPE;PGM_DATA_FILE_EXT=\"sch\";BUILD_KIWAY_DLL" + COMPILE_DEFINITIONS "TOP_FRAME=FRAME_SCH;PGM_DATA_FILE_EXT=\"sch\";BUILD_KIWAY_DLL" ) target_link_libraries( eeschema #singletop # replaces common, giving us restrictive control and link warnings. @@ -345,7 +345,7 @@ else() ) set_source_files_properties( ../common/single_top.cpp PROPERTIES - COMPILE_DEFINITIONS "TOP_FRAME=SCHEMATIC_FRAME_TYPE;PGM_DATA_FILE_EXT=\"sch\";BUILD_KIWAY_DLL" + COMPILE_DEFINITIONS "TOP_FRAME=FRAME_SCH;PGM_DATA_FILE_EXT=\"sch\";BUILD_KIWAY_DLL" ) if( APPLE ) diff --git a/eeschema/eeschema.cpp b/eeschema/eeschema.cpp index 0d0d0c43e9..fafcd90ac5 100644 --- a/eeschema/eeschema.cpp +++ b/eeschema/eeschema.cpp @@ -79,7 +79,7 @@ static struct IFACE : public KIFACE_I { switch( aClassId ) { - case SCHEMATIC_FRAME_TYPE: + case FRAME_SCH: { SCH_EDIT_FRAME* frame = new SCH_EDIT_FRAME( aKiway, aParent ); @@ -97,7 +97,7 @@ static struct IFACE : public KIFACE_I } break; - case LIBEDITOR_FRAME_TYPE: + case FRAME_SCH_LIB_EDITOR: { LIB_EDIT_FRAME* frame = new LIB_EDIT_FRAME( aKiway, dynamic_cast( aParent ) ); diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index b8e8f7897a..e4f16b3a8f 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -810,7 +810,7 @@ void LIB_PIN::drawGraphic( EDA_DRAW_PANEL* aPanel, if( aPanel && aPanel->GetParent() ) frame = (EDA_DRAW_FRAME*)aPanel->GetParent(); - if( frame && frame->IsType( SCHEMATIC_FRAME_TYPE ) && + if( frame && frame->IsType( FRAME_SCH ) && ! ((SCH_EDIT_FRAME*)frame)->GetShowAllPins() ) return; diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index 0eaa7aca20..1a79cba67e 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -190,7 +190,7 @@ END_EVENT_TABLE() #define LIB_EDIT_FRAME_NAME wxT( "LibeditFrame" ) LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, SCH_EDIT_FRAME* aParent ) : - SCH_BASE_FRAME( aKiway, aParent, LIBEDITOR_FRAME_TYPE, _( "Library Editor" ), + SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH_LIB_EDITOR, _( "Library Editor" ), wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, GetLibEditFrameName() ) { wxASSERT( aParent ); // LIB_EDIT_FRAME needs a parent, since it peeks up there. diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index 686efce6de..7908defdc1 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -29,7 +29,7 @@ SCH_BASE_FRAME::SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, - ID_DRAWFRAME_TYPE aWindowType, const wxString& aTitle, + FRAME_T aWindowType, const wxString& aTitle, const wxPoint& aPosition, const wxSize& aSize, long aStyle, const wxString& aFrameName ) : EDA_DRAW_FRAME( aKiway, aParent, aWindowType, aTitle, aPosition, diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index a26598437f..69221fd9ec 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -176,7 +176,7 @@ END_EVENT_TABLE() #define SCH_EDIT_FRAME_NAME wxT( "SchematicFrame" ) SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ): - SCH_BASE_FRAME( aKiway, aParent, SCHEMATIC_FRAME_TYPE, wxT( "Eeschema" ), + SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH, wxT( "Eeschema" ), wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, SCH_EDIT_FRAME_NAME ), m_item_to_repeat( 0 ) { @@ -821,7 +821,7 @@ void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event ) { KIFACE_I& kf = Kiface(); - wxWindow* w = kf.CreateWindow( this, LIBEDITOR_FRAME_TYPE, &Kiway(), kf.StartFlags() ); + wxWindow* w = kf.CreateWindow( this, FRAME_SCH_LIB_EDITOR, &Kiway(), kf.StartFlags() ); libeditFrame = dynamic_cast( w ); } diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index 3963b03dbf..33b05c1bc6 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -97,7 +97,7 @@ static wxAcceleratorEntry accels[] = LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, SCH_BASE_FRAME* aParent, CMP_LIBRARY* aLibrary, wxSemaphore* aSemaphore, long aStyle ) : - SCH_BASE_FRAME( aKiway, aParent, VIEWER_FRAME_TYPE, _( "Library Browser" ), + SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH_VIEWER, _( "Library Browser" ), wxDefaultPosition, wxDefaultSize, aStyle, GetLibViewerFrameName() ) { wxAcceleratorTable table( ACCEL_TABLE_CNT, accels ); diff --git a/gerbview/CMakeLists.txt b/gerbview/CMakeLists.txt index df67987d6f..7eff8d254e 100644 --- a/gerbview/CMakeLists.txt +++ b/gerbview/CMakeLists.txt @@ -100,7 +100,7 @@ if( USE_KIWAY_DLLS ) ${GERBVIEW_RESOURCES} ) set_source_files_properties( ../common/single_top.cpp PROPERTIES - COMPILE_DEFINITIONS "TOP_FRAME=GERBER_FRAME_TYPE;BUILD_KIWAY_DLL" + COMPILE_DEFINITIONS "TOP_FRAME=FRAME_GERBER;BUILD_KIWAY_DLL" ) target_link_libraries( gerbview #singletop # replaces common, giving us restrictive control and link warnings. diff --git a/gerbview/gerbview.cpp b/gerbview/gerbview.cpp index e7ae04c786..0423cd6b72 100644 --- a/gerbview/gerbview.cpp +++ b/gerbview/gerbview.cpp @@ -81,7 +81,7 @@ static struct IFACE : public KIFACE_I { switch( aClassId ) { - case GERBER_FRAME_TYPE: + case FRAME_GERBER: { GERBVIEW_FRAME* frame = new GERBVIEW_FRAME( aKiway, aParent ); diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 1e2b073e8d..b6d6d412e4 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -65,7 +65,7 @@ static const wxString cfgShowBorderAndTitleBlock( wxT( "ShowBorderAndTitleBloc #define GERBVIEW_FRAME_NAME wxT( "GerberFrame" ) GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ): - EDA_DRAW_FRAME( aKiway, aParent, GERBER_FRAME_TYPE, wxT( "GerbView" ), + EDA_DRAW_FRAME( aKiway, aParent, FRAME_GERBER, wxT( "GerbView" ), wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, GERBVIEW_FRAME_NAME ) { m_colorsSettings = &g_ColorsSettings; diff --git a/include/draw_frame.h b/include/draw_frame.h index b533688e55..67aba863c1 100644 --- a/include/draw_frame.h +++ b/include/draw_frame.h @@ -118,7 +118,7 @@ protected: public: EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, - ID_DRAWFRAME_TYPE aFrameType, + FRAME_T aFrameType, const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize, long aStyle, diff --git a/include/frame_type.h b/include/frame_type.h new file mode 100644 index 0000000000..23411168c6 --- /dev/null +++ b/include/frame_type.h @@ -0,0 +1,32 @@ +#ifndef FRAME_T_H_ +#define FRAME_T_H_ + +/** + * Enum FRAME_T + * is the set of EDA_BASE_FRAME derivatives, typically stored in + * EDA_BASE_FRAME::m_Ident. + */ +enum FRAME_T +{ + FRAME_SCH, + FRAME_SCH_LIB_EDITOR, + FRAME_SCH_VIEWER, + FRAME_PCB, + FRAME_PCB_MODULE_EDITOR, + FRAME_PCB_MODULE_VIEWER, + FRAME_PCB_FOOTPRINT_WIZARD, + FRAME_PCB_DISPLAY3D, + FRAME_CVPCB, + FRAME_CVPCB_DISPLAY, + FRAME_GERBER, + + KIWAY_PLAYER_COUNT, // counts subset of FRAME_T's tracked in class KIWAY + + KICAD_MAIN_FRAME_T = KIWAY_PLAYER_COUNT, + FRAME_PL_EDITOR, + //TEXT_EDITOR_FRAME_T, + + FRAME_T_COUNT +}; + +#endif // FRAME_T_H_ diff --git a/include/kiway.h b/include/kiway.h index 92e20b93e4..f4f40ca980 100644 --- a/include/kiway.h +++ b/include/kiway.h @@ -101,6 +101,7 @@ as such! As such, it is OK to use UTF8 characters: #include #include #include +#include #define VTBL_ENTRY virtual @@ -126,6 +127,7 @@ class wxWindow; class wxConfigBase; class PGM_BASE; class KIWAY; +class KIWAY_PLAYER; /** @@ -248,50 +250,109 @@ class KIWAY : public wxEvtHandler { public: - /// Possible KIFACEs on *this* KIWAY + /// Known KIFACE implementations enum FACE_T { - FACE_SCH, ///< eeschema DSO - // FACE_LIB, - FACE_PCB, ///< pcbnew DSO - // FACE_MOD, + FACE_SCH, ///< eeschema DSO + FACE_PCB, ///< pcbnew DSO FACE_CVPCB, - FACE_BMP2CMP, + /// count of those above here, which is the subset managed in a KIWAY. + KIWAY_FACE_COUNT, + + FACE_BMP2CMP = KIWAY_FACE_COUNT, FACE_GERBVIEW, FACE_PL_EDITOR, FACE_PCB_CALCULATOR, - FACE_COUNT, ///< how many KIWAY player types + FACE_COUNT }; - // If you change the vtable, recompile all of KiCad. + /** + * Function KifaceType + * is a simple mapping function which returns the FACE_T which is known to + * implement @a aFrameType. + * + * @return KIWAY::FACE_T - a valid value or FACE_T(-1) if given a bad aFrameType. + */ + static FACE_T KifaceType( FRAME_T aFrameType ); + // If you change the vtable, recompile all of KiCad. + /** * Function KiFACE * returns the KIFACE* given a FACE_T. If it is not already loaded, the * KIFACE is loaded and initialized with a call to KIFACE::OnKifaceStart() */ - VTBL_ENTRY KIFACE* KiFACE( PGM_BASE* aProgram, - FACE_T aFaceId, bool doLoad = true ); + VTBL_ENTRY KIFACE* KiFACE( FACE_T aFaceId, bool doLoad = true ); - VTBL_ENTRY PROJECT& Prj() const; + /** + * Function PlayerCreate + * returns the KIWAY_PLAYER* given a FRAME_T. If it is not already created, + * the required KIFACE is found and loaded and initialized if necessary, then + * the KIWAY_PLAYER window is created but not shown. Caller must Show() it. + * If it is already created, then the existing KIWAY_PLAYER* pointer is returned. + * + * @return KIWAY_PLAYER* - a valid opened KIWAY_PLAYER or NULL if there + * is something wrong. + */ + VTBL_ENTRY KIWAY_PLAYER* PlayerCreate( FRAME_T aFrameType ); - KIWAY(); + /** + * Function PlayerClose + * calls the KIWAY_PLAYER::Close( bool force ) function on the window and + * if not vetoed, returns true, else false. If window actually closes, then + * this KIWAY marks it as not opened internally. + * + * @return bool - true the window is closed and not vetoed, else false. + */ + VTBL_ENTRY bool PlayerClose( FRAME_T aFrameType, bool doForce ); + + /** + * Function PlayersClose + * calls the KIWAY_PLAYER::Close( bool force ) function on all the windows and + * if none are vetoed, returns true, else false. If window actually closes, then + * this KIWAY marks it as not opened internally. + * + * @return bool - true the window is closed and not vetoed, else false. + */ + VTBL_ENTRY bool PlayersClose( bool doForce ); + + + /** + * Function Prj + * returns the PROJECT associated with this KIWAY. This is here as an + * accessor, so that there is freedom to put the actual PROJECT storage + * in a place decided by the implementation, and not known to the caller. + */ + VTBL_ENTRY PROJECT& Prj() const; + + KIWAY( PGM_BASE* aProgram, wxFrame* aTop = NULL ); + + /// In case aTop may not be known at time of KIWAY construction: + void SetTop( wxFrame* aTop ) { m_top = aTop; } private: /// Get the full path & name of the DSO holding the requested FACE_T. static const wxString dso_full_path( FACE_T aFaceId ); - KIFACE* m_kiface[FACE_COUNT]; - int m_kiface_version[FACE_COUNT]; + static KIFACE* m_kiface[KIWAY_FACE_COUNT]; + static int m_kiface_version[KIWAY_FACE_COUNT]; - PROJECT m_project; // do not assume this is here, use Prj(). + KIWAY_PLAYER* m_player[KIWAY_PLAYER_COUNT]; // from frame_type.h + + PROJECT m_project; // do not assume this is here, use Prj(). + + PGM_BASE* m_program; + wxFrame* m_top; }; +extern KIWAY Kiway; // provided by single_top.cpp and kicad.cpp + + /** * Function Pointer KIFACE_GETTER_FUNC * points to the one and only KIFACE export. The export's address @@ -310,4 +371,5 @@ typedef KIFACE* KIFACE_GETTER_FUNC( int* aKIFACEversion, int aKIWAYversion, /// No name mangling. Each KIFACE (DSO/DLL) will implement this once. extern "C" KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram ); + #endif // KIWAY_H_ diff --git a/include/kiway_player.h b/include/kiway_player.h index 15d8489615..9a48085dd2 100644 --- a/include/kiway_player.h +++ b/include/kiway_player.h @@ -98,7 +98,7 @@ private: class KIWAY_PLAYER : public EDA_BASE_FRAME, public KIWAY_HOLDER { public: - KIWAY_PLAYER( KIWAY* aKiway, wxWindow* aParent, ID_DRAWFRAME_TYPE aFrameType, + KIWAY_PLAYER( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType, const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize, long aStyle, const wxString& aWdoName = wxFrameNameStr ) : EDA_BASE_FRAME( aParent, aFrameType, aTitle, aPos, aSize, aStyle, aWdoName ), @@ -110,7 +110,7 @@ public: KIWAY_PLAYER( wxWindow* aParent, wxWindowID aId, const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize, long aStyle, const wxString& aWdoName = wxFrameNameStr ) : - EDA_BASE_FRAME( aParent, (ID_DRAWFRAME_TYPE) aId, aTitle, aPos, aSize, aStyle, aWdoName ), + EDA_BASE_FRAME( aParent, (FRAME_T) aId, aTitle, aPos, aSize, aStyle, aWdoName ), KIWAY_HOLDER( 0 ) {} diff --git a/include/sch_base_frame.h b/include/sch_base_frame.h index 27a4193446..261989c89a 100644 --- a/include/sch_base_frame.h +++ b/include/sch_base_frame.h @@ -47,7 +47,7 @@ class SCH_BASE_FRAME : public EDA_DRAW_FRAME { public: SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, - ID_DRAWFRAME_TYPE aWindowType, + FRAME_T aWindowType, const wxString& aTitle, const wxPoint& aPosition, const wxSize& aSize, long aStyle, const wxString & aFrameName ); diff --git a/include/wxBasePcbFrame.h b/include/wxBasePcbFrame.h index 3fd117ffb9..e60a969abb 100644 --- a/include/wxBasePcbFrame.h +++ b/include/wxBasePcbFrame.h @@ -115,7 +115,7 @@ protected: static const LAYER_NUM GAL_LAYER_ORDER[]; public: - PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, ID_DRAWFRAME_TYPE aFrameType, + PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType, const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize, long aStyle, const wxString& aFrameName ); diff --git a/include/wxstruct.h b/include/wxstruct.h index dbf8679ef5..73363cceed 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -46,6 +46,7 @@ #include #include #include +#include #ifdef USE_WX_OVERLAY #include @@ -81,26 +82,6 @@ enum id_librarytype { }; -enum ID_DRAWFRAME_TYPE -{ - NOT_INIT_FRAME_TYPE = 0, - SCHEMATIC_FRAME_TYPE, - LIBEDITOR_FRAME_TYPE, - VIEWER_FRAME_TYPE, - PCB_FRAME_TYPE, - MODULE_EDITOR_FRAME_TYPE, - MODULE_VIEWER_FRAME_TYPE, - FOOTPRINT_WIZARD_FRAME_TYPE, - CVPCB_FRAME_TYPE, - CVPCB_DISPLAY_FRAME_TYPE, - GERBER_FRAME_TYPE, - TEXT_EDITOR_FRAME_TYPE, - DISPLAY3D_FRAME_TYPE, - KICAD_MAIN_FRAME_TYPE, - PL_EDITOR_FRAME_TYPE -}; - - /// Custom trace mask to enable and disable auto save tracing. extern const wxChar traceAutoSave[]; @@ -132,7 +113,7 @@ class EDA_BASE_FRAME : public wxFrame void windowClosing( wxCloseEvent& event ); protected: - ID_DRAWFRAME_TYPE m_Ident; ///< Id Type (pcb, schematic, library..) + FRAME_T m_Ident; ///< Id Type (pcb, schematic, library..) wxPoint m_FramePos; wxSize m_FrameSize; @@ -196,7 +177,7 @@ protected: virtual wxString help_name(); public: - EDA_BASE_FRAME( wxWindow* aParent, ID_DRAWFRAME_TYPE aFrameType, + EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType, const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize, long aStyle, const wxString& aFrameName ); @@ -219,7 +200,7 @@ public: bool IsActive() const { return m_FrameIsActive; } - bool IsType( ID_DRAWFRAME_TYPE aType ) const { return m_Ident == aType; } + bool IsType( FRAME_T aType ) const { return m_Ident == aType; } void GetKicadHelp( wxCommandEvent& event ); diff --git a/kicad/kicad.cpp b/kicad/kicad.cpp index 028b1aff91..ac0a734dc1 100644 --- a/kicad/kicad.cpp +++ b/kicad/kicad.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include #include @@ -149,6 +149,8 @@ bool PGM_KICAD::OnPgmInit( wxApp* aWxApp ) wxDefaultPosition, wxDefaultSize ); App().SetTopWindow( frame ); + Kiway.SetTop( frame ); + bool prjloaded = false; // true when the project is loaded if( App().argc > 1 ) @@ -251,7 +253,7 @@ void PGM_KICAD::destroy() } -KIWAY_MGR Kiways; +KIWAY Kiway( &Pgm() ); /** @@ -262,7 +264,7 @@ struct APP_KICAD : public wxApp { bool OnInit() // overload wxApp virtual { - if( Kiways.OnStart( this ) ) + // if( Kiways.OnStart( this ) ) { return Pgm().OnPgmInit( this ); } @@ -271,7 +273,7 @@ struct APP_KICAD : public wxApp int OnExit() // overload wxApp virtual { - Kiways.OnEnd(); + // Kiways.OnEnd(); Pgm().OnPgmExit(); @@ -297,10 +299,12 @@ IMPLEMENT_APP( APP_KICAD ); // this link image need this function. PROJECT& Prj() { - return Kiways[0].Prj(); + return Kiway.Prj(); } +#if 0 // there can be only one in C++ project manager. + bool KIWAY_MGR::OnStart( wxApp* aProcess ) { // The C++ project manager supports only one open PROJECT @@ -314,3 +318,5 @@ bool KIWAY_MGR::OnStart( wxApp* aProcess ) void KIWAY_MGR::OnEnd() { } + +#endif diff --git a/kicad/mainframe.cpp b/kicad/mainframe.cpp index d75e25f5ed..4f2480f38d 100644 --- a/kicad/mainframe.cpp +++ b/kicad/mainframe.cpp @@ -30,7 +30,7 @@ #include #include -#include +#include #include #include #include @@ -41,13 +41,14 @@ #include #include +#define USE_KIFACE 1 -#define TreeFrameWidthEntry wxT( "LeftWinWidth" ) +#define TreeFrameWidthEntry wxT( "LeftWinWidth" ) KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title, const wxPoint& pos, const wxSize& size ) : - EDA_BASE_FRAME( parent, KICAD_MAIN_FRAME_TYPE, title, pos, size, + EDA_BASE_FRAME( parent, KICAD_MAIN_FRAME_T, title, pos, size, KICAD_DEFAULT_DRAWFRAME_STYLE, wxT( "KicadFrame" ) ) { m_leftWinWidth = 60; @@ -154,26 +155,29 @@ void KICAD_MANAGER_FRAME::OnSize( wxSizeEvent& event ) void KICAD_MANAGER_FRAME::OnCloseWindow( wxCloseEvent& Event ) { - int px, py; - - UpdateFileHistory( m_ProjectFileName.GetFullPath(), &Pgm().GetFileHistory() ); - - if( !IsIconized() ) // save main frame position and size + if( Kiway.PlayersClose( false ) ) { - GetPosition( &px, &py ); - m_FramePos.x = px; - m_FramePos.y = py; + int px, py; - GetSize( &px, &py ); - m_FrameSize.x = px; - m_FrameSize.y = py; + UpdateFileHistory( m_ProjectFileName.GetFullPath(), &Pgm().GetFileHistory() ); + + if( !IsIconized() ) // save main frame position and size + { + GetPosition( &px, &py ); + m_FramePos.x = px; + m_FramePos.y = py; + + GetSize( &px, &py ); + m_FrameSize.x = px; + m_FrameSize.y = py; + } + + Event.SetCanVeto( true ); + + m_LeftWin->Show( false ); + + Destroy(); } - - Event.SetCanVeto( true ); - - m_LeftWin->Show( false ); - - Destroy(); } @@ -243,17 +247,12 @@ void KICAD_MANAGER_FRAME::OnRunPcbNew( wxCommandEvent& event ) wxFileName& board = ( !legacy_board.FileExists() || kicad_board.FileExists() ) ? kicad_board : legacy_board; - -#if 0 // it works! - KIFACE* kiface = Kiways[0].KiFACE( &Pgm(), KIWAY::FACE_PCB ); - - KIWAY_PLAYER* frame = (KIWAY_PLAYER*) kiface->CreateWindow( this, PCB_FRAME_TYPE, &Kiways[0], KFCTL_PROJECT_SUITE ); +#if USE_KIFACE + KIWAY_PLAYER* frame = Kiway.PlayerCreate( FRAME_PCB ); frame->OpenProjectFiles( std::vector( 1, board.GetFullPath() ) ); - frame->Show( true ); frame->Raise(); - #else Execute( this, PCBNEW_EXE, QuoteFullPath( board ) ); #endif @@ -265,25 +264,49 @@ void KICAD_MANAGER_FRAME::OnRunCvpcb( wxCommandEvent& event ) wxFileName fn( m_ProjectFileName ); fn.SetExt( NetlistFileExtension ); + +#if USE_KIFACE + KIWAY_PLAYER* frame = Kiway.PlayerCreate( FRAME_CVPCB ); + + frame->OpenProjectFiles( std::vector( 1, fn.GetFullPath() ) ); + frame->Show( true ); + frame->Raise(); +#else Execute( this, CVPCB_EXE, QuoteFullPath( fn ) ); +#endif } + void KICAD_MANAGER_FRAME::OnRunEeschema( wxCommandEvent& event ) { wxFileName fn( m_ProjectFileName ); fn.SetExt( SchematicFileExtension ); - Execute( this, EESCHEMA_EXE, QuoteFullPath( fn ) ); +#if USE_KIFACE + KIWAY_PLAYER* frame = Kiway.PlayerCreate( FRAME_SCH ); + + frame->OpenProjectFiles( std::vector( 1, fn.GetFullPath() ) ); + frame->Show( true ); + frame->Raise(); +#else + Execute( this, EESCHEMA_EXE, QuoteFullPath( fn ) ); +#endif } void KICAD_MANAGER_FRAME::OnRunGerbview( wxCommandEvent& event ) { wxFileName fn( m_ProjectFileName ); + wxString path = wxT( "\"" ); + path += fn.GetPath( wxPATH_GET_SEPARATOR | wxPATH_GET_VOLUME ) + wxT( "\"" ); +#if USE_KIFACE && 0 + +#else Execute( this, GERBVIEW_EXE, path ); +#endif } @@ -353,10 +376,11 @@ void KICAD_MANAGER_FRAME::SaveSettings( wxConfigBase* aCfg ) */ void KICAD_MANAGER_FRAME::PrintPrjInfo() { - wxString msg; - msg.Printf( _( "Working dir: %s\nProject: %s\n" ), - GetChars( wxGetCwd() ), - GetChars( m_ProjectFileName.GetFullPath() ) ); + wxString msg = wxString::Format( _( + "Working dir: %s\nProject: %s\n" ), + GetChars( wxGetCwd() ), + GetChars( m_ProjectFileName.GetFullPath() ) + ); PrintMsg( msg ); } diff --git a/pagelayout_editor/CMakeLists.txt b/pagelayout_editor/CMakeLists.txt index 308bd94949..cd6e41acdd 100644 --- a/pagelayout_editor/CMakeLists.txt +++ b/pagelayout_editor/CMakeLists.txt @@ -62,7 +62,7 @@ if( USE_KIWAY_DLLS ) ${PL_EDITOR_RESOURCES} ) set_source_files_properties( ../common/single_top.cpp PROPERTIES - COMPILE_DEFINITIONS "TOP_FRAME=PL_EDITOR_FRAME_TYPE;PGM_DATA_FILE_EXT=\"kicad_wks\";BUILD_KIWAY_DLL" + COMPILE_DEFINITIONS "TOP_FRAME=FRAME_PL_EDITOR;PGM_DATA_FILE_EXT=\"kicad_wks\";BUILD_KIWAY_DLL" ) target_link_libraries( pl_editor #singletop # replaces common, giving us restrictive control and link warnings. diff --git a/pagelayout_editor/pl_editor.cpp b/pagelayout_editor/pl_editor.cpp index a72ee92505..f15d34e8ab 100644 --- a/pagelayout_editor/pl_editor.cpp +++ b/pagelayout_editor/pl_editor.cpp @@ -62,7 +62,7 @@ static struct IFACE : public KIFACE_I { switch( aClassId ) { - case PL_EDITOR_FRAME_TYPE: + case FRAME_PL_EDITOR: { PL_EDITOR_FRAME* frame = new PL_EDITOR_FRAME( aKiway, aParent ); diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index d5defe8d16..dd1162b9f3 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -54,7 +54,7 @@ #define PL_EDITOR_FRAME_NAME wxT( "PlEditorFrame" ) PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : - EDA_DRAW_FRAME( aKiway, aParent, PL_EDITOR_FRAME_TYPE, wxT( "PlEditorFrame" ), + EDA_DRAW_FRAME( aKiway, aParent, FRAME_PL_EDITOR, wxT( "PlEditorFrame" ), wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, PL_EDITOR_FRAME_NAME ) { m_FrameName = PL_EDITOR_FRAME_NAME; diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index 5cf723661c..42350320f5 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -512,7 +512,7 @@ if( USE_KIWAY_DLLS ) ${PCBNEW_RESOURCES} ) set_source_files_properties( ../common/single_top.cpp pcbnew.cpp PROPERTIES - COMPILE_DEFINITIONS "TOP_FRAME=PCB_FRAME_TYPE;PGM_DATA_FILE_EXT=\"kicad_pcb\";BUILD_KIWAY_DLL" + COMPILE_DEFINITIONS "TOP_FRAME=FRAME_PCB;PGM_DATA_FILE_EXT=\"kicad_pcb\";BUILD_KIWAY_DLL" ) target_link_libraries( pcbnew #singletop # replaces common, giving us restrictive control and link warnings. @@ -614,7 +614,7 @@ else() # milestone A) kills this off: ${PCBNEW_RESOURCES} ) set_source_files_properties( ../common/single_top.cpp PROPERTIES - COMPILE_DEFINITIONS "TOP_FRAME=PCB_FRAME_TYPE;PGM_DATA_FILE_EXT=\"kicad_pcb\"" + COMPILE_DEFINITIONS "TOP_FRAME=FRAME_PCB;PGM_DATA_FILE_EXT=\"kicad_pcb\"" ) target_link_libraries( pcbnew 3d-viewer diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index 1afb7e71c6..2307a5b3c7 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -129,7 +129,7 @@ BEGIN_EVENT_TABLE( PCB_BASE_FRAME, EDA_DRAW_FRAME ) END_EVENT_TABLE() -PCB_BASE_FRAME::PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, ID_DRAWFRAME_TYPE aFrameType, +PCB_BASE_FRAME::PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType, const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize, long aStyle, const wxString & aFrameName ) : EDA_DRAW_FRAME( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName ) diff --git a/pcbnew/dialogs/dialog_set_grid.cpp b/pcbnew/dialogs/dialog_set_grid.cpp index d60e152805..689b803699 100644 --- a/pcbnew/dialogs/dialog_set_grid.cpp +++ b/pcbnew/dialogs/dialog_set_grid.cpp @@ -211,7 +211,7 @@ bool PCB_BASE_FRAME::InvokeDialogGrid() if( ret == wxID_OK ) { - if( GetGridOrigin() != grid_origin && IsType( PCB_FRAME_TYPE ) ) + if( GetGridOrigin() != grid_origin && IsType( FRAME_PCB ) ) OnModify(); // because grid origin is saved in board, show as modified SetGridOrigin( grid_origin ); diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index de2c27b58f..92b267c856 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -196,7 +196,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) { KIFACE_I& kf = Kiface(); - editor = (FOOTPRINT_EDIT_FRAME*) kf.CreateWindow( this, MODULE_EDITOR_FRAME_TYPE, &Kiway(), kf.StartFlags() ); + editor = (FOOTPRINT_EDIT_FRAME*) kf.CreateWindow( this, FRAME_PCB_MODULE_EDITOR, &Kiway(), kf.StartFlags() ); editor->Show( true ); editor->Zoom_Automatique( false ); @@ -224,7 +224,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) { KIFACE_I& kf = Kiface(); - viewer = (FOOTPRINT_VIEWER_FRAME*) kf.CreateWindow( this, MODULE_VIEWER_FRAME_TYPE, &Kiway(), kf.StartFlags() ); + viewer = (FOOTPRINT_VIEWER_FRAME*) kf.CreateWindow( this, FRAME_PCB_MODULE_VIEWER, &Kiway(), kf.StartFlags() ); viewer->Show( true ); viewer->Zoom_Automatique( false ); @@ -845,7 +845,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) { KIFACE_I& kf = Kiface(); - editor = (FOOTPRINT_EDIT_FRAME*) kf.CreateWindow( this, MODULE_EDITOR_FRAME_TYPE, &Kiway(), kf.StartFlags() ); + editor = (FOOTPRINT_EDIT_FRAME*) kf.CreateWindow( this, FRAME_PCB_MODULE_EDITOR, &Kiway(), kf.StartFlags() ); } editor->Load_Module_From_BOARD( (MODULE*)GetCurItem() ); diff --git a/pcbnew/editmod.cpp b/pcbnew/editmod.cpp index a7cc3cbe74..49325bc1eb 100644 --- a/pcbnew/editmod.cpp +++ b/pcbnew/editmod.cpp @@ -80,7 +80,7 @@ void PCB_EDIT_FRAME::InstallModuleOptionsFrame( MODULE* Module, wxDC* DC ) { KIFACE_I& kf = Kiface(); - editor = (FOOTPRINT_EDIT_FRAME*) kf.CreateWindow( this, MODULE_EDITOR_FRAME_TYPE, &Kiway(), kf.StartFlags() ); + editor = (FOOTPRINT_EDIT_FRAME*) kf.CreateWindow( this, FRAME_PCB_MODULE_EDITOR, &Kiway(), kf.StartFlags() ); } editor->Load_Module_From_BOARD( Module ); diff --git a/pcbnew/edtxtmod.cpp b/pcbnew/edtxtmod.cpp index d180cd00cd..78c1f40d30 100644 --- a/pcbnew/edtxtmod.cpp +++ b/pcbnew/edtxtmod.cpp @@ -108,7 +108,7 @@ void PCB_BASE_FRAME::RotateTextModule( TEXTE_MODULE* Text, wxDC* DC ) if( module && module->GetFlags() == 0 && Text->GetFlags() == 0 ) // prepare undo command { - if( IsType( PCB_FRAME_TYPE ) ) + if( IsType( FRAME_PCB ) ) SaveCopyInUndoList( module, UR_CHANGED ); } @@ -236,7 +236,7 @@ void PCB_BASE_FRAME::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC ) double tmp = Text->GetOrientation(); Text->SetOrientation( TextInitialOrientation ); - if( IsType( PCB_FRAME_TYPE ) ) + if( IsType( FRAME_PCB ) ) SaveCopyInUndoList( Module, UR_CHANGED ); else SaveCopyInUndoList( Module, UR_MODEDIT ); diff --git a/pcbnew/footprint_wizard_frame.cpp b/pcbnew/footprint_wizard_frame.cpp index a5d5a5a325..b09623f074 100644 --- a/pcbnew/footprint_wizard_frame.cpp +++ b/pcbnew/footprint_wizard_frame.cpp @@ -121,7 +121,7 @@ static wxAcceleratorEntry accels[] = FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, FOOTPRINT_EDIT_FRAME* aParent, wxSemaphore* semaphore, long style ) : - PCB_BASE_FRAME( aKiway, aParent, FOOTPRINT_WIZARD_FRAME_TYPE, + PCB_BASE_FRAME( aKiway, aParent, FRAME_PCB_FOOTPRINT_WIZARD, _( "Footprint Wizard" ), wxDefaultPosition, wxDefaultSize, style, FOOTPRINT_WIZARD_FRAME_NAME ) { diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index 22ef70221e..c9198d4a41 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -273,7 +273,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) { KIFACE_I& kf = Kiface(); - viewer = (FOOTPRINT_VIEWER_FRAME*) kf.CreateWindow( this, MODULE_VIEWER_FRAME_TYPE, &Kiway(), kf.StartFlags() ); + viewer = (FOOTPRINT_VIEWER_FRAME*) kf.CreateWindow( this, FRAME_PCB_MODULE_VIEWER, &Kiway(), kf.StartFlags() ); viewer->Show( true ); viewer->Zoom_Automatique( false ); } diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index fa28eca5b4..bf2983ccd0 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -153,7 +153,7 @@ END_EVENT_TABLE() #define FOOTPRINT_EDIT_FRAME_NAME wxT( "ModEditFrame" ) FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, PCB_EDIT_FRAME* aParent ) : - PCB_BASE_FRAME( aKiway, aParent, MODULE_EDITOR_FRAME_TYPE, wxEmptyString, + PCB_BASE_FRAME( aKiway, aParent, FRAME_PCB_MODULE_EDITOR, wxEmptyString, wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, GetFootprintEditorFrameName() ) { diff --git a/pcbnew/modview_frame.cpp b/pcbnew/modview_frame.cpp index b79a2c4d3c..30bb30063e 100644 --- a/pcbnew/modview_frame.cpp +++ b/pcbnew/modview_frame.cpp @@ -119,7 +119,7 @@ static wxAcceleratorEntry accels[] = FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, PCB_BASE_FRAME* aParent, wxSemaphore* aSemaphore ) : - PCB_BASE_FRAME( aKiway, aParent, MODULE_VIEWER_FRAME_TYPE, _( "Footprint Library Browser" ), + PCB_BASE_FRAME( aKiway, aParent, FRAME_PCB_MODULE_VIEWER, _( "Footprint Library Browser" ), wxDefaultPosition, wxDefaultSize, !aSemaphore ? KICAD_DEFAULT_DRAWFRAME_STYLE : diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index e815ed705a..55c7a6b2ce 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -299,7 +299,7 @@ END_EVENT_TABLE() #define PCB_EDIT_FRAME_NAME wxT( "PcbFrame" ) PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : - PCB_BASE_FRAME( aKiway, aParent, PCB_FRAME_TYPE, wxT( "Pcbnew" ), wxDefaultPosition, + PCB_BASE_FRAME( aKiway, aParent, FRAME_PCB, wxT( "Pcbnew" ), wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, PCB_EDIT_FRAME_NAME ) { m_FrameName = PCB_EDIT_FRAME_NAME; diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index 98e5a5b660..3c47fb7f3d 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -110,7 +110,7 @@ static struct IFACE : public KIFACE_I switch( aClassId ) { - case PCB_FRAME_TYPE: + case FRAME_PCB: { PCB_EDIT_FRAME* frame = new PCB_EDIT_FRAME( aKiway, aParent ); @@ -130,7 +130,7 @@ static struct IFACE : public KIFACE_I } break; - case MODULE_EDITOR_FRAME_TYPE: + case FRAME_PCB_MODULE_EDITOR: { // yuck: PCB_EDIT_FRAME* editor = dynamic_cast( aParent ); @@ -147,7 +147,7 @@ static struct IFACE : public KIFACE_I } break; - case MODULE_VIEWER_FRAME_TYPE: + case FRAME_PCB_MODULE_VIEWER: { // yuck: PCB_BASE_FRAME* editor = dynamic_cast( aParent ); diff --git a/pcbnew/printout_controler.cpp b/pcbnew/printout_controler.cpp index 092304298c..c553cd83ed 100644 --- a/pcbnew/printout_controler.cpp +++ b/pcbnew/printout_controler.cpp @@ -263,7 +263,7 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage() // In module editor, the module is located at 0,0 but for printing // it is moved to pageSizeIU.x/2, pageSizeIU.y/2. // So the equivalent board must be moved to the center of the page: - if( m_Parent->IsType( MODULE_EDITOR_FRAME_TYPE ) ) + if( m_Parent->IsType( FRAME_PCB_MODULE_EDITOR ) ) { boardBoundingBox.Move( wxPoint( pageSizeIU.x/2, pageSizeIU.y/2 ) ); }