[Resolved] BTabView Resizing Programming Question

I am just coming back to BeOS/Haiku and am writing an application that has a BTabView. Within the individual BTabs I have a BScrollView and a BTextView. When I have more than one tab in the tab view and I resize the BWindow the inactive BTab’s contents do not resize. When I switch the inactive tab to active then the frame doesn’t take up the entire space in the BTabView(the lower right corner of the BTab/contents is not in the lower right corner of the BTabView).

I am passing B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE for the flags to the BScollView and the BTextView. I am passing B_FOLLOW_ALL for the resizing mode.

How can I get the contents to resize? Do I need to override the FrameResized method in the BTextView?

I am using BeOS Max 4 (PE 5.03) on X86 hardware. Developing using BEIDE.

Any help would be greatly appreciated.

The developers do not hang out here on the forums that much, you should send this message to the haiku mailing list, that is if no one replyies here first.

I would give the link, but I am using a ps3 to wrie this. :wink:

Thanks,

I was hoping that this would be a more generalized UI programming question that would not rate disturbing kernel programers.

It’s apparently a common issue, and one of the hated things about BTabView.

A quick trip to google revealed a couple discussions that may shed some light on what’s going on:

http://forums.begroovy.com/index.php?PHPSESSID=380461c239382a6377a331afc7d7dc20&topic=1195.0

Well, I was stepping through my program with the debugger and it seems the last thing called for the FrameResized hook is the call to the main BWindow(ie all the BTabs respond first and then finally the BWindow). Seems that two FrameResize are called on the BTab’s target (once for drag start and once for drag stop).I am going to try to iterate through all the BTabs in the BTabView (since it is attached to the BWindow) and do a resize and maybe an invalidate on the objects in the BTabs by taking the current BTab’s properties through the BWindow’s FrameResize.

I think this will solve the issue.

Ok, I think I have this figured out. Buried in the developer mailing archives is a reference to AttachedToWindow() hook call. Using that hook I was able to get the BScrollView and BTextView to resize when a tab changed in the BTabView. I will clean up my code and post a more though review later tonight.

This turned out to be simple. I don’t understand why this is not documented somewhere else.

The problem:
Views that are in a BTab when the BTabView are resized do not automatically resize. This causes the view in the BTab to look like crap.

The solution:
You MUST subclass the view and implement the hook function AttachedToWindow().

example:

void myScrollView::AttachedToWindow(){
BRect newSize = Parent()->Frame();
ResizeTo(newSize.right - OFFSET_VIEW_RIGHT,newSize.bottom - OFFSET_VIEW_BOTTOM);
Invalidate();
}

where OFFSET_VIEW_RIGHT is how far off the right border you want the view displayed and OFFSET_VIEW_BOTTOM is off the bottom.