macos.h

Go to the documentation of this file.
00001 /* $Id: macos.h 13913 2008-08-01 17:43:11Z bjarni $ */
00002 
00005 #ifndef MACOS_H
00006 #define MACOS_H
00007 
00008 /* It would seem that to ensure backward compability we have to ensure that we have defined MAC_OS_X_VERSION_10_x everywhere */
00009 #ifndef MAC_OS_X_VERSION_10_3
00010 #define MAC_OS_X_VERSION_10_3 1030
00011 #endif
00012 
00013 #ifndef MAC_OS_X_VERSION_10_4
00014 #define MAC_OS_X_VERSION_10_4 1040
00015 #endif
00016 
00017 #ifndef MAC_OS_X_VERSION_10_5
00018 #define MAC_OS_X_VERSION_10_5 1050
00019 #endif
00020 
00021 
00022 /*
00023  * Functions to show the popup window
00024  * use ShowMacDialog when you want to control title, message and text on the button
00025  * ShowMacAssertDialog is used by assert
00026  * ShowMacErrorDialog should be used when an unrecoverable error shows up. It only contains the title, which will should tell what went wrong
00027  * the function then adds text that tells the user to update and then report the bug if it's present in the newest version
00028  * It also quits in a nice way since we call it when we know something happened that will crash OpenTTD (like a needed pointer turns out to be NULL or similar)
00029  */
00030 void ShowMacDialog ( const char *title, const char *message, const char *buttonLabel );
00031 void ShowMacAssertDialog ( const char *function, const char *file, const int line, const char *expression );
00032 void ShowMacErrorDialog(const char *error);
00033 
00034 // Since MacOS X users will never see an assert unless they started the game from a terminal
00035 // we're using a custom assert(e) macro.
00036 #undef assert
00037 
00038 #ifdef NDEBUG
00039 #define assert(e)       ((void)0)
00040 #else
00041 
00042 #define assert(e) \
00043     (__builtin_expect(!(e), 0) ? ShowMacAssertDialog ( __func__, __FILE__, __LINE__, #e ): (void)0 )
00044 #endif
00045 
00046 
00047 
00052 long GetMacOSVersionMajor();
00053 
00058 long GetMacOSVersionMinor();
00059 
00064 long GetMacOSVersionBugfix();
00065 
00073 static inline bool MacOSVersionIsAtLeast(long major, long minor, long bugfix)
00074 {
00075   long maj = GetMacOSVersionMajor();
00076   long min = GetMacOSVersionMinor();
00077   long bf = GetMacOSVersionBugfix();
00078 
00079   if (maj < major) return false;
00080   if (maj == major && min < minor) return false;
00081   if (maj == major && min == minor && bf < bugfix) return false;
00082 
00083   return true;
00084 }
00085 
00086 #endif /* MACOS_H */

Generated on Mon Feb 16 23:12:09 2009 for openttd by  doxygen 1.5.6