From cb774bb3058e0bce5c0d3e9775747bc44e75f2dd Mon Sep 17 00:00:00 2001 From: Bill Su Date: Thu, 9 Jul 2026 20:00:31 -0400 Subject: [PATCH] Ensure that wxAuiNotebook center pane uses expected dock values Avoid the wxAuiNotebook center pane having non-zero dock_layer, dock_row, or dock_pos values as it doesn't make sense for it. Closes #26679. --- docs/changes.txt | 4 ++++ include/wx/aui/framemanager.h | 13 ++++++++++--- src/aui/floatpane.cpp | 3 +-- src/aui/framemanager.cpp | 6 ++++++ 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 0573257418..1e7e3afd2c 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -145,6 +145,10 @@ Changes in behaviour not resulting in compilation errors wxTextDataObject, but for the code working with the raw bytes in this format you may need to change it to use wxConvUTF8 instead of wxConvLocal. +- Creating central wxAUI pane window with non-zero layer, row or position + values was previously silently allowed but couldn't work correctly, so now + attempting to do it will assert. Don't set these values for the central pane. + Changes in behaviour which may result in build errors ----------------------------------------------------- diff --git a/include/wx/aui/framemanager.h b/include/wx/aui/framemanager.h index bf2502f2e9..efddbc0567 100644 --- a/include/wx/aui/framemanager.h +++ b/include/wx/aui/framemanager.h @@ -243,9 +243,16 @@ public: wxAuiPaneInfo& Right() { dock_direction = wxAUI_DOCK_RIGHT; return *this; } wxAuiPaneInfo& Top() { dock_direction = wxAUI_DOCK_TOP; return *this; } wxAuiPaneInfo& Bottom() { dock_direction = wxAUI_DOCK_BOTTOM; return *this; } - wxAuiPaneInfo& Center() { dock_direction = wxAUI_DOCK_CENTER; return *this; } - wxAuiPaneInfo& Centre() { dock_direction = wxAUI_DOCK_CENTRE; return *this; } - wxAuiPaneInfo& Direction(int direction) { dock_direction = direction; return *this; } + wxAuiPaneInfo& Center() { dock_direction = wxAUI_DOCK_CENTER; return Layer(0).Row(0).Position(0); } + wxAuiPaneInfo& Centre() { dock_direction = wxAUI_DOCK_CENTRE; return Layer(0).Row(0).Position(0); } + wxAuiPaneInfo& Direction(int direction) + { + if (dock_direction == wxAUI_DOCK_CENTRE) + return Centre(); + + dock_direction = direction; + return *this; + } wxAuiPaneInfo& Layer(int layer) { dock_layer = layer; return *this; } wxAuiPaneInfo& Row(int row) { dock_row = row; return *this; } wxAuiPaneInfo& Position(int pos) { dock_pos = pos; return *this; } diff --git a/src/aui/floatpane.cpp b/src/aui/floatpane.cpp index 3785f15b36..ef8275d37c 100644 --- a/src/aui/floatpane.cpp +++ b/src/aui/floatpane.cpp @@ -85,8 +85,7 @@ void wxAuiFloatingFrame::SetPaneWindow(const wxAuiPaneInfo& pane) wxAuiPaneInfo contained_pane = pane; contained_pane.Dock().Center().Show(). CaptionVisible(false). - PaneBorder(false). - Layer(0).Row(0).Position(0); + PaneBorder(false); // Carry over the minimum size wxSize pane_min_size = pane.window->GetMinSize(); diff --git a/src/aui/framemanager.cpp b/src/aui/framemanager.cpp index 2c314cc4c7..4356fbb311 100644 --- a/src/aui/framemanager.cpp +++ b/src/aui/framemanager.cpp @@ -532,6 +532,12 @@ static int PaneSortFunc(wxAuiPaneInfo** p1, wxAuiPaneInfo** p2) bool wxAuiPaneInfo::IsValid() const { + if ( dock_direction == wxAUI_DOCK_CENTRE && + !(dock_layer == 0 && dock_row == 0 && dock_pos == 0) ) + { + return false; + } + // Should this RTTI and function call be rewritten as // sending a new event type to allow other window types // to check the pane settings?