Re: programmatically creating a NSMatrix with a prototype cell
Re: programmatically creating a NSMatrix with a prototype cell
- Subject: Re: programmatically creating a NSMatrix with a prototype cell
- From: Bertil Holmberg <email@hidden>
- Date: Sat, 20 Jun 2009 22:25:51 +0200
I do something similar here, perhaps you can spot some discrepancy?
// Instantiate a special buttonCell that can be drawn in color and
configure it
CCDColoredButtonCell *colorCell = [[CCDColoredButtonCell alloc]
init];
[colorCell setButtonColor:[NSColor clearColor]];
[colorCell setButtonType:NSMomentaryPushInButton];
[colorCell setBezelStyle:NSShadowlessSquareBezelStyle];
[colorCell setFont:[NSFont systemFontOfSize:15]];
[colorCell setAllowsMixedState:YES];
[colorCell setTarget:self];
[colorCell setAction:@selector(myAction:)];
[colorCell autorelease];
// Initial size of the buttons matrix
float mSize = 37 * squares - 2;
// Create the matrix of tri-state color capable buttons
protoMatrix = [[NSMatrix alloc] initWithFrame:NSMakeRect(20, 60,
mSize, mSize)
mode:NSHighlightModeMatrix
prototype:colorCell
numberOfRows:squares
numberOfColumns:squares];
[protoMatrix setIntercellSpacing:NSMakeSize(5, 5)];
[protoMatrix setCellSize:NSMakeSize(32, 32)];
[protoMatrix sizeToCells];
[protoMatrix autorelease];
// Disable unused cells, set tag and title of the visible ones
[self configureMatrix];
Create a NSTextFieldCell and customize it. Create a NSMatrix using
the "prototype" init version, and display it. All the custom
formatting is gone - all cells are vanilla NSTextFieldCells.
Loop through the matrix, and set each cell to a copy of the cell I
used as a prototype, using the "putCell..." method. Now it works fine.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden