author | Sam Lantinga <slouken@libsdl.org> |
Fri, 08 Apr 2011 13:03:26 -0700 | |
changeset 5535 | 96594ac5fd1a |
parent 5466 | 006883d5fa51 |
child 5544 | 7bf3c86d8b60 |
permissions | -rw-r--r-- |
1931
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 |
/* |
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5466
diff
changeset
|
2 |
Simple DirectMedia Layer |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5466
diff
changeset
|
3 |
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org> |
1931
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5466
diff
changeset
|
5 |
This software is provided 'as-is', without any express or implied |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5466
diff
changeset
|
6 |
warranty. In no event will the authors be held liable for any damages |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5466
diff
changeset
|
7 |
arising from the use of this software. |
1931
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5466
diff
changeset
|
9 |
Permission is granted to anyone to use this software for any purpose, |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5466
diff
changeset
|
10 |
including commercial applications, and to alter it and redistribute it |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5466
diff
changeset
|
11 |
freely, subject to the following restrictions: |
1931
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5466
diff
changeset
|
13 |
1. The origin of this software must not be misrepresented; you must not |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5466
diff
changeset
|
14 |
claim that you wrote the original software. If you use this software |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5466
diff
changeset
|
15 |
in a product, an acknowledgment in the product documentation would be |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5466
diff
changeset
|
16 |
appreciated but is not required. |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5466
diff
changeset
|
17 |
2. Altered source versions must be plainly marked as such, and must not be |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5466
diff
changeset
|
18 |
misrepresented as being the original software. |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5466
diff
changeset
|
19 |
3. This notice may not be removed or altered from any source distribution. |
1931
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 |
*/ |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 |
#include "SDL_config.h" |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 |
|
5375
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
23 |
#include "SDL_endian.h" |
1931
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 |
#include "SDL_cocoavideo.h" |
4827
5660aac926e9
Got basic, pre-actually-writing-anything Cocoa to build.
egottlieb
parents:
4810
diff
changeset
|
25 |
#include "SDL_cocoashape.h" |
3660
2d17445190f6
Fixed Mac OS X assertion code.
Ryan C. Gordon <icculus@icculus.org>
parents:
3647
diff
changeset
|
26 |
#include "SDL_assert.h" |
1931
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 |
|
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 |
/* Initialization/Query functions */ |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 |
static int Cocoa_VideoInit(_THIS); |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 |
static void Cocoa_VideoQuit(_THIS); |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 |
|
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 |
/* Cocoa driver bootstrap functions */ |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 |
|
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 |
static int |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 |
Cocoa_Available(void) |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 |
{ |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 |
return (1); |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 |
} |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 |
|
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 |
static void |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 |
Cocoa_DeleteDevice(SDL_VideoDevice * device) |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 |
{ |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 |
SDL_free(device->driverdata); |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 |
SDL_free(device); |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 |
} |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 |
|
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 |
static SDL_VideoDevice * |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 |
Cocoa_CreateDevice(int devindex) |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 |
{ |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 |
SDL_VideoDevice *device; |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 |
SDL_VideoData *data; |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 |
|
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 |
Cocoa_RegisterApp(); |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 |
|
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 |
/* Initialize all variables that we clean on shutdown */ |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 |
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 |
if (device) { |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 |
data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); |
4457 | 59 |
} else { |
60 |
data = NULL; |
|
1931
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 |
} |
4457 | 62 |
if (!data) { |
1931
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 |
SDL_OutOfMemory(); |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 |
if (device) { |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 |
SDL_free(device); |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 |
} |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 |
return NULL; |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 |
} |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 |
device->driverdata = data; |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 |
|
1959
25d6537feea4
Implemented Cocoa key event handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1952
diff
changeset
|
71 |
/* Find out what version of Mac OS X we're running */ |
25d6537feea4
Implemented Cocoa key event handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1952
diff
changeset
|
72 |
Gestalt(gestaltSystemVersion, &data->osversion); |
25d6537feea4
Implemented Cocoa key event handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1952
diff
changeset
|
73 |
|
1931
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 |
/* Set the function pointers */ |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 |
device->VideoInit = Cocoa_VideoInit; |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 |
device->VideoQuit = Cocoa_VideoQuit; |
3528
59ff7a2beb57
Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents:
3280
diff
changeset
|
77 |
device->GetDisplayBounds = Cocoa_GetDisplayBounds; |
1931
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 |
device->GetDisplayModes = Cocoa_GetDisplayModes; |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 |
device->SetDisplayMode = Cocoa_SetDisplayMode; |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 |
device->PumpEvents = Cocoa_PumpEvents; |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 |
|
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 |
device->CreateWindow = Cocoa_CreateWindow; |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 |
device->CreateWindowFrom = Cocoa_CreateWindowFrom; |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 |
device->SetWindowTitle = Cocoa_SetWindowTitle; |
5375
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
85 |
device->SetWindowIcon = Cocoa_SetWindowIcon; |
1931
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 |
device->SetWindowPosition = Cocoa_SetWindowPosition; |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 |
device->SetWindowSize = Cocoa_SetWindowSize; |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 |
device->ShowWindow = Cocoa_ShowWindow; |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 |
device->HideWindow = Cocoa_HideWindow; |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 |
device->RaiseWindow = Cocoa_RaiseWindow; |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 |
device->MaximizeWindow = Cocoa_MaximizeWindow; |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 |
device->MinimizeWindow = Cocoa_MinimizeWindow; |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 |
device->RestoreWindow = Cocoa_RestoreWindow; |
5249
7a963be087ef
Mostly fixed fullscreen mode on Mac OS X, and you can toggle it on and off.
Sam Lantinga <slouken@libsdl.org>
parents:
5088
diff
changeset
|
94 |
device->SetWindowFullscreen = Cocoa_SetWindowFullscreen; |
5466 | 95 |
device->SetWindowGammaRamp = Cocoa_SetWindowGammaRamp; |
96 |
device->GetWindowGammaRamp = Cocoa_GetWindowGammaRamp; |
|
1931
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 |
device->SetWindowGrab = Cocoa_SetWindowGrab; |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 |
device->DestroyWindow = Cocoa_DestroyWindow; |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 |
device->GetWindowWMInfo = Cocoa_GetWindowWMInfo; |
4810
7a602fd2121f
OK, it appears that dramatic hacks are not necessary to make Cocoa work...
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4457
diff
changeset
|
100 |
|
7a602fd2121f
OK, it appears that dramatic hacks are not necessary to make Cocoa work...
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4457
diff
changeset
|
101 |
device->shape_driver.CreateShaper = Cocoa_CreateShaper; |
7a602fd2121f
OK, it appears that dramatic hacks are not necessary to make Cocoa work...
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4457
diff
changeset
|
102 |
device->shape_driver.SetWindowShape = Cocoa_SetWindowShape; |
7a602fd2121f
OK, it appears that dramatic hacks are not necessary to make Cocoa work...
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4457
diff
changeset
|
103 |
device->shape_driver.ResizeWindowShape = Cocoa_ResizeWindowShape; |
7a602fd2121f
OK, it appears that dramatic hacks are not necessary to make Cocoa work...
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4457
diff
changeset
|
104 |
|
5088 | 105 |
#if SDL_VIDEO_OPENGL_CGL |
1931
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 |
device->GL_LoadLibrary = Cocoa_GL_LoadLibrary; |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 |
device->GL_GetProcAddress = Cocoa_GL_GetProcAddress; |
3057
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
108 |
device->GL_UnloadLibrary = Cocoa_GL_UnloadLibrary; |
1931
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 |
device->GL_CreateContext = Cocoa_GL_CreateContext; |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 |
device->GL_MakeCurrent = Cocoa_GL_MakeCurrent; |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 |
device->GL_SetSwapInterval = Cocoa_GL_SetSwapInterval; |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 |
device->GL_GetSwapInterval = Cocoa_GL_GetSwapInterval; |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 |
device->GL_SwapWindow = Cocoa_GL_SwapWindow; |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 |
device->GL_DeleteContext = Cocoa_GL_DeleteContext; |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 |
#endif |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 |
|
3280
00cace2d9080
Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
117 |
device->StartTextInput = Cocoa_StartTextInput; |
00cace2d9080
Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
118 |
device->StopTextInput = Cocoa_StopTextInput; |
00cace2d9080
Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
119 |
device->SetTextInputRect = Cocoa_SetTextInputRect; |
00cace2d9080
Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
120 |
|
4499
c2ebe3e020c6
Added Mac OS X implementation of clipboard support
Sam Lantinga <slouken@libsdl.org>
parents:
4498
diff
changeset
|
121 |
device->SetClipboardText = Cocoa_SetClipboardText; |
c2ebe3e020c6
Added Mac OS X implementation of clipboard support
Sam Lantinga <slouken@libsdl.org>
parents:
4498
diff
changeset
|
122 |
device->GetClipboardText = Cocoa_GetClipboardText; |
c2ebe3e020c6
Added Mac OS X implementation of clipboard support
Sam Lantinga <slouken@libsdl.org>
parents:
4498
diff
changeset
|
123 |
device->HasClipboardText = Cocoa_HasClipboardText; |
c2ebe3e020c6
Added Mac OS X implementation of clipboard support
Sam Lantinga <slouken@libsdl.org>
parents:
4498
diff
changeset
|
124 |
|
1931
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 |
device->free = Cocoa_DeleteDevice; |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 |
|
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 |
return device; |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 |
} |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 |
|
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 |
VideoBootStrap COCOA_bootstrap = { |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 |
"cocoa", "SDL Cocoa video driver", |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 |
Cocoa_Available, Cocoa_CreateDevice |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 |
}; |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 |
|
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 |
|
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 |
int |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 |
Cocoa_VideoInit(_THIS) |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 |
{ |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 |
Cocoa_InitModes(_this); |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 |
Cocoa_InitKeyboard(_this); |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 |
Cocoa_InitMouse(_this); |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 |
return 0; |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 |
} |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 |
|
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 |
void |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 |
Cocoa_VideoQuit(_THIS) |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 |
{ |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 |
Cocoa_QuitModes(_this); |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 |
Cocoa_QuitKeyboard(_this); |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 |
Cocoa_QuitMouse(_this); |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 |
} |
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 |
|
5375
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
153 |
/* This function assumes that it's called from within an autorelease pool */ |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
154 |
NSImage * |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
155 |
Cocoa_CreateImage(SDL_Surface * surface) |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
156 |
{ |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
157 |
SDL_Surface *converted; |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
158 |
NSBitmapImageRep *imgrep; |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
159 |
Uint8 *pixels; |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
160 |
int i; |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
161 |
NSImage *img; |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
162 |
|
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
163 |
converted = SDL_ConvertSurfaceFormat(surface, |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
164 |
#if SDL_BYTEORDER == SDL_BIG_ENDIAN |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
165 |
SDL_PIXELFORMAT_RGBA8888, |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
166 |
#else |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
167 |
SDL_PIXELFORMAT_ABGR8888, |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
168 |
#endif |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
169 |
0); |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
170 |
if (!converted) { |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
171 |
return nil; |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
172 |
} |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
173 |
|
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
174 |
imgrep = [[[NSBitmapImageRep alloc] initWithBitmapDataPlanes: NULL |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
175 |
pixelsWide: converted->w |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
176 |
pixelsHigh: converted->h |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
177 |
bitsPerSample: 8 |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
178 |
samplesPerPixel: 4 |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
179 |
hasAlpha: YES |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
180 |
isPlanar: NO |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
181 |
colorSpaceName: NSDeviceRGBColorSpace |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
182 |
bytesPerRow: converted->pitch |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
183 |
bitsPerPixel: converted->format->BitsPerPixel] autorelease]; |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
184 |
if (imgrep == nil) { |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
185 |
SDL_FreeSurface(converted); |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
186 |
return nil; |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
187 |
} |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
188 |
|
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
189 |
/* Copy the pixels */ |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
190 |
pixels = [imgrep bitmapData]; |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
191 |
SDL_memcpy(pixels, converted->pixels, converted->h * converted->pitch); |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
192 |
SDL_FreeSurface(converted); |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
193 |
|
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
194 |
/* Premultiply the alpha channel */ |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
195 |
for (i = (converted->h * converted->w); i--; ) { |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
196 |
Uint8 alpha = pixels[3]; |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
197 |
pixels[0] = (Uint8)(((Uint16)pixels[0] * alpha) / 255); |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
198 |
pixels[1] = (Uint8)(((Uint16)pixels[1] * alpha) / 255); |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
199 |
pixels[2] = (Uint8)(((Uint16)pixels[2] * alpha) / 255); |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
200 |
pixels += 4; |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
201 |
} |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
202 |
|
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
203 |
img = [[[NSImage alloc] initWithSize: NSMakeSize(surface->w, surface->h)] autorelease]; |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
204 |
if (img != nil) { |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
205 |
[img addRepresentation: imgrep]; |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
206 |
} |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
207 |
return img; |
16877f74123c
Implemented Cocoa_SetWindowIcon(), added SDL_ConvertSurfaceFormat()
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
208 |
} |
3647
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
209 |
|
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
210 |
/* |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
211 |
* Mac OS X assertion support. |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
212 |
* |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
213 |
* This doesn't really have aything to do with the interfaces of the SDL video |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
214 |
* subsystem, but we need to stuff this into an Objective-C source code file. |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
215 |
*/ |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
216 |
|
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
217 |
SDL_assert_state |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
218 |
SDL_PromptAssertion_cocoa(const SDL_assert_data *data) |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
219 |
{ |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
220 |
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
221 |
|
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
222 |
NSString *msg = [NSString stringWithFormat: |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
223 |
@"Assertion failure at %s (%s:%d), triggered %u time%s:\n '%s'", |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
224 |
data->function, data->filename, data->linenum, |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
225 |
data->trigger_count, (data->trigger_count == 1) ? "" : "s", |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
226 |
data->condition]; |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
227 |
|
3660
2d17445190f6
Fixed Mac OS X assertion code.
Ryan C. Gordon <icculus@icculus.org>
parents:
3647
diff
changeset
|
228 |
NSLog(@"%s", msg); |
3647
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
229 |
|
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
230 |
/* |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
231 |
* !!! FIXME: this code needs to deal with fullscreen modes: |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
232 |
* !!! FIXME: reset to default desktop, runModal, reset to current? |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
233 |
*/ |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
234 |
|
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
235 |
NSAlert* alert = [[NSAlert alloc] init]; |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
236 |
[alert setAlertStyle:NSCriticalAlertStyle]; |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
237 |
[alert setMessageText:msg]; |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
238 |
[alert addButtonWithTitle:@"Retry"]; |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
239 |
[alert addButtonWithTitle:@"Break"]; |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
240 |
[alert addButtonWithTitle:@"Abort"]; |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
241 |
[alert addButtonWithTitle:@"Ignore"]; |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
242 |
[alert addButtonWithTitle:@"Always Ignore"]; |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
243 |
const NSInteger clicked = [alert runModal]; |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
244 |
[pool release]; |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
245 |
return (SDL_assert_state) (clicked - NSAlertFirstButtonReturn); |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
246 |
} |
c5925cd41955
First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
3528
diff
changeset
|
247 |
|
1931
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 |
/* vim: set ts=4 sw=4 expandtab: */ |