[Top][All Lists]

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

[lmi] Wrong wxFlexGridSizer usage in about_dialog.cpp

From: Vadim Zeitlin
Subject: [lmi] Wrong wxFlexGridSizer usage in about_dialog.cpp
Date: Tue, 20 Oct 2009 17:46:14 +0200


 AboutDialog::ShowModal() in about_dialog.cpp creates 2 sizes using this
ctor: new wxFlexGridSizer(0, 1). This doesn't compile any more with the
latest wx svn trunk and for a good reason: usually such 2 argument ctor is
used by mistake and it seems that this was indeed the case here.

 In previous wx version (until 2.9.0) using wxFlexGridSizer ctor with 2
arguments used wxFlexGridSizer(int cols, int vgap = 0, int hgap = 0)
overload. I.e. what this call did was creating a sizer with automatically
determined number of columns, vertical gap between rows of 1 pixel and
horizontal gap of 0 pixels.

 However LMI code proceeds by calling AddGrowableCol(0) and
AddGrowableCol(1) which seems to indicate that the intention was to create
a sizer with 2 columns and one row. I.e. the constructor should be really
replaced with wxFlexGridSizer(/* cols = */2).

 Similarly, the call to new wxFlexGridSizer(1, 0) below was probably meant
to create a one column sizer and so should be replaced with
wxFlexGridSizer(1). This would work with both 2.8, 2.9.0 and latest svn and
do the right thing so here is the trivial patch which I suggest to apply:

--- about_dialog.cpp    revid:address@hidden
+++ about_dialog.cpp    2009-10-09 13:20:43 +0000
@@ -87,13 +87,13 @@
         ,"Let me illustrate"

-    wxFlexGridSizer* sizer1 = new wxFlexGridSizer(0, 1);
+    wxFlexGridSizer* sizer1 = new wxFlexGridSizer(2);
     sizer1->Add(license_button, 1, wxALL|wxALIGN_LEFT , 5);
     sizer1->Add(cancel_button , 1, wxALL|wxALIGN_RIGHT, 5);

-    wxFlexGridSizer* sizer0 = new wxFlexGridSizer(1, 0);
+    wxFlexGridSizer* sizer0 = new wxFlexGridSizer(1);
     sizer0->Add(html_window, 1, wxALL, 10);
     sizer0->Add(sizer1     , 1, wxALL, 10);

 FWIW I, as usual, wouldn't use wxFlexGridSizer here at all: a simple
combination of wxBoxSizer(wxHORIZONTAL) for the buttons and
wxBoxSizer(wxVERTICAL) containing the HTML window and the buttons sizer
would be simpler to understand IMO. I can, of course, make another patch if
you agree.


reply via email to

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