Changeset 53 for trunk/Cocoa/Pester/Source/NJRFSObjectSelector.m
- Timestamp:
- 01/02/03 05:30:03 (22 years ago)
- Location:
- trunk/Cocoa/Pester/Source
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cocoa/Pester/Source
- Property svn:ignore
-
old new 1 1 build 2 .gdb_history
-
- Property svn:ignore
-
trunk/Cocoa/Pester/Source/NJRFSObjectSelector.m
r43 r53 1 1 #import "NJRFSObjectSelector.h" 2 2 #import "NSImage-NJRExtensions.h" 3 #import "NSString-NJRExtensions.h" 3 4 #include <Carbon/Carbon.h> 4 5 6 static NSImage *PopupTriangleImage = nil; 7 static NSSize PopupTriangleSize; 8 5 9 @implementation NJRFSObjectSelector 6 10 7 11 - (void)_initSelector; 8 12 { 13 if (PopupTriangleImage == nil) { 14 PopupTriangleImage = [[NSImage imageNamed: @"Popup triangle"] retain]; 15 PopupTriangleSize = [PopupTriangleImage size]; 16 } 9 17 canChooseFiles = YES; canChooseDirectories = NO; 10 18 [self setAlias: nil]; … … 47 55 [NSBezierPath strokeRect: NSInsetRect(boundsRect, 2, 2)]; 48 56 } else if (selectedAlias != nil && [self isEnabled]) { 49 static NSImage *popupTriangle = nil;50 static NSSize imageSize;51 if (popupTriangle == nil) {52 popupTriangle = [[NSImage imageNamed: @"Popup triangle"] retain];53 imageSize = [popupTriangle size];54 }55 57 // equivalent to popup triangle location for large bezel in Carbon 56 [ popupTriangle compositeToPoint: NSMakePoint(NSMaxX(boundsRect) - imageSize.width - 5, NSMaxY(boundsRect) - 5) operation: NSCompositeSourceOver];58 [PopupTriangleImage compositeToPoint: NSMakePoint(NSMaxX(boundsRect) - PopupTriangleSize.width - 5, NSMaxY(boundsRect) - 5) operation: NSCompositeSourceOver]; 57 59 } 58 60 } … … 130 132 NSString *path = [alias fullPath]; 131 133 NSString *revealPath = nil; 132 NSString *targetName = [path lastPathComponent];133 134 NSMenu *menu = [[NSMenu alloc] initWithTitle: @""]; 134 135 NSFileManager *fmgr = [NSFileManager defaultManager]; … … 136 137 if (path != nil) { // can resolve alias 137 138 [self setImage: [[NSWorkspace sharedWorkspace] iconForFile: path]]; 138 [self setTitle: targetName]; 139 { // set image first so titleRectForBounds: returns the correct value 140 NSMutableString *title = [[fmgr displayNameAtPath: path] mutableCopy]; 141 NSDictionary *fontAttributes = [[self attributedTitle] fontAttributesInRange: NSMakeRange(0, 0)]; 142 [title truncateToWidth: [[self cell] titleRectForBounds: [self bounds]].size.width - PopupTriangleSize.width by: NSLineBreakByTruncatingMiddle withAttributes: fontAttributes]; 143 [self setTitle: title]; 144 [title release]; 145 } 139 146 do { 140 147 item = [menu addItemWithTitle: [fmgr displayNameAtPath: path]
Note:
See TracChangeset
for help on using the changeset viewer.