1/* GWViewerScrollView.m
2 *
3 * Copyright (C) 2004-2013 Free Software Foundation, Inc.
4 *
5 * Author: Enrico Sersale <enrico@imago.ro>
6 * Date: December 2004
7 *
8 * This file is part of the GNUstep GWorkspace application
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
23 */
24
25#import <AppKit/AppKit.h>
26
27#import "FSNFunctions.h"
28#import "GWViewerScrollView.h"
29#import "GWViewer.h"
30
31@implementation GWViewerScrollView
32
33- (id)initWithFrame:(NSRect)frameRect
34           inViewer:(id)aviewer
35{
36  self = [super initWithFrame: frameRect];
37
38  if (self) {
39    viewer = aviewer;
40  }
41
42  return self;
43}
44
45- (void)setDocumentView:(NSView *)aView
46{
47  [super setDocumentView: aView];
48
49  if (aView != nil) {
50    nodeView = [viewer nodeView];
51
52    if ([nodeView needsDndProxy]) {
53      [self registerForDraggedTypes: [NSArray arrayWithObjects:
54                                              NSFilenamesPboardType,
55                                              @"GWLSFolderPboardType",
56                                              @"GWRemoteFilenamesPboardType",
57                                              nil]];
58    } else {
59      [self unregisterDraggedTypes];
60    }
61  } else {
62    nodeView = nil;
63    [self unregisterDraggedTypes];
64  }
65}
66
67@end
68
69
70@implementation GWViewerScrollView (DraggingDestination)
71
72- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
73{
74  if (nodeView && [nodeView needsDndProxy]) {
75    return [nodeView draggingEntered: sender];
76  }
77  return NSDragOperationNone;
78}
79
80- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender
81{
82  if (nodeView && [nodeView needsDndProxy]) {
83    return [nodeView draggingUpdated: sender];
84  }
85  return NSDragOperationNone;
86}
87
88- (void)draggingExited:(id <NSDraggingInfo>)sender
89{
90  if (nodeView && [nodeView needsDndProxy]) {
91    [nodeView draggingExited: sender];
92  }
93}
94
95- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
96{
97  if (nodeView && [nodeView needsDndProxy]) {
98    return [nodeView prepareForDragOperation: sender];
99  }
100  return NO;
101}
102
103- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
104{
105  if (nodeView && [nodeView needsDndProxy]) {
106    return [nodeView performDragOperation: sender];
107  }
108  return NO;
109}
110
111- (void)concludeDragOperation:(id <NSDraggingInfo>)sender
112{
113  if (nodeView && [nodeView needsDndProxy]) {
114    [nodeView concludeDragOperation: sender];
115  }
116}
117
118@end
119
120
121
122
123
124
125
126
127
128
129
130