mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 17:40:48 +00:00
* Source/NSButtonCell.m: Improvements in both initWithCoder: and
encodeWithCoder: utilize the setCellAttribute:to: method and the cellAttribute: method to determine settings when saving to a keyed archive. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@23310 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c1e814a745
commit
e97c9a158f
2 changed files with 83 additions and 48 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2006-08-17 00:54-EDT Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
|
* Source/NSButtonCell.m: Improvements in both initWithCoder: and
|
||||||
|
encodeWithCoder: utilize the setCellAttribute:to: method and
|
||||||
|
the cellAttribute: method to determine settings when saving
|
||||||
|
to a keyed archive.
|
||||||
|
|
||||||
2006-08-16 00:53-EDT Gregory John Casamento <greg_casamento@yahoo.com>
|
2006-08-16 00:53-EDT Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
* Source/NSTabView.m: Corrections in initWithCoder: and
|
* Source/NSTabView.m: Corrections in initWithCoder: and
|
||||||
|
|
|
@ -76,13 +76,13 @@ typedef struct _GSButtonCellFlags
|
||||||
unsigned int hasKeyEquiv:1;
|
unsigned int hasKeyEquiv:1;
|
||||||
unsigned int lastState:1;
|
unsigned int lastState:1;
|
||||||
unsigned int isTransparent:1;
|
unsigned int isTransparent:1;
|
||||||
unsigned int unused2:6; // inset:2 doesn't dim:1 gradient:3
|
unsigned int unused1:6; // inset:2 doesn't dim:1 gradient:3
|
||||||
unsigned int useButtonImageSource:1;
|
unsigned int useButtonImageSource:1;
|
||||||
unsigned int unused3:8; // alt mnemonic loc.
|
unsigned int unused2:8; // alt mnemonic loc.
|
||||||
#else
|
#else
|
||||||
unsigned int unused3:8; // alt mnemonic loc.
|
unsigned int unused2:8; // alt mnemonic loc.
|
||||||
unsigned int useButtonImageSource:1;
|
unsigned int useButtonImageSource:1;
|
||||||
unsigned int unused0:6; // inset:2 doesn't dim:1 gradient:3
|
unsigned int unused1:6; // inset:2 doesn't dim:1 gradient:3
|
||||||
unsigned int isTransparent:1;
|
unsigned int isTransparent:1;
|
||||||
unsigned int lastState:1;
|
unsigned int lastState:1;
|
||||||
unsigned int hasKeyEquiv:1;
|
unsigned int hasKeyEquiv:1;
|
||||||
|
@ -1450,21 +1450,47 @@ typedef struct _GSButtonCellFlags
|
||||||
GSButtonCellFlags buttonCellFlags;
|
GSButtonCellFlags buttonCellFlags;
|
||||||
unsigned int bFlags = 0;
|
unsigned int bFlags = 0;
|
||||||
unsigned int bFlags2 = 0;
|
unsigned int bFlags2 = 0;
|
||||||
NSImage *image = nil;
|
NSImage *image = [self image];
|
||||||
NSButtonImageSource *bi = nil;
|
NSButtonImageSource *bi = nil;
|
||||||
|
|
||||||
[aCoder encodeObject: [self keyEquivalent] forKey: @"NSKeyEquivalent"];
|
if([self keyEquivalent] != nil)
|
||||||
[aCoder encodeObject: [self image] forKey: @"NSNormalImage"];
|
{
|
||||||
[aCoder encodeObject: [self alternateTitle] forKey: @"NSAlternateContents"];
|
[aCoder encodeObject: [self keyEquivalent] forKey: @"NSKeyEquivalent"];
|
||||||
|
}
|
||||||
|
if([self image] != nil)
|
||||||
|
{
|
||||||
|
[aCoder encodeObject: [self image] forKey: @"NSNormalImage"];
|
||||||
|
}
|
||||||
|
if([self alternateTitle] != nil)
|
||||||
|
{
|
||||||
|
[aCoder encodeObject: [self alternateTitle] forKey: @"NSAlternateContents"];
|
||||||
|
}
|
||||||
|
|
||||||
// encode button flags...
|
buttonCellFlags.useButtonImageSource = (([NSImage imageNamed: @"NSSwitch"] == image) ||
|
||||||
|
([NSImage imageNamed: @"NSRadioButton"] == image));
|
||||||
buttonCellFlags.isTransparent = [self isTransparent];
|
buttonCellFlags.isTransparent = [self isTransparent];
|
||||||
buttonCellFlags.isBordered = [self isBordered];
|
buttonCellFlags.isBordered = [self isBordered];
|
||||||
buttonCellFlags.highlightByBackground = (_highlightsByMask & NSChangeBackgroundCellMask);
|
buttonCellFlags.isImageAndText = (image != nil);
|
||||||
buttonCellFlags.highlightByContents = (_highlightsByMask & NSContentsCellMask);
|
buttonCellFlags.hasKeyEquiv = ([self keyEquivalent] != nil);
|
||||||
buttonCellFlags.isPushin = (_highlightsByMask & NSPushInCellMask);
|
|
||||||
buttonCellFlags.changeBackground = (_showAltStateMask & NSChangeBackgroundCellMask);
|
// cell attributes...
|
||||||
buttonCellFlags.changeContents = (_showAltStateMask & NSContentsCellMask);
|
buttonCellFlags.isPushin = [self cellAttribute: NSPushInCell];
|
||||||
|
buttonCellFlags.highlightByBackground = [self cellAttribute: NSCellLightsByBackground];
|
||||||
|
buttonCellFlags.highlightByContents = [self cellAttribute: NSCellLightsByContents];
|
||||||
|
buttonCellFlags.highlightByGray = [self cellAttribute: NSCellLightsByGray];
|
||||||
|
buttonCellFlags.changeBackground = [self cellAttribute: NSChangeBackgroundCell];
|
||||||
|
buttonCellFlags.changeContents = [self cellAttribute: NSCellChangesContents];
|
||||||
|
buttonCellFlags.changeGray = [self cellAttribute: NSChangeGrayCell];
|
||||||
|
|
||||||
|
// set these to zero...
|
||||||
|
buttonCellFlags.unused1 = 0; // 32;
|
||||||
|
buttonCellFlags.unused2 = 0; // 255;
|
||||||
|
buttonCellFlags.lastState = 0;
|
||||||
|
buttonCellFlags.isImageSizeDiff = 0;
|
||||||
|
buttonCellFlags.imageDoesOverlap = 0;
|
||||||
|
buttonCellFlags.drawing = 0;
|
||||||
|
buttonCellFlags.isBottomOrLeft = 0;
|
||||||
|
|
||||||
memcpy((void *)&bFlags, (void *)&buttonCellFlags,sizeof(unsigned int));
|
memcpy((void *)&bFlags, (void *)&buttonCellFlags,sizeof(unsigned int));
|
||||||
[aCoder encodeInt: bFlags forKey: @"NSButtonFlags"];
|
[aCoder encodeInt: bFlags forKey: @"NSButtonFlags"];
|
||||||
|
|
||||||
|
@ -1474,19 +1500,30 @@ typedef struct _GSButtonCellFlags
|
||||||
[aCoder encodeInt: bFlags2 forKey: @"NSButtonFlags2"];
|
[aCoder encodeInt: bFlags2 forKey: @"NSButtonFlags2"];
|
||||||
|
|
||||||
// alternate image encoding...
|
// alternate image encoding...
|
||||||
image = [self image];
|
if(image != nil)
|
||||||
if ([image isKindOfClass: [NSImage class]])
|
|
||||||
{
|
{
|
||||||
if([NSImage imageNamed: @"NSSwitch"] == image)
|
if ([image isKindOfClass: [NSImage class]] && buttonCellFlags.useButtonImageSource)
|
||||||
{
|
{
|
||||||
bi = [[NSButtonImageSource alloc] initWithImageNamed: @"NSHighlightedSwitch"];
|
if([NSImage imageNamed: @"NSSwitch"] == image)
|
||||||
}
|
{
|
||||||
else if([NSImage imageNamed: @"NSRadioButton"] == image)
|
bi = [[NSButtonImageSource alloc] initWithImageNamed: @"NSHighlightedSwitch"];
|
||||||
{
|
}
|
||||||
bi = [[NSButtonImageSource alloc] initWithImageNamed: @"NSHighlightedRadioButton"];
|
else if([NSImage imageNamed: @"NSRadioButton"] == image)
|
||||||
|
{
|
||||||
|
bi = [[NSButtonImageSource alloc] initWithImageNamed: @"NSHighlightedRadioButton"];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[aCoder encodeObject: bi forKey: @"NSAlternateImage"];
|
|
||||||
|
// encode button image source, if it exists...
|
||||||
|
if(bi != nil)
|
||||||
|
{
|
||||||
|
[aCoder encodeObject: bi forKey: @"NSAlternateImage"];
|
||||||
|
}
|
||||||
|
else if(_altImage != nil)
|
||||||
|
{
|
||||||
|
[aCoder encodeObject: _altImage forKey: @"NSAlternateImage"];
|
||||||
|
}
|
||||||
|
|
||||||
// repeat and delay
|
// repeat and delay
|
||||||
[aCoder encodeInt: (int)_delayInterval forKey: @"NSPeriodicDelay"];
|
[aCoder encodeInt: (int)_delayInterval forKey: @"NSPeriodicDelay"];
|
||||||
|
@ -1520,7 +1557,7 @@ typedef struct _GSButtonCellFlags
|
||||||
{
|
{
|
||||||
int delay = 0;
|
int delay = 0;
|
||||||
int interval = 0;
|
int interval = 0;
|
||||||
NSControl *control = [aDecoder decodeObjectForKey: @"NSControlView"];
|
// NSControl *control = [aDecoder decodeObjectForKey: @"NSControlView"];
|
||||||
|
|
||||||
if ([aDecoder containsValueForKey: @"NSKeyEquivalent"])
|
if ([aDecoder containsValueForKey: @"NSKeyEquivalent"])
|
||||||
{
|
{
|
||||||
|
@ -1537,36 +1574,27 @@ typedef struct _GSButtonCellFlags
|
||||||
if ([aDecoder containsValueForKey: @"NSButtonFlags"])
|
if ([aDecoder containsValueForKey: @"NSButtonFlags"])
|
||||||
{
|
{
|
||||||
unsigned int bFlags = [aDecoder decodeIntForKey: @"NSButtonFlags"];
|
unsigned int bFlags = [aDecoder decodeIntForKey: @"NSButtonFlags"];
|
||||||
int highlights = 0;
|
|
||||||
int show_state = NSNoCellMask;
|
|
||||||
GSButtonCellFlags buttonCellFlags;
|
GSButtonCellFlags buttonCellFlags;
|
||||||
memcpy((void *)&buttonCellFlags,(void *)&bFlags,sizeof(struct _GSButtonCellFlags));
|
memcpy((void *)&buttonCellFlags,(void *)&bFlags,sizeof(struct _GSButtonCellFlags));
|
||||||
|
|
||||||
[self setTransparent: buttonCellFlags.isTransparent];
|
[self setTransparent: buttonCellFlags.isTransparent];
|
||||||
[self setBordered: buttonCellFlags.isBordered];
|
[self setBordered: buttonCellFlags.isBordered];
|
||||||
|
|
||||||
if (buttonCellFlags.highlightByBackground)
|
[self setCellAttribute: NSPushInCell
|
||||||
{
|
to: buttonCellFlags.isPushin];
|
||||||
highlights |= NSChangeBackgroundCellMask;
|
[self setCellAttribute: NSCellLightsByBackground
|
||||||
}
|
to: buttonCellFlags.highlightByBackground];
|
||||||
if (buttonCellFlags.highlightByContents)
|
[self setCellAttribute: NSCellLightsByContents
|
||||||
{
|
to: buttonCellFlags.highlightByContents];
|
||||||
highlights |= NSContentsCellMask;
|
[self setCellAttribute: NSCellLightsByGray
|
||||||
}
|
to: buttonCellFlags.highlightByGray];
|
||||||
if (buttonCellFlags.changeBackground)
|
[self setCellAttribute: NSChangeBackgroundCell
|
||||||
{
|
to: buttonCellFlags.changeBackground];
|
||||||
show_state |= NSChangeBackgroundCellMask;
|
[self setCellAttribute: NSCellChangesContents
|
||||||
}
|
to: buttonCellFlags.changeContents];
|
||||||
if (buttonCellFlags.changeContents)
|
[self setCellAttribute: NSChangeGrayCell
|
||||||
{
|
to: buttonCellFlags.changeGray];
|
||||||
show_state |= NSContentsCellMask;
|
|
||||||
}
|
|
||||||
if (buttonCellFlags.isPushin)
|
|
||||||
{
|
|
||||||
highlights |= NSPushInCellMask;
|
|
||||||
}
|
|
||||||
[self setHighlightsBy: highlights];
|
|
||||||
[self setShowsStateBy: show_state];
|
|
||||||
[self setImagePosition: NSImageLeft];
|
[self setImagePosition: NSImageLeft];
|
||||||
}
|
}
|
||||||
if ([aDecoder containsValueForKey: @"NSButtonFlags2"])
|
if ([aDecoder containsValueForKey: @"NSButtonFlags2"])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue