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>
|
||||
|
||||
* Source/NSManagedObjectContext.h
|
||||
|
|
|
@ -38,26 +38,36 @@
|
|||
|
||||
@class NSString;
|
||||
@class NSArray;
|
||||
@class NSDictionary;
|
||||
@class NSMutableDictionary;
|
||||
|
||||
@class NSFont;
|
||||
@class NSFontDescriptor;
|
||||
@class NSMenu;
|
||||
@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;
|
||||
|
||||
enum {
|
||||
NSItalicFontMask = 1,
|
||||
NSUnitalicFontMask = 0, //1024,
|
||||
NSBoldFontMask = 2,
|
||||
NSUnboldFontMask = 0, //2048,
|
||||
NSNarrowFontMask = 4,
|
||||
NSExpandedFontMask = 8,
|
||||
NSCondensedFontMask = 16,
|
||||
NSSmallCapsFontMask = 32,
|
||||
NSPosterFontMask = 64,
|
||||
NSCompressedFontMask = 128,
|
||||
NSNonStandardCharacterSetFontMask = 256,
|
||||
NSFixedPitchFontMask = 512
|
||||
NSUnboldFontMask = 4,
|
||||
NSNonStandardCharacterSetFontMask = 8,
|
||||
NSNarrowFontMask = 16,
|
||||
NSExpandedFontMask = 32,
|
||||
NSCondensedFontMask = 64,
|
||||
NSSmallCapsFontMask = 128,
|
||||
NSPosterFontMask = 256,
|
||||
NSCompressedFontMask = 512,
|
||||
NSFixedPitchFontMask = 1024,
|
||||
NSUnitalicFontMask = 1 << 24
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
|
@ -82,6 +92,8 @@ typedef enum {
|
|||
NSFontTag _storedTag;
|
||||
NSFontTraitMask _trait;
|
||||
id _fontEnumerator;
|
||||
NSDictionary *_selectedAttributes;
|
||||
NSMutableDictionary *_collections;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -183,6 +195,22 @@ typedef enum {
|
|||
- (SEL)action;
|
||||
- (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
|
||||
|
||||
@interface NSObject (NSFontManagerDelegate)
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSValue.h>
|
||||
#include <Foundation/NSDebug.h>
|
||||
#include "AppKit/NSFontDescriptor.h"
|
||||
#include "AppKit/NSFontManager.h"
|
||||
#include "AppKit/NSApplication.h"
|
||||
#include "AppKit/NSFont.h"
|
||||
|
@ -116,6 +117,7 @@ static Class fontPanelClass = Nil;
|
|||
_action = @selector(changeFont:);
|
||||
_storedTag = NSNoFontChangeAction;
|
||||
_fontEnumerator = RETAIN([GSFontEnumerator sharedEnumerator]);
|
||||
_collections = [[NSMutableDictionary alloc] initWithCapacity: 3];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -123,8 +125,10 @@ static Class fontPanelClass = Nil;
|
|||
- (void) dealloc
|
||||
{
|
||||
TEST_RELEASE(_selectedFont);
|
||||
TEST_RELEASE(_selectedAttributes);
|
||||
TEST_RELEASE(_fontMenu);
|
||||
TEST_RELEASE(_fontEnumerator);
|
||||
RELEASE(_collections);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -199,6 +203,7 @@ static Class fontPanelClass = Nil;
|
|||
|
||||
_multiple = flag;
|
||||
ASSIGN(_selectedFont, fontObject);
|
||||
DESTROY(_selectedAttributes);
|
||||
|
||||
if (fontPanel != nil)
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
// FIXME: Should be send to backend
|
||||
_f.has_shadow = hasShadow;
|
||||
if (_windowNum)
|
||||
{
|
||||
[GSServerForWindow(self) setShadow: hasShadow : _windowNum];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL) hasShadow
|
||||
|
|
Loading…
Reference in a new issue