/*
 *   This sourcecode is part of FileSpy, a logfile observing utility.
 *   Copyright (C) 1996  Felix Rauch
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *   
 *   Notice that this program may not be possessed, used, copied,
 *   distributed or modified by people having to do with nuclear
 *   weapons. See the file CONDITIONS for details.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *   To contact the original author, try:
 *   e-mail: Felix.Rauch@nice.ch
 *   Traditional mail:	Felix Rauch
 *			Sempacherstrasse 33
 *			8032 Zurich
 *			Switzerland
 */

#import "MyScrollView.h"

@implementation MyScrollView

- setController:sender
{
    controller = sender;
    return self;
}

- (NXDragOperation)draggingEntered:sender
{
    if([sender draggingSourceOperationMask] & NX_DragOperationCopy)
	return NX_DragOperationCopy;
    return NX_DragOperationNone;
}

- (BOOL)prepareForDragOperation:sender
{
    return YES;
}

- (BOOL)performDragOperation:sender
{
    Pasteboard *aPb = [sender draggingPasteboard];
    char *filename;
    int length;

    if([aPb readType:NXFilenamePboardType
		data:&filename length:&length]) {
	char *end = filename, tmp;
	while(*end++ != '\000') {
	    while((*end != '\t') && (*end != '\000'))
		end++;
	    tmp = *end;
	    *end = '\000';
	    [controller addFileWithName:filename];
	    *end = tmp;
	    filename = (char *)(end + 1);
	}
	return YES;
    }
    return NO;
}

- (BOOL)acceptsFirstMouse
{
    return YES;
}

@end
