libs-gui/Testing/testpb.m
Felipe A. Rodriguez b08fa89ee5 * Model/GNUmakefile enable build of test app, fix resource files ref.
* Model/test.gmodel remove ref to IMCustomView.
	* Model/GMAppKit.m add test for XRAW backend.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3175 72102866-910b-0410-8b05-ffd578937521
1998-11-06 04:01:33 +00:00

75 lines
1.6 KiB
Objective-C
Executable file

#include <Foundation/NSRunLoop.h>
#include <Foundation/NSData.h>
#include <Foundation/NSArray.h>
#include <Foundation/NSAutoreleasePool.h>
#include <Foundation/NSGeometry.h>
#include <AppKit/NSPasteboard.h>
BOOL
initialize_gnustep_backend(void)
{
/* Dummy replacement for the xdps function */
return YES;
}
void NSHighlightRect(NSRect aRect) // dummy define
{}
void NSRectFill(NSRect aRect) // dummy define
{}
void NSBeep(void) // dummy define
{}
@interface GMModel: NSObject
{
}
@end
@implementation GMModel
@end
@interface pbOwner : NSObject
{
}
- (void) pasteboard: (NSPasteboard*)pb provideDataForType: (NSString*)type;
@end
@implementation pbOwner
- (void) pasteboard: (NSPasteboard*)pb provideDataForType: (NSString*)type
{
if ([type isEqual: NSFileContentsPboardType]) {
NSString* s = [pb stringForType: NSStringPboardType];
if (s) {
const char* ptr;
int len;
NSData* d;
ptr = [s cString];
len = strlen(ptr);
d = [NSData dataWithBytes: ptr length: len];
[pb setData: d forType: type];
}
}
}
@end
int
main(int argc, char** argv)
{
pbOwner *owner = [pbOwner new];
NSPasteboard *pb;
NSArray *types;
NSData *d;
[NSObject enableDoubleReleaseCheck: YES];
types = [NSArray arrayWithObjects:
NSStringPboardType, NSFileContentsPboardType, nil];
pb = [NSPasteboard generalPasteboard];
[pb declareTypes: types owner: owner];
[pb setString: @"This is a test" forType: NSStringPboardType];
d = [pb dataForType: NSFileContentsPboardType];
printf("%.*s\n", [d length], [d bytes]);
exit(0);
}