Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /XspfManager/XspfMShadowImageCell.m

Parent Directory Parent Directory | Revision Log Revision Log


Revision 517 - (hide annotations) (download)
Wed Jan 26 13:23:39 2011 UTC (13 years, 2 months ago) by masakih
File size: 1353 byte(s)
[Mod] NSShadowを使い回すように変更。
1 masakih 516 //
2     // XspfMShadowImageCell.m
3     // XspfManager
4     //
5     // Created by Hori,Masaki on 11/01/26.
6     // Copyright 2011 masakih. All rights reserved.
7     //
8    
9     #import "XspfMShadowImageCell.h"
10    
11     @interface NSImageCell (CocoaPrivate)
12     - (NSRect)_imageRectForDrawing:(id)fp8 inFrame:(NSRect)fp12 inView:(id)fp28;
13     @end
14    
15 masakih 517 @interface XspfMShadowImageCell(XspfMPrivate)
16     + (NSShadow *)shadow;
17     - (NSShadow *)shadow;
18     @end
19    
20 masakih 516 @implementation XspfMShadowImageCell
21 masakih 517 + (NSShadow *)shadow
22     {
23     static NSShadow *shadow = nil;
24    
25     if(shadow) return shadow;
26    
27     shadow = [[NSShadow alloc] init];
28     [shadow setShadowOffset:NSMakeSize(2.8, -2.8)];
29     [shadow setShadowBlurRadius:5.6];
30     [shadow setShadowColor:[NSColor darkGrayColor]];
31    
32     return shadow;
33     }
34     - (NSShadow *)shadow
35     {
36     return [[self class] shadow];
37     }
38    
39 masakih 516 static inline NSRect enabledImageFrame(NSRect original)
40     {
41     original = NSInsetRect(original, 5, 5);
42     return NSOffsetRect(original, -1, 2);
43     }
44    
45     - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView;
46     {
47     [NSGraphicsContext saveGraphicsState];
48    
49     cellFrame = enabledImageFrame(cellFrame);
50    
51 masakih 517 [[self shadow] set];
52 masakih 516
53     NSRect imageRect = [self _imageRectForDrawing:[self image] inFrame:cellFrame inView:controlView];
54     [[NSColor whiteColor] set];
55     NSRectFill(imageRect);
56    
57     [NSGraphicsContext restoreGraphicsState];
58    
59     [self drawInteriorWithFrame:cellFrame inView:controlView];
60     }
61    
62     @end

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26