xref: /haiku/headers/os/interface/StringView.h (revision 9fe35223cf4eb9714865152d62e8efc36b327fef)
1 /*
2  * Copyright 2001-2009, Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _STRING_VIEW_H
6 #define _STRING_VIEW_H
7 
8 
9 #include <BeBuild.h>
10 #include <View.h>
11 
12 
13 class BStringView : public BView{
14 public:
15 								BStringView(BRect bounds, const char* name,
16 									const char* text, uint32 resizeFlags
17 										= B_FOLLOW_LEFT | B_FOLLOW_TOP,
18 									uint32 flags = B_WILL_DRAW);
19 								BStringView(const char* name, const char* text,
20 									uint32 flags = B_WILL_DRAW);
21 								BStringView(BMessage* archive);
22 	virtual 					~BStringView();
23 
24 	static	BArchivable*		Instantiate(BMessage* archive);
25 	virtual	status_t			Archive(BMessage* archive,
26 									bool deep = true) const;
27 
28 			void				SetText(const char* text);
29 			const char*			Text() const;
30 			void				SetAlignment(alignment flag);
31 			alignment			Alignment() const;
32 
33 	virtual	void				AttachedToWindow();
34 	virtual	void				DetachedFromWindow();
35 	virtual	void				AllAttached();
36 	virtual	void				AllDetached();
37 
38 	virtual	void				MakeFocus(bool state = true);
39 
40 	virtual void				GetPreferredSize(float* _width,
41 									float* _height);
42 	virtual	BSize				MinSize();
43 	virtual	BSize				MaxSize();
44 	virtual	BSize				PreferredSize();
45 	virtual	void				InvalidateLayout(bool descendants = false);
46 	virtual	void				ResizeToPreferred();
47 	virtual	void				FrameMoved(BPoint newPosition);
48 	virtual	void				FrameResized(float newWidth, float newHeight);
49 
50 	virtual	void				Draw(BRect bounds);
51 
52 	virtual	void				MessageReceived(BMessage* message);
53 	virtual	void				MouseDown(BPoint point);
54 	virtual	void				MouseUp(BPoint point);
55 	virtual	void				MouseMoved(BPoint point, uint32 transit,
56 									const BMessage* dragMessage);
57 
58 	virtual	BHandler*			ResolveSpecifier(BMessage* message,
59 									int32 index, BMessage* specifier,
60 									int32 form, const char* property);
61 	virtual	status_t			GetSupportedSuites(BMessage* data);
62 
63 	virtual	void				SetFont(const BFont* font,
64 									uint32 mask = B_FONT_ALL);
65 
66 
67 private:
68 	// FBC padding and forbidden methods
69 	virtual	status_t			Perform(perform_code code, void* data);
70 
71 	virtual	void				_ReservedStringView1();
72 	virtual	void				_ReservedStringView2();
73 	virtual	void				_ReservedStringView3();
74 
75 			BStringView&		operator=(const BStringView& other);
76 
77 private:
78 			BSize				_ValidatePreferredSize();
79 
80 private:
81 			char*				fText;
82 			alignment			fAlign;
83 			BSize				fPreferredSize;
84 
85 			uint32				_reserved[1];
86 };
87 
88 #endif // _STRING_VIEW_H
89