xref: /haiku/headers/os/interface/ScrollView.h (revision 1e36cfc2721ef13a187c6f7354dc9cbc485e89d3)
1 /*
2 ** Copyright 2004, OpenBeOS. All Rights Reserved.
3 ** Distributed under the terms of the OpenBeOS License.
4 */
5 #ifndef _SCROLL_VIEW_H
6 #define _SCROLL_VIEW_H
7 
8 /**	The BScrollView is a convenience class to add a scrolling
9  *	mechanism to the target view.
10  */
11 
12 #include <ScrollBar.h>
13 
14 
15 class BScrollView : public BView {
16 	public:
17 		BScrollView(const char *name, BView *target,
18 			uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
19 			uint32 flags = 0, bool horizontal = false, bool vertical = false,
20 			border_style border = B_FANCY_BORDER);
21 		BScrollView(BMessage *archive);
22 		virtual ~BScrollView();
23 
24 		static BArchivable	*Instantiate(BMessage *archive);
25 		virtual status_t	Archive(BMessage *archive, bool deep = true) const;
26 
27 		virtual void		Draw(BRect updateRect);
28 		virtual void		AttachedToWindow();
29 
30 		BScrollBar			*ScrollBar(orientation posture) const;
31 
32 		virtual void		SetBorder(border_style border);
33 		border_style		Border() const;
34 
35 		virtual status_t	SetBorderHighlighted(bool state);
36 		bool				IsBorderHighlighted() const;
37 
38 		void				SetTarget(BView *target);
39 		BView				*Target() const;
40 
41 		virtual void		MessageReceived(BMessage *message);
42 		virtual void		MouseDown(BPoint point);
43 
44 		virtual void		WindowActivated(bool active);
45 		virtual	void		MouseUp(BPoint point);
46 		virtual	void		MouseMoved(BPoint point, uint32 code, const BMessage *msg);
47 
48 		virtual	void		DetachedFromWindow();
49 		virtual	void		AllAttached();
50 		virtual	void		AllDetached();
51 
52 		virtual	void		FrameMoved(BPoint position);
53 		virtual	void		FrameResized(float width, float height);
54 
55 		virtual BHandler	*ResolveSpecifier(BMessage *message, int32 index,
56 								BMessage *specifier, int32 form, const char *property);
57 
58 		virtual void		ResizeToPreferred();
59 		virtual void		GetPreferredSize(float *_width, float *_height);
60 		virtual void		MakeFocus(bool state = true);
61 		virtual status_t	GetSupportedSuites(BMessage *data);
62 
63 		virtual	BSize		MinSize();
64 		virtual	BSize		PreferredSize();
65 
66 		// private or reserved methods are following
67 
68 		virtual status_t	Perform(perform_code d, void *arg);
69 
70 	private:
71 		friend class BView;
72 
73 		virtual	void		_ReservedScrollView1();
74 		virtual	void		_ReservedScrollView2();
75 		virtual	void		_ReservedScrollView3();
76 		virtual	void		_ReservedScrollView4();
77 
78 		BScrollView			&operator=(const BScrollView &);
79 
80 		static BRect		CalcFrame(BView *target, bool h, bool v, border_style);
81 		static float		BorderSize(border_style border);
82 		static int32		ModifyFlags(int32 flags, border_style);
83 
84 		BView				*fTarget;
85 		BScrollBar			*fHorizontalScrollBar;
86 		BScrollBar			*fVerticalScrollBar;
87 		border_style		fBorder;
88 		uint16				fPreviousWidth;
89 		uint16				fPreviousHeight;
90 		bool				fHighlighted;
91 
92 		uint32				_reserved[3];
93 };
94 
95 #endif  /* _SCROLL_VIEW_H */
96