more canvas refactoring.
[ardour.git] / gtk2_ardour / sys_ex.cc
1 /*
2     Copyright (C) 2009 Paul Davis
3     Author: Hans Baier
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #include <iostream>
21 #include "canvas/flag.h"
22 #include "ardour_ui.h"
23 #include "sys_ex.h"
24
25 using namespace std;
26
27 SysEx::SysEx (
28         MidiRegionView& region,
29         ArdourCanvas::Container* parent,
30         string&         text,
31         double          height,
32         double          x,
33         double          y)
34         : _region (region)
35 {
36         _flag = new ArdourCanvas::Flag (
37                 parent,
38                 height, 
39                 ARDOUR_UI::config()->get_canvasvar_MidiSysExOutline(),
40                 ARDOUR_UI::config()->get_canvasvar_MidiSysExFill(),
41                 ArdourCanvas::Duple (x, y)
42                 );
43         
44         _flag->set_text (text);
45 }
46
47 SysEx::~SysEx()
48 {
49 }
50
51 bool
52 SysEx::event_handler (GdkEvent* ev)
53 {
54         switch (ev->type) {
55         case GDK_BUTTON_PRESS:
56                 if (ev->button.button == 3) {
57                         return true;
58                 }
59                 break;
60
61         case GDK_SCROLL:
62                 if (ev->scroll.direction == GDK_SCROLL_UP) {
63                         return true;
64                 } else if (ev->scroll.direction == GDK_SCROLL_DOWN) {
65                         return true;
66                 }
67                 break;
68
69         default:
70                 break;
71         }
72
73         return false;
74 }
75
76 void
77 SysEx::hide ()
78 {
79         _flag->hide ();
80 }
81
82 void
83 SysEx::show ()
84 {
85         _flag->show ();
86 }