5 // Created by Pieter de Bie on 17-06-08.
6 // Copyright 2008 __MyCompanyName__. All rights reserved.
9 #import "PBGitRevisionCell.h"
12 @implementation PBGitRevisionCell
15 -(void) setCellInfo: (PBGraphCellInfo*) info
21 - (id) initWithCoder: (id) coder
23 self = [super initWithCoder:coder];
32 return [NSArray arrayWithObjects:[NSColor redColor], [NSColor blueColor],
33 [NSColor orangeColor], [NSColor blackColor], [NSColor greenColor], nil];
36 - (void) drawLineFromColumn: (int) from toColumn: (int) to inRect: (NSRect) r offset: (int) offset
40 NSPoint origin = r.origin;
42 NSPoint source = NSMakePoint(origin.x + columnWidth* from, origin.y + offset);
43 NSPoint center = NSMakePoint( origin.x + columnWidth * to, origin.y + r.size.height * 0.5);
45 // Just use red for now.
46 [[[self colors] objectAtIndex:0] set];
48 NSBezierPath * path = [NSBezierPath bezierPath];
49 [path setLineWidth:2];
51 [path moveToPoint: source];
52 [path lineToPoint: center];
57 - (void) drawCircleForColumn: (int) c inRect: (NSRect) r
59 NSArray* col = [NSArray arrayWithObjects:[NSColor redColor], [NSColor blueColor],
60 [NSColor orangeColor], [NSColor blackColor], [NSColor greenColor], nil];
63 NSPoint origin = r.origin;
64 NSPoint columnOrigin = { origin.x + columnWidth * c, origin.y};
66 NSRect oval = { columnOrigin.x - 5, columnOrigin.y + r.size.height * 0.5 - 5, 10, 10};
69 NSBezierPath * path = [NSBezierPath bezierPath];
70 path = [NSBezierPath bezierPathWithOvalInRect:oval];
71 //[[col objectAtIndex:cellInfo.columns[c].color] set];
74 NSRect smallOval = { columnOrigin.x - 3, columnOrigin.y + r.size.height * 0.5 - 3, 6, 6};
75 [[NSColor whiteColor] set];
76 path = [NSBezierPath bezierPathWithOvalInRect:smallOval];
80 - (void) drawWithFrame: (NSRect) rect inView:(NSView *)view
83 return [super drawWithFrame:rect inView:view];
85 float pathWidth = 10 + 10 * cellInfo.numColumns;
88 NSDivideRect(rect, &ownRect, &rect, pathWidth, NSMinXEdge);
90 for (PBLine* line in cellInfo.lines) {
92 [self drawLineFromColumn: line.from toColumn: line.to inRect:ownRect offset: ownRect.size.height];
94 [self drawLineFromColumn:line.from toColumn: line.to inRect:ownRect offset: 0];
97 [self drawCircleForColumn: cellInfo.position inRect: ownRect];
100 [super drawWithFrame:rect inView:view];