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 <Entry.h> 15 #include <Message.h> 16 #include <MessageRunner.h> 17 #include <MimeType.h> 18 #include <Notification.h> 19 #include <Path.h> 20 #include <Roster.h> 21 #include <String.h> 22 #include <TextView.h> 23 #include <View.h> 24 25 class NotificationWindow; 26 27 const uint32 kRemoveView = 'ReVi'; 28 29 class NotificationView : public BView { 30 public: 31 NotificationView(NotificationWindow* win, 32 notification_type type, 33 const char* app, const char* title, 34 const char* text, BMessage* details); 35 virtual ~NotificationView(); 36 37 virtual void AttachedToWindow(); 38 virtual void MessageReceived(BMessage* message); 39 virtual void GetPreferredSize(float* width, float* height); 40 virtual void Draw(BRect updateRect); 41 virtual void MouseDown(BPoint point); 42 virtual void FrameResized(float width, float height); 43 44 virtual BHandler* ResolveSpecifier(BMessage* msg, int32 index, 45 BMessage* specifier, int32 form, 46 const char* property); 47 virtual status_t GetSupportedSuites(BMessage* msg); 48 49 const char* Application() const; 50 const char* Title() const; 51 const char* Text() const; 52 53 void SetText(const char* app, const char* title, 54 const char* text, float newMaxWidth = -1); 55 bool HasMessageID(const char* id); 56 const char* MessageID(); 57 void SetPosition(bool first, bool last); 58 59 private: 60 BBitmap* _ReadNodeIcon(const char* fileName, 61 icon_size size); 62 void _LoadIcon(); 63 64 private: 65 struct LineInfo { 66 BFont font; 67 BString text; 68 BPoint location; 69 }; 70 71 typedef std::list<LineInfo*> LineInfoList; 72 73 74 NotificationWindow* fParent; 75 76 notification_type fType; 77 BMessageRunner* fRunner; 78 float fProgress; 79 BString fMessageID; 80 81 BMessage* fDetails; 82 BBitmap* fBitmap; 83 84 LineInfoList fLines; 85 86 BString fApp; 87 BString fTitle; 88 BString fText; 89 90 float fHeight; 91 92 bool fIsFirst; 93 bool fIsLast; 94 }; 95 96 #endif // _NOTIFICATION_VIEW_H 97