1dfa1093aSAxel Dörfler /* 2*89208c77SStephan Aßmus * Copyright 2004-2009, Haiku, Inc. All rights reserved. 39e163a7aSAxel Dörfler * Distributed under the terms of the MIT license. 4dfa1093aSAxel Dörfler */ 5d734a8ceSbeveloper #ifndef _SCROLL_VIEW_H 6d734a8ceSbeveloper #define _SCROLL_VIEW_H 7d734a8ceSbeveloper 8d734a8ceSbeveloper 9dfa1093aSAxel Dörfler #include <ScrollBar.h> 10dfa1093aSAxel Dörfler 11d734a8ceSbeveloper 129e163a7aSAxel Dörfler /*! The BScrollView is a convenience class to add a scrolling 139e163a7aSAxel Dörfler mechanism to the target view. 149e163a7aSAxel Dörfler */ 15d734a8ceSbeveloper class BScrollView : public BView { 16d734a8ceSbeveloper public: 17dfa1093aSAxel Dörfler BScrollView(const char* name, BView* target, 189e163a7aSAxel Dörfler uint32 resizingMode 199e163a7aSAxel Dörfler = B_FOLLOW_LEFT | B_FOLLOW_TOP, 209e163a7aSAxel Dörfler uint32 flags = 0, bool horizontal = false, 219e163a7aSAxel Dörfler bool vertical = false, 229e163a7aSAxel Dörfler border_style border = B_FANCY_BORDER); 239e163a7aSAxel Dörfler BScrollView(const char* name, BView* target, 24*89208c77SStephan Aßmus uint32 flags, bool horizontal, 25*89208c77SStephan Aßmus bool vertical, border_style border 26*89208c77SStephan Aßmus = B_FANCY_BORDER); 27a76953d9SAxel Dörfler BScrollView(BMessage* archive); 28d734a8ceSbeveloper virtual ~BScrollView(); 29dfa1093aSAxel Dörfler 30a76953d9SAxel Dörfler static BArchivable* Instantiate(BMessage* archive); 31*89208c77SStephan Aßmus virtual status_t Archive(BMessage* archive, 32*89208c77SStephan Aßmus bool deep = true) const; 33*89208c77SStephan Aßmus 34*89208c77SStephan Aßmus virtual void AttachedToWindow(); 35*89208c77SStephan Aßmus virtual void DetachedFromWindow(); 36*89208c77SStephan Aßmus virtual void AllAttached(); 37*89208c77SStephan Aßmus virtual void AllDetached(); 38d734a8ceSbeveloper 39d734a8ceSbeveloper virtual void Draw(BRect updateRect); 40dfa1093aSAxel Dörfler 41*89208c77SStephan Aßmus virtual void WindowActivated(bool active); 42*89208c77SStephan Aßmus virtual void MakeFocus(bool state = true); 43*89208c77SStephan Aßmus 44*89208c77SStephan Aßmus virtual void GetPreferredSize(float* _width, 45*89208c77SStephan Aßmus float* _height); 46*89208c77SStephan Aßmus virtual BSize MinSize(); 47*89208c77SStephan Aßmus virtual BSize MaxSize(); 48*89208c77SStephan Aßmus virtual BSize PreferredSize(); 49*89208c77SStephan Aßmus virtual void ResizeToPreferred(); 50*89208c77SStephan Aßmus 51*89208c77SStephan Aßmus virtual void InvalidateLayout(bool descendants = false); 52*89208c77SStephan Aßmus virtual void DoLayout(); 53*89208c77SStephan Aßmus virtual void FrameMoved(BPoint position); 54*89208c77SStephan Aßmus virtual void FrameResized(float width, float height); 55*89208c77SStephan Aßmus 56*89208c77SStephan Aßmus virtual void MessageReceived(BMessage* message); 57*89208c77SStephan Aßmus 58*89208c77SStephan Aßmus virtual void MouseDown(BPoint point); 59*89208c77SStephan Aßmus virtual void MouseUp(BPoint point); 60*89208c77SStephan Aßmus virtual void MouseMoved(BPoint point, uint32 code, 61*89208c77SStephan Aßmus const BMessage* dragMessage); 62*89208c77SStephan Aßmus 63*89208c77SStephan Aßmus // BScrollView 6426021c2cSAxel Dörfler BScrollBar* ScrollBar(orientation posture) const; 65d734a8ceSbeveloper 66d734a8ceSbeveloper virtual void SetBorder(border_style border); 67d734a8ceSbeveloper border_style Border() const; 68d734a8ceSbeveloper 6926021c2cSAxel Dörfler virtual status_t SetBorderHighlighted(bool state); 70d734a8ceSbeveloper bool IsBorderHighlighted() const; 71d734a8ceSbeveloper 72dfa1093aSAxel Dörfler void SetTarget(BView* target); 73d734a8ceSbeveloper BView* Target() const; 74d734a8ceSbeveloper 75*89208c77SStephan Aßmus // Scripting 76*89208c77SStephan Aßmus virtual BHandler* ResolveSpecifier(BMessage* message, 77*89208c77SStephan Aßmus int32 index, BMessage* specifier, 78*89208c77SStephan Aßmus int32 form, const char* property); 79d734a8ceSbeveloper virtual status_t GetSupportedSuites(BMessage* data); 80d734a8ceSbeveloper 81d734a8ceSbeveloper virtual status_t Perform(perform_code d, void* arg); 82d734a8ceSbeveloper 83d734a8ceSbeveloper private: 84*89208c77SStephan Aßmus // FBC padding and forbidden methods 85d734a8ceSbeveloper virtual void _ReservedScrollView1(); 86d734a8ceSbeveloper virtual void _ReservedScrollView2(); 87d734a8ceSbeveloper virtual void _ReservedScrollView3(); 88d734a8ceSbeveloper virtual void _ReservedScrollView4(); 89d734a8ceSbeveloper 909e163a7aSAxel Dörfler BScrollView& operator=(const BScrollView& other); 91d734a8ceSbeveloper 92*89208c77SStephan Aßmus private: 93*89208c77SStephan Aßmus friend class BView; 94*89208c77SStephan Aßmus 959e163a7aSAxel Dörfler void _Init(bool horizontal, bool vertical); 969e163a7aSAxel Dörfler float _BorderSize() const; 979e163a7aSAxel Dörfler BRect _InnerFrame() const; 989e163a7aSAxel Dörfler BSize _ComputeSize(BSize targetSize) const; 999e163a7aSAxel Dörfler BRect _ComputeFrame(BRect targetRect) const; 100*89208c77SStephan Aßmus void _AlignScrollBars(bool horizontal, 101*89208c77SStephan Aßmus bool vertical, BRect targetFrame); 1029e163a7aSAxel Dörfler 1039e163a7aSAxel Dörfler static BRect _ComputeFrame(BRect frame, bool horizontal, 1049e163a7aSAxel Dörfler bool vertical, border_style border); 1059e163a7aSAxel Dörfler static BRect _ComputeFrame(BView* target, bool horizontal, 1069e163a7aSAxel Dörfler bool vertical, border_style border); 1079e163a7aSAxel Dörfler static float _BorderSize(border_style border); 1089e163a7aSAxel Dörfler static int32 _ModifyFlags(int32 flags, border_style border); 109d734a8ceSbeveloper 110*89208c77SStephan Aßmus private: 111d734a8ceSbeveloper BView* fTarget; 112dfa1093aSAxel Dörfler BScrollBar* fHorizontalScrollBar; 113dfa1093aSAxel Dörfler BScrollBar* fVerticalScrollBar; 114d734a8ceSbeveloper border_style fBorder; 115dfa1093aSAxel Dörfler uint16 fPreviousWidth; 116dfa1093aSAxel Dörfler uint16 fPreviousHeight; 117d734a8ceSbeveloper bool fHighlighted; 118d734a8ceSbeveloper 119dfa1093aSAxel Dörfler uint32 _reserved[3]; 120dfa1093aSAxel Dörfler }; 121d734a8ceSbeveloper 122*89208c77SStephan Aßmus #endif // _SCROLL_VIEW_H 123