Commit 741bfb68 authored by Dick Hollenbeck's avatar Dick Hollenbeck

Another attempt at wxFrame::SaveSettings() standard infrastructure.

parent 8afe2dfb
......@@ -99,6 +99,18 @@ EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent,
Connect( ID_AUTO_SAVE_TIMER, wxEVT_TIMER,
wxTimerEventHandler( EDA_BASE_FRAME::onAutoSaveTimer ) );
// hook wxEVT_CLOSE_WINDOW so we can call SaveSettings(). This function seems
// to be called before any other hook for wxCloseEvent, which is necessary.
Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( EDA_BASE_FRAME::windowClosing ) );
}
void EDA_BASE_FRAME::windowClosing( wxCloseEvent& event )
{
SaveSettings(); // virtual, wxFrame specific
event.Skip(); // we did not "handle" the event, only eavesdropped on it.
}
......@@ -109,9 +121,8 @@ EDA_BASE_FRAME::~EDA_BASE_FRAME()
delete m_autoSaveTimer;
/* This needed for OSX: avoids further OnDraw processing after this
* destructor and before the native window is destroyed
*/
// This is needed for OSX: avoids further OnDraw processing after this
// destructor and before the native window is destroyed
this->Freeze();
}
......@@ -141,19 +152,6 @@ bool EDA_BASE_FRAME::ProcessEvent( wxEvent& aEvent )
}
bool EDA_BASE_FRAME::Show( bool show )
{
if( !show ) // closing
{
SaveSettings(); // virtual, wxFrame specific
}
int ret = wxFrame::Show( show );
return ret;
}
void EDA_BASE_FRAME::onAutoSaveTimer( wxTimerEvent& aEvent )
{
if( !doAutoSave() )
......
......@@ -338,9 +338,6 @@ void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event )
m_modified = false;
// hide main frame, which also forces saving curr pos and size in config
Show( false );
Destroy();
return;
}
......
......@@ -505,8 +505,6 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
// all sub sheets are deleted, only the main sheet is usable
m_CurrentSheet->Clear();
// hide main frame, which also forces saving curr pos and size in config
Show( false );
Destroy();
}
......
......@@ -177,9 +177,6 @@ GERBVIEW_FRAME::~GERBVIEW_FRAME()
void GERBVIEW_FRAME::OnCloseWindow( wxCloseEvent& Event )
{
// hide main frame, which also forces saving curr pos and size in config
Show( false );
Destroy();
}
......
......@@ -107,10 +107,26 @@ extern const wxChar traceAutoSave[];
/**
* Class EDA_BASE_FRAME
* is the base frame for deriving all KiCad main window classes. This class is not
* intended to be used directly.
* intended to be used directly. It provides support for automatic calls to
* a virtual SaveSettings() function. SaveSettings() for a derived class can choose
* to do nothing, or rely on basic SaveSettings() support in this base class to do
* most of the work by calling it from the derived class's SaveSettings().
*/
class EDA_BASE_FRAME : public wxFrame
{
/**
* Function windowClosing
* (with its unexpected name so it does not collide with the real OnWindowClose()
* function provided in derived classes) is called just before a window
* closing, and is used to call a derivation specific
* SaveSettings(). SaveSettings() is called for all derived wxFrames in this
* base class overload. (Calling it from a destructor is deprecated since the
* wxFrame's position is not available in the destructor on linux.) In other words,
* you should not need to call call SaveSettings() anywhere, except in this
* one function found only in this class.
*/
void windowClosing( wxCloseEvent& event );
protected:
ID_DRAWFRAME_TYPE m_Ident; ///< Id Type (pcb, schematic, library..)
wxPoint m_FramePos;
......@@ -177,17 +193,6 @@ public:
*/
bool ProcessEvent( wxEvent& aEvent ); // overload wxFrame::ProcessEvent()
/**
* Function Show
* hooks the wxFrame close scenario so we can grab the window size and position
* in the wxFrame specific SaveSettings() function. SaveSettings() is
* called for all derived wxFrames in this base class overload. Calling it
* from a destructor is deprecated since the wxFrame's position is not available
* in the destructor on linux. In other words, don't call SaveSettings() anywhere,
* except in this one function.
*/
bool Show( bool show ); // overload wxFrame::Show()
void SetAutoSaveInterval( int aInterval ) { m_autoSaveInterval = aInterval; }
int GetAutoSaveInterval() const { return m_autoSaveInterval; }
......
......@@ -159,8 +159,6 @@ void KICAD_MANAGER_FRAME::OnCloseWindow( wxCloseEvent& Event )
}
m_LeftWin->Show( false );
// hide main frame, which also forces saving curr pos and size in config
Show( false );
Destroy();
}
......
......@@ -258,7 +258,6 @@ void FOOTPRINT_WIZARD_FRAME::OnCloseWindow( wxCloseEvent& Event )
}
else
{
Show( false );
Destroy();
}
}
......
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