1dfa1093aSAxel Dörfler /* 2fd79684aSAxel 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, 187f9368caSlooncraz uint32 resizingMode = B_FOLLOW_LEFT_TOP, 199e163a7aSAxel Dörfler uint32 flags = 0, bool horizontal = false, 209e163a7aSAxel Dörfler bool vertical = false, 219e163a7aSAxel Dörfler border_style border = B_FANCY_BORDER); 229e163a7aSAxel Dörfler BScrollView(const char* name, BView* target, 2389208c77SStephan Aßmus uint32 flags, bool horizontal, 2489208c77SStephan Aßmus bool vertical, border_style border 2589208c77SStephan Aßmus = B_FANCY_BORDER); 26a76953d9SAxel Dörfler BScrollView(BMessage* archive); 27d734a8ceSbeveloper virtual ~BScrollView(); 28dfa1093aSAxel Dörfler 29a76953d9SAxel Dörfler static BArchivable* Instantiate(BMessage* archive); 301f424632SJohn Scipione virtual status_t Archive(BMessage* archive, bool deep = true) const; 31bdb4ae32SAdrien Destugues virtual status_t AllUnarchived(const BMessage* archive); 3289208c77SStephan Aßmus 331f424632SJohn Scipione // Hook methods 3489208c77SStephan Aßmus virtual void AllAttached(); 3589208c77SStephan Aßmus virtual void AllDetached(); 36d734a8ceSbeveloper 371f424632SJohn Scipione virtual void AttachedToWindow(); 381f424632SJohn Scipione virtual void DetachedFromWindow(); 391f424632SJohn Scipione 40d734a8ceSbeveloper virtual void Draw(BRect updateRect); 411f424632SJohn Scipione virtual void FrameMoved(BPoint newPosition); 421f424632SJohn Scipione virtual void FrameResized(float newWidth, float newHeight); 4389208c77SStephan Aßmus 4489208c77SStephan Aßmus virtual void MessageReceived(BMessage* message); 4589208c77SStephan Aßmus 461f424632SJohn Scipione virtual void MouseDown(BPoint where); 471f424632SJohn Scipione virtual void MouseMoved(BPoint where, uint32 code, 4889208c77SStephan Aßmus const BMessage* dragMessage); 491f424632SJohn Scipione virtual void MouseUp(BPoint where); 5089208c77SStephan Aßmus 511f424632SJohn Scipione virtual void WindowActivated(bool active); 521f424632SJohn Scipione 531f424632SJohn Scipione // Size 541f424632SJohn Scipione virtual void GetPreferredSize(float* _width, float* _height); 551f424632SJohn Scipione virtual void ResizeToPreferred(); 561f424632SJohn Scipione 571f424632SJohn Scipione virtual void MakeFocus(bool focus = true); 581f424632SJohn Scipione 591f424632SJohn Scipione virtual BSize MinSize(); 601f424632SJohn Scipione virtual BSize MaxSize(); 611f424632SJohn Scipione virtual BSize PreferredSize(); 621f424632SJohn Scipione 631f424632SJohn Scipione // BScrollBar 64c466b4daSJohn Scipione BScrollBar* ScrollBar(orientation direction) const; 65d734a8ceSbeveloper 66d734a8ceSbeveloper virtual void SetBorder(border_style border); 67d734a8ceSbeveloper border_style Border() const; 68fd79684aSAxel Dörfler void SetBorders(uint32 borders); 69fd79684aSAxel Dörfler uint32 Borders() const; 70d734a8ceSbeveloper 711f424632SJohn Scipione virtual status_t SetBorderHighlighted(bool highlight); 72d734a8ceSbeveloper bool IsBorderHighlighted() const; 73d734a8ceSbeveloper 74dfa1093aSAxel Dörfler void SetTarget(BView* target); 75d734a8ceSbeveloper BView* Target() const; 76d734a8ceSbeveloper 7789208c77SStephan Aßmus // Scripting 7889208c77SStephan Aßmus virtual BHandler* ResolveSpecifier(BMessage* message, 7989208c77SStephan Aßmus int32 index, BMessage* specifier, 801f424632SJohn Scipione int32 what, const char* property); 811f424632SJohn Scipione virtual status_t GetSupportedSuites(BMessage* message); 82d734a8ceSbeveloper 83d734a8ceSbeveloper virtual status_t Perform(perform_code d, void* arg); 84d734a8ceSbeveloper 8561eb1f1dSAlex Wilson protected: 8661eb1f1dSAlex Wilson virtual void LayoutInvalidated(bool descendants = false); 8761eb1f1dSAlex Wilson virtual void DoLayout(); 8861eb1f1dSAlex Wilson 89d734a8ceSbeveloper private: 9089208c77SStephan Aßmus // FBC padding and forbidden methods 91d734a8ceSbeveloper virtual void _ReservedScrollView1(); 92d734a8ceSbeveloper virtual void _ReservedScrollView2(); 93d734a8ceSbeveloper virtual void _ReservedScrollView3(); 94d734a8ceSbeveloper virtual void _ReservedScrollView4(); 95d734a8ceSbeveloper 969e163a7aSAxel Dörfler BScrollView& operator=(const BScrollView& other); 97d734a8ceSbeveloper 9889208c77SStephan Aßmus private: 9989208c77SStephan Aßmus friend class BView; 10089208c77SStephan Aßmus 1019e163a7aSAxel Dörfler void _Init(bool horizontal, bool vertical); 1029e163a7aSAxel Dörfler float _BorderSize() const; 1039e163a7aSAxel Dörfler BRect _InnerFrame() const; 1049e163a7aSAxel Dörfler BSize _ComputeSize(BSize targetSize) const; 1059e163a7aSAxel Dörfler BRect _ComputeFrame(BRect targetRect) const; 10689208c77SStephan Aßmus void _AlignScrollBars(bool horizontal, 10789208c77SStephan Aßmus bool vertical, BRect targetFrame); 1089e163a7aSAxel Dörfler 109*b022a5e2SAugustin Cavalier static BRect _ComputeFrame(BRect frame, BScrollBar* horizontal, 110*b022a5e2SAugustin Cavalier BScrollBar* vertical, border_style border, 111fd79684aSAxel Dörfler uint32 borders); 112*b022a5e2SAugustin Cavalier static BRect _ComputeFrame(BView* target, BScrollBar* horizontal, 113*b022a5e2SAugustin Cavalier BScrollBar* vertical, border_style border, 114fd79684aSAxel Dörfler uint32 borders); 1159e163a7aSAxel Dörfler static float _BorderSize(border_style border); 1164854630dSAugustin Cavalier static uint32 _ModifyFlags(uint32 flags, BView* target, 1174854630dSAugustin Cavalier border_style border); 118fd79684aSAxel Dörfler static void _InsetBorders(BRect& frame, border_style border, 11993244a65SJessica Hamilton uint32 borders, bool expand = false); 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; 128fd79684aSAxel Dörfler uint32 fBorders; 129d734a8ceSbeveloper 130fd79684aSAxel Dörfler uint32 _reserved[2]; 131dfa1093aSAxel Dörfler }; 132d734a8ceSbeveloper 13389208c77SStephan Aßmus #endif // _SCROLL_VIEW_H 134