Fix quasi-modal dialog mode in DIALOG_SHIM class.
* Add event handler to check all button clicks for default command event IDs and handle them appropriately by either calling EndQuasiModal() or passing the event up the event handler chain to allow the default dialog handlers to perform their magic. * Add event handler to handle the close window event properly. * Add scope brackets so the wxBusyCursor will stop being displayed when the footprint library loading is complete in CvPcb.
This commit is contained in:
parent
9e3fd5b762
commit
f239aee1ad
|
@ -3,7 +3,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
* Copyright (C) 2012-2016 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
|
||||
|
@ -70,6 +70,9 @@ DIALOG_SHIM::DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& titl
|
|||
if( h )
|
||||
SetKiway( this, &h->Kiway() );
|
||||
|
||||
Bind( wxEVT_CLOSE_WINDOW, &DIALOG_SHIM::OnCloseWindow, this );
|
||||
Bind( wxEVT_BUTTON, &DIALOG_SHIM::OnButton, this );
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
// On Windows, the app top windows can be brought to the foreground
|
||||
// (at least temporary) in certain circumstances,
|
||||
|
@ -535,3 +538,49 @@ void DIALOG_SHIM::EndQuasiModal( int retCode )
|
|||
|
||||
Show( false );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_SHIM::OnCloseWindow( wxCloseEvent& aEvent )
|
||||
{
|
||||
if( IsQuasiModal() )
|
||||
{
|
||||
EndQuasiModal( wxID_CANCEL );
|
||||
return;
|
||||
}
|
||||
|
||||
// This is mandatory to allow wxDialogBase::OnCloseWindow() to be called.
|
||||
aEvent.Skip();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_SHIM::OnButton( wxCommandEvent& aEvent )
|
||||
{
|
||||
if( IsQuasiModal() )
|
||||
{
|
||||
const int id = aEvent.GetId();
|
||||
|
||||
if( id == GetAffirmativeId() )
|
||||
{
|
||||
EndQuasiModal( id );
|
||||
}
|
||||
else if( id == wxID_APPLY )
|
||||
{
|
||||
if( Validate() )
|
||||
TransferDataFromWindow();
|
||||
}
|
||||
else if( id == GetEscapeId() ||
|
||||
(id == wxID_CANCEL && GetEscapeId() == wxID_ANY) )
|
||||
{
|
||||
EndQuasiModal( wxID_CANCEL );
|
||||
}
|
||||
else // not a standard button
|
||||
{
|
||||
aEvent.Skip();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// This is mandatory to allow wxDialogBase::OnButton() to be called.
|
||||
aEvent.Skip();
|
||||
}
|
||||
|
|
|
@ -725,9 +725,11 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles()
|
|||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
wxBusyCursor dummy; // Let the user know something is happening.
|
||||
|
||||
m_FootprintsList.ReadFootprintFiles( fptbl );
|
||||
}
|
||||
|
||||
if( m_FootprintsList.GetErrorCount() )
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
* Copyright (C) 2012-2016 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
|
||||
|
@ -52,6 +52,22 @@ class EVENT_LOOP;
|
|||
**/
|
||||
class DIALOG_SHIM : public wxDialog, public KIWAY_HOLDER
|
||||
{
|
||||
/**
|
||||
* Function OnCloseWindow
|
||||
*
|
||||
* properly handles the wxCloseEvent when in the quasimodal mode when not calling
|
||||
* EndQuasiModal which is possible with any dialog derived from #DIALOG_SHIM.
|
||||
*/
|
||||
void OnCloseWindow( wxCloseEvent& aEvent );
|
||||
|
||||
/**
|
||||
* Function OnCloseWindow
|
||||
*
|
||||
* properly handles the default button events when in the quasimodal mode when not
|
||||
* calling EndQuasiModal which is possible with any dialog derived from #DIALOG_SHIM.
|
||||
*/
|
||||
void OnButton( wxCommandEvent& aEvent );
|
||||
|
||||
public:
|
||||
|
||||
DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& title,
|
||||
|
|
Loading…
Reference in New Issue