Multiple fixes...

1. CPRadio should not draw its background color by default when created from a nib.

2. Substituted named constants for magic number bit flags.

3. Don't set the matrix view background color unless the nib said to draw its background.

4. NIB_CONNECTION_EQUIVALENCY_TABLE wants UIDs, changed self -> [self UID].
This commit is contained in:
Aparajita Fishman committed 2010-08-12 01:12:21 -04:00
1 parent 29c857b1e9
commit ca9d09134f
1 file changed
+18 -14
+18 -14
View File
@@ -4,6 +4,11 @@
@import "NSView.j"
var NSMatrixRadioModeMask = 0x40000000,
NSMatrixDrawsBackgroundMask = 0x01000000;
@implementation NSMatrix : CPObject
{
}
@@ -11,39 +16,35 @@
- (id)initWithCoder:(CPCoder)aCoder
{
var view = [[CPView alloc] NS_initWithCoder:aCoder];
[view setBackgroundColor:[aCoder decodeObjectForKey:@"NSBackgroundColor"]];
var numberOfRows = [aCoder decodeIntForKey:@"NSNumRows"],
numberOfColumns = [aCoder decodeIntForKey:@"NSNumCols"],
cellSize = [aCoder decodeSizeForKey:@"NSCellSize"],
intercellSpacing = [aCoder decodeSizeForKey:@"NSIntercellSpacing"],
cellBackgroundColor = [aCoder decodeObjectForKey:@"NSCellBackgroundColor"],
//cellClassName = [aCoder decodeObjectForKey:@"NSCellClass"];alert("6");
flags = [aCoder decodeIntForKey:@"NSMatrixFlags"],
isRadioMode = flags & NSMatrixRadioModeMask,
drawsBackground = flags & NSMatrixDrawsBackgroundMask,
backgroundColor = [aCoder decodeObjectForKey:@"NSBackgroundColor"],
cells = [aCoder decodeObjectForKey:@"NSCells"],
selectedCell = [aCoder decodeObjectForKey:@"NSSelectedCell"];
if (/*(cellClassName === @"NSButtonCell") &&*/ (flags & 0x40000000))
if (isRadioMode)
{
var radioGroup = [CPRadioGroup new];
var radioGroup = [CPRadioGroup new],
frame = CGRectMake(0.0, 0.0, cellSize.width, cellSize.height);
rowIndex = 0;
for (; rowIndex < numberOfRows; ++rowIndex)
for (var rowIndex; rowIndex < numberOfRows; ++rowIndex)
{
var columnIndex = 0;
frame.origin.x = 0;
for (; columnIndex < numberOfColumns; ++columnIndex)
for (var columnIndex = 0; columnIndex < numberOfColumns; ++columnIndex)
{
var cell = cells[rowIndex * numberOfColumns + columnIndex],
cellView = [[CPRadio alloc] initWithFrame:frame radioGroup:radioGroup];
[cellView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
[cellView setTitle:[cell title]];
[cellView setBackgroundColor:cellBackgroundColor];
[cellView setBackgroundColor:[CPColor clearColor]]; // the IB default
[cellView setObjectValue:[cell objectValue]];
[view addSubview:cellView];
@@ -56,7 +57,10 @@
frame.origin.y = CGRectGetMaxY(frame) + intercellSpacing.height;
}
NIB_CONNECTION_EQUIVALENCY_TABLE[self] = view;
if (drawsBackground)
[view setBackgroundColor:backgroundColor];
NIB_CONNECTION_EQUIVALENCY_TABLE[[self UID]] = view;
}
return view;