It seems like the best solution would be to handle both the Leopard+ and pre-Leopard cases at runtime so any changes to HID over time are non-issues since you've limited the custom code to the pre-Leopard case. You might be able to get away with as little as adding a category to NSCell (typed in Mail so this hasn't been tested):

@implementation NSCell (MyRaisedBackgroundStyle)
- (void)useRaisedBackgroundStyle
{
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
    if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_4)
    {
NSMutableAttributedString* text = [[[NSMutableAttributedString alloc] initWithAttributedString:
                                [self attributedStringValue]] autorelease];
        NSShadow* shadow = [[[NSShadow alloc] init] autorelease];

[shadow setShadowColor:[NSColor colorWithCalibratedWhite:1.0 alpha:0.5]];
        [shadow setShadowOffset:NSMakeSize(0.0, -1.5)];
        [shadow setShadowBlurRadius:0.0];

[text addAttribute:NSShadowAttributeName value:shadow range:NSMakeRange(0, [text length])];
        [self setAttributedStringValue:text];
    }
    else
#endif

    {
        [self setBackgroundStyle:NSBackgroundStyleRaised];
    }
}
@end

You'd need to call this method after the cell's text has been initialized/modified, which could just be done in -awakeFromNib for static text. If you wanted to get fancy, you could write a custom cell class that does all of the above whenever any of the text attributes are changed.

steve


On Feb 22, 2009, at 2:38 PM, Ken Ferry wrote:

Yes, I'm sure. :-) You won't get the subpixel font smoothing right, if
nothing else.
Also, the other method tracks whatever the current human interface design is
for text on a raised surface.

-Ken

On Sun, Feb 22, 2009 at 2:16 PM, Graham Cox <graham....@bigpond.com> wrote:


On 23/02/2009, at 4:43 AM, Ken Ferry wrote:

 This effect cannot be implemented with text attributes.


Are you sure? This gets awfully close, unless I'm missing the point here
(the font to use your choice):

+ (NSDictionary*)       defaultTitleAttributes
{
// return the dictionary used to specify the attributes for drawing
the title string in the palette windows. Override to
       // customize the title string

       static NSDictionary*    sTitleAttrs = nil;

       if ( sTitleAttrs == nil )
       {
               NSFont* font = [NSFont boldSystemFontOfSize:11.0];
               NSMutableParagraphStyle* style = [[NSParagraphStyle
defaultParagraphStyle] mutableCopy];

               [style setAlignment:NSCenterTextAlignment];

               NSShadow* shadw = [[NSShadow alloc] init];

               [shadw setShadowColor:[NSColor whiteColor]];
               [shadw setShadowOffset:NSMakeSize( 0, -1.5 )];
               [shadw setShadowBlurRadius:1.0];

               sTitleAttrs = [NSDictionary
dictionaryWithObjectsAndKeys:font,NSFontAttributeName,

 style,NSParagraphStyleAttributeName,

 shadw, NSShadowAttributeName,

 nil];
               [sTitleAttrs retain];
               [style release];
               [shadw release];
       }

       return sTitleAttrs;
}
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to