Page 1 of 2
Status bar
Posted: Fri Aug 03, 2012 4:36 pm
by Polo
I'm wondering on what's the expected behaviour on this, is the status bar supposed to take some space into the window's inne height (like it does on the Mac) or is it supposed to do like the toolbar and be an additional height?
Re: Status bar
Posted: Fri Aug 03, 2012 4:56 pm
by srod
The statusbar is like any other child window and sits in the client area of the window. You will thus have to subtract the height of the statusbar from the height of the window's client area when calculating how much of the window you can use.
What I am saying is that, unlike menus and scrollbars, GetClientRect_() will ignore statusbars and toolbars etc. and will not adjust the height value returned because there is a statusbar present.
Re: Status bar
Posted: Fri Aug 03, 2012 5:09 pm
by Polo
Thanks srod. I was wondering as this doesn't happen with the toolbars, and it's not clearly stated in the help that the status bar will take space in the window's client area

Re: Status bar
Posted: Fri Aug 03, 2012 5:28 pm
by srod
No, it is the same with toolbars which also encroach into the clientarea.
If you add a scrollbar to a window (not a separate scrollbar control) then Windows adjusts the size of the client area. Thus you can consider a window's scrollbars as being separate from the window's client area.
This is not true for toolbars and statusbars which actually sit inside the clientarea (Windows makes no adjustment).
Re: Status bar
Posted: Fri Aug 03, 2012 6:15 pm
by Polo
Are you sure?
On the Mac the toolbar is not taking the client area height. Not on Carbon, havent tested on Cocoa.
Re: Status bar
Posted: Fri Aug 03, 2012 6:19 pm
by Polo
Ok I tested on Windows and on Cocoa, it seems the Toolbar is taking the client area height only on Windows... weird.
Re: Status bar
Posted: Fri Aug 03, 2012 6:20 pm
by srod
Absolutely sure.
Code: Select all
If OpenWindow(0, 100, 150, 300, 100, "PureBasic - StatusBar Example", #PB_Window_SystemMenu | #PB_Window_SizeGadget)
GetClientRect_(WindowID(0), rc.RECT)
Debug "Client height before toolbar = " + Str(rc\bottom)
If CreateToolBar(0, WindowID(0))
ToolBarStandardButton(0, #PB_ToolBarIcon_New)
GetClientRect_(WindowID(0), rc.RECT)
Debug "Client height after toolbar = " + Str(rc\bottom)
EndIf
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Re: Status bar
Posted: Fri Aug 03, 2012 6:24 pm
by Polo
Yes, but not on Mac

Re: Status bar
Posted: Fri Aug 03, 2012 6:42 pm
by srod
How did you get the client height on the mac?
Re: Status bar
Posted: Fri Aug 03, 2012 6:56 pm
by Polo
srod wrote:How did you get the client height on the mac?
I didn't. Just create a window with a height of 25, add a toolbar, and you'll easily see the available height is still 25, whereas it's not on Windows

Re: Status bar
Posted: Fri Aug 03, 2012 7:28 pm
by srod
Ah, you mean the window resizes in order to keep the client area it's original size?
Windows does not do that at all; although there are functions for modifying the window size in relation to various window styles.
Re: Status bar
Posted: Fri Aug 03, 2012 8:02 pm
by Polo
srod wrote:Ah, you mean the window resizes in order to keep the client area it's original size?
Windows does not do that at all; although there are functions for modifying the window size in relation to various window styles.
Err, no idea how it work, but the Toolbar never eats the client area on PB Mac. Can get messy with cross platform apps!
Re: Status bar
Posted: Fri Aug 03, 2012 8:04 pm
by srod
Yep - messy and ugly!

Re: Status bar
Posted: Fri Aug 03, 2012 8:11 pm
by Polo
srod wrote:Yep - messy and ugly!

Sounds like it could do with a feature request!

Re: Status bar
Posted: Fri Aug 03, 2012 9:45 pm
by Shardik
Polo wrote:srod wrote:How did you get the client height on the mac?
I didn't. Just create a window with a height of 25, add a toolbar, and you'll easily see the available height is still 25, whereas it's not on Windows

Sorry, but the behaviour of Mac's PB 4.61 with the Carbon framework (Snow Leopard) doesn't differ from that of Windows' PB 4.61 (Windows 7 Home Premium x64, PB x86 and x64): both don't change the window's height when adding a StatusBar. Please try the following code example on Mac and Windows:
Code: Select all
OpenWindow(0, 270, 100, 200, 60, "StatusBar test")
ButtonGadget(0, 45, 10, 110, 20, "Add StatusBar")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
If EventGadget() = 0
If EventType() = #PB_EventType_LeftClick
If CreateStatusBar(0, WindowID(0))
AddStatusBarField(#PB_Ignore)
StatusBarText(0, 0, "StatusBar")
DisableGadget(0, #True)
EndIf
EndIf
EndIf
EndSelect
ForEver