| 450 | | if( [iconPath length] ) { |
|---|
| 451 | | NSURL *iconURL; |
|---|
| 452 | | if( iconURL = [NSURL URLWithString:iconPath] ) { |
|---|
| | 451 | if( [iconPath isKindOfClass:[NSString class]] && [(NSString *)iconPath length] ) { |
|---|
| | 452 | NSURL *iconURL = nil; |
|---|
| | 453 | if( [iconPath hasPrefix:@"#"] ) { |
|---|
| | 454 | NSSize size = NSZeroSize; |
|---|
| | 455 | if( [iconSize isKindOfClass:[NSArray class]] && [(NSArray *)iconSize count] == 2 ) { |
|---|
| | 456 | size = NSMakeSize( [[iconSize objectAtIndex:0] unsignedIntValue], [[iconSize objectAtIndex:1] unsignedIntValue] ); |
|---|
| | 457 | } else if( [iconSize isKindOfClass:[NSNumber class]] ) { |
|---|
| | 458 | size = NSMakeSize( [iconSize unsignedIntValue], [iconSize unsignedIntValue] ); |
|---|
| | 459 | } else size = NSMakeSize( 24., 12. ); |
|---|
| | 460 | |
|---|
| | 461 | NSColor *color = [NSColor colorWithHTMLAttributeValue:iconPath]; |
|---|
| | 462 | NSImage *icon = [[[NSImage alloc] initWithSize:size] autorelease]; |
|---|
| | 463 | |
|---|
| | 464 | [icon lockFocus]; |
|---|
| | 465 | [[color shadowWithLevel:0.1] set]; |
|---|
| | 466 | [NSBezierPath fillRect:NSMakeRect( 0., 0., size.width, size.height )]; |
|---|
| | 467 | [color drawSwatchInRect:NSMakeRect( 1., 1., size.width - 2., size.height - 2. )]; |
|---|
| | 468 | [icon unlockFocus]; |
|---|
| | 469 | |
|---|
| | 470 | [mitem setImage:icon]; |
|---|
| | 471 | } else if( ( iconURL = [NSURL URLWithString:iconPath] ) ) { |
|---|
| | 500 | } else if( [iconPath isKindOfClass:[NSArray class]] && [(NSArray *)iconPath count] == 3 ) { |
|---|
| | 501 | NSSize size = NSZeroSize; |
|---|
| | 502 | if( [iconSize isKindOfClass:[NSArray class]] && [(NSArray *)iconSize count] == 2 ) { |
|---|
| | 503 | size = NSMakeSize( [[iconSize objectAtIndex:0] unsignedIntValue], [[iconSize objectAtIndex:1] unsignedIntValue] ); |
|---|
| | 504 | } else if( [iconSize isKindOfClass:[NSNumber class]] ) { |
|---|
| | 505 | size = NSMakeSize( [iconSize unsignedIntValue], [iconSize unsignedIntValue] ); |
|---|
| | 506 | } else size = NSMakeSize( 24., 12. ); |
|---|
| | 507 | |
|---|
| | 508 | NSColor *color = [NSColor colorWithCalibratedRed:( [[iconPath objectAtIndex:0] unsignedIntValue] / 65535. ) green:( [[iconPath objectAtIndex:1] unsignedIntValue] / 65535. ) blue:( [[iconPath objectAtIndex:2] unsignedIntValue] / 65535. ) alpha:1.]; |
|---|
| | 509 | NSImage *icon = [[[NSImage alloc] initWithSize:size] autorelease]; |
|---|
| | 510 | |
|---|
| | 511 | [icon lockFocus]; |
|---|
| | 512 | [[color shadowWithLevel:0.1] set]; |
|---|
| | 513 | [NSBezierPath fillRect:NSMakeRect( 0., 0., size.width, size.height )]; |
|---|
| | 514 | [color drawSwatchInRect:NSMakeRect( 1., 1., size.width - 2., size.height - 2. )]; |
|---|
| | 515 | [icon unlockFocus]; |
|---|
| | 516 | |
|---|
| | 517 | [mitem setImage:icon]; |
|---|