Author Topic: wxSmith Feature request: Option to disable calls to Fit() and SetSizeHints()  (Read 16124 times)

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Quote
As I mentioned in a previous post the issue is that there are loads of copies of libstdc++-6.dll on my machine, both 32 bit and 64 bit. I have many open source applications installed and apparently many were built with MinGW. CodeBlocks even installs 3 copies.

I am currently getting around the problem by running CodeBlocks from a command prompt with PATH just set to point to MinGW and the wx dlls.
generally it is a bad idea to have all this in path...
I keep my compiler instillations all out of path.... If i need a compierl i use a bat file to set up the environment...

Offline lesnewell

  • Multiple posting newcomer
  • *
  • Posts: 66
After more testing I still haven't found any cases where this patch breaks existing projects and layouts. Should I submit it as a ticket?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Yep, I'm trying to find some time to push it. I've taken a brief look, but that is it.
The biggest problem for me is that the default seems wrong and the name of the field doesn't have a tooltip with a better explanation.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline lesnewell

  • Multiple posting newcomer
  • *
  • Posts: 66
I know the time problem very well.

As far as I know none of the options have a tool tip. At least I don't see them here. Adding tool tip functionality to the framework is likely to be quite a bit of work.
Maybe it's worth renaming the option. If you have any suggestions for a better name I'll happily change it. Admittedly that would break the projects I've used this on but I'mm sure I can get around that with some judicious wxs file editing.


'Lay out window' should default to enabled because we normally want the window to be laid out automatically. This also maintains compatibility with older projects.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Are you removing the code for the per sizer fit/layout calls? Is this unconditional?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline lesnewell

  • Multiple posting newcomer
  • *
  • Posts: 66
Yes it unconditionally removes the calls per sizer. I looked back at the wx2.8.11 samples and they only call SetSizeHints once for the top level window so I can't see it being needed for backwards compatibility with old versions of wx.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
We don't care for wx2.x in wxSmith as far as I'm concerned.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline lesnewell

  • Multiple posting newcomer
  • *
  • Posts: 66
The point I was trying to make is that the recommended use for SetSizeHints does not appear to have changed for a long time. If the current behaviour was put in due to a bug in wx I guess it was probably fixed a long time ago.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
I'm testing this patch.
Am I supposed to see this new property for wxFrames?
Are they supposed to be laid out?

I think, I've implemented the tooltip stuff, but I have to find where is the property to test it. :)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
OK, I'm not sure if this is a problem or side effect.
I have a wxFrame test project.
If I use the code generated by the patched cb the min size of the window is not set, so I can shrink it smaller then the content.
I have "Default min size" checked.
I'm always confused by this min size stuff, so I don't know if this is a regression or not but it is a change in behaviour.

Any comments about it? Do you have wxFrame based windows in your app?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Ah it seems you're not using flTopLevel, so the property is never visible...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
And my simple change to add tooltips works fine. :)
So I'll need a good explanation what this property does before pushing this fix.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline lesnewell

  • Multiple posting newcomer
  • *
  • Posts: 66
Ah it seems you're not using flTopLevel, so the property is never visible...
Huh. I just checked the patch and it looks like I messed up somewhere. There are some files missing from the patch. That explains why the property was missing from your frame.

I'll have another go tomorrow.
Quote
If I use the code generated by the patched cb the min size of the window is not set, so I can shrink it smaller then the content.
I have "Default min size" checked.

SetSizeHints should automatically set min and max sizes. Is SetSizeHints being called?

Offline lesnewell

  • Multiple posting newcomer
  • *
  • Posts: 66
Quote
If I use the code generated by the patched cb the min size of the window is not set, so I can shrink it smaller then the content.
I just tested a frame and with 'Lay out the window' turned off you can resize the frame to any size you want. With it on (the default) you can't resize below the minimum size that fits all controls. That is the expected behaviour.

Quote
I have "Default min size" checked.
I'm always confused by this min size stuff, so I don't know if this is a regression or not but it is a change in behaviour.

Size sets the initial size of the window, overriding the layout system.
Min size sets the minimum size of the window. This will override the layout system if the layout could be smaller.
Max size sets the maximum size of the window. This will override the layout system if the layout should be bigger.
Manually setting these sizes is really not a good idea in most cases. SetSizeHints sets these automatically, based on the ideal minimum and maximum sizes reported by the layout system.

I just ran some tests and noticed a bug that has been around for a very long time. As SetSizeHints was called for every sizer, it overrode whatever sizes you entered. This probably explains why you found them confusing. They actually did nothing. I've also been caught out by this a few times.

With the attached patch, size, min size and max size should work correctly. For top level windows with 'Lay out window' selected it gets a little complicated.
  • If size, min and max are set to default, SetSizeHints() is used. The layout system is free to decide the optimum window layout and sizes.
  • If size is default but min and/or max are not, Fit() is used. This sets size to the optimum decided by the layout system while still obeying min and max size. Depending on min/max size the layout may not fit.
  • If size is not default Layout() is used. This makes the layout system try to fit to your defined size. The layout probably will not fit.

The attached patch has these changes:
  • The above changes depending on what defaults are used
  • The missing files
  • Fixed 'Lay out the window' selection not being saved correctly.
  • Fixed SetSizer() sometimes being called twice on top level windows

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Thanks, it seems to work.

Now I need a couple of things to finish this of:
1. Descriptive commit message. I can gather one from the topic, but I'd be happier if you can provide one.
2. A real name or nickname. I like to give credit to people who provide patches and svn doesn't allow separation between author and committer name, so I write it down in the commit message.
3. A description for the tooltip for the "Lay out the window" property.

Just a note: You've messed up the load/save of the layout property, but I've fixed it. Re using parent_arg wasn't a good idea. ;)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]