- Timestamp:
- 02/13/04 21:01:06 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cocoa/F-Script Anywhere/Source/NSString-NJRExtensions.m
r7 r153 14 14 #import "NSString-NJRExtensions.h" 15 15 16 #ifndef NSAppKitVersionNumber10_2 17 #define NSAppKitVersionNumber10_2 663 18 #endif 19 16 20 @implementation NSString (NJRExtensions) 17 21 … … 20 24 NSAttributedString *s = [NSAttributedString alloc]; 21 25 NSMutableParagraphStyle *ps = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; 22 OSStatus err; 23 /* 24 NSString *fs; 25 Str255 font; 26 SInt16 size; // label font is 10, pushbutton font 13, views font is 12! 27 err = GetThemeFont(kThemeViewsFont, smUnicodeScript, font, &size, NULL); 28 fs = CFStringCreateWithPascalString(kCFAllocatorDefault, font, CFStringGetSystemEncoding()); 29 NSLog(@"Theme font: %@ %d", fs, size); 30 */ 31 err = TruncateThemeText((CFMutableStringRef) text, kThemeViewsFont, 32 kThemeStateActive, width, truncMiddle, NULL); 33 /* // There's a workaround for a 10.1 bug in Connections' awakeFromNib: the initial 34 // column size is wrong, until you resize the window. Here's how to demonstrate the bug: 35 { static float lastWidth = 0; // XXX debug 36 if (lastWidth != width) { 37 lastWidth = width; 38 NSLog(@"Got width %f", width); 39 } 26 if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_2) { 27 [ps setLineBreakMode: NSLineBreakByTruncatingMiddle]; 28 } else { 29 // Mac OS X versions earlier than 10.3 don't implement NSLineBreakByTruncatingMiddle; fake it 30 OSStatus err; 31 err = TruncateThemeText((CFMutableStringRef) text, kThemeViewsFont, 32 kThemeStateActive, width, truncMiddle, NULL); 33 if (err != noErr) FSALog(@"-[NSString asAttributedStringTruncatedToWidth:]: TruncateThemeText failed with error %d", err); 34 [ps setLineBreakMode: NSLineBreakByClipping]; 40 35 } 41 */42 if (err != noErr) FSALog(@"-[NSString asAttributedStringTruncatedToWidth:]: TruncateThemeText failed with error %d", err);43 // XXX Should be able to skip the above by using NSLineBreakByTruncatingMiddle,44 // XXX but OS X 10.1 doesn't implement it yet.45 [ps setLineBreakMode: NSLineBreakByClipping];46 36 s = [s initWithString: text attributes: 47 37 [NSDictionary dictionaryWithObjectsAndKeys: ps, NSParagraphStyleAttributeName, nil]];
Note:
See TracChangeset
for help on using the changeset viewer.