Corrected the handling of the cellClass so that every subclass of

NSControl, that uses a cell, has its own implementaion of
[cellClass] and [setCellClass].


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@9544 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2001-04-09 21:28:49 +00:00
parent 499f86c8df
commit 77b0f2bfb1
2 changed files with 50 additions and 16 deletions

View file

@ -29,13 +29,41 @@
#include <AppKit/NSImageCell.h>
#include <AppKit/NSImageView.h>
/*
* Class variables
*/
static Class usedCellClass;
static Class imageCellClass;
@implementation NSImageView
//
// Class methods
//
+ (void) initialize
{
if (self == [NSImageView class])
{
[self setVersion: 1];
imageCellClass = [NSImageCell class];
usedCellClass = imageCellClass;
}
}
/*
* Setting the Cell class
*/
+ (Class) cellClass
{
return [NSImageCell class];
return usedCellClass;
}
+ (void) setCellClass: (Class)factoryId
{
usedCellClass = factoryId ? factoryId : imageCellClass;
}
- (id) init
{
return [self initWithFrame: NSZeroRect];
@ -45,9 +73,6 @@
{
[super initWithFrame: aFrame];
// allocate the image cell
[self setCell: [[NSImageCell alloc] init]];
// set the default values
[self setImageAlignment: NSImageAlignCenter];
[self setImageFrameStyle: NSImageFrameNone];

View file

@ -44,6 +44,12 @@
static NSNotificationCenter *nc;
/*
* Class variables
*/
static Class usedCellClass;
static Class textFieldCellClass;
@implementation NSTextField
//
// Class methods
@ -53,11 +59,25 @@ static NSNotificationCenter *nc;
if (self == [NSTextField class])
{
[self setVersion: 1];
[self setCellClass: [NSTextFieldCell class]];
textFieldCellClass = [NSTextFieldCell class];
usedCellClass = textFieldCellClass;
nc = [NSNotificationCenter defaultCenter];
}
}
/*
* Setting the Cell class
*/
+ (Class) cellClass
{
return usedCellClass;
}
+ (void) setCellClass: (Class)factoryId
{
usedCellClass = factoryId ? factoryId : textFieldCellClass;
}
//
// Instance methods
//
@ -75,17 +95,6 @@ static NSNotificationCenter *nc;
return self;
}
//
// Creating copies
//
- (id) copyWithZone: (NSZone*)zone
{
NSTextField *c;
c = [super copyWithZone: zone];
return c;
}
//
// Setting User Access to Text