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 <String.h> 14 #include <View.h> 15 16 17 class BBitmap; 18 class BMessageRunner; 19 class BNotification; 20 21 class NotificationWindow; 22 23 const uint32 kRemoveView = 'ReVi'; 24 25 26 class NotificationView : public BView { 27 public: 28 NotificationView(NotificationWindow* win, 29 BNotification* notification, 30 bigtime_t timeout = -1); 31 virtual ~NotificationView(); 32 33 virtual void AttachedToWindow(); 34 virtual void MessageReceived(BMessage* message); 35 virtual void Draw(BRect updateRect); 36 virtual void MouseDown(BPoint point); 37 38 /* 39 virtual BSize MinSize(); 40 virtual BSize MaxSize(); 41 virtual BSize PreferredSize(); 42 */ 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 void SetText(float newMaxWidth = -1); 50 51 const char* MessageID() const; 52 53 private: 54 void _CalculateSize(); 55 void _DrawCloseButton(const BRect& updateRect); 56 57 struct LineInfo { 58 BFont font; 59 BString text; 60 BPoint location; 61 }; 62 63 typedef std::list<LineInfo*> LineInfoList; 64 65 NotificationWindow* fParent; 66 BNotification* fNotification; 67 bigtime_t fTimeout; 68 69 BMessageRunner* fRunner; 70 71 BBitmap* fBitmap; 72 LineInfoList fLines; 73 float fHeight; 74 rgb_color fStripeColor; 75 bool fCloseClicked; 76 }; 77 78 #endif // _NOTIFICATION_VIEW_H 79