mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 19:10:48 +00:00
Added keyed decoding.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@18530 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7ebc080da5
commit
108986ee7d
7 changed files with 171 additions and 61 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2004-02-02 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Source/NSFont.m
|
||||||
|
Try to get at least some font on keyed decoding.
|
||||||
|
* Source/NSTextFieldCell.m
|
||||||
|
* Source/NSImageCell.m
|
||||||
|
* Source/NSImageView.m
|
||||||
|
* Source/NSBox.m
|
||||||
|
* Source/NSSplitView.m
|
||||||
|
Added keyed decoding.
|
||||||
|
|
||||||
2004-02-01 Fred Kiefer <FredKiefer@gmx.de>
|
2004-02-01 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Source/NSTextFieldCell.m (-setBackgroundColor:,
|
* Source/NSTextFieldCell.m (-setBackgroundColor:,
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <Foundation/NSArray.h>
|
#include <Foundation/NSArray.h>
|
||||||
#include <Foundation/NSDebug.h>
|
#include <Foundation/NSDebug.h>
|
||||||
#include <Foundation/NSException.h>
|
#include <Foundation/NSException.h>
|
||||||
|
#include <Foundation/NSKeyedArchiver.h>
|
||||||
#include <Foundation/NSString.h>
|
#include <Foundation/NSString.h>
|
||||||
|
|
||||||
#include "AppKit/NSBox.h"
|
#include "AppKit/NSBox.h"
|
||||||
|
@ -407,33 +408,68 @@
|
||||||
|
|
||||||
- (id) initWithCoder: (NSCoder*)aDecoder
|
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||||
{
|
{
|
||||||
[super initWithCoder: aDecoder];
|
self = [super initWithCoder: aDecoder];
|
||||||
|
|
||||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_cell];
|
if ([aDecoder allowsKeyedCoding])
|
||||||
_offsets = [aDecoder decodeSize];
|
{
|
||||||
[aDecoder decodeValueOfObjCType: @encode(NSBorderType)
|
NSView *contentView = [aDecoder decodeObjectForKey: @"NSContentView"];
|
||||||
at: &_border_type];
|
NSCell *titleCell = [aDecoder decodeObjectForKey: @"NSTitleCell"];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(NSTitlePosition)
|
|
||||||
at: &_title_position];
|
|
||||||
|
|
||||||
// The content view is our only sub_view
|
[self setContentView: contentView];
|
||||||
if ([_sub_views count] == 0)
|
ASSIGN(_cell, titleCell);
|
||||||
{
|
if ([aDecoder containsValueForKey: @"NSBoxType"])
|
||||||
|
{
|
||||||
NSDebugLLog(@"NSBox", @"NSBox: decoding without content view\n");
|
//int boxType = [aDecoder decodeIntForKey: @"NSBoxType"];
|
||||||
// No content view
|
|
||||||
_content_view = nil;
|
|
||||||
[self calcSizesAllowingNegative: NO];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ([_sub_views count] != 1)
|
|
||||||
{
|
|
||||||
NSLog (@"Warning: Encoded NSBox with more than one content view!");
|
|
||||||
}
|
}
|
||||||
_content_view = [_sub_views objectAtIndex: 0];
|
if ([aDecoder containsValueForKey: @"NSBorderType"])
|
||||||
// The following also computes _title_rect and _border_rect.
|
{
|
||||||
[_content_view setFrame: [self calcSizesAllowingNegative: NO]];
|
NSBorderType borderType = [aDecoder decodeIntForKey: @"NSBorderType"];
|
||||||
|
|
||||||
|
[self setBorderType: borderType];
|
||||||
|
}
|
||||||
|
if ([aDecoder containsValueForKey: @"NSTitlePosition"])
|
||||||
|
{
|
||||||
|
NSTitlePosition titlePosition = [aDecoder decodeIntForKey:
|
||||||
|
@"NSTitlePosition"];
|
||||||
|
|
||||||
|
[self setTitlePosition: titlePosition];
|
||||||
|
}
|
||||||
|
if ([aDecoder containsValueForKey: @"NSTransparent"])
|
||||||
|
{
|
||||||
|
//Bool transparent = [aDecoder decodeBoolForKey: @"NSTransparent"];
|
||||||
|
}
|
||||||
|
if ([aDecoder containsValueForKey: @"NSOffsets"])
|
||||||
|
{
|
||||||
|
[self setContentViewMargins: [aDecoder decodeSizeForKey: @"NSOffsets"]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &_cell];
|
||||||
|
_offsets = [aDecoder decodeSize];
|
||||||
|
[aDecoder decodeValueOfObjCType: @encode(NSBorderType)
|
||||||
|
at: &_border_type];
|
||||||
|
[aDecoder decodeValueOfObjCType: @encode(NSTitlePosition)
|
||||||
|
at: &_title_position];
|
||||||
|
|
||||||
|
// The content view is our only sub_view
|
||||||
|
if ([_sub_views count] == 0)
|
||||||
|
{
|
||||||
|
NSDebugLLog(@"NSBox", @"NSBox: decoding without content view\n");
|
||||||
|
// No content view
|
||||||
|
_content_view = nil;
|
||||||
|
[self calcSizesAllowingNegative: NO];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ([_sub_views count] != 1)
|
||||||
|
{
|
||||||
|
NSLog (@"Warning: Encoded NSBox with more than one content view!");
|
||||||
|
}
|
||||||
|
_content_view = [_sub_views objectAtIndex: 0];
|
||||||
|
// The following also computes _title_rect and _border_rect.
|
||||||
|
[_content_view setFrame: [self calcSizesAllowingNegative: NO]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
|
@ -986,11 +986,28 @@ static BOOL flip_hack;
|
||||||
RELEASE(self);
|
RELEASE(self);
|
||||||
if ([aDecoder containsValueForKey: @"NSfFlags"])
|
if ([aDecoder containsValueForKey: @"NSfFlags"])
|
||||||
{
|
{
|
||||||
//int flags = [aDecoder decodeIntForKey: @"NSfFlags"];
|
int flags = [aDecoder decodeIntForKey: @"NSfFlags"];
|
||||||
// FIXME
|
// FIXME
|
||||||
|
if (flags == 16)
|
||||||
|
{
|
||||||
|
return [NSFont controlContentFontOfSize: size];
|
||||||
|
}
|
||||||
|
else if (flags == 20)
|
||||||
|
{
|
||||||
|
return [NSFont labelFontOfSize: size];
|
||||||
|
}
|
||||||
|
else if (flags == 22)
|
||||||
|
{
|
||||||
|
return [NSFont titleBarFontOfSize: size];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self = [NSFont fontWithName: name size: size];
|
self = [NSFont fontWithName: name size: size];
|
||||||
|
if (self == nil)
|
||||||
|
{
|
||||||
|
self = [NSFont systemFontOfSize: size];
|
||||||
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -374,12 +374,34 @@ scaleProportionally(NSSize imageSize, NSRect canvasRect)
|
||||||
|
|
||||||
- (id) initWithCoder: (NSCoder *)aDecoder
|
- (id) initWithCoder: (NSCoder *)aDecoder
|
||||||
{
|
{
|
||||||
[super initWithCoder: aDecoder];
|
self = [super initWithCoder: aDecoder];
|
||||||
|
|
||||||
[aDecoder decodeValueOfObjCType: @encode(NSImageAlignment) at: &_imageAlignment];
|
if ([aDecoder allowsKeyedCoding])
|
||||||
[aDecoder decodeValueOfObjCType: @encode(NSImageFrameStyle) at: &_frameStyle];
|
{
|
||||||
[aDecoder decodeValueOfObjCType: @encode(NSImageScaling) at: &_imageScaling];
|
if ([aDecoder containsValueForKey: @"NSAlign"])
|
||||||
_original_image_size = [aDecoder decodeSize];
|
{
|
||||||
|
[self setImageAlignment: [aDecoder decodeIntForKey: @"NSAlign"]];
|
||||||
|
}
|
||||||
|
if ([aDecoder containsValueForKey: @"NSScale"])
|
||||||
|
{
|
||||||
|
[self setImageScaling: [aDecoder decodeIntForKey: @"NSScale"]];
|
||||||
|
}
|
||||||
|
if ([aDecoder containsValueForKey: @"NSStyle"])
|
||||||
|
{
|
||||||
|
[self setImageFrameStyle: [aDecoder decodeIntForKey: @"NSStyle"]];
|
||||||
|
}
|
||||||
|
if ([aDecoder containsValueForKey: @"NSAnimates"])
|
||||||
|
{
|
||||||
|
//BOOL animates = [aDecoder decodeBoolForKey: @"NSAnimates"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[aDecoder decodeValueOfObjCType: @encode(NSImageAlignment) at: &_imageAlignment];
|
||||||
|
[aDecoder decodeValueOfObjCType: @encode(NSImageFrameStyle) at: &_frameStyle];
|
||||||
|
[aDecoder decodeValueOfObjCType: @encode(NSImageScaling) at: &_imageScaling];
|
||||||
|
_original_image_size = [aDecoder decodeSize];
|
||||||
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -276,10 +276,23 @@ static Class imageCellClass;
|
||||||
- (id) initWithCoder: (NSCoder *)aDecoder
|
- (id) initWithCoder: (NSCoder *)aDecoder
|
||||||
{
|
{
|
||||||
self = [super initWithCoder: aDecoder];
|
self = [super initWithCoder: aDecoder];
|
||||||
if ([aDecoder versionForClassName: @"NSImageView"] >= 2)
|
|
||||||
|
if ([aDecoder allowsKeyedCoding])
|
||||||
{
|
{
|
||||||
_target = [aDecoder decodeObject];
|
//NSArray *dragType = [aDecoder decodeObjectForKey: @"NSDragTypes"];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(SEL) at: &_action];
|
|
||||||
|
if ([aDecoder containsValueForKey: @"NSEditable"])
|
||||||
|
{
|
||||||
|
[self setEditable: [aDecoder decodeBoolForKey: @"NSEditable"]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ([aDecoder versionForClassName: @"NSImageView"] >= 2)
|
||||||
|
{
|
||||||
|
_target = [aDecoder decodeObject];
|
||||||
|
[aDecoder decodeValueOfObjCType: @encode(SEL) at: &_action];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
|
@ -898,33 +898,35 @@ static inline NSPoint centerSizeInRect(NSSize innerSize, NSRect outerRect)
|
||||||
- (id) initWithCoder: (NSCoder *)aDecoder
|
- (id) initWithCoder: (NSCoder *)aDecoder
|
||||||
{
|
{
|
||||||
self = [super initWithCoder: aDecoder];
|
self = [super initWithCoder: aDecoder];
|
||||||
|
|
||||||
|
if ([aDecoder allowsKeyedCoding])
|
||||||
|
{
|
||||||
|
if ([aDecoder containsValueForKey: @"NSIsVertical"])
|
||||||
|
{
|
||||||
|
[self setVertical: [aDecoder decodeBoolForKey: @"NSIsVertical"]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Decode objects that we don't retain.
|
||||||
|
[self setDelegate: [aDecoder decodeObject]];
|
||||||
|
|
||||||
/*
|
// Decode objects that we do retain.
|
||||||
* Decode objects that we don't retain.
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &_dimpleImage];
|
||||||
*/
|
if (_dimpleImage == nil)
|
||||||
[self setDelegate: [aDecoder decodeObject]];
|
ASSIGN(_dimpleImage, [NSImage imageNamed: @"common_Dimple.tiff"]);
|
||||||
|
|
||||||
/*
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &_backgroundColor];
|
||||||
* Decode objects that we do retain.
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &_dividerColor];
|
||||||
*/
|
|
||||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_dimpleImage];
|
|
||||||
if (_dimpleImage == nil)
|
|
||||||
ASSIGN(_dimpleImage, [NSImage imageNamed: @"common_Dimple.tiff"]);
|
|
||||||
|
|
||||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_backgroundColor];
|
// Decode non-object data.
|
||||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_dividerColor];
|
[aDecoder decodeValueOfObjCType: @encode(int) at: &_draggedBarWidth];
|
||||||
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isVertical];
|
||||||
|
|
||||||
/*
|
_dividerWidth = [self dividerThickness];
|
||||||
* Decode non-object data.
|
_never_displayed_before = YES;
|
||||||
*/
|
}
|
||||||
[aDecoder decodeValueOfObjCType: @encode(int) at: &_draggedBarWidth];
|
|
||||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isVertical];
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
_dividerWidth = [self dividerThickness];
|
|
||||||
_never_displayed_before = YES;
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -198,14 +198,23 @@ static NSColor *txtCol;
|
||||||
|
|
||||||
- (id) initWithCoder: (NSCoder*)aDecoder
|
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||||
{
|
{
|
||||||
BOOL tmp;
|
|
||||||
[super initWithCoder: aDecoder];
|
[super initWithCoder: aDecoder];
|
||||||
|
|
||||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_background_color];
|
if ([aDecoder allowsKeyedCoding])
|
||||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_text_color];
|
{
|
||||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &tmp];
|
[self setBackgroundColor: [aDecoder decodeObjectForKey: @"NSBackgroundColor"]];
|
||||||
_textfieldcell_draws_background = tmp;
|
[self setTextColor: [aDecoder decodeObjectForKey: @"NSTextColor"]];
|
||||||
_textfieldcell_is_opaque = [self _isOpaque];
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BOOL tmp;
|
||||||
|
|
||||||
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &_background_color];
|
||||||
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &_text_color];
|
||||||
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &tmp];
|
||||||
|
_textfieldcell_draws_background = tmp;
|
||||||
|
_textfieldcell_is_opaque = [self _isOpaque];
|
||||||
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue