public
Description: Web Application Framework in JavaScript and Objective-J
Homepage: http://cappuccino.org
Clone URL: git://github.com/280north/cappuccino.git
Klaas Pieter Annema (author)
Tue Jun 30 05:48:32 -0700 2009
tolmasky (committer)
Tue Jun 30 05:59:49 -0700 2009
cappuccino / Tools / nib2cib / NSMatrix.j
100644 63 lines (45 sloc) 2.064 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
@import <Foundation/CPObject.j>
@import <AppKit/CPView.j>
 
@import "NSView.j"
 
 
@implementation NSMatrix : CPObject
{
}
 
- (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"],
        cells = [aCoder decodeObjectForKey:@"NSCells"],
        selectedCell = [aCoder decodeObjectForKey:@"NSSelectedCell"];
 
    if (/*(cellClassName === @"NSButtonCell") &&*/ (flags & 0x40000000))
    {
        var radioGroup = [CPRadioGroup new];
            frame = CGRectMake(0.0, 0.0, cellSize.width, cellSize.height);
            rowIndex = 0;
 
        for (; rowIndex < numberOfRows; ++rowIndex)
        {
            var columnIndex = 0;
 
            frame.origin.x = 0;
 
            for (; 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 setObjectValue:[cell objectValue]];
                
                [view addSubview:cellView];
 
                frame.origin.x = CGRectGetMaxX(frame) + intercellSpacing.width;
            }
 
            frame.origin.y = CGRectGetMaxY(frame) + intercellSpacing.height;
        }
    }
 
    return view;
}
 
@end