1 // TipView.h 2 // * PURPOSE 3 // Provide a basic, extensible 'ToolTip' view, designed 4 // to be hosted by a floating window (TipWindow). 5 // * HISTORY 6 // e.moon 20oct99 multi-line support 7 // e.moon 17oct99 Begun. 8 9 #ifndef __TipView_H__ 10 #define __TipView_H__ 11 12 #include <Font.h> 13 #include <String.h> 14 #include <View.h> 15 16 #include <vector> 17 18 #include "cortex_defs.h" 19 __BEGIN_CORTEX_NAMESPACE 20 21 class TipWindow; 22 23 class TipView : 24 public BView { 25 typedef BView _inherited; 26 27 public: // *** dtor/ctors 28 virtual ~TipView(); 29 TipView(); 30 31 public: // *** operations 32 33 // if attached to a BWindow, the window must be locked 34 virtual void setText( 35 const char* text); 36 37 public: // *** BView 38 39 virtual void Draw( 40 BRect updateRect); 41 42 virtual void FrameResized( 43 float width, 44 float height); 45 46 virtual void GetPreferredSize( 47 float* outWidth, 48 float* outHeight); 49 50 private: // implementation 51 BString m_text; 52 BPoint m_offset; 53 54 BFont m_font; 55 font_height m_fontHeight; 56 57 rgb_color m_textColor; 58 rgb_color m_borderLoColor; 59 rgb_color m_borderHiColor; 60 rgb_color m_viewColor; 61 62 63 typedef std::vector<int32> line_set; 64 line_set m_lineSet; 65 66 private: 67 static const float s_xPad; 68 static const float s_yPad; 69 70 void _initColors(); 71 void _initFont(); 72 void _updateLayout( 73 float width, 74 float height); 75 76 void _setText( 77 const char* text); 78 79 float _maxTextWidth(); 80 float _textHeight(); 81 }; 82 83 __END_CORTEX_NAMESPACE 84 #endif /*__TipView_H__*/ 85