src/video/bwindow/SDL_bclipboard.cc
author Nathan Heisey <nathanheisey@gmail.com>
Wed, 13 Jul 2011 09:29:43 +0000
changeset 5918 2063df37190b
child 5939 d9e9c343d264
permissions -rw-r--r--
Renamed all .c files in src/video/bwindow to .cc files.
nathanheisey@5918
     1
/*
nathanheisey@5918
     2
  Simple DirectMedia Layer
nathanheisey@5918
     3
  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
nathanheisey@5918
     4
nathanheisey@5918
     5
  This software is provided 'as-is', without any express or implied
nathanheisey@5918
     6
  warranty.  In no event will the authors be held liable for any damages
nathanheisey@5918
     7
  arising from the use of this software.
nathanheisey@5918
     8
nathanheisey@5918
     9
  Permission is granted to anyone to use this software for any purpose,
nathanheisey@5918
    10
  including commercial applications, and to alter it and redistribute it
nathanheisey@5918
    11
  freely, subject to the following restrictions:
nathanheisey@5918
    12
nathanheisey@5918
    13
  1. The origin of this software must not be misrepresented; you must not
nathanheisey@5918
    14
     claim that you wrote the original software. If you use this software
nathanheisey@5918
    15
     in a product, an acknowledgment in the product documentation would be
nathanheisey@5918
    16
     appreciated but is not required.
nathanheisey@5918
    17
  2. Altered source versions must be plainly marked as such, and must not be
nathanheisey@5918
    18
     misrepresented as being the original software.
nathanheisey@5918
    19
  3. This notice may not be removed or altered from any source distribution.
nathanheisey@5918
    20
*/
nathanheisey@5918
    21
nathanheisey@5918
    22
nathanheisey@5918
    23
/* BWindow based framebuffer implementation */
nathanheisey@5918
    24
#include "SDL_config.h"
nathanheisey@5918
    25
nathanheisey@5918
    26
#include <unistd.h>
nathanheisey@5918
    27
#include <TypeConstants.h>
nathanheisey@5918
    28
nathanheisey@5918
    29
#include "SDL_BWin.h"
nathanheisey@5918
    30
#include "SDL_timer.h"
nathanheisey@5918
    31
#include "../SDL_sysvideo.h"
nathanheisey@5918
    32
nathanheisey@5918
    33
#ifdef __cplusplus
nathanheisey@5918
    34
extern "C" {
nathanheisey@5918
    35
#endif
nathanheisey@5918
    36
nathanheisey@5918
    37
int BE_SetClipboardText(_THIS, const char *text) {
nathanheisey@5918
    38
#if 0
nathanheisey@5918
    39
	BMessage *clip = NULL;
nathanheisey@5918
    40
	if(be_clipboard->Lock()) {
nathanheisey@5918
    41
		be_clipboard->Clear();
nathanheisey@5918
    42
		if((clip = be_clipboard->Data())) {
nathanheisey@5918
    43
			/* Presumably the string of characters is ascii-format */
nathanheisey@5918
    44
			ssize_t asciiLength = 0;
nathanheisey@5918
    45
			for(; text[asciiLength] != 0; ++asciiLength) {}
nathanheisey@5918
    46
			clip->AddData("text/plain", B_MIME_TYPE, &text, asciiLength);
nathanheisey@5918
    47
			be_clipboard->Commit();
nathanheisey@5918
    48
		}
nathanheisey@5918
    49
		be_clipboard->Unlock();
nathanheisey@5918
    50
	}
nathanheisey@5918
    51
#else
nathanheisey@5918
    52
return -1;
nathanheisey@5918
    53
#endif
nathanheisey@5918
    54
}
nathanheisey@5918
    55
nathanheisey@5918
    56
char *BE_GetClipboardText(_THIS) {
nathanheisey@5918
    57
#if 0
nathanheisey@5918
    58
	BMessage *clip = NULL;
nathanheisey@5918
    59
	const char *text;
nathanheisey@5918
    60
	ssize_t length;
nathanheisey@5918
    61
	if(be_clipboard->Lock()) {
nathanheisey@5918
    62
		if((clip = be_clipboard->Data())) {
nathanheisey@5918
    63
			/* Presumably the string of characters is ascii-format */
nathanheisey@5918
    64
			clip->FindData("text/plain", B_MIME_TYPE, (void**)&text, &length);
nathanheisey@5918
    65
		} else {
nathanheisey@5918
    66
			be_clipboard->Unlock();
nathanheisey@5918
    67
			return NULL;
nathanheisey@5918
    68
		}
nathanheisey@5918
    69
		be_clipboard->Unlock();
nathanheisey@5918
    70
	} else {
nathanheisey@5918
    71
		return NULL;
nathanheisey@5918
    72
	}
nathanheisey@5918
    73
	
nathanheisey@5918
    74
	/* Copy the data and pass on to SDL */
nathanheisey@5918
    75
	char *result = (char*)SDL_calloc(1, sizeof(char*)*length);
nathanheisey@5918
    76
	SDL_strlcpy(result, text, length);
nathanheisey@5918
    77
	
nathanheisey@5918
    78
	return result;
nathanheisey@5918
    79
#else
nathanheisey@5918
    80
return NULL;
nathanheisey@5918
    81
#endif;
nathanheisey@5918
    82
}
nathanheisey@5918
    83
nathanheisey@5918
    84
SDL_bool BE_HasClipboardText(_THIS) {
nathanheisey@5918
    85
#if 0
nathanheisey@5918
    86
	BMessage *clip = NULL;
nathanheisey@5918
    87
	const char *text;
nathanheisey@5918
    88
	ssize_t length;
nathanheisey@5918
    89
	SDL_bool retval = SDL_FALSE;
nathanheisey@5918
    90
	
nathanheisey@5918
    91
	if(be_clipboard->Lock()) {
nathanheisey@5918
    92
		if((clip = be_clipboard->Data())) {
nathanheisey@5918
    93
			/* Presumably the string of characters is ascii-format */
nathanheisey@5918
    94
			clip->FindData("text/plain", B_MIME_TYPE, (void**)&text, &length);
nathanheisey@5918
    95
			if( text ) retval = SDL_TRUE;
nathanheisey@5918
    96
		}
nathanheisey@5918
    97
		be_clipboard->Unlock();
nathanheisey@5918
    98
	}
nathanheisey@5918
    99
	return retval;
nathanheisey@5918
   100
#else
nathanheisey@5918
   101
return SDL_FALSE;
nathanheisey@5918
   102
#endif
nathanheisey@5918
   103
nathanheisey@5918
   104
}
nathanheisey@5918
   105
nathanheisey@5918
   106
#ifdef __cplusplus
nathanheisey@5918
   107
}					/* Extern C */
nathanheisey@5918
   108
#endif
nathanheisey@5918
   109