2014-10-16 21:03:24 +00:00
|
|
|
#include "compat.h"
|
2006-04-13 20:47:06 +00:00
|
|
|
#include "osxbits.h"
|
2006-07-01 01:40:18 +00:00
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
|
|
|
|
#ifndef MAC_OS_VERSION_10_3
|
|
|
|
# define MAC_OS_VERSION_10_3 1030
|
|
|
|
#endif
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2014-10-16 21:03:24 +00:00
|
|
|
int osx_msgbox(const char *name, const char *msg)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2014-10-16 21:03:24 +00:00
|
|
|
NSString *mmsg = [[NSString alloc] initWithUTF8String:msg];
|
2006-07-01 01:40:18 +00:00
|
|
|
|
|
|
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
|
|
|
|
NSAlert *alert = [[NSAlert alloc] init];
|
2006-04-13 20:47:06 +00:00
|
|
|
[alert addButtonWithTitle: @"OK"];
|
2006-07-01 01:40:18 +00:00
|
|
|
[alert setInformativeText: mmsg];
|
2006-04-13 20:47:06 +00:00
|
|
|
[alert setAlertStyle: NSInformationalAlertStyle];
|
2014-10-16 21:03:24 +00:00
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
[alert runModal];
|
2014-10-16 21:03:24 +00:00
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
[alert release];
|
2006-07-01 01:40:18 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
NSRunAlertPanel(nil, mmsg, @"OK", nil, nil);
|
|
|
|
#endif
|
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
[mmsg release];
|
2014-10-16 21:03:24 +00:00
|
|
|
|
|
|
|
UNREFERENCED_PARAMETER(name);
|
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-10-16 21:03:24 +00:00
|
|
|
int osx_ynbox(const char *name, const char *msg)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2014-10-16 21:03:24 +00:00
|
|
|
NSString *mmsg = [[NSString alloc] initWithUTF8String:msg];
|
2006-04-13 20:47:06 +00:00
|
|
|
int r;
|
|
|
|
|
2006-07-01 01:40:18 +00:00
|
|
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
|
|
|
|
NSAlert *alert = [[NSAlert alloc] init];
|
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
[alert addButtonWithTitle:@"Yes"];
|
|
|
|
[alert addButtonWithTitle:@"No"];
|
2006-07-01 01:40:18 +00:00
|
|
|
[alert setInformativeText: mmsg];
|
2006-04-13 20:47:06 +00:00
|
|
|
[alert setAlertStyle: NSInformationalAlertStyle];
|
2014-10-16 21:03:24 +00:00
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
r = ([alert runModal] == NSAlertFirstButtonReturn);
|
|
|
|
|
|
|
|
[alert release];
|
2006-07-01 01:40:18 +00:00
|
|
|
#else
|
|
|
|
r = (NSRunAlertPanel(nil, mmsg, @"Yes", @"No", nil) == NSAlertDefaultReturn);
|
|
|
|
#endif
|
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
[mmsg release];
|
2014-10-16 21:03:24 +00:00
|
|
|
|
|
|
|
UNREFERENCED_PARAMETER(name);
|
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
return r;
|
|
|
|
}
|