PageRenderTime 21ms CodeModel.GetById 18ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/YEDNodeViewConnector.j

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