Author Topic: A request about auto-generated code by wxSmith  (Read 2274 times)

Offline hirofield

  • Single posting newcomer
  • *
  • Posts: 4
A request about auto-generated code by wxSmith
« on: September 17, 2009, 09:23:29 am »
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: [Select]
SizeTestFrame::SizeTestFrame(wxWindow* parent,wxWindowID id)
{
    //(*Initialize(SizeTestFrame)
    Create(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("id"));
    //*)
}

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: [Select]
SizeTestFrame::SizeTestFrame(wxWindow* parent,wxWindowID id)
{
    //(*Initialize(SizeTestFrame)
    Create(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("id"));
    SetClientSize(wxSize(300,200));
    //*)
}

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: [Select]
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);
    //*)
}

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: [Select]
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));
}

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

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11629
    • Travis build status
Re: A request about auto-generated code by wxSmith
« Reply #1 on: September 17, 2009, 10:48:12 am »
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.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline hirofield

  • Single posting newcomer
  • *
  • Posts: 4
Re: A request about auto-generated code by wxSmith
« Reply #2 on: September 17, 2009, 04:21:43 pm »
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!