/*+++*
 *  RCS CheckedBrowserCell.m,v 1.2 1995/07/13 13:16:23 tom Exp
 *  title:	CheckedBrowserCell.m
 *  abstract:	implementation of CheckedBrowserCell class, for NewsConfig.app
 *  author:	T.R.Hageman, Groningen, The Netherlands
 *  created:	January 1995
 *  modified:	(see RCS Log at end)
 *  copyright:
 *
 *		Copyright (C) 1995  Tom R. Hageman.
 *
 *	This is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License as published by
 *	the Free Software Foundation; either version 2 of the License, or
 *	(at your option) any later version.
 *
 *	This software is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this software; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *  description:
 *
 *---*/

#import "CheckedBrowserCell.h"


@interface CheckedBrowserCell (Private)
- (void)_setChecked:(BOOL)yn;
@end


@implementation CheckedBrowserCell

- initTextCell:(const char *)aString
{
	if (self = [super initTextCell:aString]) {
		[self _setChecked:NO];
	}
	return self;
}

- copyFromZone:(NXZone *)zone
{
	CheckedBrowserCell *copy;

	if (copy = [super copyFromZone:zone]) {
		[copy _setChecked:checked];
	}
	return copy;
}

// Return minimum cell size.  (default just gives cells that are
// too cramped somehow.  Don't ask me why.)
- calcCellSize:(NXSize *)theSize
{
	theSize->width = theSize->height = 15;	// *VERY* Quick Hack(tm)

	return self;
}


// Accessor methods.
- (BOOL)checked	{ return checked; }

- setChecked:(BOOL)yn
{
	if (checked != yn) {
		[self _setChecked:yn];
	}
	return self;
}

@end // CheckedBrowserCell


@implementation CheckedBrowserCell (Private)

- (void)_setChecked:(BOOL)yn
{
	const char *imageName, *imageHName;

	if (checked = yn) {
		imageName = "check";
		imageHName= "checkH";
	}
	else {
		imageName = "nocheck";
		imageHName= "nocheckH";
	}
	[self setImage:[[NXImage findImageNamed:imageName] copyFromZone:[self zone]]];
	[self setAltImage:[[NXImage findImageNamed:imageHName] copyFromZone:[self zone]]];
}

@end // CheckedBrowserCell

//======================================================================
// CheckedBrowserCell.m,v
// Revision 1.2  1995/07/13 13:16:23  tom
// [added RCS Id, fixed Copyright notice]
//
// Revision 1.1  1995/01/10  03:27:10  tom
// Initial revision
//
//======================================================================
