[haiku-development] Re: BView.ScollBy and scrolling BViews in general

  • From: "Axel Dörfler" <axeld@xxxxxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Fri, 01 Jun 2007 12:26:39 +0200 CEST

Chris Peel <chris.gsi@xxxxxxxxxxxx> wrote:
> I'd like to understand the mechanics a bit more as the documentation  
> talks about a Bounds rectangle (which I understand) but also a 'Data'  
> rectangle and I'm not sure where that fits in.  For example, if I  
> create a new BView with frame (10,10) (199,199) this will give me a  
> 190x190 rectangle at point 10,10 in the parent (or BWindow)  
> coordinate space.  Now, if I do a BView.ScrollBy(20,0) this would  
> scroll the view content by 20 pixels so now I get:
> 
> Frame = 10,10 - 199, 199 (i.e. no change)
> Bounds = 20,0 - 219,199?
> 
> So how would I draw more content into the view?
> 
> As you can see, I'm really confused by this so any information from  
> the devs would be greatly appreciated here!

In file:///boot/beos/documentation/Be Book/The Interface Kit/
1_Drawing.html (on your HD if you're in BeOS) there is a short section.
In the example above, the new bounds would be BRect(20, 0, 209, 189); 
the bounds are always the relative size of the view. It's you who 
define the data section of the view; if you draw something at x=190 it 
wouldn't be seen before you scroll the view, but afterwards it is.
Since the scrollview has no idea about the size of your data rectangle, 
you have to manually set the scrollbars to make them fit. See 
BListView::_FixupScrollBar() in the Haiku implementation of the 
BListView class to see how to do that.

HTH,

Bye,
   Axel.


Other related posts: