1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
|
/* Implementation of class NSTableCellView
Copyright (C) 2022 Free Software Foundation, Inc.
By: Gregory John Casamento <greg.casamento@gmail.com>
Date: 12-12-2022
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"
#import "AppKit/NSImageView.h"
#import "AppKit/NSTextField.h"
@implementation NSTableCellView
- (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];
}
- (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;
}
- (void) setRowSizeStyle: (NSTableViewRowSizeStyle)rowSizeStyle
{
_rowSizeStyle = rowSizeStyle;
}
- (NSArray *) draggingImageComponents
{
return _draggingImageComponents;
}
- (void) setDraggingImageComponents: (NSArray *)draggingImageComponents
{
ASSIGNCOPY(_draggingImageComponents, draggingImageComponents);
}
- (void) encodeWithCoder: (NSCoder *)coder
{
[super encodeWithCoder: coder];
if ([coder allowsKeyedCoding])
{
[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"];
}
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])
{
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"])
{
[self setDraggingImageComponents: [coder decodeObjectForKey: @"NSDraggingImageComponents"]];
}
}
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
{
NSTableCellView *copy = [[NSTableCellView allocWithZone: zone] init];
[copy setObjectValue: [self objectValue]];
[copy setImageView: [self imageView]];
[copy setTextField: [self textField]];
[copy setDraggingImageComponents: [self draggingImageComponents]];
[copy setBackgroundStyle: [self backgroundStyle]];
[copy setRowSizeStyle: [self rowSizeStyle]];
return copy;
}
@end
|