[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] wx pre-3.3.0 warning

From: Vadim Zeitlin
Subject: Re: [lmi] wx pre-3.3.0 warning
Date: Fri, 5 May 2023 14:55:41 +0200

On Fri, 5 May 2023 01:01:18 +0000 Greg Chicares <gchicares@sbcglobal.net> wrote:

GC> On 5/5/23 00:18, Vadim Zeitlin wrote:
GC> > On Fri, 5 May 2023 00:08:58 +0000 Greg Chicares <gchicares@sbcglobal.net> 
GC> [...]
GC> > GC> 
GC> > GC>     // setting self as a wxPanel
GC> > GC>     wxPanel::Create(parent, id, pos, size);
GC> > GC>     ...
GC> > GC>     wxStaticBoxSizer* const sizer =
GC> > GC>         new(wx) wxStaticBoxSizer(wxHORIZONTAL, this, "Axis");
GC> > GC> 
GC> > GC> where no explicit wxStaticBox is created at all.
GC> > 
GC> >  It's created implicitly by wxStaticBoxSizer and can be retrieved (in 
GC> > to be used as parent for the other windows) using its GetStaticBox()
GC> > function.
GC> Then is it preferable to create a wxStaticBox explicitly first,

 There shouldn't be any difference between creating the wxStaticBox
yourself and letting wxStaticBoxSizer do it for you as a convenience, it's
just a matter of whether you prefer to be more brief or moe explicit.

GC> and use that (not the wxPanel) as a parent when creating the
GC> wxStaticBoxSizer, as in the patch below? This patch does seem
GC> to prevent the diagnostic from occurring.
GC> +    wxStaticBox* static_box = new(wx) wxStaticBox(this, wxID_ANY, "");
GC>      wxStaticBoxSizer* const sizer =
GC> -        new(wx) wxStaticBoxSizer(wxHORIZONTAL, this, "Axis");
GC> +        new(wx) wxStaticBoxSizer(wxHORIZONTAL, static_box, "Axis");

 No, sorry, this is not what I meant: it's the parent of windows added to
wxStaticBoxSizer which matters, not the window passed to its ctor, as this
makes it still create (another) wxStaticBox using the provided static_box
as parent.

 If you want to use wxStaticBoxSizer with the provided wxStaticBox, you
need to create it like this instead

        wxStaticBox* static_box = new(wx) wxStaticBox(this, wxID_ANY, "Axis");
        wxStaticBoxSizer* const sizer =
            new(wx) wxStaticBox(static_box, wxHORIZONTAL);

GC> However, clearly I'm in over my head here, and maybe I should
GC> just leave well enough alone, following Pope:
GC>   "Drink deep, or taste not the Pierian spring"

 I'm afraid you do indeed to dive even deeper into this to really fix it,
as it's the parent of all windows used inside this sizer that needs to be
changed, not just the way the sizer is created.

 As you say, I'm not sure if it's worth doing it right now, even if, in
principle, this is the recommended and preferred way of using


Attachment: pgpxbltIp9bVD.pgp
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]