xref: /haiku/headers/os/interface/ScrollView.h (revision c466b4daebf3404b0e5c58bff26bb472f29078f7)
1dfa1093aSAxel Dörfler /*
21f424632SJohn Scipione  * Copyright 2004-2009, Axel Dörfler, axeld@pinc-software.de.
31f424632SJohn Scipione  * Copyright 2014 Haiku, Inc. All rights reserved.
41f424632SJohn Scipione  * Distributed under the terms of the MIT License.
51f424632SJohn Scipione  *
61f424632SJohn Scipione  * Authors:
71f424632SJohn Scipione  *		Axel Dörfler, axeld@pinc-software.de
81f424632SJohn Scipione  *		John Scipione, jscpione@gmail.com
9dfa1093aSAxel Dörfler  */
10d734a8ceSbeveloper #ifndef _SCROLL_VIEW_H
11d734a8ceSbeveloper #define _SCROLL_VIEW_H
12d734a8ceSbeveloper 
13d734a8ceSbeveloper 
14dfa1093aSAxel Dörfler #include <ScrollBar.h>
15dfa1093aSAxel Dörfler 
16d734a8ceSbeveloper 
179e163a7aSAxel Dörfler /*!	The BScrollView is a convenience class to add a scrolling
189e163a7aSAxel Dörfler 	mechanism to the target view.
199e163a7aSAxel Dörfler */
20d734a8ceSbeveloper class BScrollView : public BView {
21d734a8ceSbeveloper public:
22dfa1093aSAxel Dörfler 								BScrollView(const char* name, BView* target,
239e163a7aSAxel Dörfler 									uint32 resizingMode
249e163a7aSAxel Dörfler 										= B_FOLLOW_LEFT | B_FOLLOW_TOP,
259e163a7aSAxel Dörfler 									uint32 flags = 0, bool horizontal = false,
269e163a7aSAxel Dörfler 									bool vertical = false,
279e163a7aSAxel Dörfler 									border_style border = B_FANCY_BORDER);
289e163a7aSAxel Dörfler 								BScrollView(const char* name, BView* target,
2989208c77SStephan Aßmus 									uint32 flags, bool horizontal,
3089208c77SStephan Aßmus 									bool vertical, border_style border
3189208c77SStephan Aßmus 										= B_FANCY_BORDER);
32a76953d9SAxel Dörfler 								BScrollView(BMessage* archive);
33d734a8ceSbeveloper 	virtual						~BScrollView();
34dfa1093aSAxel Dörfler 
35a76953d9SAxel Dörfler 	static	BArchivable*		Instantiate(BMessage* archive);
361f424632SJohn Scipione 	virtual	status_t			Archive(BMessage* archive, bool deep = true) const;
37bdb4ae32SAdrien Destugues 	virtual status_t			AllUnarchived(const BMessage* archive);
3889208c77SStephan Aßmus 
391f424632SJohn Scipione 	// Hook methods
4089208c77SStephan Aßmus 	virtual	void				AllAttached();
4189208c77SStephan Aßmus 	virtual	void				AllDetached();
42d734a8ceSbeveloper 
431f424632SJohn Scipione 	virtual	void				AttachedToWindow();
441f424632SJohn Scipione 	virtual	void				DetachedFromWindow();
451f424632SJohn Scipione 
46d734a8ceSbeveloper 	virtual	void				Draw(BRect updateRect);
471f424632SJohn Scipione 	virtual	void				FrameMoved(BPoint newPosition);
481f424632SJohn Scipione 	virtual	void				FrameResized(float newWidth, float newHeight);
4989208c77SStephan Aßmus 
5089208c77SStephan Aßmus 	virtual	void				MessageReceived(BMessage* message);
5189208c77SStephan Aßmus 
521f424632SJohn Scipione 	virtual	void				MouseDown(BPoint where);
531f424632SJohn Scipione 	virtual	void				MouseMoved(BPoint where, uint32 code,
5489208c77SStephan Aßmus 									const BMessage* dragMessage);
551f424632SJohn Scipione 	virtual	void				MouseUp(BPoint where);
5689208c77SStephan Aßmus 
571f424632SJohn Scipione 	virtual	void				WindowActivated(bool active);
581f424632SJohn Scipione 
591f424632SJohn Scipione 	// Size
601f424632SJohn Scipione 	virtual	void				GetPreferredSize(float* _width, float* _height);
611f424632SJohn Scipione 	virtual	void				ResizeToPreferred();
621f424632SJohn Scipione 
631f424632SJohn Scipione 	virtual	void				MakeFocus(bool focus = true);
641f424632SJohn Scipione 
651f424632SJohn Scipione 	virtual	BSize				MinSize();
661f424632SJohn Scipione 	virtual	BSize				MaxSize();
671f424632SJohn Scipione 	virtual	BSize				PreferredSize();
681f424632SJohn Scipione 
691f424632SJohn Scipione 	// BScrollBar
70*c466b4daSJohn Scipione 			BScrollBar*			ScrollBar(orientation direction) const;
71d734a8ceSbeveloper 
72d734a8ceSbeveloper 	virtual	void				SetBorder(border_style border);
73d734a8ceSbeveloper 			border_style		Border() const;
74d734a8ceSbeveloper 
751f424632SJohn Scipione 	virtual	status_t			SetBorderHighlighted(bool highlight);
76d734a8ceSbeveloper 			bool				IsBorderHighlighted() const;
77d734a8ceSbeveloper 
78dfa1093aSAxel Dörfler 			void				SetTarget(BView* target);
79d734a8ceSbeveloper 			BView*				Target() const;
80d734a8ceSbeveloper 
8189208c77SStephan Aßmus 	// Scripting
8289208c77SStephan Aßmus 	virtual	BHandler*			ResolveSpecifier(BMessage* message,
8389208c77SStephan Aßmus 									int32 index, BMessage* specifier,
841f424632SJohn Scipione 									int32 what, const char* property);
851f424632SJohn Scipione 	virtual	status_t			GetSupportedSuites(BMessage* message);
86d734a8ceSbeveloper 
87d734a8ceSbeveloper 	virtual	status_t			Perform(perform_code d, void* arg);
88d734a8ceSbeveloper 
8961eb1f1dSAlex Wilson protected:
9061eb1f1dSAlex Wilson 	virtual	void				LayoutInvalidated(bool descendants = false);
9161eb1f1dSAlex Wilson 	virtual	void				DoLayout();
9261eb1f1dSAlex Wilson 
93d734a8ceSbeveloper private:
9489208c77SStephan Aßmus 	// FBC padding and forbidden methods
95d734a8ceSbeveloper 	virtual	void				_ReservedScrollView1();
96d734a8ceSbeveloper 	virtual	void				_ReservedScrollView2();
97d734a8ceSbeveloper 	virtual	void				_ReservedScrollView3();
98d734a8ceSbeveloper 	virtual	void				_ReservedScrollView4();
99d734a8ceSbeveloper 
1009e163a7aSAxel Dörfler 			BScrollView&		operator=(const BScrollView& other);
101d734a8ceSbeveloper 
10289208c77SStephan Aßmus private:
10389208c77SStephan Aßmus 	friend class BView;
10489208c77SStephan Aßmus 
1059e163a7aSAxel Dörfler 			void				_Init(bool horizontal, bool vertical);
1069e163a7aSAxel Dörfler 			float				_BorderSize() const;
1079e163a7aSAxel Dörfler 			BRect				_InnerFrame() const;
1089e163a7aSAxel Dörfler 			BSize				_ComputeSize(BSize targetSize) const;
1099e163a7aSAxel Dörfler 			BRect				_ComputeFrame(BRect targetRect) const;
11089208c77SStephan Aßmus 			void				_AlignScrollBars(bool horizontal,
11189208c77SStephan Aßmus 									bool vertical, BRect targetFrame);
1129e163a7aSAxel Dörfler 
1139e163a7aSAxel Dörfler 	static	BRect				_ComputeFrame(BRect frame, bool horizontal,
1149e163a7aSAxel Dörfler 									bool vertical, border_style border);
1159e163a7aSAxel Dörfler 	static	BRect				_ComputeFrame(BView* target, bool horizontal,
1169e163a7aSAxel Dörfler 									bool vertical, border_style border);
1179e163a7aSAxel Dörfler 	static	float				_BorderSize(border_style border);
1189e163a7aSAxel Dörfler 	static	int32				_ModifyFlags(int32 flags, border_style border);
119d734a8ceSbeveloper 
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;
128d734a8ceSbeveloper 
129dfa1093aSAxel Dörfler 			uint32				_reserved[3];
130dfa1093aSAxel Dörfler };
131d734a8ceSbeveloper 
13289208c77SStephan Aßmus #endif // _SCROLL_VIEW_H
133