add requester slider capabilities: vertical orientation and start offset (untested)
[enigma2.git] / lib / actions / action.h
1 #ifndef __lib_driver_action_h
2 #define __lib_driver_action_h
3
4 #include <lib/base/object.h>
5
6                 /* avoid warnigs :) */
7 #include <features.h>
8 #undef _POSIX_C_SOURCE
9 #define _POSIX_C_SOURCE 200112L
10 #include <Python.h>
11 #include <lib/python/python.h>
12 #include <string>
13 #include <map>
14
15 class eWidget;
16
17 class eActionMap: public iObject
18 {
19 DECLARE_REF(eActionMap);
20 public:
21 #ifndef SWIG
22         eActionMap();
23         ~eActionMap();
24         void bindAction(const std::string &context, int priority, int id, eWidget *widget);
25         void unbindAction(eWidget *widget, int id);
26 #endif
27
28         void bindAction(const std::string &context, int priority, PyObject *function);
29         void unbindAction(const std::string &context, PyObject *function);
30         
31         void bindKey(const std::string &device, int key, int flags, const std::string &context, const std::string &action);
32         
33         void keyPressed(int device, int key, int flags);
34         
35         static RESULT getInstance(ePtr<eActionMap> &ptr);
36 #ifndef SWIG
37 private:
38         static eActionMap *instance;
39         struct eActionBinding
40         {
41 //              eActionContext *m_context;
42                 std::string m_context; // FIXME
43                 
44                 PyObject *m_fnc;
45                 
46                 eWidget *m_widget;
47                 int m_id;
48         };
49         
50         std::multimap<int, eActionBinding> m_bindings;
51
52         friend struct compare_string_keybind_native;
53         struct eNativeKeyBinding
54         {
55                 int m_device;
56                 int m_key;
57                 int m_flags;
58                 
59 //              eActionContext *m_context;
60                 int m_action;
61         };
62         
63         std::multimap<std::string, eNativeKeyBinding> m_native_keys;
64         
65         friend struct compare_string_keybind_python;
66         struct ePythonKeyBinding
67         {
68                 int m_device;
69                 int m_key;
70                 int m_flags;
71                 
72                 std::string m_action;
73         };
74         
75         std::multimap<std::string, ePythonKeyBinding> m_python_keys;
76 #endif
77 };
78
79 #endif