Author Topic: wxSmith: control construction lines don't set control's name  (Read 5798 times)

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
I noticed that the control constructors in the generated code don't use all the arguments.
For example, here's a wxTextCtrl's ctor generated by wxSmith:
Code: "cpp"
txtFolder = new wxTextCtrl(this,ID_TEXTCTRL1,_("Text"),wxDefaultPosition,wxDefaultSize,0);

It's missing the validator and name arguments. For the validator, I don't care. wxSmith can't work with validators anyway. But the name is important, I think. I 'd expect this ctor to be generated:
Code: "cpp"
txtFolder = new wxTextCtrl(this,ID_TEXTCTRL1,_("Text"),wxDefaultPosition,wxDefaultSize,0,wxDefaultValidator,_T("txtFolder"));

Notice that it's setting the control's name too. Without this, calls to wxWindow::FindWindowByName() fail.

Is this intentional? Can this be fixed easily?
« Last Edit: July 02, 2006, 11:45:00 am by mandrav »
Be patient!
This bug will be fixed soon...

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 836
Re: wxSmith: control construction lines don't set control's name
« Reply #1 on: July 02, 2006, 12:21:38 pm »
It shouldn't be hard to add. Of course with name, validators won't be supported in near future ;). I haven't added support for name because it could be little bit confusing for new users. There's variable name, identifier and widget name. All those can be used to identify and find widget.

The easiest solution would be to use variable name as widget name too. Hope this would be enough ;)
(I don't want to add any other standard properties do the "confusing" problem won't appear)
I'll try code it tomorrow.

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: wxSmith: control construction lines don't set control's name
« Reply #2 on: July 02, 2006, 12:49:46 pm »
The easiest solution would be to use variable name as widget name too. Hope this would be enough ;)

It' s the correct thing to do, too :)
That's what other XRC editors do...

It's no big deal, take your time. It just struk me today why my calls to wxWindow::FindWindowByName() would fail ;)
Be patient!
This bug will be fixed soon...

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 836
Re: wxSmith: control construction lines don't set control's name
« Reply #3 on: July 03, 2006, 04:45:34 pm »
Ok, one small change. I've looked into xrc sourcecode and it uses id for setting up name. So it will be better to do it the same way. So in wxSmith, name won't be initialized with variable name but with string representation of identifier.

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: wxSmith: control construction lines don't set control's name
« Reply #4 on: July 03, 2006, 05:42:01 pm »
Just as good :)
Be patient!
This bug will be fixed soon...