2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2011 Sam Lantinga
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "SDL_config.h"
24 #include "SDL_cocoavideo.h"
25 #include "../../events/SDL_clipboardevents_c.h"
30 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
31 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
33 if (data->osversion >= 0x1060) {
34 return NSPasteboardTypeString;
36 return NSStringPboardType;
39 return NSStringPboardType;
44 Cocoa_SetClipboardText(_THIS, const char *text)
46 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
47 NSAutoreleasePool *pool;
48 NSPasteboard *pasteboard;
49 NSString *format = GetTextFormat(_this);
51 pool = [[NSAutoreleasePool alloc] init];
53 pasteboard = [NSPasteboard generalPasteboard];
54 data->clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
55 [pasteboard setString:[NSString stringWithUTF8String:text] forType:format];
63 Cocoa_GetClipboardText(_THIS)
65 NSAutoreleasePool *pool;
66 NSPasteboard *pasteboard;
67 NSString *format = GetTextFormat(_this);
71 pool = [[NSAutoreleasePool alloc] init];
73 pasteboard = [NSPasteboard generalPasteboard];
74 available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:format]];
75 if ([available isEqualToString:format]) {
79 string = [pasteboard stringForType:format];
83 utf8 = [string UTF8String];
85 text = SDL_strdup(utf8);
87 text = SDL_strdup("");
96 Cocoa_HasClipboardText(_THIS)
98 NSAutoreleasePool *pool;
99 NSPasteboard *pasteboard;
100 NSString *format = GetTextFormat(_this);
104 pool = [[NSAutoreleasePool alloc] init];
106 pasteboard = [NSPasteboard generalPasteboard];
107 available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:format]];
108 if ([available isEqualToString:format]) {
120 Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data)
122 NSAutoreleasePool *pool;
123 NSPasteboard *pasteboard;
126 pool = [[NSAutoreleasePool alloc] init];
128 pasteboard = [NSPasteboard generalPasteboard];
129 count = [pasteboard changeCount];
130 if (count != data->clipboard_count) {
131 if (data->clipboard_count) {
132 SDL_SendClipboardUpdate();
134 data->clipboard_count = count;
140 /* vi: set ts=4 sw=4 expandtab: */