Author Topic: Some feature request about wxSmith on generating the code  (Read 10540 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6023
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Some feature request about wxSmith on generating the code
« on: May 24, 2023, 12:55:12 pm »
wxMathPlot

This is an improved wxMathPlot which has many good features, such as track the points(around the mouse), magnet cross lines, more powerful context menu and config dialog to tweak the plot.

In-fact, I have helped to improve this control, and when discussed with the author, he has some feature request:

https://github.com/GitHubLionel/wxMathPlot/issues/13#issuecomment-1560538840

Mainly:


Quote
    the ability (with a checkbox in the IDE) to avoid the creation of the name of the widget (suppress all the long list of wxNewId())
    the creation of an array of string for the wxChoice widget
    the use of Bind in place of Connect
    an user code for i18n string. Default code is _("string") but if you have your own function, you wish could replace it by another thing (for example _myI18N("string")).

Any ideas, and hopefully we can fix some of them.
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.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1632
Re: Some feature request about wxSmith on generating the code
« Reply #1 on: May 24, 2023, 02:13:49 pm »
Generation of Bind() vs Connect() would be desirable, currently GCC emits a warning on every Connect() due to incorrect type for the wxObjectEventFunction parameter. This warnings appear when you activate -Wextra.

For the rest, I do not see the need:
  - wxChoice already allows entering an array of strings, and you can use the "Extra code" property for more advanced usage.
  - The custom string for translation makes little sense, the .POT files should be modified to recognize the custom string for no advantage.
  - Removal of the name of the widget may reduce code size, but I see no other advantage

wxNewId() is deprecated, but it is difficult to replace.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6023
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Some feature request about wxSmith on generating the code
« Reply #2 on: May 24, 2023, 02:33:23 pm »
Generation of Bind() vs Connect() would be desirable, currently GCC emits a warning on every Connect() due to incorrect type for the wxObjectEventFunction parameter. This warnings appear when you activate -Wextra.

Yes, the author of wxMathPlot also saw this issue in his IDE, see his github issue comment: https://github.com/GitHubLionel/wxMathPlot/issues/2#issuecomment-1348985032  and  https://github.com/GitHubLionel/wxMathPlot/issues/12#issuecomment-1554172051



Quote

For the rest, I do not see the need:
  - wxChoice already allows entering an array of strings, and you can use the "Extra code" property for more advanced usage.
  - The custom string for translation makes little sense, the .POT files should be modified to recognize the custom string for no advantage.
  - Removal of the name of the widget may reduce code size, but I see no other advantage

wxNewId() is deprecated, but it is difficult to replace.

OK, I see.
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.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1632
Re: Some feature request about wxSmith on generating the code
« Reply #3 on: May 24, 2023, 05:24:24 pm »
The Connect() calls are generated inside wxsEvents::GenerateBindingCode() and the change to Bind() looks straightforward, but IMHO this is not the best moment for doing this.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1632
Re: Some feature request about wxSmith on generating the code
« Reply #4 on: May 25, 2023, 10:42:02 am »
Now wxSmith allows generation of Bind() instead of Connect() changing a setting.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6023
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Some feature request about wxSmith on generating the code
« Reply #5 on: May 25, 2023, 12:52:19 pm »
Now wxSmith allows generation of Bind() instead of Connect() changing a setting.

Thanks, let me building the new C::B right now.
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.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6023
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Some feature request about wxSmith on generating the code
« Reply #6 on: May 25, 2023, 01:31:57 pm »
Good work! I just build the latest svn Code::Blocks, and the generating of "Bind" function call works fine, thanks!
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.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6023
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Some feature request about wxSmith on generating the code
« Reply #7 on: May 30, 2023, 09:21:12 am »
Hi, the author of wxMathPlot library has built C::B himself, and he modify the wxSmith code, and it can have the features he needed.

See here:
https://github.com/GitHubLionel/wxSmith/tree/main/src

And you can see the generated code here:
Change Items array for wxChoice

I guess we can incorporate his contribution?

See the discussion here: code with new wxSmith Issue #14 GitHubLionel/wxMathPlot
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.