src/video/SDL_clipboard.c
changeset 4495 dbbfdb9ea716
parent 4493 f0b7c8d169f5
child 4500 eff4e88cc1e8
     1.1 --- a/src/video/SDL_clipboard.c	Wed Jul 07 23:26:07 2010 -0700
     1.2 +++ b/src/video/SDL_clipboard.c	Wed Jul 07 23:54:03 2010 -0700
     1.3 @@ -24,78 +24,50 @@
     1.4  #include "SDL_clipboard.h"
     1.5  #include "SDL_sysvideo.h"
     1.6  
     1.7 -/* FOURCC values for text and image clipboard formats */
     1.8 -#define TEXT_DATA  SDL_FOURCC('T', 'E', 'X', 'T')
     1.9 -#define IMAGE_DATA SDL_FOURCC('B', 'M', 'P', ' ')
    1.10  
    1.11  int
    1.12  SDL_SetClipboardText(const char *text)
    1.13  {
    1.14 -    return SDL_SetClipboard(TEXT_DATA, text, SDL_strlen(text)+1);
    1.15 +    SDL_VideoDevice *_this = SDL_GetVideoDevice();
    1.16 +
    1.17 +    if (_this->SetClipboardText) {
    1.18 +        return _this->SetClipboardText(_this, text);
    1.19 +    } else {
    1.20 +        _this->clipboard_text = SDL_strdup(text);
    1.21 +        return 0;
    1.22 +    }
    1.23  }
    1.24  
    1.25  char *
    1.26  SDL_GetClipboardText()
    1.27  {
    1.28 -    void *data;
    1.29 -    size_t length;
    1.30 +    SDL_VideoDevice *_this = SDL_GetVideoDevice();
    1.31  
    1.32 -    if (SDL_GetClipboard(TEXT_DATA, &data, &length) == 0) {
    1.33 -        return SDL_static_cast(char*, data);
    1.34 +    if (_this->GetClipboardText) {
    1.35 +        return _this->GetClipboardText(_this);
    1.36      } else {
    1.37 -        return NULL;
    1.38 +        const char *text = _this->clipboard_text;
    1.39 +        if (!text) {
    1.40 +            text = "";
    1.41 +        }
    1.42 +        return SDL_strdup(text);
    1.43      }
    1.44  }
    1.45  
    1.46  SDL_bool
    1.47  SDL_HasClipboardText()
    1.48  {
    1.49 -    return SDL_HasClipboardFormat(TEXT_DATA);
    1.50 -}
    1.51 -
    1.52 -int
    1.53 -SDL_SetClipboardImage(SDL_Surface *image)
    1.54 -{
    1.55 -    SDL_Unsupported();
    1.56 -    return -1;
    1.57 -}
    1.58 -
    1.59 -SDL_Surface *
    1.60 -SDL_GetClipboardImage()
    1.61 -{
    1.62 -    SDL_Unsupported();
    1.63 -    return NULL;
    1.64 -}
    1.65 -
    1.66 -SDL_bool
    1.67 -SDL_HasClipboardImage()
    1.68 -{
    1.69 -    return SDL_FALSE;
    1.70 -}
    1.71 +    SDL_VideoDevice *_this = SDL_GetVideoDevice();
    1.72  
    1.73 -int
    1.74 -SDL_SetClipboard(Uint32 format, void *data, size_t length)
    1.75 -{
    1.76 -    SDL_Unsupported();
    1.77 -    return -1;
    1.78 -}
    1.79 -
    1.80 -int
    1.81 -SDL_GetClipboard(Uint32 format, void **data, size_t *length)
    1.82 -{
    1.83 -    SDL_Unsupported();
    1.84 -    return -1;
    1.85 -}
    1.86 -
    1.87 -SDL_bool
    1.88 -SDL_HasClipboardFormat(Uint32 format)
    1.89 -{
    1.90 -    return SDL_FALSE;
    1.91 -}
    1.92 -
    1.93 -void
    1.94 -SDL_ClearClipboard(void)
    1.95 -{
    1.96 +    if (_this->HasClipboardText) {
    1.97 +        return _this->HasClipboardText(_this);
    1.98 +    } else {
    1.99 +        if (_this->clipboard_text) {
   1.100 +            return SDL_TRUE;
   1.101 +        } else {
   1.102 +            return SDL_FALSE;
   1.103 +        }
   1.104 +    }
   1.105  }
   1.106  
   1.107  /* vi: set ts=4 sw=4 expandtab: */