-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLocationsToolbar.j
55 lines (44 loc) · 1.65 KB
/
LocationsToolbar.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
@import <AppKit/CPView.j>
@implementation LocationsToolbar : CPView
{
CPButton addButton;
CPButton removeButton;
id delegate @accessors;
}
- (id)initWithFrame:(CGRect)aFrame
{
self = [super initWithFrame:aFrame];
if (self)
{
[self setBackgroundColor:[CPColor colorWithHexString:@"FFF"]];
addButton = [self imageButtonAtPoint:CPPointMake(0.0, 0.0) withName:@"add"];
[addButton setTarget:self];
[addButton setAction:@selector(forwardAddLocation)];
[self addSubview:addButton];
removeButton = [self imageButtonAtPoint:CPPointMake(33.0, 0.0) withName:@"remove"];
[removeButton setTarget:self];
[removeButton setAction:@selector(forwardRemoveLocation)];
[self addSubview:removeButton];
}
return self;
}
- (void)forwardAddLocation {
if (delegate && [delegate respondsToSelector:@selector(addLocation)]) {
[delegate addLocation];
}
}
- (void)forwardRemoveLocation {
if (delegate && [delegate respondsToSelector:@selector(removeLocation)]) {
[delegate removeLocation];
}
}
- (CPButton)imageButtonAtPoint:(CPPoint)point withName:(CPString)aName {
var someButton = [[CPButton alloc] initWithFrame:CPRectMake(point.x, point.y, 30.0, 25.0)];
var image = [[CPImage alloc] initWithContentsOfFile:("Resources/" + aName + ".png") size:CPSizeMake(30, 25)],
highlighted = [[CPImage alloc] initWithContentsOfFile:("Resources/" + aName + "Highlighted.png") size:CPSizeMake(30, 25)];
[someButton setImage:image];
[someButton setAlternateImage:highlighted];
[someButton setBordered:NO];
return someButton;
}
@end