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 #ifndef SCROLLER_H 9 #define SCROLLER_H 10 11 #include <Rect.h> 12 13 class Scrollable; 14 15 class Scroller { 16 public: 17 Scroller(); 18 virtual ~Scroller(); 19 20 void SetScrollTarget(Scrollable* target); 21 Scrollable* ScrollTarget() const; 22 23 void SetDataRect(BRect dataRect); 24 BRect DataRect() const; 25 26 void SetScrollOffset(BPoint offset); 27 BPoint ScrollOffset() const; 28 29 void SetVisibleSize(float width, float height); 30 BRect VisibleBounds() const; 31 BRect VisibleRect() const; 32 33 virtual void SetScrollingEnabled(bool enabled); IsScrollingEnabled()34 bool IsScrollingEnabled() const 35 { return fScrollingEnabled; } 36 37 virtual bool IsScrolling() const; 38 39 protected: 40 virtual void DataRectChanged(BRect oldDataRect, 41 BRect newDataRect); 42 virtual void ScrollOffsetChanged(BPoint oldOffset, 43 BPoint newOffset); 44 virtual void VisibleSizeChanged(float oldWidth, 45 float oldHeight, 46 float newWidth, 47 float newHeight); 48 virtual void ScrollTargetChanged(Scrollable* oldTarget, 49 Scrollable* newTarget); 50 51 protected: 52 Scrollable* fScrollTarget; 53 bool fScrollingEnabled; 54 55 friend class Scrollable; 56 }; 57 58 59 #endif // SCROLLER_H 60