Author Topic: wxSmith : add option for Create function in inhereited cases  (Read 688 times)

Online LR83

  • Single posting newcomer
  • *
  • Posts: 8
wxSmith : add option for Create function in inhereited cases
« on: January 23, 2026, 03:04:10 pm »
I have a problem when I want to inherit from my custom panel. wxSmith add automatically this Create function:
Code
Create(parent, id, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("id"));
But my constructor is:
Code
myNewPanel::myNewPanel(wxWindow* parent, wxWindowID id): myPanel(parent, id)
so I need each time to comment the bad Create line.

Is it possible to add an option to prevent this line from being added automatically, such as the "Lay-out the window" option?

And another point, is it possible to add another option for the "Lay-out the window" option to have the choice beetwen SetSizeHints(this) and Fit(this) ?

Online LR83

  • Single posting newcomer
  • *
  • Posts: 8
Re: wxSmith : add option for Create function in inhereited cases
« Reply #1 on: Yesterday at 05:25:13 pm »
I try to add the option.
- Add m_Create property in wxsBaseProperties
- wxsItem::GetCreatePrefix, test the m_Create property. If false, I just add '//' before the Create function. So we can always see the parameters of the Create function (may be usefull).
Work for my project but I don't know if my solution is always good.
See the corrected files in the attachment.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6130
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Hi, I use some my own defined wxWidgets control from time to time. When I try to add this custom control in the wxSmith GUI designer, you can select the "Custom" control, and define the constructor yourself.

Is this the case I describe above?
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Online LR83

  • Single posting newcomer
  • *
  • Posts: 8
Not exactly, in my case it's about inherited classes.
For example, we have a first class that inherits from wxPanel: wxMyPanel. Then a second class that inherits from wxMyPanel with different parameters. For this second class, we don't want to use the Create function but inheritance directly in the constructor.
This is also possible with first class. For example:
Header:
Code
class wxMyPanel: public wxPanel
{
  public:

    wxMyPanel(wxWindow* parent, wxWindowID id);
    virtual ~wxMyPanel();

  protected:
     // Other declarations
};
Code:
Code
wxMyPanel::wxMyPanel(wxWindow* parent, wxWindowID id)
{
  //(*Initialize(wxMyPanel)

  Create(parent, id, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("id"));
  // Other declarations
}

Or directly:
Code
wxMyPanel::wxMyPanel(wxWindow* parent, wxWindowID id): wxPanel(parent, id)
{
  //(*Initialize(wxMyPanel)

  // Other declarations
}