1dfa1093aSAxel Dörfler /* 2*fd79684aSAxel Dörfler * Copyright 2004-2015 Haiku, Inc. All rights reserved. 31f424632SJohn Scipione * 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, 2489208c77SStephan Aßmus uint32 flags, bool horizontal, 2589208c77SStephan Aßmus bool vertical, border_style border 2689208c77SStephan 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); 311f424632SJohn Scipione virtual status_t Archive(BMessage* archive, bool deep = true) const; 32bdb4ae32SAdrien Destugues virtual status_t AllUnarchived(const BMessage* archive); 3389208c77SStephan Aßmus 341f424632SJohn Scipione // Hook methods 3589208c77SStephan Aßmus virtual void AllAttached(); 3689208c77SStephan Aßmus virtual void AllDetached(); 37d734a8ceSbeveloper 381f424632SJohn Scipione virtual void AttachedToWindow(); 391f424632SJohn Scipione virtual void DetachedFromWindow(); 401f424632SJohn Scipione 41d734a8ceSbeveloper virtual void Draw(BRect updateRect); 421f424632SJohn Scipione virtual void FrameMoved(BPoint newPosition); 431f424632SJohn Scipione virtual void FrameResized(float newWidth, float newHeight); 4489208c77SStephan Aßmus 4589208c77SStephan Aßmus virtual void MessageReceived(BMessage* message); 4689208c77SStephan Aßmus 471f424632SJohn Scipione virtual void MouseDown(BPoint where); 481f424632SJohn Scipione virtual void MouseMoved(BPoint where, uint32 code, 4989208c77SStephan Aßmus const BMessage* dragMessage); 501f424632SJohn Scipione virtual void MouseUp(BPoint where); 5189208c77SStephan Aßmus 521f424632SJohn Scipione virtual void WindowActivated(bool active); 531f424632SJohn Scipione 541f424632SJohn Scipione // Size 551f424632SJohn Scipione virtual void GetPreferredSize(float* _width, float* _height); 561f424632SJohn Scipione virtual void ResizeToPreferred(); 571f424632SJohn Scipione 581f424632SJohn Scipione virtual void MakeFocus(bool focus = true); 591f424632SJohn Scipione 601f424632SJohn Scipione virtual BSize MinSize(); 611f424632SJohn Scipione virtual BSize MaxSize(); 621f424632SJohn Scipione virtual BSize PreferredSize(); 631f424632SJohn Scipione 641f424632SJohn Scipione // BScrollBar 65c466b4daSJohn Scipione BScrollBar* ScrollBar(orientation direction) const; 66d734a8ceSbeveloper 67d734a8ceSbeveloper virtual void SetBorder(border_style border); 68d734a8ceSbeveloper border_style Border() const; 69*fd79684aSAxel Dörfler void SetBorders(uint32 borders); 70*fd79684aSAxel Dörfler uint32 Borders() const; 71d734a8ceSbeveloper 721f424632SJohn Scipione virtual status_t SetBorderHighlighted(bool highlight); 73d734a8ceSbeveloper bool IsBorderHighlighted() const; 74d734a8ceSbeveloper 75dfa1093aSAxel Dörfler void SetTarget(BView* target); 76d734a8ceSbeveloper BView* Target() const; 77d734a8ceSbeveloper 7889208c77SStephan Aßmus // Scripting 7989208c77SStephan Aßmus virtual BHandler* ResolveSpecifier(BMessage* message, 8089208c77SStephan Aßmus int32 index, BMessage* specifier, 811f424632SJohn Scipione int32 what, const char* property); 821f424632SJohn Scipione virtual status_t GetSupportedSuites(BMessage* message); 83d734a8ceSbeveloper 84d734a8ceSbeveloper virtual status_t Perform(perform_code d, void* arg); 85d734a8ceSbeveloper 8661eb1f1dSAlex Wilson protected: 8761eb1f1dSAlex Wilson virtual void LayoutInvalidated(bool descendants = false); 8861eb1f1dSAlex Wilson virtual void DoLayout(); 8961eb1f1dSAlex Wilson 90d734a8ceSbeveloper private: 9189208c77SStephan Aßmus // FBC padding and forbidden methods 92d734a8ceSbeveloper virtual void _ReservedScrollView1(); 93d734a8ceSbeveloper virtual void _ReservedScrollView2(); 94d734a8ceSbeveloper virtual void _ReservedScrollView3(); 95d734a8ceSbeveloper virtual void _ReservedScrollView4(); 96d734a8ceSbeveloper 979e163a7aSAxel Dörfler BScrollView& operator=(const BScrollView& other); 98d734a8ceSbeveloper 9989208c77SStephan Aßmus private: 10089208c77SStephan Aßmus friend class BView; 10189208c77SStephan Aßmus 1029e163a7aSAxel Dörfler void _Init(bool horizontal, bool vertical); 1039e163a7aSAxel Dörfler float _BorderSize() const; 1049e163a7aSAxel Dörfler BRect _InnerFrame() const; 1059e163a7aSAxel Dörfler BSize _ComputeSize(BSize targetSize) const; 1069e163a7aSAxel Dörfler BRect _ComputeFrame(BRect targetRect) const; 10789208c77SStephan Aßmus void _AlignScrollBars(bool horizontal, 10889208c77SStephan Aßmus bool vertical, BRect targetFrame); 1099e163a7aSAxel Dörfler 1109e163a7aSAxel Dörfler static BRect _ComputeFrame(BRect frame, bool horizontal, 111*fd79684aSAxel Dörfler bool vertical, border_style border, 112*fd79684aSAxel Dörfler uint32 borders); 1139e163a7aSAxel Dörfler static BRect _ComputeFrame(BView* target, bool horizontal, 114*fd79684aSAxel Dörfler bool vertical, border_style border, 115*fd79684aSAxel Dörfler uint32 borders); 1169e163a7aSAxel Dörfler static float _BorderSize(border_style border); 1179e163a7aSAxel Dörfler static int32 _ModifyFlags(int32 flags, border_style border); 118*fd79684aSAxel Dörfler static void _InsetBorders(BRect& frame, border_style border, 119*fd79684aSAxel Dörfler uint32 borders); 12089208c77SStephan Aßmus private: 121d734a8ceSbeveloper BView* fTarget; 122dfa1093aSAxel Dörfler BScrollBar* fHorizontalScrollBar; 123dfa1093aSAxel Dörfler BScrollBar* fVerticalScrollBar; 124d734a8ceSbeveloper border_style fBorder; 125dfa1093aSAxel Dörfler uint16 fPreviousWidth; 126dfa1093aSAxel Dörfler uint16 fPreviousHeight; 127d734a8ceSbeveloper bool fHighlighted; 128*fd79684aSAxel Dörfler uint32 fBorders; 129d734a8ceSbeveloper 130*fd79684aSAxel Dörfler uint32 _reserved[2]; 131dfa1093aSAxel Dörfler }; 132d734a8ceSbeveloper 13389208c77SStephan Aßmus #endif // _SCROLL_VIEW_H 134