-
Notifications
You must be signed in to change notification settings - Fork 1
/
THRRowTemplate.j
73 lines (66 loc) · 2.05 KB
/
THRRowTemplate.j
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
64
65
66
67
68
69
70
71
72
73
@import <Foundation/CPObject.j>
@implementation THRRowTemplate : CPObject
{
CPArray subviewsArray;
float height @accessors(readonly);
float width @accessors(readonly);
}
- (id)initWithSubviewsArray:(CPArray) aSubviewsArray
{
if (self = [super init])
{
width=5.0;
height=3.0;
subviewsArray = aSubviewsArray;
var c=[subviewsArray count];
for( var i=0;i<c;i++ )
{
var currentView = [subviewsArray objectAtIndex:i];
var oldViewFrame = [currentView frame];
height = (height>6.0+oldViewFrame.size.height ? height : 6.0+oldViewFrame.size.height);
}
for( var i=0;i<c;i++ )
{
var currentView = [subviewsArray objectAtIndex:i];
var oldViewFrame = [currentView frame];
var newViewFrame = CGRectMake(width, (height-oldViewFrame.size.height)/2.0,oldViewFrame.size.width, oldViewFrame.size.height);
width += (oldViewFrame.size.width+8);
[currentView setFrame:newViewFrame];
}
width -= (i ? 3 : 0);
}
return self;
}
- (id) newRowAtIndex:(int) aIndex withContent:(CPArray) content
{
var c=[subviewsArray count];
var d=[content count];
var newRow = [[CPView alloc] initWithFrame:CGRectMake(0,0,width, height)];
for( var i=0;i<c;i++ )
{
var currentView = [[subviewsArray objectAtIndex:i] copy];
if( i<d )
{
//alert( CPStringFromClass([currentView class]) );
if( [currentView isKindOfClass:CPClassFromString(@"CPTextField")] )
{
[currentView setStringValue:[content objectAtIndex:i]];
}
}
[currentView setTag:(aIndex*1000+i)];
[newRow addSubview:currentView];
}
return newRow;
}
- (id) defaultRowString
{
var c=[subviewsArray count];
var newContent = [CPArray array];
for( var i=0;i<c;i++ )
{
var currentView = [subviewsArray objectAtIndex:i];
[newContent addObject:@""];
}
return newContent;
}
@end