Release notes for 0.6.3
[GitX.git] / PBCommitList.m
blob06c5ec8681a065b5100f1bc1e5973c5da43856c8
1 //
2 //  PBCommitList.m
3 //  GitX
4 //
5 //  Created by Pieter de Bie on 9/11/08.
6 //  Copyright 2008 __MyCompanyName__. All rights reserved.
7 //
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:@" "])
26         {
27                 if ([event modifierFlags] & NSShiftKeyMask)
28                         [webView scrollPageUp: self];
29                 else
30                         [webView scrollPageDown: self];
31         }
32         else if ([character rangeOfCharacterFromSet:[NSCharacterSet characterSetWithCharactersInString:@"jkcv"]].location == 0)
33                 [((PBWebHistoryController *)webController) sendKey: character];
34         else
35                 [super keyDown: event];
38 - (void) copy:(id)sender
40         [controller copyCommitInfo];
41 };      
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];
60         if (index == -1)
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);
68         [newImage lockFocus];
69         [cell drawLabelAtIndex:index inRect:rect];
70         [newImage unlockFocus];
72         *dragImageOffset = NSMakePoint(rect.size.width / 2 + 10, 0);
73         return newImage;
76 @end