mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-18 17:19:17 +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.
This commit is contained in:
parent
5688a87212
commit
991926d320
bitmap2component
common
cvpcb
eeschema
block_libedit.cppeeschema.cppeeschema_config.cppgetpart.cpplibeditframe.cpplibeditframe.hsch_base_frame.cppschedit.cppschframe.cppsheet.cpptool_viewlib.cppviewlib_frame.cppviewlib_frame.h
gerbview
include
draw_frame.hfpid.hframe_type.hkiface_i.hkiway.hkiway_player.hwxEeschemaStruct.hwxPcbStruct.hwxstruct.h
kicad
pagelayout_editor
pcb_calculator
pcbnew
block_module_editor.cppedit.cppeditmod.cppfootprint_wizard.cppfootprint_wizard_frame.cppfootprint_wizard_frame.hgpcb_plugin.cppkicad_plugin.cpplibrairi.cpploadcmp.cppmodedit.cppmodule_editor_frame.hmoduleframe.cppmodview_frame.cppmodview_frame.hpcbframe.cpppcbnew.cpppcbnew_config.cpptool_modview.cpp
@ -14,7 +14,7 @@ set( BITMAP2COMPONENT_SRCS
|
||||
)
|
||||
|
||||
set_source_files_properties( ../common/single_top.cpp PROPERTIES
|
||||
COMPILE_DEFINITIONS "TOP_FRAME=0"
|
||||
COMPILE_DEFINITIONS "TOP_FRAME=FRAME_BM2CMP"
|
||||
)
|
||||
set_source_files_properties( bitmap2cmp_gui.cpp PROPERTIES
|
||||
COMPILE_DEFINITIONS "COMPILING_DLL"
|
||||
|
@ -169,12 +169,8 @@ void EDA_BASE_FRAME::ReCreateMenuBar()
|
||||
}
|
||||
|
||||
|
||||
void EDA_BASE_FRAME::SetLanguage( wxCommandEvent& event )
|
||||
void EDA_BASE_FRAME::ShowChangedLanguage()
|
||||
{
|
||||
int id = event.GetId();
|
||||
|
||||
Pgm().SetLanguageIdentifier( id );
|
||||
Pgm().SetLanguage();
|
||||
ReCreateMenuBar();
|
||||
GetMenuBar()->Refresh();
|
||||
}
|
||||
@ -717,27 +713,3 @@ void EDA_BASE_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void EDA_BASE_FRAME::SetModalMode( bool aModal )
|
||||
{
|
||||
// Disable all other windows
|
||||
#if wxCHECK_VERSION(2, 9, 4)
|
||||
if( IsTopLevel() )
|
||||
{
|
||||
wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst();
|
||||
|
||||
while( node )
|
||||
{
|
||||
wxWindow* win = node->GetData();
|
||||
|
||||
if( win != this )
|
||||
win->Enable( !aModal );
|
||||
|
||||
node = node->GetNext();
|
||||
}
|
||||
}
|
||||
#else
|
||||
// Deprecated since wxWidgets 2.9.4
|
||||
MakeModal( aModal );
|
||||
#endif
|
||||
}
|
||||
|
@ -122,6 +122,7 @@ EDA_COLOR_T ColorMix( EDA_COLOR_T aColor1, EDA_COLOR_T aColor2 )
|
||||
// First easy thing: a black gives always the other colour
|
||||
if( aColor1 == BLACK )
|
||||
return aColor2;
|
||||
|
||||
if( aColor2 == BLACK)
|
||||
return aColor1;
|
||||
|
||||
|
@ -556,12 +556,6 @@ bool EDA_DRAW_FRAME::HandleBlockEnd( wxDC* DC )
|
||||
}
|
||||
|
||||
|
||||
void EDA_DRAW_FRAME::SetLanguage( wxCommandEvent& event )
|
||||
{
|
||||
EDA_BASE_FRAME::SetLanguage( event );
|
||||
}
|
||||
|
||||
|
||||
void EDA_DRAW_FRAME::UpdateStatusBar()
|
||||
{
|
||||
wxString Line;
|
||||
|
@ -62,6 +62,7 @@ const char* EndsWithRev( const char* start, const char* tail, char separator )
|
||||
}
|
||||
|
||||
|
||||
#if 0 // Not used
|
||||
int RevCmp( const char* s1, const char* s2 )
|
||||
{
|
||||
int r = strncmp( s1, s2, 3 );
|
||||
@ -76,6 +77,7 @@ int RevCmp( const char* s1, const char* s2 )
|
||||
|
||||
return -(rnum1 - rnum2); // swap the sign, higher revs first
|
||||
}
|
||||
#endif
|
||||
|
||||
//----<Policy and field test functions>-------------------------------------
|
||||
|
||||
@ -116,7 +118,7 @@ void FPID::clear()
|
||||
}
|
||||
|
||||
|
||||
int FPID::Parse( const std::string& aId )
|
||||
int FPID::Parse( const UTF8& aId )
|
||||
{
|
||||
clear();
|
||||
|
||||
@ -171,12 +173,6 @@ int FPID::Parse( const std::string& aId )
|
||||
}
|
||||
|
||||
|
||||
int FPID::Parse( const wxString& aId )
|
||||
{
|
||||
return Parse( std::string( TO_UTF8( aId ) ) );
|
||||
}
|
||||
|
||||
|
||||
FPID::FPID( const std::string& aId ) throw( PARSE_ERROR )
|
||||
{
|
||||
int offset = Parse( aId );
|
||||
@ -194,14 +190,14 @@ FPID::FPID( const std::string& aId ) throw( PARSE_ERROR )
|
||||
|
||||
FPID::FPID( const wxString& aId ) throw( PARSE_ERROR )
|
||||
{
|
||||
std::string id = TO_UTF8( aId );
|
||||
UTF8 id = aId;
|
||||
|
||||
int offset = Parse( id );
|
||||
|
||||
if( offset != -1 )
|
||||
{
|
||||
THROW_PARSE_ERROR( _( "Illegal character found in FPID string" ),
|
||||
wxString::FromUTF8( id.c_str() ),
|
||||
aId,
|
||||
id.c_str(),
|
||||
0,
|
||||
offset );
|
||||
@ -209,7 +205,7 @@ FPID::FPID( const wxString& aId ) throw( PARSE_ERROR )
|
||||
}
|
||||
|
||||
|
||||
int FPID::SetLibNickname( const std::string& aLogical )
|
||||
int FPID::SetLibNickname( const UTF8& aLogical )
|
||||
{
|
||||
int offset = okLogical( aLogical );
|
||||
|
||||
@ -222,15 +218,9 @@ int FPID::SetLibNickname( const std::string& aLogical )
|
||||
}
|
||||
|
||||
|
||||
int FPID::SetLibNickname( const wxString& aLogical )
|
||||
int FPID::SetFootprintName( const UTF8& aFootprintName )
|
||||
{
|
||||
return SetLibNickname( std::string( TO_UTF8( aLogical ) ) );
|
||||
}
|
||||
|
||||
|
||||
int FPID::SetFootprintName( const std::string& aFootprintName )
|
||||
{
|
||||
int separation = int( aFootprintName.find_first_of( "/" ) );
|
||||
int separation = int( aFootprintName.find_first_of( "/" ) );
|
||||
|
||||
if( separation != -1 )
|
||||
{
|
||||
@ -246,13 +236,7 @@ int FPID::SetFootprintName( const std::string& aFootprintName )
|
||||
}
|
||||
|
||||
|
||||
int FPID::SetFootprintName( const wxString& aFootprintName )
|
||||
{
|
||||
return SetFootprintName( std::string( TO_UTF8( aFootprintName ) ) );
|
||||
}
|
||||
|
||||
|
||||
int FPID::SetRevision( const std::string& aRevision )
|
||||
int FPID::SetRevision( const UTF8& aRevision )
|
||||
{
|
||||
int offset = okRevision( aRevision );
|
||||
|
||||
@ -301,8 +285,10 @@ UTF8 FPID::GetFootprintNameAndRev() const
|
||||
}
|
||||
|
||||
|
||||
UTF8 FPID::Format( const std::string& aLogicalLib, const std::string& aFootprintName,
|
||||
const std::string& aRevision )
|
||||
#if 0 // this is broken, it does not output aFootprintName for some reason
|
||||
|
||||
UTF8 FPID::Format( const UTF8& aLogicalLib, const UTF8& aFootprintName,
|
||||
const UTF8& aRevision )
|
||||
throw( PARSE_ERROR )
|
||||
{
|
||||
UTF8 ret;
|
||||
@ -344,6 +330,7 @@ UTF8 FPID::Format( const std::string& aLogicalLib, const std::string& aFootprint
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int FPID::compare( const FPID& aFPID ) const
|
||||
|
@ -23,14 +23,16 @@
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <wx/debug.h>
|
||||
#include <wx/stdpaths.h>
|
||||
|
||||
#include <macros.h>
|
||||
#include <kiway.h>
|
||||
#include <kiway_player.h>
|
||||
#include <kiway_express.h>
|
||||
#include <pgm_base.h>
|
||||
#include <config.h>
|
||||
#include <wx/debug.h>
|
||||
#include <wx/stdpaths.h>
|
||||
#include <id.h>
|
||||
|
||||
|
||||
KIFACE* KIWAY::m_kiface[KIWAY_FACE_COUNT];
|
||||
@ -38,22 +40,24 @@ int KIWAY::m_kiface_version[KIWAY_FACE_COUNT];
|
||||
|
||||
|
||||
|
||||
KIWAY::KIWAY( PGM_BASE* aProgram, wxFrame* aTop ):
|
||||
KIWAY::KIWAY( PGM_BASE* aProgram, int aCtlBits, wxFrame* aTop ):
|
||||
m_program( aProgram ),
|
||||
m_ctl( aCtlBits ),
|
||||
m_top( 0 )
|
||||
{
|
||||
SetTop( aTop ); // hook playerDestroyHandler() into aTop.
|
||||
SetTop( aTop ); // hook player_destroy_handler() into aTop.
|
||||
|
||||
memset( m_player, 0, sizeof( m_player ) );
|
||||
}
|
||||
|
||||
|
||||
// Any event types derived from wxCommandEvt, like wxWindowDestroyEvent, are
|
||||
// propogated upwards to parent windows if not handled below. Therefor the
|
||||
// m_top window should receive all wxWindowDestroyEvents originating from
|
||||
// KIWAY_PLAYERs. It does anyways, but now playerDestroyHandler eavesdrops
|
||||
// KIWAY_PLAYERs. It does anyways, but now player_destroy_handler eavesdrops
|
||||
// on that event stream looking for KIWAY_PLAYERs being closed.
|
||||
|
||||
void KIWAY::playerDestroyHandler( wxWindowDestroyEvent& event )
|
||||
void KIWAY::player_destroy_handler( wxWindowDestroyEvent& event )
|
||||
{
|
||||
wxWindow* w = event.GetWindow();
|
||||
|
||||
@ -62,7 +66,7 @@ void KIWAY::playerDestroyHandler( wxWindowDestroyEvent& event )
|
||||
// if destroying one of our flock, then mark it as deceased.
|
||||
if( (wxWindow*) m_player[i] == w )
|
||||
{
|
||||
// DBG(printf( "%s: marking m_player[%d] as destroyed\n", __func__, i );)
|
||||
DBG(printf( "%s: marking m_player[%d] as destroyed\n", __func__, i );)
|
||||
m_player[i] = 0;
|
||||
}
|
||||
}
|
||||
@ -73,12 +77,12 @@ void KIWAY::SetTop( wxFrame* aTop )
|
||||
{
|
||||
if( m_top )
|
||||
{
|
||||
m_top->Disconnect( wxEVT_DESTROY, wxWindowDestroyEventHandler( KIWAY::playerDestroyHandler ), NULL, this );
|
||||
m_top->Disconnect( wxEVT_DESTROY, wxWindowDestroyEventHandler( KIWAY::player_destroy_handler ), NULL, this );
|
||||
}
|
||||
|
||||
if( aTop )
|
||||
{
|
||||
aTop->Connect( wxEVT_DESTROY, wxWindowDestroyEventHandler( KIWAY::playerDestroyHandler ), NULL, this );
|
||||
aTop->Connect( wxEVT_DESTROY, wxWindowDestroyEventHandler( KIWAY::player_destroy_handler ), NULL, this );
|
||||
}
|
||||
|
||||
m_top = aTop;
|
||||
@ -91,13 +95,13 @@ const wxString KIWAY::dso_full_path( FACE_T aFaceId )
|
||||
|
||||
switch( aFaceId )
|
||||
{
|
||||
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: who knows.
|
||||
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;
|
||||
|
||||
default:
|
||||
wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFaceId" ) );
|
||||
@ -172,7 +176,7 @@ KIFACE* KIWAY::KiFACE( 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( m_program, KFCTL_PROJECT_SUITE ) )
|
||||
if( kiface->OnKifaceStart( m_program, m_ctl ) )
|
||||
{
|
||||
// Tell dso's wxDynamicLibrary destructor not to Unload() the program image.
|
||||
(void) dso.Detach();
|
||||
@ -214,12 +218,14 @@ KIWAY::FACE_T KIWAY::KifaceType( FRAME_T aFrameType )
|
||||
case FRAME_SCH:
|
||||
case FRAME_SCH_LIB_EDITOR:
|
||||
case FRAME_SCH_VIEWER:
|
||||
case FRAME_SCH_VIEWER_MODAL:
|
||||
return FACE_SCH;
|
||||
|
||||
case FRAME_PCB:
|
||||
case FRAME_PCB_MODULE_EDITOR:
|
||||
case FRAME_PCB_MODULE_VIEWER:
|
||||
case FRAME_PCB_FOOTPRINT_WIZARD:
|
||||
case FRAME_PCB_MODULE_VIEWER_MODAL:
|
||||
case FRAME_PCB_FOOTPRINT_WIZARD_MODAL:
|
||||
case FRAME_PCB_DISPLAY3D:
|
||||
return FACE_PCB;
|
||||
|
||||
@ -233,6 +239,12 @@ KIWAY::FACE_T KIWAY::KifaceType( FRAME_T aFrameType )
|
||||
case FRAME_PL_EDITOR:
|
||||
return FACE_PL_EDITOR;
|
||||
|
||||
case FRAME_CALC:
|
||||
return FACE_PCB_CALCULATOR;
|
||||
|
||||
case FRAME_BM2CMP:
|
||||
return FACE_BMP2CMP;
|
||||
|
||||
default:
|
||||
return FACE_T( -1 );
|
||||
}
|
||||
@ -266,7 +278,12 @@ KIWAY_PLAYER* KIWAY::Player( FRAME_T aFrameType, bool doCreate )
|
||||
|
||||
if( kiface )
|
||||
{
|
||||
KIWAY_PLAYER* frame = (KIWAY_PLAYER*) kiface->CreateWindow( m_top, aFrameType, this, KFCTL_PROJECT_SUITE );
|
||||
KIWAY_PLAYER* frame = (KIWAY_PLAYER*) kiface->CreateWindow(
|
||||
m_top,
|
||||
aFrameType,
|
||||
this,
|
||||
m_ctl // questionable need, these same flags where passed to the KIFACE::OnKifaceStart()
|
||||
);
|
||||
wxASSERT( frame );
|
||||
|
||||
return m_player[aFrameType] = frame;
|
||||
@ -327,6 +344,39 @@ void KIWAY::ExpressMail( FRAME_T aDestination,
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool KIWAY::ProcessEvent( wxEvent& aEvent )
|
||||
{
|
||||
KIWAY_EXPRESS* mail = dynamic_cast<KIWAY_EXPRESS*>( &aEvent );
|
||||
@ -351,3 +401,14 @@ bool KIWAY::ProcessEvent( wxEvent& aEvent )
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void KIWAY::OnKiwayEnd()
|
||||
{
|
||||
for( unsigned i=0; i < DIM( m_kiface ); ++i )
|
||||
{
|
||||
if( m_kiface[i] )
|
||||
m_kiface[i]->OnKifaceEnd();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,28 +2,26 @@
|
||||
|
||||
#include <kiway_player.h>
|
||||
#include <kiway_express.h>
|
||||
#include <kiway.h>
|
||||
#include <id.h>
|
||||
#include <typeinfo>
|
||||
|
||||
|
||||
BEGIN_EVENT_TABLE( KIWAY_PLAYER, EDA_BASE_FRAME )
|
||||
/* have not been able to get this to work yet:
|
||||
EVT_KIWAY_EXPRESS( KIWAY_PLAYER::kiway_express )
|
||||
Use Connect() in constructor until this can be sorted out.
|
||||
|
||||
OK the problem is KIWAY_PLAYER::wxEVENT_ID not being unique accross all link images.
|
||||
*/
|
||||
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, KIWAY_PLAYER::language_change )
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
|
||||
KIWAY_PLAYER::KIWAY_PLAYER( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
|
||||
const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
|
||||
long aStyle, const wxString& aWdoName ) :
|
||||
EDA_BASE_FRAME( aParent, aFrameType, aTitle, aPos, aSize, aStyle, aWdoName ),
|
||||
KIWAY_HOLDER( aKiway )
|
||||
KIWAY_HOLDER( aKiway ),
|
||||
m_modal_dismissed( 0 )
|
||||
{
|
||||
DBG( printf("KIWAY_EXPRESS::wxEVENT_ID:%d\n", KIWAY_EXPRESS::wxEVENT_ID );)
|
||||
Connect( KIWAY_EXPRESS::wxEVENT_ID, wxKiwayExressHandler( KIWAY_PLAYER::kiway_express ) );
|
||||
//Connect( KIWAY_EXPRESS::wxEVENT_ID, wxKiwayExressHandler( KIWAY_PLAYER::kiway_express ) );
|
||||
}
|
||||
|
||||
|
||||
@ -31,10 +29,125 @@ KIWAY_PLAYER::KIWAY_PLAYER( wxWindow* aParent, wxWindowID aId, const wxString& a
|
||||
const wxPoint& aPos, const wxSize& aSize, long aStyle,
|
||||
const wxString& aWdoName ) :
|
||||
EDA_BASE_FRAME( aParent, (FRAME_T) aId, aTitle, aPos, aSize, aStyle, aWdoName ),
|
||||
KIWAY_HOLDER( 0 )
|
||||
KIWAY_HOLDER( 0 ),
|
||||
m_modal_dismissed( 0 )
|
||||
{
|
||||
DBG( printf("KIWAY_EXPRESS::wxEVENT_ID:%d\n", KIWAY_EXPRESS::wxEVENT_ID );)
|
||||
Connect( KIWAY_EXPRESS::wxEVENT_ID, wxKiwayExressHandler( KIWAY_PLAYER::kiway_express ) );
|
||||
//Connect( KIWAY_EXPRESS::wxEVENT_ID, wxKiwayExressHandler( KIWAY_PLAYER::kiway_express ) );
|
||||
}
|
||||
|
||||
|
||||
KIWAY_PLAYER::~KIWAY_PLAYER(){}
|
||||
|
||||
|
||||
void KIWAY_PLAYER::KiwayMailIn( KIWAY_EXPRESS& aEvent )
|
||||
{
|
||||
// override this in derived classes.
|
||||
}
|
||||
|
||||
|
||||
static void makeModal( wxFrame* aFrame, bool IsModal )
|
||||
{
|
||||
// disable or enable all other top level windows
|
||||
#if wxCHECK_VERSION(2, 9, 4)
|
||||
wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst();
|
||||
|
||||
while( node )
|
||||
{
|
||||
wxWindow* win = node->GetData();
|
||||
|
||||
if( win != aFrame )
|
||||
win->Enable( !IsModal );
|
||||
|
||||
node = node->GetNext();
|
||||
}
|
||||
#else
|
||||
// Deprecated since wxWidgets 2.9.4
|
||||
aFrame->MakeModal( IsModal );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* toggle global wxFrame enable/disable state, does the re-enable part even
|
||||
* if an exception is thrown.
|
||||
*/
|
||||
struct ENABLE_DISABLE
|
||||
{
|
||||
wxFrame* m_frame;
|
||||
|
||||
ENABLE_DISABLE( wxFrame* aFrame ) :
|
||||
m_frame( aFrame )
|
||||
{
|
||||
makeModal( aFrame, true );
|
||||
}
|
||||
|
||||
~ENABLE_DISABLE()
|
||||
{
|
||||
// Re-enable all frames, (oops, even if they were previously inactive).
|
||||
// This is probably why this function was deprecated in wx.
|
||||
makeModal( m_frame, false );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
bool KIWAY_PLAYER::ShowModal( wxString* aResult )
|
||||
{
|
||||
/*
|
||||
This function has a nice interface but an unsightly implementation.
|
||||
Now it is encapsulated, making it easier to improve. I am not sure
|
||||
a wxSemaphore was needed, especially since no blocking happens. It seems
|
||||
like a volatile bool is sufficient.
|
||||
|
||||
It works in tandem with DismissModal(). But only ShowModal() is in the
|
||||
vtable and therefore cross-module capable.
|
||||
*/
|
||||
|
||||
volatile bool dismissed = false;
|
||||
|
||||
// disable all frames except the modal one, re-enable on exit, exception safe.
|
||||
ENABLE_DISABLE toggle( this );
|
||||
|
||||
m_modal_dismissed = &dismissed;
|
||||
|
||||
Show( true );
|
||||
Raise();
|
||||
|
||||
// Wait for the one and only active frame to call DismissModal() from
|
||||
// some concluding event.
|
||||
while( !dismissed )
|
||||
{
|
||||
wxYield();
|
||||
wxMilliSleep( 50 );
|
||||
}
|
||||
|
||||
// no longer modal, not to mention that the pointer would be invalid outside this scope.
|
||||
m_modal_dismissed = NULL;
|
||||
|
||||
if( aResult )
|
||||
*aResult = m_modal_string;
|
||||
|
||||
return m_modal_ret_val;
|
||||
}
|
||||
|
||||
|
||||
bool KIWAY_PLAYER::IsDismissed()
|
||||
{
|
||||
// if already dismissed, then m_modal_dismissed may be NULL, and if not,
|
||||
// it can still be dismissed if the bool is true.
|
||||
bool ret = !m_modal_dismissed || *m_modal_dismissed;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void KIWAY_PLAYER::DismissModal( bool aRetVal, const wxString& aResult )
|
||||
{
|
||||
m_modal_ret_val = aRetVal;
|
||||
m_modal_string = aResult;
|
||||
|
||||
if( m_modal_dismissed )
|
||||
*m_modal_dismissed = true;
|
||||
}
|
||||
|
||||
|
||||
@ -42,17 +155,20 @@ void KIWAY_PLAYER::kiway_express( KIWAY_EXPRESS& aEvent )
|
||||
{
|
||||
// logging support
|
||||
#if defined(DEBUG)
|
||||
const char* class_name = typeid(this).name();
|
||||
const char* class_name = typeid( this ).name();
|
||||
|
||||
printf( "%s: cmd:%d pay:'%s'\n", class_name,
|
||||
aEvent.GetEventType(), aEvent.GetPayload().c_str() );
|
||||
printf( "%s: received cmd:%d pay:'%s'\n", class_name,
|
||||
aEvent.Command(), aEvent.GetPayload().c_str() );
|
||||
#endif
|
||||
|
||||
KiwayMailIn( aEvent ); // call the virtual, overload in derived.
|
||||
KiwayMailIn( aEvent ); // call the virtual, override in derived.
|
||||
}
|
||||
|
||||
|
||||
void KIWAY_PLAYER::KiwayMailIn( KIWAY_EXPRESS& aEvent )
|
||||
void KIWAY_PLAYER::language_change( wxCommandEvent& event )
|
||||
{
|
||||
// overload this.
|
||||
int id = event.GetId();
|
||||
|
||||
// tell all the KIWAY_PLAYERs about the language change.
|
||||
Kiway().SetLanguage( id );
|
||||
}
|
||||
|
@ -622,7 +622,7 @@ bool PGM_BASE::SetLanguage( bool first_time )
|
||||
|
||||
void PGM_BASE::SetLanguageIdentifier( int menu_id )
|
||||
{
|
||||
wxLogDebug( wxT( "Select language ID %d from %zd possible languages." ),
|
||||
wxLogDebug( wxT( "Select language ID %d from %d possible languages." ),
|
||||
menu_id, DIM( s_Languages ) );
|
||||
|
||||
for( unsigned ii = 0; ii < DIM( s_Languages ); ii++ )
|
||||
|
@ -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.
|
||||
KIWAY Kiway( &Pgm() );
|
||||
KIWAY Kiway( &Pgm(), KFCTL_STANDALONE );
|
||||
|
||||
|
||||
// implement a PGM_BASE and a wxApp side by side:
|
||||
@ -225,82 +225,6 @@ struct APP_SINGLE_TOP : public wxApp
|
||||
IMPLEMENT_APP( APP_SINGLE_TOP );
|
||||
|
||||
|
||||
/**
|
||||
* Function get_kiface_getter
|
||||
* returns a KIFACE_GETTER_FUNC for the current process's main implementation
|
||||
* link image.
|
||||
*
|
||||
* @param aDSOName is an absolute full path to the DSO to load and find
|
||||
* KIFACE_GETTER_FUNC within.
|
||||
*
|
||||
* @return KIFACE_GETTER_FUNC* - a pointer to a function which can be called to
|
||||
* get the KIFACE or NULL if the getter func was not found. If not found,
|
||||
* it is possibly not version compatible since the lookup is done by name and
|
||||
* the name contains the API version.
|
||||
*/
|
||||
static KIFACE_GETTER_FUNC* get_kiface_getter( const wxString& aDSOName )
|
||||
{
|
||||
#if defined(BUILD_KIWAY_DLL)
|
||||
|
||||
// Remember single_top only knows about a single DSO. Using an automatic
|
||||
// with a defeated destructor, see Detach() below, so that the DSO program
|
||||
// image stays in RAM until process termination, and specifically
|
||||
// beyond the point in time at which static destructors are run. Otherwise
|
||||
// a static wxDynamicLibrary's destructor might create an out of sequence
|
||||
// problem. This was never detected, so it's only a preventative strategy.
|
||||
wxDynamicLibrary dso;
|
||||
|
||||
void* addr = NULL;
|
||||
|
||||
if( !dso.Load( aDSOName, wxDL_VERBATIM | wxDL_NOW ) )
|
||||
{
|
||||
// Failure: error reporting UI was done via wxLogSysError().
|
||||
// No further reporting required here.
|
||||
}
|
||||
|
||||
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.
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// Tell dso's wxDynamicLibrary destructor not to Unload() the program image.
|
||||
(void) dso.Detach();
|
||||
|
||||
return (KIFACE_GETTER_FUNC*) addr;
|
||||
}
|
||||
|
||||
// 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( aDSOName ),
|
||||
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
|
||||
// is bad. This exception will likely not get caught until way up in the
|
||||
// wxApp derivative, at which point the process will exit gracefully.
|
||||
THROW_IO_ERROR( msg );
|
||||
|
||||
#else
|
||||
return &KIFACE_GETTER;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static KIFACE* kiface;
|
||||
static int kiface_version;
|
||||
|
||||
|
||||
|
||||
bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp )
|
||||
{
|
||||
// first thing: set m_wx_app
|
||||
@ -321,44 +245,27 @@ bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp )
|
||||
if( !initPgm() )
|
||||
return false;
|
||||
|
||||
wxString dname = dso_full_path( absoluteArgv0 );
|
||||
#if !defined(BUILD_KIWAY_DLL)
|
||||
// Get the getter, it is statically linked into this binary image.
|
||||
KIFACE_GETTER_FUNC* getter = &KIFACE_GETTER;
|
||||
|
||||
// Get the getter.
|
||||
KIFACE_GETTER_FUNC* getter = get_kiface_getter( dname );
|
||||
|
||||
if( !getter )
|
||||
{
|
||||
// get_kiface_getter() failed & already showed the UI message.
|
||||
// Return failure without any further UI.
|
||||
return false;
|
||||
}
|
||||
int kiface_version;
|
||||
|
||||
// Get the KIFACE.
|
||||
kiface = getter( &kiface_version, KIFACE_VERSION, this );
|
||||
KIFACE* kiface = getter( &kiface_version, KIFACE_VERSION, this );
|
||||
|
||||
// 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.
|
||||
if( !kiface->OnKifaceStart( this, KFCTL_STANDALONE ) )
|
||||
return false;
|
||||
|
||||
// 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 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<KIWAY_PLAYER*>( kiface->CreateWindow(
|
||||
NULL, TOP_FRAME, &Kiway, KFCTL_STANDALONE ) );
|
||||
#else
|
||||
KIWAY_PLAYER* frame = (KIWAY_PLAYER*) kiface->CreateWindow(
|
||||
NULL, TOP_FRAME, &Kiway, KFCTL_STANDALONE );
|
||||
// Trick the KIWAY into thinking it loaded a KIFACE, by recording the KIFACE
|
||||
// in the KIWAY. It needs to be there for KIWAY::OnKiwayEnd() anyways.
|
||||
Kiway.set_kiface( KIWAY::KifaceType( TOP_FRAME ), kiface );
|
||||
#endif
|
||||
|
||||
// Use KIWAY to create a top window, which registers its existence also.
|
||||
// "TOP_FRAME" is a macro that is passed on compiler command line from CMake,
|
||||
// and is one of the types in FRAME_T.
|
||||
KIWAY_PLAYER* frame = Kiway.Player( TOP_FRAME, true );
|
||||
|
||||
Kiway.SetTop( frame );
|
||||
|
||||
App().SetTopWindow( frame ); // wxApp gets a face.
|
||||
|
||||
// Open project or file specified on the command line:
|
||||
@ -454,8 +361,7 @@ bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp )
|
||||
|
||||
void PGM_SINGLE_TOP::OnPgmExit()
|
||||
{
|
||||
if( kiface )
|
||||
kiface->OnKifaceEnd();
|
||||
Kiway.OnKiwayEnd();
|
||||
|
||||
saveCommonSettings();
|
||||
|
||||
|
@ -76,8 +76,6 @@ BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, EDA_BASE_FRAME )
|
||||
|
||||
EVT_MENU( ID_CVPCB_LIB_TABLE_EDIT, CVPCB_MAINFRAME::OnEditFootprintLibraryTable )
|
||||
|
||||
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, CVPCB_MAINFRAME::SetLanguage )
|
||||
|
||||
// Toolbar events
|
||||
EVT_TOOL( ID_CVPCB_QUIT, CVPCB_MAINFRAME::OnQuit )
|
||||
EVT_TOOL( ID_CVPCB_READ_INPUT_NETLIST, CVPCB_MAINFRAME::LoadNetList )
|
||||
@ -558,12 +556,6 @@ void CVPCB_MAINFRAME::DisplayModule( wxCommandEvent& event )
|
||||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::SetLanguage( wxCommandEvent& event )
|
||||
{
|
||||
EDA_BASE_FRAME::SetLanguage( event );
|
||||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::DisplayDocFile( wxCommandEvent& event )
|
||||
{
|
||||
GetAssociatedDocument( this, m_DocModulesFileName, &Kiface().KifaceSearch() );
|
||||
|
@ -123,12 +123,6 @@ public:
|
||||
|
||||
void ChangeFocus( bool aMoveRight );
|
||||
|
||||
/**
|
||||
* Function SetLanguage
|
||||
* is called on a language menu selection.
|
||||
*/
|
||||
void SetLanguage( wxCommandEvent& event );
|
||||
|
||||
void ToFirstNA( wxCommandEvent& event );
|
||||
void ToPreviousNA( wxCommandEvent& event );
|
||||
|
||||
|
@ -321,7 +321,7 @@ void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
|
||||
wxPoint move_offset;
|
||||
block = &screen->m_BlockLocate;
|
||||
|
||||
LIB_EDIT_FRAME* parent = ( LIB_EDIT_FRAME* ) aPanel->GetParent();
|
||||
LIB_EDIT_FRAME* parent = (LIB_EDIT_FRAME*) aPanel->GetParent();
|
||||
wxASSERT( parent != NULL );
|
||||
|
||||
LIB_COMPONENT* component = parent->GetComponent();
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <eda_dde.h>
|
||||
#include <wxEeschemaStruct.h>
|
||||
#include <libeditframe.h>
|
||||
#include <viewlib_frame.h>
|
||||
#include <eda_text.h>
|
||||
|
||||
#include <general.h>
|
||||
@ -104,6 +105,15 @@ static struct IFACE : public KIFACE_I
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case FRAME_SCH_VIEWER:
|
||||
case FRAME_SCH_VIEWER_MODAL:
|
||||
{
|
||||
LIB_VIEW_FRAME* frame = new LIB_VIEW_FRAME( aKiway, aParent, FRAME_T( aClassId ) );
|
||||
return frame;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
@ -118,7 +118,10 @@ EDA_COLOR_T GetInvisibleItemColor()
|
||||
|
||||
void LIB_EDIT_FRAME::InstallConfigFrame( wxCommandEvent& event )
|
||||
{
|
||||
InvokeEeschemaConfig( (SCH_EDIT_FRAME *)GetParent(), this );
|
||||
SCH_EDIT_FRAME* frame = (SCH_EDIT_FRAME*) Kiway().Player( FRAME_SCH, false );
|
||||
wxASSERT( frame );
|
||||
|
||||
InvokeEeschemaConfig( frame, this );
|
||||
}
|
||||
|
||||
|
||||
@ -134,7 +137,9 @@ void LIB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
|
||||
{
|
||||
int id = event.GetId();
|
||||
wxFileName fn;
|
||||
SCH_EDIT_FRAME* schFrame = ( SCH_EDIT_FRAME* ) GetParent();
|
||||
|
||||
SCH_EDIT_FRAME* schFrame = (SCH_EDIT_FRAME*) Kiway().Player( FRAME_SCH, false );
|
||||
wxASSERT( schFrame );
|
||||
|
||||
switch( id )
|
||||
{
|
||||
@ -143,20 +148,20 @@ void LIB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
|
||||
break;
|
||||
|
||||
case ID_CONFIG_READ:
|
||||
{
|
||||
fn = g_RootSheet->GetScreen()->GetFileName();
|
||||
fn.SetExt( ProjectFileExtension );
|
||||
{
|
||||
fn = g_RootSheet->GetScreen()->GetFileName();
|
||||
fn.SetExt( ProjectFileExtension );
|
||||
|
||||
wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(),
|
||||
fn.GetFullName(), ProjectFileWildcard,
|
||||
wxFD_OPEN | wxFD_FILE_MUST_EXIST );
|
||||
wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(),
|
||||
fn.GetFullName(), ProjectFileWildcard,
|
||||
wxFD_OPEN | wxFD_FILE_MUST_EXIST );
|
||||
|
||||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
break;
|
||||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
break;
|
||||
|
||||
schFrame->LoadProjectFile( dlg.GetPath(), true );
|
||||
}
|
||||
break;
|
||||
schFrame->LoadProjectFile( dlg.GetPath(), true );
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
// Hotkey IDs
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <pgm_base.h>
|
||||
#include <kiway.h>
|
||||
#include <gr_basic.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <confirm.h>
|
||||
@ -55,18 +56,14 @@
|
||||
wxString SCH_BASE_FRAME::SelectComponentFromLibBrowser( LIB_ALIAS* aPreselectedAlias,
|
||||
int* aUnit, int* aConvert )
|
||||
{
|
||||
wxSemaphore semaphore( 0, 1 );
|
||||
wxString cmpname;
|
||||
|
||||
// Close the current Lib browser, if open, and open a new one, in "modal" mode:
|
||||
LIB_VIEW_FRAME* viewlibFrame = LIB_VIEW_FRAME::GetActiveLibraryViewer( this );
|
||||
// Close the any current non-modal Lib browser if open, and open a new one, in "modal" mode:
|
||||
LIB_VIEW_FRAME* viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
|
||||
if( viewlibFrame )
|
||||
viewlibFrame->Destroy();
|
||||
|
||||
viewlibFrame = new LIB_VIEW_FRAME( &Kiway(), this, NULL, &semaphore,
|
||||
KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT );
|
||||
viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER_MODAL, true );
|
||||
|
||||
if ( aPreselectedAlias )
|
||||
if( aPreselectedAlias )
|
||||
{
|
||||
viewlibFrame->SetSelectedLibrary( aPreselectedAlias->GetLibraryName() );
|
||||
viewlibFrame->SetSelectedComponent( aPreselectedAlias->GetName() );
|
||||
@ -80,15 +77,9 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibBrowser( LIB_ALIAS* aPreselectedA
|
||||
|
||||
viewlibFrame->Refresh();
|
||||
|
||||
// Show the library viewer frame until it is closed
|
||||
// Wait for viewer closing event:
|
||||
while( semaphore.TryWait() == wxSEMA_BUSY )
|
||||
{
|
||||
wxYield();
|
||||
wxMilliSleep( 50 );
|
||||
}
|
||||
wxString cmpname;
|
||||
|
||||
cmpname = viewlibFrame->GetSelectedComponent();
|
||||
viewlibFrame->ShowModal( &cmpname );
|
||||
|
||||
if( aUnit )
|
||||
*aUnit = viewlibFrame->GetUnit();
|
||||
@ -101,6 +92,7 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibBrowser( LIB_ALIAS* aPreselectedA
|
||||
return cmpname;
|
||||
}
|
||||
|
||||
|
||||
wxString SCH_BASE_FRAME::SelectComponentFromLibrary( const wxString& aLibname,
|
||||
wxArrayString& aHistoryList,
|
||||
int& aHistoryLastUnit,
|
||||
|
@ -99,7 +99,7 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
|
||||
EVT_SIZE( LIB_EDIT_FRAME::OnSize )
|
||||
EVT_ACTIVATE( LIB_EDIT_FRAME::OnActivate )
|
||||
|
||||
/* Main horizontal toolbar. */
|
||||
// Main horizontal toolbar.
|
||||
EVT_TOOL( ID_LIBEDIT_SAVE_CURRENT_LIB, LIB_EDIT_FRAME::OnSaveActiveLibrary )
|
||||
EVT_TOOL( ID_LIBEDIT_SELECT_CURRENT_LIB, LIB_EDIT_FRAME::Process_Special_Functions )
|
||||
EVT_TOOL( ID_LIBEDIT_DELETE_PART, LIB_EDIT_FRAME::DeleteOnePart )
|
||||
@ -125,12 +125,12 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
|
||||
EVT_COMBOBOX( ID_LIBEDIT_SELECT_PART_NUMBER, LIB_EDIT_FRAME::OnSelectPart )
|
||||
EVT_COMBOBOX( ID_LIBEDIT_SELECT_ALIAS, LIB_EDIT_FRAME::OnSelectAlias )
|
||||
|
||||
/* Right vertical toolbar. */
|
||||
// Right vertical toolbar.
|
||||
EVT_TOOL( ID_NO_TOOL_SELECTED, LIB_EDIT_FRAME::OnSelectTool )
|
||||
EVT_TOOL_RANGE( ID_LIBEDIT_PIN_BUTT, ID_LIBEDIT_DELETE_ITEM_BUTT,
|
||||
LIB_EDIT_FRAME::OnSelectTool )
|
||||
|
||||
/* menubar commands */
|
||||
// menubar commands
|
||||
EVT_MENU( wxID_EXIT, LIB_EDIT_FRAME::CloseWindow )
|
||||
EVT_MENU( ID_LIBEDIT_SAVE_CURRENT_LIB_AS, LIB_EDIT_FRAME::OnSaveActiveLibrary )
|
||||
EVT_MENU( ID_LIBEDIT_GEN_PNG_FILE, LIB_EDIT_FRAME::OnPlotCurrentComponent )
|
||||
@ -152,9 +152,7 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
|
||||
EVT_MENU_RANGE( ID_PREFERENCES_HOTKEY_START, ID_PREFERENCES_HOTKEY_END,
|
||||
LIB_EDIT_FRAME::Process_Config )
|
||||
|
||||
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, LIB_EDIT_FRAME::SetLanguage )
|
||||
|
||||
/* Context menu events and commands. */
|
||||
// Context menu events and commands.
|
||||
EVT_MENU( ID_LIBEDIT_EDIT_PIN, LIB_EDIT_FRAME::OnEditPin )
|
||||
EVT_MENU( ID_LIBEDIT_ROTATE_ITEM, LIB_EDIT_FRAME::OnRotateItem )
|
||||
|
||||
@ -165,7 +163,7 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
|
||||
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
|
||||
LIB_EDIT_FRAME::Process_Special_Functions )
|
||||
|
||||
/* Update user interface elements. */
|
||||
// Update user interface elements.
|
||||
EVT_UPDATE_UI( ExportPartId, LIB_EDIT_FRAME::OnUpdateEditingPart )
|
||||
EVT_UPDATE_UI( CreateNewLibAndSavePartId, LIB_EDIT_FRAME::OnUpdateEditingPart )
|
||||
EVT_UPDATE_UI( ID_LIBEDIT_SAVE_CURRENT_PART, LIB_EDIT_FRAME::OnUpdateEditingPart )
|
||||
@ -193,7 +191,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, SCH_EDIT_FRAME* aParent ) :
|
||||
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.
|
||||
wxASSERT( aParent );
|
||||
|
||||
m_FrameName = GetLibEditFrameName();
|
||||
m_showAxis = true; // true to draw axis
|
||||
@ -204,6 +202,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, SCH_EDIT_FRAME* aParent ) :
|
||||
m_tempCopyComponent = NULL;
|
||||
m_HotkeysZoomAndGridList = s_Libedit_Hokeys_Descr;
|
||||
m_editPinsPerPartOrConvert = false;
|
||||
|
||||
// Initialize grid id to the default value 50 mils:
|
||||
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000;
|
||||
|
||||
@ -293,12 +292,6 @@ const wxChar* LIB_EDIT_FRAME::GetLibEditFrameName()
|
||||
}
|
||||
|
||||
|
||||
LIB_EDIT_FRAME* LIB_EDIT_FRAME::GetActiveLibraryEditor()
|
||||
{
|
||||
return (LIB_EDIT_FRAME*) wxWindow::FindWindowByName(GetLibEditFrameName());
|
||||
}
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
|
||||
{
|
||||
#if 0 // original
|
||||
@ -389,12 +382,12 @@ void LIB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
|
||||
|
||||
double LIB_EDIT_FRAME::BestZoom()
|
||||
{
|
||||
/* Please, note: wxMSW before version 2.9 seems have
|
||||
* problems with zoom values < 1 ( i.e. userscale > 1) and needs to be patched:
|
||||
* edit file <wxWidgets>/src/msw/dc.cpp
|
||||
* search for line static const int VIEWPORT_EXTENT = 1000;
|
||||
* and replace by static const int VIEWPORT_EXTENT = 10000;
|
||||
*/
|
||||
/* Please, note: wxMSW before version 2.9 seems have
|
||||
* problems with zoom values < 1 ( i.e. userscale > 1) and needs to be patched:
|
||||
* edit file <wxWidgets>/src/msw/dc.cpp
|
||||
* search for line static const int VIEWPORT_EXTENT = 1000;
|
||||
* and replace by static const int VIEWPORT_EXTENT = 10000;
|
||||
*/
|
||||
int dx, dy;
|
||||
wxSize size;
|
||||
EDA_RECT BoundaryBox;
|
||||
@ -750,23 +743,23 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
||||
break;
|
||||
|
||||
case ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT:
|
||||
{
|
||||
// Delete the last created segment, while creating a polyline draw item
|
||||
if( m_drawItem == NULL )
|
||||
break;
|
||||
{
|
||||
// Delete the last created segment, while creating a polyline draw item
|
||||
if( m_drawItem == NULL )
|
||||
break;
|
||||
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
STATUS_FLAGS oldFlags = m_drawItem->GetFlags();
|
||||
m_drawItem->ClearFlags();
|
||||
m_drawItem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, NULL,
|
||||
DefaultTransform );
|
||||
( (LIB_POLYLINE*) m_drawItem )->DeleteSegment( GetCrossHairPosition( true ) );
|
||||
m_drawItem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, NULL,
|
||||
DefaultTransform );
|
||||
m_drawItem->SetFlags( oldFlags );
|
||||
m_lastDrawItem = NULL;
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
STATUS_FLAGS oldFlags = m_drawItem->GetFlags();
|
||||
m_drawItem->ClearFlags();
|
||||
m_drawItem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, NULL,
|
||||
DefaultTransform );
|
||||
( (LIB_POLYLINE*) m_drawItem )->DeleteSegment( GetCrossHairPosition( true ) );
|
||||
m_drawItem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, NULL,
|
||||
DefaultTransform );
|
||||
m_drawItem->SetFlags( oldFlags );
|
||||
m_lastDrawItem = NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ID_POPUP_LIBEDIT_DELETE_ITEM:
|
||||
if( m_drawItem )
|
||||
@ -918,17 +911,6 @@ void LIB_EDIT_FRAME::EnsureActiveLibExists()
|
||||
}
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::SetLanguage( wxCommandEvent& event )
|
||||
{
|
||||
EDA_BASE_FRAME::SetLanguage( event );
|
||||
SCH_EDIT_FRAME *parent = (SCH_EDIT_FRAME *)GetParent();
|
||||
// Call parent->EDA_BASE_FRAME::SetLanguage and NOT
|
||||
// parent->SetLanguage because parent->SetLanguage call
|
||||
// LIB_EDIT_FRAME::SetLanguage
|
||||
parent->EDA_BASE_FRAME::SetLanguage( event );
|
||||
}
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::TempCopyComponent()
|
||||
{
|
||||
if( m_tempCopyComponent )
|
||||
|
@ -133,13 +133,6 @@ public:
|
||||
*/
|
||||
static const wxChar* GetLibEditFrameName();
|
||||
|
||||
/**
|
||||
* Function GetActiveLibraryEditor (static)
|
||||
* @return a reference to the current opened Library editor
|
||||
* or NULL if no Library editor currently opened
|
||||
*/
|
||||
static LIB_EDIT_FRAME* GetActiveLibraryEditor();
|
||||
|
||||
void ReCreateMenuBar();
|
||||
|
||||
/**
|
||||
@ -149,12 +142,6 @@ public:
|
||||
*/
|
||||
static void EnsureActiveLibExists();
|
||||
|
||||
/**
|
||||
* Function SetLanguage
|
||||
* is called on a language menu selection
|
||||
*/
|
||||
void SetLanguage( wxCommandEvent& event );
|
||||
|
||||
void InstallConfigFrame( wxCommandEvent& event );
|
||||
void InstallDimensionsDialog( wxCommandEvent& event );
|
||||
void OnColorConfig( wxCommandEvent& aEvent );
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <viewlib_frame.h>
|
||||
#include <libeditframe.h>
|
||||
#include <base_units.h>
|
||||
#include <kiway.h>
|
||||
|
||||
|
||||
SCH_BASE_FRAME::SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent,
|
||||
@ -40,12 +41,10 @@ SCH_BASE_FRAME::SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent,
|
||||
|
||||
void SCH_BASE_FRAME::OnOpenLibraryViewer( wxCommandEvent& event )
|
||||
{
|
||||
LIB_VIEW_FRAME* viewlibFrame = LIB_VIEW_FRAME::GetActiveLibraryViewer( this );
|
||||
LIB_VIEW_FRAME* viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, true );
|
||||
|
||||
if( viewlibFrame )
|
||||
viewlibFrame->Show( true );
|
||||
else
|
||||
new LIB_VIEW_FRAME( &Kiway(), this );
|
||||
viewlibFrame->Show( true );
|
||||
viewlibFrame->Raise();
|
||||
}
|
||||
|
||||
|
||||
|
@ -664,7 +664,7 @@ static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
|
||||
{
|
||||
SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
|
||||
SCH_ITEM* item = screen->GetCurItem();
|
||||
SCH_EDIT_FRAME* parent = ( SCH_EDIT_FRAME* ) aPanel->GetParent();
|
||||
SCH_EDIT_FRAME* parent = (SCH_EDIT_FRAME*) aPanel->GetParent();
|
||||
|
||||
parent->SetRepeatItem( NULL );
|
||||
screen->SetCurItem( NULL );
|
||||
|
@ -96,8 +96,6 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
|
||||
EVT_MENU( ID_COLORS_SETUP, SCH_EDIT_FRAME::OnColorConfig )
|
||||
EVT_TOOL( wxID_PREFERENCES, SCH_EDIT_FRAME::OnSetOptions )
|
||||
|
||||
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, SCH_EDIT_FRAME::SetLanguage )
|
||||
|
||||
EVT_TOOL( ID_TO_LIBRARY, SCH_EDIT_FRAME::OnOpenLibraryEditor )
|
||||
EVT_TOOL( ID_POPUP_SCH_CALL_LIBEDIT_AND_LOAD_CMP, SCH_EDIT_FRAME::OnOpenLibraryEditor )
|
||||
EVT_TOOL( ID_TO_LIBVIEW, SCH_EDIT_FRAME::OnOpenLibraryViewer )
|
||||
@ -442,13 +440,20 @@ void SCH_EDIT_FRAME::SaveUndoItemInUndoList( SCH_ITEM* aItem )
|
||||
|
||||
void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
|
||||
{
|
||||
LIB_EDIT_FRAME * libeditFrame = LIB_EDIT_FRAME::GetActiveLibraryEditor();;
|
||||
if( libeditFrame && !libeditFrame->Close() ) // Can close component editor?
|
||||
return;
|
||||
if( Kiface().IsSingle() )
|
||||
{
|
||||
LIB_EDIT_FRAME* libeditFrame = (LIB_EDIT_FRAME*) Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
|
||||
if( libeditFrame && !libeditFrame->Close() ) // Can close component editor?
|
||||
return;
|
||||
|
||||
LIB_VIEW_FRAME* viewlibFrame = LIB_VIEW_FRAME::GetActiveLibraryViewer( this );
|
||||
if( viewlibFrame && !viewlibFrame->Close() ) // Can close component viewer?
|
||||
return;
|
||||
LIB_VIEW_FRAME* viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
|
||||
if( viewlibFrame && !viewlibFrame->Close() ) // Can close component viewer?
|
||||
return;
|
||||
|
||||
viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER_MODAL, false );
|
||||
if( viewlibFrame && !viewlibFrame->Close() ) // Can close modal component viewer?
|
||||
return;
|
||||
}
|
||||
|
||||
SCH_SHEET_LIST SheetList;
|
||||
|
||||
@ -829,7 +834,7 @@ void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
|
||||
{
|
||||
SCH_ITEM* item = GetScreen()->GetCurItem();
|
||||
|
||||
if( (item == NULL) || (item->GetFlags() != 0) || ( item->Type() != SCH_COMPONENT_T ) )
|
||||
if( !item || (item->GetFlags() != 0) || ( item->Type() != SCH_COMPONENT_T ) )
|
||||
{
|
||||
wxMessageBox( _( "Error: not a component or no component" ) );
|
||||
return;
|
||||
@ -838,9 +843,21 @@ void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
|
||||
component = (SCH_COMPONENT*) item;
|
||||
}
|
||||
|
||||
// @todo: should be changed to use Kiway().Player()?
|
||||
LIB_EDIT_FRAME* libeditFrame = (LIB_EDIT_FRAME*) Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
|
||||
if( !libeditFrame )
|
||||
{
|
||||
libeditFrame = (LIB_EDIT_FRAME*) Kiway().Player( FRAME_SCH_LIB_EDITOR, true );
|
||||
libeditFrame->Show( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
// if( libeditFrame->IsIconized() )
|
||||
// libeditFrame->Iconize( false );
|
||||
}
|
||||
|
||||
LIB_EDIT_FRAME* libeditFrame = LIB_EDIT_FRAME::GetActiveLibraryEditor();;
|
||||
libeditFrame->Raise();
|
||||
|
||||
#if 0
|
||||
if( libeditFrame )
|
||||
{
|
||||
if( libeditFrame->IsIconized() )
|
||||
@ -855,6 +872,8 @@ void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
|
||||
wxWindow* w = kf.CreateWindow( this, FRAME_SCH_LIB_EDITOR, &Kiway(), kf.StartFlags() );
|
||||
libeditFrame = dynamic_cast<LIB_EDIT_FRAME*>( w );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if( component )
|
||||
{
|
||||
@ -875,16 +894,6 @@ void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
|
||||
}
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::SetLanguage( wxCommandEvent& event )
|
||||
{
|
||||
EDA_BASE_FRAME::SetLanguage( event );
|
||||
|
||||
LIB_EDIT_FRAME * libeditFrame = LIB_EDIT_FRAME::GetActiveLibraryEditor();;
|
||||
if( libeditFrame )
|
||||
libeditFrame->EDA_BASE_FRAME::SetLanguage( event );
|
||||
}
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::OnPrint( wxCommandEvent& event )
|
||||
{
|
||||
wxFileName fn;
|
||||
|
@ -283,7 +283,7 @@ static void ExitSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
|
||||
SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
|
||||
SCH_ITEM* item = screen->GetCurItem();
|
||||
|
||||
SCH_EDIT_FRAME* parent = ( SCH_EDIT_FRAME* ) aPanel->GetParent();
|
||||
SCH_EDIT_FRAME* parent = (SCH_EDIT_FRAME*) aPanel->GetParent();
|
||||
|
||||
if( (item == NULL) || (item->Type() != SCH_SHEET_T) || (parent == NULL) )
|
||||
return;
|
||||
|
@ -116,9 +116,9 @@ void LIB_VIEW_FRAME::ReCreateHToolbar()
|
||||
_( "View component documents" ) );
|
||||
m_mainToolBar->EnableTool( ID_LIBVIEW_VIEWDOC, false );
|
||||
|
||||
if( m_semaphore )
|
||||
// if library browser is modal
|
||||
if( m_Ident == FRAME_SCH_VIEWER_MODAL )
|
||||
{
|
||||
// The library browser is called from a "load component" command
|
||||
m_mainToolBar->AddSeparator();
|
||||
m_mainToolBar->AddTool( ID_LIBVIEW_CMP_EXPORT_TO_SCHEMATIC,
|
||||
wxEmptyString, KiBitmap( export_xpm ),
|
||||
|
@ -47,28 +47,25 @@
|
||||
*/
|
||||
wxString LIB_VIEW_FRAME::m_libraryName;
|
||||
wxString LIB_VIEW_FRAME::m_entryName;
|
||||
|
||||
int LIB_VIEW_FRAME::m_unit = 1;
|
||||
int LIB_VIEW_FRAME::m_convert = 1;
|
||||
|
||||
|
||||
/// When the viewer is used to select a component in schematic, the selected component is here.
|
||||
wxString LIB_VIEW_FRAME::m_exportToEeschemaCmpName;
|
||||
|
||||
|
||||
BEGIN_EVENT_TABLE( LIB_VIEW_FRAME, EDA_DRAW_FRAME )
|
||||
/* Window events */
|
||||
// Window events
|
||||
EVT_CLOSE( LIB_VIEW_FRAME::OnCloseWindow )
|
||||
EVT_SIZE( LIB_VIEW_FRAME::OnSize )
|
||||
EVT_ACTIVATE( LIB_VIEW_FRAME::OnActivate )
|
||||
|
||||
/* Toolbar events */
|
||||
// Toolbar events
|
||||
EVT_TOOL_RANGE( ID_LIBVIEW_NEXT, ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT,
|
||||
LIB_VIEW_FRAME::Process_Special_Functions )
|
||||
|
||||
EVT_TOOL( ID_LIBVIEW_CMP_EXPORT_TO_SCHEMATIC, LIB_VIEW_FRAME::ExportToSchematicLibraryPart )
|
||||
EVT_COMBOBOX( ID_LIBVIEW_SELECT_PART_NUMBER, LIB_VIEW_FRAME::Process_Special_Functions )
|
||||
|
||||
/* listbox events */
|
||||
// listbox events
|
||||
EVT_LISTBOX( ID_LIBVIEW_LIB_LIST, LIB_VIEW_FRAME::ClickOnLibList )
|
||||
EVT_LISTBOX( ID_LIBVIEW_CMP_LIST, LIB_VIEW_FRAME::ClickOnCmpList )
|
||||
EVT_LISTBOX_DCLICK( ID_LIBVIEW_CMP_LIST, LIB_VIEW_FRAME::DClickOnCmpList )
|
||||
@ -95,11 +92,17 @@ static wxAcceleratorEntry accels[] =
|
||||
#define ACCEL_TABLE_CNT ( sizeof( accels ) / sizeof( wxAcceleratorEntry ) )
|
||||
#define LIB_VIEW_FRAME_NAME wxT( "ViewlibFrame" )
|
||||
|
||||
LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, SCH_BASE_FRAME* aParent,
|
||||
CMP_LIBRARY* aLibrary, wxSemaphore* aSemaphore, long aStyle ) :
|
||||
SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH_VIEWER, _( "Library Browser" ),
|
||||
wxDefaultPosition, wxDefaultSize, aStyle, GetLibViewerFrameName() )
|
||||
LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
|
||||
CMP_LIBRARY* aLibrary ) :
|
||||
SCH_BASE_FRAME( aKiway, aParent, aFrameType, _( "Library Browser" ),
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
aFrameType==FRAME_SCH_VIEWER ?
|
||||
KICAD_DEFAULT_DRAWFRAME_STYLE :
|
||||
KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT,
|
||||
GetLibViewerFrameName() )
|
||||
{
|
||||
wxASSERT( aFrameType==FRAME_SCH_VIEWER || aFrameType==FRAME_SCH_VIEWER_MODAL );
|
||||
|
||||
wxAcceleratorTable table( ACCEL_TABLE_CNT, accels );
|
||||
|
||||
m_FrameName = GetLibViewerFrameName();
|
||||
@ -114,12 +117,6 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, SCH_BASE_FRAME* aParent,
|
||||
m_HotkeysZoomAndGridList = s_Viewlib_Hokeys_Descr;
|
||||
m_cmpList = NULL;
|
||||
m_libList = NULL;
|
||||
m_semaphore = aSemaphore;
|
||||
|
||||
if( m_semaphore )
|
||||
SetModalMode( true );
|
||||
|
||||
m_exportToEeschemaCmpName.Empty();
|
||||
|
||||
SetScreen( new SCH_SCREEN() );
|
||||
GetScreen()->m_Center = true; // Axis origin centered on screen.
|
||||
@ -139,10 +136,10 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, SCH_BASE_FRAME* aParent,
|
||||
|
||||
wxPoint win_pos( 0, 0 );
|
||||
|
||||
if( aLibrary == NULL )
|
||||
if( !aLibrary )
|
||||
{
|
||||
// Creates the libraries window display
|
||||
m_libList = new wxListBox( this, ID_LIBVIEW_LIB_LIST,
|
||||
m_libList = new wxListBox( this, ID_LIBVIEW_LIB_LIST,
|
||||
wxPoint( 0, 0 ), wxSize(m_libListWidth, -1),
|
||||
0, NULL, wxLB_HSCROLL );
|
||||
}
|
||||
@ -243,25 +240,19 @@ const wxChar* LIB_VIEW_FRAME::GetLibViewerFrameName()
|
||||
}
|
||||
|
||||
|
||||
LIB_VIEW_FRAME* LIB_VIEW_FRAME::GetActiveLibraryViewer( const wxWindow* aParent )
|
||||
{
|
||||
return (LIB_VIEW_FRAME*) wxWindow::FindWindowByName( GetLibViewerFrameName(), aParent );
|
||||
}
|
||||
|
||||
|
||||
void LIB_VIEW_FRAME::OnCloseWindow( wxCloseEvent& Event )
|
||||
{
|
||||
if( m_semaphore )
|
||||
{
|
||||
m_semaphore->Post();
|
||||
// This window will be destroyed by the calling function,
|
||||
// if needed
|
||||
SetModalMode( false );
|
||||
}
|
||||
else
|
||||
if( !IsModal() )
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
else if( !IsDismissed() )
|
||||
{
|
||||
// only dismiss modal frame if not already dismissed.
|
||||
DismissModal( false );
|
||||
|
||||
// Modal frame will be destroyed by the calling function.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -283,12 +274,13 @@ void LIB_VIEW_FRAME::OnSetRelativeOffset( wxCommandEvent& event )
|
||||
|
||||
double LIB_VIEW_FRAME::BestZoom()
|
||||
{
|
||||
/* Please, note: wxMSW before version 2.9 seems have
|
||||
* problems with zoom values < 1 ( i.e. userscale > 1) and needs to be patched:
|
||||
* edit file <wxWidgets>/src/msw/dc.cpp
|
||||
* search for line static const int VIEWPORT_EXTENT = 1000;
|
||||
* and replace by static const int VIEWPORT_EXTENT = 10000;
|
||||
*/
|
||||
/* Please, note: wxMSW before version 2.9 seems have
|
||||
* problems with zoom values < 1 ( i.e. userscale > 1) and needs to be patched:
|
||||
* edit file <wxWidgets>/src/msw/dc.cpp
|
||||
* search for line static const int VIEWPORT_EXTENT = 1000;
|
||||
* and replace by static const int VIEWPORT_EXTENT = 10000;
|
||||
*/
|
||||
|
||||
LIB_COMPONENT* component = NULL;
|
||||
double bestzoom = 16.0; // default value for bestzoom
|
||||
CMP_LIBRARY* lib = CMP_LIBRARY::FindLibrary( m_libraryName );
|
||||
@ -344,8 +336,8 @@ void LIB_VIEW_FRAME::ReCreateListLib()
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If not found, clear current library selection because it can be
|
||||
* deleted after a config change. */
|
||||
// If not found, clear current library selection because it can be
|
||||
// deleted after a config change.
|
||||
m_libraryName = wxEmptyString;
|
||||
m_entryName = wxEmptyString;
|
||||
m_unit = 1;
|
||||
@ -417,6 +409,7 @@ void LIB_VIEW_FRAME::SetSelectedLibrary( const wxString& aLibraryName )
|
||||
m_canvas->Refresh();
|
||||
DisplayLibInfos();
|
||||
ReCreateHToolbar();
|
||||
|
||||
// Ensure the corresponding line in m_libList is selected
|
||||
// (which is not necessary the case if SetSelectedLibrary is called
|
||||
// by an other caller than ClickOnLibList.
|
||||
@ -440,9 +433,10 @@ void LIB_VIEW_FRAME::SetSelectedComponent( const wxString& aComponentName )
|
||||
if( m_entryName.CmpNoCase( aComponentName ) != 0 )
|
||||
{
|
||||
m_entryName = aComponentName;
|
||||
|
||||
// Ensure the corresponding line in m_cmpList is selected
|
||||
// (which is not necessary the case if SetSelectedComponent is called
|
||||
// by an other caller than ClickOnCmpList.
|
||||
// (which is not necessarily the case if SetSelectedComponent is called
|
||||
// by another caller than ClickOnCmpList.
|
||||
m_cmpList->SetStringSelection( aComponentName, true );
|
||||
DisplayLibInfos();
|
||||
m_unit = 1;
|
||||
@ -456,14 +450,21 @@ void LIB_VIEW_FRAME::SetSelectedComponent( const wxString& aComponentName )
|
||||
|
||||
void LIB_VIEW_FRAME::DClickOnCmpList( wxCommandEvent& event )
|
||||
{
|
||||
if( m_semaphore )
|
||||
if( IsModal() )
|
||||
{
|
||||
ExportToSchematicLibraryPart( event );
|
||||
|
||||
// Prevent the double click from being as a single click in the parent
|
||||
// window which would cause the part to be parked rather than staying
|
||||
// in drag mode.
|
||||
((SCH_BASE_FRAME*) GetParent())->SkipNextLeftButtonReleaseEvent();
|
||||
// The schematic editor might not be the parent of the library viewer.
|
||||
// It could be a python window.
|
||||
SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
|
||||
|
||||
if( schframe )
|
||||
{
|
||||
// Prevent the double click from being as a single click in the parent
|
||||
// window which would cause the part to be parked rather than staying
|
||||
// in drag mode.
|
||||
schframe->SkipNextLeftButtonReleaseEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -473,9 +474,17 @@ void LIB_VIEW_FRAME::ExportToSchematicLibraryPart( wxCommandEvent& event )
|
||||
int ii = m_cmpList->GetSelection();
|
||||
|
||||
if( ii >= 0 )
|
||||
m_exportToEeschemaCmpName = m_cmpList->GetString( ii );
|
||||
{
|
||||
wxString part_name = m_cmpList->GetString( ii );
|
||||
|
||||
// a selection was made, pass true
|
||||
DismissModal( true, part_name );
|
||||
}
|
||||
else
|
||||
m_exportToEeschemaCmpName.Empty();
|
||||
{
|
||||
// no selection was made, pass false
|
||||
DismissModal( false );
|
||||
}
|
||||
|
||||
Close( true );
|
||||
}
|
||||
@ -524,10 +533,6 @@ void LIB_VIEW_FRAME::OnActivate( wxActivateEvent& event )
|
||||
{
|
||||
EDA_DRAW_FRAME::OnActivate( event );
|
||||
|
||||
// Ensure we do not have old selection:
|
||||
if( m_FrameIsActive )
|
||||
m_exportToEeschemaCmpName.Empty();
|
||||
|
||||
if( m_libList )
|
||||
ReCreateListLib();
|
||||
|
||||
|
@ -38,7 +38,6 @@
|
||||
|
||||
class wxSashLayoutWindow;
|
||||
class wxListBox;
|
||||
class wxSemaphore;
|
||||
class CMP_LIBRARY;
|
||||
|
||||
|
||||
@ -48,9 +47,14 @@ class CMP_LIBRARY;
|
||||
class LIB_VIEW_FRAME : public SCH_BASE_FRAME
|
||||
{
|
||||
public:
|
||||
LIB_VIEW_FRAME( KIWAY* aKiway, SCH_BASE_FRAME* aParent,
|
||||
CMP_LIBRARY* aLibrary = NULL, wxSemaphore* aSemaphore = NULL,
|
||||
long aStyle = KICAD_DEFAULT_DRAWFRAME_STYLE );
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param aFrameType must be given either FRAME_SCH_LIB_VIEWER or
|
||||
* FRAME_SCH_LIB_VIEWER_MODAL
|
||||
*/
|
||||
LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent,
|
||||
FRAME_T aFrameType, CMP_LIBRARY* aLibrary = NULL );
|
||||
|
||||
~LIB_VIEW_FRAME();
|
||||
|
||||
@ -61,13 +65,6 @@ public:
|
||||
*/
|
||||
static const wxChar* GetLibViewerFrameName();
|
||||
|
||||
/**
|
||||
* Function GetActiveLibraryViewer (static)
|
||||
* @return a reference to the current opened Library viewer
|
||||
* or NULL if no Library viewer currently opened
|
||||
*/
|
||||
static LIB_VIEW_FRAME* GetActiveLibraryViewer( const wxWindow* aParent );
|
||||
|
||||
void OnSize( wxSizeEvent& event );
|
||||
|
||||
/**
|
||||
@ -109,7 +106,6 @@ public:
|
||||
* @param the alias name of the component to be selected.
|
||||
*/
|
||||
void SetSelectedComponent( const wxString& aComponentName );
|
||||
const wxString& GetSelectedComponent( void ) const { return m_exportToEeschemaCmpName; }
|
||||
|
||||
void SetUnit( int aUnit ) { m_unit = aUnit; }
|
||||
int GetUnit( void ) { return m_unit; }
|
||||
@ -147,8 +143,6 @@ private:
|
||||
wxListBox* m_cmpList; // The list of components
|
||||
int m_cmpListWidth; // Last width of the window
|
||||
|
||||
// Flags
|
||||
wxSemaphore* m_semaphore; // != NULL if the frame must emulate a modal dialog
|
||||
wxString m_configPath; // subpath for configuration
|
||||
|
||||
// TODO(hzeller): looks like these members were chosen to be static to survive different
|
||||
@ -156,11 +150,8 @@ private:
|
||||
// ugly hack, and should be solved differently.
|
||||
static wxString m_libraryName;
|
||||
|
||||
// TODO(hzeller): figure out what the difference between these is and the motivation to
|
||||
// have this distinction. Shouldn't these essentially be the same ?
|
||||
static wxString m_entryName;
|
||||
static wxString m_exportToEeschemaCmpName; // When the viewer is used to select a component
|
||||
// in schematic, the selected component is here
|
||||
|
||||
static int m_unit;
|
||||
static int m_convert;
|
||||
|
||||
|
@ -52,8 +52,6 @@ BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME )
|
||||
GERBVIEW_FRAME::OnSelectOptionToolbar )
|
||||
EVT_MENU( wxID_PREFERENCES, GERBVIEW_FRAME::InstallGerberOptionsDialog )
|
||||
|
||||
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, EDA_DRAW_FRAME::SetLanguage )
|
||||
|
||||
// menu Postprocess
|
||||
EVT_MENU( ID_GERBVIEW_SHOW_LIST_DCODES, GERBVIEW_FRAME::Process_Special_Functions )
|
||||
EVT_MENU( ID_GERBVIEW_SHOW_SOURCE, GERBVIEW_FRAME::OnShowGerberSourceFile )
|
||||
@ -209,9 +207,6 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
||||
}
|
||||
|
||||
|
||||
/* Selects the active DCode for the current active layer.
|
||||
* Items using this DCode are hightlighted
|
||||
*/
|
||||
void GERBVIEW_FRAME::OnSelectActiveDCode( wxCommandEvent& event )
|
||||
{
|
||||
GERBER_IMAGE* gerber_image = g_GERBER_List[getActiveLayer()];
|
||||
@ -228,10 +223,7 @@ void GERBVIEW_FRAME::OnSelectActiveDCode( wxCommandEvent& event )
|
||||
}
|
||||
}
|
||||
|
||||
/* Selects the active layer:
|
||||
* - if a file is loaded, it is loaded in this layer
|
||||
* _ this layer is displayed on top of other layers
|
||||
*/
|
||||
|
||||
void GERBVIEW_FRAME::OnSelectActiveLayer( wxCommandEvent& event )
|
||||
{
|
||||
LAYER_NUM layer = getActiveLayer();
|
||||
@ -246,9 +238,6 @@ void GERBVIEW_FRAME::OnSelectActiveLayer( wxCommandEvent& event )
|
||||
}
|
||||
|
||||
|
||||
/* Call preferred editor to show (and edit) the gerber source file
|
||||
* loaded in the active layer
|
||||
*/
|
||||
void GERBVIEW_FRAME::OnShowGerberSourceFile( wxCommandEvent& event )
|
||||
{
|
||||
LAYER_NUM layer = getActiveLayer();
|
||||
@ -275,9 +264,6 @@ void GERBVIEW_FRAME::OnShowGerberSourceFile( wxCommandEvent& event )
|
||||
}
|
||||
|
||||
|
||||
/* Function OnSelectDisplayMode: called to select display mode
|
||||
* (fast display, or exact mode with stacked images or with transparency
|
||||
*/
|
||||
void GERBVIEW_FRAME::OnSelectDisplayMode( wxCommandEvent& event )
|
||||
{
|
||||
int oldMode = GetDisplayMode();
|
||||
@ -301,20 +287,20 @@ void GERBVIEW_FRAME::OnSelectDisplayMode( wxCommandEvent& event )
|
||||
m_canvas->Refresh();
|
||||
}
|
||||
|
||||
|
||||
void GERBVIEW_FRAME::OnQuit( wxCommandEvent& event )
|
||||
{
|
||||
Close( true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Function SetLanguage
|
||||
* called on a language menu selection
|
||||
* Update Layer manager title and tabs texts
|
||||
*/
|
||||
void GERBVIEW_FRAME::SetLanguage( wxCommandEvent& event )
|
||||
|
||||
void GERBVIEW_FRAME::ShowChangedLanguage()
|
||||
{
|
||||
EDA_DRAW_FRAME::SetLanguage( event );
|
||||
// call my base class
|
||||
EDA_DRAW_FRAME::ShowChangedLanguage();
|
||||
|
||||
m_LayersManager->SetLayersManagerTabsText();
|
||||
|
||||
wxAuiPaneInfo& pane_info = m_auimgr.GetPane( m_LayersManager );
|
||||
pane_info.Caption( _( "Visibles" ) );
|
||||
m_auimgr.Update();
|
||||
@ -322,14 +308,12 @@ void GERBVIEW_FRAME::SetLanguage( wxCommandEvent& event )
|
||||
ReFillLayerWidget();
|
||||
}
|
||||
|
||||
/**
|
||||
* Function OnSelectOptionToolbar
|
||||
* called to validate current choices
|
||||
*/
|
||||
|
||||
void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
|
||||
{
|
||||
int id = event.GetId();
|
||||
bool state;
|
||||
int id = event.GetId();
|
||||
bool state;
|
||||
|
||||
switch( id )
|
||||
{
|
||||
case ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG:
|
||||
@ -374,6 +358,7 @@ void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
|
||||
break;
|
||||
|
||||
case ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR:
|
||||
|
||||
// show/hide auxiliary Vertical layers and visibility manager toolbar
|
||||
m_show_layer_manager_tools = state;
|
||||
m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).Show( m_show_layer_manager_tools );
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user