What is wrong with my sizers?

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
MadBoat
In need of some credit
In need of some credit
Posts: 2
Joined: Mon Aug 17, 2015 5:23 pm

What is wrong with my sizers?

Post by MadBoat » Mon Aug 17, 2015 5:29 pm

Originally posted this over in the codeblocks forum (http://forums.codeblocks.org/index.php/ ... 508.0.html), who suggested I ought to ask people in the wxWidgets community.
--------------

Yesterday I was fiddling with some unrelated problems (AFAIK), and suddenly the sizers (both box sizers and grid sizers) I use in the new window I'm working on stop doing anything. I kept paring away functionality from my window until it's idiot-simple, and I still can't get the sizers to DO anything. The problem does seem to be limited to this new window, but I have no idea why.

I give up. Can you see anything I've done wrong?

BotsSummaryWindow4.h

Code: Select all

#include <editorbase.h>
#include <wx/sizer.h>
#include <wx/button.h>

class BotsSummaryWindow4 : public EditorBase
{
    public:
    BotsSummaryWindow4(wxWindow * parent, wxString title);

};
MAD_Debugging_support.cpp

Code: Select all

...
void MAD_Debugging_Support::OnHitSummaryWindow(wxCommandEvent& event)
{
    DoStartSummary();
}

void MAD_Debugging_Support::DoStartSummary()
{
    if (!m_summaryDisplayed)
    {
        m_summaryDisplay = new BotsSummaryWindow4((wxWindow *) Manager::Get()->GetEditorManager()->GetNotebook(), wxT("BotsDisplay"));
        m_summaryDisplayed = true;
    }
    m_summaryDisplay->SetFocus();
}
...
BotsSummaryWindow4.cpp

Code: Select all

#include "BotsSummaryWindow4.h"
BotsSummaryWindow4::BotsSummaryWindow4(wxWindow * parent, wxString title) : EditorBase(parent, title)
{
    wxBoxSizer *        buttonsSizer = new wxBoxSizer(wxHORIZONTAL);
    wxPanel *           helpMeObiwan = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(500, 500));
    wxButton *          west = new wxButton(helpMeObiwan, wxID_ANY, _T("west"), wxPoint(100, 100));
    wxButton *          east = new wxButton(helpMeObiwan, wxID_ANY, _T("east"), wxPoint(110, 110));

    buttonsSizer->Add(west, TRUE, wxEXPAND | wxALL, 1);
    buttonsSizer->Add(east, TRUE, wxEXPAND | wxALL, 1);
    helpMeObiwan->SetSizer(buttonsSizer);
}
how it looks
Image

This is identical to how it appears if I don't use sizers at all.

jgrzybowski
Earned some good credits
Earned some good credits
Posts: 113
Joined: Sat Sep 24, 2011 9:32 pm
Location: Poland

Re: What is wrong with my sizers?

Post by jgrzybowski » Mon Aug 17, 2015 10:04 pm

I use wxDevC++ with designer (RAD), which create such a code automatically, and it looks like this:

Code: Select all

wxBoxSizer * buttonsSizer = new wxBoxSizer(wxHORIZONTAL);
this->SetSizer(buttonsSizer);
this->SetAutoLayout(true);

wxButton * west = new wxButton(this, wxID_ANY, _T("west"), wxPoint(100, 100));
wxButton * east = new wxButton(this, wxID_ANY, _T("east"), wxPoint(110, 110));

buttonsSizer->Add(west, TRUE, wxEXPAND | wxALL, 1);
buttonsSizer->Add(east, TRUE, wxEXPAND | wxALL, 1);

GetSizer()->Layout();
GetSizer()->Fit(this);
GetSizer()->SetSizeHints(this);
Center();
Regards, Jarek

MadBoat
In need of some credit
In need of some credit
Posts: 2
Joined: Mon Aug 17, 2015 5:23 pm

Re: What is wrong with my sizers?

Post by MadBoat » Mon Aug 17, 2015 11:52 pm

That did it, thanks Jarek.

Post Reply