hide random home http://www.be.com/documentation/be_book/InterfaceKit/ScrollV.html (Amiga Plus Extra No. 5/97, 05/1997)



The Interface Kit: BScrollView

Derived from: public BView

Declared in: <interface/ScrollView.h>


Overview

A BScrollView object is a container for another view, a target view , typically a view that can be scrolled. The BScrollView creates and positions the scroll bars the target view needs and makes itself the parent of the scroll bars and the target view. It's a convenient way to set up scroll bars for another view.

If requested, the BScrollView draws a one-pixel wide black border around its children. Otherwise, it does no drawing and simply contains the family of views it set up.

The ScrollBar() function provides access to the scroll bars the BScrollView creates, so you can set their ranges and values as needed.


Constructor and Destructor


BScrollView()

      BScrollView(const char *name, BView *target,
         ulong resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP, 
         ulong flags = 0,
         bool horizontal = FALSE, 
         bool vertical = FALSE,
         bool bordered = TRUE)

Initializes the BScrollView. It will have a frame rectangle large enough to contain the target view and any scroll bars that are requested. If horizontal is TRUE, there will be a horizontal scroll bar. If vertical is TRUE, there will be a vertical scroll bar. Scroll bars are not provided unless you ask for them.

If bordered is TRUE, as it is by default, the frame rectangle will also be large enough to draw a narrow black border around the target view and scroll bars. A BScrollView can be used without scroll bars to simply contain and border the target view.

The BScrollView adapts its frame rectangle from the frame rectangle of the target view. It positions itself so that its left and top sides are exactly where the left and top sides of the target view originally were. It then adds the target view as its child along with any requested scroll bars. In the process, it modifies the target view's frame rectangle (but not its bounds rectangle) so that it will fit within its new parent.

If the resize mode of the target view is B_FOLLOW_ALL_SIDES , it and the scroll bars will be automatically resized to fill the container view whenever the container view is resized.

The scroll bars created by the BScrollView have an initial range extending from a minimum of 0 to a maximum of 1000. You'll generally need to ask for the scroll bars (using the ScrollBar() function) and set their ranges to more appropriate values.

The name, resizeMode, and flags arguments are identical to those declared in the BView class and are passed unchanged to the BView constructor.

See also: the BView constructor


~BScrollView()

      virtual ~BScrollView(void)

Does nothing.


Member Functions


AttachedToWindow()

      virtual void AttachedToWindow(void)

Resizes scroll bars belonging to BScrollViews that occupy the right bottom corner of a document window (B_DOCUMENT_WINDOW) so that room is left for the resize knob. This function assumes that vertical scroll bars are B_V_SCOLL_BAR_WIDTH units wide and horizontal scroll bars are B_H_SCROLL_BAR_HEIGHT units high. It doesn't check to make sure the window is actually resizable.

See also: BView::AttachedToWindow()


Draw()

      virtual void Draw(BRect updateRect)

Draws a one-pixel wide black border around the target view and scroll views, provided the bordered flag wasn't set to FALSE in the BScrollView constructor.

See also: the BScrollView constructor, BView::Draw()


IsBordered() see SetBordered()


ScrollBar()

      BScrollBar *ScrollBar(orientation posture) const

Returns the horizontal scroll bar if posture is B_HORIZONTAL and the vertical scroll bar if posture is B_VERTICAL. If the BScrollView doesn't contain a scroll bar with the requested orientation, this function returns NULL.

See also: the BScrollBar class


SetBordered(), IsBordered()

      virtual void SetBordered(bool bordered)
      inline bool IsBordered(void) const

SetBordered() determines whether a narrow black border will be drawn around the edge of the view. Calling this function is equivalent to passing a bordered flag to the BScrollView constructor. Bordered() returns the current flag.

See also: the BScrollView constructor






The Be Book, HTML Edition, for Developer Release 8 of the Be Operating System.

Copyright © 1996 Be, Inc. All rights reserved.

Be, the Be logo, BeBox, BeOS, BeWare, and GeekPort are trademarks of Be, Inc.

Last modified September 6, 1996.