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

input.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_INPUT_H
00024 #define INCLUDE_INPUT_H
00025 
00026 #include "trigo.h"
00027 #include "myString.h"
00028 #include "mylist.h"
00029 #include "sigslot.h"
00030 
00041 class StateMouse
00042 {
00043 public:
00044         Point2D<int> pos;
00045         BOOL leftBtn;
00046         BOOL rightBtn;
00047         BOOL midBtn;
00048         int wheelVal;
00049         int wheelDelta;
00050 
00051         StateMouse();
00052         void operator= (StateMouse &src);
00053         int GetNbButtonPush();
00054         StateMouse * GetDelta(StateMouse *second); // delta = second-this
00055 
00056         void ToString(MyString &str);
00057 };
00058 
00059 #define DebugMouse(context,ptrMouse) { MyString message; message<<context<<" "; if (ptrMouse) (ptrMouse)->ToString(message); else message<<" (NULL)"; Debug0Param(message); }
00060 #define DebugMouse2(context,ptrMouse,face) { MyString message; message<<context<<" "; if (ptrMouse) (ptrMouse)->ToString(message); else message<<" (NULL)"; message<<" Face:"<<face; Debug0Param(message); }
00061 
00065 class StateKey
00066 {
00067 private:
00068         int oldDelay;           //! Encienne valeur de delay du clavier
00069         int oldRepeate;         //! Envienne valeur de repeate du clavier
00070 
00071 public:
00072         char letter;
00073         short code;
00074         BOOL isPush;
00075 
00076         StateKey();
00077         ~StateKey();
00078 
00079         void operator= (StateKey &src);
00080         void ToString(MyString &str);
00081 
00082         // tools
00083         static BOOL GetState(int code);
00084         static void SetDelayAndRepeate(int delay,int repeate);
00085         void SaveDelayAndRepeate();
00086         void RestoreDelayAndRepeate();
00087 };
00088 
00089 #define DebugKey(context,ptrKey) { MyString message; message<<context<<" "; if (ptrKey) (ptrKey)->ToString(message); else message<<" (NULL)"; Debug0Param(message); }
00090 #define DebugKey2(context,ptrKey,face) { MyString message; message<<context<<" "; if (ptrKey) (ptrKey)->ToString(message); else message<<" (NULL)"; message<<" Face:"<<face; Debug0Param(message); }
00091 
00092 
00127 using namespace sigslot;  // pour signal (evit l'ecriture sigslot::signal?<...>)
00128 
00132 #define BindTimer(theTimer,methode,frec)\
00133 {\
00134         using namespace sigslot; \
00135         theTimer.onTimer.connect(this,methode);\
00136         theTimer.Start(frec);\
00137 }
00138         
00139 class Timer
00140 {
00141 public:
00142         // variable membre static
00143         static MyList<Timer *> list;    //!< list des instances de TimerEvent
00144         static int nextFreeId;                          //!< prochain numero de timer valide
00145         static HWND hWnd;                                       //!< hWnd qui collect les messages
00146         static LARGE_INTEGER frecTimer;         //!< frequence du timer
00147 
00148 public:
00149         // variable membre
00150         signal1<Timer *> onTimer;                       //!< int Call(Timer *timer)
00151         int id;                                                         //!< id du WM_TIMER en cour
00152         BOOL insideList;                                        //!< cette element est il dans la liste ?
00153         int frequency;                                          //!< frequence de declenchement
00154         LARGE_INTEGER beginTime;
00155         BOOL isRuning;                                          //!< timer en cours
00156 
00157         static BOOL Init(HWND _hWnd);           // initialise avec la callback gerant les timer
00158         static Timer *Find(int idToFind);       // recherche d'un instanciation 
00159         static BOOL Call(int idToFind);         // A utiliser dans le message WM_TIMER de la callback de hWnd
00160 
00161 public:
00162         Timer();
00163         ~Timer();
00164         BOOL Start();
00165         BOOL Start(int frequency);
00166         BOOL Pause();
00167         BOOL Resume();
00168         BOOL Stop();
00169         BOOL StopAndUnBind();
00170         BOOL Stop(int idToFind,BOOL unBind);
00171 
00172         double GetDeltaTime(BOOL reset=FALSE);
00173         double GetDeltaTime(BOOL reset,LARGE_INTEGER *referenceTime);
00174 
00175         BOOL IsRuning();
00176 };
00177 
00178 #endif

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