Edges are clickable now.
[av.git] / gtk / src / vertex.hpp
blob3856f2ff2343bf2ce3a4a5d776bd8acc9d437958
1 #ifndef __VERTEX_HPP__
2 #define __VERTEX_HPP__
4 #include <vector>
5 #include <gtkmm/widget.h>
6 #include <pangomm/layout.h>
7 #include <cairomm/context.h>
9 #include "drawable.hpp"
10 #include "core/word.hpp"
12 class Vertex : public Drawable<Vertex *>
14 public:
15 Vertex(Gtk::Widget &parent, const Word &word);
16 virtual ~Vertex(void);
17 void set_font(const Glib::ustring &font);
18 void set_coordinates(gdouble x, gdouble y);
19 gdouble get_x(void) const;
20 gdouble get_y(void) const;
21 gdouble get_width(void) const;
22 gdouble get_height(void) const;
23 void get_top_anchor(gdouble &x, gdouble &y) const;
24 void get_bottom_anchor(gdouble &x, gdouble &y) const;
25 virtual void draw(Cairo::RefPtr<Cairo::Context> cr);
26 void add_friend(const Vertex &v);
27 void delete_friend(const Vertex &v);
28 bool is_friend(const Vertex &v) const;
29 virtual bool select(Cairo::RefPtr<Cairo::Context> cr, gdouble x, gdouble y);
30 virtual void deselect(void);
31 private:
32 bool _is_in_region(Cairo::RefPtr<Cairo::Context> cr, gdouble x, gdouble y) const;
34 const gint _PADDING;
35 gdouble _x;
36 gdouble _y;
37 gdouble _width;
38 gdouble _height;
39 gdouble _descent;
40 bool _is_highlight;
41 Cairo::Path *_path;
43 const Word &_word;
44 Glib::RefPtr<Pango::Layout> _layout;
45 std::vector<const Vertex *> _friends;
48 inline void Vertex::set_coordinates(gdouble x, gdouble y)
50 _x = x;
51 _y = y;
54 inline gdouble Vertex::get_x(void) const
56 return _x;
59 inline gdouble Vertex::get_y(void) const
61 return _y;
64 inline gdouble Vertex::get_width(void) const
66 return _width;
69 inline gdouble Vertex::get_height(void) const
71 return _height;
74 inline void Vertex::get_top_anchor(gdouble &x, gdouble &y) const
76 x = _x + _width / 2;
77 y = _y;
80 inline void Vertex::get_bottom_anchor(gdouble &x, gdouble &y) const
82 x = _x + _width / 2;
83 y = _y + _height;
86 #endif