Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: derived_params not used during code generation #1484

Open
jeff-kohn opened this issue Jul 28, 2024 · 3 comments
Open

Bug: derived_params not used during code generation #1484

jeff-kohn opened this issue Jul 28, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@jeff-kohn
Copy link

jeff-kohn commented Jul 28, 2024

Hi,

I'm trying to use the derived_class, and derived_params properties to generate a base class for my main frame window that inherits from something other than wxFrame (such as wxDocParentFrame). Specifiying derived_class works, the new base class name is used. Unfortunately, the generated base class won't compile.

The derived_params property seems to be broken. Nothing I enter here gets added to the generated code anywhere. For instance, I set the property to wxDocManager* manager, so that the Create() signature will be compatible with the base class, but this doesn't result in any new parameters being inserted anywhere in the ctor/Create() or anywhere else. It seems this setting is completely ignored during code generation. In fact, adding text here and then trying to generate code tells me that "All classes are up to date".

derived_params not being used is kind of a show-stopper, because it means I have to hand-edit the base class every time it's regenerated to fix up the Create parameters.

@jeff-kohn jeff-kohn added the bug Something isn't working label Jul 28, 2024
@jeff-kohn jeff-kohn changed the title Bug: Bug: derived_params not used during code generation Jul 28, 2024
@KeyWorksRW
Copy link
Owner

That's an oversight -- forms currently do not go through the normal code path that supports the derived_params property. They definitely should.

@KeyWorksRW KeyWorksRW added this to the wxUiEditor 1.2.2 milestone Jul 29, 2024
@KeyWorksRW
Copy link
Owner

Unlike controls, forms have two different ways to handle derived classes. The most common is to create your class and derive it from the generated class which in turn derives from the wxWidgets form (e.g., wxFrame). This has the advantage that you can create your own constructor with whatever parameters you want and override the base Create function with your own Create function. E.g., given you creating MyFrame from a generated MyFrameBase, you can create MyFrame::Create(foo, parent, id, bar) and call MyFrameBase::Create(parent, id) from it.

The second way is to specify the derived class and initial parameters. In this case you have no control over the constructor, and you can only insert parameters before the official set. You create an instance of the generated class instead of your own class, and then call the generated class's Create function with the parameters you want rather than calling your own Create function.

My question is, what is the scenario where it is better to use the second way for forms? You have to do that for controls, but I'm having trouble thinking of a scenario where it is better to generate a class that derives from your class rather than creating your class which derives from the generated class.

I realize I can't remove the second method, since importing from wxFormBuiilder, CodeBlocks, and others require it, but it certainly strikes me as an odd way to create a derived class since you are so much more limited in what you can do (no option for additional construction arguments, fixed placement of additional parameters for Create()).

@KeyWorksRW
Copy link
Owner

Never mind, I just thought of a scenario -- a base class shared between multiple derived classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants