Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Examples  

Mouse.H

Go to the documentation of this file.
00001 
00014 #ifndef MOUSE_H
00015 #define MOUSE_H
00016 
00017 // #include <GL/glut.h>
00018 // #include <cmath>
00019 // #include <UserInterface.H>
00020 
00021 // namespace xchen
00022 // {
00023   class UI::Mouse 
00024   {
00025   public:
00026       enum { NoButton=-10, LeftButton=GLUT_LEFT_BUTTON, MiddleButton=GLUT_MIDDLE_BUTTON, RightButton=GLUT_RIGHT_BUTTON }; 
00027 
00028       Mouse(unsigned time=0) : msecs(time), motion_mode(false)    { if(msecs) disableMotionEvent(); }
00029 
00030       void Press(int btn, int x, int y);
00031       void Release(int btn, int x, int y)                         { button = NoButton; motion_mode = false; }
00032       bool MoveTo(int x, int y);                                  
00033       bool MouseMotionMode() const                                { return motion_mode; }
00034       
00035   private:
00036 
00037       int button;
00038       int mousex, mousey;                                         // updated each time Press() is called.
00039       bool motion_mode;
00040       
00041       bool ignore_motion_event;
00042       unsigned msecs;
00043 
00044       static void motion_timer(int)                              { ms->enableMotionEvent(); }
00045       bool ignoreMotionEvent() const                              { return msecs && ignore_motion_event; }
00046       void disableMotionEvent()                                   { ignore_motion_event = true; glutTimerFunc(msecs, motion_timer, 0); }
00047       void enableMotionEvent()                                    { ignore_motion_event = false; }
00048 
00049       bool isDoubleClick(int x, int y)                            { return std::abs(mousex - x) < 3 && std::abs(mousey - y) < 3; }
00050       void simulate3Buttons(int& button);
00051   };
00052 //}
00053 
00054 #endif

Generated on Wed Apr 7 21:40:49 2004 by doxygen1.2.18