1996-05-30 20:03:15 +00:00
|
|
|
/*
|
|
|
|
NSActionCell.m
|
|
|
|
|
|
|
|
Abstract cell for target/action paradigm
|
|
|
|
|
|
|
|
Copyright (C) 1996 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Author: Scott Christley <scottc@net-community.com>
|
|
|
|
Date: 1996
|
|
|
|
|
|
|
|
This file is part of the GNUstep GUI Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library 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
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
1996-10-18 17:14:13 +00:00
|
|
|
License along with this library; see the file COPYING.LIB.
|
|
|
|
If not, write to the Free Software Foundation,
|
|
|
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1996-05-30 20:03:15 +00:00
|
|
|
*/
|
|
|
|
|
1997-02-18 00:29:25 +00:00
|
|
|
#include <Foundation/NSCoder.h>
|
|
|
|
#include <AppKit/NSActionCell.h>
|
|
|
|
#include <AppKit/NSControl.h>
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
@implementation NSActionCell
|
|
|
|
|
|
|
|
//
|
|
|
|
// Class methods
|
|
|
|
//
|
|
|
|
+ (void)initialize
|
|
|
|
{
|
|
|
|
if (self == [NSActionCell class])
|
|
|
|
{
|
1996-07-11 00:59:30 +00:00
|
|
|
NSDebugLog(@"Initialize NSActionCell class\n");
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
// Initial version
|
|
|
|
[self setVersion:1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Instance methods
|
|
|
|
//
|
|
|
|
- init
|
|
|
|
{
|
|
|
|
[super init];
|
|
|
|
target = nil;
|
|
|
|
action = NULL;
|
|
|
|
tag = 0;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- initImageCell:(NSImage *)anImage
|
|
|
|
{
|
|
|
|
[super initImageCell:anImage];
|
|
|
|
target = nil;
|
|
|
|
action = NULL;
|
|
|
|
tag = 0;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- initTextCell:(NSString *)aString
|
|
|
|
{
|
|
|
|
[super initTextCell:aString];
|
|
|
|
target = nil;
|
|
|
|
action = NULL;
|
|
|
|
tag = 0;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Configuring an NSActionCell
|
|
|
|
//
|
|
|
|
- (void)setAlignment:(NSTextAlignment)mode
|
|
|
|
{
|
|
|
|
[super setAlignment:mode];
|
|
|
|
if (control_view)
|
|
|
|
if ([control_view isKindOfClass: [NSControl class]])
|
|
|
|
[(NSControl *)control_view updateCell: self];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setBezeled:(BOOL)flag
|
|
|
|
{
|
|
|
|
[super setBezeled:flag];
|
|
|
|
if (control_view)
|
|
|
|
if ([control_view isKindOfClass: [NSControl class]])
|
|
|
|
[(NSControl *)control_view updateCell: self];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setBordered:(BOOL)flag
|
|
|
|
{
|
|
|
|
[super setBordered:flag];
|
|
|
|
if (control_view)
|
|
|
|
if ([control_view isKindOfClass: [NSControl class]])
|
|
|
|
[(NSControl *)control_view updateCell: self];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setEnabled:(BOOL)flag
|
|
|
|
{
|
|
|
|
[super setEnabled:flag];
|
|
|
|
if (control_view)
|
|
|
|
if ([control_view isKindOfClass: [NSControl class]])
|
|
|
|
[(NSControl *)control_view updateCell: self];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setFloatingPointFormat:(BOOL)autoRange
|
|
|
|
left:(unsigned int)leftDigits
|
|
|
|
right:(unsigned int)rightDigits
|
|
|
|
{
|
|
|
|
[super setFloatingPointFormat:autoRange left:leftDigits right:rightDigits];
|
|
|
|
if (control_view)
|
|
|
|
if ([control_view isKindOfClass: [NSControl class]])
|
|
|
|
[(NSControl *)control_view updateCell: self];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setFont:(NSFont *)fontObject
|
|
|
|
{
|
|
|
|
[super setFont:fontObject];
|
|
|
|
if (control_view)
|
|
|
|
if ([control_view isKindOfClass: [NSControl class]])
|
|
|
|
[(NSControl *)control_view updateCell: self];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setImage:(NSImage *)image
|
|
|
|
{
|
|
|
|
[super setImage:image];
|
|
|
|
if (control_view)
|
|
|
|
if ([control_view isKindOfClass: [NSControl class]])
|
|
|
|
[(NSControl *)control_view updateCell: self];
|
|
|
|
}
|
|
|
|
|
1996-07-10 20:43:47 +00:00
|
|
|
//
|
|
|
|
// Setting the NSCell's State
|
|
|
|
//
|
|
|
|
- (void)setState:(int)value
|
|
|
|
{
|
|
|
|
[super setState: value];
|
|
|
|
if (control_view)
|
|
|
|
if ([control_view isKindOfClass: [NSControl class]])
|
|
|
|
[(NSControl *)control_view updateCell: self];
|
|
|
|
}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
|
|
|
// Manipulating NSActionCell Values
|
|
|
|
//
|
|
|
|
- (void)setStringValue:(NSString *)aString
|
|
|
|
{
|
|
|
|
[super setStringValue:aString];
|
|
|
|
if (control_view)
|
|
|
|
if ([control_view isKindOfClass: [NSControl class]])
|
|
|
|
[(NSControl *)control_view updateCell: self];
|
|
|
|
}
|
|
|
|
|
1997-02-18 00:29:25 +00:00
|
|
|
- (void)setDoubleValue:(double)aDouble
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
[super setDoubleValue:aDouble];
|
|
|
|
if (control_view)
|
|
|
|
if ([control_view isKindOfClass: [NSControl class]])
|
|
|
|
[(NSControl *)control_view updateCell: self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1997-02-18 00:29:25 +00:00
|
|
|
- (void)setFloatValue:(float)aFloat
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
[super setFloatValue:aFloat];
|
|
|
|
if (control_view)
|
|
|
|
if ([control_view isKindOfClass: [NSControl class]])
|
|
|
|
[(NSControl *)control_view updateCell: self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1997-02-18 00:29:25 +00:00
|
|
|
- (void)setIntValue:(int)anInt
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
[super setIntValue:anInt];
|
|
|
|
if (control_view)
|
|
|
|
if ([control_view isKindOfClass: [NSControl class]])
|
|
|
|
[(NSControl *)control_view updateCell: self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Target and Action
|
|
|
|
//
|
|
|
|
- (SEL)action
|
|
|
|
{
|
|
|
|
return action;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setAction:(SEL)aSelector
|
|
|
|
{
|
|
|
|
action = aSelector;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setTarget:(id)anObject
|
|
|
|
{
|
|
|
|
target = anObject;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id)target
|
|
|
|
{
|
|
|
|
return target;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Assigning a Tag
|
|
|
|
//
|
|
|
|
- (void)setTag:(int)anInt
|
|
|
|
{
|
|
|
|
tag = anInt;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int)tag
|
|
|
|
{
|
|
|
|
return tag;
|
|
|
|
}
|
|
|
|
|
1997-04-22 18:23:58 +00:00
|
|
|
- (id)copyWithZone:(NSZone*)zone
|
|
|
|
{
|
|
|
|
NSActionCell* c = [super copyWithZone:zone];
|
|
|
|
|
|
|
|
[c setTag:tag];
|
|
|
|
[c setTarget:target];
|
|
|
|
[c setAction:action];
|
|
|
|
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
|
|
|
// NSCoding protocol
|
|
|
|
//
|
|
|
|
- (void)encodeWithCoder:aCoder
|
|
|
|
{
|
|
|
|
[super encodeWithCoder:aCoder];
|
|
|
|
|
|
|
|
[aCoder encodeValueOfObjCType: "i" at: &tag];
|
1997-02-18 00:29:25 +00:00
|
|
|
#if 0
|
1996-05-30 20:03:15 +00:00
|
|
|
[aCoder encodeObjectReference: target withName: @"Target"];
|
1997-02-18 00:29:25 +00:00
|
|
|
#else
|
|
|
|
[aCoder encodeConditionalObject:target];
|
|
|
|
#endif
|
|
|
|
|
|
|
|
[aCoder encodeValueOfObjCType:@encode(SEL) at: &action];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- initWithCoder:aDecoder
|
|
|
|
{
|
|
|
|
[super initWithCoder:aDecoder];
|
|
|
|
|
|
|
|
[aDecoder decodeValueOfObjCType: "i" at: &tag];
|
1997-02-18 00:29:25 +00:00
|
|
|
#if 0
|
1996-05-30 20:03:15 +00:00
|
|
|
[aDecoder decodeObjectAt: &target withName: NULL];
|
1997-02-18 00:29:25 +00:00
|
|
|
#else
|
|
|
|
target = [aDecoder decodeObject];
|
|
|
|
#endif
|
1996-05-30 20:03:15 +00:00
|
|
|
[aDecoder decodeValueOfObjCType: @encode(SEL) at: &action];
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|