1 #ifndef TEXT_H 2 #define TEXT_H 3 4 #include <string> 5 6 #include "Annotation.h" 7 8 class Text : public Annotation 9 { 10 public: 11 Text(const unsigned char color[3], 12 const int x, const int y, 13 const int iconWidth, const int iconHeight, 14 const int align, 15 const std::string &text); 16 17 virtual ~Text(); 18 Align()19 int Align() const { return(align_); }; 20 void Align(const int align); 21 void ComputeBoundingBox(DisplayBase *display); FixedAlign()22 bool FixedAlign() const { return(fixedAlign_); }; Font(const std::string & font)23 void Font(const std::string &font) { font_.assign(font); }; FontSize(const int fontSize)24 void FontSize(const int fontSize) { fontSize_ = fontSize; }; 25 Opacity(const double d)26 void Opacity(const double d) { opacity_ = d; }; 27 Outline(const bool b)28 void Outline(const bool b) { outlined_ = b; }; 29 30 int Overhang(const int width, const int height); 31 int Overlap(const Text *const t); 32 X(const int x)33 void X(const int x) { x_ = x; } ; X()34 int X() const { return(x_); }; 35 Shift(const int x)36 virtual void Shift(const int x) { x_ += x; }; 37 virtual void Draw(DisplayBase *display); 38 39 private: 40 41 int align_; 42 bool fixedAlign_; 43 44 std::string font_; 45 int fontSize_; 46 47 const int iconHeight_; 48 const int iconWidth_; 49 50 bool needAlign_; 51 bool needBoundingBox_; 52 53 double opacity_; 54 55 // (xOffset, yOffset) is the offset of the text from (x_, y_) 56 int xOffset_; 57 int yOffset_; 58 59 bool outlined_; 60 61 std::string text_; 62 int textHeight_; 63 int textWidth_; 64 65 // (x_, y_) is the center of the icon 66 int x_; 67 const int y_; 68 69 int ulx_, uly_; 70 int lrx_, lry_; 71 72 int Overlap(const int ulx, const int uly, const int lrx, const int lry); 73 }; 74 75 #endif 76