Make Dropdown menus at least as wide as the button
[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 "sys_ex.h"
23 #include "ui_config.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 {
35         _flag = new ArdourCanvas::Flag (
36                 parent,
37                 height,
38                 UIConfiguration::instance().color ("midi sysex outline"),
39                 UIConfiguration::instance().color_mod ("midi sysex fill", "midi sysex fill"),
40                 ArdourCanvas::Duple (x, y)
41                 );
42
43         _flag->set_text (text);
44 }
45
46 SysEx::~SysEx()
47 {
48 }
49
50 bool
51 SysEx::event_handler (GdkEvent* ev)
52 {
53         switch (ev->type) {
54         case GDK_BUTTON_PRESS:
55                 if (ev->button.button == 3) {
56                         return true;
57                 }
58                 break;
59
60         case GDK_SCROLL:
61                 if (ev->scroll.direction == GDK_SCROLL_UP) {
62                         return true;
63                 } else if (ev->scroll.direction == GDK_SCROLL_DOWN) {
64                         return true;
65                 }
66                 break;
67
68         default:
69                 break;
70         }
71
72         return false;
73 }
74
75 void
76 SysEx::hide ()
77 {
78         _flag->hide ();
79 }
80
81 void
82 SysEx::show ()
83 {
84         _flag->show ();
85 }