Minor tidyups ... nothing functional

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@14587 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2002-09-27 08:26:13 +00:00
parent 3677175985
commit ab43ceed49
2 changed files with 64 additions and 25 deletions

View file

@ -174,7 +174,11 @@ setNSFont(NSString* key, NSFont* font)
/* Getting the preferred user fonts. */ /* Getting the preferred user fonts. */
// This is deprecated in MacOSX /**
* Return the default bold font for use in menus and heading in standard
* gui components.<br />
* This is deprecated in MacOSX
*/
+ (NSFont*) boldSystemFontOfSize: (float)fontSize + (NSFont*) boldSystemFontOfSize: (float)fontSize
{ {
static NSFont *font = nil; static NSFont *font = nil;
@ -194,7 +198,11 @@ setNSFont(NSString* key, NSFont* font)
} }
} }
// This is deprecated in MacOSX /**
* Return the default font for use in menus and heading in standard
* gui components.<br />
* This is deprecated in MacOSX
*/
+ (NSFont*) systemFontOfSize: (float)fontSize + (NSFont*) systemFontOfSize: (float)fontSize
{ {
static NSFont *font = nil; static NSFont *font = nil;
@ -214,6 +222,10 @@ setNSFont(NSString* key, NSFont* font)
} }
} }
/**
* Return the default fixed pitch font for use in locations other
* than standard gui components.
*/
+ (NSFont*) userFixedPitchFontOfSize: (float)fontSize + (NSFont*) userFixedPitchFontOfSize: (float)fontSize
{ {
static NSFont *font = nil; static NSFont *font = nil;
@ -233,6 +245,10 @@ setNSFont(NSString* key, NSFont* font)
} }
} }
/**
* Return the default font for use in locations other
* than standard gui components.
*/
+ (NSFont*) userFontOfSize: (float)fontSize + (NSFont*) userFontOfSize: (float)fontSize
{ {
static NSFont *font = nil; static NSFont *font = nil;
@ -252,7 +268,10 @@ setNSFont(NSString* key, NSFont* font)
} }
} }
+ (NSArray *)preferredFontNames /**
* Return an array of the names of preferred fonts.
*/
+ (NSArray*) preferredFontNames
{ {
return _preferredFonts; return _preferredFonts;
} }
@ -269,7 +288,7 @@ setNSFont(NSString* key, NSFont* font)
setNSFont (@"NSUserFont", aFont); setNSFont (@"NSUserFont", aFont);
} }
+ (void)setPreferredFontNames:(NSArray *)fontNames + (void) setPreferredFontNames: (NSArray*)fontNames
{ {
ASSIGN(_preferredFonts, fontNames); ASSIGN(_preferredFonts, fontNames);
} }
@ -582,7 +601,9 @@ setNSFont(NSString* key, NSFont* font)
{ {
NSFont*new_font; NSFont*new_font;
if (NSShouldRetainWithZone(self, zone)) if (NSShouldRetainWithZone(self, zone))
new_font = RETAIN(self); {
new_font = RETAIN(self);
}
else else
{ {
new_font = (NSFont*)NSCopyObject(self, 0, zone); new_font = (NSFont*)NSCopyObject(self, 0, zone);
@ -788,9 +809,12 @@ setNSFont(NSString* key, NSFont* font)
float fontMatrix[6]; float fontMatrix[6];
name = [aDecoder decodeObject]; name = [aDecoder decodeObject];
[aDecoder decodeArrayOfObjCType: @encode(float) count: 6 at: fontMatrix]; [aDecoder decodeArrayOfObjCType: @encode(float)
count: 6
at: fontMatrix];
self = [self initWithName: name matrix: fontMatrix]; self = [self initWithName: name matrix: fontMatrix];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &matrixExplicitlySet]; [aDecoder decodeValueOfObjCType: @encode(BOOL)
at: &matrixExplicitlySet];
} }
else else
{ {
@ -798,7 +822,9 @@ setNSFont(NSString* key, NSFont* font)
float fontMatrix[6]; float fontMatrix[6];
name = [aDecoder decodeObject]; name = [aDecoder decodeObject];
[aDecoder decodeArrayOfObjCType: @encode(float) count: 6 at: fontMatrix]; [aDecoder decodeArrayOfObjCType: @encode(float)
count: 6
at: fontMatrix];
self = [self initWithName: name matrix: fontMatrix]; self = [self initWithName: name matrix: fontMatrix];
if (fontMatrix[0] == fontMatrix[3] if (fontMatrix[0] == fontMatrix[3]
&& fontMatrix[1] == 0.0 && fontMatrix[1] == 0.0

View file

@ -138,7 +138,9 @@ static Class fontPanelClass = Nil;
NSString *name = [fontsList objectAtIndex: i]; NSString *name = [fontsList objectAtIndex: i];
if ([self _includeFont: name]) if ([self _includeFont: name])
[fontNames addObject: name]; {
[fontNames addObject: name];
}
} }
return fontNames; return fontNames;
@ -159,7 +161,7 @@ static Class fontPanelClass = Nil;
for (i = 0; i < [fontFamilies count]; i++) for (i = 0; i < [fontFamilies count]; i++)
{ {
NSArray *fontDefs = [self availableMembersOfFontFamily: NSArray *fontDefs = [self availableMembersOfFontFamily:
[fontFamilies objectAtIndex: i]]; [fontFamilies objectAtIndex: i]];
for (j = 0; j < [fontDefs count]; j++) for (j = 0; j < [fontDefs count]; j++)
{ {
@ -193,7 +195,9 @@ static Class fontPanelClass = Nil;
NSString *name = [fontDef objectAtIndex: 0]; NSString *name = [fontDef objectAtIndex: 0];
if ([self _includeFont: name]) if ([self _includeFont: name])
[fonts addObject: fontDef]; {
[fonts addObject: fontDef];
}
} }
return fonts; return fonts;
@ -220,7 +224,9 @@ static Class fontPanelClass = Nil;
_multiple = flag; _multiple = flag;
// The panel should also know if multiple changed // The panel should also know if multiple changed
if (fontPanel != nil) if (fontPanel != nil)
[fontPanel setPanelFont: fontObject isMultiple: flag]; {
[fontPanel setPanelFont: fontObject isMultiple: flag];
}
} }
return; return;
} }
@ -229,7 +235,9 @@ static Class fontPanelClass = Nil;
ASSIGN(_selectedFont, fontObject); ASSIGN(_selectedFont, fontObject);
if (fontPanel != nil) if (fontPanel != nil)
[fontPanel setPanelFont: fontObject isMultiple: flag]; {
[fontPanel setPanelFont: fontObject isMultiple: flag];
}
if (_fontMenu != nil) if (_fontMenu != nil)
{ {
@ -495,12 +503,12 @@ static Class fontPanelClass = Nil;
else if (trait == NSUnboldFontMask) else if (trait == NSUnboldFontMask)
{ {
return [self convertFont: fontObject return [self convertFont: fontObject
toNotHaveTrait: NSBoldFontMask]; toNotHaveTrait: NSBoldFontMask];
} }
else if (trait == NSUnitalicFontMask) else if (trait == NSUnitalicFontMask)
{ {
return [self convertFont: fontObject return [self convertFont: fontObject
toNotHaveTrait: NSItalicFontMask]; toNotHaveTrait: NSItalicFontMask];
} }
else else
{ {
@ -535,10 +543,13 @@ static Class fontPanelClass = Nil;
// This is a bit strange but is stated in the specification // This is a bit strange but is stated in the specification
if (trait & NSUnboldFontMask) if (trait & NSUnboldFontMask)
{
trait = (trait | NSBoldFontMask) & ~NSUnboldFontMask; trait = (trait | NSBoldFontMask) & ~NSUnboldFontMask;
}
if (trait & NSUnitalicFontMask) if (trait & NSUnitalicFontMask)
{
trait = (trait | NSItalicFontMask) & ~NSUnitalicFontMask; trait = (trait | NSItalicFontMask) & ~NSUnitalicFontMask;
}
if (!(t & trait)) if (!(t & trait))
{ {
// If already do not have that trait then just return it // If already do not have that trait then just return it
@ -555,8 +566,9 @@ static Class fontPanelClass = Nil;
// We cannot reuse the weight in an unbold // We cannot reuse the weight in an unbold
if (trait & NSBoldFontMask) if (trait & NSBoldFontMask)
weight = 5; {
weight = 5;
}
t &= ~trait; t &= ~trait;
newFont = [self fontWithFamily: family newFont = [self fontWithFamily: family
traits: t traits: t
@ -653,8 +665,8 @@ static Class fontPanelClass = Nil;
NSArray *fontDef = [fontDefs objectAtIndex: i]; NSArray *fontDef = [fontDefs objectAtIndex: i];
int w1 = [[fontDef objectAtIndex: 2] intValue]; int w1 = [[fontDef objectAtIndex: 2] intValue];
if (w1 < w && w1 > next_w && if (w1 < w && w1 > next_w
[[fontDef objectAtIndex: 3] unsignedIntValue] == trait) && [[fontDef objectAtIndex: 3] unsignedIntValue] == trait)
{ {
next_w = w1; next_w = w1;
fontName = [fontDef objectAtIndex: 0]; fontName = [fontDef objectAtIndex: 0];
@ -671,8 +683,8 @@ static Class fontPanelClass = Nil;
NSArray *fontDef = [fontDefs objectAtIndex: i]; NSArray *fontDef = [fontDefs objectAtIndex: i];
int w1 = [[fontDef objectAtIndex: 2] intValue]; int w1 = [[fontDef objectAtIndex: 2] intValue];
if (w1 < w && w1 > next_w && if (w1 < w && w1 > next_w
[[fontDef objectAtIndex: 3] unsignedIntValue] == trait) && [[fontDef objectAtIndex: 3] unsignedIntValue] == trait)
{ {
next_w = w1; next_w = w1;
fontName = [fontDef objectAtIndex: 0]; fontName = [fontDef objectAtIndex: 0];
@ -682,9 +694,10 @@ static Class fontPanelClass = Nil;
} }
if (fontName != nil) if (fontName != nil)
newFont = [NSFont fontWithName: fontName {
size: size]; newFont = [NSFont fontWithName: fontName
size: size];
}
if (newFont == nil) if (newFont == nil)
return fontObject; return fontObject;
else else