Backports from trunk

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/branches/gnustep_stable_20070311@25792 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 2007-12-27 16:28:44 +00:00
parent 3352a25907
commit 65fa5805e2
7 changed files with 891 additions and 786 deletions

View file

@ -1,3 +1,40 @@
2007-11-05 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSFont.m (-initWithName:matrix:fix:screenFont:role:): Add
fallback for missing standard fonts.
* Backport from trunk.
2007-11-03 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSControl.m,
* Source/NSMenuItem.m (-initWithCoder:, -encodeWithCoder:): Better
support for keyed encoding (Tag, separator,...).
* Backport from trunk.
2007-11-01 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSBrowser.m (+initialize): Create titleCell here to have
it available for browsers loaded from Gorm files.
* Source/NSBrowser.m (GSBrowserTitleCell): Add method
drawingRectForBounds: and correct drawWithFrame:inView:.
* Source/NSBrowser.m (-displayAllColumns, -displayColumn:): Mark
for redraw.
* Backport from trunk.
2007-11-01 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSTableView.m (-draggingUpdated:): Use
currentDropOperation instead of NSTableViewDropAbove.
* Source/NSDocument.m (-windowForSheet): Return nil instead of
mainWindow, when there is no associated window.
Patches by Wolfgang Lux <wolfgang.lux@gmail.com>.
* Backport from trunk.
2007-10-30 Adam Fedor <fedor@gnu.org>
* gnustep-gui.spec.in: Change Copyright to License.
* Backport from trunk.
2007-10-29 Fred Kiefer <FredKiefer@gmx.de>
* COPYING: Add GPL file.

File diff suppressed because it is too large Load diff

View file

