Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

wxSmith Feature request: Option to disable calls to Fit() and SetSizeHints()

(1/8) > >>

lesnewell:
I use wxSmith to generate layouts but often want to add extra controls or hide controls outside wxSmith's automatically generated code. The problem I have is that for every sizer wxSmith adds this code:   
   theSizer->Fit(theWindow);
   theSizer->SetSizeHints(theWindow);

This locks window sizes causing layout issues if you later hide controls or add extra controls. I am currently manually deleting these calls but if I make any changes to the layout wxSmith puts them back. It's easy to forget to go back and edit the code. It would be really handy to have an option to not put these calls in.

As an aside, is there any need to call Fit and SetSizeHints for every sizer?. None of the wxWidgets samples do this. They only do it for the top level window. Looking at the changelog it appears these calls were added back in 2005 but there is no explanation of why.

Miguel Gimenez:
You can remove that code from src\plugins\contrib\wxSmith\wxwidgets\wxscontainer.cpp (lines 214 to 217) and recompile C::B

lesnewell:
Thanks. Yes, I saw that code. The problem is that taking it out would affect all windows in my application. I don't add/hide controls on all windows. Making it optional for a window gives the choice.
I'm sure I'm not the only one caught by this. The big problem is that when you do add/remove controls it is very unpredictable what will happen. Sometimes it works, other times it does not. It took me an embarassingly long to figure out why my layouts sometimes went wrong in strange ways. Without those calls the windows lay out predictably.

oBFusCATed:
Do you want to have control if wxsmith would generate the fit/layout for the top level windows?
Probably this was done this way because of misunderstanding of wx or wx-bug which are no longer present.
I doubt we'll know the exact reason, so I think we should try to modify wxsmith to generate idiomatic wx style code and see what happens.

I suppose we could separate the fit code in a separate section, so the user can just delete it or comment it out.
Something like this:

--- Code: ---// * wxsmith
main code
// * wxsmith

// *wxsmith-layout
the layout code
// *wxsmith-layout

--- End code ---

With this scheme the user would be able to decide on a case by case basis if he/she wants the layout code.

lesnewell:

--- Quote ---Do you want to have control if wxsmith would generate the fit/layout for the top level windows?
--- End quote ---
Ideally. For example I quite often create panels in wxSmith which are then used in multiple windows. Calling Fit/Layout in them is redundant.



--- Quote ---I suppose we could separate the fit code in a separate section, so the user can just delete it or comment it out.
--- End quote ---
That sounds like a good idea. How would it cope with existing code? Currently all of the creation code is marked with
//(*Initialize(myClass)
//*)

To be honest I'd assumed such an option would be a check box in  the top level window's options in the wxSmith designer. I prefer your suggestion though.

Navigation

[0] Message Index

[#] Next page

Go to full version