NEURON
ocinput.h
Go to the documentation of this file.
1 #ifndef ocinput_h
2 #define ocinput_h
3 
4 #include <InterViews/input.h>
5 #include <InterViews/event.h>
6 #include <InterViews/handler.h>
7 
8 class HandlerList;
9 
10 public StandardInputHandler : public InputHandler {
11 public:
13  virtual ~StandardInputHandler();
14 
15  virtual void bind_select(Handler* h) {bind_press(Event::left, h);}
16  virtual void bind_adjust(Handler* h) {bind_press(Event::middle, h);}
17  virtual void bind_menu(Handler* h) {bind_press(Event::right, h);}
18 
19  virtual void move(const Event& e) { mouse(0, e); }
20  virtual void press(const Event& e) { mouse(1, e); }
21  virtual void drag(const Event& e) { mouse(2, e); }
22  virtual void release(const Event& e) { mouse(3, e); }
23  void mouse(int, const Event&);
24 
25  void bind_move(EventButton eb, Handler* h) {bind(0, eb, h);}
26  void bind_press(EventButton eb, Handler* h) {bind(0, eb, h);}
27  void bind_drag(EventButton eb, Handler* h) {bind(0, eb, h);}
28  void bind_release(EventButton eb, Handler* h) {bind(0, eb, h);}
29  void bind(int, EventButton eb, Handler* h) {bind(0, eb, h);}
30  void remove_all(EventButton);
31 private:
32  HandlerList* handlers_[4];
33 };
34 
35 /*
36  * Handler denoted by an object and member function to call on the object.
37  * Used the FieldEditorAction as a template
38  */
39 
40 #if defined(__STDC__) || defined(__ANSI_CPP__) || defined (WIN32)
41 #define __HandlerCallback(T) T##_HandlerCallback
42 #define HandlerCallback(T) __HandlerCallback(T)
43 #define __HandlerMemberFunction(T) T##_HandlerMemberFunction
44 #define HandlerMemberFunction(T) __HandlerMemberFunction(T)
45 #else
46 #define __HandlerCallback(T) T/**/_HandlerCallback
47 #define HandlerCallback(T) __HandlerCallback(T)
48 #define __HandlerMemberFunction(T) T/**/_HandlerMemberFunction
49 #define HandlerMemberFunction(T) __HandlerMemberFunction(T)
50 #endif
51 
52 #define declareHandlerCallback(T) \
53 typedef void (T::*HandlerMemberFunction(T))(Event&); \
54 class HandlerCallback(T) : public Handler { \
55 public: \
56  HandlerCallback(T)(T*, HandlerMemberFunction(T)); \
57  virtual ~HandlerCallback(T)(); \
58 \
59  virtual void event(Event&); \
60 private: \
61  T* obj_; \
62  HandlerMemberFunction(T) func_; \
63 };
64 
65 #define implementHandlerCallback(T) \
66 HandlerCallback(T)::HandlerCallback(T)( \
67  T* obj, HandlerMemberFunction(T) func \
68 ) { \
69  obj_ = obj; \
70  func_ = func; \
71 } \
72 \
73 HandlerCallback(T)::~HandlerCallback(T)() { } \
74 \
75 void HandlerCallback(T)::event(Event& e) { \
76  (obj_->*func_)(e); \
77 }
78 
79 #endif
void bind_drag(EventButton eb, Handler *h)
Definition: ocinput.h:27
virtual void bind_select(Handler *h)
Definition: ocinput.h:15
void bind_press(EventButton eb, Handler *h)
Definition: ocinput.h:26
#define Glyph
Definition: _defines.h:132
#define InputHandler
Definition: _defines.h:151
void mouse(int, const Event &)
#define Handler
Definition: _defines.h:146
void bind(int, EventButton eb, Handler *h)
Definition: ocinput.h:29
#define e
Definition: passive0.cpp:24
virtual void bind_menu(Handler *h)
Definition: ocinput.h:17
void remove_all(EventButton)
virtual void drag(const Event &e)
Definition: ocinput.h:21
void bind_move(EventButton eb, Handler *h)
Definition: ocinput.h:25
virtual void press(const Event &e)
Definition: ocinput.h:20
#define left
Definition: rbtqueue.cpp:45
virtual void move(const Event &e)
Definition: ocinput.h:19
#define Event
Definition: _defines.h:107
virtual void release(const Event &e)
Definition: ocinput.h:22
HandlerList * handlers_[4]
Definition: ocinput.h:32
#define right
Definition: rbtqueue.cpp:46
void bind_release(EventButton eb, Handler *h)
Definition: ocinput.h:28
public StandardInputHandler
Definition: ocinput.h:8
#define Style
Definition: _defines.h:281
virtual void bind_adjust(Handler *h)
Definition: ocinput.h:16
#define EventButton
Definition: _defines.h:21
public Style *virtual ~StandardInputHandler()