Hi,

In the new Mail, when there's no selection, the detail's view show "No Message 
Selected" in an what seems to be embossed text. My various attempts to emulate 
that, have failed. Well it kinda work but it's a bit ugly.

Here's what I've done:

- (BOOL)isFlipped
{
    return YES;
}

- (void)drawRect:(NSRect)dirtyRect
{
    [[NSColor whiteColor] set];
        [NSBezierPath fillRect:[self bounds]];  
    [[NSColor grayColor] set];
    [NSBezierPath strokeRect:[self bounds]];
    // draw image
    CGFloat imgW = [banner size].width;
    CGFloat imgH = [banner size].height;
    CGFloat centerX = [self bounds].size.width / 2.0f;
    CGFloat centerY = [self bounds].size.height /2.0f;
    CGFloat x = centerX - (imgW / 2.0f);
    CGFloat y = centerY - (imgH / 2.0f);
    NSRect rectToDraw = NSMakeRect(x, y, imgW, imgH);
    NSRect imgRect = NSMakeRect(0.0f, 0.0f, imgW, imgH);
    [banner drawInRect:rectToDraw fromRect:imgRect operation:NSCompositeCopy 
fraction:1.0];
    // draw text
    CGFloat fontSize = 18.0f;
    NSString *fontName = @"Helvetica";
    NSString *message = @"No Message Selected";
    CGFloat offset = 1.0f;
    
    NSDictionary *attributes = [NSDictionary 
dictionaryWithObjectsAndKeys:[NSFont fontWithName:fontName size:fontSize],
                                NSFontAttributeName,
                                [NSColor grayColor],
                                NSForegroundColorAttributeName, 
                                nil];
    
    NSAttributedString * currentText=[[NSAttributedString alloc] 
initWithString:message attributes: attributes];
    CGFloat textW = [currentText size].width;
    NSPoint textPt = NSMakePoint(centerX - (textW / 2.0f), centerY + (imgH / 
2.0f) + 10);
    [currentText drawAtPoint:textPt];
    [NSGraphicsContext restoreGraphicsState];

    NSDictionary *attributesOffset = [NSDictionary 
dictionaryWithObjectsAndKeys:[NSFont fontWithName:fontName size:fontSize],
                                NSFontAttributeName,
                                [NSColor lightGrayColor],
                                NSForegroundColorAttributeName, 
                                nil];
    
    NSAttributedString * currentTextOffset=[[NSAttributedString alloc] 
initWithString:message attributes: attributesOffset];
    //textPt.x += offset;
    textPt.y += offset;
    [currentTextOffset drawAtPoint:textPt];
}

Any suggestions?

Thanks,

Andre Masse
_______________________________________________

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