User forums > General (but related to Code::Blocks)

A request about auto-generated code by wxSmith

(1/1)

hirofield:
Hi,

First of all. thanks to all the members who develop such an excellent software.
This time let me make a request related to auto-generated code by wxSmith.

I'm testing a  wxFrame based program which has fixed sized frame.
I created a new frame based wxSmith project, then deleted the MenuBar1 and the StatusBar1
which are automatically added by default.   In this situation, the codes of frame constructor is
as follows.


--- Code: ---SizeTestFrame::SizeTestFrame(wxWindow* parent,wxWindowID id)
{
    //(*Initialize(SizeTestFrame)
    Create(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("id"));
    //*)
}

--- End code ---

Next, I unchecked the [Default size] checkbox in the property editor, then set Width 300 and Height 200.
The codes of constructor was changed as follows.


--- Code: ---SizeTestFrame::SizeTestFrame(wxWindow* parent,wxWindowID id)
{
    //(*Initialize(SizeTestFrame)
    Create(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("id"));
    SetClientSize(wxSize(300,200));
    //*)
}
--- End code ---

After that, I placed a BoxSizer into the Frame on the GUI designer screen.  Then the frame was shrunk
to very small size, and the constructor codes are changed:


--- Code: ---SizeTestFrame::SizeTestFrame(wxWindow* parent,wxWindowID id)
{
    //(*Initialize(SizeTestFrame)
    wxBoxSizer* BoxSizer1;

    Create(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("id"));
    SetClientSize(wxSize(300,200));
    BoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
    SetSizer(BoxSizer1);
    BoxSizer1->SetSizeHints(this);
    //*)
}

--- End code ---

This means the size setting by SetClientSize(wxSize(300,200)); is ignored.
I suppose it's a spec or a bug of wxWidgets, so I manually added SetClientSize(wxSize(300,200));
again after the auto-generated codes:


--- Code: ---SizeTestFrame::SizeTestFrame(wxWindow* parent,wxWindowID id)
{
    //(*Initialize(SizeTestFrame)
    wxBoxSizer* BoxSizer1;

    Create(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("id"));
    SetClientSize(wxSize(300,200));
    BoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
    SetSizer(BoxSizer1);
    BoxSizer1->SetSizeHints(this);
    //*)

    SetClientSize(wxSize(300,200));
}

--- End code ---

Then the frame was shown at the expected size on runtime.  But the frame is still shrunk on the
GUI designer even clicking "preview" button.

I think it's better to place SetClientSize(wxSize(x, y)); at the end of the auto-generated codes,
and it's reflected in the GUI designer screen.
Because programmers sometimes would like to fix the size of frame regardless of its contents.

That's my request.
I would be happy if you consider the request.

Regards,

hirofield

oBFusCATed:
Hi,
I've stumbled upon this problem too and it was very frustrating.   :?
So if this can be fixed I'll be happy too :)

hirofield, thanks for the detailed explanation.

hirofield:
Hi,
Thank you for your support.

I think this problem also affects the usability of the GUI designer.
Actually, it's rather difficult for me to place a widgets on the exact
position in the narrow space.

Thanks!

Navigation

[0] Message Index

Go to full version