From dea6a38d308cb4e709689f152527f0de5e79cd34 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Tue, 4 Nov 2025 15:51:13 +0100 Subject: [PATCH] Discontinue perspective caption manipulation Reference: https://github.com/wxWidgets/wxWidgets/issues/12528 Signed-off-by: Simon Rozman --- build/wxExtend.props | 2 - build/wxExtendDll.vcxproj.filters | 6 - build/wxExtendLib.vcxproj.filters | 6 - include/wxex/aui/framemanager.h | 33 ----- include/wxex/persist/auimanager.h | 219 +++++++++++++++--------------- src/framemanager.cpp | 122 ----------------- src/pch.h | 2 - 7 files changed, 107 insertions(+), 283 deletions(-) delete mode 100644 include/wxex/aui/framemanager.h delete mode 100644 src/framemanager.cpp diff --git a/build/wxExtend.props b/build/wxExtend.props index 569a66d..96c7d62 100644 --- a/build/wxExtend.props +++ b/build/wxExtend.props @@ -16,7 +16,6 @@ - @@ -30,7 +29,6 @@ - diff --git a/build/wxExtendDll.vcxproj.filters b/build/wxExtendDll.vcxproj.filters index 842f9aa..716ddcc 100644 --- a/build/wxExtendDll.vcxproj.filters +++ b/build/wxExtendDll.vcxproj.filters @@ -55,9 +55,6 @@ Source Files - - Source Files - Source Files @@ -102,9 +99,6 @@ Header Files - - Header Files\aui - Header Files diff --git a/build/wxExtendLib.vcxproj.filters b/build/wxExtendLib.vcxproj.filters index f194d7b..74ff275 100644 --- a/build/wxExtendLib.vcxproj.filters +++ b/build/wxExtendLib.vcxproj.filters @@ -55,9 +55,6 @@ Source Files - - Source Files - Source Files @@ -102,9 +99,6 @@ Header Files - - Header Files\aui - Header Files diff --git a/include/wxex/aui/framemanager.h b/include/wxex/aui/framemanager.h deleted file mode 100644 index 67d9a30..0000000 --- a/include/wxex/aui/framemanager.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - ​​​SPDX-License-Identifier: GPL-3.0-or-later - Copyright © 2015-2022 Amebis - Copyright © 2016 GÉANT -*/ - -#pragma once - -#include "../common.h" - -#include -#pragma warning(push) -#pragma warning(disable: WXWIDGETS_CODE_ANALYSIS_WARNINGS) -#include -#include -#pragma warning(pop) - -/// \addtogroup wxExtend -/// @{ - -/// -/// Updates perspective captions with matching captions from panes. -/// -/// \param[in ] mgr wxAUI manager -/// \param[inout] perspective Perspective string to update captions in -/// -/// \returns -/// - \c true when update succeeded -/// - \c false otherwise -/// -bool WXEXTEND_API wxAuiManagerUpdatePerspectiveCaptions(wxAuiManager& mgr, wxString& perspective); - -/// @} diff --git a/include/wxex/persist/auimanager.h b/include/wxex/persist/auimanager.h index 34c346c..0e0bfd9 100644 --- a/include/wxex/persist/auimanager.h +++ b/include/wxex/persist/auimanager.h @@ -1,112 +1,107 @@ -/* - ​​​SPDX-License-Identifier: GPL-3.0-or-later - Copyright © 2015-2022 Amebis - Copyright © 2016 GÉANT -*/ - -#pragma once - -#include "../common.h" - -#include "../aui/framemanager.h" - -#include -#pragma warning(push) -#pragma warning(disable: WXWIDGETS_CODE_ANALYSIS_WARNINGS) -#include -#include -#pragma warning(pop) - - -/// \addtogroup wxExtend -/// @{ - -/// -/// `wxPersistentAuiManager` kind for persistent storage -/// -#define wxPERSIST_AUIMGR_KIND "AuiManager" - -/// -/// Name of the persistent storage variable for saving Aui manager state -/// -#define wxPERSIST_AUIMGR_PERSPECTIVE "perspective" - -/// -/// Supports saving/restoring wxAuiManager state -/// -class wxPersistentAuiManager : public wxPersistentObject -{ -public: - /// - /// Constructs a persistent Aui manager object - /// - wxPersistentAuiManager(wxAuiManager *mgr) : wxPersistentObject(mgr) - { - } - - /// - /// \returns `wxT(wxPERSIST_AUIMGR_KIND)` - /// - virtual wxString GetKind() const wxOVERRIDE - { - return wxT(wxPERSIST_AUIMGR_KIND); - } - - /// - /// Returns name of the window - /// - virtual wxString GetName() const wxOVERRIDE - { - // Borrow the name of wxAguiManager from its window. - return GetManager()->GetManagedWindow()->GetName(); - } - - /// - /// Saves Aui manager state - /// - virtual void Save() const wxOVERRIDE - { - // Save perspective string to configuration. - SaveValue(wxT(wxPERSIST_AUIMGR_PERSPECTIVE), GetManager()->SavePerspective()); - } - - /// - /// Restores Aui manager state - /// - virtual bool Restore() wxOVERRIDE - { - // Load perspective string from configuration. - wxString persp; - if (!RestoreValue(wxT(wxPERSIST_AUIMGR_PERSPECTIVE), &persp)) - return false; - - // Update captions (see http://trac.wxwidgets.org/ticket/12528). - wxAuiManager* mgr = GetManager(); - wxCHECK(wxAuiManagerUpdatePerspectiveCaptions(*mgr, persp), false); - - // Restore perspective. - return mgr->LoadPerspective(persp); - } - -protected: - /// \cond internal - wxAuiManager *GetManager() const - { - return static_cast(GetObject()); - } - /// \endcond - -private: - wxDECLARE_NO_COPY_CLASS(wxPersistentAuiManager); -}; - - -/// -/// wxAuiManager's instantiation of wxCreatePersistentObject template -/// -inline wxPersistentObject *wxCreatePersistentObject(wxAuiManager *mgr) -{ - return new wxPersistentAuiManager(mgr); -} - -/// @} +/* + ​​​SPDX-License-Identifier: GPL-3.0-or-later + Copyright © 2015-2022 Amebis + Copyright © 2016 GÉANT +*/ + +#pragma once + +#include "../common.h" + +#include +#pragma warning(push) +#pragma warning(disable: WXWIDGETS_CODE_ANALYSIS_WARNINGS) +#include +#include +#pragma warning(pop) + + +/// \addtogroup wxExtend +/// @{ + +/// +/// `wxPersistentAuiManager` kind for persistent storage +/// +#define wxPERSIST_AUIMGR_KIND "AuiManager" + +/// +/// Name of the persistent storage variable for saving Aui manager state +/// +#define wxPERSIST_AUIMGR_PERSPECTIVE "perspective" + +/// +/// Supports saving/restoring wxAuiManager state +/// +class wxPersistentAuiManager : public wxPersistentObject +{ +public: + /// + /// Constructs a persistent Aui manager object + /// + wxPersistentAuiManager(wxAuiManager *mgr) : wxPersistentObject(mgr) + { + } + + /// + /// \returns `wxT(wxPERSIST_AUIMGR_KIND)` + /// + virtual wxString GetKind() const wxOVERRIDE + { + return wxT(wxPERSIST_AUIMGR_KIND); + } + + /// + /// Returns name of the window + /// + virtual wxString GetName() const wxOVERRIDE + { + // Borrow the name of wxAguiManager from its window. + return GetManager()->GetManagedWindow()->GetName(); + } + + /// + /// Saves Aui manager state + /// + virtual void Save() const wxOVERRIDE + { + // Save perspective string to configuration. + SaveValue(wxT(wxPERSIST_AUIMGR_PERSPECTIVE), GetManager()->SavePerspective()); + } + + /// + /// Restores Aui manager state + /// + virtual bool Restore() wxOVERRIDE + { + // Load perspective string from configuration. + wxString persp; + if (!RestoreValue(wxT(wxPERSIST_AUIMGR_PERSPECTIVE), &persp)) + return false; + + // Restore perspective. + wxAuiManager* mgr = GetManager(); + return mgr->LoadPerspective(persp); + } + +protected: + /// \cond internal + wxAuiManager *GetManager() const + { + return static_cast(GetObject()); + } + /// \endcond + +private: + wxDECLARE_NO_COPY_CLASS(wxPersistentAuiManager); +}; + + +/// +/// wxAuiManager's instantiation of wxCreatePersistentObject template +/// +inline wxPersistentObject *wxCreatePersistentObject(wxAuiManager *mgr) +{ + return new wxPersistentAuiManager(mgr); +} + +/// @} diff --git a/src/framemanager.cpp b/src/framemanager.cpp deleted file mode 100644 index 844df0c..0000000 --- a/src/framemanager.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/* - ​​​SPDX-License-Identifier: GPL-3.0-or-later - Copyright © 2015-2022 Amebis - Copyright © 2016 GÉANT -*/ - -#include "pch.h" - - -bool WXEXTEND_API wxAuiManagerUpdatePerspectiveCaptions(wxAuiManager& mgr, wxString& perspective) -{ - wxString input = perspective; - wxString part; - - // check layout string version - // 'layout1' = wxAUI 0.9.0 - wxAUI 0.9.2 - // 'layout2' = wxAUI 0.9.2 (wxWidgets 2.8) - part = input.BeforeFirst(wxT('|')); - input = input.AfterFirst(wxT('|')); - part.Trim(true); - part.Trim(false); - if (part != wxT("layout2")) - return false; - - wxString result; - result.Alloc(500); - result = wxT("layout2|"); - - // replace escaped characters so we can - // split up the string easily - input.Replace(wxT("\\|"), wxT("\a")); - input.Replace(wxT("\\;"), wxT("\b")); - - wxSize ppi = wxClientDC(mgr.GetManagedWindow()).GetPPI(); - wxSize ppi_on_save(96, 96); - while (1) - { - wxString pane_part = input.BeforeFirst(wxT('|')); - input = input.AfterFirst(wxT('|')); - pane_part.Trim(true); - - // if the string is empty, we're done parsing - if (pane_part.empty()) - break; - - // Undo our escaping - pane_part.Replace(wxT("\a"), wxT("|")); - pane_part.Replace(wxT("\b"), wxT(";")); - - if (pane_part.Left(3) == wxT("ppi")) - { - wxString value = pane_part.AfterFirst(wxT('=')); - - long ppi_horz, ppi_vert; - value.BeforeFirst(wxT(',')).ToLong(&ppi_horz); - value.AfterFirst(wxT(',')).ToLong(&ppi_vert); - - ppi_on_save.x = ppi_horz; - ppi_on_save.y = ppi_vert; - result += wxString::Format(wxT("ppi=%d,%d|"), - ppi.x, ppi.y); - continue; - } - else if (pane_part.Left(9) == wxT("dock_size")) - { - wxString val_name = pane_part.BeforeFirst(wxT('=')); - wxString value = pane_part.AfterFirst(wxT('=')); - - long dir, layer, row, size; - wxString piece = val_name.AfterFirst(wxT('(')); - piece = piece.BeforeLast(wxT(')')); - piece.BeforeFirst(wxT(',')).ToLong(&dir); - piece = piece.AfterFirst(wxT(',')); - piece.BeforeFirst(wxT(',')).ToLong(&layer); - piece.AfterFirst(wxT(',')).ToLong(&row); - value.ToLong(&size); - - wxAuiDockInfo dock; - dock.dock_direction = dir; - dock.dock_layer = layer; - dock.dock_row = row; - dock.size = size == -1 ? -1 : - dock.IsHorizontal() ? wxMulDivInt32(size, ppi.x, ppi_on_save.x) : - wxMulDivInt32(size, ppi.y, ppi_on_save.y); - - result += wxString::Format(wxT("dock_size(%d,%d,%d)=%d|"), - dock.dock_direction, dock.dock_layer, - dock.dock_row, dock.size); - continue; - } - - wxAuiPaneInfo pane; - mgr.LoadPaneInfo(pane_part, pane, ppi_on_save); - - wxAuiPaneInfo& p = mgr.GetPane(pane.name); - if (!p.IsOk()) - { - // the pane window couldn't be found - // in the existing layout -- skip it - continue; - } - - // Update caption. - pane.caption = p.caption; - - // Reset best/min/max sizes to allow resize on GUI changes across different versions. - pane.best_size = p.best_size; - pane.min_size = p.min_size; - pane.max_size = p.max_size; - - if ((pane.state & wxAuiPaneInfo::optionResizable) == 0) { - // Reset floating size to allow resize on GUI changes across different versions for non-resizeable panes. - pane.floating_size = p.floating_size; - } - - // Re-generate and append pane info. - result += mgr.SavePaneInfo(pane) + wxT('|'); - } - - perspective = result; - return true; -} diff --git a/src/pch.h b/src/pch.h index 827eb54..ba1494a 100644 --- a/src/pch.h +++ b/src/pch.h @@ -14,8 +14,6 @@ #include #pragma warning(pop) -#include "../include/wxex/aui/framemanager.h" - #include "../include/wxex/persist/auimanager.h" #include "../include/wxex/persist/toplevel.h"