ocinput.h

Go to the documentation of this file.
00001 #ifndef ocinput_h
00002 #define ocinput_h
00003 
00004 #include <InterViews/input.h>
00005 #include <InterViews/event.h>
00006 #include <InterViews/handler.h>
00007 
00008 class HandlerList;
00009 
00010 public StandardInputHandler : public InputHandler {
00011 public:
00012    StandardInputHandler(Glyph*, Style*);
00013    virtual ~StandardInputHandler();
00014    
00015    virtual void bind_select(Handler* h) {bind_press(Event::left, h);}
00016    virtual void bind_adjust(Handler* h) {bind_press(Event::middle, h);}
00017    virtual void bind_menu(Handler* h) {bind_press(Event::right, h);}
00018 
00019    virtual void move(const Event& e) { mouse(0, e); }
00020    virtual void press(const Event& e) { mouse(1, e); }
00021    virtual void drag(const Event& e) { mouse(2, e); }
00022    virtual void release(const Event& e) { mouse(3, e); }
00023    void mouse(int, const Event&);
00024 
00025    void bind_move(EventButton eb, Handler* h) {bind(0, eb, h);}
00026    void bind_press(EventButton eb, Handler* h) {bind(0, eb, h);}
00027    void bind_drag(EventButton eb, Handler* h) {bind(0, eb, h);}
00028    void bind_release(EventButton eb, Handler* h) {bind(0, eb, h);}
00029    void bind(int, EventButton eb, Handler* h) {bind(0, eb, h);}
00030    void remove_all(EventButton);
00031 private:
00032    HandlerList* handlers_[4];
00033 };
00034 
00035 /*
00036  * Handler denoted by an object and member function to call on the object.
00037  * Used the FieldEditorAction as a template
00038  */
00039  
00040 #if defined(__STDC__) || defined(__ANSI_CPP__) || defined (WIN32)
00041 #define __HandlerCallback(T) T##_HandlerCallback
00042 #define HandlerCallback(T) __HandlerCallback(T)
00043 #define __HandlerMemberFunction(T) T##_HandlerMemberFunction
00044 #define HandlerMemberFunction(T) __HandlerMemberFunction(T)
00045 #else
00046 #define __HandlerCallback(T) T_HandlerCallback
00047 #define HandlerCallback(T) __HandlerCallback(T)
00048 #define __HandlerMemberFunction(T) T_HandlerMemberFunction
00049 #define HandlerMemberFunction(T) __HandlerMemberFunction(T)
00050 #endif
00051 
00052 #define declareHandlerCallback(T) \
00053 typedef void (T::*HandlerMemberFunction(T))(Event&); \
00054 class HandlerCallback(T) : public Handler { \
00055 public: \
00056     HandlerCallback(T)(T*, HandlerMemberFunction(T)); \
00057     virtual ~HandlerCallback(T)(); \
00058 \
00059     virtual void event(Event&); \
00060 private: \
00061     T* obj_; \
00062     HandlerMemberFunction(T) func_; \
00063 };
00064 
00065 #define implementHandlerCallback(T) \
00066 HandlerCallback(T)::HandlerCallback(T)( \
00067     T* obj, HandlerMemberFunction(T) func \
00068 ) { \
00069     obj_ = obj; \
00070     func_ = func; \
00071 } \
00072 \
00073 HandlerCallback(T)::~HandlerCallback(T)() { } \
00074 \
00075 void HandlerCallback(T)::event(Event& e) { \
00076     (obj_->*func_)(e); \
00077 }
00078 
00079 #endif
Generated on Mon Jun 13 08:10:24 2011 for NEURON by  doxygen 1.6.3