Add custom cell

This commit is contained in:
Pieter de Bie
2008-06-17 13:46:18 +02:00
parent e72d93c872
commit fe8f173360
5 changed files with 1491 additions and 1356 deletions
+12 -1
View File
@@ -7,6 +7,7 @@
//
#import "ApplicationController.h"
#import "PBGitRevisionCell.h"
@implementation ApplicationController
@@ -219,5 +220,15 @@
[super dealloc];
}
- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
{
if (![[aTableColumn identifier] isEqualToString:@"subject"])
return;
NSLog(@"Doing cell at index: %i", rowIndex);
NSNumber* n = [NSNumber numberWithInt:(rowIndex % 2)];
[aCell setCommit:n];
}
@end
+1394 -1355
View File
File diff suppressed because it is too large Load Diff
+6
View File
@@ -12,6 +12,7 @@
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
F50FE0E30E07BE9600854FCD /* PBGitRevisionCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F50FE0E20E07BE9600854FCD /* PBGitRevisionCell.m */; };
F513085B0E0740F2000C8BCD /* PBQLOutlineView.m in Sources */ = {isa = PBXBuildFile; fileRef = F513085A0E0740F2000C8BCD /* PBQLOutlineView.m */; };
F561727F0E056A11001DCD79 /* diff_style.css in Resources */ = {isa = PBXBuildFile; fileRef = F561727C0E056A11001DCD79 /* diff_style.css */; };
F56173280E056ED2001DCD79 /* diffHighlighter.js in Resources */ = {isa = PBXBuildFile; fileRef = F56173270E056ED2001DCD79 /* diffHighlighter.js */; };
@@ -45,6 +46,8 @@
77C8280C06725ACE000B614F /* ApplicationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ApplicationController.m; sourceTree = "<group>"; };
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
8D1107320486CEB800E47090 /* GitX.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GitX.app; sourceTree = BUILT_PRODUCTS_DIR; };
F50FE0E10E07BE9600854FCD /* PBGitRevisionCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitRevisionCell.h; sourceTree = "<group>"; };
F50FE0E20E07BE9600854FCD /* PBGitRevisionCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitRevisionCell.m; sourceTree = "<group>"; };
F51308590E0740F2000C8BCD /* PBQLOutlineView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBQLOutlineView.h; sourceTree = "<group>"; };
F513085A0E0740F2000C8BCD /* PBQLOutlineView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBQLOutlineView.m; sourceTree = "<group>"; };
F53EE3590E06BBA00022B925 /* CWQuickLook.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CWQuickLook.h; sourceTree = "<group>"; };
@@ -214,6 +217,8 @@
F53EE3590E06BBA00022B925 /* CWQuickLook.h */,
F51308590E0740F2000C8BCD /* PBQLOutlineView.h */,
F513085A0E0740F2000C8BCD /* PBQLOutlineView.m */,
F50FE0E10E07BE9600854FCD /* PBGitRevisionCell.h */,
F50FE0E20E07BE9600854FCD /* PBGitRevisionCell.m */,
);
name = Aux;
sourceTree = "<group>";
@@ -305,6 +310,7 @@
F57CC4410E05E496000472E2 /* PBDetailController.m in Sources */,
F513085B0E0740F2000C8BCD /* PBQLOutlineView.m in Sources */,
F5DFFA6C0E075D8800617813 /* PBEasyFS.m in Sources */,
F50FE0E30E07BE9600854FCD /* PBGitRevisionCell.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
+16
View File
@@ -0,0 +1,16 @@
//
// PBGitRevisionCell.h
// GitX
//
// Created by Pieter de Bie on 17-06-08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface PBGitRevisionCell : NSTextFieldCell {
NSNumber* commit;
}
@property(retain) NSNumber* commit;
@end
+63
View File
@@ -0,0 +1,63 @@
//
// PBGitRevisionCell.m
// GitX
//
// Created by Pieter de Bie on 17-06-08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import "PBGitRevisionCell.h"
@implementation PBGitRevisionCell
@synthesize commit;
- (void) drawWithFrame: (NSRect) rect inView:(NSView *)view
{
float pathWidth = 20;
NSRect ownRect;
NSDivideRect(rect, &ownRect, &rect, pathWidth, NSMinXEdge);
// Adjust by removing the border
ownRect.size.height += 2;
ownRect.origin.y -= 1;
NSPoint origin = ownRect.origin;
NSPoint middle = { origin.x + pathWidth / 2, origin.y + ownRect.size.height * 0.5 };
[[NSColor redColor] set];
NSBezierPath * path = [NSBezierPath bezierPath];
[path moveToPoint:NSMakePoint(middle.x, origin.y)];
[path setLineWidth:2];
[path lineToPoint: NSMakePoint(middle.x, origin.y + ownRect.size.height)];
[path stroke];
[path setLineWidth:1];
NSRect oval = { middle.x - 5, middle.y -5, 10, 10};
[[NSColor orangeColor] set];
path = [NSBezierPath bezierPathWithOvalInRect:oval];
[path fill];
if ([self.commit intValue] == 0)
[[NSColor redColor] set];
else
[[NSColor blueColor] set];
[path stroke];
NSRect smallOval = { middle.x - 3, middle.y - 3, 6, 6};
[[NSColor whiteColor] set];
path = [NSBezierPath bezierPathWithOvalInRect:smallOval];
[path fill];
[[NSColor blackColor] set];
[path stroke];
[super drawWithFrame:rect inView:view];
[[NSColor blueColor] set];
//[path stroke];
}
@end