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