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:(NSEvent *)event
23 NSString* character = [event charactersIgnoringModifiers];
25 // Pass on command-shift up/down to the responder. We want the splitview to capture this.
26 if ([event modifierFlags] & NSShiftKeyMask && [event modifierFlags] & NSCommandKeyMask && ([event keyCode] == 0x7E || [event keyCode] == 0x7D)) {
27 [self.nextResponder keyDown:event];
31 if ([character isEqualToString:@" "])
33 if ([event modifierFlags] & NSShiftKeyMask)
34 [webView scrollPageUp: self];
36 [webView scrollPageDown: self];
38 else if ([character rangeOfCharacterFromSet:[NSCharacterSet characterSetWithCharactersInString:@"jkcv"]].location == 0)
39 [webController sendKey: character];
41 [super keyDown: event];
44 - (void) copy:(id)sender
46 [controller copyCommitInfo];
49 - (void)mouseDown:(NSEvent *)theEvent
51 mouseDownPoint = [[self window] mouseLocationOutsideOfEventStream];
52 [super mouseDown:theEvent];
55 - (NSImage *)dragImageForRowsWithIndexes:(NSIndexSet *)dragRows
56 tableColumns:(NSArray *)tableColumns
57 event:(NSEvent *)dragEvent
58 offset:(NSPointPointer)dragImageOffset
60 NSPoint location = [self convertPointFromBase:mouseDownPoint];
61 int row = [self rowAtPoint:location];
62 int column = [self columnAtPoint:location];
63 PBGitRevisionCell *cell = (PBGitRevisionCell *)[self preparedCellAtColumn:column row:row];
65 int index = [cell indexAtX:location.x];
67 return [super dragImageForRowsWithIndexes:dragRows tableColumns:tableColumns event:dragEvent offset:dragImageOffset];
69 NSRect rect = [cell rectAtIndex:index];
71 NSImage *newImage = [[NSImage alloc] initWithSize:NSMakeSize(rect.size.width + 3, rect.size.height + 3)];
72 rect.origin = NSMakePoint(0.5, 0.5);
75 [cell drawLabelAtIndex:index inRect:rect];
76 [newImage unlockFocus];
78 *dragImageOffset = NSMakePoint(rect.size.width / 2 + 10, 0);