00001
00002
00003
00004 #ifndef GEST_INT_H_HAS_BEEN_INCLUDED
00005 #define GEST_INT_H_HAS_BEEN_INCLUDED
00006
00007 #include "geom/fsa.H"
00008 #include "manip/manip.H"
00009 #include "std/stop_watch.H"
00010
00011 #include "gesture.H"
00012
00013
00014 class GestObs;
00015
00016
00017
00018
00019 class GESTURE_list : public LIST<GESTUREptr> {
00020 public:
00021
00022 GESTURE_list(int n=0) : LIST<GESTUREptr>(n) { begin_index(); }
00023 GESTURE_list(const GESTURE_list& list) : LIST<GESTUREptr>(list) {
00024 begin_index();
00025 }
00026
00027 virtual ~GESTURE_list() { end_index(); }
00028
00029
00030 virtual void set_index(CGESTUREptr& g, int i) const {
00031
00032
00033
00034
00035
00036 if (g)
00037 ((GESTUREptr&)g)->set_index(i);
00038 }
00039 virtual void clear_index(CGESTUREptr& g) const { set_index(g, BAD_IND); }
00040 virtual int get_index (CGESTUREptr& g) const {
00041 return g ? ((GESTUREptr&)g)->index() : BAD_IND;
00042 }
00043 };
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 #define CGEST_INTptr const GEST_INTptr
00055 MAKE_PTR_SUBC(GEST_INT,FRAMEobs);
00056
00057 class GEST_INT : public FRAMEobs, public CAMobs, public Simple_int {
00058 protected:
00059 VIEWptr _view;
00060 ARRAY<GestObs*> _obs;
00061 GESTURE_list _stack;
00062 GestureDrawer* _drawer;
00063 FSA _fsa;
00064
00065 State _b2_pressed;
00066
00067
00068 bool _keep_history;
00069
00070 int _num_history;
00071
00072 void activate();
00073 void deactivate();
00074
00075 public:
00076
00077 GEST_INT(CVIEWptr& view,
00078 CEvent &d, CEvent &m, CEvent &u,
00079 CEvent &d2, CEvent &u2);
00080 virtual ~GEST_INT()
00081 {
00082 err_mesg(ERR_LEV_SPAM, "GEST_INT destructor");
00083 }
00084
00085
00086
00087 void rem_obs(GestObs* g);
00088 void add_obs(GestObs* g);
00089
00090
00091 void reset() { _fsa.reset(); }
00092
00093
00094 void set_drawer(GestureDrawer* drawer) { _drawer = drawer; }
00095 GestureDrawer* drawer() { return _drawer; }
00096
00097 void set_keep_history(bool b)
00098 {
00099 err_mesg(ERR_LEV_SPAM, "GEST_INT::set keep history() - Now is %d",(b)?(1):(0));
00100 _keep_history = b;
00101 }
00102 bool keep_history() { return _keep_history; }
00103 void start_history();
00104
00105
00106
00107 GESTUREptr gesture(int k) const {
00108 return _stack.valid_index(k) ? _stack[k] : GESTUREptr(0);
00109 }
00110 GESTUREptr last() const { return gesture(_stack.num()-1); }
00111
00112 virtual int null_cb(CEvent&, State*&) { return 0; }
00113
00114
00115 virtual int down(CEvent &,State *&);
00116 virtual int move(CEvent &,State *&);
00117 virtual int up (CEvent &,State *&);
00118
00119
00120 virtual void notify(CCAMdataptr &data);
00121
00122
00123 virtual int tick();
00124 };
00125
00126
00127
00128
00129
00130
00131
00132 class GestObs {
00133 public:
00134
00135 virtual ~GestObs() {}
00136
00137
00138 virtual void notify_gesture(GEST_INT* gest_int, CGESTUREptr& gest) = 0;
00139
00140
00141
00142 virtual int handle_event(CEvent&, State* &) { return 0; }
00143 };
00144
00145 #endif // GEST_INT_H_HAS_BEEN_INCLUDED
00146
00147