On Thu, 8 Dec 2016 17:47:18 -0800 (PST) Andrew Haas wrote:
AH> I am getting back into coding after 9 years, so I'm embarrassed about my
AH> code.
There is nothing to be embarrassed about, but please do try to minimize
the amount of code you post here, it's difficult to read all of it and at
least some parts of it are completely unnecessary to reproduce the problem
(e.g. all this fine-grained wxGrid setup, like enabling grid lines and what
not).
It's also great to provide some code that could actually be compiled and
tested, to allow other to reproduce your problem. Ideal is to make a small
patch (please see
http://trac.wxwidgets.org/wiki/HowToSubmitPatches which
describes how to make patches, even if in a different context) to a sample,
e.g. the "grid" one in your case (or "minimal" if the grid one is too
complex to modify easily).
Anyhow, I did look at the code and I don't see anything wrong with it, so
I suspect the problem is in the part you're not showing us. All I can say
is that it's definitely not how things work in wxWidgets, windows managed
by sizers do not overlap. Please try reproducing the problem with minimal
amount of code, you'll likely find the bug while doing it.
This being said, a few small remarks about your code, not directly related
to the problem, but which can still be useful:
AH> But here is the setup code for the dialog, and then the code to populate
AH> the grid upon adding rows.
AH>
AH> wxFlexGridSizer *mainFlexgrid = new wxFlexGridSizer(3, 1, 10, 10);
This is a pretty strange way to do layout, what's the point of using a
wxFlexGridSizer with a single column? You could use a vertical wxBoxSizer
and make your code much simpler.
Of course, if you really insist on using wxFlexGridSizer, this works too,
but it's unnecessarily complicated.
AH> topSizer->Add(securitiesLabel, 0, wxALL, 5);
Here and elsewhere, do yourself a favour and start using wxSizerFlags (see
the examples in the documentation) instead of using this cryptic overload.
With this class this line would be just
topSizer->Add(securitiesLabel, wxSizerFlags().Border());
which is much more readable (and also more correct, as 5px is not always
the right border size to use).
AH> wxPanel * panel = new wxPanel(this, -1);
AH> panel->SetSizer(mainFlexgrid);
AH> mainFlexgrid->AddGrowableRow(1);
AH> mainFlexgrid->AddGrowableCol(0);
AH> wxFlexGridSizer* topSizer = new wxFlexGridSizer(1, 2, 5, 5);
Same as above, this could be replaced by a horizontal wxBoxSizer.
AH> m_grid = new wxGrid(panel, Grid, wxDefaultPosition, wxDefaultSize, 0);
...
AH> mainFlexgrid->Add(topSizer, 0, wxEXPAND);
AH> mainFlexgrid->Add(m_grid,0,wxEXPAND);
AH> mainFlexgrid->Add(bottomSizer, 0, wxRIGHT);
AH> this->Layout();
The last line is unnecessary.
AH> This code populates the grid:
...
AH> m_grid->AutoSize();
AH> m_grid->FitInside();
AH> this->Layout();
This FitInside() is unnecessary too, I think, but, again, there is nothing
really wrong with it.
Regards,
VZ