Mercurial > dwindows
comparison mac/dw.m @ 1895:fafe1a68f0fd
Fixed OS X 10.9 issues by migrating to NSAlert from newly deprecated methods.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Fri, 25 Oct 2013 09:38:21 +0000 |
parents | 09860ba329a4 |
children | 8637a32d33d9 |
comparison
equal
deleted
inserted
replaced
1894:ed377fd16360 | 1895:fafe1a68f0fd |
---|---|
3361 * format: printf style format string. | 3361 * format: printf style format string. |
3362 * ...: Additional variables for use in the format. | 3362 * ...: Additional variables for use in the format. |
3363 */ | 3363 */ |
3364 int API dw_messagebox(char *title, int flags, char *format, ...) | 3364 int API dw_messagebox(char *title, int flags, char *format, ...) |
3365 { | 3365 { |
3366 int iResponse; | 3366 NSAlert *alert; |
3367 NSInteger iResponse; | |
3367 NSString *button1 = @"OK"; | 3368 NSString *button1 = @"OK"; |
3368 NSString *button2 = nil; | 3369 NSString *button2 = nil; |
3369 NSString *button3 = nil; | 3370 NSString *button3 = nil; |
3370 va_list args; | 3371 va_list args; |
3371 char outbuf[1025] = {0}; | |
3372 | |
3373 va_start(args, format); | |
3374 vsnprintf(outbuf, 1024, format, args); | |
3375 va_end(args); | |
3376 | 3372 |
3377 if(flags & DW_MB_OKCANCEL) | 3373 if(flags & DW_MB_OKCANCEL) |
3378 { | 3374 { |
3379 button2 = @"Cancel"; | 3375 button2 = @"Cancel"; |
3380 } | 3376 } |
3388 button1 = @"Yes"; | 3384 button1 = @"Yes"; |
3389 button2 = @"No"; | 3385 button2 = @"No"; |
3390 button3 = @"Cancel"; | 3386 button3 = @"Cancel"; |
3391 } | 3387 } |
3392 | 3388 |
3389 va_start(args, format); | |
3390 alert = [NSAlert alertWithMessageText:[ NSString stringWithUTF8String:title ] defaultButton:button1 alternateButton:button2 otherButton:button3 informativeTextWithFormat:@"%@", [[[NSString alloc] initWithFormat:[NSString stringWithUTF8String:format] arguments:args] autorelease]]; | |
3391 va_end(args); | |
3392 | |
3393 iResponse = [alert runModal]; | |
3394 | |
3393 if(flags & DW_MB_ERROR) | 3395 if(flags & DW_MB_ERROR) |
3394 { | 3396 [alert setAlertStyle:NSCriticalAlertStyle]; |
3395 iResponse = (int) | |
3396 NSRunCriticalAlertPanel([ NSString stringWithUTF8String:title ], | |
3397 [ NSString stringWithUTF8String:outbuf ], | |
3398 button1, button2, button3); | |
3399 } | |
3400 else if(flags & DW_MB_INFORMATION) | 3397 else if(flags & DW_MB_INFORMATION) |
3401 { | 3398 [alert setAlertStyle:NSInformationalAlertStyle]; |
3402 iResponse = (int) | |
3403 NSRunInformationalAlertPanel([ NSString stringWithUTF8String:title ], | |
3404 [ NSString stringWithUTF8String:outbuf ], | |
3405 button1, button2, button3); | |
3406 } | |
3407 else | 3399 else |
3408 { | 3400 [alert setAlertStyle:NSWarningAlertStyle]; |
3409 iResponse = (int) | |
3410 NSRunAlertPanel([ NSString stringWithUTF8String:title ], | |
3411 [ NSString stringWithUTF8String:outbuf ], | |
3412 button1, button2, button3); | |
3413 } | |
3414 | 3401 |
3415 switch(iResponse) | 3402 switch(iResponse) |
3416 { | 3403 { |
3417 case NSAlertDefaultReturn: /* user pressed OK */ | 3404 case NSAlertDefaultReturn: /* user pressed OK */ |
3418 if(flags & DW_MB_YESNO || flags & DW_MB_YESNOCANCEL) | 3405 if(flags & DW_MB_YESNO || flags & DW_MB_YESNOCANCEL) |