mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-25 14:00:54 +00:00
Add MacOSX 10.3 methods and constants.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@25396 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
3a1993231e
commit
ddb8506a63
4 changed files with 474 additions and 266 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2007-08-16 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Headers/AppKit/NSFontManager.h,
|
||||||
|
* Source/NSFontManager.m: Add MacOSX 10.3 methods and constants.
|
||||||
|
* Source/NSWindow.m (-setHasShadow:): Add backend call.
|
||||||
|
|
||||||
2007-08-14 23:24-EDT Gregory John Casamento <greg_casamento@yahoo.com>
|
2007-08-14 23:24-EDT Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
* Source/NSManagedObjectContext.h
|
* Source/NSManagedObjectContext.h
|
||||||
|
|
|
@ -38,26 +38,36 @@
|
||||||
|
|
||||||
@class NSString;
|
@class NSString;
|
||||||
@class NSArray;
|
@class NSArray;
|
||||||
|
@class NSDictionary;
|
||||||
|
@class NSMutableDictionary;
|
||||||
|
|
||||||
@class NSFont;
|
@class NSFont;
|
||||||
|
@class NSFontDescriptor;
|
||||||
@class NSMenu;
|
@class NSMenu;
|
||||||
@class NSFontPanel;
|
@class NSFontPanel;
|
||||||
|
|
||||||
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
|
||||||
|
enum _NSFontManagerAddCollectionOptions
|
||||||
|
{
|
||||||
|
NSFontCollectionApplicationOnlyMask = 1 << 0
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef unsigned int NSFontTraitMask;
|
typedef unsigned int NSFontTraitMask;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
NSItalicFontMask = 1,
|
NSItalicFontMask = 1,
|
||||||
NSUnitalicFontMask = 0, //1024,
|
|
||||||
NSBoldFontMask = 2,
|
NSBoldFontMask = 2,
|
||||||
NSUnboldFontMask = 0, //2048,
|
NSUnboldFontMask = 4,
|
||||||
NSNarrowFontMask = 4,
|
NSNonStandardCharacterSetFontMask = 8,
|
||||||
NSExpandedFontMask = 8,
|
NSNarrowFontMask = 16,
|
||||||
NSCondensedFontMask = 16,
|
NSExpandedFontMask = 32,
|
||||||
NSSmallCapsFontMask = 32,
|
NSCondensedFontMask = 64,
|
||||||
NSPosterFontMask = 64,
|
NSSmallCapsFontMask = 128,
|
||||||
NSCompressedFontMask = 128,
|
NSPosterFontMask = 256,
|
||||||
NSNonStandardCharacterSetFontMask = 256,
|
NSCompressedFontMask = 512,
|
||||||
NSFixedPitchFontMask = 512
|
NSFixedPitchFontMask = 1024,
|
||||||
|
NSUnitalicFontMask = 1 << 24
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -82,6 +92,8 @@ typedef enum {
|
||||||
NSFontTag _storedTag;
|
NSFontTag _storedTag;
|
||||||
NSFontTraitMask _trait;
|
NSFontTraitMask _trait;
|
||||||
id _fontEnumerator;
|
id _fontEnumerator;
|
||||||
|
NSDictionary *_selectedAttributes;
|
||||||
|
NSMutableDictionary *_collections;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -183,6 +195,22 @@ typedef enum {
|
||||||
- (SEL)action;
|
- (SEL)action;
|
||||||
- (void)setAction:(SEL)aSelector;
|
- (void)setAction:(SEL)aSelector;
|
||||||
|
|
||||||
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
|
||||||
|
- (BOOL)addCollection:(NSString *)name options:(int)options;
|
||||||
|
- (BOOL)removeCollection:(NSString *)collection;
|
||||||
|
- (NSArray *)collectionNames;
|
||||||
|
|
||||||
|
- (void)addFontDescriptors:(NSArray *)descriptors
|
||||||
|
toCollection:(NSString *)collection;
|
||||||
|
- (void)removeFontDescriptor:(NSFontDescriptor *)descriptor
|
||||||
|
fromCollection:(NSString *)collection;
|
||||||
|
- (NSArray *)fontDescriptorsInCollection:(NSString *)collection;
|
||||||
|
|
||||||
|
- (NSArray *)availableFontNamesMatchingFontDescriptor:(NSFontDescriptor *)descriptor;
|
||||||
|
- (NSDictionary *)convertAttributes:(NSDictionary *)attributes;
|
||||||
|
- (void)setSelectedAttributes:(NSDictionary *)attributes
|
||||||
|
isMultiple:(BOOL)flag;
|
||||||
|
#endif
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface NSObject (NSFontManagerDelegate)
|
@interface NSObject (NSFontManagerDelegate)
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include <Foundation/NSString.h>
|
#include <Foundation/NSString.h>
|
||||||
#include <Foundation/NSValue.h>
|
#include <Foundation/NSValue.h>
|
||||||
#include <Foundation/NSDebug.h>
|
#include <Foundation/NSDebug.h>
|
||||||
|
#include "AppKit/NSFontDescriptor.h"
|
||||||
#include "AppKit/NSFontManager.h"
|
#include "AppKit/NSFontManager.h"
|
||||||
#include "AppKit/NSApplication.h"
|
#include "AppKit/NSApplication.h"
|
||||||
#include "AppKit/NSFont.h"
|
#include "AppKit/NSFont.h"
|
||||||
|
@ -44,10 +45,10 @@
|
||||||
/*
|
/*
|
||||||
* Class variables
|
* Class variables
|
||||||
*/
|
*/
|
||||||
static NSFontManager *sharedFontManager = nil;
|
static NSFontManager *sharedFontManager = nil;
|
||||||
static NSFontPanel *fontPanel = nil;
|
static NSFontPanel *fontPanel = nil;
|
||||||
static Class fontManagerClass = Nil;
|
static Class fontManagerClass = Nil;
|
||||||
static Class fontPanelClass = Nil;
|
static Class fontPanelClass = Nil;
|
||||||
|
|
||||||
|
|
||||||
@implementation NSFontManager
|
@implementation NSFontManager
|
||||||
|
@ -116,6 +117,7 @@ static Class fontPanelClass = Nil;
|
||||||
_action = @selector(changeFont:);
|
_action = @selector(changeFont:);
|
||||||
_storedTag = NSNoFontChangeAction;
|
_storedTag = NSNoFontChangeAction;
|
||||||
_fontEnumerator = RETAIN([GSFontEnumerator sharedEnumerator]);
|
_fontEnumerator = RETAIN([GSFontEnumerator sharedEnumerator]);
|
||||||
|
_collections = [[NSMutableDictionary alloc] initWithCapacity: 3];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -123,8 +125,10 @@ static Class fontPanelClass = Nil;
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
TEST_RELEASE(_selectedFont);
|
TEST_RELEASE(_selectedFont);
|
||||||
|
TEST_RELEASE(_selectedAttributes);
|
||||||
TEST_RELEASE(_fontMenu);
|
TEST_RELEASE(_fontMenu);
|
||||||
TEST_RELEASE(_fontEnumerator);
|
TEST_RELEASE(_fontEnumerator);
|
||||||
|
RELEASE(_collections);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,17 +154,17 @@ 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++)
|
||||||
{
|
{
|
||||||
NSArray *fontDef = [fontDefs objectAtIndex: j];
|
NSArray *fontDef = [fontDefs objectAtIndex: j];
|
||||||
|
|
||||||
traits = [[fontDef objectAtIndex: 3] unsignedIntValue];
|
traits = [[fontDef objectAtIndex: 3] unsignedIntValue];
|
||||||
// Check if the font has exactly the given mask
|
// Check if the font has exactly the given mask
|
||||||
if (traits == fontTraitMask)
|
if (traits == fontTraitMask)
|
||||||
[fontNames addObject: [fontDef objectAtIndex: 0]];
|
[fontNames addObject: [fontDef objectAtIndex: 0]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return fontNames;
|
return fontNames;
|
||||||
|
@ -172,7 +176,7 @@ static Class fontPanelClass = Nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString*) localizedNameForFamily: (NSString*)family
|
- (NSString*) localizedNameForFamily: (NSString*)family
|
||||||
face: (NSString*)face
|
face: (NSString*)face
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
return [NSString stringWithFormat: @"%@-%@", family, face];
|
return [NSString stringWithFormat: @"%@-%@", family, face];
|
||||||
|
@ -181,24 +185,25 @@ static Class fontPanelClass = Nil;
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
- (void) setSelectedFont: (NSFont*)fontObject
|
- (void) setSelectedFont: (NSFont*)fontObject
|
||||||
isMultiple: (BOOL)flag
|
isMultiple: (BOOL)flag
|
||||||
{
|
{
|
||||||
if (_selectedFont == fontObject)
|
if (_selectedFont == fontObject)
|
||||||
{
|
{
|
||||||
if (flag != _multiple)
|
if (flag != _multiple)
|
||||||
{
|
{
|
||||||
_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;
|
||||||
}
|
}
|
||||||
|
|
||||||
_multiple = flag;
|
_multiple = flag;
|
||||||
ASSIGN(_selectedFont, fontObject);
|
ASSIGN(_selectedFont, fontObject);
|
||||||
|
DESTROY(_selectedAttributes);
|
||||||
|
|
||||||
if (fontPanel != nil)
|
if (fontPanel != nil)
|
||||||
{
|
{
|
||||||
|
@ -215,42 +220,42 @@ static Class fontPanelClass = Nil;
|
||||||
* We keep the tag, to mark the item
|
* We keep the tag, to mark the item
|
||||||
*/
|
*/
|
||||||
if (trait & NSItalicFontMask)
|
if (trait & NSItalicFontMask)
|
||||||
{
|
{
|
||||||
menuItem = [_fontMenu itemWithTag: NSItalicFontMask];
|
menuItem = [_fontMenu itemWithTag: NSItalicFontMask];
|
||||||
if (menuItem != nil)
|
if (menuItem != nil)
|
||||||
{
|
{
|
||||||
[menuItem setTitle: @"Unitalic"];
|
[menuItem setTitle: @"Unitalic"];
|
||||||
[menuItem setAction: @selector(removeFontTrait:)];
|
[menuItem setAction: @selector(removeFontTrait:)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
menuItem = [_fontMenu itemWithTag: NSItalicFontMask];
|
menuItem = [_fontMenu itemWithTag: NSItalicFontMask];
|
||||||
if (menuItem != nil)
|
if (menuItem != nil)
|
||||||
{
|
{
|
||||||
[menuItem setTitle: @"Italic"];
|
[menuItem setTitle: @"Italic"];
|
||||||
[menuItem setAction: @selector(addFontTrait:)];
|
[menuItem setAction: @selector(addFontTrait:)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trait & NSBoldFontMask)
|
if (trait & NSBoldFontMask)
|
||||||
{
|
{
|
||||||
menuItem = [_fontMenu itemWithTag: NSBoldFontMask];
|
menuItem = [_fontMenu itemWithTag: NSBoldFontMask];
|
||||||
if (menuItem != nil)
|
if (menuItem != nil)
|
||||||
{
|
{
|
||||||
[menuItem setTitle: @"Unbold"];
|
[menuItem setTitle: @"Unbold"];
|
||||||
[menuItem setAction: @selector(removeFontTrait:)];
|
[menuItem setAction: @selector(removeFontTrait:)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
menuItem = [_fontMenu itemWithTag: NSBoldFontMask];
|
menuItem = [_fontMenu itemWithTag: NSBoldFontMask];
|
||||||
if (menuItem != nil)
|
if (menuItem != nil)
|
||||||
{
|
{
|
||||||
[menuItem setTitle: @"Bold"];
|
[menuItem setTitle: @"Bold"];
|
||||||
[menuItem setAction: @selector(addFontTrait:)];
|
[menuItem setAction: @selector(addFontTrait:)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Update the rest of the font menu to reflect this font
|
// TODO Update the rest of the font menu to reflect this font
|
||||||
}
|
}
|
||||||
|
@ -283,12 +288,12 @@ static Class fontPanelClass = Nil;
|
||||||
// We update our own selected font
|
// We update our own selected font
|
||||||
if (_selectedFont != nil)
|
if (_selectedFont != nil)
|
||||||
{
|
{
|
||||||
NSFont *newFont = [self convertFont: _selectedFont];
|
NSFont *newFont = [self convertFont: _selectedFont];
|
||||||
|
|
||||||
if (newFont != nil)
|
if (newFont != nil)
|
||||||
{
|
{
|
||||||
[self setSelectedFont: newFont isMultiple: _multiple];
|
[self setSelectedFont: newFont isMultiple: _multiple];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,12 +306,12 @@ static Class fontPanelClass = Nil;
|
||||||
// We update our own selected font
|
// We update our own selected font
|
||||||
if (_selectedFont != nil)
|
if (_selectedFont != nil)
|
||||||
{
|
{
|
||||||
NSFont *newFont = [self convertFont: _selectedFont];
|
NSFont *newFont = [self convertFont: _selectedFont];
|
||||||
|
|
||||||
if (newFont != nil)
|
if (newFont != nil)
|
||||||
{
|
{
|
||||||
[self setSelectedFont: newFont isMultiple: _multiple];
|
[self setSelectedFont: newFont isMultiple: _multiple];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,12 +323,12 @@ static Class fontPanelClass = Nil;
|
||||||
// We update our own selected font
|
// We update our own selected font
|
||||||
if (_selectedFont != nil)
|
if (_selectedFont != nil)
|
||||||
{
|
{
|
||||||
NSFont *newFont = [self convertFont: _selectedFont];
|
NSFont *newFont = [self convertFont: _selectedFont];
|
||||||
|
|
||||||
if (newFont != nil)
|
if (newFont != nil)
|
||||||
{
|
{
|
||||||
[self setSelectedFont: newFont isMultiple: _multiple];
|
[self setSelectedFont: newFont isMultiple: _multiple];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,12 +340,12 @@ static Class fontPanelClass = Nil;
|
||||||
// We update our own selected font
|
// We update our own selected font
|
||||||
if (_selectedFont != nil)
|
if (_selectedFont != nil)
|
||||||
{
|
{
|
||||||
NSFont *newFont = [self convertFont: _selectedFont];
|
NSFont *newFont = [self convertFont: _selectedFont];
|
||||||
|
|
||||||
if (newFont != nil)
|
if (newFont != nil)
|
||||||
{
|
{
|
||||||
[self setSelectedFont: newFont isMultiple: _multiple];
|
[self setSelectedFont: newFont isMultiple: _multiple];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,7 +361,7 @@ static Class fontPanelClass = Nil;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
float size;
|
float size;
|
||||||
float sizes[] = {4.0, 6.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0,
|
float sizes[] = {4.0, 6.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0,
|
||||||
14.0, 16.0, 18.0, 24.0, 36.0, 48.0, 64.0};
|
14.0, 16.0, 18.0, 24.0, 36.0, 48.0, 64.0};
|
||||||
|
|
||||||
if (fontObject == nil)
|
if (fontObject == nil)
|
||||||
return nil;
|
return nil;
|
||||||
|
@ -364,51 +369,51 @@ static Class fontPanelClass = Nil;
|
||||||
switch (_storedTag)
|
switch (_storedTag)
|
||||||
{
|
{
|
||||||
case NSNoFontChangeAction:
|
case NSNoFontChangeAction:
|
||||||
break;
|
break;
|
||||||
case NSViaPanelFontAction:
|
case NSViaPanelFontAction:
|
||||||
if (fontPanel != nil)
|
if (fontPanel != nil)
|
||||||
{
|
{
|
||||||
newFont = [fontPanel panelConvertFont: fontObject];
|
newFont = [fontPanel panelConvertFont: fontObject];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NSAddTraitFontAction:
|
case NSAddTraitFontAction:
|
||||||
newFont = [self convertFont: fontObject toHaveTrait: _trait];
|
newFont = [self convertFont: fontObject toHaveTrait: _trait];
|
||||||
break;
|
break;
|
||||||
case NSRemoveTraitFontAction:
|
case NSRemoveTraitFontAction:
|
||||||
newFont = [self convertFont: fontObject toNotHaveTrait: _trait];
|
newFont = [self convertFont: fontObject toNotHaveTrait: _trait];
|
||||||
break;
|
break;
|
||||||
case NSSizeUpFontAction:
|
case NSSizeUpFontAction:
|
||||||
size = [fontObject pointSize];
|
size = [fontObject pointSize];
|
||||||
for (i = 0; i < sizeof(sizes)/sizeof(float); i++)
|
for (i = 0; i < sizeof(sizes)/sizeof(float); i++)
|
||||||
{
|
{
|
||||||
if (sizes[i] > size)
|
if (sizes[i] > size)
|
||||||
{
|
{
|
||||||
size = sizes[i];
|
size = sizes[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newFont = [self convertFont: fontObject
|
newFont = [self convertFont: fontObject
|
||||||
toSize: size];
|
toSize: size];
|
||||||
break;
|
break;
|
||||||
case NSSizeDownFontAction:
|
case NSSizeDownFontAction:
|
||||||
size = [fontObject pointSize];
|
size = [fontObject pointSize];
|
||||||
for (i = sizeof(sizes)/sizeof(float) -1; i >= 0; i--)
|
for (i = sizeof(sizes)/sizeof(float) -1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
if (sizes[i] < size)
|
if (sizes[i] < size)
|
||||||
{
|
{
|
||||||
size = sizes[i];
|
size = sizes[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newFont = [self convertFont: fontObject
|
newFont = [self convertFont: fontObject
|
||||||
toSize: size];
|
toSize: size];
|
||||||
break;
|
break;
|
||||||
case NSHeavierFontAction:
|
case NSHeavierFontAction:
|
||||||
newFont = [self convertWeight: YES ofFont: fontObject];
|
newFont = [self convertWeight: YES ofFont: fontObject];
|
||||||
break;
|
break;
|
||||||
case NSLighterFontAction:
|
case NSLighterFontAction:
|
||||||
newFont = [self convertWeight: NO ofFont: fontObject];
|
newFont = [self convertWeight: NO ofFont: fontObject];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return newFont;
|
return newFont;
|
||||||
|
@ -416,7 +421,7 @@ static Class fontPanelClass = Nil;
|
||||||
|
|
||||||
|
|
||||||
- (NSFont*) convertFont: (NSFont*)fontObject
|
- (NSFont*) convertFont: (NSFont*)fontObject
|
||||||
toFamily: (NSString*)family
|
toFamily: (NSString*)family
|
||||||
{
|
{
|
||||||
if ([family isEqualToString: [fontObject familyName]])
|
if ([family isEqualToString: [fontObject familyName]])
|
||||||
{
|
{
|
||||||
|
@ -432,18 +437,18 @@ static Class fontPanelClass = Nil;
|
||||||
float size = [fontObject pointSize];
|
float size = [fontObject pointSize];
|
||||||
|
|
||||||
newFont = [self fontWithFamily: family
|
newFont = [self fontWithFamily: family
|
||||||
traits: trait
|
traits: trait
|
||||||
weight: weight
|
weight: weight
|
||||||
size: size];
|
size: size];
|
||||||
if (newFont == nil)
|
if (newFont == nil)
|
||||||
return fontObject;
|
return fontObject;
|
||||||
else
|
else
|
||||||
return newFont;
|
return newFont;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSFont*) convertFont: (NSFont*)fontObject
|
- (NSFont*) convertFont: (NSFont*)fontObject
|
||||||
toFace: (NSString*)typeface
|
toFace: (NSString*)typeface
|
||||||
{
|
{
|
||||||
NSFont *newFont;
|
NSFont *newFont;
|
||||||
|
|
||||||
|
@ -461,7 +466,7 @@ static Class fontPanelClass = Nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSFont*) convertFont: (NSFont*)fontObject
|
- (NSFont*) convertFont: (NSFont*)fontObject
|
||||||
toHaveTrait: (NSFontTraitMask)trait
|
toHaveTrait: (NSFontTraitMask)trait
|
||||||
{
|
{
|
||||||
NSFontTraitMask t = [self traitsOfFont: fontObject];
|
NSFontTraitMask t = [self traitsOfFont: fontObject];
|
||||||
|
|
||||||
|
@ -473,13 +478,13 @@ 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
|
||||||
{
|
{
|
||||||
// Else convert it
|
// Else convert it
|
||||||
|
@ -491,23 +496,23 @@ static Class fontPanelClass = Nil;
|
||||||
|
|
||||||
// We cannot reuse the weight in a bold
|
// We cannot reuse the weight in a bold
|
||||||
if (trait == NSBoldFontMask)
|
if (trait == NSBoldFontMask)
|
||||||
weight = 9;
|
weight = 9;
|
||||||
|
|
||||||
t = t | trait;
|
t = t | trait;
|
||||||
newFont = [self fontWithFamily: family
|
newFont = [self fontWithFamily: family
|
||||||
traits: t
|
traits: t
|
||||||
weight: weight
|
weight: weight
|
||||||
size: size];
|
size: size];
|
||||||
|
|
||||||
if (newFont == nil)
|
if (newFont == nil)
|
||||||
return fontObject;
|
return fontObject;
|
||||||
else
|
else
|
||||||
return newFont;
|
return newFont;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSFont*) convertFont: (NSFont*)fontObject
|
- (NSFont*) convertFont: (NSFont*)fontObject
|
||||||
toNotHaveTrait: (NSFontTraitMask)trait
|
toNotHaveTrait: (NSFontTraitMask)trait
|
||||||
{
|
{
|
||||||
NSFontTraitMask t = [self traitsOfFont: fontObject];
|
NSFontTraitMask t = [self traitsOfFont: fontObject];
|
||||||
|
|
||||||
|
@ -536,23 +541,23 @@ 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
|
||||||
weight: weight
|
weight: weight
|
||||||
size: size];
|
size: size];
|
||||||
if (newFont == nil)
|
if (newFont == nil)
|
||||||
return fontObject;
|
return fontObject;
|
||||||
else
|
else
|
||||||
return newFont;
|
return newFont;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSFont*) convertFont: (NSFont*)fontObject
|
- (NSFont*) convertFont: (NSFont*)fontObject
|
||||||
toSize: (float)size
|
toSize: (float)size
|
||||||
{
|
{
|
||||||
if ([fontObject pointSize] == size)
|
if ([fontObject pointSize] == size)
|
||||||
{
|
{
|
||||||
|
@ -565,16 +570,16 @@ static Class fontPanelClass = Nil;
|
||||||
NSFont *newFont;
|
NSFont *newFont;
|
||||||
|
|
||||||
newFont = [NSFont fontWithName: [fontObject fontName]
|
newFont = [NSFont fontWithName: [fontObject fontName]
|
||||||
size: size];
|
size: size];
|
||||||
if (newFont == nil)
|
if (newFont == nil)
|
||||||
return fontObject;
|
return fontObject;
|
||||||
else
|
else
|
||||||
return newFont;
|
return newFont;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSFont*) convertWeight: (BOOL)upFlag
|
- (NSFont*) convertWeight: (BOOL)upFlag
|
||||||
ofFont: (NSFont*)fontObject
|
ofFont: (NSFont*)fontObject
|
||||||
{
|
{
|
||||||
NSFont *newFont = nil;
|
NSFont *newFont = nil;
|
||||||
NSString *fontName = nil;
|
NSString *fontName = nil;
|
||||||
|
@ -594,36 +599,36 @@ static Class fontPanelClass = Nil;
|
||||||
int next_w = 15;
|
int next_w = 15;
|
||||||
|
|
||||||
for (i = 0; i < [fontDefs count]; i++)
|
for (i = 0; i < [fontDefs count]; i++)
|
||||||
{
|
{
|
||||||
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];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fontName == nil)
|
if (fontName == nil)
|
||||||
{
|
{
|
||||||
// Not found, try again with changed trait
|
// Not found, try again with changed trait
|
||||||
trait |= NSBoldFontMask;
|
trait |= NSBoldFontMask;
|
||||||
|
|
||||||
for (i = 0; i < [fontDefs count]; i++)
|
for (i = 0; i < [fontDefs count]; i++)
|
||||||
{
|
{
|
||||||
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];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -631,42 +636,42 @@ static Class fontPanelClass = Nil;
|
||||||
int next_w = 0;
|
int next_w = 0;
|
||||||
|
|
||||||
for (i = 0; i < [fontDefs count]; i++)
|
for (i = 0; i < [fontDefs count]; i++)
|
||||||
{
|
{
|
||||||
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];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fontName == nil)
|
if (fontName == nil)
|
||||||
{
|
{
|
||||||
// Not found, try again with changed trait
|
// Not found, try again with changed trait
|
||||||
trait &= ~NSBoldFontMask;
|
trait &= ~NSBoldFontMask;
|
||||||
|
|
||||||
for (i = 0; i < [fontDefs count]; i++)
|
for (i = 0; i < [fontDefs count]; i++)
|
||||||
{
|
{
|
||||||
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];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fontName != nil)
|
if (fontName != nil)
|
||||||
{
|
{
|
||||||
newFont = [NSFont fontWithName: fontName
|
newFont = [NSFont fontWithName: fontName
|
||||||
size: size];
|
size: size];
|
||||||
}
|
}
|
||||||
if (newFont == nil)
|
if (newFont == nil)
|
||||||
return fontObject;
|
return fontObject;
|
||||||
|
@ -678,9 +683,9 @@ static Class fontPanelClass = Nil;
|
||||||
* Getting a font
|
* Getting a font
|
||||||
*/
|
*/
|
||||||
- (NSFont*) fontWithFamily: (NSString*)family
|
- (NSFont*) fontWithFamily: (NSString*)family
|
||||||
traits: (NSFontTraitMask)traits
|
traits: (NSFontTraitMask)traits
|
||||||
weight: (int)weight
|
weight: (int)weight
|
||||||
size: (float)size
|
size: (float)size
|
||||||
{
|
{
|
||||||
NSArray *fontDefs = [self availableMembersOfFontFamily: family];
|
NSArray *fontDefs = [self availableMembersOfFontFamily: family];
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
@ -696,12 +701,12 @@ static Class fontPanelClass = Nil;
|
||||||
// [[fontDef objectAtIndex: 2] intValue],
|
// [[fontDef objectAtIndex: 2] intValue],
|
||||||
// [[fontDef objectAtIndex: 3] unsignedIntValue]);
|
// [[fontDef objectAtIndex: 3] unsignedIntValue]);
|
||||||
if (([[fontDef objectAtIndex: 2] intValue] == weight) &&
|
if (([[fontDef objectAtIndex: 2] intValue] == weight) &&
|
||||||
([[fontDef objectAtIndex: 3] unsignedIntValue] == traits))
|
([[fontDef objectAtIndex: 3] unsignedIntValue] == traits))
|
||||||
{
|
{
|
||||||
//NSLog(@"Found font");
|
//NSLog(@"Found font");
|
||||||
return [NSFont fontWithName: [fontDef objectAtIndex: 0]
|
return [NSFont fontWithName: [fontDef objectAtIndex: 0]
|
||||||
size: size];
|
size: size];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to find something close
|
// Try to find something close
|
||||||
|
@ -713,17 +718,17 @@ static Class fontPanelClass = Nil;
|
||||||
//NSLog(@"Trying ignore weights for bold font");
|
//NSLog(@"Trying ignore weights for bold font");
|
||||||
for (i = 0; i < [fontDefs count]; i++)
|
for (i = 0; i < [fontDefs count]; i++)
|
||||||
{
|
{
|
||||||
NSArray *fontDef = [fontDefs objectAtIndex: i];
|
NSArray *fontDef = [fontDefs objectAtIndex: i];
|
||||||
NSFontTraitMask t = [[fontDef objectAtIndex: 3] unsignedIntValue];
|
NSFontTraitMask t = [[fontDef objectAtIndex: 3] unsignedIntValue];
|
||||||
|
|
||||||
t &= ~(NSNonStandardCharacterSetFontMask | NSFixedPitchFontMask);
|
t &= ~(NSNonStandardCharacterSetFontMask | NSFixedPitchFontMask);
|
||||||
if (t == traits)
|
if (t == traits)
|
||||||
{
|
{
|
||||||
//NSLog(@"Found font");
|
//NSLog(@"Found font");
|
||||||
return [NSFont fontWithName: [fontDef objectAtIndex: 0]
|
return [NSFont fontWithName: [fontDef objectAtIndex: 0]
|
||||||
size: size];
|
size: size];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (weight == 5 || weight == 6)
|
if (weight == 5 || weight == 6)
|
||||||
|
@ -731,19 +736,19 @@ static Class fontPanelClass = Nil;
|
||||||
//NSLog(@"Trying alternate non-bold weights for non-bold font");
|
//NSLog(@"Trying alternate non-bold weights for non-bold font");
|
||||||
for (i = 0; i < [fontDefs count]; i++)
|
for (i = 0; i < [fontDefs count]; i++)
|
||||||
{
|
{
|
||||||
NSArray *fontDef = [fontDefs objectAtIndex: i];
|
NSArray *fontDef = [fontDefs objectAtIndex: i];
|
||||||
NSFontTraitMask t = [[fontDef objectAtIndex: 3] unsignedIntValue];
|
NSFontTraitMask t = [[fontDef objectAtIndex: 3] unsignedIntValue];
|
||||||
|
|
||||||
t &= ~(NSNonStandardCharacterSetFontMask | NSFixedPitchFontMask);
|
t &= ~(NSNonStandardCharacterSetFontMask | NSFixedPitchFontMask);
|
||||||
if ((([[fontDef objectAtIndex: 2] intValue] == 5) ||
|
if ((([[fontDef objectAtIndex: 2] intValue] == 5) ||
|
||||||
([[fontDef objectAtIndex: 2] intValue] == 6)) &&
|
([[fontDef objectAtIndex: 2] intValue] == 6)) &&
|
||||||
(t == traits))
|
(t == traits))
|
||||||
{
|
{
|
||||||
//NSLog(@"Found font");
|
//NSLog(@"Found font");
|
||||||
return [NSFont fontWithName: [fontDef objectAtIndex: 0]
|
return [NSFont fontWithName: [fontDef objectAtIndex: 0]
|
||||||
size: size];
|
size: size];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//NSLog(@"Didnt find font");
|
//NSLog(@"Didnt find font");
|
||||||
|
@ -777,24 +782,24 @@ 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++)
|
||||||
{
|
{
|
||||||
NSArray *fontDef = [fontDefs objectAtIndex: j];
|
NSArray *fontDef = [fontDefs objectAtIndex: j];
|
||||||
|
|
||||||
if ([[fontDef objectAtIndex: 0] isEqualToString: typeface])
|
if ([[fontDef objectAtIndex: 0] isEqualToString: typeface])
|
||||||
{
|
{
|
||||||
traits = [[fontDef objectAtIndex: 3] unsignedIntValue];
|
traits = [[fontDef objectAtIndex: 3] unsignedIntValue];
|
||||||
// FIXME: This is not exactly the right condition
|
// FIXME: This is not exactly the right condition
|
||||||
if ((traits & fontTraitMask) == fontTraitMask)
|
if ((traits & fontTraitMask) == fontTraitMask)
|
||||||
{
|
{
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NO;
|
return NO;
|
||||||
|
@ -822,9 +827,9 @@ static Class fontPanelClass = Nil;
|
||||||
if (_fontMenu != nil)
|
if (_fontMenu != nil)
|
||||||
{
|
{
|
||||||
for (i = 0; i < [_fontMenu numberOfItems]; i++)
|
for (i = 0; i < [_fontMenu numberOfItems]; i++)
|
||||||
{
|
{
|
||||||
[[_fontMenu itemAtIndex: i] setEnabled: flag];
|
[[_fontMenu itemAtIndex: i] setEnabled: flag];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fontPanel != nil)
|
if (fontPanel != nil)
|
||||||
|
@ -847,49 +852,49 @@ static Class fontPanelClass = Nil;
|
||||||
|
|
||||||
// First an entry to start the font panel
|
// First an entry to start the font panel
|
||||||
menuItem = [_fontMenu addItemWithTitle: @"Font Panel"
|
menuItem = [_fontMenu addItemWithTitle: @"Font Panel"
|
||||||
action: @selector(orderFrontFontPanel:)
|
action: @selector(orderFrontFontPanel:)
|
||||||
keyEquivalent: @"t"];
|
keyEquivalent: @"t"];
|
||||||
[menuItem setTarget: self];
|
[menuItem setTarget: self];
|
||||||
|
|
||||||
// Entry for italic
|
// Entry for italic
|
||||||
menuItem = [_fontMenu addItemWithTitle: @"Italic"
|
menuItem = [_fontMenu addItemWithTitle: @"Italic"
|
||||||
action: @selector(addFontTrait:)
|
action: @selector(addFontTrait:)
|
||||||
keyEquivalent: @"i"];
|
keyEquivalent: @"i"];
|
||||||
[menuItem setTag: NSItalicFontMask];
|
[menuItem setTag: NSItalicFontMask];
|
||||||
[menuItem setTarget: self];
|
[menuItem setTarget: self];
|
||||||
|
|
||||||
// Entry for bold
|
// Entry for bold
|
||||||
menuItem = [_fontMenu addItemWithTitle: @"Bold"
|
menuItem = [_fontMenu addItemWithTitle: @"Bold"
|
||||||
action: @selector(addFontTrait:)
|
action: @selector(addFontTrait:)
|
||||||
keyEquivalent: @"b"];
|
keyEquivalent: @"b"];
|
||||||
[menuItem setTag: NSBoldFontMask];
|
[menuItem setTag: NSBoldFontMask];
|
||||||
[menuItem setTarget: self];
|
[menuItem setTarget: self];
|
||||||
|
|
||||||
// Entry to increase weight
|
// Entry to increase weight
|
||||||
menuItem = [_fontMenu addItemWithTitle: @"Heavier"
|
menuItem = [_fontMenu addItemWithTitle: @"Heavier"
|
||||||
action: @selector(modifyFont:)
|
action: @selector(modifyFont:)
|
||||||
keyEquivalent: @"h"];
|
keyEquivalent: @"h"];
|
||||||
[menuItem setTag: NSHeavierFontAction];
|
[menuItem setTag: NSHeavierFontAction];
|
||||||
[menuItem setTarget: self];
|
[menuItem setTarget: self];
|
||||||
|
|
||||||
// Entry to decrease weight
|
// Entry to decrease weight
|
||||||
menuItem = [_fontMenu addItemWithTitle: @"Lighter"
|
menuItem = [_fontMenu addItemWithTitle: @"Lighter"
|
||||||
action: @selector(modifyFont:)
|
action: @selector(modifyFont:)
|
||||||
keyEquivalent: @"g"];
|
keyEquivalent: @"g"];
|
||||||
[menuItem setTag: NSLighterFontAction];
|
[menuItem setTag: NSLighterFontAction];
|
||||||
[menuItem setTarget: self];
|
[menuItem setTarget: self];
|
||||||
|
|
||||||
// Entry to increase size
|
// Entry to increase size
|
||||||
menuItem = [_fontMenu addItemWithTitle: @"Larger"
|
menuItem = [_fontMenu addItemWithTitle: @"Larger"
|
||||||
action: @selector(modifyFont:)
|
action: @selector(modifyFont:)
|
||||||
keyEquivalent: @"l"];
|
keyEquivalent: @"l"];
|
||||||
[menuItem setTag: NSSizeUpFontAction];
|
[menuItem setTag: NSSizeUpFontAction];
|
||||||
[menuItem setTarget: self];
|
[menuItem setTarget: self];
|
||||||
|
|
||||||
// Entry to decrease size
|
// Entry to decrease size
|
||||||
menuItem = [_fontMenu addItemWithTitle: @"Smaller"
|
menuItem = [_fontMenu addItemWithTitle: @"Smaller"
|
||||||
action: @selector(modifyFont:)
|
action: @selector(modifyFont:)
|
||||||
keyEquivalent: @"s"];
|
keyEquivalent: @"s"];
|
||||||
[menuItem setTag: NSSizeDownFontAction];
|
[menuItem setTag: NSSizeDownFontAction];
|
||||||
[menuItem setTarget: self];
|
[menuItem setTarget: self];
|
||||||
}
|
}
|
||||||
|
@ -974,5 +979,171 @@ static Class fontPanelClass = Nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
- (BOOL) addCollection: (NSString *)name options: (int)options
|
||||||
|
{
|
||||||
|
[_collections setObject: [NSMutableArray arrayWithCapacity: 10] forKey: name];
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) removeCollection:(NSString *) collection;
|
||||||
|
{
|
||||||
|
if ([_collections objectForKey: collection])
|
||||||
|
{
|
||||||
|
[_collections removeObjectForKey: collection];
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSArray *) collectionNames
|
||||||
|
{
|
||||||
|
return [_collections allKeys];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) addFontDescriptors: (NSArray *)descriptors
|
||||||
|
toCollection: (NSString *)collection
|
||||||
|
{
|
||||||
|
NSMutableArray *a = [_collections objectForKey: collection];
|
||||||
|
|
||||||
|
if (a)
|
||||||
|
{
|
||||||
|
[a addObjectsFromArray: descriptors];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) removeFontDescriptor: (NSFontDescriptor *)descriptor
|
||||||
|
fromCollection: (NSString *)collection
|
||||||
|
{
|
||||||
|
NSMutableArray *a = [_collections objectForKey: collection];
|
||||||
|
|
||||||
|
if (a)
|
||||||
|
{
|
||||||
|
[a removeObject: descriptor];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- (NSArray *) fontDescriptorsInCollection: (NSString *)collection
|
||||||
|
{
|
||||||
|
return [_collections objectForKey: collection];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSArray *) availableFontNamesMatchingFontDescriptor: (NSFontDescriptor *)descriptor
|
||||||
|
{
|
||||||
|
// FIXME
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSDictionary *) convertAttributes: (NSDictionary *)attributes
|
||||||
|
{
|
||||||
|
NSMutableDictionary *newAttributes;
|
||||||
|
unsigned int i;
|
||||||
|
float size;
|
||||||
|
float sizes[] = {4.0, 6.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0,
|
||||||
|
14.0, 16.0, 18.0, 24.0, 36.0, 48.0, 64.0};
|
||||||
|
NSFontTraitMask t;
|
||||||
|
|
||||||
|
if (attributes == nil)
|
||||||
|
return nil;
|
||||||
|
|
||||||
|
newAttributes = AUTORELEASE([attributes mutableCopy]);
|
||||||
|
switch (_storedTag)
|
||||||
|
{
|
||||||
|
case NSNoFontChangeAction:
|
||||||
|
break;
|
||||||
|
case NSViaPanelFontAction:
|
||||||
|
// FIXME
|
||||||
|
break;
|
||||||
|
case NSAddTraitFontAction:
|
||||||
|
t = [[attributes objectForKey: NSFontSymbolicTrait] unsignedIntValue];
|
||||||
|
|
||||||
|
if (t & _trait)
|
||||||
|
{
|
||||||
|
return newAttributes;
|
||||||
|
}
|
||||||
|
else if (_trait == NSUnboldFontMask)
|
||||||
|
{
|
||||||
|
t &= ~NSBoldFontMask;
|
||||||
|
}
|
||||||
|
else if (_trait == NSUnitalicFontMask)
|
||||||
|
{
|
||||||
|
t &= ~NSItalicFontMask;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
t &= _trait;
|
||||||
|
// FIXME: What about weight for NSBoldFontMask?
|
||||||
|
}
|
||||||
|
[newAttributes setObject: [NSNumber numberWithUnsignedInt: t]
|
||||||
|
forKey: NSFontSymbolicTrait];
|
||||||
|
break;
|
||||||
|
case NSRemoveTraitFontAction:
|
||||||
|
t = [[attributes objectForKey: NSFontSymbolicTrait] unsignedIntValue];
|
||||||
|
|
||||||
|
if (!(t & _trait))
|
||||||
|
{
|
||||||
|
return newAttributes;
|
||||||
|
}
|
||||||
|
else if (_trait == NSUnboldFontMask)
|
||||||
|
{
|
||||||
|
t = (t | NSBoldFontMask) & ~NSUnboldFontMask;
|
||||||
|
}
|
||||||
|
else if (_trait == NSUnitalicFontMask)
|
||||||
|
{
|
||||||
|
t = (t | NSItalicFontMask) & ~NSUnitalicFontMask;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
t &= ~_trait;
|
||||||
|
// FIXME: What about weight for NSBoldFontMask?
|
||||||
|
}
|
||||||
|
[newAttributes setObject: [NSNumber numberWithUnsignedInt: t]
|
||||||
|
forKey: NSFontSymbolicTrait];
|
||||||
|
break;
|
||||||
|
case NSSizeUpFontAction:
|
||||||
|
size = [[attributes objectForKey: NSFontSizeAttribute] floatValue];
|
||||||
|
for (i = 0; i < sizeof(sizes)/sizeof(float); i++)
|
||||||
|
{
|
||||||
|
if (sizes[i] > size)
|
||||||
|
{
|
||||||
|
size = sizes[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[newAttributes setObject: [NSString stringWithFormat: @"%f", size]
|
||||||
|
forKey: NSFontSizeAttribute];
|
||||||
|
break;
|
||||||
|
case NSSizeDownFontAction:
|
||||||
|
size = [[attributes objectForKey: NSFontSizeAttribute] floatValue];
|
||||||
|
for (i = sizeof(sizes)/sizeof(float) -1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
if (sizes[i] < size)
|
||||||
|
{
|
||||||
|
size = sizes[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[newAttributes setObject: [NSString stringWithFormat: @"%f", size]
|
||||||
|
forKey: NSFontSizeAttribute];
|
||||||
|
break;
|
||||||
|
case NSHeavierFontAction:
|
||||||
|
// FIXME
|
||||||
|
break;
|
||||||
|
case NSLighterFontAction:
|
||||||
|
// FIXME
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return newAttributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setSelectedAttributes: (NSDictionary *)attributes
|
||||||
|
isMultiple: (BOOL)flag
|
||||||
|
{
|
||||||
|
ASSIGN(_selectedAttributes, attributes);
|
||||||
|
_multiple = flag;
|
||||||
|
DESTROY(_selectedFont);
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
|
@ -1129,8 +1129,11 @@ many times.
|
||||||
|
|
||||||
- (void) setHasShadow: (BOOL)hasShadow
|
- (void) setHasShadow: (BOOL)hasShadow
|
||||||
{
|
{
|
||||||
// FIXME: Should be send to backend
|
|
||||||
_f.has_shadow = hasShadow;
|
_f.has_shadow = hasShadow;
|
||||||
|
if (_windowNum)
|
||||||
|
{
|
||||||
|
[GSServerForWindow(self) setShadow: hasShadow : _windowNum];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) hasShadow
|
- (BOOL) hasShadow
|
||||||
|
|
Loading…
Reference in a new issue