Author Topic: Does wxSmith overwrite all of its h/cpp files content ? Should I derive or not ?  (Read 5870 times)

Offline eranon

  • Almost regular
  • **
  • Posts: 180
Something is not clear in my mind. Well, I'll try to explain (stop me if I'm wrong at any step) :

For every UI resource, wxSmith manages a wxs file and its appropriated class in a h/cpp pair files. Everytime you modify the resource using the C::B/wxSmith's UI editor, some parts of these files are candidates to be regenerated. These parts are materialized in block starting with "//(*" and ending with "//*)". So, you have to take care to never add any code manually into these block to avoid any loss at next wxSmith regeneration.

But, outside of these blocks, is it safe to add any code manually ? Or does wxSmith be suceptible to overwrite/erase them at any moment ?

Elsewhere in the forum, about wxFormBuilder, I've read that we need to derive any wxFB generated class, because wxFB can entirely overwrite its h/cpp pairs without any warning. Is it different for wxSmith ?

Seeing wxSmith is able to generate event handlers, I assume that any code we can add manually in the body of these handlers are safe (ie. will never be erased or overwritten ; otherwise it would be a real problem). But what about any function helpers or manually added methods and properties ?

Well, knowing I like to keep project as simple as possible (and number of source files does matter), I would like to be sure of the utility to systematically derive any wxSmith class... Or I'll work directly in the wxSmith generated ones.

Could you make the point with me on this specific subject ? To derive or not to derive, that is the question :o
[Independent dev. - wxWidgets 3.0.0 under "Win 7 Pro 64-bit, C::B SVN 9435 & wxSmith, TDM64-GCC 4.7 & MSVC9" + "OS X 10.8, FSF GCC 4.7 & C::B SVN 8909"]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
But, outside of these blocks, is it safe to add any code manually ? Or does wxSmith be suceptible to overwrite/erase them at any moment ?
wxSmith will not touch any regions outside the tagged once.

Is it different for wxSmith ?
Although In wonder if that is really true, wxSmith is different in that case.

Have a look at the C::B project itself, we are embedding non-generated code a lot in wxSmith based UI controls.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline eranon

  • Almost regular
  • **
  • Posts: 180
OK, thanks a lot for this clarification, Morten. I was upset to have to derive anything. Well, so, and since I've definitively adopted C::B and wxSmith (really, both are very cool until first contact passed:)), I'll just derive what really required (for example, when I've to implement a virtual method). And I'll take a look at C::B code when I'l have some time, for sure ;)
« Last Edit: May 18, 2012, 01:57:58 am by eanon »
[Independent dev. - wxWidgets 3.0.0 under "Win 7 Pro 64-bit, C::B SVN 9435 & wxSmith, TDM64-GCC 4.7 & MSVC9" + "OS X 10.8, FSF GCC 4.7 & C::B SVN 8909"]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
I was upset to have to derive anything.
Well its a matter of taste. I said that because it would nicely separate UI stuff from logic, so the code is not cluttered... but its not mandatory. In the end, you can toggle wxSmith generated code to become invisible (wxSmith regions in the editor), so that's about the same then.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline eranon

  • Almost regular
  • **
  • Posts: 180
In the end, you can toggle wxSmith generated code to become invisible (wxSmith regions in the editor), so that's about the same then.

And it's where C::B comes to my help :) I agree
[Independent dev. - wxWidgets 3.0.0 under "Win 7 Pro 64-bit, C::B SVN 9435 & wxSmith, TDM64-GCC 4.7 & MSVC9" + "OS X 10.8, FSF GCC 4.7 & C::B SVN 8909"]