00001 /* *********************************************************************************** 00002 Writer: Sebastien Bloc 00003 Copyright: 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 00038 class StateMouse 00039 { 00040 public: 00041 Point2D<int> pos; 00042 BOOL leftBtn; 00043 BOOL rightBtn; 00044 BOOL midBtn; 00045 int wheelVal; 00046 int wheelDelta; 00047 00048 StateMouse(); 00049 void operator= (StateMouse &src); 00050 int GetNbButtonPush(); 00051 StateMouse * GetDelta(StateMouse *second); // delta = second-this 00052 void ToString(MyString &str); 00053 }; 00054 00055 #define DebugMouse(context,ptrMouse) { MyString message; message<<context<<" "; if (ptrMouse) (ptrMouse)->ToString(message); else message<<" (NULL)"; Debug0Param(message); } 00056 #define DebugMouse2(context,ptrMouse,face) { MyString message; message<<context<<" "; if (ptrMouse) (ptrMouse)->ToString(message); else message<<" (NULL)"; message<<" Face:"<<face; Debug0Param(message); } 00057 00061 class StateKey 00062 { 00063 public: 00064 char letter; 00065 short code; 00066 BOOL isPush; 00067 00068 StateKey(); 00069 void operator= (StateKey &src); 00070 void ToString(MyString &str); 00071 static BOOL GetState(int code); 00072 00073 }; 00074 00075 #define DebugKey(context,ptrKey) { MyString message; message<<context<<" "; if (ptrKey) (ptrKey)->ToString(message); else message<<" (NULL)"; Debug0Param(message); } 00076 #define DebugKey2(context,ptrKey,face) { MyString message; message<<context<<" "; if (ptrKey) (ptrKey)->ToString(message); else message<<" (NULL)"; message<<" Face:"<<face; Debug0Param(message); } 00077 00078 00119 #define BindTimer(theTimer,methode,frec)\ 00120 {\ 00121 __hook(&EventTimer::Call,&theTimer.onTimer,methode);\ 00122 theTimer.Start(frec);\ 00123 } 00124 class Timer; 00125 00126 [event_source(native)] 00127 class EventTimer 00128 { 00129 public: 00130 __event void Call(Timer *timer); //!< Methode a appeler 00131 }; 00132 00133 class Timer 00134 { 00135 public: 00136 // variable membre static 00137 EventTimer onTimer; 00138 static MyList<Timer *> list; //!< list des instances de TimerEvent 00139 static int nextFreeId; //!< prochain numero de timer valide 00140 static HWND hWnd; //!< hWnd qui collect les messages 00141 static LARGE_INTEGER frecTimer; //!< frequence du timer 00142 00143 public: 00144 // variable membre 00145 int id; //!< id du WM_TIMER en cour 00146 BOOL insideList; //!< cette element est il dans la liste ? 00147 int frequency; //!< frequence de declenchement 00148 LARGE_INTEGER beginTime; 00149 BOOL isRuning; //!< timer en cours 00150 00151 static BOOL Init(HWND _hWnd); // initialise avec la callback gerant les timer 00152 static Timer *Find(int idToFind); // recherche d'un instanciation 00153 static BOOL Call(int idToFind); // A utiliser dans le message WM_TIMER de la callback de hWnd 00154 00155 public: 00156 Timer(); 00157 ~Timer(); 00158 BOOL Start(int frequency); 00159 BOOL Pause(); 00160 BOOL Resume(); 00161 BOOL Stop(); 00162 BOOL Stop(int idToFind); 00163 double GetDeltaTime(BOOL reset=FALSE); 00164 BOOL IsRuning(); 00165 }; 00166 00167 #endif