Make track selection visible in track headers.
[ardour.git] / gtk2_ardour / keyboard_target.h
1 /*
2     Copyright (C) 2001 Paul Davis 
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18     $Id$
19 */
20
21 #ifndef __ardour_keyboard_target_h__
22 #define __ardour_keyboard_target_h__
23
24 #include <map>
25 #include <string>
26 #include <sigc++/signal.h>
27 #include <sigc++/slot.h>
28 #include <gdk/gdk.h>
29 #include <pbd/xml++.h>
30
31 #include "keyboard.h"
32
33 namespace Gtk {
34         class Window;
35 }
36
37 class KeyboardTarget 
38 {
39   public:
40         KeyboardTarget(Gtk::Window& w, std::string name);
41         virtual ~KeyboardTarget();
42
43         sigc::signal<void> Hiding;
44         sigc::signal<void> GoingAway;
45
46         typedef sigc::slot<void> KeyAction;
47
48         std::string name() const { return _name; }
49
50         void key_press_event (GdkEventKey *, Keyboard::State&, bool& handled);
51         void key_release_event (GdkEventKey *, Keyboard::State&);
52
53         int add_binding (std::string keys, std::string name);
54         std::string get_binding (std::string name); /* returns keys bound to name */
55
56         XMLNode& get_binding_state () const;
57         int set_binding_state (const XMLNode&);
58
59         static int32_t add_action (std::string, KeyAction);
60         static int32_t find_action (std::string, KeyAction&);
61         static int32_t remove_action (std::string);
62         static void show_all_actions();
63
64         Gtk::Window& window() const { return _window; }
65         
66   protected:
67         typedef std::map<Keyboard::State,KeyAction> KeyMap;
68         typedef std::map<std::string,std::string> BindingMap;
69
70         KeyMap     keymap;
71         BindingMap bindings;
72
73   private:
74         typedef map<std::string,KeyAction> ActionMap; 
75         static ActionMap actions;
76         std::string _name;
77         Gtk::Window& _window;
78
79         int load_bindings (const XMLNode&);
80 };
81
82 #endif /* __ardour_keyboard_target_h__ */
83