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/>.
8 /** @file macos.h Functions related to MacOS support. */
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
);
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;
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
{
48 if (p
) ::CFRelease(p
);
52 /** Specialisation of std::unique_ptr for CoreFoundation objects. */
54 using CFAutoRelease
= std::unique_ptr
<typename
std::remove_pointer
<T
>::type
, CFDeleter
<typename
std::remove_pointer
<T
>::type
>>;