1 /* 2 * Copyright 2006, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Stephan Aßmus <superstippi@gmx.de> 7 * Ingo Weinhold <bonefish@cs.tu-berlin.de> 8 */ 9 10 #ifndef SCROLL_VIEW_H 11 #define SCROLL_VIEW_H 12 13 #include <View.h> 14 15 #include "Scroller.h" 16 17 class Scrollable; 18 class InternalScrollBar; 19 class ScrollCorner; 20 21 enum { 22 SCROLL_HORIZONTAL = 0x01, 23 SCROLL_VERTICAL = 0x02, 24 SCROLL_HORIZONTAL_MAGIC = 0x04, 25 SCROLL_VERTICAL_MAGIC = 0x08, 26 SCROLL_VISIBLE_RECT_IS_CHILD_BOUNDS = 0x10, 27 SCROLL_NO_FRAME = 0x20, 28 }; 29 30 class ScrollView : public BView, public Scroller { 31 public: 32 ScrollView(BView* child, 33 uint32 scrollingFlags, 34 BRect frame, 35 const char *name, 36 uint32 resizingMode, uint32 flags); 37 virtual ~ScrollView(); 38 39 virtual void AllAttached(); 40 virtual void Draw(BRect updateRect); 41 virtual void FrameResized(float width, float height); 42 virtual void WindowActivated(bool activated); 43 44 uint32 ScrollingFlags() const; 45 void SetVisibleRectIsChildBounds(bool flag); 46 bool VisibleRectIsChildBounds() const; 47 48 BView* Child() const; 49 void ChildFocusChanged(bool focused); 50 51 BScrollBar* HScrollBar() const; 52 BScrollBar* VScrollBar() const; 53 BView* HVScrollCorner() const; 54 55 void SetHSmallStep(float hStep); 56 void SetVSmallStep(float vStep); 57 void SetSmallSteps(float hStep, float vStep); 58 void GetSmallSteps(float* hStep, 59 float* vStep) const; 60 float HSmallStep() const; 61 float VSmallStep() const; 62 63 protected: 64 virtual void DataRectChanged(BRect oldDataRect, 65 BRect newDataRect); 66 virtual void ScrollOffsetChanged(BPoint oldOffset, 67 BPoint newOffset); 68 virtual void VisibleSizeChanged(float oldWidth, 69 float oldHeight, 70 float newWidth, 71 float newHeight); 72 virtual void ScrollTargetChanged(Scrollable* oldTarget, 73 Scrollable* newTarget); 74 75 private: 76 BView* fChild; // child view 77 uint32 fScrollingFlags; 78 InternalScrollBar* fHScrollBar; // horizontal scroll bar 79 InternalScrollBar* fVScrollBar; // vertical scroll bar 80 ScrollCorner* fScrollCorner; // scroll corner 81 bool fHVisible; // horizontal/vertical scroll 82 bool fVVisible; // bar visible flag 83 bool fCornerVisible; // scroll corner visible flag 84 bool fWindowActive; 85 bool fChildFocused; 86 float fHSmallStep; 87 float fVSmallStep; 88 89 void _ScrollValueChanged( 90 InternalScrollBar* scrollBar, 91 float value); 92 void _ScrollCornerValueChanged(BPoint offset); 93 94 protected: 95 virtual void _Layout(uint32 flags); 96 97 private: 98 void _UpdateScrollBars(); 99 uint32 _UpdateScrollBarVisibility(); 100 101 BRect _InnerRect() const; 102 BRect _ChildRect() const; 103 BRect _ChildRect(bool hbar, bool vbar) const; 104 BRect _GuessVisibleRect(bool hbar, bool vbar) const; 105 BRect _MaxVisibleRect() const; 106 107 friend class InternalScrollBar; 108 friend class ScrollCorner; 109 }; 110 111 112 113 #endif // SCROLL_VIEW_H 114