xref: /haiku/src/servers/notification/NotificationView.h (revision 865a0be1c022cdd7d155ecb3a44ca2769bce4f60)
1 /*
2  * Copyright 2010, Haiku, Inc. All Rights Reserved.
3  * Copyright 2008-2009, Pier Luigi Fiorini. All Rights Reserved.
4  * Copyright 2004-2008, Michael Davidson. All Rights Reserved.
5  * Copyright 2004-2007, Mikael Eiman. All Rights Reserved.
6  * Distributed under the terms of the MIT License.
7  */
8 #ifndef _NOTIFICATION_VIEW_H
9 #define _NOTIFICATION_VIEW_H
10 
11 #include <list>
12 
13 #include <Bitmap.h>
14 #include <MessageRunner.h>
15 #include <Notification.h>
16 #include <View.h>
17 
18 class NotificationWindow;
19 
20 const uint32 kRemoveView = 'ReVi';
21 
22 class NotificationView : public BView {
23 public:
24 								NotificationView(NotificationWindow* win,
25 									BNotification* notification,
26 									bigtime_t timeout = -1);
27 	virtual						~NotificationView();
28 
29 	virtual	void 				AttachedToWindow();
30 	virtual	void 				MessageReceived(BMessage* message);
31 	virtual	void				Draw(BRect updateRect);
32 	virtual	void				MouseDown(BPoint point);
33 
34 /*
35 	virtual	BSize				MinSize();
36 	virtual	BSize				MaxSize();
37 	virtual	BSize 				PreferredSize();
38 */
39 
40 	virtual	BHandler*			ResolveSpecifier(BMessage* msg, int32 index,
41 									BMessage* specifier, int32 form,
42 									const char* property);
43 	virtual	status_t			GetSupportedSuites(BMessage* msg);
44 
45 			void 				SetText(float newMaxWidth = -1);
46 
47 			const char*			MessageID() const;
48 
49 private:
50 			BSize				_CalculateSize();
51 
52 			struct LineInfo {
53 				BFont	font;
54 				BString	text;
55 				BPoint	location;
56 			};
57 
58 			typedef std::list<LineInfo*> LineInfoList;
59 
60 			NotificationWindow*	fParent;
61 			BNotification*		fNotification;
62 			bigtime_t			fTimeout;
63 
64 			BMessageRunner*		fRunner;
65 
66 			BBitmap*			fBitmap;
67 
68 			LineInfoList		fLines;
69 
70 			float				fHeight;
71 };
72 
73 #endif	// _NOTIFICATION_VIEW_H
74