xref: /haiku/headers/os/interface/Box.h (revision ed24eb5ff12640d052171c6a7feba37fab8a75d1)
1 /*
2  * Copyright 2005-2015 Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _BOX_H
6 #define _BOX_H
7 
8 
9 #include <View.h>
10 
11 
12 class BBox : public BView {
13 	public:
14 							BBox(BRect frame, const char* name = NULL,
15 								uint32 resizingMode = B_FOLLOW_LEFT_TOP,
16 								uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS
17 									| B_NAVIGABLE_JUMP,
18 								border_style border = B_FANCY_BORDER);
19 							BBox(const char* name,
20 								uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS
21 									| B_NAVIGABLE_JUMP,
22 								border_style border = B_FANCY_BORDER,
23 								BView* child = NULL);
24 							BBox(border_style border, BView* child);
25 		virtual				~BBox();
26 
27 		/* Archiving */
28 							BBox(BMessage* archive);
29 		static BArchivable*	Instantiate(BMessage* archive);
30 		virtual	status_t	Archive(BMessage* archive, bool deep = true) const;
31 
32 		virtual	void		SetBorder(border_style border);
33 		border_style		Border() const;
34 
35 		float				TopBorderOffset();
36 		BRect				InnerFrame();
37 
38 		void				SetLabel(const char* string);
39 		status_t			SetLabel(BView* viewLabel);
40 
41 		const char*			Label() const;
42 		BView*				LabelView() const;
43 
44 		virtual	void		Draw(BRect updateRect);
45 		virtual	void		AttachedToWindow();
46 		virtual	void		DetachedFromWindow();
47 		virtual	void		AllAttached();
48 		virtual	void		AllDetached();
49 		virtual	void		FrameResized(float width, float height);
50 		virtual	void		MessageReceived(BMessage* message);
51 		virtual	void		MouseDown(BPoint point);
52 		virtual	void		MouseUp(BPoint point);
53 		virtual	void		WindowActivated(bool active);
54 		virtual	void		MouseMoved(BPoint point, uint32 transit,
55 								const BMessage* dragMessage);
56 		virtual	void		FrameMoved(BPoint newLocation);
57 
58 		virtual	BHandler*	ResolveSpecifier(BMessage* message,
59 								int32 index, BMessage* specifier,
60 								int32 what, const char* property);
61 
62 		virtual	void		ResizeToPreferred();
63 		virtual	void		GetPreferredSize(float* _width, float* _height);
64 		virtual	void		MakeFocus(bool focused = true);
65 		virtual	status_t	GetSupportedSuites(BMessage* message);
66 
67 		virtual	status_t	Perform(perform_code d, void* arg);
68 
69 		virtual	BSize		MinSize();
70 		virtual	BSize		MaxSize();
71 		virtual	BSize		PreferredSize();
72 		virtual	BAlignment	LayoutAlignment();
73 
74 	protected:
75 		virtual	void		LayoutInvalidated(bool descendants = false);
76 		virtual	void		DoLayout();
77 
78 	private:
79 		struct LayoutData;
80 
81 		virtual	void		_ReservedBox1();
82 		virtual	void		_ReservedBox2();
83 
84 		BBox				&operator=(const BBox &);
85 
86 		void				_InitObject(BMessage* data = NULL);
87 		void				_DrawPlain(BRect labelBox);
88 		void				_DrawFancy(BRect labelBox);
89 		void				_ClearLabel();
90 
91 		BView*				_Child() const;
92 		void				_ValidateLayoutData();
93 
94 		char*				fLabel;
95 		BRect				fBounds;
96 		border_style		fStyle;
97 		BView*				fLabelView;
98 		LayoutData*			fLayoutData;
99 };
100 
101 #endif	// _BOX_H
102