forked from ImageOptim/ImageOptim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransformers.m
More file actions
59 lines (48 loc) · 1.11 KB
/
Copy pathTransformers.m
File metadata and controls
59 lines (48 loc) · 1.11 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
//
// CeilFormatter.m
//
// Created by porneL on 30.wrz.07.
//
#import "Transformers.h"
@implementation CeilFormatter
+ (Class)transformedValueClass {
return [NSNumber class];
}
- (id)transformedValue:(id)value {
double v = 1.0;
if ([value respondsToSelector:@selector(doubleValue)]) {
v = MAX(1.0F, ceil([value doubleValue]));
}
return @(v);
}
@end
@implementation DisabledColor
+ (Class)transformedValueClass {
return [NSColor class];
}
- (id)transformedValue:(id)value {
if ([value respondsToSelector:@selector(boolValue)] && ![value boolValue]) {
return [NSColor disabledControlTextColor];
}
return [NSColor textColor];
}
@end
static NSMutableDictionary *imageCache;
@implementation IOStatusImage
+ (Class)transformedValueClass {
return [NSImage class];
}
- (id)transformedValue:(id)value {
if (!value) {
value = @"err";
}
if (!imageCache) {
imageCache = [NSMutableDictionary new];
}
NSImage *img = imageCache[value];
if (!img) {
imageCache[value] = img = [NSImage imageNamed:value];
}
return img;
}
@end