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