Minor updates of auto-saving feature

This commit is contained in:
Simon Rozman 2016-04-22 13:39:34 +02:00
parent 5f755aa3d9
commit 82d2fc42bd
2 changed files with 13 additions and 2 deletions

View File

@ -25,7 +25,7 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
BEGIN_EVENT_TABLE(wxZRColaComposerPanel, wxZRColaComposerPanelBase) BEGIN_EVENT_TABLE(wxZRColaComposerPanel, wxZRColaComposerPanelBase)
EVT_TIMER(1, wxZRColaComposerPanel::OnTimerTimeout) EVT_TIMER(wxZRColaComposerPanel::wxID_TIMER, wxZRColaComposerPanel::OnTimerTimeout)
END_EVENT_TABLE() END_EVENT_TABLE()
@ -37,8 +37,10 @@ wxZRColaComposerPanel::wxZRColaComposerPanel(wxWindow* parent) :
{ {
m_decomposed->PushEventHandler(&m_keyhandler); m_decomposed->PushEventHandler(&m_keyhandler);
m_timer = new wxTimer(this, 1); // Create timer for saving the state.
m_timer = new wxTimer(this, wxID_TIMER);
// Restore the previously saved state (if exists).
wxPersistentZRColaComposerPanel(this).Restore(); wxPersistentZRColaComposerPanel(this).Restore();
} }
@ -77,6 +79,8 @@ void wxZRColaComposerPanel::OnDecomposedText(wxCommandEvent& event)
// We are being updated by wxZRColaComposerPanel::OnComposedText() // We are being updated by wxZRColaComposerPanel::OnComposedText()
event.Skip(); event.Skip();
} else { } else {
m_timer->Stop();
#ifdef __WINDOWS__ #ifdef __WINDOWS__
// Use Windows GetWindowText() function to avoid line ending conversion incompletely imposed by wxWidgets. // Use Windows GetWindowText() function to avoid line ending conversion incompletely imposed by wxWidgets.
WXHWND hWnd = m_decomposed->GetHWND(); WXHWND hWnd = m_decomposed->GetHWND();
@ -130,6 +134,8 @@ void wxZRColaComposerPanel::OnComposedText(wxCommandEvent& event)
// We are being updated by wxZRColaComposerPanel::OnDecomposedText() // We are being updated by wxZRColaComposerPanel::OnDecomposedText()
event.Skip(); event.Skip();
} else { } else {
m_timer->Stop();
#ifdef __WINDOWS__ #ifdef __WINDOWS__
// Use Windows GetWindowTextLength() function to avoid line ending conversion incompletely imposed by wxWidgets. // Use Windows GetWindowTextLength() function to avoid line ending conversion incompletely imposed by wxWidgets.
WXHWND hWnd = m_composed->GetHWND(); WXHWND hWnd = m_composed->GetHWND();

View File

@ -38,6 +38,11 @@ class wxZRColaComposerPanel;
class wxZRColaComposerPanel : public wxZRColaComposerPanelBase class wxZRColaComposerPanel : public wxZRColaComposerPanelBase
{ {
public: public:
enum
{
wxID_TIMER = 1,
};
wxZRColaComposerPanel(wxWindow* parent); wxZRColaComposerPanel(wxWindow* parent);
virtual ~wxZRColaComposerPanel(); virtual ~wxZRColaComposerPanel();