/*************************************************************************\|* Create a collection view for the parts\*************************************************************************/var H = 40;frm = CGRectMake(10, y, b.size.width-40, H*6);var cv = [[CPCollectionView alloc] initWithFrame:frm];CPLog(@"Items: %@", _items);[cv setMaxNumberOfColumns:1];[cv setContent:_items];[cv setAutoresizingMask:CPViewWidthSizable|CPViewHeightSizable];[cv setMinItemSize:CGSizeMake(frm.size.width, H)];[cv setMaxItemSize:CGSizeMake(frm.size.width, H)];var proto = [CPCollectionViewItem new];var cvView = [[IParserSubview alloc] initWithFrame:CGRectMakeZero()];[proto setView:cvView];[cv setItemPrototype:proto];frm.size.width += 20; // Vertical scrollbarfrm.size.height += 5*[cv verticalMargin]; // separatorsvar sv = [[CPScrollView alloc] initWithFrame:frm];[sv setDocumentView:cv];[sv setAutoresizingMask:CPViewWidthSizable|CPViewHeightSizable];[sv setAutohidesScrollers:YES];[self addSubview:sv];
2016-08-31 09:05:58.011 Cappuccino [info]: Items: [IParserData:Manufacturer],[IParserData:Manufacturer Part Number],[IParserData:Description],[IParserData:Lead Free Status / RoHS Status],[IParserData:Moisture Sensitivity Level (MSL)],[IParserData:Category],[IParserData:Family],[IParserData:Series],[IParserData:Packaging],[IParserData:Part Status],[IParserData:Resistance (Ohms)],[IParserData:Tolerance],[IParserData:Power (Watts)],[IParserData:Composition],[IParserData:Features],[IParserData:Temperature Coefficient],[IParserData:Operating Temperature],[IParserData:Package / Case],[IParserData:Supplier Device Package],[IParserData:Size / Dimension],[IParserData:Height],[IParserData:Number of Terminations]
@import <AppKit/AppKit.j>@import "IParserData.j"@implementation IParserSubview : CPView{CPTextField _fieldName;CPColor _bg;}/*****************************************************************************\|* Create the subviews\*****************************************************************************/- (void) layout:(IParserData)d{var b = [self bounds];var y = 2;var frm = CGRectMake(2, y, 250, 18);_fieldName = [[CPTextField alloc] initWithFrame:frm];[_fieldName setAlignment:CPRightTextAlignment];[_fieldName setEditable:NO];[_fieldName setTextColor:[CPColor whiteColor]];[_fieldName setFont:[CPFont boldSystemFontOfSize:FONT_LARGE]];[self addSubview:_fieldName];}/*****************************************************************************\|* Allow interaction with the collection view\*****************************************************************************/- (void)setRepresentedObject:(IParserData)data{if (_fieldName == nil)[self layout:data];if (data != nil){[_fieldName setStringValue:[data name]];if ([data toggled])_bg = [CPColor colorWithWhite:1.0 alpha:0.2];else_bg = [CPColor colorWithWhite:1.0 alpha:0.1];}}/*****************************************************************************\|* Allow selection\*****************************************************************************/- (void)setSelected:(BOOL)isSelected{[self setBackgroundColor:isSelected ? [CPColor grayColor] : nil];}/*****************************************************************************\|* Overlay the background with an alternating alpha mask\*****************************************************************************/- (void) drawRect:(CGRect)dirty{if (_bg != nil){var ctx = [[CPGraphicsContext currentContext] graphicsPort];CGContextSetFillColor(ctx, _bg);CGContextFillRect(ctx, [self bounds]);}}@end
... everything worked just fine. PEBCAK strikes again!
frm = CGRectMake(0,0, b.size.width-40, H*6);
--
You received this message because you are subscribed to the Google Groups "Cappuccino & Objective-J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to objectivej+...@googlegroups.com.
To post to this group, send email to objec...@googlegroups.com.
Visit this group at https://groups.google.com/group/objectivej.
For more options, visit https://groups.google.com/d/optout.
height = MAX(height, numberOfRows * (_minItemSize.height + _verticalMargin));
[displayItems enumerateObjectsUsingBlock:function(item, idx, stop) { var view = [item view];
if (idx >= displayCount) { [view setFrameOrigin:CGPointMake(-anItemSize.width, -anItemSize.height)]; return; }
if (idx % numberOfColumns == 0) { x = _horizontalMargin; y += _verticalMargin + anItemSize.height; }
[view setFrameOrigin:CGPointMake(x, y)]; [view setFrameSize:anItemSize];
x += anItemSize.width + _horizontalMargin; }];
The 'idx % numberOfColumns' part probably needs a check for (idx != 0) for the addition of _verticalMargin and the overall height then needs to take into account the lack of an initial separator offset.
The 'idx % numberOfColumns' part probably needs a check for (idx != 0) for the addition of _verticalMargin and the overall height then needs to take into account the lack of an initial separator offset.Can you open an issue for that ?