Changeset 10028 for trunk/macosx/DragOverlayView.m
- Timestamp:
- Jan 28, 2010, 3:36:47 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/DragOverlayView.m
r9844 r10028 25 25 #import "DragOverlayView.h" 26 26 27 #define PADDING 10.0 f28 #define ICON_WIDTH 64.0 f27 #define PADDING 10.0 28 #define ICON_WIDTH 64.0 29 29 30 30 @implementation DragOverlayView … … 34 34 if ((self = [super initWithFrame: frame])) 35 35 { 36 //create badge37 NSRect badgeRect = NSMakeRect(0.0f, 0.0f, 325.0f, 84.0f);38 NSBezierPath * bp = [NSBezierPath bezierPathWithRoundedRect: badgeRect xRadius: 15.0f yRadius: 15.0f];39 40 fBackBadge = [[NSImage alloc] initWithSize: badgeRect.size];41 [fBackBadge lockFocus];42 43 [[NSColor colorWithCalibratedWhite: 0.0f alpha: 0.75f] set];44 [bp fill];45 46 [fBackBadge unlockFocus];47 48 36 //create attributes 49 37 NSShadow * stringShadow = [[NSShadow alloc] init]; 50 [stringShadow setShadowOffset: NSMakeSize(2.0 f, -2.0f)];51 [stringShadow setShadowBlurRadius: 4.0 f];38 [stringShadow setShadowOffset: NSMakeSize(2.0, -2.0)]; 39 [stringShadow setShadowBlurRadius: 4.0]; 52 40 53 41 NSFont * bigFont = [[NSFontManager sharedFontManager] convertFont: 54 [NSFont fontWithName: @"Lucida Grande" size: 18.0 f] toHaveTrait: NSBoldFontMask],55 * smallFont = [NSFont fontWithName: @"Lucida Grande" size: 14.0 f];42 [NSFont fontWithName: @"Lucida Grande" size: 18.0] toHaveTrait: NSBoldFontMask], 43 * smallFont = [NSFont fontWithName: @"Lucida Grande" size: 14.0]; 56 44 57 45 NSMutableParagraphStyle * paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; … … 76 64 - (void) dealloc 77 65 { 78 [fBackBadge release];79 66 [fBadge release]; 80 67 … … 88 75 { 89 76 [fBadge release]; 90 fBadge = [fBackBadge copy];91 NSSize badgeSize = [fBadge size];92 77 78 //create badge 79 const NSRect badgeRect = NSMakeRect(0.0, 0.0, 325.0, 84.0); 80 NSBezierPath * bp = [NSBezierPath bezierPathWithRoundedRect: badgeRect xRadius: 15.0 yRadius: 15.0]; 81 82 fBadge = [[NSImage alloc] initWithSize: badgeRect.size]; 93 83 [fBadge lockFocus]; 94 84 85 [[NSColor colorWithCalibratedWhite: 0.0 alpha: 0.75] set]; 86 [bp fill]; 87 95 88 //place icon 96 [icon drawInRect: NSMakeRect(PADDING, ( badgeSize.height - ICON_WIDTH) * 0.5f, ICON_WIDTH, ICON_WIDTH) fromRect: NSZeroRect97 operation: NSCompositeSourceOver fraction: 1.0 f];89 [icon drawInRect: NSMakeRect(PADDING, (NSHeight(badgeRect) - ICON_WIDTH) * 0.5, ICON_WIDTH, ICON_WIDTH) fromRect: NSZeroRect 90 operation: NSCompositeSourceOver fraction: 1.0]; 98 91 99 92 //place main text 100 NSSize mainLineSize = [mainLine sizeWithAttributes: fMainLineAttributes];101 NSSize subLineSize = [subLine sizeWithAttributes: fSubLineAttributes];93 const NSSize mainLineSize = [mainLine sizeWithAttributes: fMainLineAttributes]; 94 const NSSize subLineSize = [subLine sizeWithAttributes: fSubLineAttributes]; 102 95 103 NSRect lineRect = NSMakeRect(PADDING + ICON_WIDTH + 5.0 f,104 ( badgeSize.height + (subLineSize.height + 2.0f - mainLineSize.height)) * 0.5f,105 badgeSize.width - (PADDING + ICON_WIDTH + 2.0f) - PADDING, mainLineSize.height);96 NSRect lineRect = NSMakeRect(PADDING + ICON_WIDTH + 5.0, 97 (NSHeight(badgeRect) + (subLineSize.height + 2.0 - mainLineSize.height)) * 0.5, 98 NSWidth(badgeRect) - (PADDING + ICON_WIDTH + 2.0) - PADDING, mainLineSize.height); 106 99 [mainLine drawInRect: lineRect withAttributes: fMainLineAttributes]; 107 100 108 101 //place sub text 109 lineRect.origin.y -= subLineSize.height + 2.0 f;102 lineRect.origin.y -= subLineSize.height + 2.0; 110 103 lineRect.size.height = subLineSize.height; 111 104 [subLine drawInRect: lineRect withAttributes: fSubLineAttributes]; … … 120 113 if (fBadge) 121 114 { 122 NSRect frame = [self frame];123 NSSize imageSize = [fBadge size];124 [fBadge compositeToPoint: NSMakePoint(( frame.size.width - imageSize.width) * 0.5f,125 ( frame.size.height - imageSize.height) * 0.5f) operation: NSCompositeSourceOver];115 const NSRect frame = [self frame]; 116 const NSSize imageSize = [fBadge size]; 117 [fBadge compositeToPoint: NSMakePoint((NSWidth(frame) - imageSize.width) * 0.5, 118 (NSHeight(frame) - imageSize.height) * 0.5) operation: NSCompositeSourceOver]; 126 119 } 127 120 }
Note: See TracChangeset
for help on using the changeset viewer.