wxToolBar not playing nice with wxFrame children (client area?)

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Mick P.
Earned some good credits
Earned some good credits
Posts: 110
Joined: Thu Jun 06, 2019 3:41 am
Contact:

wxToolBar not playing nice with wxFrame children (client area?)

Post by Mick P. » Tue Aug 27, 2019 5:41 am

I'm scratching my head looking at wxToolBar. The documentation seems to suggest it allocates "nonclient" space for itself, as if it's a menu bar. But that's not what I'm observing.

As such, I'm unsure how to proceed. I prefer to have resource than to try to hatch a harebrained workaround. If anyone knows?

EDITED: FWIW the code has the wxFrame use CreateToolBar (wxTB_DEFAULT_STYLE|wxTB_NODIVIDER) and then at the end I've the wxToolBar do Realize. EDITED: Also, I've seen many sources say to use a "panel" as root element, or a "sizer" but in case it's important, I'm using neither, and will not use either.

alys666
I live to help wx-kind
I live to help wx-kind
Posts: 191
Joined: Tue Oct 18, 2016 2:31 pm

Re: wxToolBar not playing nice with wxFrame children (client area?)

Post by alys666 » Tue Aug 27, 2019 8:34 am

i everywhere used wxFrame:: CreateToolBar(..), and it worked.
http://zetcode.com/gui/wxwidgets/menustoolbars/
but now i use wxAuiToolBar, and it can be placed everywhere at least in wxAuiManager.
ubuntu 16.04, wxWidgets 3.0.4

Mick P.
Earned some good credits
Earned some good credits
Posts: 110
Joined: Thu Jun 06, 2019 3:41 am
Contact:

Re: wxToolBar not playing nice with wxFrame children (client area?)

Post by Mick P. » Tue Aug 27, 2019 12:24 pm

Something that worked for me is after Realize to go through every window in the frame and use SetPosition on themselves. I didn't use "GetPosition" for this, however I think for it to work, then SetPosition(0,0) must situate a window under the toolbar, and from that it follows "GetPosition" should be 0,0.

I think this is a defect.

EDITED: I'm seeing this on MSW with 3.1.2.0 I think. Maybe it should be reported.

EDITED: https://trac.wxwidgets.org/ticket/18477#ticket

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

Re: wxToolBar not playing nice with wxFrame children (client area?)

Post by doublemax » Tue Aug 27, 2019 3:38 pm

Are you using sizers or absolute positioning? I assume the latter and if that's the case you should have mentioned it in the ticket.
Use the source, Luke!

Mick P.
Earned some good credits
Earned some good credits
Posts: 110
Joined: Thu Jun 06, 2019 3:41 am
Contact:

Re: wxToolBar not playing nice with wxFrame children (client area?)

Post by Mick P. » Fri Aug 30, 2019 6:19 am

Off-topic: Sorry to bother again!

My toolbar is 32px tall on MSW. That's 5px more than the bottom of the blue square border. So it creates a lot of empty space.

This may be a bug (see below) but I'm wondering if there is an obvious something I'm missing too, since 32 is like the default size of big icons on Windows.

There is a recent ticket here, likely newer than my wxWidgets:

http://trac.wxwidgets.org/ticket/18294

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

Re: wxToolBar not playing nice with wxFrame children (client area?)

Post by ONEEYEMAN » Fri Aug 30, 2019 2:18 pm

Hi,
Do you have a screenshot?
And the code?

Thank you.

Mick P.
Earned some good credits
Earned some good credits
Posts: 110
Joined: Thu Jun 06, 2019 3:41 am
Contact:

Re: wxToolBar not playing nice with wxFrame children (client area?)

Post by Mick P. » Sat Aug 31, 2019 6:24 pm

ONEEYEMAN wrote:
Fri Aug 30, 2019 2:18 pm
Hi,
Do you have a screenshot?
And the code?

Thank you.
For the 32px height problem? Just playing along, I happen to have shared a screenshot the other day, however the backgrounds are the same color, so it's not worth much. The code adds bitmaps. The maximum height is 22px. I tried setting the height to that height (though the buttons add some extra girth) and values slightly smaller than 32px. Though I think I saw on some webpage there is an API for creating a toolbar with an explicit height. But the wxFrame::CreateToolBar API doesn't have size parameters. Other than this I'm using wxToolBar::Realize afterward, as I believe I said in the OP.

(NOTE: This work-in-progress screenshot's widgets are not wxWidgets' in case anyone is wondering. It's OpenGL based.)

EDITED: The toolbar is sitting on the dotted focus-rect. 32px.

EDITED: Maybe this (viewtopic.php?f=19&t=26216&p=112126&hil ... ht#p112126) is that webpage.

Image

P.S. I'm also a little curious how programs tackle toolbar overflow, since there is no scrolling option or anything, it's highly dependent on the user's window width, and to a lesser extent the screen's width. Is there a way to set the toolbar's width?

Post Reply