Ignore:
Timestamp:
01/02/03 05:30:03 (20 years ago)
Author:
Nicholas Riley
Message:

Updated for Pester 1.1a5 (very limited release).

Pester 1.1a4 was never released.

Location:
trunk/Cocoa/Pester/Source
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cocoa/Pester/Source

    • Property svn:ignore
      •  

        old new  
        11build
         2.gdb_history
  • trunk/Cocoa/Pester/Source/NJRFSObjectSelector.m

    r43 r53  
    11#import "NJRFSObjectSelector.h"
    22#import "NSImage-NJRExtensions.h"
     3#import "NSString-NJRExtensions.h"
    34#include <Carbon/Carbon.h>
    45
     6static NSImage *PopupTriangleImage = nil;
     7static NSSize PopupTriangleSize;
     8
    59@implementation NJRFSObjectSelector
    610
    711- (void)_initSelector;
    812{
     13    if (PopupTriangleImage == nil) {
     14        PopupTriangleImage = [[NSImage imageNamed: @"Popup triangle"] retain];
     15        PopupTriangleSize = [PopupTriangleImage size];
     16    }
    917    canChooseFiles = YES; canChooseDirectories = NO;
    1018    [self setAlias: nil];
     
    4755        [NSBezierPath strokeRect: NSInsetRect(boundsRect, 2, 2)];
    4856    } 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         }
    5557        // 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];
    5759    }
    5860}
     
    130132        NSString *path = [alias fullPath];
    131133        NSString *revealPath = nil;
    132         NSString *targetName = [path lastPathComponent];
    133134        NSMenu *menu = [[NSMenu alloc] initWithTitle: @""];
    134135        NSFileManager *fmgr = [NSFileManager defaultManager];
     
    136137        if (path != nil) { // can resolve alias
    137138            [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            }
    139146            do {
    140147                item = [menu addItemWithTitle: [fmgr displayNameAtPath: path]
Note: See TracChangeset for help on using the changeset viewer.