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> 2007-10-29 Fred Kiefer <FredKiefer@gmx.de>
* COPYING: Add GPL file. * 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 encodeObject: [self cell] forKey: @"NSCell"];
[aCoder encodeBool: [self isEnabled] forKey: @"NSEnabled"]; [aCoder encodeBool: [self isEnabled] forKey: @"NSEnabled"];
if (_tag)
{
[aCoder encodeInt: [self tag] forKey: @"NSTag"];
}
} }
else else
{ {
@ -930,12 +934,17 @@ static NSNotificationCenter *nc;
if (cell != nil) if (cell != nil)
{ {
[self setCell: cell]; [self setCell: cell];
} }
if ([aDecoder containsValueForKey: @"NSEnabled"]) 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 else
{ {

View file

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

View file

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

View file

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

View file

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