Honor monitor layout and DPI changes when persisting window placement

This commit is contained in:
Simon Rozman 2018-09-11 15:32:13 +02:00
parent 16dc9aff96
commit 974d6bd827
12 changed files with 37 additions and 31 deletions

View File

@ -37,6 +37,7 @@
#include <wxex/common.h>
#include <wxex/url.h>
#include <wxex/persist/auimanager.h>
#include <wxex/persist/toplevel.h>
#include <wx/clipbrd.h>
#include <wx/ffile.h>

View File

@ -71,14 +71,14 @@ void wxZRColaCharRequest::OnOKButtonClick(wxCommandEvent& event)
// wxPersistentZRColaCharRequest
//////////////////////////////////////////////////////////////////////////
wxPersistentZRColaCharRequest::wxPersistentZRColaCharRequest(wxZRColaCharRequest *wnd) : wxPersistentDialog(wnd)
wxPersistentZRColaCharRequest::wxPersistentZRColaCharRequest(wxZRColaCharRequest *wnd) : wxPersistentTLWEx(wnd)
{
}
void wxPersistentZRColaCharRequest::Save() const
{
wxPersistentDialog::Save();
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 +97,5 @@ bool wxPersistentZRColaCharRequest::Restore()
if (RestoreValue(wxT("context"), &str))
wnd->m_context->SetValue(str);
return wxPersistentDialog::Restore();
return wxPersistentTLWEx::Restore();
}

View File

