Reputation: 7133
I play with Eclipse + wxWidgets + wxFormBuilder
I use wxFormBuilder
for GUI-design. It generates 2 classes: first is base class; second inherits first to implement functionality like button clicks. But both of this files are regenerated every time I have changes in wxFormBuilder.
I wonder how to add some code to inherited class. For example, I have listbox, button and menu item. I want to do same action (add some string to listbox) when user presses button or selects menu item. For this reason I want to implement common function 'action'. I'll call this functuion in button and menu item handlers. Where I should declare this function and its implementation to avoid erasing manual code?
Thanks.
Upvotes: 3
Views: 6779
Reputation: 199
What I do is: when I'm done laying out the GUI, I save the FormBuilder file, and generate the file containing the inherited class. Then I make a copy of the inherited class file in a separate working file. I then edit the working file to subclass the main class from the inherited class file. I can then edit the working file as necessary to add event handlers etc. but it picks up the FB GUI instructions.
If the GUI needs changes, I change it with FormBuilder, save the FB file and regenerate the inherited class file. This, then, remains subclassed in the working file. The GUI is updated, but the working file is unaffected.
This has worked well for me.
Upvotes: 0
Reputation: 7133
There is my own code generator for wxFormBuilder inherited classes which preserves manual code wxFUp455
Upvotes: 0
Reputation: 3078
wxFormbuilder has the ability to generate a derived class for you. Located under Tools->Generate Inherited Class.
This code is only generated when you invoke this tool, so most probably only once. It is derived from the automatically generated class. You use this class and can implement your stuff inside of it.
So, the usual workflow is like this:
Upvotes: 4