Do not restore placement and sizing when GUI changes
This commit is contained in:
parent
ea5049172d
commit
ce11c7f4d4
@ -71,6 +71,9 @@ void wxZRColaCharRequest::OnOKButtonClick(wxCommandEvent& event)
|
||||
// wxPersistentZRColaCharRequest
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const int wxPersistentZRColaCharRequest::s_guiLevel = 1;
|
||||
|
||||
|
||||
wxPersistentZRColaCharRequest::wxPersistentZRColaCharRequest(wxZRColaCharRequest *wnd) : wxPersistentTLWEx(wnd)
|
||||
{
|
||||
}
|
||||
@ -78,6 +81,7 @@ wxPersistentZRColaCharRequest::wxPersistentZRColaCharRequest(wxZRColaCharRequest
|
||||
|
||||
void wxPersistentZRColaCharRequest::Save() const
|
||||
{
|
||||
SaveValue(wxT("guiLevel"), s_guiLevel);
|
||||
wxPersistentTLWEx::Save();
|
||||
|
||||
auto wnd = static_cast<const wxZRColaCharRequest*>(GetWindow()); // dynamic_cast is not reliable as we are typically called late in the wxTopLevelWindowMSW destructor.
|
||||
@ -97,5 +101,6 @@ bool wxPersistentZRColaCharRequest::Restore()
|
||||
if (RestoreValue(wxT("context"), &str))
|
||||
wnd->m_context->SetValue(str);
|
||||
|
||||
return wxPersistentTLWEx::Restore();
|
||||
int guiLevel;
|
||||
return RestoreValue(wxT("guiLevel"), &guiLevel) && guiLevel == s_guiLevel ? wxPersistentTLWEx::Restore() : true;
|
||||
}
|
||||
|
@ -58,6 +58,9 @@ public:
|
||||
|
||||
virtual void Save() const;
|
||||
virtual bool Restore();
|
||||
|
||||
protected:
|
||||
static const int s_guiLevel; ///< Persisted placements/sizing are considered incompatible between different GUI levels
|
||||
};
|
||||
|
||||
|
||||
|
@ -786,6 +786,9 @@ bool __cdecl wxZRColaCharSelect::SearchThread::TestDestroyS(void *cookie)
|
||||
// wxPersistentZRColaCharSelect
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const int wxPersistentZRColaCharSelect::s_guiLevel = 1;
|
||||
|
||||
|
||||
wxPersistentZRColaCharSelect::wxPersistentZRColaCharSelect(wxZRColaCharSelect *wnd) : wxPersistentTLWEx(wnd)
|
||||
{
|
||||
}
|
||||
@ -793,6 +796,7 @@ wxPersistentZRColaCharSelect::wxPersistentZRColaCharSelect(wxZRColaCharSelect *w
|
||||
|
||||
void wxPersistentZRColaCharSelect::Save() const
|
||||
{
|
||||
SaveValue(wxT("guiLevel"), s_guiLevel);
|
||||
wxPersistentTLWEx::Save();
|
||||
|
||||
auto wnd = static_cast<const wxZRColaCharSelect*>(GetWindow()); // dynamic_cast is not reliable as we are typically called late in the wxTopLevelWindowMSW destructor.
|
||||
@ -870,5 +874,6 @@ bool wxPersistentZRColaCharSelect::Restore()
|
||||
|
||||
wnd->ResetResults();
|
||||
|
||||
return wxPersistentTLWEx::Restore();
|
||||
int guiLevel;
|
||||
return RestoreValue(wxT("guiLevel"), &guiLevel) && guiLevel == s_guiLevel ? wxPersistentTLWEx::Restore() : true;
|
||||
}
|
||||
|
@ -228,6 +228,9 @@ public:
|
||||
|
||||
virtual void Save() const;
|
||||
virtual bool Restore();
|
||||
|
||||
protected:
|
||||
static const int s_guiLevel; ///< Persisted placements/sizing are considered incompatible between different GUI levels
|
||||
};
|
||||
|
||||
|
||||
|
@ -398,6 +398,9 @@ void wxZRColaComposerPanel::SetHexValue(wxTextCtrl *wnd, std::pair<long, long> &
|
||||
// wxPersistentZRColaComposerPanel
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const int wxPersistentZRColaComposerPanel::s_guiLevel = 1;
|
||||
|
||||
|
||||
wxPersistentZRColaComposerPanel::wxPersistentZRColaComposerPanel(wxZRColaComposerPanel *wnd) : wxPersistentWindow<wxZRColaComposerPanel>(wnd)
|
||||
{
|
||||
}
|
||||
@ -413,6 +416,7 @@ void wxPersistentZRColaComposerPanel::Save() const
|
||||
{
|
||||
auto wnd = static_cast<wxZRColaComposerPanel*>(GetWindow()); // dynamic_cast is not reliable as we are typically called late in the wxTopLevelWindowMSW destructor.
|
||||
|
||||
SaveValue(wxT("guiLevel" ), s_guiLevel);
|
||||
SaveValue(wxT("dpiX" ), wxClientDC(wnd).GetPPI().x);
|
||||
SaveValue(wxT("splitDecomposed"), wnd->m_splitterSource ->GetSashPosition());
|
||||
SaveValue(wxT("splitComposed" ), wnd->m_splitterDestination->GetSashPosition());
|
||||
@ -423,6 +427,10 @@ bool wxPersistentZRColaComposerPanel::Restore()
|
||||
{
|
||||
auto wnd = dynamic_cast<wxZRColaComposerPanel*>(GetWindow());
|
||||
|
||||
int guiLevel;
|
||||
if (!RestoreValue(wxT("guiLevel"), &guiLevel) || guiLevel != s_guiLevel)
|
||||
return true;
|
||||
|
||||
int dpiHorz = wxClientDC(wnd).GetPPI().x;
|
||||
int dpiHorzVal;
|
||||
int sashVal;
|
||||
|
@ -88,6 +88,9 @@ public:
|
||||
virtual wxString GetKind() const;
|
||||
virtual void Save() const;
|
||||
virtual bool Restore();
|
||||
|
||||
protected:
|
||||
static const int s_guiLevel; ///< Persisted placements/sizing are considered incompatible between different GUI levels
|
||||
};
|
||||
|
||||
|
||||
|
@ -64,6 +64,9 @@ wxBEGIN_EVENT_TABLE(wxZRColaFrame, wxZRColaFrameBase)
|
||||
wxEND_EVENT_TABLE()
|
||||
|
||||
|
||||
const int wxZRColaFrame::s_guiLevel = 1;
|
||||
|
||||
|
||||
wxZRColaFrame::wxZRColaFrame() :
|
||||
m_hWndSource(NULL),
|
||||
m_wasIconised(false),
|
||||
@ -173,9 +176,12 @@ wxZRColaFrame::wxZRColaFrame() :
|
||||
SetAcceleratorTable(wxAcceleratorTable(_countof(entries), entries));
|
||||
}
|
||||
|
||||
// Restore persistent state of wxAuiManager manually, since m_mgr is not a standalone heap object
|
||||
// and cannot be registered for persistence.
|
||||
wxPersistentAuiManager(&m_mgr).Restore();
|
||||
int guiLevel;
|
||||
if (wxConfigBase::Get()->Read(wxT("guiLevel"), &guiLevel) && guiLevel == s_guiLevel) {
|
||||
// Restore persistent state of wxAuiManager manually, since m_mgr is not a standalone heap object
|
||||
// and cannot be registered for persistence.
|
||||
wxPersistentAuiManager(&m_mgr).Restore();
|
||||
}
|
||||
persist_mgr.RegisterAndRestore(this, new wxPersistentZRColaFrame(this));
|
||||
|
||||
// Update (de)composition selection.
|
||||
@ -219,6 +225,7 @@ wxZRColaFrame::~wxZRColaFrame()
|
||||
|
||||
// Save wxAuiManager's state before destructor is finished.
|
||||
// m_mgr is not a standalone heap object and is bound to wxZRColaFrame, which is being destroyed.
|
||||
wxConfigBase::Get()->Write(wxT("guiLevel"), s_guiLevel);
|
||||
wxPersistentAuiManager(&m_mgr).Save();
|
||||
wxPersistenceManager::Get().SaveAndUnregister(this);
|
||||
|
||||
@ -717,6 +724,9 @@ WXLRESULT wxZRColaFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM
|
||||
// wxPersistentZRColaFrame
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const int wxPersistentZRColaFrame::s_guiLevel = 1;
|
||||
|
||||
|
||||
wxPersistentZRColaFrame::wxPersistentZRColaFrame(wxZRColaFrame *wnd) : wxPersistentTLWEx(wnd)
|
||||
{
|
||||
}
|
||||
@ -724,6 +734,7 @@ wxPersistentZRColaFrame::wxPersistentZRColaFrame(wxZRColaFrame *wnd) : wxPersist
|
||||
|
||||
void wxPersistentZRColaFrame::Save() const
|
||||
{
|
||||
SaveValue(wxT("guiLevel"), s_guiLevel);
|
||||
wxPersistentTLWEx::Save();
|
||||
|
||||
auto wnd = static_cast<const wxZRColaFrame*>(GetWindow()); // dynamic_cast is not reliable as we are typically called late in the wxTopLevelWindowMSW destructor.
|
||||
@ -753,5 +764,6 @@ bool wxPersistentZRColaFrame::Restore()
|
||||
else
|
||||
wnd->m_composition = wnd->m_transeq_id == ZRCOLA_TRANSEQID_DEFAULT;
|
||||
|
||||
return wxPersistentTLWEx::Restore();
|
||||
int guiLevel;
|
||||
return RestoreValue(wxT("guiLevel"), &guiLevel) && guiLevel == s_guiLevel ? wxPersistentTLWEx::Restore() : true;
|
||||
}
|
||||
|
@ -130,6 +130,9 @@ protected:
|
||||
virtual WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
static const int s_guiLevel; ///< Persisted placements/sizing are considered incompatible between different GUI levels
|
||||
|
||||
protected:
|
||||
WXHWND m_hWndSource; ///< Handle of the active window, when the ZRCola hotkey was pressed
|
||||
bool m_wasIconised; ///< Was the ZRCola window iconized, when the ZRCola hotkey was pressed
|
||||
@ -153,6 +156,9 @@ public:
|
||||
|
||||
virtual void Save() const;
|
||||
virtual bool Restore();
|
||||
|
||||
protected:
|
||||
static const int s_guiLevel; ///< Persisted placements/sizing are considered incompatible between different GUI levels
|
||||
};
|
||||
|
||||
|
||||
|
@ -139,6 +139,9 @@ void wxZRColaSettings::OnOKButtonClick(wxCommandEvent& event)
|
||||
// wxPersistentZRColaSettings
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const int wxPersistentZRColaSettings::s_guiLevel = 1;
|
||||
|
||||
|
||||
wxPersistentZRColaSettings::wxPersistentZRColaSettings(wxZRColaSettings *wnd) : wxPersistentTLWEx(wnd)
|
||||
{
|
||||
}
|
||||
@ -146,6 +149,7 @@ wxPersistentZRColaSettings::wxPersistentZRColaSettings(wxZRColaSettings *wnd) :
|
||||
|
||||
void wxPersistentZRColaSettings::Save() const
|
||||
{
|
||||
SaveValue(wxT("guiLevel"), s_guiLevel);
|
||||
wxPersistentTLWEx::Save();
|
||||
|
||||
auto wnd = static_cast<const wxZRColaSettings*>(GetWindow()); // dynamic_cast is not reliable as we are typically called late in the wxTopLevelWindowMSW destructor.
|
||||
@ -177,5 +181,6 @@ bool wxPersistentZRColaSettings::Restore()
|
||||
} else
|
||||
wnd->m_lang = ZRCola::langid_t::blank;
|
||||
|
||||
return wxPersistentTLWEx::Restore();
|
||||
int guiLevel;
|
||||
return RestoreValue(wxT("guiLevel"), &guiLevel) && guiLevel == s_guiLevel ? wxPersistentTLWEx::Restore() : true;
|
||||
}
|
||||
|
@ -63,6 +63,9 @@ public:
|
||||
|
||||
virtual void Save() const;
|
||||
virtual bool Restore();
|
||||
|
||||
protected:
|
||||
static const int s_guiLevel; ///< Persisted placements/sizing are considered incompatible between different GUI levels
|
||||
};
|
||||
|
||||
|
||||
|
@ -208,6 +208,9 @@ void wxZRColaTranslationSeq::OnOKButtonClick(wxCommandEvent& event)
|
||||
// wxPersistentZRColaTranslationSeq
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const int wxPersistentZRColaTranslationSeq::s_guiLevel = 1;
|
||||
|
||||
|
||||
wxPersistentZRColaTranslationSeq::wxPersistentZRColaTranslationSeq(wxZRColaTranslationSeq *wnd) : wxPersistentTLWEx(wnd)
|
||||
{
|
||||
}
|
||||
@ -215,6 +218,7 @@ wxPersistentZRColaTranslationSeq::wxPersistentZRColaTranslationSeq(wxZRColaTrans
|
||||
|
||||
void wxPersistentZRColaTranslationSeq::Save() const
|
||||
{
|
||||
SaveValue(wxT("guiLevel"), s_guiLevel);
|
||||
wxPersistentTLWEx::Save();
|
||||
|
||||
auto wnd = static_cast<const wxZRColaTranslationSeq*>(GetWindow()); // dynamic_cast is not reliable as we are typically called late in the wxTopLevelWindowMSW destructor.
|
||||
@ -249,5 +253,6 @@ bool wxPersistentZRColaTranslationSeq::Restore()
|
||||
wnd->m_transeq = std::move(transet);
|
||||
}
|
||||
|
||||
return wxPersistentTLWEx::Restore();
|
||||
int guiLevel;
|
||||
return RestoreValue(wxT("guiLevel"), &guiLevel) && guiLevel == s_guiLevel ? wxPersistentTLWEx::Restore() : true;
|
||||
}
|
||||
|
@ -71,6 +71,9 @@ public:
|
||||
|
||||
virtual void Save() const;
|
||||
virtual bool Restore();
|
||||
|
||||
protected:
|
||||
static const int s_guiLevel; ///< Persisted placements/sizing are considered incompatible between different GUI levels
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user