return nil;
break;
case slightly:
- color = [NSColor yellowColor];
+ color = [NSColor colorWithCalibratedRed:1.000 green:0.956 blue:0.012 alpha:1.000];
color = [color colorWithAlphaComponent:0.5];
-// color = [NSColor colorWithCalibratedRed:0.99 green:0.9 blue:0.0 alpha:0.5];
break;
case modest:
color = [NSColor orangeColor];
return nil;
break;
case slightly:
-// color = [NSColor yellowColor];
color = [NSColor orangeColor];
color = [color colorWithAlphaComponent:0.50];
break;
- (NSBezierPath *)path
{
+ NSBezierPath *path = nil;
+
+ switch(self.controlSize) {
+ case NSRegularControlSize:
+ path = [self pathForRegular];
+ break;
+ case NSSmallControlSize:
+ case NSMiniControlSize:
+ path = [self pathForSmall];
+ break;
+ }
+ return path;
+}
+
+- (NSBezierPath *)pathForRegular
+{
+ NSRect bounds = self.bounds;
+ NSSize boundsSize = bounds.size;
+ NSBezierPath *path = nil;
+
+ switch(self.damageType) {
+ case none:
+ return nil;
+ break;
+ case slightly:
+ path = [NSBezierPath bezierPath];
+ [path moveToPoint:NSMakePoint(35.0, boundsSize.height - 2.0)];
+ [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 2.0)];
+ [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 35.0)];
+ [path closePath];
+ break;
+ case modest:
+ path = [NSBezierPath bezierPath];
+ [path moveToPoint:NSMakePoint(50.0, boundsSize.height - 2.0)];
+ [path lineToPoint:NSMakePoint(25.0, boundsSize.height - 2.0)];
+ [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 25.0)];
+ [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 50.0)];
+ [path closePath];
+ break;
+ case badly:
+ path = [NSBezierPath bezierPath];
+ [path moveToPoint:NSMakePoint(60.0, boundsSize.height - 2.0)];
+ [path lineToPoint:NSMakePoint(53.0, boundsSize.height - 2.0)];
+ [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 53.0)];
+ [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 60.0)];
+ [path closePath];
+
+ [path moveToPoint:NSMakePoint(47.0, boundsSize.height - 2.0)];
+ [path lineToPoint:NSMakePoint(23.0, boundsSize.height - 2.0)];
+ [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 23.0)];
+ [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 47.0)];
+ [path closePath];
+ break;
+ }
+
+ return path;
+}
+
+- (NSBezierPath *)pathForSmall
+{
NSRect bounds = self.bounds;
NSSize boundsSize = bounds.size;
NSBezierPath *path = nil;
break;
case slightly:
path = [NSBezierPath bezierPath];
- [path moveToPoint:NSMakePoint(boundsSize.width - 35.0, 0.0)];
- [path lineToPoint:NSMakePoint(boundsSize.width - 2, 0.0)];
- [path lineToPoint:NSMakePoint(boundsSize.width - 2, 35.0)];
+ [path moveToPoint:NSMakePoint(35.0, boundsSize.height - 2.0)];
+ [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 2.0)];
+ [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 35.0)];
[path closePath];
break;
case modest:
path = [NSBezierPath bezierPath];
- [path moveToPoint:NSMakePoint(boundsSize.width - 50.0, 0.0)];
- [path lineToPoint:NSMakePoint(boundsSize.width - 25.0, 0.0)];
- [path lineToPoint:NSMakePoint(boundsSize.width - 2, 25.0)];
- [path lineToPoint:NSMakePoint(boundsSize.width - 2, 50.0)];
+ [path moveToPoint:NSMakePoint(50.0, boundsSize.height - 2.0)];
+ [path lineToPoint:NSMakePoint(25.0, boundsSize.height - 2.0)];
+ [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 25.0)];
+ [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 50.0)];
[path closePath];
break;
case badly:
path = [NSBezierPath bezierPath];
- [path moveToPoint:NSMakePoint(boundsSize.width - 60.0, 0.0)];
- [path lineToPoint:NSMakePoint(boundsSize.width - 55.0, 0.0)];
- [path lineToPoint:NSMakePoint(boundsSize.width - 2, 55.0)];
- [path lineToPoint:NSMakePoint(boundsSize.width - 2, 60.0)];
+ [path moveToPoint:NSMakePoint(55.0, boundsSize.height - 2.0)];
+ [path lineToPoint:NSMakePoint(48.0, boundsSize.height - 2.0)];
+ [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 48.0)];
+ [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 55.0)];
[path closePath];
- [path moveToPoint:NSMakePoint(boundsSize.width - 50.0, 0.0)];
- [path lineToPoint:NSMakePoint(boundsSize.width - 25.0, 0.0)];
- [path lineToPoint:NSMakePoint(boundsSize.width - 2, 25.0)];
- [path lineToPoint:NSMakePoint(boundsSize.width - 2, 50.0)];
+ [path moveToPoint:NSMakePoint(42.0, boundsSize.height - 2.0)];
+ [path lineToPoint:NSMakePoint(20.0, boundsSize.height - 2.0)];
+ [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 20.0)];
+ [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 42.0)];
[path closePath];
break;
}
[[NSColor colorWithCalibratedWhite:0.9 alpha:0.8] set];
[fillPath fill];
- [self drawTaihiInrect:bounds];
+ switch(self.controlSize) {
+ case NSRegularControlSize:
+ [self drawTaihiInrect:bounds];
+ break;
+ case NSSmallControlSize:
+ case NSMiniControlSize:
+ [self drawSmallTaihiInrect:bounds];
+ break;
+ }
}
- (void)drawTaihiInrect:(NSRect)bounds
[hi drawInRect:rect];
}
+- (void)drawSmallTaihiInrect:(NSRect)bounds
+{
+ const CGFloat width = 100;
+ const CGFloat height = 50;
+ NSRect rect = NSMakeRect(
+ (NSInteger)((bounds.size.width - width) * 0.5),
+ (NSInteger)((bounds.size.height - height) * 0.5),
+ width, height);
+
+ NSBezierPath *path = [NSBezierPath bezierPathWithRect:rect];
+
+ [[NSColor whiteColor] set];
+ [path fill];
+
+ [[NSColor blackColor] set];
+ [path stroke];
+
+ rect = NSInsetRect(rect, 3, 3);
+ path = [NSBezierPath bezierPathWithRect:rect];
+ path.lineWidth = 2;
+ [path stroke];
+
+ NSDictionary *taiAttr = @{
+ NSForegroundColorAttributeName : [NSColor lightGrayColor],
+ NSFontAttributeName : [NSFont boldSystemFontOfSize:height - 14],
+ };
+ NSAttributedString *tai = [[NSAttributedString alloc] initWithString:taiString attributes:taiAttr];
+
+ NSAttributedString *hi = [[NSAttributedString alloc] initWithString:hiString attributes:taiAttr];
+
+ rect = NSInsetRect(rect, 2, 2);
+ rect.origin.y += 4;
+ rect.origin.x += 4;
+ rect.size.height -= 2;
+ [tai drawInRect:rect];
+ rect.origin.x += rect.size.width * 0.5;
+ [hi drawInRect:rect];
+}
+
@end