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
|
|
|
|
|
|
|
int osx_msgbox(char *name, char *msg)
|
|
|
|
{
|
|
|
|
NSString *mmsg = [[NSString alloc] initWithCString: 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];
|
|
|
|
|
|
|
|
[alert runModal];
|
|
|
|
|
|
|
|
[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];
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int osx_ynbox(char *name, char *msg)
|
|
|
|
{
|
|
|
|
NSString *mmsg = [[NSString alloc] initWithCString: msg];
|
|
|
|
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];
|
|
|
|
|
|
|
|
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];
|
|
|
|
return r;
|
|
|
|
}
|