1 /* 2 * Copyright 2010-2017, 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 const uint32 kRemoveView = 'ReVi'; 22 const float kExpandSize = 8; 23 const float kPenSize = 1; 24 25 26 class NotificationView : public BView { 27 public: 28 NotificationView(BNotification* notification, 29 bigtime_t timeout, float iconSize, 30 bool disableTimeout = false); 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 void SetPreviewModeOn(bool enabled); 51 52 const char* MessageID() const; 53 54 private: 55 void _CalculateSize(); 56 void _DrawCloseButton(const BRect& updateRect); 57 58 struct LineInfo { 59 BFont font; 60 BString text; 61 BPoint location; 62 }; 63 64 typedef std::list<LineInfo*> LineInfoList; 65 66 BNotification* fNotification; 67 bigtime_t fTimeout; 68 float fIconSize; 69 bool fDisableTimeout; 70 71 BMessageRunner* fRunner; 72 73 BBitmap* fBitmap; 74 LineInfoList fLines; 75 float fHeight; 76 rgb_color fStripeColor; 77 bool fCloseClicked; 78 bool fPreviewModeOn; 79 }; 80 81 #endif // _NOTIFICATION_VIEW_H 82