From ca9d09134fb9be22a20db2e1e7e739683167bf77 Mon Sep 17 00:00:00 2001 From: Aparajita Fishman Date: Thu, 12 Aug 2010 01:12:21 -0400 Subject: [PATCH] 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]. --- Tools/nib2cib/NSMatrix.j | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/Tools/nib2cib/NSMatrix.j b/Tools/nib2cib/NSMatrix.j index 254acabcc..64f85ef7d 100644 --- a/Tools/nib2cib/NSMatrix.j +++ b/Tools/nib2cib/NSMatrix.j @@ -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;