1 /* 2 * Copyright 2009, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _TOOL_TIP_H 6 #define _TOOL_TIP_H 7 8 9 #include <Alignment.h> 10 #include <Archivable.h> 11 #include <Point.h> 12 #include <Referenceable.h> 13 14 15 class BView; 16 class BTextView; 17 18 19 class BToolTip : public BArchivable, public BReferenceable { 20 public: 21 BToolTip(); 22 BToolTip(BMessage* archive); 23 virtual ~BToolTip(); 24 25 virtual status_t Archive(BMessage* archive, 26 bool deep = true) const; 27 28 virtual BView* View() const = 0; 29 30 virtual void SetSticky(bool enable); 31 bool IsSticky() const; 32 virtual void SetMouseRelativeLocation(BPoint location); 33 BPoint MouseRelativeLocation() const; 34 virtual void SetAlignment(BAlignment alignment); 35 BAlignment Alignment() const; 36 37 virtual void AttachedToWindow(); 38 virtual void DetachedFromWindow(); 39 40 protected: 41 bool Lock(); 42 void Unlock(); 43 44 private: 45 BToolTip(const BToolTip& other); 46 BToolTip& operator=(const BToolTip &other); 47 48 void _InitData(); 49 50 private: 51 bool fLockedLooper; 52 bool fIsSticky; 53 BPoint fRelativeLocation; 54 BAlignment fAlignment; 55 }; 56 57 58 class BTextToolTip : public BToolTip { 59 public: 60 BTextToolTip(const char* text); 61 BTextToolTip(BMessage* archive); 62 virtual ~BTextToolTip(); 63 64 static BTextToolTip* Instantiate(BMessage* archive); 65 virtual status_t Archive(BMessage* archive, 66 bool deep = true) const; 67 68 virtual BView* View() const; 69 70 const char* Text() const; 71 void SetText(const char* text); 72 73 private: 74 void _InitData(const char* text); 75 76 private: 77 BTextView* fTextView; 78 }; 79 80 81 #endif // _TOOL_TIP_H 82