00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00023 #ifndef INCLUDE_CONTROL_H
00024 #define INCLUDE_CONTROL_H
00025 
00026 #include "MyList.h"
00027 #include "MyString.h"
00028 #include "MyDebug.h"
00029 #include "input.h"
00030 #include "inertia.h"
00031 #include "face.h"
00032 #include "sigslot.h"
00033 
00034 
00035 #define DEFAULT_DEPTH_TEXTBOX            4
00036 #define DEFAULT_DEPTH_MAX_BUTTON         5
00037 #define DEFAULT_DEPTH_MIN_BUTTON         1 // ne peut etre =0 sinon erreur de picking
00038 #define DEFAULT_DEPTH_CONTAINER          3
00039 #define DEFAULT_DEPTH_TITLE                      2
00040 #define DEFAULT_DEPTH_WINDOW             10 
00041 #define DEFAULT_SIZE_TRACK_BUTTON        16
00042 
00043 #define TIME_OUT_PUSH_DOWN_BUTTON    0.3
00044 
00045 
00046 
00047 
00048 
00049 
00050 
00051 #define Debug0Param(text) MyDebug::SendEvent(name,text);
00052 #define Debug1Param(text,p1) MyDebug::SendEvent(name,text,p1);
00053 #define Debug2Param(text,p1,p2) MyDebug::SendEvent(name,text,p1,p2);
00054 #define Debug3Param(text,p1,p2,p3) MyDebug::SendEvent(name,text,p1,p2,p3);
00055 
00056 
00057 
00058 
00059 
00060 
00061 
00062 
00063 typedef Point2D<int> Point2D_int;
00064 typedef Point2D<double> Point2D_double;
00065 
00066 using namespace sigslot;  
00067 
00078 class EventMouseButton
00079 { 
00080 public:
00081         signal2<StateMouse *,int > up;                  
00082         signal2<StateMouse *,int > down;                
00083         signal2<StateMouse *,int > doubleClick; 
00084         signal2<StateMouse *,int > click;               
00085 
00086         Timer timerClick;
00087         int GetNbLinks()
00088         {
00089                 return up.size()+down.size()+doubleClick.size()+click.size();
00090         }
00091 };
00092 
00093 class EventKey
00094 { 
00095 
00096 
00097 
00098 
00099 
00100 
00101 
00102 
00103 
00104 
00105 
00106 
00107 public:
00108         signal2<StateKey *,int> up;                             
00109         signal2<StateKey *,int> down;                   
00110         signal2<StateKey *,int> doubleClick;    
00111         signal2<StateKey *,int> click;                  
00112 
00113         int GetNbLinks()
00114         {
00115                 return up.size()+down.size()+doubleClick.size()+click.size();
00116         }
00117 
00118 
00119 
00120 
00121 
00122 
00123 
00124 
00125 
00126 
00127 
00128 
00129 
00130 
00131 
00132 
00133 
00134 
00135 
00136 };
00137 
00138 typedef enum
00139 {
00140         buttonLeft = 0,
00141         buttonMid = 1,
00142         buttonRight = 2
00143 } TypeButton;
00144 
00155 class EventMouse
00156 {
00157 public:
00158         EventMouseButton left,right,mid;
00159 
00160         signal4<StateMouse *,int,int,int> move; 
00161         signal2<StateMouse *,int> wheel;
00162 
00163         int GetNbLinks()
00164         {
00165                 return move.size()+wheel.size()+left.GetNbLinks()+right.GetNbLinks()+mid.GetNbLinks();
00166         }
00167 } ;
00168 
00177 class EventOver
00178 {
00179 public:
00180         signal2<Control *,int> in; 
00181         signal2<Control *,int> out;
00182 
00183         int GetNbLinks()
00184         {
00185                 return in.size()+out.size();
00186         }
00187 } ;
00188 
00189 class EventFaceOver
00190 {
00191 public:
00192         signal1<int> in; 
00193         signal1<int> out;
00194 
00195         int GetNbLinks()
00196         {
00197                 return in.size()+out.size();
00198         }
00199 } ;
00200 
00201 class EventControl
00202 {
00203 public:
00204         EventMouse mouse;
00205         EventKey key;
00206         EventOver over;
00207         EventFaceOver faceOver;
00208         signal0<> sleeped;      
00209 
00210         int GetNbLinks()
00211         {
00212                 return mouse.GetNbLinks()+key.GetNbLinks()+over.GetNbLinks()+faceOver.GetNbLinks()+sleeped.size();
00213         }
00214 };
00215 
00231 class Control : public has_slots<>
00232 {
00233 public:
00234         
00235         static MyList<Control *> controls;      
00236         static int nextId;
00237         static Inertia inertia;
00238         static Timer timerAutoWheel;    
00239         static Timer timerSleeped;              
00240         static BOOL leftDown;                   
00241         static BOOL midDown;                    
00242         static BOOL rightDown;                  
00243 
00244 public:
00245         
00246         int id;
00247         FaceNode *faceNode;                     
00248         MyString name;
00249         BOOL isEnable;
00250         BOOL isView;
00251         int sleepedDelay;                       
00252         Control *parent;                        
00253         int parentFace;                         
00254 
00255         
00256         EventControl onControl;
00257 
00258         
00259 private:
00260         BOOL UseInertia(int numButton,StateMouse *mouse,int face);
00261         int  OnAutoMouseWheel(Timer *timer);
00262         int  OnSleeped(Timer *timer);
00263         void DeleteSub(FaceNode *curFaceNode);
00264         void DeleteFaces(FaceNode *curFaceNode);
00265 
00266 public:
00267         Control();
00268         ~Control();
00269         void SetParent();                                                               
00270         BOOL Delete();                                                                  
00271         void DeleteFaces();                                                             
00272         void DeleteSub();                                                               
00273         static Control * Find(int _idControl);                  
00274         void operator= (Control &src);                                  
00275         virtual void Create() {};                                               
00276         void ToString(MyString &str);                                   
00277         void SetBlending(BOOL enable);                                  
00278         void SetAlphaBlending(float alpha);                             
00279         void SetLines(Color color,float size);                  
00280 
00281         void OverIn(Control *oldControl,int face);              
00282         void OverOut(Control *newControl,int face);             
00283         void FaceOverIn (int oldFace);                                  
00284         void FaceOverOut (int newFace);                                 
00285 
00286         BOOL ScreenMove(double x,double y,double z);    
00287         BOOL ScreenMoveTo(double x,double y,double z);  
00288         BOOL Move(double x,double y,double z);                  
00289         BOOL MoveTo(double x,double y,double z);                
00290         BOOL Size(double x,double y);                                   
00291         BOOL ReSize(double dx,double dy);                               
00292         BOOL Rotate(double x,double y,double z);                
00293         BOOL RotateQuaternion(double x,double y,double z);
00294         BOOL RotateTo(double x,double y,double z);              
00295 
00296         
00297         BOOL XDockLeft(double margeX,double sizeX,BOOL isCenter=FALSE);
00298         BOOL XDockRight(double margeX,double sizeX,BOOL isCenter=FALSE);
00299         BOOL XDockCenter(double sizeX);
00300         BOOL XDockCenter(double margeLeft,double margeRight);
00301         BOOL YDockTop(double margeY,double sizeY,BOOL isCenter=FALSE);
00302         BOOL YDockBottom(double margeY,double sizeY,BOOL isCenter=FALSE);
00303         BOOL YDockCenter(double sizeY);
00304         BOOL YDockCenter(double margeTop,double margeBottom);
00305 
00306         BOOL ChangeDirection();
00307 
00308         int OnMouseWheel(StateMouse *mouse,int face);   
00309         int OnMouseMove(StateMouse *mouse,int face);    
00310         int OnLButtonDown(StateMouse *mouse,int face);  
00311         int OnMButtonDown(StateMouse *mouse,int face);  
00312         int OnRButtonDown(StateMouse *mouse,int face);  
00313         int OnLButtonUp(StateMouse *mouse,int face);    
00314         int OnMButtonUp(StateMouse *mouse,int face);    
00315         int OnRButtonUp(StateMouse *mouse,int face);    
00316         int OnLButtonDouble(StateMouse *mouse,int face);
00317         int OnMButtonDouble(StateMouse *mouse,int face);
00318         int OnRButtonDouble(StateMouse *mouse,int face);
00319         int OnKeyUp(StateKey *key,int face);                    
00320         int OnKeyDown(StateKey *key,int face);                  
00321         int OnKeyDouble(StateKey *key,int face);                
00322         int OnClick(StateMouse *mouse,int face);                
00323 
00324         void GetCorners(int face,Point3D<double> *points);
00325         Point2D<double> GetLocalPos(int face,Point2D<double> absolutePos);
00326 };
00327 
00328 #endif