-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathYEDNodeViewCollectionItem.j
39 lines (33 loc) · 1.05 KB
/
YEDNodeViewCollectionItem.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
@import <AppKit/CPBox.j>
@import <AppKit/CPView.j>
@implementation YEDNodeViewCollectionItem : CPView
{
CPTextField nameField;
CPBox boxView;
}
- (void)setRepresentedObject:(id)object
{
if(!nameField)
{
nameField = [[CPTextField alloc] initWithFrame:CGRectMake(100,15,145,20)];
[nameField setFont:[CPFont boldSystemFontOfSize:12.0]];
[self addSubview:nameField];
}
[nameField setStringValue:[[object representedObject] name]];
if(!boxView)
{
boxView = [[CPBox alloc] initWithFrame:CGRectMake(25,0,50,50)];
[self addSubview:boxView];
}
[boxView setBorderType:CPLineBorder];
[boxView setBorderColor:[object borderColor]];
[boxView setBorderWidth:[object borderWidth]];
[boxView setCornerRadius:[object cornerRadius]];
[boxView setFillColor:[object fillColor]];
}
- (void)setSelected:(BOOL)isSelected
{
[self setBackgroundColor:isSelected ? [CPColor blueColor] : nil];
[nameField setTextColor:isSelected ? [CPColor whiteColor] : [CPColor blackColor]];
}
@end