2014-02-03 15:10:37 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
|
|
|
* Copyright (C) 2014 KiCad Developers, see CHANGELOG.TXT for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2014-04-18 02:05:40 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2014-04-19 18:47:20 +00:00
|
|
|
#include <macros.h>
|
2014-02-03 15:10:37 +00:00
|
|
|
#include <kiway.h>
|
2014-04-19 18:47:20 +00:00
|
|
|
#include <kiway_player.h>
|
2014-04-21 06:28:17 +00:00
|
|
|
#include <kiway_express.h>
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
#include <pgm_base.h>
|
2014-02-03 19:26:18 +00:00
|
|
|
#include <config.h>
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
#include <id.h>
|
2014-02-03 15:10:37 +00:00
|
|
|
|
2014-05-04 00:44:57 +00:00
|
|
|
#include <wx/stdpaths.h>
|
|
|
|
#include <wx/debug.h>
|
|
|
|
|
2014-02-03 15:10:37 +00:00
|
|
|
|
2014-04-19 18:47:20 +00:00
|
|
|
KIFACE* KIWAY::m_kiface[KIWAY_FACE_COUNT];
|
|
|
|
int KIWAY::m_kiface_version[KIWAY_FACE_COUNT];
|
|
|
|
|
|
|
|
|
2014-04-21 14:49:33 +00:00
|
|
|
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
KIWAY::KIWAY( PGM_BASE* aProgram, int aCtlBits, wxFrame* aTop ):
|
2014-04-19 18:47:20 +00:00
|
|
|
m_program( aProgram ),
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
m_ctl( aCtlBits ),
|
2014-04-19 19:44:59 +00:00
|
|
|
m_top( 0 )
|
2014-02-03 15:10:37 +00:00
|
|
|
{
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
SetTop( aTop ); // hook player_destroy_handler() into aTop.
|
2014-04-19 19:44:59 +00:00
|
|
|
|
2014-04-19 18:47:20 +00:00
|
|
|
memset( m_player, 0, sizeof( m_player ) );
|
2014-02-03 15:10:37 +00:00
|
|
|
}
|
|
|
|
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
|
2014-04-19 19:44:59 +00:00
|
|
|
// Any event types derived from wxCommandEvt, like wxWindowDestroyEvent, are
|
2014-05-05 17:28:40 +00:00
|
|
|
// propogated upwards to parent windows if not handled below. Therefore the
|
2014-04-20 04:35:34 +00:00
|
|
|
// m_top window should receive all wxWindowDestroyEvents originating from
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
// KIWAY_PLAYERs. It does anyways, but now player_destroy_handler eavesdrops
|
2014-04-19 19:44:59 +00:00
|
|
|
// on that event stream looking for KIWAY_PLAYERs being closed.
|
|
|
|
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
void KIWAY::player_destroy_handler( wxWindowDestroyEvent& event )
|
2014-04-19 19:44:59 +00:00
|
|
|
{
|
|
|
|
wxWindow* w = event.GetWindow();
|
|
|
|
|
|
|
|
for( unsigned i=0; i<DIM(m_player); ++i )
|
|
|
|
{
|
2014-04-20 04:35:34 +00:00
|
|
|
// if destroying one of our flock, then mark it as deceased.
|
2014-04-19 19:44:59 +00:00
|
|
|
if( (wxWindow*) m_player[i] == w )
|
|
|
|
{
|
2014-05-05 17:28:40 +00:00
|
|
|
DBG(printf( "%s: m_player[%d] destroyed: %s\n",
|
|
|
|
__func__, i, TO_UTF8( m_player[i]->GetName() ) );)
|
|
|
|
|
2014-04-19 19:44:59 +00:00
|
|
|
m_player[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
2014-05-05 17:28:40 +00:00
|
|
|
|
|
|
|
// event.Skip(); skip to who, the wxApp? I'm the top window.
|
2014-04-19 19:44:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KIWAY::SetTop( wxFrame* aTop )
|
|
|
|
{
|
|
|
|
if( m_top )
|
|
|
|
{
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
m_top->Disconnect( wxEVT_DESTROY, wxWindowDestroyEventHandler( KIWAY::player_destroy_handler ), NULL, this );
|
2014-04-19 19:44:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( aTop )
|
|
|
|
{
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
aTop->Connect( wxEVT_DESTROY, wxWindowDestroyEventHandler( KIWAY::player_destroy_handler ), NULL, this );
|
2014-04-19 19:44:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_top = aTop;
|
|
|
|
}
|
|
|
|
|
2014-02-03 15:10:37 +00:00
|
|
|
|
2014-04-18 02:05:40 +00:00
|
|
|
const wxString KIWAY::dso_full_path( FACE_T aFaceId )
|
2014-02-03 15:10:37 +00:00
|
|
|
{
|
2014-04-19 18:47:20 +00:00
|
|
|
const wxChar* name;
|
2014-04-18 02:05:40 +00:00
|
|
|
|
2014-02-03 15:10:37 +00:00
|
|
|
switch( aFaceId )
|
|
|
|
{
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
case FACE_SCH: name = KIFACE_PREFIX wxT( "eeschema" ); break;
|
|
|
|
case FACE_PCB: name = KIFACE_PREFIX wxT( "pcbnew" ); break;
|
|
|
|
case FACE_CVPCB: name = KIFACE_PREFIX wxT( "cvpcb" ); break;
|
|
|
|
case FACE_GERBVIEW: name = KIFACE_PREFIX wxT( "gerbview" ); break;
|
|
|
|
case FACE_PL_EDITOR: name = KIFACE_PREFIX wxT( "pl_editor" ); break;
|
|
|
|
case FACE_PCB_CALCULATOR: name = KIFACE_PREFIX wxT( "pcb_calculator" ); break;
|
|
|
|
case FACE_BMP2CMP: name = KIFACE_PREFIX wxT( "bitmap2component" ); break;
|
2014-02-03 15:10:37 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFaceId" ) );
|
|
|
|
return wxEmptyString;
|
|
|
|
}
|
2014-04-18 02:05:40 +00:00
|
|
|
|
|
|
|
wxFileName fn = wxStandardPaths::Get().GetExecutablePath();
|
|
|
|
|
|
|
|
fn.SetName( name );
|
|
|
|
|
|
|
|
// Here a "suffix" == an extension with a preceding '.',
|
|
|
|
// so skip the preceding '.' to get an extension
|
|
|
|
fn.SetExt( KIFACE_SUFFIX + 1 ); // + 1 => &KIFACE_SUFFIX[1]
|
|
|
|
|
|
|
|
return fn.GetFullPath();
|
2014-02-03 15:10:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
PROJECT& KIWAY::Prj() const
|
2014-02-03 15:10:37 +00:00
|
|
|
{
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
return *(PROJECT*) &m_project; // strip const-ness, function really is const.
|
2014-02-03 15:10:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-19 18:47:20 +00:00
|
|
|
KIFACE* KIWAY::KiFACE( FACE_T aFaceId, bool doLoad )
|
2014-02-03 15:10:37 +00:00
|
|
|
{
|
2014-04-19 18:47:20 +00:00
|
|
|
// Since this will be called from python, cannot assume that code will
|
|
|
|
// not pass a bad aFaceId.
|
|
|
|
if( unsigned( aFaceId ) >= DIM( m_kiface ) )
|
2014-02-03 15:10:37 +00:00
|
|
|
{
|
2014-04-19 18:47:20 +00:00
|
|
|
// @todo : throw an exception here for python's benefit, at least that
|
|
|
|
// way it gets some explanatory text.
|
2014-02-03 15:10:37 +00:00
|
|
|
|
|
|
|
wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFaceId" ) );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-04-19 18:47:20 +00:00
|
|
|
// 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?
|
2014-02-03 15:10:37 +00:00
|
|
|
if( doLoad )
|
|
|
|
{
|
2014-04-18 02:05:40 +00:00
|
|
|
wxString dname = dso_full_path( aFaceId );
|
|
|
|
|
|
|
|
wxDynamicLibrary dso;
|
|
|
|
|
|
|
|
void* addr = NULL;
|
|
|
|
|
2014-06-12 13:57:00 +00:00
|
|
|
if( !dso.Load( dname, wxDL_VERBATIM | wxDL_NOW | wxDL_GLOBAL ) )
|
2014-02-03 15:10:37 +00:00
|
|
|
{
|
2014-04-18 02:05:40 +00:00
|
|
|
// Failure: error reporting UI was done via wxLogSysError().
|
|
|
|
// No further reporting required here.
|
|
|
|
}
|
2014-02-03 15:10:37 +00:00
|
|
|
|
2014-04-18 02:05:40 +00:00
|
|
|
else if( ( addr = dso.GetSymbol( wxT( KIFACE_INSTANCE_NAME_AND_VERSION ) ) ) == NULL )
|
|
|
|
{
|
|
|
|
// Failure: error reporting UI was done via wxLogSysError().
|
|
|
|
// No further reporting required here.
|
|
|
|
}
|
2014-02-03 15:10:37 +00:00
|
|
|
|
2014-04-18 02:05:40 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
KIFACE_GETTER_FUNC* getter = (KIFACE_GETTER_FUNC*) addr;
|
|
|
|
|
2014-04-19 18:47:20 +00:00
|
|
|
KIFACE* kiface = getter( &m_kiface_version[aFaceId], KIFACE_VERSION, m_program );
|
2014-04-18 02:05:40 +00:00
|
|
|
|
|
|
|
// KIFACE_GETTER_FUNC function comment (API) says the non-NULL is unconditional.
|
|
|
|
wxASSERT_MSG( kiface,
|
|
|
|
wxT( "attempted DSO has a bug, failed to return a KIFACE*" ) );
|
|
|
|
|
|
|
|
// Give the DSO a single chance to do its "process level" initialization.
|
|
|
|
// "Process level" specifically means stay away from any projects in there.
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
if( kiface->OnKifaceStart( m_program, m_ctl ) )
|
2014-04-18 02:05:40 +00:00
|
|
|
{
|
|
|
|
// Tell dso's wxDynamicLibrary destructor not to Unload() the program image.
|
|
|
|
(void) dso.Detach();
|
|
|
|
|
|
|
|
return m_kiface[aFaceId] = kiface;
|
|
|
|
}
|
2014-02-03 15:10:37 +00:00
|
|
|
}
|
2014-04-18 02:05:40 +00:00
|
|
|
|
|
|
|
// In any of the failure cases above, dso.Unload() should be called here
|
|
|
|
// by dso destructor.
|
2014-04-24 11:30:14 +00:00
|
|
|
// However:
|
|
|
|
|
|
|
|
// There is a file installation bug. We only look for KIFACE_I's which we know
|
|
|
|
// to exist, and we did not find one. If we do not find one, this is an
|
|
|
|
// installation bug.
|
|
|
|
|
|
|
|
wxString msg = wxString::Format( wxT(
|
|
|
|
"Fatal Installation Bug\nmissing file:\n'%s'\n\nargv[0]:\n'%s'" ),
|
|
|
|
GetChars( dname ),
|
|
|
|
GetChars( wxStandardPaths::Get().GetExecutablePath() )
|
|
|
|
);
|
|
|
|
|
|
|
|
// This is a fatal error, one from which we cannot recover, nor do we want
|
|
|
|
// to protect against in client code which would require numerous noisy
|
|
|
|
// tests in numerous places. So we inform the user that the installation
|
2014-04-24 17:25:57 +00:00
|
|
|
// is bad. This exception will likely not get caught until way up in the
|
|
|
|
// wxApp derivative, at which point the process will exit gracefully.
|
2014-04-24 11:30:14 +00:00
|
|
|
THROW_IO_ERROR( msg );
|
2014-02-03 15:10:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2014-04-19 18:47:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
KIWAY::FACE_T KIWAY::KifaceType( FRAME_T aFrameType )
|
|
|
|
{
|
|
|
|
switch( aFrameType )
|
|
|
|
{
|
|
|
|
case FRAME_SCH:
|
|
|
|
case FRAME_SCH_LIB_EDITOR:
|
|
|
|
case FRAME_SCH_VIEWER:
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
case FRAME_SCH_VIEWER_MODAL:
|
2014-04-19 18:47:20 +00:00
|
|
|
return FACE_SCH;
|
|
|
|
|
|
|
|
case FRAME_PCB:
|
|
|
|
case FRAME_PCB_MODULE_EDITOR:
|
|
|
|
case FRAME_PCB_MODULE_VIEWER:
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
case FRAME_PCB_MODULE_VIEWER_MODAL:
|
|
|
|
case FRAME_PCB_FOOTPRINT_WIZARD_MODAL:
|
2014-04-19 18:47:20 +00:00
|
|
|
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;
|
|
|
|
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
case FRAME_CALC:
|
|
|
|
return FACE_PCB_CALCULATOR;
|
|
|
|
|
|
|
|
case FRAME_BM2CMP:
|
|
|
|
return FACE_BMP2CMP;
|
|
|
|
|
2014-04-19 18:47:20 +00:00
|
|
|
default:
|
|
|
|
return FACE_T( -1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-20 04:35:34 +00:00
|
|
|
KIWAY_PLAYER* KIWAY::Player( FRAME_T aFrameType, bool doCreate )
|
2014-04-19 18:47:20 +00:00
|
|
|
{
|
|
|
|
// 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];
|
|
|
|
|
2014-04-20 04:35:34 +00:00
|
|
|
if( doCreate )
|
|
|
|
{
|
|
|
|
FACE_T face_type = KifaceType( aFrameType );
|
|
|
|
wxASSERT( face_type != FACE_T(-1) );
|
2014-04-19 18:47:20 +00:00
|
|
|
|
2014-04-20 04:35:34 +00:00
|
|
|
KIFACE* kiface = KiFACE( face_type );
|
2014-04-22 16:10:07 +00:00
|
|
|
wxASSERT( kiface );
|
|
|
|
|
2014-04-22 16:16:34 +00:00
|
|
|
if( kiface )
|
|
|
|
{
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
KIWAY_PLAYER* frame = (KIWAY_PLAYER*) kiface->CreateWindow(
|
|
|
|
m_top,
|
|
|
|
aFrameType,
|
|
|
|
this,
|
|
|
|
m_ctl // questionable need, these same flags where passed to the KIFACE::OnKifaceStart()
|
|
|
|
);
|
2014-04-23 13:53:07 +00:00
|
|
|
wxASSERT( frame );
|
2014-04-19 18:47:20 +00:00
|
|
|
|
2014-04-22 16:16:34 +00:00
|
|
|
return m_player[aFrameType] = frame;
|
|
|
|
}
|
2014-04-20 04:35:34 +00:00
|
|
|
}
|
2014-04-19 18:47:20 +00:00
|
|
|
|
2014-04-20 04:35:34 +00:00
|
|
|
return NULL;
|
2014-04-19 18:47:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2014-04-21 06:28:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
void KIWAY::ExpressMail( FRAME_T aDestination,
|
2014-04-22 15:16:19 +00:00
|
|
|
MAIL_T aCommand, const std::string& aPayload, wxWindow* aSource )
|
2014-04-21 06:28:17 +00:00
|
|
|
{
|
|
|
|
KIWAY_EXPRESS mail( aDestination, aCommand, aPayload, aSource );
|
|
|
|
|
|
|
|
ProcessEvent( mail );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
void KIWAY::SetLanguage( int aLanguage )
|
|
|
|
{
|
|
|
|
Pgm().SetLanguageIdentifier( aLanguage );
|
|
|
|
Pgm().SetLanguage();
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
// This is a risky hack that goes away if we allow the language to be
|
|
|
|
// set only from the top most frame if !Kiface.IsSingle()
|
|
|
|
|
|
|
|
// Only for the C++ project manager, and not for the python one and not for
|
|
|
|
// single_top do we look for the EDA_BASE_FRAME as the top level window.
|
|
|
|
// For single_top this is not needed because that window is registered in
|
|
|
|
// the array below.
|
|
|
|
if( m_ctl & KFCTL_CPP_PROJECT_SUITE )
|
|
|
|
{
|
|
|
|
EDA_BASE_FRAME* top = (EDA_BASE_FRAME*) m_top;
|
|
|
|
if( top )
|
|
|
|
top->ShowChangedLanguage();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for( unsigned i=0; i < DIM( m_player ); ++i )
|
|
|
|
{
|
|
|
|
KIWAY_PLAYER* frame = m_player[i];
|
|
|
|
|
|
|
|
if( frame )
|
|
|
|
{
|
|
|
|
frame->ShowChangedLanguage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-21 06:28:17 +00:00
|
|
|
bool KIWAY::ProcessEvent( wxEvent& aEvent )
|
|
|
|
{
|
|
|
|
KIWAY_EXPRESS* mail = dynamic_cast<KIWAY_EXPRESS*>( &aEvent );
|
|
|
|
|
|
|
|
if( mail )
|
|
|
|
{
|
|
|
|
FRAME_T dest = mail->Dest();
|
|
|
|
|
|
|
|
// see if recipient is alive
|
|
|
|
KIWAY_PLAYER* alive = Player( dest, false );
|
|
|
|
|
|
|
|
if( alive )
|
2014-04-21 06:51:33 +00:00
|
|
|
{
|
2014-04-21 14:49:33 +00:00
|
|
|
#if 1
|
2014-04-21 06:28:17 +00:00
|
|
|
return alive->ProcessEvent( aEvent );
|
2014-04-21 06:51:33 +00:00
|
|
|
#else
|
|
|
|
alive->KiwayMailIn( *mail );
|
|
|
|
return true;
|
|
|
|
#endif
|
|
|
|
}
|
2014-04-21 06:28:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
void KIWAY::OnKiwayEnd()
|
|
|
|
{
|
|
|
|
for( unsigned i=0; i < DIM( m_kiface ); ++i )
|
|
|
|
{
|
|
|
|
if( m_kiface[i] )
|
|
|
|
m_kiface[i]->OnKifaceEnd();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|