Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

control.h

Go to the documentation of this file.
00001 /* ***********************************************************************************
00002         Writer:         Sebastien Bloc
00003         Copyright:      2003-2004
00004         eMail:          sebastien.bloc@free.fr
00005         URL:            http://mignonsoft.free.fr
00006 
00007         This program is free software; you can redistribute it and/or
00008         modify it under the terms of the GNU General Public License
00009         as published by the Free Software Foundation; either version 2
00010         of the License, or (at your option) any later version.
00011 
00012         This program is distributed in the hope that it will be useful,
00013         but WITHOUT ANY WARRANTY; without even the implied warranty of
00014         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015         GNU General Public License for more details.
00016         http://www.gnu.org/copyleft/gpl.html
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 // parametre des dimentions des controls
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  *      Gestion des debugs
00047  */
00048 
00049 // Info de debug
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 // Pas d'info de debug
00057 /*
00058 #define Debug0Param(text)
00059 #define Debug1Param(text,p1)
00060 #define Debug2Param(text,p1,p2)
00061 #define Debug3Param(text,p1,p2,p3)
00062 */
00063 typedef Point2D<int> Point2D_int;
00064 typedef Point2D<double> Point2D_double;
00065 
00066 using namespace sigslot;  // pour signal (evit l'ecriture sigslot::signal?<...>)
00067 
00078 class EventMouseButton
00079 { 
00080 public:
00081         signal2<StateMouse *,int > up;                  //Call: int OnUp(StateMouse *mouse,int face);
00082         signal2<StateMouse *,int > down;                //Call: int OnDown(StateMouse *mouse,int face);
00083         signal2<StateMouse *,int > doubleClick; //Call: int OnDoubleClick(StateMouse *mouse,int face);
00084         signal2<StateMouse *,int > click;               //Call: int OnClick(StateMouse *mouse,int face);
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 private:
00097         static StateKey oldKey;
00098         static int oldFace;
00099         static Timer *timerDoubleClick;
00100 
00101         void TimeOutDoubleClick()
00102         {
00103                 timer->StopAndUnBind();
00104                 click(&oldKey,oldFace);
00105         }
00106 */
00107 public:
00108         signal2<StateKey *,int> up;                             //Call: int OnUp(StateKey *key,int face);
00109         signal2<StateKey *,int> down;                   //Call: int OnDown(StateKey *key,int face);
00110         signal2<StateKey *,int> doubleClick;    //Call: int OnDoubleClick(StateKey *key,int face);
00111         signal2<StateKey *,int> click;                  //Call: int OnClick(StateKey *key,int face);
00112 
00113         int GetNbLinks()
00114         {
00115                 return up.size()+down.size()+doubleClick.size()+click.size();
00116         }
00117 /*
00118         int Up(StateKey *key,int face)
00119         {
00120                 if (doubleClick.size())
00121                 {
00122                         oldKey=*key;
00123                         oldFace=face;
00124                         BindTimer(timerDoubleClick,TimeOutDoubleClick,10);
00125                 }
00126         }
00127 
00128         int Down()
00129         {
00130                 if (doubleClick.size())
00131                 {
00132                         timerDoubleClick->StopAndUnBind();
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; //Call: int OnMove(StateMouse *mouse,int deltaX,int deltaY,int face);
00161         signal2<StateMouse *,int> wheel;//Call: int OnWheel(StateMouse *mouse,int face);
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; //Call: int OnIn(Control *oldControl,int face);
00181         signal2<Control *,int> out;//Call: int OnOut(Control *newControl,int face);
00182 
00183         int GetNbLinks()
00184         {
00185                 return in.size()+out.size();
00186         }
00187 } ;
00188 
00189 class EventFaceOver
00190 {
00191 public:
00192         signal1<int> in; //Call: int OnIn(int face);
00193         signal1<int> out;//Call: int OnOut(int face);
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;      //Call: int OnSleeped();
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         // list des instansition de control
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         // variable membre
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         // evenement disponible
00256         EventControl onControl;
00257 
00258         // methodes
00259 private:
00260         BOOL UseInertia(int numButton,StateMouse *mouse,int face);//utilise une inertie sur bouton souris up uniquement
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();                                                               // config le parent
00270         BOOL Delete();                                                                  // supression de l'element dans la liste static
00271         void DeleteFaces();                                                             // supression des face du control
00272         void DeleteSub();                                                               // supression des controls contenue
00273         static Control * Find(int _idControl);                  // recherche un control par son idControl dans la list des instances
00274         void operator= (Control &src);                                  // operateur de copie   
00275         virtual void Create() {};                                               // pour le prototipage des conteneurs
00276         void ToString(MyString &str);                                   // pour le debugage
00277         void SetBlending(BOOL enable);                                  // active/desactive le blending sur toute les faces
00278         void SetAlphaBlending(float alpha);                             // positionne l'alpha de toute le faces
00279         void SetLines(Color color,float size);                  // positionne les ligne de toute le faces
00280 
00281         void OverIn(Control *oldControl,int face);              // on rentre sur le control
00282         void OverOut(Control *newControl,int face);             // on part du control
00283         void FaceOverIn (int oldFace);                                  // on entre sur un nouvelle face du control
00284         void FaceOverOut (int newFace);                                 // on sort d'un face
00285 
00286         BOOL ScreenMove(double x,double y,double z);    // deplace en position ecran
00287         BOOL ScreenMoveTo(double x,double y,double z);  // place en position ecran
00288         BOOL Move(double x,double y,double z);                  // deplace le control
00289         BOOL MoveTo(double x,double y,double z);                // positione le control
00290         BOOL Size(double x,double y);                                   // assigne une taille du control
00291         BOOL ReSize(double dx,double dy);                               // redimetionne un control
00292         BOOL Rotate(double x,double y,double z);                // delta-rotation du control
00293         BOOL RotateQuaternion(double x,double y,double z);// delta-rotation du control par rapport a l'unives
00294         BOOL RotateTo(double x,double y,double z);              // assigne une rotation du control
00295 
00296         // placement par rapport au pere
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);   // rotation de wheel de la souris
00309         int OnMouseMove(StateMouse *mouse,int face);    // la souris bouge      
00310         int OnLButtonDown(StateMouse *mouse,int face);  // appuis
00311         int OnMButtonDown(StateMouse *mouse,int face);  // appuis
00312         int OnRButtonDown(StateMouse *mouse,int face);  // appuis
00313         int OnLButtonUp(StateMouse *mouse,int face);    // relachement
00314         int OnMButtonUp(StateMouse *mouse,int face);    // relachement
00315         int OnRButtonUp(StateMouse *mouse,int face);    // relachement 
00316         int OnLButtonDouble(StateMouse *mouse,int face);// double click
00317         int OnMButtonDouble(StateMouse *mouse,int face);// double click
00318         int OnRButtonDouble(StateMouse *mouse,int face);// double click
00319         int OnKeyUp(StateKey *key,int face);                    // appuis 
00320         int OnKeyDown(StateKey *key,int face);                  // relachement
00321         int OnKeyDouble(StateKey *key,int face);                // double click 
00322         int OnClick(StateMouse *mouse,int face);                // click sans chagement de control depuis l'appuis
00323 
00324         void GetCorners(int face,Point3D<double> *points);
00325         Point2D<double> GetLocalPos(int face,Point2D<double> absolutePos);
00326 };
00327 
00328 #endif

Generated on Fri Aug 20 19:19:43 2004 for 3d Controls by doxygen 1.3.6