src/video/SDL_clipboard.c
author Sam Lantinga <slouken@libsdl.org>
Wed, 07 Jul 2010 23:24:04 -0700
changeset 4493 f0b7c8d169f5
child 4495 dbbfdb9ea716
permissions -rw-r--r--
First pass at clipboard API, still very much in progress
slouken@4493
     1
/*
slouken@4493
     2
    SDL - Simple DirectMedia Layer
slouken@4493
     3
    Copyright (C) 1997-2010 Sam Lantinga
slouken@4493
     4
slouken@4493
     5
    This library is free software; you can redistribute it and/or
slouken@4493
     6
    modify it under the terms of the GNU Lesser General Public
slouken@4493
     7
    License as published by the Free Software Foundation; either
slouken@4493
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@4493
     9
slouken@4493
    10
    This library is distributed in the hope that it will be useful,
slouken@4493
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@4493
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@4493
    13
    Lesser General Public License for more details.
slouken@4493
    14
slouken@4493
    15
    You should have received a copy of the GNU Lesser General Public
slouken@4493
    16
    License along with this library; if not, write to the Free Software
slouken@4493
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@4493
    18
slouken@4493
    19
    Sam Lantinga
slouken@4493
    20
    slouken@libsdl.org
slouken@4493
    21
*/
slouken@4493
    22
#include "SDL_config.h"
slouken@4493
    23
slouken@4493
    24
#include "SDL_clipboard.h"
slouken@4493
    25
#include "SDL_sysvideo.h"
slouken@4493
    26
slouken@4493
    27
/* FOURCC values for text and image clipboard formats */
slouken@4493
    28
#define TEXT_DATA  SDL_FOURCC('T', 'E', 'X', 'T')
slouken@4493
    29
#define IMAGE_DATA SDL_FOURCC('B', 'M', 'P', ' ')
slouken@4493
    30
slouken@4493
    31
int
slouken@4493
    32
SDL_SetClipboardText(const char *text)
slouken@4493
    33
{
slouken@4493
    34
    return SDL_SetClipboard(TEXT_DATA, text, SDL_strlen(text)+1);
slouken@4493
    35
}
slouken@4493
    36
slouken@4493
    37
char *
slouken@4493
    38
SDL_GetClipboardText()
slouken@4493
    39
{
slouken@4493
    40
    void *data;
slouken@4493
    41
    size_t length;
slouken@4493
    42
slouken@4493
    43
    if (SDL_GetClipboard(TEXT_DATA, &data, &length) == 0) {
slouken@4493
    44
        return SDL_static_cast(char*, data);
slouken@4493
    45
    } else {
slouken@4493
    46
        return NULL;
slouken@4493
    47
    }
slouken@4493
    48
}
slouken@4493
    49
slouken@4493
    50
SDL_bool
slouken@4493
    51
SDL_HasClipboardText()
slouken@4493
    52
{
slouken@4493
    53
    return SDL_HasClipboardFormat(TEXT_DATA);
slouken@4493
    54
}
slouken@4493
    55
slouken@4493
    56
int
slouken@4493
    57
SDL_SetClipboardImage(SDL_Surface *image)
slouken@4493
    58
{
slouken@4493
    59
    SDL_Unsupported();
slouken@4493
    60
    return -1;
slouken@4493
    61
}
slouken@4493
    62
slouken@4493
    63
SDL_Surface *
slouken@4493
    64
SDL_GetClipboardImage()
slouken@4493
    65
{
slouken@4493
    66
    SDL_Unsupported();
slouken@4493
    67
    return NULL;
slouken@4493
    68
}
slouken@4493
    69
slouken@4493
    70
SDL_bool
slouken@4493
    71
SDL_HasClipboardImage()
slouken@4493
    72
{
slouken@4493
    73
    return SDL_FALSE;
slouken@4493
    74
}
slouken@4493
    75
slouken@4493
    76
int
slouken@4493
    77
SDL_SetClipboard(Uint32 format, void *data, size_t length)
slouken@4493
    78
{
slouken@4493
    79
    SDL_Unsupported();
slouken@4493
    80
    return -1;
slouken@4493
    81
}
slouken@4493
    82
slouken@4493
    83
int
slouken@4493
    84
SDL_GetClipboard(Uint32 format, void **data, size_t *length)
slouken@4493
    85
{
slouken@4493
    86
    SDL_Unsupported();
slouken@4493
    87
    return -1;
slouken@4493
    88
}
slouken@4493
    89
slouken@4493
    90
SDL_bool
slouken@4493
    91
SDL_HasClipboardFormat(Uint32 format)
slouken@4493
    92
{
slouken@4493
    93
    return SDL_FALSE;
slouken@4493
    94
}
slouken@4493
    95
slouken@4493
    96
void
slouken@4493
    97
SDL_ClearClipboard(void)
slouken@4493
    98
{
slouken@4493
    99
}
slouken@4493
   100
slouken@4493
   101
/* vi: set ts=4 sw=4 expandtab: */