@ -21,12 +21,14 @@
/// Forward declarations
///
class wxZRColaCharRequest;
class wxPersistentZRColaCharRequest;
#pragma once
#include "zrcolagui.h"
#include "zrcolakeyhndlr.h"
#include <wxex/persist/toplevel.h>
///
@ -49,7 +51,7 @@ protected:
///
/// Supports saving/restoring wxZRColaCharRequest state
///
class wxPersistentZRColaCharRequest : public wxPersistentDialog
class wxPersistentZRColaCharRequest : public wxPersistentTLWEx
{
public:
wxPersistentZRColaCharRequest(wxZRColaCharRequest *wnd);

View File

@ -786,14 +786,14 @@ bool __cdecl wxZRColaCharSelect::SearchThread::TestDestroyS(void *cookie)
// wxPersistentZRColaCharSelect
//////////////////////////////////////////////////////////////////////////
wxPersistentZRColaCharSelect::wxPersistentZRColaCharSelect(wxZRColaCharSelect *wnd) : wxPersistentDialog(wnd)
wxPersistentZRColaCharSelect::wxPersistentZRColaCharSelect(wxZRColaCharSelect *wnd) : wxPersistentTLWEx(wnd)
{
}
void wxPersistentZRColaCharSelect::Save() const
{
wxPersistentDialog::Save();
wxPersistentTLWEx::Save();
auto wnd = static_cast<const wxZRColaCharSelect*>(GetWindow()); // dynamic_cast is not reliable as we are typically called late in the wxTopLevelWindowMSW destructor.
auto app = dynamic_cast<ZRColaApp*>(wxTheApp);
@ -870,5 +870,5 @@ bool wxPersistentZRColaCharSelect::Restore()
wnd->ResetResults();
return wxPersistentDialog::Restore();
return wxPersistentTLWEx::Restore();
}

View File

@ -28,8 +28,8 @@ class wxPersistentZRColaCharSelect;
#include "zrcolagui.h"
#include <zrcola/character.h>
#include <wxex/persist/toplevel.h>
#include <wx/validate.h>
#include <wxex/persist/dialog.h>
#include <wx/event.h>
#include <wx/thread.h>
#include <list>
@ -41,7 +41,7 @@ class wxPersistentZRColaCharSelect;
///
/// Validator for Unicode character
///
class WXEXTEND_API wxZRColaUTF16CharValidator : public wxValidator
class wxZRColaUTF16CharValidator : public wxValidator
{
public:
///
@ -221,7 +221,7 @@ protected:
///
/// Supports saving/restoring wxZRColaCharSelect state
///
class wxPersistentZRColaCharSelect : public wxPersistentDialog
class wxPersistentZRColaCharSelect : public wxPersistentTLWEx
{
public:
wxPersistentZRColaCharSelect(wxZRColaCharSelect *wnd);

View File

@ -110,17 +110,19 @@ wxZRColaFrame::wxZRColaFrame() :
delete m_taskBarIcon;
}
wxPersistenceManager &persist_mgr = wxPersistenceManager::Get();
m_settings = new wxZRColaSettings(this);
wxPersistentRegisterAndRestore<wxZRColaSettings>(m_settings);
persist_mgr.RegisterAndRestore(m_settings, new wxPersistentZRColaSettings(m_settings));
m_transeq = new wxZRColaTranslationSeq(this);
wxPersistentRegisterAndRestore<wxZRColaTranslationSeq>(m_transeq);
persist_mgr.RegisterAndRestore(m_transeq, new wxPersistentZRColaTranslationSeq(m_transeq));
m_chrSelect = new wxZRColaCharSelect(this);
wxPersistentRegisterAndRestore<wxZRColaCharSelect>(m_chrSelect);
persist_mgr.RegisterAndRestore(m_chrSelect, new wxPersistentZRColaCharSelect(m_chrSelect));
m_chrReq = new wxZRColaCharRequest(this);
wxPersistentRegisterAndRestore<wxZRColaCharRequest>(m_chrReq);
persist_mgr.RegisterAndRestore(m_chrReq, new wxPersistentZRColaCharRequest(m_chrReq));
// Set focus.
m_panel->m_source->SetFocus();
@ -155,7 +157,7 @@ wxZRColaFrame::wxZRColaFrame() :
// 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();
wxPersistentRegisterAndRestore<wxZRColaFrame>(this);
persist_mgr.RegisterAndRestore(this, new wxPersistentZRColaFrame(this));
// Populate list of translation sequences.
for (unsigned int i = 0, n = m_toolTranslationSeq->GetCount(); ; i++) {
@ -615,14 +617,14 @@ WXLRESULT wxZRColaFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM
// wxPersistentZRColaFrame
//////////////////////////////////////////////////////////////////////////
wxPersistentZRColaFrame::wxPersistentZRColaFrame(wxZRColaFrame *wnd) : wxPersistentTLW(wnd)
wxPersistentZRColaFrame::wxPersistentZRColaFrame(wxZRColaFrame *wnd) : wxPersistentTLWEx(wnd)
{
}
void wxPersistentZRColaFrame::Save() const
{
wxPersistentTLW::Save();
wxPersistentTLWEx::Save();
auto wnd = static_cast<const wxZRColaFrame*>(GetWindow()); // dynamic_cast is not reliable as we are typically called late in the wxTopLevelWindowMSW destructor.
@ -644,5 +646,5 @@ bool wxPersistentZRColaFrame::Restore()
if (RestoreValue(wxT("transeqId"), &num))
wnd->m_transeq_id = num;
return wxPersistentTLW::Restore();
return wxPersistentTLWEx::Restore();
}

View File

@ -21,6 +21,7 @@
/// Forward declarations
///
class wxZRColaFrame;
class wxPersistentZRColaFrame;
#pragma once
@ -32,8 +33,8 @@ class wxZRColaFrame;
#include "zrcolatranseq.h"
#include <zrcola/language.h>
#include <zrcola/translate.h>
#include <wxex/persist/toplevel.h>
#include <wx/taskbar.h>
#include <wx/persist/toplevel.h>
#if defined(__WXMSW__)
#include <msctf.h>
#endif
@ -136,7 +137,7 @@ protected:
///
/// Supports saving/restoring wxZRColaFrame GUI state
///
class wxPersistentZRColaFrame : public wxPersistentTLW
class wxPersistentZRColaFrame : public wxPersistentTLWEx
{
public:
wxPersistentZRColaFrame(wxZRColaFrame *wnd);

View File

@ -139,14 +139,14 @@ void wxZRColaSettings::OnOKButtonClick(wxCommandEvent& event)
// wxPersistentZRColaSettings
//////////////////////////////////////////////////////////////////////////
wxPersistentZRColaSettings::wxPersistentZRColaSettings(wxZRColaSettings *wnd) : wxPersistentDialog(wnd)
wxPersistentZRColaSettings::wxPersistentZRColaSettings(wxZRColaSettings *wnd) : wxPersistentTLWEx(wnd)
{
}
void wxPersistentZRColaSettings::Save() const
{
wxPersistentDialog::Save();
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 +177,5 @@ bool wxPersistentZRColaSettings::Restore()
} else
wnd->m_lang = ZRCola::langid_t::blank;
return wxPersistentDialog::Restore();
return wxPersistentTLWEx::Restore();
}

View File

@ -27,7 +27,7 @@ class wxPersistentZRColaSettings;
#pragma once
#include "zrcolagui.h"
#include <wxex/persist/dialog.h>
#include <wxex/persist/toplevel.h>
#include <vector>
@ -56,7 +56,7 @@ public:
///
/// Supports saving/restoring wxZRColaSettings state
///
class wxPersistentZRColaSettings : public wxPersistentDialog
class wxPersistentZRColaSettings : public wxPersistentTLWEx
{
public:
wxPersistentZRColaSettings(wxZRColaSettings *wnd);

View File

@ -208,14 +208,14 @@ void wxZRColaTranslationSeq::OnOKButtonClick(wxCommandEvent& event)
// wxPersistentZRColaTranslationSeq
//////////////////////////////////////////////////////////////////////////
wxPersistentZRColaTranslationSeq::wxPersistentZRColaTranslationSeq(wxZRColaTranslationSeq *wnd) : wxPersistentDialog(wnd)
wxPersistentZRColaTranslationSeq::wxPersistentZRColaTranslationSeq(wxZRColaTranslationSeq *wnd) : wxPersistentTLWEx(wnd)
{
}
void wxPersistentZRColaTranslationSeq::Save() const
{
wxPersistentDialog::Save();
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 +249,5 @@ bool wxPersistentZRColaTranslationSeq::Restore()
wnd->m_transeq = std::move(transet);
}
return wxPersistentDialog::Restore();
return wxPersistentTLWEx::Restore();
}

View File

@ -28,7 +28,7 @@ class wxPersistentZRColaTranslationSeq;
#include "zrcolagui.h"
#include <zrcola/translate.h>
#include <wxex/persist/dialog.h>
#include <wxex/persist/toplevel.h>
#include <vector>
@ -64,7 +64,7 @@ public:
///
/// Supports saving/restoring wxZRColaTranslationSeq state
///
class wxPersistentZRColaTranslationSeq : public wxPersistentDialog
class wxPersistentZRColaTranslationSeq : public wxPersistentTLWEx
{
public:
wxPersistentZRColaTranslationSeq(wxZRColaTranslationSeq *wnd);

@ -1 +1 @@
Subproject commit 1b11ccf4a2abb5c62a2972f554cf6d40e4b71dbc
Subproject commit 5a912ebcc6d5d2887628387eae7fc5c8105d7938