Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /XspfManager/XspfMShadowImageCell.m

Parent Directory Parent Directory | Revision Log Revision Log


Revision 518 - (hide annotations) (download)
Thu Jan 27 12:01:46 2011 UTC (13 years, 2 months ago) by masakih
File size: 1589 byte(s)
[Mod] 新しいアイコンビューでクイックルック出来るようにした。
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 masakih 518 - (NSRect)imageRectForBounds:(NSRect)cellFrame inView:(NSView *)controlView
46     {
47     cellFrame = enabledImageFrame(cellFrame);
48    
49     NSRect frame = [self _imageRectForDrawing:[self image] inFrame:cellFrame inView:controlView];
50     return frame;
51     }
52    
53 masakih 516 - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView;
54     {
55     [NSGraphicsContext saveGraphicsState];
56    
57     cellFrame = enabledImageFrame(cellFrame);
58    
59 masakih 517 [[self shadow] set];
60 masakih 516
61     NSRect imageRect = [self _imageRectForDrawing:[self image] inFrame:cellFrame inView:controlView];
62     [[NSColor whiteColor] set];
63     NSRectFill(imageRect);
64    
65     [NSGraphicsContext restoreGraphicsState];
66    
67     [self drawInteriorWithFrame:cellFrame inView:controlView];
68     }
69    
70     @end

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