2022-09-03 11:27:49 +00:00
|
|
|
/* Implementation of class NSTableCellView
|
|
|
|
Copyright (C) 2022 Free Software Foundation, Inc.
|
|
|
|
|
2022-12-12 15:46:34 +00:00
|
|
|
By: Gregory John Casamento <greg.casamento@gmail.com>
|
|
|
|
Date: 12-12-2022
|
2022-09-03 11:27:49 +00:00
|
|
|
|
|
|
|
This file is part of the GNUstep Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 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
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library; if not, write to the Free
|
|
|
|
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02110 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#import "AppKit/NSTableCellView.h"
|
2022-12-12 16:14:02 +00:00
|
|
|
#import "AppKit/NSImageView.h"
|
|
|
|
#import "AppKit/NSTextField.h"
|
2022-09-03 11:27:49 +00:00
|
|
|
|
|
|
|
@implementation NSTableCellView
|
|
|
|
|
2022-12-12 19:37:46 +00:00
|
|
|
- (instancetype) initWithFrame: (NSRect)frame
|
|
|
|
{
|
|
|
|
self = [super initWithFrame: frame];
|
|
|
|
if (self != nil)
|
|
|
|
{
|
|
|
|
_rowSizeStyle = NSTableViewRowSizeStyleDefault;
|
|
|
|
_backgroundStyle = NSBackgroundStyleLight;
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (instancetype) init
|
|
|
|
{
|
|
|
|
return [self initWithFrame: NSZeroRect];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
RELEASE(_objectValue);
|
|
|
|
RELEASE(_imageView);
|
|
|
|
RELEASE(_textField);
|
|
|
|
RELEASE(_draggingImageComponents);
|
|
|
|
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2022-12-12 16:14:02 +00:00
|
|
|
- (id) objectValue
|
|
|
|
{
|
|
|
|
return _objectValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setObjectValue: (id)objectValue
|
|
|
|
{
|
|
|
|
ASSIGN(_objectValue, objectValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSImageView *) imageView
|
|
|
|
{
|
|
|
|
return _imageView;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setImageView: (NSImageView *)imageView
|
|
|
|
{
|
|
|
|
ASSIGN(_imageView, imageView);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSTextField *) textField
|
|
|
|
{
|
|
|
|
return _textField;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setTextField: (NSTextField *)textField
|
|
|
|
{
|
|
|
|
ASSIGN(_textField, textField);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSBackgroundStyle) backgroundStyle
|
|
|
|
{
|
|
|
|
return _backgroundStyle;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setBackgroundStyle: (NSBackgroundStyle)backgroundStyle
|
|
|
|
{
|
|
|
|
_backgroundStyle = backgroundStyle;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSTableViewRowSizeStyle) rowSizeStyle
|
|
|
|
{
|
|
|
|
return _rowSizeStyle;
|
|
|
|
}
|
|
|
|
|
2024-02-19 16:33:24 +00:00
|
|
|
- (void) setRowSizeStyle: (NSTableViewRowSizeStyle)rowSizeStyle
|
2022-12-12 16:14:02 +00:00
|
|
|
{
|
|
|
|
_rowSizeStyle = rowSizeStyle;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) draggingImageComponents
|
|
|
|
{
|
|
|
|
return _draggingImageComponents;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setDraggingImageComponents: (NSArray *)draggingImageComponents
|
|
|
|
{
|
|
|
|
ASSIGNCOPY(_draggingImageComponents, draggingImageComponents);
|
|
|
|
}
|
|
|
|
|
2022-12-12 19:37:46 +00:00
|
|
|
- (void) encodeWithCoder: (NSCoder *)coder
|
|
|
|
{
|
|
|
|
[super encodeWithCoder: coder];
|
|
|
|
if ([coder allowsKeyedCoding])
|
|
|
|
{
|
2024-02-19 16:33:24 +00:00
|
|
|
[coder encodeObject: [self objectValue]
|
|
|
|
forKey: @"NSObjectValue"];
|
|
|
|
[coder encodeObject: [self imageView]
|
|
|
|
forKey: @"NSImageView"];
|
|
|
|
[coder encodeObject: [self textField]
|
|
|
|
forKey: @"NSTextField"];
|
|
|
|
[coder encodeInt: [self backgroundStyle]
|
|
|
|
forKey: @"NSBackgroundStyle"];
|
|
|
|
[coder encodeInt: [self rowSizeStyle]
|
|
|
|
forKey: @"NSTableViewRowSizeStyle"];
|
|
|
|
[coder encodeObject: [self draggingImageComponents]
|
|
|
|
forKey: @"NSDraggingImageComponents"];
|
2022-12-12 19:37:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[coder encodeObject: _objectValue];
|
|
|
|
[coder encodeObject: _imageView];
|
|
|
|
[coder encodeObject: _textField];
|
|
|
|
[coder encodeObject: _draggingImageComponents];
|
|
|
|
|
|
|
|
[coder encodeValueOfObjCType: @encode(NSBackgroundStyle)
|
|
|
|
at: &_backgroundStyle];
|
|
|
|
[coder encodeValueOfObjCType: @encode(NSTableViewRowSizeStyle)
|
|
|
|
at: &_rowSizeStyle];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) initWithCoder: (NSCoder *)coder
|
|
|
|
{
|
|
|
|
self = [super initWithCoder: coder];
|
|
|
|
if (self != nil)
|
|
|
|
{
|
|
|
|
if ([coder allowsKeyedCoding])
|
|
|
|
{
|
2024-02-19 16:33:24 +00:00
|
|
|
if ([coder containsValueForKey: @"NSObjectValue"])
|
|
|
|
{
|
|
|
|
[self setObjectValue: [coder decodeObjectForKey: @"NSObjectValue"]];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ([coder containsValueForKey: @"NSImageView"])
|
|
|
|
{
|
|
|
|
[self setImageView: [coder decodeObjectForKey: @"NSImageView"]];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ([coder containsValueForKey: @"NSTextField"])
|
|
|
|
{
|
|
|
|
[self setTextField: [coder decodeObjectForKey: @"NSTextField"]];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ([coder containsValueForKey: @"NSBackgroundStyle"])
|
|
|
|
{
|
|
|
|
[self setBackgroundStyle: [coder decodeIntForKey: @"NSBackgroundStyle"]];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ([coder containsValueForKey: @"NSTableViewRowSizeStyle"])
|
|
|
|
{
|
|
|
|
[self setRowSizeStyle: [coder decodeIntForKey: @"NSTableViewRowSizeStyle"]];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ([coder containsValueForKey: @"NSDraggingImageComponents"])
|
|
|
|
{
|
2024-04-19 20:50:12 +00:00
|
|
|
[self setDraggingImageComponents: [coder decodeObjectForKey: @"NSDraggingImageComponents"]];
|
2024-02-19 16:33:24 +00:00
|
|
|
}
|
2022-12-12 19:37:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[self setObjectValue: [coder decodeObject]];
|
|
|
|
[self setImageView: [coder decodeObject]];
|
|
|
|
[self setTextField: [coder decodeObject]];
|
|
|
|
[self setDraggingImageComponents: [coder decodeObject]];
|
|
|
|
|
|
|
|
[coder decodeValueOfObjCType: @encode(NSBackgroundStyle)
|
|
|
|
at: &_backgroundStyle];
|
|
|
|
[coder decodeValueOfObjCType: @encode(NSTableViewRowSizeStyle)
|
|
|
|
at: &_rowSizeStyle];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) copyWithZone: (NSZone *)zone
|
|
|
|
{
|
|
|
|
NSData *d = [NSArchiver archivedDataWithRootObject: self];
|
|
|
|
id copy = [NSUnarchiver unarchiveObjectWithData: d];
|
|
|
|
|
|
|
|
return copy;
|
|
|
|
}
|
|
|
|
|
2022-09-03 11:27:49 +00:00
|
|
|
@end
|