comparison src/video/cocoa/SDL_cocoaclipboard.m @ 4501:0cf025066b6f

Updated Xcode project files for clipboard API Fixed generation of SDL_revision.h when hg is in the path set up in .bash_profile
author Sam Lantinga <slouken@libsdl.org>
date Thu, 08 Jul 2010 06:16:27 -0700
parents c2ebe3e020c6
children 524dfefd554c
comparison
equal deleted inserted replaced
4500:eff4e88cc1e8 4501:0cf025066b6f
21 */ 21 */
22 #include "SDL_config.h" 22 #include "SDL_config.h"
23 23
24 #include "SDL_cocoavideo.h" 24 #include "SDL_cocoavideo.h"
25 25
26 static NSString *
27 GetTextFormat(_THIS)
28 {
29 #if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
30 return NSStringPboardType;
31 #else
32 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
33
34 if (data->osversion >= 0x1060) {
35 return NSPasteboardTypeString;
36 } else {
37 return NSStringPboardType;
38 }
39 #endif
40 }
26 41
27 int 42 int
28 Cocoa_SetClipboardText(_THIS, const char *text) 43 Cocoa_SetClipboardText(_THIS, const char *text)
29 { 44 {
30 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
31 NSAutoreleasePool *pool; 45 NSAutoreleasePool *pool;
32 NSPasteboard *pasteboard; 46 NSPasteboard *pasteboard;
33 NSString *format; 47 NSString *format = GetTextFormat(_this);
34
35 if (data->osversion >= 0x1060) {
36 format = NSPasteboardTypeString;
37 } else {
38 format = NSStringPboardType;
39 }
40 48
41 pool = [[NSAutoreleasePool alloc] init]; 49 pool = [[NSAutoreleasePool alloc] init];
42 50
43 pasteboard = [NSPasteboard generalPasteboard]; 51 pasteboard = [NSPasteboard generalPasteboard];
44 [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil]; 52 [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
50 } 58 }
51 59
52 char * 60 char *
53 Cocoa_GetClipboardText(_THIS) 61 Cocoa_GetClipboardText(_THIS)
54 { 62 {
55 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
56 NSAutoreleasePool *pool; 63 NSAutoreleasePool *pool;
57 NSPasteboard *pasteboard; 64 NSPasteboard *pasteboard;
58 NSString *format; 65 NSString *format = GetTextFormat(_this);
59 NSString *available; 66 NSString *available;
60 char *text; 67 char *text;
61
62 if (data->osversion >= 0x1060) {
63 format = NSPasteboardTypeString;
64 } else {
65 format = NSStringPboardType;
66 }
67 68
68 pool = [[NSAutoreleasePool alloc] init]; 69 pool = [[NSAutoreleasePool alloc] init];
69 70
70 pasteboard = [NSPasteboard generalPasteboard]; 71 pasteboard = [NSPasteboard generalPasteboard];
71 available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:format]]; 72 available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:format]];
90 } 91 }
91 92
92 SDL_bool 93 SDL_bool
93 Cocoa_HasClipboardText(_THIS) 94 Cocoa_HasClipboardText(_THIS)
94 { 95 {
95 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
96 NSAutoreleasePool *pool; 96 NSAutoreleasePool *pool;
97 NSPasteboard *pasteboard; 97 NSPasteboard *pasteboard;
98 NSString *format; 98 NSString *format = GetTextFormat(_this);
99 NSString *available; 99 NSString *available;
100 SDL_bool result; 100 SDL_bool result;
101
102 if (data->osversion >= 0x1060) {
103 format = NSPasteboardTypeString;
104 } else {
105 format = NSStringPboardType;
106 }
107 101
108 pool = [[NSAutoreleasePool alloc] init]; 102 pool = [[NSAutoreleasePool alloc] init];
109 103
110 pasteboard = [NSPasteboard generalPasteboard]; 104 pasteboard = [NSPasteboard generalPasteboard];
111 available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:format]]; 105 available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:format]];