ccb42fdf745efc317d0374ba66305b916ad1dd94
[ardour.git] / libs / canvas / pixbuf.cc
1 #include <cairomm/cairomm.h>
2 #include <gdkmm/general.h>
3
4 #include "pbd/xml++.h"
5
6 #include "canvas/pixbuf.h"
7
8 using namespace std;
9 using namespace ArdourCanvas;
10
11 Pixbuf::Pixbuf (Group* g)
12         : Item (g)
13 {
14         
15 }
16
17 void
18 Pixbuf::render (Rect const & /*area*/, Cairo::RefPtr<Cairo::Context> context) const
19 {
20         Gdk::Cairo::set_source_pixbuf (context, _pixbuf, 0, 0);
21         context->paint ();
22 }
23         
24 void
25 Pixbuf::compute_bounding_box () const
26 {
27         if (_pixbuf) {
28                 _bounding_box = boost::optional<Rect> (Rect (0, 0, _pixbuf->get_width(), _pixbuf->get_height()));
29         } else {
30                 _bounding_box = boost::optional<Rect> ();
31         }
32
33         _bounding_box_dirty = false;
34 }
35
36 void
37 Pixbuf::set (Glib::RefPtr<Gdk::Pixbuf> pixbuf)
38 {
39         begin_change ();
40         
41         _pixbuf = pixbuf;
42         _bounding_box_dirty = true;
43
44         end_change ();
45 }
46
47 Glib::RefPtr<Gdk::Pixbuf>
48 Pixbuf::pixbuf() {
49         return _pixbuf;
50 }
51
52 XMLNode *
53 Pixbuf::get_state () const
54 {
55         /* XXX */
56         return new XMLNode ("Pixbuf");
57 }
58
59 void
60 Pixbuf::set_state (XMLNode const * /*node*/)
61 {
62         /* XXX */
63 }