tweak time axis view item text positioning; allow ArdourCanvas::Text to have its...
[ardour.git] / libs / canvas / canvas / text.h
1 #ifndef __ardour_canvas_text_h__
2 #define __ardour_canvas_text_h__
3
4 #include <pangomm/fontdescription.h>
5 #include <pangomm/layout.h>
6
7 #include "canvas/item.h"
8
9 namespace ArdourCanvas {
10
11 class Text : public Item
12 {
13 public:
14         Text (Group *);
15        ~Text();
16
17         void render (Rect const &, Cairo::RefPtr<Cairo::Context>) const;
18         void compute_bounding_box () const;
19         XMLNode* get_state () const;
20         void set_state (XMLNode const *);
21
22         void set (std::string const &);
23         void set_color (uint32_t);
24         void set_font_description (Pango::FontDescription);
25         void set_alignment (Pango::Alignment);
26
27         void clamp_width (double);
28
29         void set_size_chars (int nchars);
30         void dump (std::ostream&) const;
31
32 private:
33         std::string      _text;
34         uint32_t         _color;
35         Pango::FontDescription* _font_description;
36         Pango::Alignment _alignment;
37         mutable Cairo::RefPtr<Cairo::ImageSurface> _image;
38         mutable Duple _origin;
39         mutable double _width;
40         mutable double _height;
41         mutable bool _need_redraw;
42         double _clamped_width;
43
44         void redraw (Cairo::RefPtr<Cairo::Context>) const;
45 };
46
47 }
48
49 #endif /* __ardour_canvas_text_h__ */