23 #if SDL_VIDEO_DRIVER_COCOA
25 #if defined(__APPLE__) && defined(__POWERPC__) && !defined(__APPLE_ALTIVEC__)
37 @interface SDLMessageBoxPresenter : NSObject {
43 - (
void) alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(
void *)contextInfo;
46 @implementation SDLMessageBoxPresenter
64 - (
void)showAlert:(NSAlert*)alert
67 [alert beginSheetModalForWindow:nswindow modalDelegate:self didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) contextInfo:nil];
74 clicked = [alert runModal];
78 - (
void) alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(
void *)contextInfo
92 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
94 NSAlert* alert = [[[NSAlert alloc] init] autorelease];
97 [alert setAlertStyle:NSCriticalAlertStyle];
99 [alert setAlertStyle:NSWarningAlertStyle];
101 [alert setAlertStyle:NSInformationalAlertStyle];
104 [alert setMessageText:[NSString stringWithUTF8String:messageboxdata->title]];
105 [alert setInformativeText:[NSString stringWithUTF8String:messageboxdata->message]];
109 for (i = 0; i < messageboxdata->
numbuttons; ++i) {
110 NSButton *button = [alert addButtonWithTitle:[NSString stringWithUTF8String:buttons[i].text]];
112 [button setKeyEquivalent:@"\r"];
114 [button setKeyEquivalent:@"\033"];
116 [button setKeyEquivalent:@""];
120 SDLMessageBoxPresenter* presenter = [[[SDLMessageBoxPresenter alloc] initWithParentWindow:messageboxdata->window] autorelease];
122 [presenter performSelectorOnMainThread:@selector(showAlert:)
127 NSInteger clicked = presenter->clicked;
128 if (clicked >= NSAlertFirstButtonReturn)
130 clicked -= NSAlertFirstButtonReturn;
131 *buttonid = buttons[clicked].
buttonid;
135 returnValue =
SDL_SetError(
"Did not get a valid `clicked button' id: %d", clicked);
void Cocoa_RegisterApp(void)
GLvoid **typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
DECLSPEC void SDLCALL SDL_PumpEvents(void)
DECLSPEC void SDLCALL SDL_Delay(Uint32 ms)
Wait a specified number of milliseconds before returning.
DECLSPEC int SDLCALL SDL_SetError(const char *fmt,...)
const SDL_MessageBoxButtonData * buttons
MessageBox structure containing title, text, window, etc.
GLenum GLsizei GLsizei GLsizei GLsizei GLbitfield flags