Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: mandrav on July 02, 2006, 11:43:29 am

Title: wxSmith: control construction lines don't set control's name
Post by: mandrav on July 02, 2006, 11:43:29 am
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?
Title: Re: wxSmith: control construction lines don't set control's name
Post by: byo 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.
Title: Re: wxSmith: control construction lines don't set control's name
Post by: mandrav 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 ;)
Title: Re: wxSmith: control construction lines don't set control's name
Post by: byo 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.
Title: Re: wxSmith: control construction lines don't set control's name
Post by: mandrav on July 03, 2006, 05:42:01 pm
Just as good :)