xref: /haiku/headers/os/interface/StringView.h (revision fccd8899fcb583bfb73c5c26c9fcd714b963959b)
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 <View.h>
10 
11 
12 class BStringView : public BView{
13 public:
14 								BStringView(BRect bounds, const char* name,
15 									const char* text, uint32 resizeFlags
16 										= B_FOLLOW_LEFT | B_FOLLOW_TOP,
17 									uint32 flags = B_WILL_DRAW);
18 								BStringView(const char* name, const char* text,
19 									uint32 flags = B_WILL_DRAW);
20 								BStringView(BMessage* archive);
21 	virtual 					~BStringView();
22 
23 	static	BArchivable*		Instantiate(BMessage* archive);
24 	virtual	status_t			Archive(BMessage* archive,
25 									bool deep = true) const;
26 
27 			void				SetText(const char* text);
28 			const char*			Text() const;
29 			void				SetAlignment(alignment flag);
30 			alignment			Alignment() const;
31 
32 	virtual	void				AttachedToWindow();
33 	virtual	void				DetachedFromWindow();
34 	virtual	void				AllAttached();
35 	virtual	void				AllDetached();
36 
37 	virtual	void				MakeFocus(bool state = true);
38 
39 	virtual void				GetPreferredSize(float* _width,
40 									float* _height);
41 	virtual	BSize				MinSize();
42 	virtual	BSize				MaxSize();
43 	virtual	BSize				PreferredSize();
44 	virtual	void				ResizeToPreferred();
45 	virtual	void				FrameMoved(BPoint newPosition);
46 	virtual	void				FrameResized(float newWidth, float newHeight);
47 
48 	virtual	void				Draw(BRect bounds);
49 
50 	virtual	void				MessageReceived(BMessage* message);
51 	virtual	void				MouseDown(BPoint point);
52 	virtual	void				MouseUp(BPoint point);
53 	virtual	void				MouseMoved(BPoint point, uint32 transit,
54 									const BMessage* dragMessage);
55 
56 	virtual	BHandler*			ResolveSpecifier(BMessage* message,
57 									int32 index, BMessage* specifier,
58 									int32 form, const char* property);
59 	virtual	status_t			GetSupportedSuites(BMessage* data);
60 
61 	virtual	void				SetFont(const BFont* font,
62 									uint32 mask = B_FONT_ALL);
63 
64 protected:
65 	virtual	void				LayoutInvalidated(bool descendants = false);
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 			float				fStringWidth;
83 			alignment			fAlign;
84 			BSize				fPreferredSize;
85 };
86 
87 #endif // _STRING_VIEW_H
88