src/foundation/ZTicks.h

00001 /*  @(#) $Id: ZTicks.h,v 1.7 2006/07/15 20:54:22 goingware Exp $ */
00002 
00003 /* ------------------------------------------------------------
00004 Copyright (c) 2000 Andrew Green and Learning in Motion, Inc.
00005 http://www.zoolib.org
00006 
00007 Permission is hereby granted, free of charge, to any person obtaining a copy
00008 of this software and associated documentation files (the "Software"), to deal
00009 in the Software without restriction, including without limitation the rights
00010 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00011 copies of the Software, and to permit persons to whom the Software is
00012 furnished to do so, subject to the following conditions:
00013 
00014 The above copyright notice and this permission notice shall be included in
00015 all copies or substantial portions of the Software.
00016 
00017 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00018 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00020 COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00021 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00022 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00023 ------------------------------------------------------------ */
00024 
00025 #ifndef __ZTicks__
00026 #define __ZTicks__ 1
00027 #include "zconfig.h"
00028 
00029 #include "ZTypes.h"
00030 
00031 #if ZCONFIG(OS, MacOS7) || ZCONFIG(OS, Carbon) || ZCONFIG(OS, MacOSX)
00032 #       if ZCONFIG(OS, MacOSX)
00033 #               include <HIToolbox/Events.h>
00034 #       else
00035 #               include <Events.h> // For GetDblTime & GetCaretTime
00036 #       endif
00037 #endif
00038 
00039 #if ZCONFIG(OS, POSIX)
00040 #       include <sys/time.h> // For timeval
00041 #endif
00042 
00043 #if ZCONFIG(OS, Be)
00044 #       include <interface/InterfaceDefs.h> // for get_click_speed
00045 #       include <kernel/OS.h> // for system_time
00046 #endif
00047 
00048 // =================================================================================================
00049 
00050 namespace ZTicks {
00051 
00052 #if ZCONFIG(OS, MacOS7) || ZCONFIG(OS, Carbon) || ZCONFIG(OS, MacOSX) || ZCONFIG(OS, Win32)
00053 bigtime_t sNow();
00054 
00055 #elif ZCONFIG(OS, POSIX)
00056 inline bigtime_t sNow()
00057         {
00058         timeval theTimeVal;
00059         ::gettimeofday(&theTimeVal, nil);
00060         return (bigtime_t(theTimeVal.tv_sec) * 1000000LL) + bigtime_t(theTimeVal.tv_usec);
00061         }
00062 
00063 #elif ZCONFIG(OS, Be)
00064 inline bigtime_t sNow()
00065         { return ::system_time(); }
00066 
00067 #endif // ZCONFIG_OS
00068 
00069 
00070 inline bigtime_t sPerSecond()
00071         { return 1000000; }
00072 
00073 
00074 #if ZCONFIG(OS, MacOS7) || ZCONFIG(OS, Carbon) || ZCONFIG(OS, MacOSX)
00075 inline bigtime_t sDoubleClick()
00076         { return bigtime_t(::GetDblTime()) * 16667LL; }
00077 
00078 #elif ZCONFIG(OS, Win32)
00079 bigtime_t sDoubleClick();
00080 
00081 #elif ZCONFIG(OS, POSIX)
00082 inline bigtime_t sDoubleClick()
00083         { return sPerSecond() / 10; }
00084 
00085 #elif ZCONFIG(OS, Be)
00086 inline bigtime_t sDoubleClick()
00087         {
00088         bigtime_t result;
00089         ::get_click_speed(&result);
00090         return result;
00091         }
00092 #endif
00093 
00094 #if ZCONFIG(OS, MacOS7) || ZCONFIG(OS, Carbon) || ZCONFIG(OS, MacOSX)
00095 inline bigtime_t sCaretFlash()
00096         { return bigtime_t(::GetCaretTime()) * 16667LL; }
00097 
00098 #else
00099 inline bigtime_t sCaretFlash()
00100         { return sPerSecond() / 5; }
00101 
00102 #endif
00103 
00104 } // namespace ZTicks
00105 
00106 // =================================================================================================
00107 
00108 #endif // __ZTicks__

Generated on Thu Jul 26 11:21:51 2007 for ZooLib by  doxygen 1.4.7