@ -911,6 +911,10 @@ static NSNotificationCenter *nc;
{
[aCoder encodeObject: [self cell] forKey: @"NSCell"];
[aCoder encodeBool: [self isEnabled] forKey: @"NSEnabled"];
if (_tag)
{
[aCoder encodeInt: [self tag] forKey: @"NSTag"];
}
}
else
{
@ -930,12 +934,17 @@ static NSNotificationCenter *nc;
if (cell != nil)
{
[self setCell: cell];
}
[self setCell: cell];
}
if ([aDecoder containsValueForKey: @"NSEnabled"])
{
[self setEnabled: [aDecoder decodeBoolForKey: @"NSEnabled"]];
}
[self setEnabled: [aDecoder decodeBoolForKey: @"NSEnabled"]];
}
if ([aDecoder containsValueForKey: @"NSTag"])
{
int tag = [aDecoder decodeIntForKey: @"NSTag"];
[self setTag: tag];
}
}
else
{

View file

@ -352,7 +352,7 @@ withContentsOfURL: (NSURL *)url
return win;
}
return [NSApp mainWindow];
return nil;
}
/**

View file

@ -46,13 +46,13 @@
@interface NSFont (Private)
- (id) initWithName: (NSString*)name
matrix: (const float*)fontMatrix
fix: (BOOL)explicitlySet
screenFont: (BOOL)screenFont
role: (int)role;
matrix: (const float*)fontMatrix
fix: (BOOL)explicitlySet
screenFont: (BOOL)screenFont
role: (int)role;
+ (NSFont*) _fontWithName: (NSString*)aFontName
size: (float)fontSize
role: (int)role;
size: (float)fontSize
role: (int)role;
@end
static int currentVersion = 3;
@ -108,7 +108,7 @@ globalFontMap.
static GSFontMapKey *
keyForFont(NSString *name, const float *matrix, BOOL fix,
BOOL screenFont, int role)
BOOL screenFont, int role)
{
GSFontMapKey *d;
d=[GSFontMapKey alloc];
@ -123,7 +123,7 @@ keyForFont(NSString *name, const float *matrix, BOOL fix,
d->matrix[4] = matrix[4] * 1000;
d->matrix[5] = matrix[5] * 1000;
d->hash = [d->name hash] + screenFont + role * 4 + fix * 2
+ d->matrix[0] + d->matrix[1] + d->matrix[2] + d->matrix[3];
+ d->matrix[0] + d->matrix[1] + d->matrix[2] + d->matrix[3];
return d;
}
@ -193,12 +193,12 @@ static NSFont *placeHolder = nil;
static NSArray *_preferredFonts;
/* Class for fonts */
static Class NSFontClass = 0;
static Class NSFontClass = 0;
/* Cache all created fonts for reuse. */
static NSMapTable* globalFontMap = 0;
static NSUserDefaults *defaults = nil;
static NSUserDefaults *defaults = nil;
/*
@ -295,22 +295,22 @@ static NSString *fontNameForRole(int role, int *actual_entry)
{
fontName = [defaults stringForKey: font_roles[i].key];
if (fontName)
{
break;
}
{
break;
}
else if (font_roles[i].fallback)
{
i = font_roles[i].fallback;
}
{
i = font_roles[i].fallback;
}
else if (font_roles[i].defaultFont)
{
fontName = font_roles[i].defaultFont;
break;
}
{
fontName = font_roles[i].defaultFont;
break;
}
else
{
NSCAssert(NO, @"Invalid font role table entry.");
}
{
NSCAssert(NO, @"Invalid font role table entry.");
}
}
if (actual_entry)
*actual_entry = i;
@ -339,13 +339,13 @@ static NSFont *getNSFont(float fontSize, int role)
if (defaultSize)
{
if (font_roles[role].cachedFont)
return AUTORELEASE(RETAIN(font_roles[role].cachedFont));
return AUTORELEASE(RETAIN(font_roles[role].cachedFont));
fontSize = [defaults floatForKey:
[NSString stringWithFormat: @"%@Size", font_roles[role].key]];
[NSString stringWithFormat: @"%@Size", font_roles[role].key]];
if (!fontSize)
fontSize = [NSFont systemFontSize];
fontSize = [NSFont systemFontSize];
}
else
{
@ -354,51 +354,51 @@ static NSFont *getNSFont(float fontSize, int role)
fontName = fontNameForRole(role, &i);
font = [NSFontClass _fontWithName: fontName
size: fontSize
role: font_role];
size: fontSize
role: font_role];
/* That font couldn't be found. */
if (font == nil)
{
/* Warn using the role that specified the invalid font. */
NSLog(@"The font specified for %@, %@, can't be found.",
font_roles[i].key, fontName);
font_roles[i].key, fontName);
/* Try the system font. */
fontName = fontNameForRole(RoleSystemFont, NULL);
font = [NSFontClass _fontWithName: fontName
size: fontSize
role: font_role];
size: fontSize
role: font_role];
if (font == nil)
{
/* Try the default system font and size. */
fontName = font_roles[RoleSystemFont].defaultFont;
font = [NSFontClass _fontWithName: fontName
size: 12.0
role: font_role];
{
/* Try the default system font and size. */
fontName = font_roles[RoleSystemFont].defaultFont;
font = [NSFontClass _fontWithName: fontName
size: 12.0
role: font_role];
/* It seems we can't get any font here! Try some well known
* fonts as a last resort. */
if (font == nil)
{
font = [NSFontClass _fontWithName: @"Helvetica"
size: 12.0
role: font_role];
}
if (font == nil)
{
font = [NSFontClass _fontWithName: @"Courier"
size: 12.0
role: font_role];
}
if (font == nil)
{
font = [NSFontClass _fontWithName: @"Fixed"
size: 12.0
role: font_role];
}
}
/* It seems we can't get any font here! Try some well known
* fonts as a last resort. */
if (font == nil)
{
font = [NSFontClass _fontWithName: @"Helvetica"
size: 12.0
role: font_role];
}
if (font == nil)
{
font = [NSFontClass _fontWithName: @"Courier"
size: 12.0
role: font_role];
}
if (font == nil)
{
font = [NSFontClass _fontWithName: @"Fixed"
size: 12.0
role: font_role];
}
}
}
if (defaultSize)
@ -413,7 +413,7 @@ static void setNSFont(NSString *key, NSFont *font)
[defaults setObject: [font fontName] forKey: key];
[defaults setObject: [NSNumber numberWithFloat: [font pointSize]]
forKey: [NSString stringWithFormat: @"%@Size",key]];
forKey: [NSString stringWithFormat: @"%@Size",key]];
for (i = 1; i < RoleMax; i++)
{
@ -612,20 +612,20 @@ static void setNSFont(NSString *key, NSFont *font)
{
case NSMiniControlSize:
{
float fontSize = [defaults floatForKey: @"NSMiniFontSize"];
float fontSize = [defaults floatForKey: @"NSMiniFontSize"];
if (fontSize == 0)
{
fontSize = 6;
}
if (fontSize == 0)
{
fontSize = 6;
}
return fontSize;
}
return fontSize;
}
case NSSmallControlSize:
return [self smallSystemFontSize];
return [self smallSystemFontSize];
case NSRegularControlSize:
default:
return [self systemFontSize];
return [self systemFontSize];
}
}
@ -638,10 +638,10 @@ static void setNSFont(NSString *key, NSFont *font)
</p>
*/
+ (NSFont*) fontWithName: (NSString*)aFontName
matrix: (const float*)fontMatrix
matrix: (const float*)fontMatrix
{
NSFont *font;
BOOL fix;
NSFont *font;
BOOL fix;
if (fontMatrix == NSFontIdentityMatrix)
fix = NO;
@ -649,10 +649,10 @@ static void setNSFont(NSString *key, NSFont *font)
fix = YES;
font = [placeHolder initWithName: aFontName
matrix: fontMatrix
fix: fix
screenFont: NO
role: RoleExplicit];
matrix: fontMatrix
fix: fix
screenFont: NO
role: RoleExplicit];
return AUTORELEASE(font);
}
@ -662,36 +662,36 @@ static void setNSFont(NSString *key, NSFont *font)
* when set in a flipped view.</p>
*/
+ (NSFont*) fontWithName: (NSString*)aFontName
size: (float)fontSize
size: (float)fontSize
{
return [self _fontWithName: aFontName
size: fontSize
role: RoleExplicit];
size: fontSize
role: RoleExplicit];
}
+ (NSFont*) _fontWithName: (NSString*)aFontName
size: (float)fontSize
role: (int)aRole
size: (float)fontSize
role: (int)aRole
{
NSFont *font;
float fontMatrix[6] = { 0, 0, 0, 0, 0, 0 };
NSFont *font;
float fontMatrix[6] = { 0, 0, 0, 0, 0, 0 };
if (fontSize == 0)
{
fontSize = [defaults floatForKey: @"NSUserFontSize"];
if (fontSize == 0)
{
fontSize = 12;
}
{
fontSize = 12;
}
}
fontMatrix[0] = fontSize;
fontMatrix[3] = fontSize;
font = [placeHolder initWithName: aFontName
matrix: fontMatrix
fix: NO
screenFont: NO
role: aRole];
matrix: fontMatrix
fix: NO
screenFont: NO
role: aRole];
return AUTORELEASE(font);
}
@ -708,7 +708,7 @@ static void setNSFont(NSString *key, NSFont *font)
- (id) init
{
[NSException raise: NSInternalInconsistencyException
format: @"Called -init on NSFont ... illegal"];
format: @"Called -init on NSFont ... illegal"];
return self;
}
@ -721,50 +721,79 @@ static void setNSFont(NSString *key, NSFont *font)
* This method may destroy the receiver and return a cached instance.
*/
- (id) initWithName: (NSString*)name
matrix: (const float*)fontMatrix
fix: (BOOL)explicitlySet
screenFont: (BOOL)screen
role: (int)aRole
matrix: (const float*)fontMatrix
fix: (BOOL)explicitlySet
screenFont: (BOOL)screen
role: (int)aRole
{
GSFontMapKey *key;
NSFont *font;
GSFontMapKey *key;
NSFont *font;
/* Should never be called on an initialised font! */
NSAssert(fontName == nil, NSInternalInconsistencyException);
/* Check whether the font is cached */
key = keyForFont(name, fontMatrix, explicitlySet,
screen, aRole);
screen, aRole);
font = (id)NSMapGet(globalFontMap, (void *)key);
if (font == nil)
{
if (self == placeHolder)
{
/*
* If we are initialising the placeHolder, we actually want to
* leave it be (for later re-use) and initialise a newly created
* instance instead.
*/
self = [NSFontClass alloc];
}
{
/*
* If we are initialising the placeHolder, we actually want to
* leave it be (for later re-use) and initialise a newly created
* instance instead.
*/
self = [NSFontClass alloc];
}
fontName = [name copy];
memcpy(matrix, fontMatrix, sizeof(matrix));
matrixExplicitlySet = explicitlySet;
screenFont = screen;
role = aRole;
fontInfo = RETAIN([GSFontInfo fontInfoForFontName: fontName
matrix: fontMatrix
screenFont: screen]);
cachedFlippedFont = placeHolder;
if (!screenFont)
cachedScreenFont = placeHolder;
matrix: fontMatrix
screenFont: screen]);
if ((fontInfo == nil) && (aRole == RoleExplicit))
{
/*
Last fallback: If a system font was explicitly requested
and this font does not exist, try to replace it with the
corresponding font in the current setup.
*/
if ([fontName isEqualToString: @"Helvetica"] &&
![font_roles[RoleSystemFont].defaultFont isEqualToString: @"Helvetica"])
{
fontInfo = RETAIN([GSFontInfo fontInfoForFontName:
font_roles[RoleSystemFont].defaultFont
matrix: fontMatrix
screenFont: screen]);
}
else if ([fontName isEqualToString: @"Helvetica-Bold"] &&
![font_roles[RoleBoldSystemFont].defaultFont isEqualToString: @"Helvetica-Bold"])
{
fontInfo = RETAIN([GSFontInfo fontInfoForFontName:
font_roles[RoleBoldSystemFont].defaultFont
matrix: fontMatrix
screenFont: screen]);
}
else if ([fontName isEqualToString: @"Courier"] &&
![font_roles[RoleUserFixedPitchFont].defaultFont isEqualToString: @"Courier"])
{
fontInfo = RETAIN([GSFontInfo fontInfoForFontName:
font_roles[RoleUserFixedPitchFont].defaultFont
matrix: fontMatrix
screenFont: screen]);
}
}
if (fontInfo == nil)
{
DESTROY(fontName);
DESTROY(key);
RELEASE(self);
return nil;
}
{
DESTROY(fontName);
DESTROY(key);
RELEASE(self);
return nil;
}
/* Cache the font for later use */
NSMapInsert(globalFontMap, (void *)key, (void *)self);
@ -772,9 +801,9 @@ static void setNSFont(NSString *key, NSFont *font)
else
{
if (self != placeHolder)
{
RELEASE(self);
}
{
RELEASE(self);
}
self = RETAIN(font);
}
RELEASE(key);
@ -789,24 +818,22 @@ static void setNSFont(NSString *key, NSFont *font)
GSFontMapKey *key;
key = keyForFont(fontName, matrix,
matrixExplicitlySet, screenFont,
role);
matrixExplicitlySet, screenFont,
role);
NSMapRemove(globalFontMap, (void *)key);
RELEASE(key);
RELEASE(fontName);
}
TEST_RELEASE(fontInfo);
if (cachedFlippedFont != placeHolder)
DESTROY(cachedFlippedFont);
if (cachedScreenFont != placeHolder)
DESTROY(cachedScreenFont);
DESTROY(cachedFlippedFont);
DESTROY(cachedScreenFont);
[super dealloc];
}
- (NSString *) description
{
NSString *nameWithMatrix;
NSString *description;
NSString *nameWithMatrix;
NSString *description;
nameWithMatrix = [[NSString alloc] initWithFormat:
@"%@ %.3f %.3f %.3f %.3f %.3f %.3f %c %c %i", fontName,
@ -858,7 +885,7 @@ static void setNSFont(NSString *key, NSFont *font)
- (NSFont *)_flippedViewFont
{
if (cachedFlippedFont == placeHolder)
if (cachedFlippedFont == nil)
{
float fontMatrix[6];
memcpy(fontMatrix, matrix, sizeof(matrix));
@ -963,10 +990,10 @@ static BOOL flip_hack;
if (!screenFont)
return self;
return AUTORELEASE([placeHolder initWithName: fontName
matrix: matrix
fix: matrixExplicitlySet
screenFont: NO
role: role]);
matrix: matrix
fix: matrixExplicitlySet
screenFont: NO
role: role]);
}
- (NSFont*) screenFont
@ -978,24 +1005,24 @@ static BOOL flip_hack;
Note that if the font has no corresponding screen font, cachedScreenFont
will be set to nil.
*/
if (cachedScreenFont == placeHolder)
if (cachedScreenFont == nil)
cachedScreenFont = [placeHolder initWithName: fontName
matrix: matrix
fix: matrixExplicitlySet
screenFont: YES
role: role];
matrix: matrix
fix: matrixExplicitlySet
screenFont: YES
role: role];
return AUTORELEASE(RETAIN(cachedScreenFont));
}
- (float) ascender { return [fontInfo ascender]; }
- (float) descender { return [fontInfo descender]; }
- (float) capHeight { return [fontInfo capHeight]; }
- (float) italicAngle { return [fontInfo italicAngle]; }
- (NSSize) maximumAdvancement { return [fontInfo maximumAdvancement]; }
- (NSSize) minimumAdvancement { return [fontInfo minimumAdvancement]; }
- (float) underlinePosition { return [fontInfo underlinePosition]; }
- (float) underlineThickness { return [fontInfo underlineThickness]; }
- (float) xHeight { return [fontInfo xHeight]; }
- (float) ascender { return [fontInfo ascender]; }
- (float) descender { return [fontInfo descender]; }
- (float) capHeight { return [fontInfo capHeight]; }
- (float) italicAngle { return [fontInfo italicAngle]; }
- (NSSize) maximumAdvancement { return [fontInfo maximumAdvancement]; }
- (NSSize) minimumAdvancement { return [fontInfo minimumAdvancement]; }
- (float) underlinePosition { return [fontInfo underlinePosition]; }
- (float) underlineThickness { return [fontInfo underlineThickness]; }
- (float) xHeight { return [fontInfo xHeight]; }
- (float) defaultLineHeightForFont { return [fontInfo defaultLineHeightForFont]; }
/* Computing font metrics attributes*/
@ -1051,56 +1078,56 @@ static BOOL flip_hack;
}
- (NSPoint) positionOfGlyph: (NSGlyph)curGlyph
precededByGlyph: (NSGlyph)prevGlyph
isNominal: (BOOL*)nominal
precededByGlyph: (NSGlyph)prevGlyph
isNominal: (BOOL*)nominal
{
return [fontInfo positionOfGlyph: curGlyph precededByGlyph: prevGlyph
isNominal: nominal];
}
- (NSPoint) positionOfGlyph: (NSGlyph)aGlyph
forCharacter: (unichar)aChar
struckOverRect: (NSRect)aRect
forCharacter: (unichar)aChar
struckOverRect: (NSRect)aRect
{
return [fontInfo positionOfGlyph: aGlyph
forCharacter: aChar
struckOverRect: aRect];
forCharacter: aChar
struckOverRect: aRect];
}
- (NSPoint) positionOfGlyph: (NSGlyph)aGlyph
struckOverGlyph: (NSGlyph)baseGlyph
metricsExist: (BOOL *)flag
struckOverGlyph: (NSGlyph)baseGlyph
metricsExist: (BOOL *)flag
{
return [fontInfo positionOfGlyph: aGlyph
struckOverGlyph: baseGlyph
metricsExist: flag];
struckOverGlyph: baseGlyph
metricsExist: flag];
}
- (NSPoint) positionOfGlyph: (NSGlyph)aGlyph
struckOverRect: (NSRect)aRect
metricsExist: (BOOL *)flag
struckOverRect: (NSRect)aRect
metricsExist: (BOOL *)flag
{
return [fontInfo positionOfGlyph: aGlyph
struckOverRect: aRect
metricsExist: flag];
struckOverRect: aRect
metricsExist: flag];
}
- (NSPoint) positionOfGlyph: (NSGlyph)aGlyph
withRelation: (NSGlyphRelation)relation
toBaseGlyph: (NSGlyph)baseGlyph
totalAdvancement: (NSSize *)offset
metricsExist: (BOOL *)flag
withRelation: (NSGlyphRelation)relation
toBaseGlyph: (NSGlyph)baseGlyph
totalAdvancement: (NSSize *)offset
metricsExist: (BOOL *)flag
{
return [fontInfo positionOfGlyph: aGlyph
withRelation: relation
toBaseGlyph: baseGlyph
totalAdvancement: offset
metricsExist: flag];
withRelation: relation
toBaseGlyph: baseGlyph
totalAdvancement: offset
metricsExist: flag];
}
- (int) positionsForCompositeSequence: (NSGlyph *)glyphs
numberOfGlyphs: (int)numGlyphs
pointArray: (NSPoint *)points
numberOfGlyphs: (int)numGlyphs
pointArray: (NSPoint *)points
{
int i;
NSGlyph base = glyphs[0];
@ -1113,10 +1140,10 @@ static BOOL flip_hack;
// This only places the glyphs relative to the base glyph
// not to each other
points[i] = [self positionOfGlyph: glyphs[i]
struckOverGlyph: base
metricsExist: &flag];
struckOverGlyph: base
metricsExist: &flag];
if (!flag)
return i - 1;
return i - 1;
}
return i;
@ -1144,19 +1171,19 @@ static BOOL flip_hack;
switch (role >> 1)
{
// FIXME: Many cases still missing
case RoleControlContentFont:
[aCoder encodeInt: 16 forKey: @"NSfFlags"];
break;
case RoleLabelFont:
[aCoder encodeInt: 20 forKey: @"NSfFlags"];
break;
case RoleTitleBarFont:
[aCoder encodeInt: 22 forKey: @"NSfFlags"];
break;
default:
break;
}
// FIXME: Many cases still missing
case RoleControlContentFont:
[aCoder encodeInt: 16 forKey: @"NSfFlags"];
break;
case RoleLabelFont:
[aCoder encodeInt: 20 forKey: @"NSfFlags"];
break;
case RoleTitleBarFont:
[aCoder encodeInt: 22 forKey: @"NSfFlags"];
break;
default:
break;
}
}
else
{
@ -1164,14 +1191,14 @@ static BOOL flip_hack;
if (role == 0)
{
[aCoder encodeObject: fontName];
[aCoder encodeArrayOfObjCType: @encode(float) count: 6 at: matrix];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &matrixExplicitlySet];
}
[aCoder encodeObject: fontName];
[aCoder encodeArrayOfObjCType: @encode(float) count: 6 at: matrix];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &matrixExplicitlySet];
}
else if (role & 1)
{
[aCoder encodeValueOfObjCType: @encode(float) at: &matrix[0]];
}
[aCoder encodeValueOfObjCType: @encode(float) at: &matrix[0]];
}
}
}
@ -1185,151 +1212,151 @@ static BOOL flip_hack;
RELEASE(self);
if ([aDecoder containsValueForKey: @"NSfFlags"])
{
int flags = [aDecoder decodeIntForKey: @"NSfFlags"];
// FIXME
if (flags == 16)
{
return RETAIN([NSFont controlContentFontOfSize: size]);
}
else if (flags == 20)
{
return RETAIN([NSFont labelFontOfSize: size]);
}
else if (flags == 22)
{
return RETAIN([NSFont titleBarFontOfSize: size]);
}
}
int flags = [aDecoder decodeIntForKey: @"NSfFlags"];
// FIXME
if (flags == 16)
{
return RETAIN([NSFont controlContentFontOfSize: size]);
}
else if (flags == 20)
{
return RETAIN([NSFont labelFontOfSize: size]);
}
else if (flags == 22)
{
return RETAIN([NSFont titleBarFontOfSize: size]);
}
}
self = [NSFont fontWithName: name size: size];
if (self == nil)
{
self = RETAIN([NSFont systemFontOfSize: size]);
}
self = RETAIN([NSFont systemFontOfSize: size]);
}
return self;
}
else
{
int version = [aDecoder versionForClassName: @"NSFont"];
id name;
float fontMatrix[6];
BOOL fix;
id name;
float fontMatrix[6];
BOOL fix;
int the_role;
if (version == 3)
{
[aDecoder decodeValueOfObjCType: @encode(int)
at: &the_role];
}
[aDecoder decodeValueOfObjCType: @encode(int)
at: &the_role];
}
else
{
the_role = RoleExplicit;
}
the_role = RoleExplicit;
}
if (the_role == RoleExplicit)
{
/* The easy case: an explicit font, or a font encoded with
version <= 2. */
name = [aDecoder decodeObject];
[aDecoder decodeArrayOfObjCType: @encode(float)
count: 6
at: fontMatrix];
/* The easy case: an explicit font, or a font encoded with
version <= 2. */
name = [aDecoder decodeObject];
[aDecoder decodeArrayOfObjCType: @encode(float)
count: 6
at: fontMatrix];
if (version >= 2)
{
[aDecoder decodeValueOfObjCType: @encode(BOOL)
at: &fix];
}
else
{
if (fontMatrix[0] == fontMatrix[3]
&& fontMatrix[1] == 0.0 && fontMatrix[2] == 0.0)
fix = NO;
else
fix = YES;
}
if (version >= 2)
{
[aDecoder decodeValueOfObjCType: @encode(BOOL)
at: &fix];
}
else
{
if (fontMatrix[0] == fontMatrix[3]
&& fontMatrix[1] == 0.0 && fontMatrix[2] == 0.0)
fix = NO;
else
fix = YES;
}
self = [self initWithName: name
matrix: fontMatrix
fix: fix
screenFont: NO
role: RoleExplicit];
if (self)
return self;
self = [self initWithName: name
matrix: fontMatrix
fix: fix
screenFont: NO
role: RoleExplicit];
if (self)
return self;
self = [NSFont userFontOfSize: fontMatrix[0]];
NSAssert(self != nil, @"Couldn't find a valid font when decoding.");
return RETAIN(self);
}
self = [NSFont userFontOfSize: fontMatrix[0]];
NSAssert(self != nil, @"Couldn't find a valid font when decoding.");
return RETAIN(self);
}
else
{
/* A non-explicit font. */
float size;
NSFont *new;
/* A non-explicit font. */
float size;
NSFont *new;
if (the_role & 1)
{
[aDecoder decodeValueOfObjCType: @encode(float)
at: &size];
}
else
{
size = 0.0;
}
if (the_role & 1)
{
[aDecoder decodeValueOfObjCType: @encode(float)
at: &size];
}
else
{
size = 0.0;
}
switch (the_role >> 1)
{
case RoleBoldSystemFont:
new = [NSFont boldSystemFontOfSize: size];
break;
case RoleSystemFont:
new = [NSFont systemFontOfSize: size];
break;
case RoleUserFixedPitchFont:
new = [NSFont userFixedPitchFontOfSize: size];
break;
case RoleTitleBarFont:
new = [NSFont titleBarFontOfSize: size];
break;
case RoleMenuFont:
new = [NSFont menuFontOfSize: size];
break;
case RoleMessageFont:
new = [NSFont messageFontOfSize: size];
break;
case RolePaletteFont:
new = [NSFont paletteFontOfSize: size];
break;
case RoleToolTipsFont:
new = [NSFont toolTipsFontOfSize: size];
break;
case RoleControlContentFont:
new = [NSFont controlContentFontOfSize: size];
break;
case RoleLabelFont:
new = [NSFont labelFontOfSize: size];
break;
case RoleMenuBarFont:
new = [NSFont menuBarFontOfSize: size];
break;
switch (the_role >> 1)
{
case RoleBoldSystemFont:
new = [NSFont boldSystemFontOfSize: size];
break;
case RoleSystemFont:
new = [NSFont systemFontOfSize: size];
break;
case RoleUserFixedPitchFont:
new = [NSFont userFixedPitchFontOfSize: size];
break;
case RoleTitleBarFont:
new = [NSFont titleBarFontOfSize: size];
break;
case RoleMenuFont:
new = [NSFont menuFontOfSize: size];
break;
case RoleMessageFont:
new = [NSFont messageFontOfSize: size];
break;
case RolePaletteFont:
new = [NSFont paletteFontOfSize: size];
break;
case RoleToolTipsFont:
new = [NSFont toolTipsFontOfSize: size];
break;
case RoleControlContentFont:
new = [NSFont controlContentFontOfSize: size];
break;
case RoleLabelFont:
new = [NSFont labelFontOfSize: size];
break;
case RoleMenuBarFont:
new = [NSFont menuBarFontOfSize: size];
break;
default:
NSDebugLLog(@"NSFont", @"unknown role %i", the_role);
/* fall through */
case RoleUserFont:
new = [NSFont userFontOfSize: size];
break;
}
default:
NSDebugLLog(@"NSFont", @"unknown role %i", the_role);
/* fall through */
case RoleUserFont:
new = [NSFont userFontOfSize: size];
break;
}
RELEASE(self);
if (new)
return RETAIN(new);
RELEASE(self);
if (new)
return RETAIN(new);
new = [NSFont userFontOfSize: size];
NSAssert(new != nil, @"Couldn't find a valid font when decoding.");
return RETAIN(new);
}
new = [NSFont userFontOfSize: size];
NSAssert(new != nil, @"Couldn't find a valid font when decoding.");
return RETAIN(new);
}
}
}
@ -1356,9 +1383,9 @@ static BOOL flip_hack;
int NSConvertGlyphsToPackedGlyphs(NSGlyph *glBuf,
int count,
NSMultibyteGlyphPacking packing,
char *packedGlyphs)
int count,
NSMultibyteGlyphPacking packing,
char *packedGlyphs)
{
int i;
int j;
@ -1370,25 +1397,25 @@ int NSConvertGlyphsToPackedGlyphs(NSGlyph *glBuf,
switch (packing)
{
case NSOneByteGlyphPacking:
packedGlyphs[j++] = (char)(g & 0xFF);
break;
case NSTwoByteGlyphPacking:
packedGlyphs[j++] = (char)((g & 0xFF00) >> 8) ;
packedGlyphs[j++] = (char)(g & 0xFF);
break;
case NSFourByteGlyphPacking:
packedGlyphs[j++] = (char)((g & 0xFF000000) >> 24) ;
packedGlyphs[j++] = (char)((g & 0xFF0000) >> 16);
packedGlyphs[j++] = (char)((g & 0xFF00) >> 8) ;
packedGlyphs[j++] = (char)(g & 0xFF);
break;
case NSJapaneseEUCGlyphPacking:
case NSAsciiWithDoubleByteEUCGlyphPacking:
default:
// FIXME
break;
}
case NSOneByteGlyphPacking:
packedGlyphs[j++] = (char)(g & 0xFF);
break;
case NSTwoByteGlyphPacking:
packedGlyphs[j++] = (char)((g & 0xFF00) >> 8) ;
packedGlyphs[j++] = (char)(g & 0xFF);
break;
case NSFourByteGlyphPacking:
packedGlyphs[j++] = (char)((g & 0xFF000000) >> 24) ;
packedGlyphs[j++] = (char)((g & 0xFF0000) >> 16);
packedGlyphs[j++] = (char)((g & 0xFF00) >> 8) ;
packedGlyphs[j++] = (char)(g & 0xFF);
break;
case NSJapaneseEUCGlyphPacking:
case NSAsciiWithDoubleByteEUCGlyphPacking:
default:
// FIXME
break;
}
}
return j;

