* formatting/style guide
[ardour.git] / gtk2_ardour / canvas-program-change.cc
1 #include "canvas-program-change.h"
2 #include <iostream>
3 #include "ardour_ui.h"
4
5 using namespace Gnome::Canvas;
6 using namespace std;
7
8 CanvasProgramChange::CanvasProgramChange(
9                 MidiRegionView&                       region,
10                 Group&                                parent,
11                 boost::shared_ptr<MIDI::Event>        event,
12                 double                                height,
13                 double                                x,
14                 double                                y)
15         : Group(parent, x, y),
16           _region(region),
17           _event(event),
18           _text(0),
19           _line(0),
20           _rect(0),
21           _widget(0)
22 {
23         _text = new Text(*this);
24         assert(_text);
25         ostringstream pgm(ios::ate);
26         pgm << int(event->pgm_number());
27         _text->property_text() = pgm.str();
28         _text->property_justification() = Gtk::JUSTIFY_CENTER;
29         _text->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_MidiProgramChangeOutline.get();
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() = ARDOUR_UI::config()->canvasvar_MidiProgramChangeOutline.get();
37         _rect = new SimpleRect(*this, 0.0, 0.0, flagwidth, flagheight);
38         _rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_MidiProgramChangeOutline.get();
39         _rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_MidiProgramChangeFill.get();
40         _text->lower_to_bottom();
41         _text->raise(2);
42         assert(_widget == 0);
43         assert(_text != 0);
44         assert(_line != 0);
45         assert(_rect != 0);
46 }
47
48 CanvasProgramChange::~CanvasProgramChange()
49 {
50         if(_line)
51                 delete _line;
52         if(_rect)
53                 delete _rect;
54         if(_text)
55                 delete _text;
56         if(_widget)
57                 delete _widget;
58 }
59
60