clean up item event handling in MidiRegionViews by removing unnecessary InteractiveIt...
[ardour.git] / gtk2_ardour / canvas-flag.cc
1 #include "canvas-flag.h"
2 #include <iostream>
3 #include "ardour_ui.h"
4
5 using namespace Gnome::Canvas;
6 using namespace std;
7
8 CanvasFlag::CanvasFlag (MidiRegionView& region,
9                         Group&          parent,
10                         double          height,
11                         guint           outline_color_rgba,
12                         guint           fill_color_rgba,
13                         double          x,
14                         double          y)
15         : Group(parent, x, y)
16         , _text(0)
17         , _height(height)
18         , _outline_color_rgba(outline_color_rgba)
19         , _fill_color_rgba(fill_color_rgba)
20         , _region(region)
21         , _line(0)
22         , _rect(0)
23 {
24         /* XXX this connection is needed if ::on_event() is changed to actually do anything */
25         signal_event().connect (sigc::mem_fun (*this, &CanvasFlag::on_event));
26 }
27
28 void
29 CanvasFlag::delete_allocated_objects()
30 {
31         delete _text;
32         _text = 0;
33
34         delete _line;
35         _line = 0;
36
37         delete _rect;
38         _rect = 0;
39 }
40
41 void
42 CanvasFlag::set_text(const string& a_text)
43 {
44         delete_allocated_objects();
45
46         _text = new Text (*this, 0.0, 0.0, Glib::ustring(a_text));
47         _text->property_justification() = Gtk::JUSTIFY_CENTER;
48         _text->property_fill_color_rgba() = _outline_color_rgba;
49         double flagwidth  = _text->property_text_width()  + 10.0;
50         double flagheight = _text->property_text_height() + 3.0;
51         _text->property_x() = flagwidth / 2.0;
52         _text->property_y() = flagheight / 2.0;
53         _text->show();
54         _line = new SimpleLine(*this, 0.0, 0.0, 0.0, _height);
55         _line->property_color_rgba() = _outline_color_rgba;
56         _rect = new SimpleRect(*this, 0.0, 0.0, flagwidth, flagheight);
57         _rect->property_outline_color_rgba() = _outline_color_rgba;
58         _rect->property_fill_color_rgba() = _fill_color_rgba;
59         _text->raise_to_top();
60
61         /* XXX these two connections are needed if ::on_event() is changed to actually do anything */
62         //_rect->signal_event().connect (sigc::mem_fun (*this, &CanvasFlag::on_event));
63         //_text->signal_event().connect (sigc::mem_fun (*this, &CanvasFlag::on_event));
64 }
65
66 CanvasFlag::~CanvasFlag()
67 {
68         delete_allocated_objects();
69 }
70
71 bool
72 CanvasFlag::on_event(GdkEvent* /*ev*/)
73 {
74         /* XXX if you change this function to actually do anything, be sure
75            to fix the connections commented out elsewhere in this file.
76         */
77         return false;
78 }