xref: /haiku/src/apps/icon-o-matic/generic/gui/scrollview/Scrollable.h (revision 0562493379cd52eb7103531f895f10bb8e77c085)
1 /*
2  * Copyright 2006, Haiku.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Ingo Weinhold <bonefish@cs.tu-berlin.de>
7  */
8 
9 #ifndef SCROLLABLE_H
10 #define SCROLLABLE_H
11 
12 #include <Point.h>
13 #include <Rect.h>
14 
15 class Scroller;
16 
17 class Scrollable {
18  public:
19 								Scrollable();
20 	virtual						~Scrollable();
21 
22 			void				SetScrollSource(Scroller* source);
23 			Scroller*			ScrollSource() const;
24 
25 			void				SetDataRect(BRect dataRect);
26 			BRect				DataRect() const;
27 
28 			void				SetScrollOffset(BPoint offset);
29 			BPoint				ScrollOffset() const;
30 
31 			void				SetVisibleSize(float width, float height);
32 			BRect				VisibleBounds() const;
33 			BRect				VisibleRect() const;
34 
35 protected:
36 	virtual	void				DataRectChanged(BRect oldDataRect,
37 												BRect newDataRect);
38 	virtual	void				ScrollOffsetChanged(BPoint oldOffset,
39 													BPoint newOffset);
40 	virtual	void				VisibleSizeChanged(float oldWidth,
41 												   float oldHeight,
42 												   float newWidth,
43 												   float newHeight);
44 	virtual	void				ScrollSourceChanged(Scroller* oldSource,
45 													Scroller* newSource);
46 
47  private:
48 			BRect				fDataRect;
49 			BPoint				fScrollOffset;
50 			float				fVisibleWidth;
51 			float				fVisibleHeight;
52 			Scroller*			fScrollSource;
53 
54 			BPoint				_ValidScrollOffsetFor(BPoint offset) const;
55 };
56 
57 
58 #endif	// SCROLLABLE_H
59 
60