-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathYEDNodeViewConnector.j
49 lines (40 loc) · 1.35 KB
/
YEDNodeViewConnector.j
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
@import <AppKit/CPPasteboard.j>
@import "YEDNodeView.j"
YEDNodeViewConnectorDragType = @"YEDNodeViewConnectorDragType";
@implementation YEDNodeViewConnector : CPView
{
YEDNodeView nodeView @accessors;
CPEvent mouseDownEvent;
}
- (void)drawRect:(CGRect)rect
{
var context = [[CPGraphicsContext currentContext] graphicsPort];
CGContextSetFillColor(context, [CPColor yellowColor]);
CGContextSetStrokeColor(context, [CPColor grayColor]);
CGContextFillEllipseInRect(context, rect);
CGContextStrokeEllipseInRect(context, rect);
}
- (void)mouseDown:(CPEvent)event
{
mouseDownEvent = event;
}
- (void)mouseDragged:(CPEvent)event
{
var dragTypes = [YEDNodeViewConnectorDragType];
[[CPPasteboard pasteboardWithName:CPDragPboard] declareTypes:dragTypes owner:self];
var dragView = [[YEDNodeViewConnector alloc] init];
[dragView setFrame:CGRectMakeCopy([self frame])];
[self dragView:dragView
at:[dragView bounds].origin
offset:CGSizeMakeZero()
event:mouseDownEvent
pasteboard:nil
source:self
slideBack:YES];
}
- (void)pasteboard:(CPPasteboard)aPasteboard provideDataForType:(CPString)aType
{
if(aType === YEDNodeViewConnectorDragType)
[aPasteboard setData:@"Retreive nodeView from drag source." forType:aType];
}
@end