View file

@ -483,6 +483,10 @@ static Class imageClass;
{
if ([aCoder allowsKeyedCoding])
{
if ([self isSeparatorItem])
{
[aCoder encodeBool: YES forKey: @"NSIsSeparator"];
}
[aCoder encodeObject: _title forKey: @"NSTitle"];
[aCoder encodeObject: NSStringFromSelector(_action) forKey: @"NSAction"];
[aCoder encodeObject: _keyEquivalent forKey: @"NSKeyEquiv"];
@ -495,6 +499,11 @@ static Class imageClass;
[aCoder encodeInt: _keyEquivalentModifierMask forKey: @"NSKeyEquivModMask"];
[aCoder encodeInt: _mnemonicLocation forKey: @"NSMnemonicLoc"];
[aCoder encodeInt: _state forKey: @"NSState"];
[aCoder encodeBool: ![self isEnabled] forKey: @"NSIsDisabled"];
if (_tag)
{
[aCoder encodeInt: _tag forKey: @"NSTag"];
}
}
else
{
@ -529,28 +538,48 @@ static Class imageClass;
NSString *title;
NSString *action;
NSString *key;
NSImage *mixedImage;
NSImage *onImage;
id target;
NSMenu *submenu;
BOOL isSeparator = NO;
if ([aDecoder containsValueForKey: @"NSIsSeparator"])
{
isSeparator = [aDecoder decodeBoolForKey: @"NSIsSeparator"];
}
if (isSeparator)
{
RELEASE(self);
return [NSMenuItem separatorItem];
}
title = [aDecoder decodeObjectForKey: @"NSTitle"];
action = [aDecoder decodeObjectForKey: @"NSAction"];
key = [aDecoder decodeObjectForKey: @"NSKeyEquiv"];
mixedImage = [aDecoder decodeObjectForKey: @"NSMixedImage"];
onImage = [aDecoder decodeObjectForKey: @"NSOnImage"];
target = [aDecoder decodeObjectForKey: @"NSTarget"];
[aDecoder decodeObjectForKey: @"NSMenu"];
submenu = [aDecoder decodeObjectForKey: @"NSSubmenu"];
self = [self initWithTitle: title
action: NSSelectorFromString(action)
keyEquivalent: key];
[self setTarget: target];
[self setMixedStateImage: mixedImage];
[self setOnStateImage: onImage];
[self setSubmenu: submenu];
action: NSSelectorFromString(action)
keyEquivalent: key];
//[aDecoder decodeObjectForKey: @"NSMenu"];
if ([aDecoder containsValueForKey: @"NSTarget"])
{
id target = [aDecoder decodeObjectForKey: @"NSTarget"];
[self setTarget: target];
}
if ([aDecoder containsValueForKey: @"NSMixedImage"])
{
NSImage *mixedImage = [aDecoder decodeObjectForKey: @"NSMixedImage"];
[self setMixedStateImage: mixedImage];
}
if ([aDecoder containsValueForKey: @"NSOnImage"])
{
NSImage *onImage = [aDecoder decodeObjectForKey: @"NSOnImage"];
[self setOnStateImage: onImage];
}
if ([aDecoder containsValueForKey: @"NSSubmenu"])
{
NSMenu *submenu = [aDecoder decodeObjectForKey: @"NSSubmenu"];
[self setSubmenu: submenu];
}
if ([aDecoder containsValueForKey: @"NSKeyEquivModMask"])
{
int keyMask = [aDecoder decodeIntForKey: @"NSKeyEquivModMask"];
@ -566,6 +595,16 @@ static Class imageClass;
int state = [aDecoder decodeIntForKey: @"NSState"];
[self setState: state];
}
if ([aDecoder containsValueForKey: @"NSIsDisabled"])
{
BOOL flag = [aDecoder decodeBoolForKey: @"NSIsDisabled"];
[self setEnabled: !flag];
}
if ([aDecoder containsValueForKey: @"NSTag"])
{
int tag = [aDecoder decodeIntForKey: @"NSTag"];
[self setTag: tag];
}
}
else
{

View file

@ -6192,13 +6192,13 @@ static BOOL selectContiguousRegion(NSTableView *self,
{
currentRow = [self rowAtPoint: p] - 1;
if (currentRow > 0)
[self scrollRowToVisible: currentRow];
[self scrollRowToVisible: currentRow];
}
else if (p.y > NSMaxY([self visibleRect])-3)
{
currentRow = [self rowAtPoint: p] + 1;
if (currentRow < _numberOfRows)
[self scrollRowToVisible: currentRow];
[self scrollRowToVisible: currentRow];
}
positionInRow = (int)(p.y - _bounds.origin.y) % (int)_rowHeight;
@ -6232,13 +6232,13 @@ static BOOL selectContiguousRegion(NSTableView *self,
{
currentDragOperation = dragOperation;
if ([_dataSource respondsToSelector:
@selector(tableView:validateDrop:proposedRow:proposedDropOperation:)])
{
currentDragOperation = [_dataSource tableView: self
validateDrop: sender
proposedRow: currentDropRow
proposedDropOperation: NSTableViewDropAbove];
}
@selector(tableView:validateDrop:proposedRow:proposedDropOperation:)])
{
currentDragOperation = [_dataSource tableView: self
validateDrop: sender
proposedRow: currentDropRow
proposedDropOperation: currentDropOperation];
}
lastQuarterPosition = quarterPosition;