annotate src/video/SDL_clipboard.c @ 5159:307ccc9c135e

Made it possible to create a texture of any format, even if not supported by the renderer. This allows me to reduce the set of formats supported by the renderers to the most optimal set, for a nice speed boost.
author Sam Lantinga <slouken@libsdl.org>
date Thu, 03 Feb 2011 00:19:40 -0800
parents b577f47379f3
children b530ef003506
rev   line source
4493
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3 Copyright (C) 1997-2010 Sam Lantinga
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Lesser General Public License for more details.
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@libsdl.org
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22 #include "SDL_config.h"
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 #include "SDL_clipboard.h"
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 #include "SDL_sysvideo.h"
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 int
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 SDL_SetClipboardText(const char *text)
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 {
4495
dbbfdb9ea716 Simplified clipboard API for sanity's sake.
Sam Lantinga <slouken@libsdl.org>
parents: 4493
diff changeset
31 SDL_VideoDevice *_this = SDL_GetVideoDevice();
dbbfdb9ea716 Simplified clipboard API for sanity's sake.
Sam Lantinga <slouken@libsdl.org>
parents: 4493
diff changeset
32
4500
eff4e88cc1e8 Added Windows clipboard support
Sam Lantinga <slouken@libsdl.org>
parents: 4495
diff changeset
33 if (!text) {
eff4e88cc1e8 Added Windows clipboard support
Sam Lantinga <slouken@libsdl.org>
parents: 4495
diff changeset
34 text = "";
eff4e88cc1e8 Added Windows clipboard support
Sam Lantinga <slouken@libsdl.org>
parents: 4495
diff changeset
35 }
4495
dbbfdb9ea716 Simplified clipboard API for sanity's sake.
Sam Lantinga <slouken@libsdl.org>
parents: 4493
diff changeset
36 if (_this->SetClipboardText) {
dbbfdb9ea716 Simplified clipboard API for sanity's sake.
Sam Lantinga <slouken@libsdl.org>
parents: 4493
diff changeset
37 return _this->SetClipboardText(_this, text);
dbbfdb9ea716 Simplified clipboard API for sanity's sake.
Sam Lantinga <slouken@libsdl.org>
parents: 4493
diff changeset
38 } else {
dbbfdb9ea716 Simplified clipboard API for sanity's sake.
Sam Lantinga <slouken@libsdl.org>
parents: 4493
diff changeset
39 _this->clipboard_text = SDL_strdup(text);
dbbfdb9ea716 Simplified clipboard API for sanity's sake.
Sam Lantinga <slouken@libsdl.org>
parents: 4493
diff changeset
40 return 0;
dbbfdb9ea716 Simplified clipboard API for sanity's sake.
Sam Lantinga <slouken@libsdl.org>
parents: 4493
diff changeset
41 }
4493
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 }
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 char *
4506
b577f47379f3 Fixed compile warnings
Sam Lantinga <slouken@libsdl.org>
parents: 4500
diff changeset
45 SDL_GetClipboardText(void)
4493
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 {
4495
dbbfdb9ea716 Simplified clipboard API for sanity's sake.
Sam Lantinga <slouken@libsdl.org>
parents: 4493
diff changeset
47 SDL_VideoDevice *_this = SDL_GetVideoDevice();
4493
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48
4495
dbbfdb9ea716 Simplified clipboard API for sanity's sake.
Sam Lantinga <slouken@libsdl.org>
parents: 4493
diff changeset
49 if (_this->GetClipboardText) {
dbbfdb9ea716 Simplified clipboard API for sanity's sake.
Sam Lantinga <slouken@libsdl.org>
parents: 4493
diff changeset
50 return _this->GetClipboardText(_this);
4493
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 } else {
4495
dbbfdb9ea716 Simplified clipboard API for sanity's sake.
Sam Lantinga <slouken@libsdl.org>
parents: 4493
diff changeset
52 const char *text = _this->clipboard_text;
dbbfdb9ea716 Simplified clipboard API for sanity's sake.
Sam Lantinga <slouken@libsdl.org>
parents: 4493
diff changeset
53 if (!text) {
dbbfdb9ea716 Simplified clipboard API for sanity's sake.
Sam Lantinga <slouken@libsdl.org>
parents: 4493
diff changeset
54 text = "";
dbbfdb9ea716 Simplified clipboard API for sanity's sake.
Sam Lantinga <slouken@libsdl.org>
parents: 4493
diff changeset
55 }
dbbfdb9ea716 Simplified clipboard API for sanity's sake.
Sam Lantinga <slouken@libsdl.org>
parents: 4493
diff changeset
56 return SDL_strdup(text);
4493
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 }
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 }
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 SDL_bool
4506
b577f47379f3 Fixed compile warnings
Sam Lantinga <slouken@libsdl.org>
parents: 4500
diff changeset
61 SDL_HasClipboardText(void)
4493
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 {
4495
dbbfdb9ea716 Simplified clipboard API for sanity's sake.
Sam Lantinga <slouken@libsdl.org>
parents: 4493
diff changeset
63 SDL_VideoDevice *_this = SDL_GetVideoDevice();
4493
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64
4495
dbbfdb9ea716 Simplified clipboard API for sanity's sake.
Sam Lantinga <slouken@libsdl.org>
parents: 4493
diff changeset
65 if (_this->HasClipboardText) {
dbbfdb9ea716 Simplified clipboard API for sanity's sake.
Sam Lantinga <slouken@libsdl.org>
parents: 4493
diff changeset
66 return _this->HasClipboardText(_this);
dbbfdb9ea716 Simplified clipboard API for sanity's sake.
Sam Lantinga <slouken@libsdl.org>
parents: 4493
diff changeset
67 } else {
dbbfdb9ea716 Simplified clipboard API for sanity's sake.
Sam Lantinga <slouken@libsdl.org>
parents: 4493
diff changeset
68 if (_this->clipboard_text) {
dbbfdb9ea716 Simplified clipboard API for sanity's sake.
Sam Lantinga <slouken@libsdl.org>
parents: 4493
diff changeset
69 return SDL_TRUE;
dbbfdb9ea716 Simplified clipboard API for sanity's sake.
Sam Lantinga <slouken@libsdl.org>
parents: 4493
diff changeset
70 } else {
dbbfdb9ea716 Simplified clipboard API for sanity's sake.
Sam Lantinga <slouken@libsdl.org>
parents: 4493
diff changeset
71 return SDL_FALSE;
dbbfdb9ea716 Simplified clipboard API for sanity's sake.
Sam Lantinga <slouken@libsdl.org>
parents: 4493
diff changeset
72 }
dbbfdb9ea716 Simplified clipboard API for sanity's sake.
Sam Lantinga <slouken@libsdl.org>
parents: 4493
diff changeset
73 }
4493
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 }
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75
f0b7c8d169f5 First pass at clipboard API, still very much in progress
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 /* vi: set ts=4 sw=4 expandtab: */