5 // Created by Pieter de Bie on 9/11/08.
6 // Copyright 2008 __MyCompanyName__. All rights reserved.
9 #import "PBCommitList.h"
10 #import "PBGitRevisionCell.h"
11 #import "PBWebHistoryController.h"
13 @implementation PBCommitList
15 @synthesize mouseDownPoint;
16 - (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL) local
18 return NSDragOperationCopy;
21 - (void) keyDown: (id) event
23 NSString* character = [event charactersIgnoringModifiers];
25 if ([character isEqualToString:@" "])
27 if ([event modifierFlags] & NSShiftKeyMask)
28 [webView scrollPageUp: self];
30 [webView scrollPageDown: self];
32 else if ([character rangeOfCharacterFromSet:[NSCharacterSet characterSetWithCharactersInString:@"jkcv"]].location == 0)
33 [webController sendKey: character];
35 [super keyDown: event];
38 - (void) copy:(id)sender
40 [controller copyCommitInfo];
43 - (void)mouseDown:(NSEvent *)theEvent
45 mouseDownPoint = [[self window] mouseLocationOutsideOfEventStream];
46 [super mouseDown:theEvent];
49 - (NSImage *)dragImageForRowsWithIndexes:(NSIndexSet *)dragRows
50 tableColumns:(NSArray *)tableColumns
51 event:(NSEvent *)dragEvent
52 offset:(NSPointPointer)dragImageOffset
54 NSPoint location = [self convertPointFromBase:mouseDownPoint];
55 int row = [self rowAtPoint:location];
56 int column = [self columnAtPoint:location];
57 PBGitRevisionCell *cell = (PBGitRevisionCell *)[self preparedCellAtColumn:column row:row];
59 int index = [cell indexAtX:location.x];
61 return [super dragImageForRowsWithIndexes:dragRows tableColumns:tableColumns event:dragEvent offset:dragImageOffset];
63 NSRect rect = [cell rectAtIndex:index];
65 NSImage *newImage = [[NSImage alloc] initWithSize:NSMakeSize(rect.size.width + 3, rect.size.height + 3)];
66 rect.origin = NSMakePoint(0.5, 0.5);
69 [cell drawLabelAtIndex:index inRect:rect];
70 [newImage unlockFocus];
72 *dragImageOffset = NSMakePoint(rect.size.width / 2 + 10, 0);