Add: Overlay cargo icon in vehicle/depot list when holding shift+ctrl. (#12938)
[openttd-github.git] / src / os / macosx / macos.h
blob33f016a34bc594072921625297428b0cc681a6da
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
8 /** @file macos.h Functions related to MacOS support. */
10 #ifndef MACOS_H
11 #define MACOS_H
13 /** Helper function displaying a message the best possible way. */
14 void ShowMacDialog(const char *title, const char *message, const char *button_label);
16 void GetMacOSVersion(int *return_major, int *return_minor, int *return_bugfix);
18 /**
19 * Check if we are at least running on the specified version of Mac OS.
20 * @param major major version of the os. This would be 10 in the case of 10.4.11.
21 * @param minor minor version of the os. This would be 4 in the case of 10.4.11.
22 * @param bugfix bugfix version of the os. This would be 11 in the case of 10.4.11.
23 * @return true if the running os is at least what we asked, false otherwise.
25 inline bool MacOSVersionIsAtLeast(long major, long minor, long bugfix)
27 int version_major, version_minor, version_bugfix;
28 GetMacOSVersion(&version_major, &version_minor, &version_bugfix);
30 if (version_major < major) return false;
31 if (version_major == major && version_minor < minor) return false;
32 if (version_major == major && version_minor == minor && version_bugfix < bugfix) return false;
34 return true;
37 bool IsMonospaceFont(CFStringRef name);
39 void MacOSSetThreadName(const char *name);
41 uint64_t MacOSGetPhysicalMemory();
44 /** Deleter that calls CFRelease rather than deleting the pointer. */
45 template <typename T> struct CFDeleter {
46 void operator()(T *p)
48 if (p) ::CFRelease(p);
52 /** Specialisation of std::unique_ptr for CoreFoundation objects. */
53 template <typename T>
54 using CFAutoRelease = std::unique_ptr<typename std::remove_pointer<T>::type, CFDeleter<typename std::remove_pointer<T>::type>>;
56 #endif /* MACOS_H */