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