Window client size, absolute positions and sizers

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4255
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Window client size, absolute positions and sizers

Post by ONEEYEMAN » Wed Jul 22, 2020 4:08 pm

Hi, ALL,
I am facing the following problem.

I am developing the program based on the MDI Doc/View architecture.
The program design is as follows:

DocMDIMainFrame, which initially starts maximized and contain a toolbar.
When a user click on the toolbar button, DocMDIChildFrame opens. At this point parent frame will have additional 1 or 2 toolbars and the child frame will be positioned accordingly. The child frame will contain different controls with sizers that will manage positions/sizes.

Now, on Windows/GTK everything works as expected.

However, OSX gives me trouble.
Since there is no MDI per se on OSX, I decided to make the additional toolbars as children of the child window.. Howeverit looks like the sizer that is used with the call:

childframe->SetSizer( main_sizer );

is using the whole area regardless whether I set client size or not.

I am also tryibg to adjust the position when creating those controls, so that they are created below the second toolbar if its present.
The trouble is -2nd toolbar (if present) is covered by the controls, even though they are created with appropriate position. I p[resume that this is because I add them to the sizer which covers the whole window client area regardless of SetClientSize() call.

Now, on OSX it make sense to create those toolbars inside the child frame, vs MSW/GTK.

But now, it appears that I can't use sizers on OSX.

Is my suspicion correct and the sizer covers all window area regardless of the SetClientSize() call?
Is it on OSX-only?
Is there a solution?

I'm fine with using the OS conditionals - I'm already using it to create the toolbars as appropriate. Or maybe even try to modify the library code.

I'm using 3.1.3 right now but will switch to 3.1.4 when it will be released.

Thank you.

User avatar
doublemax
Moderator
Moderator
Posts: 14984
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Window client size, absolute positions and sizers

Post by doublemax » Thu Jul 23, 2020 9:00 am

Is my suspicion correct and the sizer covers all window area regardless of the SetClientSize() call?
SetClientSize only sets the total size of the window so that the client size matches the passed values. It has no additional, long-lasting effects.

I remember a previous post from you with the two toolbars, and even back then i didn't quite understand what you're trying to do. But i would try to not use the toolbar api, but instead implement the toolbars as "normal" panels. I think this would give you back total control and it shouldn't suffer from platform specific differences.
Use the source, Luke!

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4255
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Window client size, absolute positions and sizers

Post by ONEEYEMAN » Thu Jul 23, 2020 2:58 pm

doublemax,
Basically my question is - how the size decides what is wxDefaultSize and is there a function I can override to set it as I need

Thank you.

User avatar
doublemax
Moderator
Moderator
Posts: 14984
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Window client size, absolute positions and sizers

Post by doublemax » Mon Jul 27, 2020 5:12 am

The sizer algorithm is based on item's "best size", which can be defined by overriding wxWindow::DoGetBestSize() or DoGetBestClientSize().
https://docs.wxwidgets.org/trunk/classw ... a630a4669e
Use the source, Luke!

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4255
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Window client size, absolute positions and sizers

Post by ONEEYEMAN » Mon Jul 27, 2020 5:16 am

doublemax,
Well I'm talking about position, not size.

Thank you.

User avatar
doublemax
Moderator
Moderator
Posts: 14984
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Window client size, absolute positions and sizers

Post by doublemax » Mon Jul 27, 2020 3:53 pm

I was referring to this question:
Basically my question is - how the size decides what is wxDefaultSize and is there a function I can override to set it as I need
Position is always a result of sizes. In simple terms, items above push other items down, and items to the left push items to the right.
Use the source, Luke!

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4255
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Window client size, absolute positions and sizers

Post by ONEEYEMAN » Mon Jul 27, 2020 5:10 pm

doublemax,
I understand.
However we are talking top left item here that is created first

But I will see what is happening.

Thank you

Post Reply