Commit 9536ed81 authored by Maciej Suminski's avatar Maciej Suminski

Upstream merge.

parents fa5a6e5d d9c3de9b
...@@ -80,7 +80,7 @@ public: ...@@ -80,7 +80,7 @@ public:
EDA_3D_CANVAS( EDA_3D_FRAME* parent, int* attribList = 0 ); EDA_3D_CANVAS( EDA_3D_FRAME* parent, int* attribList = 0 );
~EDA_3D_CANVAS(); ~EDA_3D_CANVAS();
EDA_3D_FRAME* Parent() { return (EDA_3D_FRAME*)GetParent(); } EDA_3D_FRAME* Parent() const { return static_cast<EDA_3D_FRAME*>( GetParent() ); }
BOARD* GetBoard() { return Parent()->GetBoard(); } BOARD* GetBoard() { return Parent()->GetBoard(); }
......
...@@ -81,7 +81,7 @@ public: ...@@ -81,7 +81,7 @@ public:
m_auimgr.UnInit(); m_auimgr.UnInit();
}; };
PCB_BASE_FRAME* Parent() { return (PCB_BASE_FRAME*)GetParent(); } PCB_BASE_FRAME* Parent() const { return (PCB_BASE_FRAME*)GetParent(); }
BOARD* GetBoard(); BOARD* GetBoard();
......
...@@ -14,7 +14,7 @@ set( BITMAP2COMPONENT_SRCS ...@@ -14,7 +14,7 @@ set( BITMAP2COMPONENT_SRCS
) )
set_source_files_properties( ../common/single_top.cpp PROPERTIES 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 set_source_files_properties( bitmap2cmp_gui.cpp PROPERTIES
COMPILE_DEFINITIONS "COMPILING_DLL" COMPILE_DEFINITIONS "COMPILING_DLL"
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
#include <menus_helpers.h> #include <menus_helpers.h>
#include <boost/version.hpp> #include <boost/version.hpp>
#include <typeinfo>
/// The default auto save interval is 10 minutes. /// The default auto save interval is 10 minutes.
#define DEFAULT_AUTO_SAVE_INTERVAL 600 #define DEFAULT_AUTO_SAVE_INTERVAL 600
...@@ -151,6 +151,19 @@ bool EDA_BASE_FRAME::ProcessEvent( wxEvent& aEvent ) ...@@ -151,6 +151,19 @@ bool EDA_BASE_FRAME::ProcessEvent( wxEvent& aEvent )
} }
bool EDA_BASE_FRAME::Enable( bool enable )
{
// so we can do logging of this state change:
#if defined(DEBUG)
const char* type_id = typeid( *this ).name();
printf( "wxFrame %s: %s\n", type_id, enable ? "enabled" : "disabled" );
#endif
return wxFrame::Enable( enable );
}
void EDA_BASE_FRAME::onAutoSaveTimer( wxTimerEvent& aEvent ) void EDA_BASE_FRAME::onAutoSaveTimer( wxTimerEvent& aEvent )
{ {
if( !doAutoSave() ) if( !doAutoSave() )
...@@ -169,12 +182,8 @@ void EDA_BASE_FRAME::ReCreateMenuBar() ...@@ -169,12 +182,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(); ReCreateMenuBar();
GetMenuBar()->Refresh(); GetMenuBar()->Refresh();
} }
...@@ -717,27 +726,3 @@ void EDA_BASE_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName, ...@@ -717,27 +726,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 ) ...@@ -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 // First easy thing: a black gives always the other colour
if( aColor1 == BLACK ) if( aColor1 == BLACK )
return aColor2; return aColor2;
if( aColor2 == BLACK) if( aColor2 == BLACK)
return aColor1; return aColor1;
......
...@@ -25,17 +25,45 @@ ...@@ -25,17 +25,45 @@
#include <dialog_shim.h> #include <dialog_shim.h>
#include <kiway_player.h> #include <kiway_player.h>
#include <wx/evtloop.h>
/*
Quasi-Modal Mode Explained:
The gtk calls in wxDialog::ShowModal() cause event routing problems if that
modal dialog then tries to use KIWAY_PLAYER::ShowModal(). The latter shows up
and mostly works but does not respond to the window decoration close button.
There is no way to get around this without reversing the gtk calls temporarily.
Quasi-Modal mode is our own almost modal mode which disables only the parent
of the DIALOG_SHIM, leaving other frames operable and while staying captured in the
nested event loop. This avoids the gtk calls and leaves event routing pure
and sufficient to operate the KIWAY_PLAYER::ShowModal() properly. When using
ShowQuasiModal() you have to use EndQuasiModal() in your dialogs and not
EndModal(). There is also IsQuasiModal() but its value can only be true
when the nested event loop is active. Do not mix the modal and quasi-modal
functions. Use one set or the other.
You might find this behavior preferable over a pure modal mode, and it was said
that only the Mac has this natively, but now other platforms have something
similar. You CAN use it anywhere for any dialog. But you MUST use it when
you want to use KIWAY_PLAYER::ShowModal() from a dialog event.
*/
DIALOG_SHIM::DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& title, DIALOG_SHIM::DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& title,
const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : const wxPoint& pos, const wxSize& size, long style, const wxString& name ) :
wxDialog( aParent, id, title, pos, size, style, name ), wxDialog( aParent, id, title, pos, size, style, name ),
KIWAY_HOLDER( 0 ) KIWAY_HOLDER( 0 ),
m_qmodal_loop( 0 ),
m_qmodal_showing( false )
{ {
// pray that aParent is either a KIWAY_PLAYER or DIALOG_SHIM derivation. // pray that aParent is either a KIWAY_PLAYER or DIALOG_SHIM derivation.
KIWAY_HOLDER* h = dynamic_cast<KIWAY_HOLDER*>( aParent ); KIWAY_HOLDER* h = dynamic_cast<KIWAY_HOLDER*>( aParent );
wxASSERT_MSG( h, wxASSERT_MSG( h,
wxT( "DIALOG_SHIM's parent not derived from KIWAY_PLAYER nor DIALOG_SHIM" ) ); wxT( "DIALOG_SHIM's parent is NULL or not derived from KIWAY_PLAYER nor DIALOG_SHIM" ) );
if( h ) if( h )
SetKiway( this, &h->Kiway() ); SetKiway( this, &h->Kiway() );
...@@ -46,6 +74,14 @@ DIALOG_SHIM::DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& titl ...@@ -46,6 +74,14 @@ DIALOG_SHIM::DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& titl
} }
DIALOG_SHIM::~DIALOG_SHIM()
{
// if the dialog is quasi-modal, this will end its event loop
if( IsQuasiModal() )
EndQuasiModal( wxID_CANCEL );
}
// our hashtable is an implementation secret, don't need or want it in a header file // our hashtable is an implementation secret, don't need or want it in a header file
#include <hashtables.h> #include <hashtables.h>
#include <base_struct.h> // EDA_RECT #include <base_struct.h> // EDA_RECT
...@@ -92,6 +128,169 @@ bool DIALOG_SHIM::Show( bool show ) ...@@ -92,6 +128,169 @@ bool DIALOG_SHIM::Show( bool show )
} }
bool DIALOG_SHIM::Enable( bool enable )
{
// so we can do logging of this state change:
#if defined(DEBUG)
const char* type_id = typeid( *this ).name();
printf( "wxDialog %s: %s\n", type_id, enable ? "enabled" : "disabled" );
#endif
return wxDialog::Enable( enable );
}
#if !wxCHECK_VERSION( 2, 9, 4 )
wxWindow* DIALOG_SHIM::CheckIfCanBeUsedAsParent( wxWindow* parent ) const
{
if ( !parent )
return NULL;
extern WXDLLIMPEXP_DATA_BASE(wxList) wxPendingDelete;
if ( wxPendingDelete.Member(parent) || parent->IsBeingDeleted() )
{
// this window is being deleted and we shouldn't create any children
// under it
return NULL;
}
if ( parent->GetExtraStyle() & wxWS_EX_TRANSIENT )
{
// this window is not being deleted yet but it's going to disappear
// soon so still don't parent this window under it
return NULL;
}
if ( !parent->IsShownOnScreen() )
{
// using hidden parent won't work correctly neither
return NULL;
}
// FIXME-VC6: this compiler requires an explicit const cast or it fails
// with error C2446
if ( const_cast<const wxWindow *>(parent) == this )
{
// not sure if this can really happen but it doesn't hurt to guard
// against this clearly invalid situation
return NULL;
}
return parent;
}
wxWindow* DIALOG_SHIM::GetParentForModalDialog(wxWindow *parent, long style) const
{
// creating a parent-less modal dialog will result (under e.g. wxGTK2)
// in an unfocused dialog, so try to find a valid parent for it unless we
// were explicitly asked not to
if ( style & wxDIALOG_NO_PARENT )
return NULL;
// first try the given parent
if ( parent )
parent = CheckIfCanBeUsedAsParent(wxGetTopLevelParent(parent));
// then the currently active window
if ( !parent )
parent = CheckIfCanBeUsedAsParent(
wxGetTopLevelParent(wxGetActiveWindow()));
// and finally the application main window
if ( !parent )
parent = CheckIfCanBeUsedAsParent(wxTheApp->GetTopWindow());
return parent;
}
#endif
int DIALOG_SHIM::ShowQuasiModal()
{
// toggle a window's "enable" status to disabled, then enabled on exit.
// exception safe.
struct ENABLE_DISABLE
{
wxWindow* m_win;
ENABLE_DISABLE( wxWindow* aWindow ) : m_win( aWindow ) { if( m_win ) m_win->Disable(); }
~ENABLE_DISABLE()
{
if( m_win )
{
m_win->Enable();
m_win->SetFocus(); // let's focus back on the parent window
}
}
};
// This is an exception safe way to zero a pointer before returning.
// Yes, even though DismissModal() clears this first normally, this is
// here in case there's an exception before the dialog is dismissed.
struct NULLER
{
void*& m_what;
NULLER( void*& aPtr ) : m_what( aPtr ) {}
~NULLER() { m_what = 0; } // indeed, set it to NULL on destruction
} clear_this( (void*&) m_qmodal_loop );
// release the mouse if it's currently captured as the window having it
// will be disabled when this dialog is shown -- but will still keep the
// capture making it impossible to do anything in the modal dialog itself
wxWindow* win = wxWindow::GetCapture();
if( win )
win->ReleaseMouse();
wxWindow* parent = GetParentForModalDialog( GetParent(), GetWindowStyle() );
ENABLE_DISABLE toggle( parent ); // quasi-modal: disable only my "optimal" parent
Show( true );
m_qmodal_showing = true;
WX_EVENT_LOOP event_loop;
#if wxCHECK_VERSION( 2, 9, 4 ) // 2.9.4 is only approximate.
// new code needs this, old code does it in wxEventLoop::Run() and cannot
// tolerate it here. Where that boundary is as a version number, I don't know.
// A closer look at the subversion repo for wx would tell.
wxEventLoopActivator event_loop_stacker( &event_loop );
#endif
m_qmodal_loop = &event_loop;
event_loop.Run();
return GetReturnCode();
}
void DIALOG_SHIM::EndQuasiModal( int retCode )
{
SetReturnCode( retCode );
if( !IsQuasiModal() )
{
wxFAIL_MSG( wxT( "either DIALOG_SHIM::EndQuasiModal called twice or ShowQuasiModal wasn't called" ) );
return;
}
m_qmodal_showing = false;
if( m_qmodal_loop )
{
m_qmodal_loop->Exit();
m_qmodal_loop = NULL;
}
Show( false );
}
#if DLGSHIM_USE_SETFOCUS #if DLGSHIM_USE_SETFOCUS
static bool findWindowRecursively( const wxWindowList& children, const wxWindow* wanted ) static bool findWindowRecursively( const wxWindowList& children, const wxWindow* wanted )
......
...@@ -589,12 +589,6 @@ bool EDA_DRAW_FRAME::HandleBlockEnd( wxDC* DC ) ...@@ -589,12 +589,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() void EDA_DRAW_FRAME::UpdateStatusBar()
{ {
wxString Line; wxString Line;
......
...@@ -165,7 +165,7 @@ EDA_DRAW_PANEL::~EDA_DRAW_PANEL() ...@@ -165,7 +165,7 @@ EDA_DRAW_PANEL::~EDA_DRAW_PANEL()
} }
EDA_DRAW_FRAME* EDA_DRAW_PANEL::GetParent() EDA_DRAW_FRAME* EDA_DRAW_PANEL::GetParent() const
{ {
wxWindow* mom = wxScrolledWindow::GetParent(); wxWindow* mom = wxScrolledWindow::GetParent();
return (EDA_DRAW_FRAME*) mom; return (EDA_DRAW_FRAME*) mom;
......
...@@ -62,6 +62,7 @@ const char* EndsWithRev( const char* start, const char* tail, char separator ) ...@@ -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 RevCmp( const char* s1, const char* s2 )
{ {
int r = strncmp( s1, s2, 3 ); int r = strncmp( s1, s2, 3 );
...@@ -76,6 +77,7 @@ int RevCmp( const char* s1, const char* s2 ) ...@@ -76,6 +77,7 @@ int RevCmp( const char* s1, const char* s2 )
return -(rnum1 - rnum2); // swap the sign, higher revs first return -(rnum1 - rnum2); // swap the sign, higher revs first
} }
#endif
//----<Policy and field test functions>------------------------------------- //----<Policy and field test functions>-------------------------------------
...@@ -116,7 +118,7 @@ void FPID::clear() ...@@ -116,7 +118,7 @@ void FPID::clear()
} }
int FPID::Parse( const std::string& aId ) int FPID::Parse( const UTF8& aId )
{ {
clear(); clear();
...@@ -171,12 +173,6 @@ int FPID::Parse( const std::string& aId ) ...@@ -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 ) FPID::FPID( const std::string& aId ) throw( PARSE_ERROR )
{ {
int offset = Parse( aId ); int offset = Parse( aId );
...@@ -194,14 +190,14 @@ FPID::FPID( const std::string& aId ) throw( PARSE_ERROR ) ...@@ -194,14 +190,14 @@ FPID::FPID( const std::string& aId ) throw( PARSE_ERROR )
FPID::FPID( const wxString& 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 ); int offset = Parse( id );
if( offset != -1 ) if( offset != -1 )
{ {
THROW_PARSE_ERROR( _( "Illegal character found in FPID string" ), THROW_PARSE_ERROR( _( "Illegal character found in FPID string" ),
wxString::FromUTF8( id.c_str() ), aId,
id.c_str(), id.c_str(),
0, 0,
offset ); offset );
...@@ -209,7 +205,7 @@ FPID::FPID( const wxString& aId ) throw( PARSE_ERROR ) ...@@ -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 ); int offset = okLogical( aLogical );
...@@ -222,13 +218,7 @@ int FPID::SetLibNickname( const std::string& aLogical ) ...@@ -222,13 +218,7 @@ 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( "/" ) );
...@@ -246,13 +236,7 @@ int FPID::SetFootprintName( const std::string& aFootprintName ) ...@@ -246,13 +236,7 @@ int FPID::SetFootprintName( const std::string& aFootprintName )
} }
int FPID::SetFootprintName( const wxString& aFootprintName ) int FPID::SetRevision( const UTF8& aRevision )
{
return SetFootprintName( std::string( TO_UTF8( aFootprintName ) ) );
}
int FPID::SetRevision( const std::string& aRevision )
{ {
int offset = okRevision( aRevision ); int offset = okRevision( aRevision );
...@@ -301,8 +285,10 @@ UTF8 FPID::GetFootprintNameAndRev() const ...@@ -301,8 +285,10 @@ UTF8 FPID::GetFootprintNameAndRev() const
} }
UTF8 FPID::Format( const std::string& aLogicalLib, const std::string& aFootprintName, #if 0 // this is broken, it does not output aFootprintName for some reason
const std::string& aRevision )
UTF8 FPID::Format( const UTF8& aLogicalLib, const UTF8& aFootprintName,
const UTF8& aRevision )
throw( PARSE_ERROR ) throw( PARSE_ERROR )
{ {
UTF8 ret; UTF8 ret;
...@@ -344,6 +330,7 @@ UTF8 FPID::Format( const std::string& aLogicalLib, const std::string& aFootprint ...@@ -344,6 +330,7 @@ UTF8 FPID::Format( const std::string& aLogicalLib, const std::string& aFootprint
return ret; return ret;
} }
#endif
int FPID::compare( const FPID& aFPID ) const int FPID::compare( const FPID& aFPID ) const
......
...@@ -28,9 +28,12 @@ ...@@ -28,9 +28,12 @@
#include <kiway.h> #include <kiway.h>
#include <kiway_player.h> #include <kiway_player.h>
#include <kiway_express.h> #include <kiway_express.h>
#include <pgm_base.h>
#include <config.h> #include <config.h>
#include <wx/debug.h> #include <id.h>
#include <wx/stdpaths.h> #include <wx/stdpaths.h>
#include <wx/debug.h>
KIFACE* KIWAY::m_kiface[KIWAY_FACE_COUNT]; KIFACE* KIWAY::m_kiface[KIWAY_FACE_COUNT];
...@@ -38,22 +41,24 @@ int KIWAY::m_kiface_version[KIWAY_FACE_COUNT]; ...@@ -38,22 +41,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_program( aProgram ),
m_ctl( aCtlBits ),
m_top( 0 ) m_top( 0 )
{ {
SetTop( aTop ); // hook playerDestroyHandler() into aTop. SetTop( aTop ); // hook player_destroy_handler() into aTop.
memset( m_player, 0, sizeof( m_player ) ); memset( m_player, 0, sizeof( m_player ) );
} }
// Any event types derived from wxCommandEvt, like wxWindowDestroyEvent, are // Any event types derived from wxCommandEvt, like wxWindowDestroyEvent, are
// propogated upwards to parent windows if not handled below. Therefor the // propogated upwards to parent windows if not handled below. Therefor the
// m_top window should receive all wxWindowDestroyEvents originating from // 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. // 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(); wxWindow* w = event.GetWindow();
...@@ -62,7 +67,7 @@ void KIWAY::playerDestroyHandler( wxWindowDestroyEvent& event ) ...@@ -62,7 +67,7 @@ void KIWAY::playerDestroyHandler( wxWindowDestroyEvent& event )
// if destroying one of our flock, then mark it as deceased. // if destroying one of our flock, then mark it as deceased.
if( (wxWindow*) m_player[i] == w ) 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; m_player[i] = 0;
} }
} }
...@@ -73,12 +78,12 @@ void KIWAY::SetTop( wxFrame* aTop ) ...@@ -73,12 +78,12 @@ void KIWAY::SetTop( wxFrame* aTop )
{ {
if( m_top ) 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 ) 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; m_top = aTop;
...@@ -96,8 +101,8 @@ const wxString KIWAY::dso_full_path( FACE_T aFaceId ) ...@@ -96,8 +101,8 @@ const wxString KIWAY::dso_full_path( FACE_T aFaceId )
case FACE_CVPCB: name = KIFACE_PREFIX wxT( "cvpcb" ); break; case FACE_CVPCB: name = KIFACE_PREFIX wxT( "cvpcb" ); break;
case FACE_GERBVIEW: name = KIFACE_PREFIX wxT( "gerbview" ); break; case FACE_GERBVIEW: name = KIFACE_PREFIX wxT( "gerbview" ); break;
case FACE_PL_EDITOR: name = KIFACE_PREFIX wxT( "pl_editor" ); 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_PCB_CALCULATOR: who knows. case FACE_BMP2CMP: name = KIFACE_PREFIX wxT( "bitmap2component" ); break;
default: default:
wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFaceId" ) ); wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFaceId" ) );
...@@ -172,7 +177,7 @@ KIFACE* KIWAY::KiFACE( FACE_T aFaceId, bool doLoad ) ...@@ -172,7 +177,7 @@ KIFACE* KIWAY::KiFACE( FACE_T aFaceId, bool doLoad )
// Give the DSO a single chance to do its "process level" initialization. // Give the DSO a single chance to do its "process level" initialization.
// "Process level" specifically means stay away from any projects in there. // "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. // Tell dso's wxDynamicLibrary destructor not to Unload() the program image.
(void) dso.Detach(); (void) dso.Detach();
...@@ -214,12 +219,14 @@ KIWAY::FACE_T KIWAY::KifaceType( FRAME_T aFrameType ) ...@@ -214,12 +219,14 @@ KIWAY::FACE_T KIWAY::KifaceType( FRAME_T aFrameType )
case FRAME_SCH: case FRAME_SCH:
case FRAME_SCH_LIB_EDITOR: case FRAME_SCH_LIB_EDITOR:
case FRAME_SCH_VIEWER: case FRAME_SCH_VIEWER:
case FRAME_SCH_VIEWER_MODAL:
return FACE_SCH; return FACE_SCH;
case FRAME_PCB: case FRAME_PCB:
case FRAME_PCB_MODULE_EDITOR: case FRAME_PCB_MODULE_EDITOR:
case FRAME_PCB_MODULE_VIEWER: 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: case FRAME_PCB_DISPLAY3D:
return FACE_PCB; return FACE_PCB;
...@@ -233,6 +240,12 @@ KIWAY::FACE_T KIWAY::KifaceType( FRAME_T aFrameType ) ...@@ -233,6 +240,12 @@ KIWAY::FACE_T KIWAY::KifaceType( FRAME_T aFrameType )
case FRAME_PL_EDITOR: case FRAME_PL_EDITOR:
return FACE_PL_EDITOR; return FACE_PL_EDITOR;
case FRAME_CALC:
return FACE_PCB_CALCULATOR;
case FRAME_BM2CMP:
return FACE_BMP2CMP;
default: default:
return FACE_T( -1 ); return FACE_T( -1 );
} }
...@@ -266,7 +279,12 @@ KIWAY_PLAYER* KIWAY::Player( FRAME_T aFrameType, bool doCreate ) ...@@ -266,7 +279,12 @@ KIWAY_PLAYER* KIWAY::Player( FRAME_T aFrameType, bool doCreate )
if( kiface ) 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 ); wxASSERT( frame );
return m_player[aFrameType] = frame; return m_player[aFrameType] = frame;
...@@ -327,6 +345,39 @@ void KIWAY::ExpressMail( FRAME_T aDestination, ...@@ -327,6 +345,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 ) bool KIWAY::ProcessEvent( wxEvent& aEvent )
{ {
KIWAY_EXPRESS* mail = dynamic_cast<KIWAY_EXPRESS*>( &aEvent ); KIWAY_EXPRESS* mail = dynamic_cast<KIWAY_EXPRESS*>( &aEvent );
...@@ -351,3 +402,14 @@ bool KIWAY::ProcessEvent( wxEvent& aEvent ) ...@@ -351,3 +402,14 @@ bool KIWAY::ProcessEvent( wxEvent& aEvent )
return false; return false;
} }
void KIWAY::OnKiwayEnd()
{
for( unsigned i=0; i < DIM( m_kiface ); ++i )
{
if( m_kiface[i] )
m_kiface[i]->OnKifaceEnd();
}
}
/*
* 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
*/
#include <kiway_player.h> #include <kiway_player.h>
#include <kiway_express.h> #include <kiway_express.h>
#include <kiway.h>
#include <id.h>
#include <macros.h>
#include <typeinfo> #include <typeinfo>
#include <wx/utils.h>
#include <wx/evtloop.h>
BEGIN_EVENT_TABLE( KIWAY_PLAYER, EDA_BASE_FRAME ) 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 ) EVT_KIWAY_EXPRESS( KIWAY_PLAYER::kiway_express )
Use Connect() in constructor until this can be sorted out. EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, KIWAY_PLAYER::language_change )
OK the problem is KIWAY_PLAYER::wxEVENT_ID not being unique accross all link images.
*/
END_EVENT_TABLE() END_EVENT_TABLE()
KIWAY_PLAYER::KIWAY_PLAYER( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType, KIWAY_PLAYER::KIWAY_PLAYER( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize, const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
long aStyle, const wxString& aWdoName ) : long aStyle, const wxString& aWdoName ) :
EDA_BASE_FRAME( aParent, aFrameType, aTitle, aPos, aSize, aStyle, aWdoName ), EDA_BASE_FRAME( aParent, aFrameType, aTitle, aPos, aSize, aStyle, aWdoName ),
KIWAY_HOLDER( aKiway ) KIWAY_HOLDER( aKiway ),
m_modal( false ),
m_modal_loop( 0 )
{ {
DBG( printf("KIWAY_EXPRESS::wxEVENT_ID:%d\n", KIWAY_EXPRESS::wxEVENT_ID );) // DBG( printf("KIWAY_EXPRESS::wxEVENT_ID:%d\n", KIWAY_EXPRESS::wxEVENT_ID );)
Connect( KIWAY_EXPRESS::wxEVENT_ID, wxKiwayExressHandler( KIWAY_PLAYER::kiway_express ) );
} }
...@@ -31,10 +55,96 @@ KIWAY_PLAYER::KIWAY_PLAYER( wxWindow* aParent, wxWindowID aId, const wxString& a ...@@ -31,10 +55,96 @@ KIWAY_PLAYER::KIWAY_PLAYER( wxWindow* aParent, wxWindowID aId, const wxString& a
const wxPoint& aPos, const wxSize& aSize, long aStyle, const wxPoint& aPos, const wxSize& aSize, long aStyle,
const wxString& aWdoName ) : const wxString& aWdoName ) :
EDA_BASE_FRAME( aParent, (FRAME_T) aId, aTitle, aPos, aSize, aStyle, aWdoName ), EDA_BASE_FRAME( aParent, (FRAME_T) aId, aTitle, aPos, aSize, aStyle, aWdoName ),
KIWAY_HOLDER( 0 ) KIWAY_HOLDER( 0 ),
m_modal( false ),
m_modal_loop( 0 )
{
// DBG( printf("KIWAY_EXPRESS::wxEVENT_ID:%d\n", KIWAY_EXPRESS::wxEVENT_ID );)
}
KIWAY_PLAYER::~KIWAY_PLAYER(){}
void KIWAY_PLAYER::KiwayMailIn( KIWAY_EXPRESS& aEvent )
{ {
DBG( printf("KIWAY_EXPRESS::wxEVENT_ID:%d\n", KIWAY_EXPRESS::wxEVENT_ID );) // override this in derived classes.
Connect( KIWAY_EXPRESS::wxEVENT_ID, wxKiwayExressHandler( KIWAY_PLAYER::kiway_express ) ); }
bool KIWAY_PLAYER::ShowModal( wxString* aResult )
{
wxASSERT_MSG( IsModal(), wxT( "ShowModal() shouldn't be called on non-modal frame" ) );
/*
This function has a nice interface but a necessarily unsightly implementation.
Now the implementation is encapsulated, localizing future changes.
It works in tandem with DismissModal(). But only ShowModal() is in the
vtable and therefore cross-module capable.
*/
// This is an exception safe way to zero a pointer before returning.
// Yes, even though DismissModal() clears this first normally, this is
// here in case there's an exception before the dialog is dismissed.
struct NULLER
{
void*& m_what;
NULLER( void*& aPtr ) : m_what( aPtr ) {}
~NULLER() { m_what = 0; } // indeed, set it to NULL on destruction
} clear_this( (void*&) m_modal_loop );
// exception safe way to disable all frames except the modal one,
// re-enables only those that were disabled on exit
wxWindowDisabler toggle( this );
Show( true );
WX_EVENT_LOOP event_loop;
#if wxCHECK_VERSION( 2, 9, 4 ) // 2.9.4 is only approximate.
// new code needs this, old code does it in wxEventLoop::Run() and cannot
// tolerate it here. Where that boundary is as a version number, I don't know.
// A closer look at the subversion repo for wx would tell.
wxEventLoopActivator event_loop_stacker( &event_loop );
#endif
m_modal_loop = &event_loop;
event_loop.Run();
if( aResult )
*aResult = m_modal_string;
DBG(printf( "~%s: aResult:'%s' ret:%d\n",
__func__, TO_UTF8( m_modal_string ), m_modal_ret_val );)
return m_modal_ret_val;
}
bool KIWAY_PLAYER::IsDismissed()
{
bool ret = !m_modal_loop;
DBG(printf( "%s: ret:%d\n", __func__, ret );)
return ret;
}
void KIWAY_PLAYER::DismissModal( bool aRetVal, const wxString& aResult )
{
m_modal_ret_val = aRetVal;
m_modal_string = aResult;
if( m_modal_loop )
{
m_modal_loop->Exit();
m_modal_loop = 0; // this marks it as dismissed.
}
Show( false );
} }
...@@ -42,17 +152,20 @@ void KIWAY_PLAYER::kiway_express( KIWAY_EXPRESS& aEvent ) ...@@ -42,17 +152,20 @@ void KIWAY_PLAYER::kiway_express( KIWAY_EXPRESS& aEvent )
{ {
// logging support // logging support
#if defined(DEBUG) #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, printf( "%s: received cmd:%d pay:'%s'\n", class_name,
aEvent.GetEventType(), aEvent.GetPayload().c_str() ); aEvent.Command(), aEvent.GetPayload().c_str() );
#endif #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 );
} }
...@@ -192,7 +192,7 @@ void WS_DRAW_ITEM_TEXT::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC ) ...@@ -192,7 +192,7 @@ void WS_DRAW_ITEM_TEXT::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC )
} }
// return true if the point aPosition is on the text // return true if the point aPosition is on the text
bool WS_DRAW_ITEM_TEXT::HitTest( const wxPoint& aPosition) bool WS_DRAW_ITEM_TEXT::HitTest( const wxPoint& aPosition) const
{ {
return EDA_TEXT::TextHitTest( aPosition, 0 ); return EDA_TEXT::TextHitTest( aPosition, 0 );
} }
...@@ -221,7 +221,7 @@ void WS_DRAW_ITEM_POLYGON::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC ) ...@@ -221,7 +221,7 @@ void WS_DRAW_ITEM_POLYGON::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC )
// return true if the point aPosition is inside one of polygons // return true if the point aPosition is inside one of polygons
#include <polygon_test_point_inside.h> #include <polygon_test_point_inside.h>
bool WS_DRAW_ITEM_POLYGON::HitTest( const wxPoint& aPosition) bool WS_DRAW_ITEM_POLYGON::HitTest( const wxPoint& aPosition) const
{ {
return TestPointInsidePolygon( &m_Corners[0], return TestPointInsidePolygon( &m_Corners[0],
m_Corners.size(), aPosition ); m_Corners.size(), aPosition );
...@@ -249,7 +249,7 @@ void WS_DRAW_ITEM_RECT::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC ) ...@@ -249,7 +249,7 @@ void WS_DRAW_ITEM_RECT::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC )
} }
// return true if the point aPosition is on the rect outline // return true if the point aPosition is on the rect outline
bool WS_DRAW_ITEM_RECT::HitTest( const wxPoint& aPosition) bool WS_DRAW_ITEM_RECT::HitTest( const wxPoint& aPosition) const
{ {
int dist = GetPenWidth()/2; int dist = GetPenWidth()/2;
wxPoint start = GetStart(); wxPoint start = GetStart();
...@@ -316,7 +316,7 @@ void WS_DRAW_ITEM_LINE::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC ) ...@@ -316,7 +316,7 @@ void WS_DRAW_ITEM_LINE::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC )
} }
// return true if the point aPosition is on the text // return true if the point aPosition is on the text
bool WS_DRAW_ITEM_LINE::HitTest( const wxPoint& aPosition) bool WS_DRAW_ITEM_LINE::HitTest( const wxPoint& aPosition) const
{ {
return TestSegmentHit( aPosition, GetStart(), GetEnd(), GetPenWidth()/2 ); return TestSegmentHit( aPosition, GetStart(), GetEnd(), GetPenWidth()/2 );
} }
...@@ -394,9 +394,9 @@ void WS_DRAW_ITEM_BITMAP::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC ) ...@@ -394,9 +394,9 @@ void WS_DRAW_ITEM_BITMAP::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC )
* Virtual function * Virtual function
* return true if the point aPosition is on bitmap * return true if the point aPosition is on bitmap
*/ */
bool WS_DRAW_ITEM_BITMAP::HitTest( const wxPoint& aPosition) bool WS_DRAW_ITEM_BITMAP::HitTest( const wxPoint& aPosition) const
{ {
WORKSHEET_DATAITEM_BITMAP* parent = (WORKSHEET_DATAITEM_BITMAP*)GetParent(); const WORKSHEET_DATAITEM_BITMAP* parent = static_cast<const WORKSHEET_DATAITEM_BITMAP*>( GetParent() );
if( parent->m_ImageBitmap == NULL ) if( parent->m_ImageBitmap == NULL )
return false; return false;
......
...@@ -622,7 +622,7 @@ bool PGM_BASE::SetLanguage( bool first_time ) ...@@ -622,7 +622,7 @@ bool PGM_BASE::SetLanguage( bool first_time )
void PGM_BASE::SetLanguageIdentifier( int menu_id ) 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 ) ); menu_id, DIM( s_Languages ) );
for( unsigned ii = 0; ii < DIM( s_Languages ); ii++ ) for( unsigned ii = 0; ii < DIM( s_Languages ); ii++ )
......
...@@ -60,9 +60,9 @@ void PROJECT::SetProjectFullName( const wxString& aFullPathAndName ) ...@@ -60,9 +60,9 @@ void PROJECT::SetProjectFullName( const wxString& aFullPathAndName )
wxASSERT( m_project_name.GetName() == NAMELESS_PROJECT || m_project_name.IsAbsolute() ); wxASSERT( m_project_name.GetName() == NAMELESS_PROJECT || m_project_name.IsAbsolute() );
#if 0 #if 0
wxASSERT( m_project_name.GetExt() == wxT( ".pro" ) ) wxASSERT( m_project_name.GetExt() == ProjectFileExtension )
#else #else
m_project_name.SetExt( wxT( ".pro" ) ); m_project_name.SetExt( ProjectFileExtension );
#endif #endif
// until multiple projects are in play, set an environment variable for the // until multiple projects are in play, set an environment variable for the
...@@ -269,19 +269,21 @@ wxConfigBase* PROJECT::configCreate( const SEARCH_STACK& aSList, const wxString& ...@@ -269,19 +269,21 @@ wxConfigBase* PROJECT::configCreate( const SEARCH_STACK& aSList, const wxString&
// No suitable pro file was found, either does not exist, or is too old. // No suitable pro file was found, either does not exist, or is too old.
// Use the template kicad.pro file. Find it by using caller's SEARCH_STACK. // Use the template kicad.pro file. Find it by using caller's SEARCH_STACK.
wxString templateFile = wxT( "kicad." ) + ProjectFileExtension;
wxString kicad_pro_template = aSList.FindValidPath( wxT( "kicad.pro" ) ); wxString kicad_pro_template = aSList.FindValidPath( templateFile );
if( !kicad_pro_template ) if( !kicad_pro_template )
{ {
wxLogDebug( wxT( "Template file <kicad.pro> not found using search paths." ) ); wxLogDebug( wxT( "Template file <%s> not found using search paths." ),
GetChars( templateFile ) );
wxFileName templ( wxStandardPaths::Get().GetDocumentsDir(), wxFileName templ( wxStandardPaths::Get().GetDocumentsDir(),
wxT( "kicad" ), ProjectFileExtension ); wxT( "kicad" ), ProjectFileExtension );
if( !templ.IsFileReadable() ) if( !templ.IsFileReadable() )
{ {
wxString msg = wxString::Format( _( "Unable to find kicad.pro template file." ) ); wxString msg = wxString::Format( _( "Unable to find %s template config file." ),
GetChars( templateFile ) );
DisplayError( NULL, msg ); DisplayError( NULL, msg );
...@@ -291,8 +293,12 @@ wxConfigBase* PROJECT::configCreate( const SEARCH_STACK& aSList, const wxString& ...@@ -291,8 +293,12 @@ wxConfigBase* PROJECT::configCreate( const SEARCH_STACK& aSList, const wxString&
kicad_pro_template = templ.GetFullPath(); kicad_pro_template = templ.GetFullPath();
} }
// copy the template to cur_pro_fn, and open it at that destination. // The project config file is not found (happens for new projects,
wxCopyFile( kicad_pro_template, cur_pro_fn ); // or if the schematic editor is run outside an existing project
// In this case the default template (kicad.pro) is used
cur_pro_fn = kicad_pro_template;
wxLogDebug( wxT( "Use template file '%s' as project file." ), GetChars( cur_pro_fn ) );
cfg = new wxFileConfig( wxEmptyString, wxEmptyString, cur_pro_fn, wxEmptyString ); cfg = new wxFileConfig( wxEmptyString, wxEmptyString, cur_pro_fn, wxEmptyString );
cfg->DontCreateOnDemand(); cfg->DontCreateOnDemand();
......
...@@ -121,7 +121,7 @@ static const wxString dso_full_path( const wxString& aAbsoluteArgv0 ) ...@@ -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, // Only a single KIWAY is supported in this single_top top level component,
// which is dedicated to loading only a single DSO. // 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: // implement a PGM_BASE and a wxApp side by side:
...@@ -225,82 +225,6 @@ struct APP_SINGLE_TOP : public wxApp ...@@ -225,82 +225,6 @@ struct APP_SINGLE_TOP : public wxApp
IMPLEMENT_APP( APP_SINGLE_TOP ); 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 ) bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp )
{ {
// first thing: set m_wx_app // first thing: set m_wx_app
...@@ -321,43 +245,26 @@ bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp ) ...@@ -321,43 +245,26 @@ bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp )
if( !initPgm() ) if( !initPgm() )
return false; 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. int kiface_version;
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;
}
// Get the KIFACE. // 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. // Trick the KIWAY into thinking it loaded a KIFACE, by recording the KIFACE
wxASSERT_MSG( kiface, wxT( "attempted DSO has a bug, failed to return a KIFACE*" ) ); // in the KIWAY. It needs to be there for KIWAY::OnKiwayEnd() anyways.
Kiway.set_kiface( KIWAY::KifaceType( TOP_FRAME ), kiface );
#endif
// Give the DSO a single chance to do its "process level" initialization. // Use KIWAY to create a top window, which registers its existence also.
// "Process level" specifically means stay away from any projects in there. // "TOP_FRAME" is a macro that is passed on compiler command line from CMake,
if( !kiface->OnKifaceStart( this, KFCTL_STANDALONE ) ) // and is one of the types in FRAME_T.
return false; KIWAY_PLAYER* frame = Kiway.Player( TOP_FRAME, true );
// Use KIFACE to create a top window that the KIFACE knows about. Kiway.SetTop( frame );
// 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 );
#endif
App().SetTopWindow( frame ); // wxApp gets a face. App().SetTopWindow( frame ); // wxApp gets a face.
...@@ -454,8 +361,7 @@ bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp ) ...@@ -454,8 +361,7 @@ bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp )
void PGM_SINGLE_TOP::OnPgmExit() void PGM_SINGLE_TOP::OnPgmExit()
{ {
if( kiface ) Kiway.OnKiwayEnd();
kiface->OnKifaceEnd();
saveCommonSettings(); saveCommonSettings();
......
...@@ -76,8 +76,6 @@ BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, EDA_BASE_FRAME ) ...@@ -76,8 +76,6 @@ BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, EDA_BASE_FRAME )
EVT_MENU( ID_CVPCB_LIB_TABLE_EDIT, CVPCB_MAINFRAME::OnEditFootprintLibraryTable ) 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 // Toolbar events
EVT_TOOL( ID_CVPCB_QUIT, CVPCB_MAINFRAME::OnQuit ) EVT_TOOL( ID_CVPCB_QUIT, CVPCB_MAINFRAME::OnQuit )
EVT_TOOL( ID_CVPCB_READ_INPUT_NETLIST, CVPCB_MAINFRAME::LoadNetList ) EVT_TOOL( ID_CVPCB_READ_INPUT_NETLIST, CVPCB_MAINFRAME::LoadNetList )
...@@ -558,12 +556,6 @@ void CVPCB_MAINFRAME::DisplayModule( wxCommandEvent& event ) ...@@ -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 ) void CVPCB_MAINFRAME::DisplayDocFile( wxCommandEvent& event )
{ {
GetAssociatedDocument( this, m_DocModulesFileName, &Kiface().KifaceSearch() ); GetAssociatedDocument( this, m_DocModulesFileName, &Kiface().KifaceSearch() );
......
...@@ -123,12 +123,6 @@ public: ...@@ -123,12 +123,6 @@ public:
void ChangeFocus( bool aMoveRight ); void ChangeFocus( bool aMoveRight );
/**
* Function SetLanguage
* is called on a language menu selection.
*/
void SetLanguage( wxCommandEvent& event );
void ToFirstNA( wxCommandEvent& event ); void ToFirstNA( wxCommandEvent& event );
void ToPreviousNA( wxCommandEvent& event ); void ToPreviousNA( wxCommandEvent& event );
......
...@@ -52,7 +52,7 @@ public: ...@@ -52,7 +52,7 @@ public:
int GetSelection(); int GetSelection();
void OnSize( wxSizeEvent& event ); void OnSize( wxSizeEvent& event );
virtual CVPCB_MAINFRAME* GetParent(); virtual CVPCB_MAINFRAME* GetParent() const;
}; };
......
...@@ -79,7 +79,7 @@ int ITEMS_LISTBOX_BASE::GetSelection() ...@@ -79,7 +79,7 @@ int ITEMS_LISTBOX_BASE::GetSelection()
} }
CVPCB_MAINFRAME* ITEMS_LISTBOX_BASE::GetParent() CVPCB_MAINFRAME* ITEMS_LISTBOX_BASE::GetParent() const
{ {
return (CVPCB_MAINFRAME*) wxListView::GetParent(); return (CVPCB_MAINFRAME*) wxListView::GetParent();
} }
...@@ -321,7 +321,7 @@ void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& ...@@ -321,7 +321,7 @@ void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
wxPoint move_offset; wxPoint move_offset;
block = &screen->m_BlockLocate; 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 ); wxASSERT( parent != NULL );
LIB_COMPONENT* component = parent->GetComponent(); LIB_COMPONENT* component = parent->GetComponent();
......
...@@ -654,14 +654,14 @@ public: ...@@ -654,14 +654,14 @@ public:
*/ */
void SetPartCount( int count ); void SetPartCount( int count );
int GetPartCount() { return m_unitCount; } int GetPartCount() const { return m_unitCount; }
/** /**
* Function IsMulti * Function IsMulti
* @return true if the component has multiple parts per package. * @return true if the component has multiple parts per package.
* When happens, the reference has a sub reference ti identify part * When happens, the reference has a sub reference ti identify part
*/ */
bool IsMulti() { return m_unitCount > 1; } bool IsMulti() const { return m_unitCount > 1; }
/** /**
* Function SubReference * Function SubReference
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <fctsys.h> #include <fctsys.h>
#include <pgm_base.h> #include <pgm_base.h>
#include <kiway.h>
#include <gr_basic.h> #include <gr_basic.h>
#include <class_drawpanel.h> #include <class_drawpanel.h>
#include <confirm.h> #include <confirm.h>
...@@ -147,10 +148,10 @@ void SCH_EDIT_FRAME::EditComponent( SCH_COMPONENT* aComponent ) ...@@ -147,10 +148,10 @@ void SCH_EDIT_FRAME::EditComponent( SCH_COMPONENT* aComponent )
// make sure the chipnameTextCtrl is wide enough to hold any unusually long chip names: // make sure the chipnameTextCtrl is wide enough to hold any unusually long chip names:
EnsureTextCtrlWidth( dlg->chipnameTextCtrl ); EnsureTextCtrlWidth( dlg->chipnameTextCtrl );
dlg->ShowModal(); dlg->ShowQuasiModal();
m_canvas->MoveCursorToCrossHair();
m_canvas->SetIgnoreMouseEvents( false ); m_canvas->SetIgnoreMouseEvents( false );
m_canvas->MoveCursorToCrossHair();
dlg->Destroy(); dlg->Destroy();
} }
...@@ -213,7 +214,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnListItemSelected( wxListEvent& event ...@@ -213,7 +214,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnListItemSelected( wxListEvent& event
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnCancelButtonClick( wxCommandEvent& event ) void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnCancelButtonClick( wxCommandEvent& event )
{ {
EndModal( 1 ); EndQuasiModal( 1 );
} }
...@@ -378,7 +379,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event ...@@ -378,7 +379,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event
m_Parent->GetScreen()->TestDanglingEnds(); m_Parent->GetScreen()->TestDanglingEnds();
m_Parent->GetCanvas()->Refresh( true ); m_Parent->GetCanvas()->Refresh( true );
EndModal( 0 ); EndQuasiModal( 0 );
} }
...@@ -435,8 +436,36 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::deleteFieldButtonHandler( wxCommandEven ...@@ -435,8 +436,36 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::deleteFieldButtonHandler( wxCommandEven
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::showButtonHandler( wxCommandEvent& event ) void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::showButtonHandler( wxCommandEvent& event )
{ {
#if 0
wxString datasheet_uri = fieldValueTextCtrl->GetValue(); wxString datasheet_uri = fieldValueTextCtrl->GetValue();
::wxLaunchDefaultBrowser( datasheet_uri ); ::wxLaunchDefaultBrowser( datasheet_uri );
#else
unsigned fieldNdx = getSelectedFieldNdx();
if( fieldNdx == DATASHEET )
{
wxString datasheet_uri = fieldValueTextCtrl->GetValue();
::wxLaunchDefaultBrowser( datasheet_uri );
}
else if( fieldNdx == FOOTPRINT )
{
// pick a footprint using the footprint picker.
wxString fpid;
KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_MODULE_VIEWER_MODAL, true );
if( frame->ShowModal( &fpid ) )
{
printf( "%s: %s\n", __func__, TO_UTF8( fpid ) );
fieldValueTextCtrl->SetValue( fpid );
}
frame->Destroy();
}
#endif
} }
...@@ -733,7 +762,16 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel() ...@@ -733,7 +762,16 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
fieldValueTextCtrl->SetValue( field.GetText() ); fieldValueTextCtrl->SetValue( field.GetText() );
m_show_datasheet_button->Enable( fieldNdx == DATASHEET ); m_show_datasheet_button->Enable( fieldNdx == DATASHEET || fieldNdx == FOOTPRINT );
if( fieldNdx == DATASHEET )
m_show_datasheet_button->SetLabel( _( "Show in Browser" ) );
else if( fieldNdx == FOOTPRINT )
m_show_datasheet_button->SetLabel( _( "Assign Footprint" ) );
else
m_show_datasheet_button->SetLabel( wxEmptyString );
m_show_datasheet_button->Enable( fieldNdx == DATASHEET || fieldNdx == FOOTPRINT );
// For power symbols, the value is NOR editable, because value and pin // For power symbols, the value is NOR editable, because value and pin
// name must be same and can be edited only in library editor // name must be same and can be edited only in library editor
...@@ -975,5 +1013,5 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event ) ...@@ -975,5 +1013,5 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
m_Parent->OnModify(); m_Parent->OnModify();
m_Cmp->Draw( m_Parent->GetCanvas(), &dc, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); m_Cmp->Draw( m_Parent->GetCanvas(), &dc, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
EndModal( 1 ); EndQuasiModal( 1 );
} }
...@@ -36,11 +36,11 @@ ...@@ -36,11 +36,11 @@
#include <eda_dde.h> #include <eda_dde.h>
#include <wxEeschemaStruct.h> #include <wxEeschemaStruct.h>
#include <libeditframe.h> #include <libeditframe.h>
#include <viewlib_frame.h>
#include <eda_text.h> #include <eda_text.h>
#include <general.h> #include <general.h>
#include <class_libentry.h> #include <class_libentry.h>
//#include <sch_junction.h>
#include <hotkeys.h> #include <hotkeys.h>
#include <dialogs/dialog_color_config.h> #include <dialogs/dialog_color_config.h>
#include <transform.h> #include <transform.h>
...@@ -105,6 +105,15 @@ static struct IFACE : public KIFACE_I ...@@ -105,6 +105,15 @@ static struct IFACE : public KIFACE_I
} }
break; 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: default:
return NULL; return NULL;
} }
......
...@@ -118,7 +118,10 @@ EDA_COLOR_T GetInvisibleItemColor() ...@@ -118,7 +118,10 @@ EDA_COLOR_T GetInvisibleItemColor()
void LIB_EDIT_FRAME::InstallConfigFrame( wxCommandEvent& event ) 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,12 +137,14 @@ void LIB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) ...@@ -134,12 +137,14 @@ void LIB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
{ {
int id = event.GetId(); int id = event.GetId();
wxFileName fn; 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 ) switch( id )
{ {
case ID_CONFIG_SAVE: case ID_CONFIG_SAVE:
schFrame->SaveProjectSettings( false ); schFrame->SaveProjectSettings( true );
break; break;
case ID_CONFIG_READ: case ID_CONFIG_READ:
...@@ -205,7 +210,7 @@ void SCH_EDIT_FRAME::Process_Config( wxCommandEvent& event ) ...@@ -205,7 +210,7 @@ void SCH_EDIT_FRAME::Process_Config( wxCommandEvent& event )
switch( id ) switch( id )
{ {
case ID_CONFIG_SAVE: case ID_CONFIG_SAVE:
SaveProjectSettings( false ); SaveProjectSettings( true );
break; break;
case ID_CONFIG_READ: case ID_CONFIG_READ:
...@@ -454,8 +459,8 @@ void SCH_EDIT_FRAME::SaveProjectSettings( bool aAskForSave ) ...@@ -454,8 +459,8 @@ void SCH_EDIT_FRAME::SaveProjectSettings( bool aAskForSave )
if( aAskForSave ) if( aAskForSave )
{ {
wxFileDialog dlg( this, _( "Save Project File" ), wxFileDialog dlg( this, _( "Save Project File" ),
fn.GetPath(), fn.GetFullName(), fn.GetPath(), fn.GetFullPath(),
ProjectFileWildcard, wxFD_SAVE | wxFD_CHANGE_DIR ); ProjectFileWildcard, wxFD_SAVE );
if( dlg.ShowModal() == wxID_CANCEL ) if( dlg.ShowModal() == wxID_CANCEL )
return; return;
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <fctsys.h> #include <fctsys.h>
#include <pgm_base.h> #include <pgm_base.h>
#include <kiway.h>
#include <gr_basic.h> #include <gr_basic.h>
#include <class_drawpanel.h> #include <class_drawpanel.h>
#include <confirm.h> #include <confirm.h>
...@@ -55,18 +56,14 @@ ...@@ -55,18 +56,14 @@
wxString SCH_BASE_FRAME::SelectComponentFromLibBrowser( LIB_ALIAS* aPreselectedAlias, wxString SCH_BASE_FRAME::SelectComponentFromLibBrowser( LIB_ALIAS* aPreselectedAlias,
int* aUnit, int* aConvert ) int* aUnit, int* aConvert )
{ {
wxSemaphore semaphore( 0, 1 ); // Close any open non-modal Lib browser, and open a new one, in "modal" mode:
wxString cmpname; LIB_VIEW_FRAME* viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
// Close the current Lib browser, if open, and open a new one, in "modal" mode:
LIB_VIEW_FRAME* viewlibFrame = LIB_VIEW_FRAME::GetActiveLibraryViewer( this );
if( viewlibFrame ) if( viewlibFrame )
viewlibFrame->Destroy(); viewlibFrame->Destroy();
viewlibFrame = new LIB_VIEW_FRAME( &Kiway(), this, NULL, &semaphore, viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER_MODAL, true );
KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT );
if ( aPreselectedAlias ) if( aPreselectedAlias )
{ {
viewlibFrame->SetSelectedLibrary( aPreselectedAlias->GetLibraryName() ); viewlibFrame->SetSelectedLibrary( aPreselectedAlias->GetLibraryName() );
viewlibFrame->SetSelectedComponent( aPreselectedAlias->GetName() ); viewlibFrame->SetSelectedComponent( aPreselectedAlias->GetName() );
...@@ -80,27 +77,23 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibBrowser( LIB_ALIAS* aPreselectedA ...@@ -80,27 +77,23 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibBrowser( LIB_ALIAS* aPreselectedA
viewlibFrame->Refresh(); viewlibFrame->Refresh();
// Show the library viewer frame until it is closed wxString cmpname;
// Wait for viewer closing event:
while( semaphore.TryWait() == wxSEMA_BUSY )
{
wxYield();
wxMilliSleep( 50 );
}
cmpname = viewlibFrame->GetSelectedComponent();
if( viewlibFrame->ShowModal( &cmpname ) )
{
if( aUnit ) if( aUnit )
*aUnit = viewlibFrame->GetUnit(); *aUnit = viewlibFrame->GetUnit();
if( aConvert ) if( aConvert )
*aConvert = viewlibFrame->GetConvert(); *aConvert = viewlibFrame->GetConvert();
}
viewlibFrame->Destroy(); viewlibFrame->Destroy();
return cmpname; return cmpname;
} }
wxString SCH_BASE_FRAME::SelectComponentFromLibrary( const wxString& aLibname, wxString SCH_BASE_FRAME::SelectComponentFromLibrary( const wxString& aLibname,
wxArrayString& aHistoryList, wxArrayString& aHistoryList,
int& aHistoryLastUnit, int& aHistoryLastUnit,
......
...@@ -171,7 +171,7 @@ bool LIB_ARC::Load( LINE_READER& aLineReader, wxString& aErrorMsg ) ...@@ -171,7 +171,7 @@ bool LIB_ARC::Load( LINE_READER& aLineReader, wxString& aErrorMsg )
} }
bool LIB_ARC::HitTest( const wxPoint& aRefPoint ) bool LIB_ARC::HitTest( const wxPoint& aRefPoint ) const
{ {
int mindist = GetPenSize() / 2; int mindist = GetPenSize() / 2;
...@@ -183,7 +183,7 @@ bool LIB_ARC::HitTest( const wxPoint& aRefPoint ) ...@@ -183,7 +183,7 @@ bool LIB_ARC::HitTest( const wxPoint& aRefPoint )
} }
bool LIB_ARC::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform ) bool LIB_ARC::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const
{ {
if( aThreshold < 0 ) if( aThreshold < 0 )
......
...@@ -100,9 +100,9 @@ public: ...@@ -100,9 +100,9 @@ public:
bool Load( LINE_READER& aLineReader, wxString& aErrorMsg ); bool Load( LINE_READER& aLineReader, wxString& aErrorMsg );
bool HitTest( const wxPoint& aPosition ); bool HitTest( const wxPoint& aPosition ) const;
bool HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform ); bool HitTest( const wxPoint& aPosition, int aThreshold, const TRANSFORM& aTransform ) const;
const EDA_RECT GetBoundingBox() const; // Virtual const EDA_RECT GetBoundingBox() const; // Virtual
......
...@@ -345,7 +345,7 @@ void LIB_BEZIER::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& ...@@ -345,7 +345,7 @@ void LIB_BEZIER::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
} }
bool LIB_BEZIER::HitTest( const wxPoint& aRefPos ) bool LIB_BEZIER::HitTest( const wxPoint& aRefPos ) const
{ {
int mindist = GetPenSize() / 2; int mindist = GetPenSize() / 2;
...@@ -357,7 +357,7 @@ bool LIB_BEZIER::HitTest( const wxPoint& aRefPos ) ...@@ -357,7 +357,7 @@ bool LIB_BEZIER::HitTest( const wxPoint& aRefPos )
} }
bool LIB_BEZIER::HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aTransform ) bool LIB_BEZIER::HitTest( const wxPoint &aPosRef, int aThreshold, const TRANSFORM& aTransform ) const
{ {
wxPoint ref, start, end; wxPoint ref, start, end;
......
...@@ -72,9 +72,9 @@ public: ...@@ -72,9 +72,9 @@ public:
*/ */
unsigned GetCornerCount() const { return m_PolyPoints.size(); } unsigned GetCornerCount() const { return m_PolyPoints.size(); }
bool HitTest( const wxPoint& aPosition ); bool HitTest( const wxPoint& aPosition ) const;
bool HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aTransform ); bool HitTest( const wxPoint& aPosRef, int aThreshold, const TRANSFORM& aTransform ) const;
const EDA_RECT GetBoundingBox() const; // Virtual const EDA_RECT GetBoundingBox() const; // Virtual
......
...@@ -87,7 +87,7 @@ bool LIB_CIRCLE::Load( LINE_READER& aLineReader, wxString& aErrorMsg ) ...@@ -87,7 +87,7 @@ bool LIB_CIRCLE::Load( LINE_READER& aLineReader, wxString& aErrorMsg )
} }
bool LIB_CIRCLE::HitTest( const wxPoint& aPosRef ) bool LIB_CIRCLE::HitTest( const wxPoint& aPosRef ) const
{ {
int mindist = GetPenSize() / 2; int mindist = GetPenSize() / 2;
...@@ -99,7 +99,7 @@ bool LIB_CIRCLE::HitTest( const wxPoint& aPosRef ) ...@@ -99,7 +99,7 @@ bool LIB_CIRCLE::HitTest( const wxPoint& aPosRef )
} }
bool LIB_CIRCLE::HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aTransform ) bool LIB_CIRCLE::HitTest( const wxPoint &aPosRef, int aThreshold, const TRANSFORM& aTransform ) const
{ {
if( aThreshold < 0 ) if( aThreshold < 0 )
aThreshold = GetPenSize() / 2; aThreshold = GetPenSize() / 2;
......
...@@ -61,9 +61,9 @@ public: ...@@ -61,9 +61,9 @@ public:
bool Load( LINE_READER& aLineReader, wxString& aErrorMsg ); bool Load( LINE_READER& aLineReader, wxString& aErrorMsg );
bool HitTest( const wxPoint& aPosition ); bool HitTest( const wxPoint& aPosition ) const;
bool HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aTransform ); bool HitTest( const wxPoint& aPosRef, int aThreshold, const TRANSFORM& aTransform ) const;
int GetPenSize( ) const; int GetPenSize( ) const;
......
...@@ -237,12 +237,12 @@ public: ...@@ -237,12 +237,12 @@ public:
virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ) = 0; virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ) = 0;
LIB_COMPONENT* GetParent() LIB_COMPONENT* GetParent() const
{ {
return (LIB_COMPONENT *)m_Parent; return (LIB_COMPONENT *)m_Parent;
} }
virtual bool HitTest( const wxPoint& aPosition ) virtual bool HitTest( const wxPoint& aPosition ) const
{ {
return EDA_ITEM::HitTest( aPosition ); return EDA_ITEM::HitTest( aPosition );
} }
...@@ -255,7 +255,7 @@ public: ...@@ -255,7 +255,7 @@ public:
* @param aTransform The transform matrix. * @param aTransform The transform matrix.
* @return True if the point \a aPosition is near this object * @return True if the point \a aPosition is near this object
*/ */
virtual bool HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform ) = 0; virtual bool HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const = 0;
/** /**
* @return the boundary box for this, in library coordinates * @return the boundary box for this, in library coordinates
......
...@@ -320,7 +320,7 @@ void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a ...@@ -320,7 +320,7 @@ void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a
} }
bool LIB_FIELD::HitTest( const wxPoint& aPosition ) bool LIB_FIELD::HitTest( const wxPoint& aPosition ) const
{ {
// Because HitTest is mainly used to select the field // Because HitTest is mainly used to select the field
// return always false if this field is void // return always false if this field is void
...@@ -331,49 +331,37 @@ bool LIB_FIELD::HitTest( const wxPoint& aPosition ) ...@@ -331,49 +331,37 @@ bool LIB_FIELD::HitTest( const wxPoint& aPosition )
} }
bool LIB_FIELD::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform ) bool LIB_FIELD::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const
{ {
if( aThreshold < 0 ) if( aThreshold < 0 )
aThreshold = 0; aThreshold = 0;
int extraCharCount = 0; // Build a temporary copy of the text for hit testing
EDA_TEXT tmp_text( *this );
// Reference designator text has one or 2 additional character (displays // Reference designator text has one or 2 additional character (displays
// U? or U?A) // U? or U?A)
if( m_id == REFERENCE ) if( m_id == REFERENCE )
{ {
extraCharCount++; wxString extended_text = tmp_text.GetText();
m_Text.Append('?'); extended_text.Append('?');
LIB_COMPONENT* parent = (LIB_COMPONENT*)m_Parent; const LIB_COMPONENT* parent = static_cast<const LIB_COMPONENT*>( m_Parent );
if ( parent && ( parent->GetPartCount() > 1 ) ) if ( parent && ( parent->GetPartCount() > 1 ) )
{ extended_text.Append('A');
m_Text.Append('A'); tmp_text.SetText( extended_text );
extraCharCount++;
}
} }
wxPoint physicalpos = aTransform.TransformCoordinate( m_Pos ); tmp_text.SetTextPosition( aTransform.TransformCoordinate( m_Pos ) );
wxPoint tmp = m_Pos;
m_Pos = physicalpos;
/* The text orientation may need to be flipped if the /* The text orientation may need to be flipped if the
* transformation matrix causes xy axes to be flipped. * transformation matrix causes xy axes to be flipped.
* this simple algo works only for schematic matrix (rot 90 or/and mirror) * this simple algo works only for schematic matrix (rot 90 or/and mirror)
*/ */
int t1 = ( aTransform.x1 != 0 ) ^ ( m_Orient != 0 ); int t1 = ( aTransform.x1 != 0 ) ^ ( m_Orient != 0 );
int orient = t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT; tmp_text.SetOrientation( t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT );
EXCHG( m_Orient, orient );
bool hit = TextHitTest( aPosition );
EXCHG( m_Orient, orient );
m_Pos = tmp;
while( extraCharCount-- )
m_Text.RemoveLast( );
return hit; return tmp_text.TextHitTest( aPosition );
} }
......
...@@ -151,7 +151,7 @@ public: ...@@ -151,7 +151,7 @@ public:
* Function IsVoid * Function IsVoid
* @return true if the field value is void (no text in this field) * @return true if the field value is void (no text in this field)
*/ */
bool IsVoid() bool IsVoid() const
{ {
return m_Text.IsEmpty(); return m_Text.IsEmpty();
} }
...@@ -169,9 +169,9 @@ public: ...@@ -169,9 +169,9 @@ public:
void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ); void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );
bool HitTest( const wxPoint& aPosition ); bool HitTest( const wxPoint& aPosition ) const;
bool HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform ); bool HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const;
void operator=( const LIB_FIELD& field ) void operator=( const LIB_FIELD& field )
{ {
......
...@@ -525,13 +525,13 @@ void LIB_PIN::EnableEditMode( bool enable, bool editPinByPin ) ...@@ -525,13 +525,13 @@ void LIB_PIN::EnableEditMode( bool enable, bool editPinByPin )
} }
bool LIB_PIN::HitTest( const wxPoint& aPosition ) bool LIB_PIN::HitTest( const wxPoint& aPosition ) const
{ {
return HitTest( aPosition, 0, DefaultTransform ); return HitTest( aPosition, 0, DefaultTransform );
} }
bool LIB_PIN::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform ) bool LIB_PIN::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const
{ {
if( aThreshold < 0 ) if( aThreshold < 0 )
aThreshold = 0; aThreshold = 0;
......
...@@ -131,9 +131,9 @@ public: ...@@ -131,9 +131,9 @@ public:
bool Load( LINE_READER& aLineReader, wxString& aErrorMsg ); bool Load( LINE_READER& aLineReader, wxString& aErrorMsg );
bool HitTest( const wxPoint& aPosition ); bool HitTest( const wxPoint& aPosition ) const;
bool HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aTransform ); bool HitTest( const wxPoint &aPosRef, int aThreshold, const TRANSFORM& aTransform ) const;
void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ); void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );
......
...@@ -321,7 +321,7 @@ void LIB_POLYLINE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint ...@@ -321,7 +321,7 @@ void LIB_POLYLINE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint
} }
bool LIB_POLYLINE::HitTest( const wxPoint& aPosition ) bool LIB_POLYLINE::HitTest( const wxPoint& aPosition ) const
{ {
int mindist = GetPenSize() / 2; int mindist = GetPenSize() / 2;
...@@ -333,7 +333,7 @@ bool LIB_POLYLINE::HitTest( const wxPoint& aPosition ) ...@@ -333,7 +333,7 @@ bool LIB_POLYLINE::HitTest( const wxPoint& aPosition )
} }
bool LIB_POLYLINE::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform ) bool LIB_POLYLINE::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const
{ {
wxPoint ref, start, end; wxPoint ref, start, end;
......
...@@ -74,9 +74,9 @@ public: ...@@ -74,9 +74,9 @@ public:
*/ */
unsigned GetCornerCount() const { return m_PolyPoints.size(); } unsigned GetCornerCount() const { return m_PolyPoints.size(); }
bool HitTest( const wxPoint& aPosition ); bool HitTest( const wxPoint& aPosition ) const;
bool HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform ); bool HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const;
const EDA_RECT GetBoundingBox() const; // Virtual const EDA_RECT GetBoundingBox() const; // Virtual
......
...@@ -267,7 +267,7 @@ const EDA_RECT LIB_RECTANGLE::GetBoundingBox() const ...@@ -267,7 +267,7 @@ const EDA_RECT LIB_RECTANGLE::GetBoundingBox() const
} }
bool LIB_RECTANGLE::HitTest( const wxPoint& aPosition ) bool LIB_RECTANGLE::HitTest( const wxPoint& aPosition ) const
{ {
int mindist = ( GetPenSize() / 2 ) + 1; int mindist = ( GetPenSize() / 2 ) + 1;
...@@ -279,7 +279,7 @@ bool LIB_RECTANGLE::HitTest( const wxPoint& aPosition ) ...@@ -279,7 +279,7 @@ bool LIB_RECTANGLE::HitTest( const wxPoint& aPosition )
} }
bool LIB_RECTANGLE::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform ) bool LIB_RECTANGLE::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const
{ {
if( aThreshold < 0 ) if( aThreshold < 0 )
aThreshold = GetPenSize() / 2; aThreshold = GetPenSize() / 2;
......
...@@ -65,9 +65,9 @@ public: ...@@ -65,9 +65,9 @@ public:
bool Load( LINE_READER& aLineReader, wxString& aErrorMsg ); bool Load( LINE_READER& aLineReader, wxString& aErrorMsg );
bool HitTest( const wxPoint& aPosition ); bool HitTest( const wxPoint& aPosition ) const;
bool HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aTransform ); bool HitTest( const wxPoint &aPosRef, int aThreshold, const TRANSFORM& aTransform ) const;
int GetPenSize( ) const; int GetPenSize( ) const;
......
...@@ -185,32 +185,27 @@ bool LIB_TEXT::Load( LINE_READER& aLineReader, wxString& errorMsg ) ...@@ -185,32 +185,27 @@ bool LIB_TEXT::Load( LINE_READER& aLineReader, wxString& errorMsg )
} }
bool LIB_TEXT::HitTest( const wxPoint& aPosition ) bool LIB_TEXT::HitTest( const wxPoint& aPosition ) const
{ {
return HitTest( aPosition, 0, DefaultTransform ); return HitTest( aPosition, 0, DefaultTransform );
} }
bool LIB_TEXT::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform ) bool LIB_TEXT::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const
{ {
if( aThreshold < 0 ) if( aThreshold < 0 )
aThreshold = 0; aThreshold = 0;
wxPoint physicalpos = aTransform.TransformCoordinate( m_Pos ); EDA_TEXT tmp_text( *this );
wxPoint tmp = m_Pos; tmp_text.SetTextPosition( aTransform.TransformCoordinate( m_Pos ) );
m_Pos = physicalpos;
/* The text orientation may need to be flipped if the /* The text orientation may need to be flipped if the
* transformation matrix causes xy axes to be flipped. * transformation matrix causes xy axes to be flipped.
* this simple algo works only for schematic matrix (rot 90 or/and mirror) * this simple algo works only for schematic matrix (rot 90 or/and mirror)
*/ */
int t1 = ( aTransform.x1 != 0 ) ^ ( m_Orient != 0 ); int t1 = ( aTransform.x1 != 0 ) ^ ( m_Orient != 0 );
int orient = t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT; tmp_text.SetOrientation( t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT );
EXCHG( m_Orient, orient ); return tmp_text.TextHitTest( aPosition );
bool hit = TextHitTest( aPosition );
EXCHG( m_Orient, orient );
m_Pos = tmp;
return hit;
} }
......
...@@ -82,11 +82,11 @@ public: ...@@ -82,11 +82,11 @@ public:
bool Load( LINE_READER& aLineReader, wxString& aErrorMsg ); bool Load( LINE_READER& aLineReader, wxString& aErrorMsg );
bool HitTest( const wxPoint& aPosition ); bool HitTest( const wxPoint& aPosition ) const;
bool HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform ); bool HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const;
bool HitTest( EDA_RECT& aRect ) bool HitTest( const EDA_RECT& aRect ) const
{ {
return TextHitTest( aRect ); return TextHitTest( aRect );
} }
......
...@@ -99,7 +99,7 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) ...@@ -99,7 +99,7 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_SIZE( LIB_EDIT_FRAME::OnSize ) EVT_SIZE( LIB_EDIT_FRAME::OnSize )
EVT_ACTIVATE( LIB_EDIT_FRAME::OnActivate ) 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_SAVE_CURRENT_LIB, LIB_EDIT_FRAME::OnSaveActiveLibrary )
EVT_TOOL( ID_LIBEDIT_SELECT_CURRENT_LIB, LIB_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_LIBEDIT_SELECT_CURRENT_LIB, LIB_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_LIBEDIT_DELETE_PART, LIB_EDIT_FRAME::DeleteOnePart ) EVT_TOOL( ID_LIBEDIT_DELETE_PART, LIB_EDIT_FRAME::DeleteOnePart )
...@@ -125,12 +125,12 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) ...@@ -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_PART_NUMBER, LIB_EDIT_FRAME::OnSelectPart )
EVT_COMBOBOX( ID_LIBEDIT_SELECT_ALIAS, LIB_EDIT_FRAME::OnSelectAlias ) 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( ID_NO_TOOL_SELECTED, LIB_EDIT_FRAME::OnSelectTool )
EVT_TOOL_RANGE( ID_LIBEDIT_PIN_BUTT, ID_LIBEDIT_DELETE_ITEM_BUTT, EVT_TOOL_RANGE( ID_LIBEDIT_PIN_BUTT, ID_LIBEDIT_DELETE_ITEM_BUTT,
LIB_EDIT_FRAME::OnSelectTool ) LIB_EDIT_FRAME::OnSelectTool )
/* menubar commands */ // menubar commands
EVT_MENU( wxID_EXIT, LIB_EDIT_FRAME::CloseWindow ) EVT_MENU( wxID_EXIT, LIB_EDIT_FRAME::CloseWindow )
EVT_MENU( ID_LIBEDIT_SAVE_CURRENT_LIB_AS, LIB_EDIT_FRAME::OnSaveActiveLibrary ) EVT_MENU( ID_LIBEDIT_SAVE_CURRENT_LIB_AS, LIB_EDIT_FRAME::OnSaveActiveLibrary )
EVT_MENU( ID_LIBEDIT_GEN_PNG_FILE, LIB_EDIT_FRAME::OnPlotCurrentComponent ) EVT_MENU( ID_LIBEDIT_GEN_PNG_FILE, LIB_EDIT_FRAME::OnPlotCurrentComponent )
...@@ -152,9 +152,7 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) ...@@ -152,9 +152,7 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_MENU_RANGE( ID_PREFERENCES_HOTKEY_START, ID_PREFERENCES_HOTKEY_END, EVT_MENU_RANGE( ID_PREFERENCES_HOTKEY_START, ID_PREFERENCES_HOTKEY_END,
LIB_EDIT_FRAME::Process_Config ) 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_EDIT_PIN, LIB_EDIT_FRAME::OnEditPin )
EVT_MENU( ID_LIBEDIT_ROTATE_ITEM, LIB_EDIT_FRAME::OnRotateItem ) EVT_MENU( ID_LIBEDIT_ROTATE_ITEM, LIB_EDIT_FRAME::OnRotateItem )
...@@ -165,7 +163,7 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) ...@@ -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, EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
LIB_EDIT_FRAME::Process_Special_Functions ) 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( ExportPartId, LIB_EDIT_FRAME::OnUpdateEditingPart )
EVT_UPDATE_UI( CreateNewLibAndSavePartId, LIB_EDIT_FRAME::OnUpdateEditingPart ) EVT_UPDATE_UI( CreateNewLibAndSavePartId, LIB_EDIT_FRAME::OnUpdateEditingPart )
EVT_UPDATE_UI( ID_LIBEDIT_SAVE_CURRENT_PART, 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 ) : ...@@ -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" ), SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH_LIB_EDITOR, _( "Library Editor" ),
wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, GetLibEditFrameName() ) 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_FrameName = GetLibEditFrameName();
m_showAxis = true; // true to draw axis m_showAxis = true; // true to draw axis
...@@ -204,6 +202,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, SCH_EDIT_FRAME* aParent ) : ...@@ -204,6 +202,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, SCH_EDIT_FRAME* aParent ) :
m_tempCopyComponent = NULL; m_tempCopyComponent = NULL;
m_HotkeysZoomAndGridList = s_Libedit_Hokeys_Descr; m_HotkeysZoomAndGridList = s_Libedit_Hokeys_Descr;
m_editPinsPerPartOrConvert = false; m_editPinsPerPartOrConvert = false;
// Initialize grid id to the default value 50 mils: // Initialize grid id to the default value 50 mils:
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000; m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000;
...@@ -293,12 +292,6 @@ const wxChar* LIB_EDIT_FRAME::GetLibEditFrameName() ...@@ -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 ) void LIB_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
{ {
#if 0 // original #if 0 // original
...@@ -389,7 +382,7 @@ void LIB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event ) ...@@ -389,7 +382,7 @@ void LIB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
double LIB_EDIT_FRAME::BestZoom() double LIB_EDIT_FRAME::BestZoom()
{ {
/* Please, note: wxMSW before version 2.9 seems have /* Please, note: wxMSW before version 2.9 seems have
* problems with zoom values < 1 ( i.e. userscale > 1) and needs to be patched: * problems with zoom values < 1 ( i.e. userscale > 1) and needs to be patched:
* edit file <wxWidgets>/src/msw/dc.cpp * edit file <wxWidgets>/src/msw/dc.cpp
* search for line static const int VIEWPORT_EXTENT = 1000; * search for line static const int VIEWPORT_EXTENT = 1000;
...@@ -765,8 +758,8 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -765,8 +758,8 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
DefaultTransform ); DefaultTransform );
m_drawItem->SetFlags( oldFlags ); m_drawItem->SetFlags( oldFlags );
m_lastDrawItem = NULL; m_lastDrawItem = NULL;
break;
} }
break;
case ID_POPUP_LIBEDIT_DELETE_ITEM: case ID_POPUP_LIBEDIT_DELETE_ITEM:
if( m_drawItem ) if( m_drawItem )
...@@ -918,17 +911,6 @@ void LIB_EDIT_FRAME::EnsureActiveLibExists() ...@@ -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() void LIB_EDIT_FRAME::TempCopyComponent()
{ {
if( m_tempCopyComponent ) if( m_tempCopyComponent )
......
...@@ -133,13 +133,6 @@ public: ...@@ -133,13 +133,6 @@ public:
*/ */
static const wxChar* GetLibEditFrameName(); 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(); void ReCreateMenuBar();
/** /**
...@@ -149,12 +142,6 @@ public: ...@@ -149,12 +142,6 @@ public:
*/ */
static void EnsureActiveLibExists(); static void EnsureActiveLibExists();
/**
* Function SetLanguage
* is called on a language menu selection
*/
void SetLanguage( wxCommandEvent& event );
void InstallConfigFrame( wxCommandEvent& event ); void InstallConfigFrame( wxCommandEvent& event );
void InstallDimensionsDialog( wxCommandEvent& event ); void InstallDimensionsDialog( wxCommandEvent& event );
void OnColorConfig( wxCommandEvent& aEvent ); void OnColorConfig( wxCommandEvent& aEvent );
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <viewlib_frame.h> #include <viewlib_frame.h>
#include <libeditframe.h> #include <libeditframe.h>
#include <base_units.h> #include <base_units.h>
#include <kiway.h>
SCH_BASE_FRAME::SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, SCH_BASE_FRAME::SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent,
...@@ -40,12 +41,10 @@ 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 ) 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 ); viewlibFrame->Show( true );
else viewlibFrame->Raise();
new LIB_VIEW_FRAME( &Kiway(), this );
} }
......
...@@ -210,7 +210,7 @@ public: ...@@ -210,7 +210,7 @@ public:
wxString GetSheetPath() const { return m_sheetPath; } wxString GetSheetPath() const { return m_sheetPath; }
SCH_ITEM* GetParent() { return m_parent; } SCH_ITEM* GetParent() const { return m_parent; }
}; };
......
...@@ -664,7 +664,7 @@ static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) ...@@ -664,7 +664,7 @@ static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
{ {
SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen(); SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
SCH_ITEM* item = screen->GetCurItem(); 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 ); parent->SetRepeatItem( NULL );
screen->SetCurItem( NULL ); screen->SetCurItem( NULL );
......
...@@ -96,8 +96,6 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME ) ...@@ -96,8 +96,6 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_MENU( ID_COLORS_SETUP, SCH_EDIT_FRAME::OnColorConfig ) EVT_MENU( ID_COLORS_SETUP, SCH_EDIT_FRAME::OnColorConfig )
EVT_TOOL( wxID_PREFERENCES, SCH_EDIT_FRAME::OnSetOptions ) 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_TO_LIBRARY, SCH_EDIT_FRAME::OnOpenLibraryEditor )
EVT_TOOL( ID_POPUP_SCH_CALL_LIBEDIT_AND_LOAD_CMP, 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 ) EVT_TOOL( ID_TO_LIBVIEW, SCH_EDIT_FRAME::OnOpenLibraryViewer )
...@@ -442,14 +440,21 @@ void SCH_EDIT_FRAME::SaveUndoItemInUndoList( SCH_ITEM* aItem ) ...@@ -442,14 +440,21 @@ void SCH_EDIT_FRAME::SaveUndoItemInUndoList( SCH_ITEM* aItem )
void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent ) void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
{ {
LIB_EDIT_FRAME * libeditFrame = LIB_EDIT_FRAME::GetActiveLibraryEditor();; 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? if( libeditFrame && !libeditFrame->Close() ) // Can close component editor?
return; return;
LIB_VIEW_FRAME* viewlibFrame = LIB_VIEW_FRAME::GetActiveLibraryViewer( this ); LIB_VIEW_FRAME* viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
if( viewlibFrame && !viewlibFrame->Close() ) // Can close component viewer? if( viewlibFrame && !viewlibFrame->Close() ) // Can close component viewer?
return; 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; SCH_SHEET_LIST SheetList;
if( SheetList.IsModified() ) if( SheetList.IsModified() )
...@@ -829,7 +834,7 @@ void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event ) ...@@ -829,7 +834,7 @@ void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
{ {
SCH_ITEM* item = GetScreen()->GetCurItem(); 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" ) ); wxMessageBox( _( "Error: not a component or no component" ) );
return; return;
...@@ -838,9 +843,21 @@ void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event ) ...@@ -838,9 +843,21 @@ void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
component = (SCH_COMPONENT*) item; 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 );
}
libeditFrame->Raise();
LIB_EDIT_FRAME* libeditFrame = LIB_EDIT_FRAME::GetActiveLibraryEditor();; #if 0
if( libeditFrame ) if( libeditFrame )
{ {
if( libeditFrame->IsIconized() ) if( libeditFrame->IsIconized() )
...@@ -855,6 +872,8 @@ void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event ) ...@@ -855,6 +872,8 @@ void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
wxWindow* w = kf.CreateWindow( this, FRAME_SCH_LIB_EDITOR, &Kiway(), kf.StartFlags() ); wxWindow* w = kf.CreateWindow( this, FRAME_SCH_LIB_EDITOR, &Kiway(), kf.StartFlags() );
libeditFrame = dynamic_cast<LIB_EDIT_FRAME*>( w ); libeditFrame = dynamic_cast<LIB_EDIT_FRAME*>( w );
} }
#endif
if( component ) if( component )
{ {
...@@ -875,16 +894,6 @@ void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event ) ...@@ -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 ) void SCH_EDIT_FRAME::OnPrint( wxCommandEvent& event )
{ {
wxFileName fn; wxFileName fn;
......
...@@ -283,7 +283,7 @@ static void ExitSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) ...@@ -283,7 +283,7 @@ static void ExitSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen(); SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
SCH_ITEM* item = screen->GetCurItem(); 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) ) if( (item == NULL) || (item->Type() != SCH_SHEET_T) || (parent == NULL) )
return; return;
......
...@@ -116,9 +116,8 @@ void LIB_VIEW_FRAME::ReCreateHToolbar() ...@@ -116,9 +116,8 @@ void LIB_VIEW_FRAME::ReCreateHToolbar()
_( "View component documents" ) ); _( "View component documents" ) );
m_mainToolBar->EnableTool( ID_LIBVIEW_VIEWDOC, false ); m_mainToolBar->EnableTool( ID_LIBVIEW_VIEWDOC, false );
if( m_semaphore ) if( IsModal() )
{ {
// The library browser is called from a "load component" command
m_mainToolBar->AddSeparator(); m_mainToolBar->AddSeparator();
m_mainToolBar->AddTool( ID_LIBVIEW_CMP_EXPORT_TO_SCHEMATIC, m_mainToolBar->AddTool( ID_LIBVIEW_CMP_EXPORT_TO_SCHEMATIC,
wxEmptyString, KiBitmap( export_xpm ), wxEmptyString, KiBitmap( export_xpm ),
...@@ -130,11 +129,11 @@ void LIB_VIEW_FRAME::ReCreateHToolbar() ...@@ -130,11 +129,11 @@ void LIB_VIEW_FRAME::ReCreateHToolbar()
m_mainToolBar->Realize(); m_mainToolBar->Realize();
} }
if( (m_libraryName != wxEmptyString) && (m_entryName != wxEmptyString) ) if( m_libraryName.size() && m_entryName.size() )
{ {
lib = CMP_LIBRARY::FindLibrary( m_libraryName ); lib = CMP_LIBRARY::FindLibrary( m_libraryName );
if( lib != NULL ) if( lib )
{ {
component = lib->FindComponent( m_entryName ); component = lib->FindComponent( m_entryName );
...@@ -161,7 +160,6 @@ void LIB_VIEW_FRAME::ReCreateHToolbar() ...@@ -161,7 +160,6 @@ void LIB_VIEW_FRAME::ReCreateHToolbar()
m_mainToolBar->ToggleTool( ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, false ); m_mainToolBar->ToggleTool( ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, false );
} }
int parts_count = 1; int parts_count = 1;
if( component ) if( component )
...@@ -171,8 +169,7 @@ void LIB_VIEW_FRAME::ReCreateHToolbar() ...@@ -171,8 +169,7 @@ void LIB_VIEW_FRAME::ReCreateHToolbar()
for( ii = 0; ii < parts_count; ii++ ) for( ii = 0; ii < parts_count; ii++ )
{ {
wxString msg; wxString msg = wxString::Format( _( "Unit %c" ), 'A' + ii );
msg.Printf( _( "Unit %c" ), 'A' + ii );
m_selpartBox->Append( msg ); m_selpartBox->Append( msg );
} }
......
...@@ -47,28 +47,25 @@ ...@@ -47,28 +47,25 @@
*/ */
wxString LIB_VIEW_FRAME::m_libraryName; wxString LIB_VIEW_FRAME::m_libraryName;
wxString LIB_VIEW_FRAME::m_entryName; wxString LIB_VIEW_FRAME::m_entryName;
int LIB_VIEW_FRAME::m_unit = 1; int LIB_VIEW_FRAME::m_unit = 1;
int LIB_VIEW_FRAME::m_convert = 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 ) BEGIN_EVENT_TABLE( LIB_VIEW_FRAME, EDA_DRAW_FRAME )
/* Window events */ // Window events
EVT_CLOSE( LIB_VIEW_FRAME::OnCloseWindow ) EVT_CLOSE( LIB_VIEW_FRAME::OnCloseWindow )
EVT_SIZE( LIB_VIEW_FRAME::OnSize ) EVT_SIZE( LIB_VIEW_FRAME::OnSize )
EVT_ACTIVATE( LIB_VIEW_FRAME::OnActivate ) EVT_ACTIVATE( LIB_VIEW_FRAME::OnActivate )
/* Toolbar events */ // Toolbar events
EVT_TOOL_RANGE( ID_LIBVIEW_NEXT, ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, EVT_TOOL_RANGE( ID_LIBVIEW_NEXT, ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT,
LIB_VIEW_FRAME::Process_Special_Functions ) LIB_VIEW_FRAME::Process_Special_Functions )
EVT_TOOL( ID_LIBVIEW_CMP_EXPORT_TO_SCHEMATIC, LIB_VIEW_FRAME::ExportToSchematicLibraryPart ) 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 ) 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_LIB_LIST, LIB_VIEW_FRAME::ClickOnLibList )
EVT_LISTBOX( ID_LIBVIEW_CMP_LIST, LIB_VIEW_FRAME::ClickOnCmpList ) EVT_LISTBOX( ID_LIBVIEW_CMP_LIST, LIB_VIEW_FRAME::ClickOnCmpList )
EVT_LISTBOX_DCLICK( ID_LIBVIEW_CMP_LIST, LIB_VIEW_FRAME::DClickOnCmpList ) EVT_LISTBOX_DCLICK( ID_LIBVIEW_CMP_LIST, LIB_VIEW_FRAME::DClickOnCmpList )
...@@ -95,11 +92,20 @@ static wxAcceleratorEntry accels[] = ...@@ -95,11 +92,20 @@ static wxAcceleratorEntry accels[] =
#define ACCEL_TABLE_CNT ( sizeof( accels ) / sizeof( wxAcceleratorEntry ) ) #define ACCEL_TABLE_CNT ( sizeof( accels ) / sizeof( wxAcceleratorEntry ) )
#define LIB_VIEW_FRAME_NAME wxT( "ViewlibFrame" ) #define LIB_VIEW_FRAME_NAME wxT( "ViewlibFrame" )
LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, SCH_BASE_FRAME* aParent, LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
CMP_LIBRARY* aLibrary, wxSemaphore* aSemaphore, long aStyle ) : CMP_LIBRARY* aLibrary ) :
SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH_VIEWER, _( "Library Browser" ), SCH_BASE_FRAME( aKiway, aParent, aFrameType, _( "Library Browser" ),
wxDefaultPosition, wxDefaultSize, aStyle, GetLibViewerFrameName() ) 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 );
if( aFrameType == FRAME_SCH_VIEWER_MODAL )
SetModal( true );
wxAcceleratorTable table( ACCEL_TABLE_CNT, accels ); wxAcceleratorTable table( ACCEL_TABLE_CNT, accels );
m_FrameName = GetLibViewerFrameName(); m_FrameName = GetLibViewerFrameName();
...@@ -114,12 +120,6 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, SCH_BASE_FRAME* aParent, ...@@ -114,12 +120,6 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, SCH_BASE_FRAME* aParent,
m_HotkeysZoomAndGridList = s_Viewlib_Hokeys_Descr; m_HotkeysZoomAndGridList = s_Viewlib_Hokeys_Descr;
m_cmpList = NULL; m_cmpList = NULL;
m_libList = NULL; m_libList = NULL;
m_semaphore = aSemaphore;
if( m_semaphore )
SetModalMode( true );
m_exportToEeschemaCmpName.Empty();
SetScreen( new SCH_SCREEN() ); SetScreen( new SCH_SCREEN() );
GetScreen()->m_Center = true; // Axis origin centered on screen. GetScreen()->m_Center = true; // Axis origin centered on screen.
...@@ -139,7 +139,7 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, SCH_BASE_FRAME* aParent, ...@@ -139,7 +139,7 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, SCH_BASE_FRAME* aParent,
wxPoint win_pos( 0, 0 ); wxPoint win_pos( 0, 0 );
if( aLibrary == NULL ) if( !aLibrary )
{ {
// Creates the libraries window display // Creates the libraries window display
m_libList = new wxListBox( this, ID_LIBVIEW_LIB_LIST, m_libList = new wxListBox( this, ID_LIBVIEW_LIB_LIST,
...@@ -243,24 +243,18 @@ const wxChar* LIB_VIEW_FRAME::GetLibViewerFrameName() ...@@ -243,24 +243,18 @@ 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 ) void LIB_VIEW_FRAME::OnCloseWindow( wxCloseEvent& Event )
{ {
if( m_semaphore ) if( !IsModal() )
{ {
m_semaphore->Post(); Destroy();
// This window will be destroyed by the calling function,
// if needed
SetModalMode( false );
} }
else else if( !IsDismissed() )
{ {
Destroy(); // only dismiss modal frame if not already dismissed.
DismissModal( false );
// Modal frame will be destroyed by the calling function.
} }
} }
...@@ -283,12 +277,13 @@ void LIB_VIEW_FRAME::OnSetRelativeOffset( wxCommandEvent& event ) ...@@ -283,12 +277,13 @@ void LIB_VIEW_FRAME::OnSetRelativeOffset( wxCommandEvent& event )
double LIB_VIEW_FRAME::BestZoom() double LIB_VIEW_FRAME::BestZoom()
{ {
/* Please, note: wxMSW before version 2.9 seems have /* Please, note: wxMSW before version 2.9 seems have
* problems with zoom values < 1 ( i.e. userscale > 1) and needs to be patched: * problems with zoom values < 1 ( i.e. userscale > 1) and needs to be patched:
* edit file <wxWidgets>/src/msw/dc.cpp * edit file <wxWidgets>/src/msw/dc.cpp
* search for line static const int VIEWPORT_EXTENT = 1000; * search for line static const int VIEWPORT_EXTENT = 1000;
* and replace by static const int VIEWPORT_EXTENT = 10000; * and replace by static const int VIEWPORT_EXTENT = 10000;
*/ */
LIB_COMPONENT* component = NULL; LIB_COMPONENT* component = NULL;
double bestzoom = 16.0; // default value for bestzoom double bestzoom = 16.0; // default value for bestzoom
CMP_LIBRARY* lib = CMP_LIBRARY::FindLibrary( m_libraryName ); CMP_LIBRARY* lib = CMP_LIBRARY::FindLibrary( m_libraryName );
...@@ -344,8 +339,8 @@ void LIB_VIEW_FRAME::ReCreateListLib() ...@@ -344,8 +339,8 @@ void LIB_VIEW_FRAME::ReCreateListLib()
} }
else else
{ {
/* If not found, clear current library selection because it can be // If not found, clear current library selection because it can be
* deleted after a config change. */ // deleted after a config change.
m_libraryName = wxEmptyString; m_libraryName = wxEmptyString;
m_entryName = wxEmptyString; m_entryName = wxEmptyString;
m_unit = 1; m_unit = 1;
...@@ -417,6 +412,7 @@ void LIB_VIEW_FRAME::SetSelectedLibrary( const wxString& aLibraryName ) ...@@ -417,6 +412,7 @@ void LIB_VIEW_FRAME::SetSelectedLibrary( const wxString& aLibraryName )
m_canvas->Refresh(); m_canvas->Refresh();
DisplayLibInfos(); DisplayLibInfos();
ReCreateHToolbar(); ReCreateHToolbar();
// Ensure the corresponding line in m_libList is selected // Ensure the corresponding line in m_libList is selected
// (which is not necessary the case if SetSelectedLibrary is called // (which is not necessary the case if SetSelectedLibrary is called
// by an other caller than ClickOnLibList. // by an other caller than ClickOnLibList.
...@@ -440,9 +436,10 @@ void LIB_VIEW_FRAME::SetSelectedComponent( const wxString& aComponentName ) ...@@ -440,9 +436,10 @@ void LIB_VIEW_FRAME::SetSelectedComponent( const wxString& aComponentName )
if( m_entryName.CmpNoCase( aComponentName ) != 0 ) if( m_entryName.CmpNoCase( aComponentName ) != 0 )
{ {
m_entryName = aComponentName; m_entryName = aComponentName;
// Ensure the corresponding line in m_cmpList is selected // Ensure the corresponding line in m_cmpList is selected
// (which is not necessary the case if SetSelectedComponent is called // (which is not necessarily the case if SetSelectedComponent is called
// by an other caller than ClickOnCmpList. // by another caller than ClickOnCmpList.
m_cmpList->SetStringSelection( aComponentName, true ); m_cmpList->SetStringSelection( aComponentName, true );
DisplayLibInfos(); DisplayLibInfos();
m_unit = 1; m_unit = 1;
...@@ -456,14 +453,21 @@ void LIB_VIEW_FRAME::SetSelectedComponent( const wxString& aComponentName ) ...@@ -456,14 +453,21 @@ void LIB_VIEW_FRAME::SetSelectedComponent( const wxString& aComponentName )
void LIB_VIEW_FRAME::DClickOnCmpList( wxCommandEvent& event ) void LIB_VIEW_FRAME::DClickOnCmpList( wxCommandEvent& event )
{ {
if( m_semaphore ) if( IsModal() )
{ {
ExportToSchematicLibraryPart( event ); ExportToSchematicLibraryPart( event );
// 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 // 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 // window which would cause the part to be parked rather than staying
// in drag mode. // in drag mode.
((SCH_BASE_FRAME*) GetParent())->SkipNextLeftButtonReleaseEvent(); schframe->SkipNextLeftButtonReleaseEvent();
}
} }
} }
...@@ -473,9 +477,17 @@ void LIB_VIEW_FRAME::ExportToSchematicLibraryPart( wxCommandEvent& event ) ...@@ -473,9 +477,17 @@ void LIB_VIEW_FRAME::ExportToSchematicLibraryPart( wxCommandEvent& event )
int ii = m_cmpList->GetSelection(); int ii = m_cmpList->GetSelection();
if( ii >= 0 ) 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 else
m_exportToEeschemaCmpName.Empty(); {
// no selection was made, pass false
DismissModal( false );
}
Close( true ); Close( true );
} }
...@@ -524,10 +536,6 @@ void LIB_VIEW_FRAME::OnActivate( wxActivateEvent& event ) ...@@ -524,10 +536,6 @@ void LIB_VIEW_FRAME::OnActivate( wxActivateEvent& event )
{ {
EDA_DRAW_FRAME::OnActivate( event ); EDA_DRAW_FRAME::OnActivate( event );
// Ensure we do not have old selection:
if( m_FrameIsActive )
m_exportToEeschemaCmpName.Empty();
if( m_libList ) if( m_libList )
ReCreateListLib(); ReCreateListLib();
......
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
class wxSashLayoutWindow; class wxSashLayoutWindow;
class wxListBox; class wxListBox;
class wxSemaphore;
class CMP_LIBRARY; class CMP_LIBRARY;
...@@ -48,9 +47,14 @@ class CMP_LIBRARY; ...@@ -48,9 +47,14 @@ class CMP_LIBRARY;
class LIB_VIEW_FRAME : public SCH_BASE_FRAME class LIB_VIEW_FRAME : public SCH_BASE_FRAME
{ {
public: 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(); ~LIB_VIEW_FRAME();
...@@ -61,13 +65,6 @@ public: ...@@ -61,13 +65,6 @@ public:
*/ */
static const wxChar* GetLibViewerFrameName(); 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 ); void OnSize( wxSizeEvent& event );
/** /**
...@@ -109,7 +106,6 @@ public: ...@@ -109,7 +106,6 @@ public:
* @param the alias name of the component to be selected. * @param the alias name of the component to be selected.
*/ */
void SetSelectedComponent( const wxString& aComponentName ); void SetSelectedComponent( const wxString& aComponentName );
const wxString& GetSelectedComponent( void ) const { return m_exportToEeschemaCmpName; }
void SetUnit( int aUnit ) { m_unit = aUnit; } void SetUnit( int aUnit ) { m_unit = aUnit; }
int GetUnit( void ) { return m_unit; } int GetUnit( void ) { return m_unit; }
...@@ -147,8 +143,6 @@ private: ...@@ -147,8 +143,6 @@ private:
wxListBox* m_cmpList; // The list of components wxListBox* m_cmpList; // The list of components
int m_cmpListWidth; // Last width of the window 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 wxString m_configPath; // subpath for configuration
// TODO(hzeller): looks like these members were chosen to be static to survive different // TODO(hzeller): looks like these members were chosen to be static to survive different
...@@ -156,11 +150,8 @@ private: ...@@ -156,11 +150,8 @@ private:
// ugly hack, and should be solved differently. // ugly hack, and should be solved differently.
static wxString m_libraryName; 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_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_unit;
static int m_convert; static int m_convert;
......
...@@ -148,7 +148,7 @@ public: ...@@ -148,7 +148,7 @@ public:
* Function GetParent * Function GetParent
* @return the GERBVIEW_FRAME parent of this GERBER_IMAGE * @return the GERBVIEW_FRAME parent of this GERBER_IMAGE
*/ */
GERBVIEW_FRAME* GetParent() GERBVIEW_FRAME* GetParent() const
{ {
return m_Parent; return m_Parent;
} }
......
...@@ -131,7 +131,7 @@ wxPoint GERBER_DRAW_ITEM::GetABPosition( const wxPoint& aXYPosition ) const ...@@ -131,7 +131,7 @@ wxPoint GERBER_DRAW_ITEM::GetABPosition( const wxPoint& aXYPosition ) const
} }
wxPoint GERBER_DRAW_ITEM::GetXYPosition( const wxPoint& aABPosition ) wxPoint GERBER_DRAW_ITEM::GetXYPosition( const wxPoint& aABPosition ) const
{ {
// do the inverse transform made by GetABPosition // do the inverse transform made by GetABPosition
wxPoint xyPos = aABPosition; wxPoint xyPos = aABPosition;
...@@ -577,7 +577,7 @@ void GERBER_DRAW_ITEM::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) ...@@ -577,7 +577,7 @@ void GERBER_DRAW_ITEM::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
} }
bool GERBER_DRAW_ITEM::HitTest( const wxPoint& aRefPos ) bool GERBER_DRAW_ITEM::HitTest( const wxPoint& aRefPos ) const
{ {
// calculate aRefPos in XY gerber axis: // calculate aRefPos in XY gerber axis:
wxPoint ref_pos = GetXYPosition( aRefPos ); wxPoint ref_pos = GetXYPosition( aRefPos );
...@@ -592,7 +592,7 @@ bool GERBER_DRAW_ITEM::HitTest( const wxPoint& aRefPos ) ...@@ -592,7 +592,7 @@ bool GERBER_DRAW_ITEM::HitTest( const wxPoint& aRefPos )
} }
bool GERBER_DRAW_ITEM::HitTest( EDA_RECT& aRefArea ) bool GERBER_DRAW_ITEM::HitTest( const EDA_RECT& aRefArea ) const
{ {
wxPoint pos = GetABPosition( m_Start ); wxPoint pos = GetABPosition( m_Start );
......
...@@ -209,7 +209,7 @@ public: ...@@ -209,7 +209,7 @@ public:
* @param aABPosition = position in A,B plotter axis * @param aABPosition = position in A,B plotter axis
* @return const wxPoint - The given position in X,Y axis. * @return const wxPoint - The given position in X,Y axis.
*/ */
wxPoint GetXYPosition( const wxPoint& aABPosition ); wxPoint GetXYPosition( const wxPoint& aABPosition ) const;
/** /**
* Function GetDcodeDescr * Function GetDcodeDescr
...@@ -255,7 +255,7 @@ public: ...@@ -255,7 +255,7 @@ public:
* @param aRefPos a wxPoint to test * @param aRefPos a wxPoint to test
* @return bool - true if a hit, else false * @return bool - true if a hit, else false
*/ */
bool HitTest( const wxPoint& aRefPos ); bool HitTest( const wxPoint& aRefPos ) const;
/** /**
* Function HitTest (overloaded) * Function HitTest (overloaded)
...@@ -264,7 +264,7 @@ public: ...@@ -264,7 +264,7 @@ public:
* @param aRefArea a wxPoint to test * @param aRefArea a wxPoint to test
* @return bool - true if a hit, else false * @return bool - true if a hit, else false
*/ */
bool HitTest( EDA_RECT& aRefArea ); bool HitTest( const EDA_RECT& aRefArea ) const;
/** /**
* Function GetClass * Function GetClass
......
...@@ -52,8 +52,6 @@ BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME ) ...@@ -52,8 +52,6 @@ BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME )
GERBVIEW_FRAME::OnSelectOptionToolbar ) GERBVIEW_FRAME::OnSelectOptionToolbar )
EVT_MENU( wxID_PREFERENCES, GERBVIEW_FRAME::InstallGerberOptionsDialog ) EVT_MENU( wxID_PREFERENCES, GERBVIEW_FRAME::InstallGerberOptionsDialog )
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, EDA_DRAW_FRAME::SetLanguage )
// menu Postprocess // menu Postprocess
EVT_MENU( ID_GERBVIEW_SHOW_LIST_DCODES, GERBVIEW_FRAME::Process_Special_Functions ) EVT_MENU( ID_GERBVIEW_SHOW_LIST_DCODES, GERBVIEW_FRAME::Process_Special_Functions )
EVT_MENU( ID_GERBVIEW_SHOW_SOURCE, GERBVIEW_FRAME::OnShowGerberSourceFile ) EVT_MENU( ID_GERBVIEW_SHOW_SOURCE, GERBVIEW_FRAME::OnShowGerberSourceFile )
...@@ -209,9 +207,6 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -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 ) void GERBVIEW_FRAME::OnSelectActiveDCode( wxCommandEvent& event )
{ {
GERBER_IMAGE* gerber_image = g_GERBER_List[getActiveLayer()]; GERBER_IMAGE* gerber_image = g_GERBER_List[getActiveLayer()];
...@@ -228,10 +223,7 @@ void GERBVIEW_FRAME::OnSelectActiveDCode( wxCommandEvent& event ) ...@@ -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 ) void GERBVIEW_FRAME::OnSelectActiveLayer( wxCommandEvent& event )
{ {
LAYER_NUM layer = getActiveLayer(); LAYER_NUM layer = getActiveLayer();
...@@ -246,9 +238,6 @@ void GERBVIEW_FRAME::OnSelectActiveLayer( wxCommandEvent& event ) ...@@ -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 ) void GERBVIEW_FRAME::OnShowGerberSourceFile( wxCommandEvent& event )
{ {
LAYER_NUM layer = getActiveLayer(); LAYER_NUM layer = getActiveLayer();
...@@ -275,9 +264,6 @@ void GERBVIEW_FRAME::OnShowGerberSourceFile( wxCommandEvent& event ) ...@@ -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 ) void GERBVIEW_FRAME::OnSelectDisplayMode( wxCommandEvent& event )
{ {
int oldMode = GetDisplayMode(); int oldMode = GetDisplayMode();
...@@ -301,20 +287,20 @@ void GERBVIEW_FRAME::OnSelectDisplayMode( wxCommandEvent& event ) ...@@ -301,20 +287,20 @@ void GERBVIEW_FRAME::OnSelectDisplayMode( wxCommandEvent& event )
m_canvas->Refresh(); m_canvas->Refresh();
} }
void GERBVIEW_FRAME::OnQuit( wxCommandEvent& event ) void GERBVIEW_FRAME::OnQuit( wxCommandEvent& event )
{ {
Close( true ); Close( true );
} }
/**
* Function SetLanguage void GERBVIEW_FRAME::ShowChangedLanguage()
* called on a language menu selection
* Update Layer manager title and tabs texts
*/
void GERBVIEW_FRAME::SetLanguage( wxCommandEvent& event )
{ {
EDA_DRAW_FRAME::SetLanguage( event ); // call my base class
EDA_DRAW_FRAME::ShowChangedLanguage();
m_LayersManager->SetLayersManagerTabsText(); m_LayersManager->SetLayersManagerTabsText();
wxAuiPaneInfo& pane_info = m_auimgr.GetPane( m_LayersManager ); wxAuiPaneInfo& pane_info = m_auimgr.GetPane( m_LayersManager );
pane_info.Caption( _( "Visibles" ) ); pane_info.Caption( _( "Visibles" ) );
m_auimgr.Update(); m_auimgr.Update();
...@@ -322,14 +308,12 @@ void GERBVIEW_FRAME::SetLanguage( wxCommandEvent& event ) ...@@ -322,14 +308,12 @@ void GERBVIEW_FRAME::SetLanguage( wxCommandEvent& event )
ReFillLayerWidget(); ReFillLayerWidget();
} }
/**
* Function OnSelectOptionToolbar
* called to validate current choices
*/
void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event ) void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
{ {
int id = event.GetId(); int id = event.GetId();
bool state; bool state;
switch( id ) switch( id )
{ {
case ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG: case ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG:
...@@ -374,6 +358,7 @@ void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event ) ...@@ -374,6 +358,7 @@ void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
break; break;
case ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR: case ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR:
// show/hide auxiliary Vertical layers and visibility manager toolbar // show/hide auxiliary Vertical layers and visibility manager toolbar
m_show_layer_manager_tools = state; m_show_layer_manager_tools = state;
m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).Show( m_show_layer_manager_tools ); m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).Show( m_show_layer_manager_tools );
......
...@@ -462,11 +462,7 @@ public: ...@@ -462,11 +462,7 @@ public:
void SaveSettings( wxConfigBase* aCfg ); // override virtual void SaveSettings( wxConfigBase* aCfg ); // override virtual
/** void ShowChangedLanguage(); // override EDA_BASE_FRAME virtual
* Function SetLanguage
* called on a language menu selection
*/
virtual void SetLanguage( wxCommandEvent& event );
void Process_Special_Functions( wxCommandEvent& event ); void Process_Special_Functions( wxCommandEvent& event );
void OnSelectOptionToolbar( wxCommandEvent& event ); void OnSelectOptionToolbar( wxCommandEvent& event );
......
...@@ -456,14 +456,10 @@ public: ...@@ -456,14 +456,10 @@ public:
* Function HitTest * Function HitTest
* tests if \a aPosition is contained within or on the bounding area of an item. * tests if \a aPosition is contained within or on the bounding area of an item.
* *
* @note This function cannot be const because some of the derive objects perform
* intermediate calculations which change object members. Make sure derived
* objects do not declare this as const.
*
* @param aPosition A reference to a wxPoint object containing the coordinates to test. * @param aPosition A reference to a wxPoint object containing the coordinates to test.
* @return True if \a aPosition is within or on the item bounding area. * @return True if \a aPosition is within or on the item bounding area.
*/ */
virtual bool HitTest( const wxPoint& aPosition ) virtual bool HitTest( const wxPoint& aPosition ) const
{ {
return false; // derived classes should override this function return false; // derived classes should override this function
} }
......
...@@ -252,7 +252,7 @@ public: ...@@ -252,7 +252,7 @@ public:
*/ */
wxString GetLayerName() const; wxString GetLayerName() const;
virtual bool HitTest( const wxPoint& aPosition ) virtual bool HitTest( const wxPoint& aPosition ) const
{ {
return EDA_ITEM::HitTest( aPosition ); return EDA_ITEM::HitTest( aPosition );
} }
......
...@@ -123,7 +123,7 @@ public: ...@@ -123,7 +123,7 @@ public:
BASE_SCREEN* GetScreen(); BASE_SCREEN* GetScreen();
EDA_DRAW_FRAME* GetParent(); EDA_DRAW_FRAME* GetParent() const;
void OnPaint( wxPaintEvent& event ); void OnPaint( wxPaintEvent& event );
......
...@@ -35,6 +35,14 @@ ...@@ -35,6 +35,14 @@
#define DLGSHIM_USE_SETFOCUS 0 #define DLGSHIM_USE_SETFOCUS 0
#endif #endif
#if wxCHECK_VERSION( 2, 9, 4 )
#define WX_EVENT_LOOP wxGUIEventLoop
#else
#define WX_EVENT_LOOP wxEventLoop
#endif
class WX_EVENT_LOOP;
/** /**
* Class DIALOG_SHIM * Class DIALOG_SHIM
...@@ -56,12 +64,32 @@ public: ...@@ -56,12 +64,32 @@ public:
const wxString& name = wxDialogNameStr const wxString& name = wxDialogNameStr
); );
bool Show( bool show ); // overload wxDialog::Show ~DIALOG_SHIM();
int ShowQuasiModal(); // disable only the parent window, otherwise modal.
void EndQuasiModal( int retCode ); // End quasi-modal mode
bool IsQuasiModal() { return m_qmodal_showing; }
bool Show( bool show ); // override wxDialog::Show
bool Enable( bool enable ); // override wxDialog::Enable virtual
protected: protected:
#if !wxCHECK_VERSION( 2, 9, 4 )
wxWindow* CheckIfCanBeUsedAsParent( wxWindow* parent ) const;
wxWindow* GetParentForModalDialog( wxWindow *parent, long style ) const;
#endif
std::string m_hash_key; // alternate for class_map when classname re-used. std::string m_hash_key; // alternate for class_map when classname re-used.
// variables for quasi-modal behavior support, only used by a few derivatives.
WX_EVENT_LOOP* m_qmodal_loop; // points to nested event_loop, NULL means not qmodal and dismissed
bool m_qmodal_showing;
#if DLGSHIM_USE_SETFOCUS #if DLGSHIM_USE_SETFOCUS
private: private:
void onInit( wxInitDialogEvent& aEvent ); void onInit( wxInitDialogEvent& aEvent );
......
...@@ -281,13 +281,6 @@ public: ...@@ -281,13 +281,6 @@ public:
void EraseMsgBox(); void EraseMsgBox();
void Process_PageSettings( wxCommandEvent& event ); void Process_PageSettings( wxCommandEvent& event );
/**
* Function SetLanguage
* called on a language menu selection
* when using a derived function, do not forget to call this one
*/
virtual void SetLanguage( wxCommandEvent& event );
virtual void ReCreateHToolbar() = 0; virtual void ReCreateHToolbar() = 0;
virtual void ReCreateVToolbar() = 0; virtual void ReCreateVToolbar() = 0;
virtual void ReCreateMenuBar(); virtual void ReCreateMenuBar();
......
...@@ -80,9 +80,7 @@ public: ...@@ -80,9 +80,7 @@ public:
* @return int - minus 1 (i.e. -1) means success, >= 0 indicates the character offset into * @return int - minus 1 (i.e. -1) means success, >= 0 indicates the character offset into
* aId at which an error was detected. * aId at which an error was detected.
*/ */
int Parse( const std::string& aId ); int Parse( const UTF8& aId );
int Parse( const wxString& aId );
/** /**
* Function GetLibNickname * Function GetLibNickname
...@@ -100,9 +98,7 @@ public: ...@@ -100,9 +98,7 @@ public:
* into the parameter at which an error was detected, usually because it * into the parameter at which an error was detected, usually because it
* contained '/' or ':'. * contained '/' or ':'.
*/ */
int SetLibNickname( const std::string& aNickname ); int SetLibNickname( const UTF8& aNickname );
int SetLibNickname( const wxString& aNickname );
/** /**
* Function GetFootprintName * Function GetFootprintName
...@@ -114,11 +110,9 @@ public: ...@@ -114,11 +110,9 @@ public:
* Function SetFootprintName * Function SetFootprintName
* overrides the footprint name portion of the FPID to @a aFootprintName * overrides the footprint name portion of the FPID to @a aFootprintName
*/ */
int SetFootprintName( const std::string& aFootprintName ); int SetFootprintName( const UTF8& aFootprintName );
int SetFootprintName( const wxString& aFootprintName );
int SetRevision( const std::string& aRevision ); int SetRevision( const UTF8& aRevision );
const UTF8& GetRevision() const { return revision; } const UTF8& GetRevision() const { return revision; }
...@@ -136,10 +130,10 @@ public: ...@@ -136,10 +130,10 @@ public:
* aLibNickname, aFootprintName, and aRevision. * aLibNickname, aFootprintName, and aRevision.
* *
* @throw PARSE_ERROR if any of the pieces are illegal. * @throw PARSE_ERROR if any of the pieces are illegal.
*/ static UTF8 Format( const UTF8& aLibNickname, const UTF8& aFootprintName,
static UTF8 Format( const std::string& aLibNickname, const std::string& aFootprintName, const UTF8& aRevision = "" )
const std::string& aRevision )
throw( PARSE_ERROR ); throw( PARSE_ERROR );
*/
/** /**
* Function IsValid * Function IsValid
......
...@@ -11,22 +11,35 @@ enum FRAME_T ...@@ -11,22 +11,35 @@ enum FRAME_T
FRAME_SCH, FRAME_SCH,
FRAME_SCH_LIB_EDITOR, FRAME_SCH_LIB_EDITOR,
FRAME_SCH_VIEWER, FRAME_SCH_VIEWER,
FRAME_SCH_VIEWER_MODAL,
FRAME_PCB, FRAME_PCB,
FRAME_PCB_MODULE_EDITOR, FRAME_PCB_MODULE_EDITOR,
FRAME_PCB_MODULE_VIEWER, FRAME_PCB_MODULE_VIEWER,
FRAME_PCB_FOOTPRINT_WIZARD, FRAME_PCB_MODULE_VIEWER_MODAL,
FRAME_PCB_FOOTPRINT_WIZARD_MODAL,
FRAME_PCB_DISPLAY3D, FRAME_PCB_DISPLAY3D,
FRAME_CVPCB, FRAME_CVPCB,
FRAME_CVPCB_DISPLAY, FRAME_CVPCB_DISPLAY,
FRAME_GERBER, FRAME_GERBER,
KIWAY_PLAYER_COUNT, // counts subset of FRAME_T's tracked in class KIWAY FRAME_PL_EDITOR,
FRAME_BM2CMP,
FRAME_CALC,
KIWAY_PLAYER_COUNT, // counts subset of FRAME_T's which are KIWAY_PLAYER derivatives
// C++ project manager is not a KIWAY_PLAYER
KICAD_MAIN_FRAME_T = KIWAY_PLAYER_COUNT, KICAD_MAIN_FRAME_T = KIWAY_PLAYER_COUNT,
FRAME_PL_EDITOR,
//TEXT_EDITOR_FRAME_T,
FRAME_T_COUNT FRAME_T_COUNT
}; };
//TEXT_EDITOR_FRAME_T,
#endif // FRAME_T_H_ #endif // FRAME_T_H_
...@@ -58,7 +58,7 @@ public: ...@@ -58,7 +58,7 @@ public:
} }
VTBL_ENTRY wxWindow* CreateWindow( wxWindow* aParent, VTBL_ENTRY wxWindow* CreateWindow( wxWindow* aParent,
int aClassId, KIWAY* aKIWAY, int aCtlBits ) = 0; int aClassId, KIWAY* aKIWAY, int aCtlBits = 0 ) = 0;
VTBL_ENTRY void* IfaceOrAddress( int aDataId ) = 0; VTBL_ENTRY void* IfaceOrAddress( int aDataId ) = 0;
......
...@@ -150,7 +150,8 @@ struct KIFACE ...@@ -150,7 +150,8 @@ struct KIFACE
// this interface. // this interface.
#define KFCTL_STANDALONE (1<<0) ///< Am running as a standalone Top. #define KFCTL_STANDALONE (1<<0) ///< Am running as a standalone Top.
#define KFCTL_PROJECT_SUITE (1<<1) ///< Am running under a project mgr, possibly with others #define KFCTL_CPP_PROJECT_SUITE (1<<1) ///< Am running under C++ project mgr, possibly with others
#define KFCTL_PY_PROJECT_SUITE (1<<2) ///< Am running under python project mgr, possibly with others
/** /**
...@@ -201,7 +202,7 @@ struct KIFACE ...@@ -201,7 +202,7 @@ struct KIFACE
* not contained in the caller's link image. * not contained in the caller's link image.
*/ */
VTBL_ENTRY wxWindow* CreateWindow( wxWindow* aParent, int aClassId, VTBL_ENTRY wxWindow* CreateWindow( wxWindow* aParent, int aClassId,
KIWAY* aKIWAY, int aCtlBits ) = 0; KIWAY* aKIWAY, int aCtlBits = 0 ) = 0;
/** /**
* Function IfaceOrAddress * Function IfaceOrAddress
...@@ -249,6 +250,7 @@ struct KIFACE ...@@ -249,6 +250,7 @@ struct KIFACE
*/ */
class KIWAY : public wxEvtHandler class KIWAY : public wxEvtHandler
{ {
friend class PGM_SINGLE_TOP; // can use set_kiface()
public: public:
/// Known KIFACE implementations /// Known KIFACE implementations
...@@ -257,16 +259,12 @@ public: ...@@ -257,16 +259,12 @@ public:
FACE_SCH, ///< eeschema DSO FACE_SCH, ///< eeschema DSO
FACE_PCB, ///< pcbnew DSO FACE_PCB, ///< pcbnew DSO
FACE_CVPCB, FACE_CVPCB,
/// count of those above here, which is the subset managed in a KIWAY.
KIWAY_FACE_COUNT,
FACE_BMP2CMP = KIWAY_FACE_COUNT,
FACE_GERBVIEW, FACE_GERBVIEW,
FACE_PL_EDITOR, FACE_PL_EDITOR,
FACE_PCB_CALCULATOR, FACE_PCB_CALCULATOR,
FACE_BMP2CMP,
FACE_COUNT KIWAY_FACE_COUNT
}; };
/** /**
...@@ -325,7 +323,14 @@ public: ...@@ -325,7 +323,14 @@ public:
*/ */
VTBL_ENTRY bool PlayersClose( bool doForce ); VTBL_ENTRY bool PlayersClose( bool doForce );
VTBL_ENTRY void ExpressMail( FRAME_T aDestination, MAIL_T aCommand, const std::string& aPayload, wxWindow* aSource=NULL ); /**
* Function ExpressMail
* send aPayload to aDestination from aSource. Recipient receives this in its
* KIWAY_PLAYER::KiwayMailIn() function and can efficiently switch() based on
* aCommand in there.
*/
VTBL_ENTRY void ExpressMail( FRAME_T aDestination, MAIL_T aCommand,
const std::string& aPayload, wxWindow* aSource = NULL );
/** /**
* Function Prj * Function Prj
...@@ -335,11 +340,26 @@ public: ...@@ -335,11 +340,26 @@ public:
*/ */
VTBL_ENTRY PROJECT& Prj() const; VTBL_ENTRY PROJECT& Prj() const;
KIWAY( PGM_BASE* aProgram, wxFrame* aTop = NULL ); /**
* Function SetLanguage
* changes the language and then calls ShowChangedLanguage() on all KIWAY_PLAYERs.
*/
VTBL_ENTRY void SetLanguage( int aLanguage );
KIWAY( PGM_BASE* aProgram, int aCtlBits, wxFrame* aTop = NULL );
/// In case aTop may not be known at time of KIWAY construction: /**
* Function SetTop
* tells this KIWAY about the top most frame in the program and optionally
* allows it to play the role of one of the KIWAY_PLAYERs if launched from
* single_top.cpp.
*
* @param aTop is the top most wxFrame in the entire program.
*/
void SetTop( wxFrame* aTop ); void SetTop( wxFrame* aTop );
void OnKiwayEnd();
bool ProcessEvent( wxEvent& aEvent ); // overload virtual bool ProcessEvent( wxEvent& aEvent ); // overload virtual
private: private:
...@@ -348,12 +368,23 @@ private: ...@@ -348,12 +368,23 @@ private:
static const wxString dso_full_path( FACE_T aFaceId ); static const wxString dso_full_path( FACE_T aFaceId );
/// hooked into m_top in SetTop(), marks child frame as closed. /// hooked into m_top in SetTop(), marks child frame as closed.
void playerDestroyHandler( wxWindowDestroyEvent& event ); void player_destroy_handler( wxWindowDestroyEvent& event );
bool set_kiface( FACE_T aFaceType, KIFACE* aKiface )
{
if( unsigned( aFaceType ) < unsigned( KIWAY_FACE_COUNT ) )
{
m_kiface[aFaceType] = aKiface;
return true;
}
return false;
}
static KIFACE* m_kiface[KIWAY_FACE_COUNT]; static KIFACE* m_kiface[KIWAY_FACE_COUNT];
static int m_kiface_version[KIWAY_FACE_COUNT]; static int m_kiface_version[KIWAY_FACE_COUNT];
PGM_BASE* m_program; PGM_BASE* m_program;
int m_ctl;
wxFrame* m_top; wxFrame* m_top;
KIWAY_PLAYER* m_player[KIWAY_PLAYER_COUNT]; // from frame_type.h KIWAY_PLAYER* m_player[KIWAY_PLAYER_COUNT]; // from frame_type.h
......
...@@ -35,6 +35,8 @@ class PROJECT; ...@@ -35,6 +35,8 @@ class PROJECT;
struct KIFACE; struct KIFACE;
class KIFACE_I; class KIFACE_I;
#define VTBL_ENTRY virtual
/** /**
* Class KIWAY_HOLDER * Class KIWAY_HOLDER
...@@ -86,6 +88,15 @@ private: ...@@ -86,6 +88,15 @@ private:
class KIWAY_EXPRESS; class KIWAY_EXPRESS;
#if wxCHECK_VERSION( 2, 9, 4 )
#define WX_EVENT_LOOP wxGUIEventLoop
#else
#define WX_EVENT_LOOP wxEventLoop
#endif
class WX_EVENT_LOOP;
/** /**
* Class KIWAY_PLAYER * Class KIWAY_PLAYER
* is a wxFrame capable of the OpenProjectFiles function, meaning it can load * is a wxFrame capable of the OpenProjectFiles function, meaning it can load
...@@ -110,6 +121,9 @@ public: ...@@ -110,6 +121,9 @@ public:
const wxPoint& aPos, const wxSize& aSize, long aStyle, const wxPoint& aPos, const wxSize& aSize, long aStyle,
const wxString& aWdoName = wxFrameNameStr ); const wxString& aWdoName = wxFrameNameStr );
~KIWAY_PLAYER();
//----<Cross Module API>-----------------------------------------------------
// For the aCtl argument of OpenProjectFiles() // For the aCtl argument of OpenProjectFiles()
#define KICTL_OPEN_APPEND (1<<0) ///< append the data file, rather than replace #define KICTL_OPEN_APPEND (1<<0) ///< append the data file, rather than replace
...@@ -149,7 +163,7 @@ public: ...@@ -149,7 +163,7 @@ public:
* *
* @return bool - true if all requested files were opened OK, else false. * @return bool - true if all requested files were opened OK, else false.
*/ */
virtual bool OpenProjectFiles( const std::vector<wxString>& aFileList, int aCtl = 0 ) VTBL_ENTRY bool OpenProjectFiles( const std::vector<wxString>& aFileList, int aCtl = 0 )
{ {
// overload me for your wxFrame type. // overload me for your wxFrame type.
...@@ -161,6 +175,25 @@ public: ...@@ -161,6 +175,25 @@ public:
return false; return false;
} }
/**
* Function ShowModal
* puts up this wxFrame as if it were a modal dialog, with all other instantiated
* wxFrames disabled until this KIWAY_PLAYER derivative calls DismissModal().
* That is, behavior is similar to a modal dialog window. Not all KIWAY_PLAYERs
* use this interface, so don't call this unless the implementation knows how
* to call DismissModal() on a button click or double click or some special
* event which ends the modal behavior.
*
* @param aResult if not NULL, indicates a place to put a resultant string.
*
* @return bool - true if frame implementation called KIWAY_PLAYER::DismissModal()
* with aRetVal of true.
*/
VTBL_ENTRY bool ShowModal( wxString* aResult = NULL );
//----</Cross Module API>----------------------------------------------------
/** /**
* Function KiwayMailIn * Function KiwayMailIn
* receives KIWAY_EXPRESS messages from other players. Merely override it * receives KIWAY_EXPRESS messages from other players. Merely override it
...@@ -168,12 +201,37 @@ public: ...@@ -168,12 +201,37 @@ public:
*/ */
virtual void KiwayMailIn( KIWAY_EXPRESS& aEvent ); virtual void KiwayMailIn( KIWAY_EXPRESS& aEvent );
DECLARE_EVENT_TABLE() protected:
bool IsModal() { return m_modal; }
void SetModal( bool IsModal ) { m_modal = IsModal; }
/**
* Function IsDismissed
* returns false only if both the frame is acting in modal mode and it has not been
* dismissed yet with DismissModal(). IOW, it will return true if the dialog is
* not modal or if it is modal and has been dismissed.
*/
bool IsDismissed();
//private: void DismissModal( bool aRetVal, const wxString& aResult = wxEmptyString );
/// event handler, routes to virtual KiwayMailIn() /// event handler, routes to derivative specific virtual KiwayMailIn()
void kiway_express( KIWAY_EXPRESS& aEvent ); void kiway_express( KIWAY_EXPRESS& aEvent );
/**
* Function language_change
* is an event handler called on a language menu selection.
*/
void language_change( wxCommandEvent& event );
// variables for modal behavior support, only used by a few derivatives.
bool m_modal; // true if frame is intended to be modal, not modeless
WX_EVENT_LOOP* m_modal_loop; // points to nested event_loop, NULL means not modal and dismissed
wxString m_modal_string;
bool m_modal_ret_val; // true if a selection was made
DECLARE_EVENT_TABLE()
}; };
......
...@@ -291,7 +291,10 @@ public: ...@@ -291,7 +291,10 @@ public:
bool IsConnected( const wxPoint& aPoint ) const; bool IsConnected( const wxPoint& aPoint ) const;
/** @copydoc EDA_ITEM::HitTest(const wxPoint&) */ /** @copydoc EDA_ITEM::HitTest(const wxPoint&) */
virtual bool HitTest( const wxPoint& aPosition ) { return HitTest( aPosition, 0 ); } virtual bool HitTest( const wxPoint& aPosition ) const
{
return HitTest( aPosition, 0 );
}
/** /**
* Function HitTest * Function HitTest
......
...@@ -59,7 +59,7 @@ public: ...@@ -59,7 +59,7 @@ public:
EDA_COLOR_T GetColor() const { return m_color; } EDA_COLOR_T GetColor() const { return m_color; }
WS_DRAW_TYPE GetType() const { return m_type; }; WS_DRAW_TYPE GetType() const { return m_type; };
WORKSHEET_DATAITEM* GetParent() { return m_parent; } WORKSHEET_DATAITEM* GetParent() const { return m_parent; }
/** The function to draw a WS_DRAW_ITEM /** The function to draw a WS_DRAW_ITEM
*/ */
...@@ -69,7 +69,7 @@ public: ...@@ -69,7 +69,7 @@ public:
* Abstract function: should exist for derived items * Abstract function: should exist for derived items
* return true if the point aPosition is on the item * return true if the point aPosition is on the item
*/ */
virtual bool HitTest( const wxPoint& aPosition) = 0; virtual bool HitTest( const wxPoint& aPosition) const = 0;
/** /**
* Abstract function: should exist for derived items * Abstract function: should exist for derived items
...@@ -124,7 +124,7 @@ public: ...@@ -124,7 +124,7 @@ public:
* Virtual function * Virtual function
* return true if the point aPosition is on the line * return true if the point aPosition is on the line
*/ */
virtual bool HitTest( const wxPoint& aPosition); virtual bool HitTest( const wxPoint& aPosition) const;
/** /**
* return true if the point aPosition is on the starting point of this item. * return true if the point aPosition is on the starting point of this item.
...@@ -174,7 +174,7 @@ public: ...@@ -174,7 +174,7 @@ public:
* Virtual function * Virtual function
* return true if the point aPosition is inside one polygon * return true if the point aPosition is inside one polygon
*/ */
virtual bool HitTest( const wxPoint& aPosition); virtual bool HitTest( const wxPoint& aPosition) const;
/** /**
* return true if the point aPosition is on the starting point of this item. * return true if the point aPosition is on the starting point of this item.
...@@ -202,7 +202,7 @@ public: ...@@ -202,7 +202,7 @@ public:
* Virtual function * Virtual function
* return true if the point aPosition is on one edge of the rectangle * return true if the point aPosition is on one edge of the rectangle
*/ */
virtual bool HitTest( const wxPoint& aPosition); virtual bool HitTest( const wxPoint& aPosition) const;
/** /**
* return true if the point aPosition is on the starting point of this item. * return true if the point aPosition is on the starting point of this item.
...@@ -239,7 +239,7 @@ public: ...@@ -239,7 +239,7 @@ public:
* Virtual function * Virtual function
* return true if the point aPosition is on the text * return true if the point aPosition is on the text
*/ */
virtual bool HitTest( const wxPoint& aPosition); virtual bool HitTest( const wxPoint& aPosition) const;
/** /**
* return true if the point aPosition is on the starting point of this item. * return true if the point aPosition is on the starting point of this item.
...@@ -274,7 +274,7 @@ public: ...@@ -274,7 +274,7 @@ public:
* Virtual function * Virtual function
* return true if the point aPosition is on bitmap * return true if the point aPosition is on bitmap
*/ */
virtual bool HitTest( const wxPoint& aPosition); virtual bool HitTest( const wxPoint& aPosition) const;
/** /**
* return true if the point aPosition is on the reference point of this item. * return true if the point aPosition is on the reference point of this item.
......
...@@ -813,12 +813,6 @@ private: ...@@ -813,12 +813,6 @@ private:
void OnUpdateBusOrientation( wxUpdateUIEvent& event ); void OnUpdateBusOrientation( wxUpdateUIEvent& event );
void OnUpdateSelectTool( wxUpdateUIEvent& aEvent ); void OnUpdateSelectTool( wxUpdateUIEvent& aEvent );
/**
* Function SetLanguage
* called on a language menu selection
*/
void SetLanguage( wxCommandEvent& event );
/** /**
* Function UpdateTitle * Function UpdateTitle
* sets the main window title bar text. * sets the main window title bar text.
......
...@@ -1664,11 +1664,7 @@ public: ...@@ -1664,11 +1664,7 @@ public:
*/ */
MODULE* Genere_Self( wxDC* DC ); MODULE* Genere_Self( wxDC* DC );
/** void ShowChangedLanguage(); // override EDA_BASE_FRAME virtual
* Function SetLanguage
* called on a language menu selection
*/
virtual void SetLanguage( wxCommandEvent& event );
/** /**
* Function UpdateTitle * Function UpdateTitle
......
...@@ -190,7 +190,9 @@ public: ...@@ -190,7 +190,9 @@ public:
* @warning If you override this function in a derived class, make sure you call * @warning If you override this function in a derived class, make sure you call
* down to this or the auto save feature will be disabled. * down to this or the auto save feature will be disabled.
*/ */
bool ProcessEvent( wxEvent& aEvent ); // overload wxFrame::ProcessEvent() bool ProcessEvent( wxEvent& aEvent ); // override wxFrame::ProcessEvent()
bool Enable( bool enable ); // override wxFrame::Enable virtual
void SetAutoSaveInterval( int aInterval ) { m_autoSaveInterval = aInterval; } void SetAutoSaveInterval( int aInterval ) { m_autoSaveInterval = aInterval; }
...@@ -302,13 +304,6 @@ public: ...@@ -302,13 +304,6 @@ public:
*/ */
void ExportHotkeyConfigToFile( struct EDA_HOTKEY_CONFIG* aDescList ); void ExportHotkeyConfigToFile( struct EDA_HOTKEY_CONFIG* aDescList );
/**
* Function SetLanguage
* called on a language menu selection
* when using a derived function, do not forget to call this one
*/
virtual void SetLanguage( wxCommandEvent& event );
/** /**
* Function GetFileFromHistory * Function GetFileFromHistory
* fetches the file name from the file history list. * fetches the file name from the file history list.
...@@ -380,17 +375,10 @@ public: ...@@ -380,17 +375,10 @@ public:
void CheckForAutoSaveFile( const wxFileName& aFileName, const wxString& aBackupFileExtension ); void CheckForAutoSaveFile( const wxFileName& aFileName, const wxString& aBackupFileExtension );
/** /**
* Function SetModalMode * Function ShowChangedLanguage
* Disable or enable all other windows, to emulate a dialog behavior * redraws the menus and what not in current language.
* Useful when the frame is used to show and selec items
* (see FOOTPRINT_VIEWER_FRAME and LIB_VIEW_FRAME)
*
* @param aModal = true to disable all other opened windows (i.e.
* this windows is in dialog mode
* = false to enable other windows
* This function is analog to MakeModal( aModal ), deprecated since wxWidgets 2.9.4
*/ */
void SetModalMode( bool aModal ); virtual void ShowChangedLanguage();
}; };
...@@ -415,7 +403,6 @@ public: ...@@ -415,7 +403,6 @@ public:
* then after a //==// break has additional calls to anchor toolbars in a way that matches * then after a //==// break has additional calls to anchor toolbars in a way that matches
* present functionality. * present functionality.
*/ */
class EDA_PANEINFO : public wxAuiPaneInfo class EDA_PANEINFO : public wxAuiPaneInfo
{ {
......
...@@ -17,7 +17,7 @@ private: ...@@ -17,7 +17,7 @@ private:
public: public:
TREE_PROJECT_FRAME* GetParent() TREE_PROJECT_FRAME* GetParent() const
{ {
return m_Parent; return m_Parent;
} }
......
...@@ -197,6 +197,8 @@ bool PGM_KICAD::OnPgmInit( wxApp* aWxApp ) ...@@ -197,6 +197,8 @@ bool PGM_KICAD::OnPgmInit( wxApp* aWxApp )
void PGM_KICAD::OnPgmExit() void PGM_KICAD::OnPgmExit()
{ {
Kiway.OnKiwayEnd();
saveCommonSettings(); saveCommonSettings();
// write common settings to disk, and destroy everything in PGM_KICAD, // write common settings to disk, and destroy everything in PGM_KICAD,
...@@ -253,7 +255,7 @@ void PGM_KICAD::destroy() ...@@ -253,7 +255,7 @@ void PGM_KICAD::destroy()
} }
KIWAY Kiway( &Pgm() ); KIWAY Kiway( &Pgm(), KFCTL_CPP_PROJECT_SUITE );
/** /**
......
...@@ -140,6 +140,8 @@ public: ...@@ -140,6 +140,8 @@ public:
private: private:
int m_leftWinWidth; int m_leftWinWidth;
void language_change( wxCommandEvent& event );
public: public:
KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title, KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title,
const wxPoint& pos, const wxSize& size ); const wxPoint& pos, const wxSize& size );
...@@ -202,7 +204,6 @@ public: ...@@ -202,7 +204,6 @@ public:
*/ */
void ClearMsg(); void ClearMsg();
void SetLanguage( wxCommandEvent& event );
void OnRefresh( wxCommandEvent& event ); void OnRefresh( wxCommandEvent& event );
void OnSelectDefaultPdfBrowser( wxCommandEvent& event ); void OnSelectDefaultPdfBrowser( wxCommandEvent& event );
void OnSelectPreferredPdfBrowser( wxCommandEvent& event ); void OnSelectPreferredPdfBrowser( wxCommandEvent& event );
......
...@@ -361,6 +361,14 @@ void KICAD_MANAGER_FRAME::OnRefresh( wxCommandEvent& event ) ...@@ -361,6 +361,14 @@ void KICAD_MANAGER_FRAME::OnRefresh( wxCommandEvent& event )
} }
void KICAD_MANAGER_FRAME::language_change( wxCommandEvent& event )
{
int id = event.GetId();
Kiway.SetLanguage( id );
}
void KICAD_MANAGER_FRAME::ClearMsg() void KICAD_MANAGER_FRAME::ClearMsg()
{ {
m_MessagesBox->Clear(); m_MessagesBox->Clear();
......
...@@ -33,20 +33,20 @@ ...@@ -33,20 +33,20 @@
#include <menus_helpers.h> #include <menus_helpers.h>
#include <tree_project_frame.h> #include <tree_project_frame.h>
/* Menubar and toolbar event table */ // Menubar and toolbar event table
BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME ) BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME )
/* Window events */ // Window events
EVT_SIZE( KICAD_MANAGER_FRAME::OnSize ) EVT_SIZE( KICAD_MANAGER_FRAME::OnSize )
EVT_CLOSE( KICAD_MANAGER_FRAME::OnCloseWindow ) EVT_CLOSE( KICAD_MANAGER_FRAME::OnCloseWindow )
/* Toolbar events */ // Toolbar events
EVT_TOOL( ID_NEW_PROJECT, KICAD_MANAGER_FRAME::OnLoadProject ) EVT_TOOL( ID_NEW_PROJECT, KICAD_MANAGER_FRAME::OnLoadProject )
EVT_TOOL( ID_NEW_PROJECT_FROM_TEMPLATE, KICAD_MANAGER_FRAME::OnLoadProject ) EVT_TOOL( ID_NEW_PROJECT_FROM_TEMPLATE, KICAD_MANAGER_FRAME::OnLoadProject )
EVT_TOOL( ID_LOAD_PROJECT, KICAD_MANAGER_FRAME::OnLoadProject ) EVT_TOOL( ID_LOAD_PROJECT, KICAD_MANAGER_FRAME::OnLoadProject )
EVT_TOOL( ID_SAVE_PROJECT, KICAD_MANAGER_FRAME::OnSaveProject ) EVT_TOOL( ID_SAVE_PROJECT, KICAD_MANAGER_FRAME::OnSaveProject )
EVT_TOOL( ID_SAVE_AND_ZIP_FILES, KICAD_MANAGER_FRAME::OnArchiveFiles ) EVT_TOOL( ID_SAVE_AND_ZIP_FILES, KICAD_MANAGER_FRAME::OnArchiveFiles )
/* Menu events */ // Menu events
EVT_MENU( ID_SAVE_PROJECT, KICAD_MANAGER_FRAME::OnSaveProject ) EVT_MENU( ID_SAVE_PROJECT, KICAD_MANAGER_FRAME::OnSaveProject )
EVT_MENU( wxID_EXIT, KICAD_MANAGER_FRAME::OnExit ) EVT_MENU( wxID_EXIT, KICAD_MANAGER_FRAME::OnExit )
EVT_MENU( ID_TO_EDITOR, KICAD_MANAGER_FRAME::OnOpenTextEditor ) EVT_MENU( ID_TO_EDITOR, KICAD_MANAGER_FRAME::OnOpenTextEditor )
...@@ -63,16 +63,17 @@ BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME ) ...@@ -63,16 +63,17 @@ BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME )
EVT_MENU( wxID_INDEX, KICAD_MANAGER_FRAME::GetKicadHelp ) EVT_MENU( wxID_INDEX, KICAD_MANAGER_FRAME::GetKicadHelp )
EVT_MENU( wxID_ABOUT, KICAD_MANAGER_FRAME::GetKicadAbout ) EVT_MENU( wxID_ABOUT, KICAD_MANAGER_FRAME::GetKicadAbout )
/* Range menu events */ // Range menu events
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, KICAD_MANAGER_FRAME::SetLanguage ) EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, KICAD_MANAGER_FRAME::language_change )
EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, KICAD_MANAGER_FRAME::OnFileHistory ) EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, KICAD_MANAGER_FRAME::OnFileHistory )
// Special functions // Special functions
#ifdef KICAD_USE_FILES_WATCHER #ifdef KICAD_USE_FILES_WATCHER
EVT_MENU( ID_INIT_WATCHED_PATHS, KICAD_MANAGER_FRAME::OnChangeWatchedPaths ) EVT_MENU( ID_INIT_WATCHED_PATHS, KICAD_MANAGER_FRAME::OnChangeWatchedPaths )
#endif #endif
/* Button events */ // Button events
EVT_BUTTON( ID_TO_PCB, KICAD_MANAGER_FRAME::OnRunPcbNew ) EVT_BUTTON( ID_TO_PCB, KICAD_MANAGER_FRAME::OnRunPcbNew )
EVT_BUTTON( ID_TO_CVPCB, KICAD_MANAGER_FRAME::OnRunCvpcb ) EVT_BUTTON( ID_TO_CVPCB, KICAD_MANAGER_FRAME::OnRunCvpcb )
EVT_BUTTON( ID_TO_EESCHEMA, KICAD_MANAGER_FRAME::OnRunEeschema ) EVT_BUTTON( ID_TO_EESCHEMA, KICAD_MANAGER_FRAME::OnRunEeschema )
......
...@@ -88,8 +88,3 @@ void KICAD_MANAGER_FRAME::OnSelectPreferredPdfBrowser( wxCommandEvent& event ) ...@@ -88,8 +88,3 @@ void KICAD_MANAGER_FRAME::OnSelectPreferredPdfBrowser( wxCommandEvent& event )
Pgm().WritePdfBrowserInfos(); Pgm().WritePdfBrowserInfos();
} }
void KICAD_MANAGER_FRAME::SetLanguage( wxCommandEvent& event )
{
EDA_BASE_FRAME::SetLanguage( event );
}
...@@ -70,12 +70,8 @@ BEGIN_EVENT_TABLE( PL_EDITOR_FRAME, EDA_DRAW_FRAME ) ...@@ -70,12 +70,8 @@ BEGIN_EVENT_TABLE( PL_EDITOR_FRAME, EDA_DRAW_FRAME )
EVT_MENU( wxID_EXIT, PL_EDITOR_FRAME::OnQuit ) EVT_MENU( wxID_EXIT, PL_EDITOR_FRAME::OnQuit )
// menu Preferences // menu Preferences
EVT_MENU_RANGE( ID_PREFERENCES_HOTKEY_START, ID_PREFERENCES_HOTKEY_END, EVT_MENU_RANGE( ID_PREFERENCES_HOTKEY_START, ID_PREFERENCES_HOTKEY_END, PL_EDITOR_FRAME::Process_Config )
PL_EDITOR_FRAME::Process_Config ) EVT_MENU( ID_MENU_PL_EDITOR_SELECT_PREFERED_EDITOR, EDA_BASE_FRAME::OnSelectPreferredEditor )
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END,
EDA_DRAW_FRAME::SetLanguage )
EVT_MENU( ID_MENU_PL_EDITOR_SELECT_PREFERED_EDITOR,
EDA_BASE_FRAME::OnSelectPreferredEditor )
EVT_MENU( wxID_PREFERENCES, PL_EDITOR_FRAME::Process_Config ) EVT_MENU( wxID_PREFERENCES, PL_EDITOR_FRAME::Process_Config )
EVT_MENU( ID_MENU_SWITCH_BGCOLOR, PL_EDITOR_FRAME::Process_Config ) EVT_MENU( ID_MENU_SWITCH_BGCOLOR, PL_EDITOR_FRAME::Process_Config )
EVT_MENU( ID_MENU_GRID_ONOFF, PL_EDITOR_FRAME::Process_Config ) EVT_MENU( ID_MENU_GRID_ONOFF, PL_EDITOR_FRAME::Process_Config )
...@@ -473,15 +469,6 @@ void PL_EDITOR_FRAME::OnQuit( wxCommandEvent& event ) ...@@ -473,15 +469,6 @@ void PL_EDITOR_FRAME::OnQuit( wxCommandEvent& event )
Close( true ); Close( true );
} }
/**
* Function SetLanguage
* called on a language menu selection
* Update Layer manager title and tabs texts
*/
void PL_EDITOR_FRAME::SetLanguage( wxCommandEvent& event )
{
EDA_DRAW_FRAME::SetLanguage( event );
}
void PL_EDITOR_FRAME::ToPlotter(wxCommandEvent& event) void PL_EDITOR_FRAME::ToPlotter(wxCommandEvent& event)
{ {
......
...@@ -198,12 +198,6 @@ public: ...@@ -198,12 +198,6 @@ public:
void SaveSettings( wxConfigBase* aCfg ); // override virtual void SaveSettings( wxConfigBase* aCfg ); // override virtual
/**
* Function SetLanguage
* called on a language menu selection
*/
virtual void SetLanguage( wxCommandEvent& event );
void Process_Special_Functions( wxCommandEvent& event ); void Process_Special_Functions( wxCommandEvent& event );
void OnSelectOptionToolbar( wxCommandEvent& event ); void OnSelectOptionToolbar( wxCommandEvent& event );
......
...@@ -75,7 +75,7 @@ if( USE_KIWAY_DLLS ) ...@@ -75,7 +75,7 @@ if( USE_KIWAY_DLLS )
${PCB_CALCULATOR_RESOURCES} ${PCB_CALCULATOR_RESOURCES}
) )
set_source_files_properties( ../common/single_top.cpp PROPERTIES set_source_files_properties( ../common/single_top.cpp PROPERTIES
COMPILE_DEFINITIONS "TOP_FRAME=0;BUILD_KIWAY_DLL" COMPILE_DEFINITIONS "TOP_FRAME=FRAME_CALC;BUILD_KIWAY_DLL"
) )
target_link_libraries( pcb_calculator target_link_libraries( pcb_calculator
#singletop # replaces common, giving us restrictive control and link warnings. #singletop # replaces common, giving us restrictive control and link warnings.
...@@ -93,7 +93,6 @@ if( USE_KIWAY_DLLS ) ...@@ -93,7 +93,6 @@ if( USE_KIWAY_DLLS )
add_library( pcb_calculator_kiface MODULE add_library( pcb_calculator_kiface MODULE
pcb_calculator.cpp pcb_calculator.cpp
${PCB_CALCULATOR_SRCS} ${PCB_CALCULATOR_SRCS}
# ${PCB_CALCULATOR_RESOURCES}
) )
set_target_properties( pcb_calculator_kiface PROPERTIES set_target_properties( pcb_calculator_kiface PROPERTIES
OUTPUT_NAME pcb_calculator OUTPUT_NAME pcb_calculator
......
...@@ -134,6 +134,7 @@ PCB_CALCULATOR_FRAME::~PCB_CALCULATOR_FRAME() ...@@ -134,6 +134,7 @@ PCB_CALCULATOR_FRAME::~PCB_CALCULATOR_FRAME()
this->Freeze(); this->Freeze();
} }
void PCB_CALCULATOR_FRAME::OnClosePcbCalc( wxCloseEvent& event ) void PCB_CALCULATOR_FRAME::OnClosePcbCalc( wxCloseEvent& event )
{ {
if( m_RegulatorListChanged ) if( m_RegulatorListChanged )
......
...@@ -306,7 +306,7 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx ...@@ -306,7 +306,7 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
bool aErase ) bool aErase )
{ {
BASE_SCREEN* screen = aPanel->GetScreen(); BASE_SCREEN* screen = aPanel->GetScreen();
FOOTPRINT_EDIT_FRAME* moduleEditFrame = FOOTPRINT_EDIT_FRAME::GetActiveFootprintEditor( aPanel->GetParent() ); FOOTPRINT_EDIT_FRAME* moduleEditFrame = dynamic_cast<FOOTPRINT_EDIT_FRAME*>( aPanel->GetParent() );
wxASSERT( moduleEditFrame ); wxASSERT( moduleEditFrame );
MODULE* currentModule = moduleEditFrame->GetBoard()->m_Modules; MODULE* currentModule = moduleEditFrame->GetBoard()->m_Modules;
......
...@@ -403,7 +403,7 @@ void DIMENSION::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) ...@@ -403,7 +403,7 @@ void DIMENSION::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
} }
bool DIMENSION::HitTest( const wxPoint& aPosition ) bool DIMENSION::HitTest( const wxPoint& aPosition ) const
{ {
if( m_Text.TextHitTest( aPosition ) ) if( m_Text.TextHitTest( aPosition ) )
return true; return true;
......
...@@ -208,7 +208,7 @@ public: ...@@ -208,7 +208,7 @@ public:
void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ); void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );
bool HitTest( const wxPoint& aPosition ); bool HitTest( const wxPoint& aPosition ) const;
/** @copydoc BOARD_ITEM::HitTest(const EDA_RECT& aRect, /** @copydoc BOARD_ITEM::HitTest(const EDA_RECT& aRect,
* bool aContained = true, int aAccuracy ) const * bool aContained = true, int aAccuracy ) const
......
...@@ -475,7 +475,7 @@ const EDA_RECT DRAWSEGMENT::GetBoundingBox() const ...@@ -475,7 +475,7 @@ const EDA_RECT DRAWSEGMENT::GetBoundingBox() const
} }
bool DRAWSEGMENT::HitTest( const wxPoint& aPosition ) bool DRAWSEGMENT::HitTest( const wxPoint& aPosition ) const
{ {
switch( m_Shape ) switch( m_Shape )
{ {
......
...@@ -179,7 +179,7 @@ public: ...@@ -179,7 +179,7 @@ public:
virtual const EDA_RECT GetBoundingBox() const; virtual const EDA_RECT GetBoundingBox() const;
virtual bool HitTest( const wxPoint& aPosition ); virtual bool HitTest( const wxPoint& aPosition ) const;
/** @copydoc BOARD_ITEM::HitTest(const EDA_RECT& aRect, /** @copydoc BOARD_ITEM::HitTest(const EDA_RECT& aRect,
* bool aContained = true, int aAccuracy ) const * bool aContained = true, int aAccuracy ) const
......
...@@ -74,7 +74,7 @@ public: ...@@ -74,7 +74,7 @@ public:
return m_item; return m_item;
} }
bool HitTest( const wxPoint& aPosition ) bool HitTest( const wxPoint& aPosition ) const
{ {
return HitTestMarker( aPosition ); return HitTestMarker( aPosition );
} }
......
...@@ -158,7 +158,7 @@ void PCB_TARGET::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color, ...@@ -158,7 +158,7 @@ void PCB_TARGET::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color,
} }
bool PCB_TARGET::HitTest( const wxPoint& aPosition ) bool PCB_TARGET::HitTest( const wxPoint& aPosition ) const
{ {
int dX = aPosition.x - m_Pos.x; int dX = aPosition.x - m_Pos.x;
int dY = aPosition.y - m_Pos.y; int dY = aPosition.y - m_Pos.y;
......
...@@ -82,7 +82,7 @@ public: ...@@ -82,7 +82,7 @@ public:
void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, void Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
GR_DRAWMODE aDrawMode, const wxPoint& offset = ZeroOffset ); GR_DRAWMODE aDrawMode, const wxPoint& offset = ZeroOffset );
bool HitTest( const wxPoint& aPosition ); bool HitTest( const wxPoint& aPosition ) const;
/** @copydoc BOARD_ITEM::HitTest(const EDA_RECT& aRect, /** @copydoc BOARD_ITEM::HitTest(const EDA_RECT& aRect,
* bool aContained = true, int aAccuracy ) const * bool aContained = true, int aAccuracy ) const
......
...@@ -549,7 +549,7 @@ void MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) ...@@ -549,7 +549,7 @@ void MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
} }
bool MODULE::HitTest( const wxPoint& aPosition ) bool MODULE::HitTest( const wxPoint& aPosition ) const
{ {
if( m_BoundaryBox.Contains( aPosition ) ) if( m_BoundaryBox.Contains( aPosition ) )
return true; return true;
......
...@@ -324,7 +324,7 @@ public: ...@@ -324,7 +324,7 @@ public:
void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ); void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );
bool HitTest( const wxPoint& aPosition ); bool HitTest( const wxPoint& aPosition ) const;
/** @copydoc BOARD_ITEM::HitTest(const EDA_RECT& aRect, /** @copydoc BOARD_ITEM::HitTest(const EDA_RECT& aRect,
* bool aContained = true, int aAccuracy ) const * bool aContained = true, int aAccuracy ) const
......
...@@ -637,7 +637,7 @@ bool D_PAD::IsOnLayer( LAYER_NUM aLayer ) const ...@@ -637,7 +637,7 @@ bool D_PAD::IsOnLayer( LAYER_NUM aLayer ) const
} }
bool D_PAD::HitTest( const wxPoint& aPosition ) bool D_PAD::HitTest( const wxPoint& aPosition ) const
{ {
int dx, dy; int dx, dy;
......
...@@ -341,7 +341,7 @@ public: ...@@ -341,7 +341,7 @@ public:
* Function GetBoundingRadius * Function GetBoundingRadius
* returns the radius of a minimum sized circle which fully encloses this pad. * returns the radius of a minimum sized circle which fully encloses this pad.
*/ */
int GetBoundingRadius() int GetBoundingRadius() const
{ {
// Any member function which would affect this calculation should set // Any member function which would affect this calculation should set
// m_boundingRadius to -1 to re-trigger the calculation from here. // m_boundingRadius to -1 to re-trigger the calculation from here.
...@@ -368,7 +368,7 @@ public: ...@@ -368,7 +368,7 @@ public:
bool IsOnLayer( LAYER_NUM aLayer ) const; bool IsOnLayer( LAYER_NUM aLayer ) const;
bool HitTest( const wxPoint& aPosition ); bool HitTest( const wxPoint& aPosition ) const;
wxString GetClass() const wxString GetClass() const
{ {
...@@ -450,7 +450,8 @@ private: ...@@ -450,7 +450,8 @@ private:
*/ */
int boundingRadius() const; int boundingRadius() const;
int m_boundingRadius; ///< radius of the circle containing the pad shape // Actually computed and cached on demand by the accessor
mutable int m_boundingRadius; ///< radius of the circle containing the pad shape
/// Pad name (4 char) or a long identifier (used in pad name /// Pad name (4 char) or a long identifier (used in pad name
/// comparisons because this is faster than string comparison) /// comparisons because this is faster than string comparison)
......
...@@ -76,7 +76,7 @@ public: ...@@ -76,7 +76,7 @@ public:
void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ); void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );
bool HitTest( const wxPoint& aPosition ) bool HitTest( const wxPoint& aPosition ) const
{ {
return TextHitTest( aPosition ); return TextHitTest( aPosition );
} }
......
...@@ -163,7 +163,7 @@ void TEXTE_MODULE::SetLocalCoord() ...@@ -163,7 +163,7 @@ void TEXTE_MODULE::SetLocalCoord()
RotatePoint( &m_Pos0.x, &m_Pos0.y, -angle ); RotatePoint( &m_Pos0.x, &m_Pos0.y, -angle );
} }
bool TEXTE_MODULE::HitTest( const wxPoint& aPosition ) bool TEXTE_MODULE::HitTest( const wxPoint& aPosition ) const
{ {
wxPoint rel_pos; wxPoint rel_pos;
EDA_RECT area = GetTextBox( -1, -1 ); EDA_RECT area = GetTextBox( -1, -1 );
...@@ -455,6 +455,9 @@ void TEXTE_MODULE::ViewGetLayers( int aLayers[], int& aCount ) const ...@@ -455,6 +455,9 @@ void TEXTE_MODULE::ViewGetLayers( int aLayers[], int& aCount ) const
case LAYER_N_FRONT: case LAYER_N_FRONT:
aLayers[0] = ITEM_GAL_LAYER( MOD_TEXT_FR_VISIBLE ); // how about SILKSCREEN_N_FRONT? aLayers[0] = ITEM_GAL_LAYER( MOD_TEXT_FR_VISIBLE ); // how about SILKSCREEN_N_FRONT?
break; break;
default:
wxFAIL_MSG( wxT( "Can't tell text layer" ) );
} }
break; break;
} }
......
...@@ -150,7 +150,7 @@ public: ...@@ -150,7 +150,7 @@ public:
void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ); void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );
bool HitTest( const wxPoint& aPosition ); bool HitTest( const wxPoint& aPosition ) const;
wxString GetClass() const wxString GetClass() const
{ {
......
...@@ -1236,7 +1236,7 @@ bool TRACK::HitTest( const wxPoint& aPosition ) ...@@ -1236,7 +1236,7 @@ bool TRACK::HitTest( const wxPoint& aPosition )
return TestSegmentHit( aPosition, m_Start, m_End, m_Width / 2 ); return TestSegmentHit( aPosition, m_Start, m_End, m_Width / 2 );
} }
bool VIA::HitTest( const wxPoint& aPosition ) bool VIA::HitTest( const wxPoint& aPosition ) const
{ {
int max_dist = m_Width / 2; int max_dist = m_Width / 2;
......
...@@ -401,7 +401,7 @@ public: ...@@ -401,7 +401,7 @@ public:
const wxPoint& GetPosition() const { return m_Start; } // was overload const wxPoint& GetPosition() const { return m_Start; } // was overload
void SetPosition( const wxPoint& aPoint ) { m_Start = aPoint; m_End = aPoint; } // was overload void SetPosition( const wxPoint& aPoint ) { m_Start = aPoint; m_End = aPoint; } // was overload
virtual bool HitTest( const wxPoint& aPosition ); virtual bool HitTest( const wxPoint& aPosition ) const;
virtual bool HitTest( const EDA_RECT& aRect, bool aContained = true, int aAccuracy = 0 ) const; virtual bool HitTest( const EDA_RECT& aRect, bool aContained = true, int aAccuracy = 0 ) const;
......
...@@ -440,37 +440,42 @@ int ZONE_CONTAINER::GetThermalReliefCopperBridge( D_PAD* aPad ) const ...@@ -440,37 +440,42 @@ int ZONE_CONTAINER::GetThermalReliefCopperBridge( D_PAD* aPad ) const
} }
bool ZONE_CONTAINER::HitTest( const wxPoint& aPosition ) bool ZONE_CONTAINER::HitTest( const wxPoint& aPosition ) const
{ {
if( HitTestForCorner( aPosition ) ) if( HitTestForCorner( aPosition ) >= 0 )
return true; return true;
if( HitTestForEdge( aPosition ) ) if( HitTestForEdge( aPosition ) >= 0 )
return true; return true;
return false; return false;
} }
void ZONE_CONTAINER::SetSelectedCorner( const wxPoint& aPosition )
{
m_CornerSelection = HitTestForCorner( aPosition );
if( m_CornerSelection < 0 )
m_CornerSelection = HitTestForEdge( aPosition );
}
// Zones outlines have no thickness, so it Hit Test functions // Zones outlines have no thickness, so it Hit Test functions
// we must have a default distance between the test point // we must have a default distance between the test point
// and a corner or a zone edge: // and a corner or a zone edge:
#define MAX_DIST_IN_MM 0.25 #define MAX_DIST_IN_MM 0.25
bool ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos ) int ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos ) const
{ {
int distmax = Millimeter2iu( MAX_DIST_IN_MM ); int distmax = Millimeter2iu( MAX_DIST_IN_MM );
m_CornerSelection = m_Poly->HitTestForCorner( refPos, distmax ); return m_Poly->HitTestForCorner( refPos, distmax );
return m_CornerSelection >= 0;
} }
bool ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos ) int ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos ) const
{ {
int distmax = Millimeter2iu( MAX_DIST_IN_MM ); int distmax = Millimeter2iu( MAX_DIST_IN_MM );
m_CornerSelection = m_Poly->HitTestForEdge( refPos, distmax ); return m_Poly->HitTestForEdge( refPos, distmax );
return m_CornerSelection >= 0;
} }
...@@ -700,25 +705,23 @@ void ZONE_CONTAINER::Move( const wxPoint& offset ) ...@@ -700,25 +705,23 @@ void ZONE_CONTAINER::Move( const wxPoint& offset )
} }
void ZONE_CONTAINER::MoveEdge( const wxPoint& offset ) void ZONE_CONTAINER::MoveEdge( const wxPoint& offset, int aEdge )
{ {
int ii = m_CornerSelection;
// Move the start point of the selected edge: // Move the start point of the selected edge:
SetCornerPosition( ii, GetCornerPosition( ii ) + offset ); SetCornerPosition( aEdge, GetCornerPosition( aEdge ) + offset );
// Move the end point of the selected edge: // Move the end point of the selected edge:
if( m_Poly->m_CornersList.IsEndContour( ii ) || ii == GetNumCorners() - 1 ) if( m_Poly->m_CornersList.IsEndContour( aEdge ) || aEdge == GetNumCorners() - 1 )
{ {
int icont = m_Poly->GetContour( ii ); int icont = m_Poly->GetContour( aEdge );
ii = m_Poly->GetContourStart( icont ); aEdge = m_Poly->GetContourStart( icont );
} }
else else
{ {
ii++; aEdge++;
} }
SetCornerPosition( ii, GetCornerPosition( ii ) + offset ); SetCornerPosition( aEdge, GetCornerPosition( aEdge ) + offset );
m_Poly->Hatch(); m_Poly->Hatch();
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment