I have a skeleton program for custom cells in a table view. I took some ideas from a program online "customtableview" that I downloaded. One complaint that I have about it is that it does not draw a custom image; instead using a .tiff file.
Apple has a program called "dropNdragoutlineview". That program is pretty complicated, although on a post someone said it was bare-bones what was needed. My program has two classes, MyCell, the custom cell, and AppController, that contains the tableview. Below is the custom cell -
One thing I would like to understand is how to make a custom cell with drawing. On apple's site they recommend using lockFocus and unlockFocus.
Next is the tableview --
I'm sure it's much more complicated that this. Any suggestions would be helpful.
Adam
Apple has a program called "dropNdragoutlineview". That program is pretty complicated, although on a post someone said it was bare-bones what was needed. My program has two classes, MyCell, the custom cell, and AppController, that contains the tableview. Below is the custom cell -
Code:
@implementation MyCell
-(void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView
{
NSImage*myImage=[[NSImage alloc]init];
[myImage lockFocus];
myPath=[NSBezierPath bezierPathWithRect:cellFrame];
NSColor*myColor=[NSColor blueColor];
[myColor set];
[myPath fill];
[myImage unlockFocus];
[myImage drawInRect:cellFrame fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
}
@end
One thing I would like to understand is how to make a custom cell with drawing. On apple's site they recommend using lockFocus and unlockFocus.
Next is the tableview --
Code:
@implementation AppController
-(id)init
{
[super init];
myArray=[NSArray arrayWithObjects:@"red",@"green",@"blue",@"purple"];
[tableView setDelegate:self];
return self;
}
-(IBAction)asmbutton1:(NSButton*)sender;
{
//some code to reset colors from myArray (in popupbutton), for cells in tableview
[tableView reloadData];
}
-(int)numberOfRowsInTableView:(NSTableView *)tv
{
return 2;
}
-(id)tableView:(NSTableView *)tv objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
{
return myCell;
}
@end
I'm sure it's much more complicated that this. Any suggestions would be helpful.
Adam