Fixed bug 2374 - Update copyright for 2014...
Is it that time already??
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
21 #include "../../SDL_internal.h"
23 #if SDL_VIDEO_DRIVER_COCOA
25 #include "SDL_cocoavideo.h"
26 #include "../../events/SDL_clipboardevents_c.h"
31 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
33 if (data->osversion >= 0x1060) {
34 return NSPasteboardTypeString;
36 return NSStringPboardType;
41 Cocoa_SetClipboardText(_THIS, const char *text)
43 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
44 NSAutoreleasePool *pool;
45 NSPasteboard *pasteboard;
46 NSString *format = GetTextFormat(_this);
48 pool = [[NSAutoreleasePool alloc] init];
50 pasteboard = [NSPasteboard generalPasteboard];
51 data->clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
52 [pasteboard setString:[NSString stringWithUTF8String:text] forType:format];
60 Cocoa_GetClipboardText(_THIS)
62 NSAutoreleasePool *pool;
63 NSPasteboard *pasteboard;
64 NSString *format = GetTextFormat(_this);
68 pool = [[NSAutoreleasePool alloc] init];
70 pasteboard = [NSPasteboard generalPasteboard];
71 available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:format]];
72 if ([available isEqualToString:format]) {
76 string = [pasteboard stringForType:format];
80 utf8 = [string UTF8String];
82 text = SDL_strdup(utf8);
84 text = SDL_strdup("");
93 Cocoa_HasClipboardText(_THIS)
95 SDL_bool result = SDL_FALSE;
96 char *text = Cocoa_GetClipboardText(_this);
98 result = text[0] != '\0' ? SDL_TRUE : SDL_FALSE;
105 Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data)
107 NSAutoreleasePool *pool;
108 NSPasteboard *pasteboard;
111 pool = [[NSAutoreleasePool alloc] init];
113 pasteboard = [NSPasteboard generalPasteboard];
114 count = [pasteboard changeCount];
115 if (count != data->clipboard_count) {
116 if (data->clipboard_count) {
117 SDL_SendClipboardUpdate();
119 data->clipboard_count = count;
125 #endif /* SDL_VIDEO_DRIVER_COCOA */
127 /* vi: set ts=4 sw=4 expandtab: */