[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] wx pre-3.3.0 warning
From: |
Greg Chicares |
Subject: |
Re: [lmi] wx pre-3.3.0 warning |
Date: |
Fri, 5 May 2023 01:01:18 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 |
On 5/5/23 00:18, Vadim Zeitlin wrote:
> On Fri, 5 May 2023 00:08:58 +0000 Greg Chicares <gchicares@sbcglobal.net>
> wrote:
[...]
> GC>
> GC> // setting self as a wxPanel
> GC> wxPanel::Create(parent, id, pos, size);
> GC> ...
> GC> wxStaticBoxSizer* const sizer =
> GC> new(wx) wxStaticBoxSizer(wxHORIZONTAL, this, "Axis");
> GC>
> GC> where no explicit wxStaticBox is created at all.
>
> It's created implicitly by wxStaticBoxSizer and can be retrieved (in order
> to be used as parent for the other windows) using its GetStaticBox()
> function.
Then is it preferable to create a wxStaticBox explicitly first,
and use that (not the wxPanel) as a parent when creating the
wxStaticBoxSizer, as in the patch below? This patch does seem
to prevent the diagnostic from occurring.
--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<
diff --git a/multidimgrid_any.cpp b/multidimgrid_any.cpp
index 2987fb439..0c5c6d7c4 100644
--- a/multidimgrid_any.cpp
+++ b/multidimgrid_any.cpp
@@ -33,6 +33,7 @@
#include <wx/gbsizer.h>
#include <wx/msgdlg.h>
#include <wx/sizer.h>
+#include <wx/statbox.h>
#include <wx/stattext.h>
#include <wx/window.h>
#include <wx/wupdlock.h>
@@ -346,8 +347,9 @@ bool MultiDimGrid::Create
axis_adjust_wins_.resize(dimension_);
axis_varies_checkboxes_.resize(dimension_);
+ wxStaticBox* static_box = new(wx) wxStaticBox(this, wxID_ANY, "");
wxStaticBoxSizer* const sizer =
- new(wx) wxStaticBoxSizer(wxHORIZONTAL, this, "Axis");
+ new(wx) wxStaticBoxSizer(wxHORIZONTAL, static_box, "Axis");
// wxGridBagSizer(vgap, hgap)
axis_sizer_ = new(wx) wxGridBagSizer(MDGRID_SIZER_VGAP, MDGRID_SIZER_HGAP);
--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<
I had tried this instead:
--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<
// main sizer contains axis controls in the left part and the grid in the
right
wxBoxSizer* const grid_sizer = new(wx) wxBoxSizer(wxHORIZONTAL);
grid_sizer->Add
- (sizer
+ (sizer->GetStaticBox()
,wxSizerFlags()
.Expand()
.Border(wxLEFT | wxRIGHT, MDGRID_SIZER_HGAP)
--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<
but that resulted in:
Assertion '"!m_containingSizer"' failed
(Adding a window already in a sizer, detach it first!).
[file /opt/lmi/src/lmi/third_party/wx/src/common/wincmn.cpp, line 2442]
However, clearly I'm in over my head here, and maybe I should
just leave well enough alone, following Pope:
"Drink deep, or taste not the Pierian spring"