ftp.nice.ch/pub/next/developer/resources/classes/BrowseableCell.s.tar.gz#/BrowseableCell/InboxCell.m

This is InboxCell.m in view mode; [Download] [Up]

#import "InboxCell.h"
#import <appkit/Text.h>

@implementation InboxCell

- loadValues: (Inbox *) inbox
{
    int i;
    /* Create the cells if they don't exist */
    if (!name) name = [Cell newTextCell: ""];
    if (!messageCount) messageCount = [[Cell newTextCell: ""]
				        setAlignment: NX_RIGHTALIGNED];
    if (!unreadCount)  unreadCount  = [[Cell newTextCell: ""]
				        setAlignment: NX_RIGHTALIGNED];

    /* Set the values, making numerics blank when zero. */
    [name setStringValueNoCopy: [inbox name]];
    if (i = [inbox messageCount]) [messageCount setIntValue: i];
    else [messageCount setStringValue: ""];
    if (i = [inbox unreadCount]) [unreadCount setIntValue: i];
    else [unreadCount setStringValue: ""];
    return self;
}

/* This doesn't actually draw this cell at all. Instead, it asks the
   component cells to draw their insides in the right places.
*/

- drawInside: (const NXRect *) cellFrame inView: controlView
{
    NXRect tempRect;
    [super drawInside: cellFrame inView: controlView];

    tempRect = *cellFrame;
    tempRect.size.width = cellFrame->size.width / 6 - 12;
    [messageCount drawInside: &tempRect inView: controlView];

    tempRect.origin.x += cellFrame->size.width / 6;
    [unreadCount drawInside: &tempRect inView: controlView];

    tempRect.origin.x += cellFrame->size.width / 6;
    tempRect.size.width = cellFrame->size.width * 2.0 / 3.0;
    [name drawInside: &tempRect inView: controlView];

    return self;
}

- copy
{
    InboxCell *newCell = [super copy];
    newCell->name = [name copy];
    newCell->messageCount = [messageCount copy];
    newCell->unreadCount = [unreadCount copy];
    return newCell;
}

- free
{
    if (name) [name free];
    if (messageCount) [messageCount free];
    if (unreadCount) [unreadCount free];
    return [super free];
}

@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.