df23b83d714111cda745b0e93f8370cb36521c21
[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
9 void 
10 CanvasFlag::delete_allocated_objects()
11 {
12         delete _text;
13         _text = 0;
14
15         delete _line;
16         _line = 0;
17
18         delete _rect;
19         _rect = 0;
20 }
21
22 void 
23 CanvasFlag::set_text(string& a_text)
24 {
25         delete_allocated_objects();
26         
27         _text = new CanvasFlagText(*this, 0.0, 0.0, Glib::ustring(a_text));
28         _text->property_justification() = Gtk::JUSTIFY_CENTER;
29         _text->property_fill_color_rgba() = _outline_color_rgba;
30         double flagwidth  = _text->property_text_width()  + 10.0;
31         double flagheight = _text->property_text_height() + 3.0;
32         _text->property_x() = flagwidth / 2.0;
33         _text->property_y() = flagheight / 2.0;
34         _text->show();
35         _line = new SimpleLine(*this, 0.0, 0.0, 0.0, _height);
36         _line->property_color_rgba() = _outline_color_rgba;
37         _rect = new CanvasFlagRect(*this, 0.0, 0.0, flagwidth, flagheight);
38         _rect->property_outline_color_rgba() = _outline_color_rgba;
39         _rect->property_fill_color_rgba() = _fill_color_rgba;
40         _text->lower_to_bottom();
41         _text->raise(2);        
42 }
43
44 CanvasFlag::~CanvasFlag()
45 {
46         delete_allocated_objects();
47 }
48
49 bool
50 CanvasFlag::on_event(GdkEvent* ev)
51 {
52         cerr << "CanvasFlag::on_event(GdkEvent* ev)" << endl;
53         return false;
54 }