1/* GormDocumentWindow.m 2 * 3 * Copyright (C) 2006 Free Software Foundation, Inc. 4 * 5 * Author: Matt Rice <ratmice@gmail.com> 6 * 7 * This file is part of GNUstep. 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 3 of the License, or 12 * (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. 22 */ 23 24#include "GormDocumentWindow.h" 25#include "GormPrivate.h" 26 27#include <GormLib/IBResourceManager.h> 28#include <AppKit/NSDragging.h> 29#include <AppKit/NSPasteboard.h> 30 31@implementation GormDocumentWindow 32/* 33- (BOOL) canBecomeMainWindow 34{ 35 return NO; 36} 37*/ 38 39- (void) setDocument:(id)document 40{ 41 _document = document; 42} 43 44- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender; 45{ 46 NSPasteboard *pb = [sender draggingPasteboard]; 47 NSUInteger mask = [sender draggingSourceOperationMask]; 48 NSUInteger oper = NSDragOperationNone; 49 dragMgr = [_document resourceManagerForPasteboard:pb]; 50 51 if (dragMgr) 52 { 53 if (mask & NSDragOperationCopy) 54 { 55 oper = NSDragOperationCopy; 56 } 57 else if (mask & NSDragOperationLink) 58 { 59 oper = NSDragOperationLink; 60 } 61 else if (mask & NSDragOperationMove) 62 { 63 oper = NSDragOperationMove; 64 } 65 else if (mask & NSDragOperationGeneric) 66 { 67 oper = NSDragOperationGeneric; 68 } 69 else if (mask & NSDragOperationPrivate) 70 { 71 oper = NSDragOperationPrivate; 72 } 73 } 74 75 return oper; 76} 77 78- (void)draggingExited:(id <NSDraggingInfo>)sender; 79{ 80 dragMgr = nil; 81} 82 83- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender; 84{ 85 return !(dragMgr == nil); 86} 87 88- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender; 89{ 90 [dragMgr addResourcesFromPasteboard:[sender draggingPasteboard]]; 91 return !(dragMgr == nil); 92} 93 94- (void)concludeDragOperation:(id <NSDraggingInfo>)sender; 95{ 96 dragMgr = nil; 97} 98 99- (void)draggingEnded: (id <NSDraggingInfo>)sender; 100{ 101 dragMgr = nil; 102} 103 104- (void) awakeFromNib 105{ 106 [self setAcceptsMouseMovedEvents: YES]; 107} 108 109@end 110 111