Add new MacOSX methods. Code mostly by Nikolaus Schaller.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@25270 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2007-06-18 21:08:54 +00:00
parent 86d97a419f
commit 4835a35c1c
21 changed files with 831 additions and 84 deletions

View file

@ -1,3 +1,29 @@
2007-06-18 Fred Kiefer <FredKiefer@gmx.de>
* Headers/AppKit/NSAttributedString.h: Add new MacOSX methods and
constants.
* Source/NSAttributedString.m: Basic implementation of new
methods.
* Source/externs.m: Define new string constants.
* Headers/AppKit/NSImageView.h: Add new MacOSX methods.
* Source/NSImageView.m: Basic implementation of new methods.
* Headers/AppKit/NSStringDrawing.h: Add new MacOSX methods.
* Source/NSStringDrawing.m: Basic implementation of new methods.
* Headers/AppKit/NSParagraphStyle.h: Add new MacOSX methods.
* Source/NSParagraphStyle.m: Implementation of new methods.
Code by Nikolaus Schaller <hns@computer.org>.
* Headers/AppKit/NSTextStorage.h,
* Source/NSText.m,
* Source/GSLayoutManager.m,
* Source/NSLayoutManager.m,
* Source/GSStandardWindowDecorationView.m,
* Source/GSHorizontalTypesetter.m,
* Source/NSMenuItemCell.m,
* Source/GSTitleView.m,
* Source/NSTextView_actions.m,
* Source/NSTextView.m,
* Source/NSToolbarItem.m: Clean up includes.
2007-06-18 Fred Kiefer <FredKiefer@gmx.de>
* Headers/AppKit/NSGraphicsContext.h: Declare new printing

View file

@ -1,4 +1,4 @@
/*
/* -*-objc-*-
NSAttributedString.h
Categories which add capabilities to NSAttributedString
@ -35,6 +35,8 @@
#include <Foundation/NSAttributedString.h>
#include <Foundation/NSRange.h>
#include <AppKit/NSFontManager.h>
// for NSWritingDirection
#include <AppKit/NSParagraphStyle.h>
#include <AppKit/NSText.h>
#include <AppKit/AppKitDefines.h>
@ -45,6 +47,10 @@
@class NSData;
@class NSArray;
@class NSURL;
@class NSError;
@class NSTextBlock;
@class NSTextList;
@class NSTextTable;
/* Global NSString attribute names used in accessing the respective
property in a text attributes dictionary. if the key is not in the
@ -70,14 +76,117 @@ APPKIT_EXPORT NSString *NSToolTipAttributeName;
APPKIT_EXPORT NSString *NSUnderlineColorAttributeName;
APPKIT_EXPORT NSString *NSUnderlineStyleAttributeName;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
APPKIT_EXPORT NSString *NSGlyphInfoAttributeName;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
APPKIT_EXPORT NSString *NSPaperSizeDocumentAttribute;
APPKIT_EXPORT NSString *NSLeftMarginDocumentAttribute;
APPKIT_EXPORT NSString *NSRightMarginDocumentAttribute;
APPKIT_EXPORT NSString *NSTopMarginDocumentAttribute;
APPKIT_EXPORT NSString *NSBottomMarginDocumentAttribute;
APPKIT_EXPORT NSString *NSHyphenationFactorDocumentAttribute;
APPKIT_EXPORT NSString *NSDocumentTypeDocumentAttribute;
APPKIT_EXPORT NSString *NSCharacterEncodingDocumentAttribute;
APPKIT_EXPORT NSString *NSViewSizeDocumentAttribute;
APPKIT_EXPORT NSString *NSViewZoomDocumentAttribute;
APPKIT_EXPORT NSString *NSViewModeDocumentAttribute;
APPKIT_EXPORT NSString *NSBackgroundColorDocumentAttribute;
APPKIT_EXPORT NSString *NSCocoaVersionDocumentAttribute;
APPKIT_EXPORT NSString *NSReadOnlyDocumentAttribute;
APPKIT_EXPORT NSString *NSConvertedDocumentAttribute;
APPKIT_EXPORT NSString *NSDefaultTabIntervalDocumentAttribute;
APPKIT_EXPORT NSString *NSTitleDocumentAttribute;
APPKIT_EXPORT NSString *NSCompanyDocumentAttribute;
APPKIT_EXPORT NSString *NSCopyrightDocumentAttribute;
APPKIT_EXPORT NSString *NSSubjectDocumentAttribute;
APPKIT_EXPORT NSString *NSAuthorDocumentAttribute;
APPKIT_EXPORT NSString *NSKeywordsDocumentAttribute;
APPKIT_EXPORT NSString *NSCommentDocumentAttribute;
APPKIT_EXPORT NSString *NSEditorDocumentAttribute;
APPKIT_EXPORT NSString *NSCreationTimeDocumentAttribute;
APPKIT_EXPORT NSString *NSModificationTimeDocumentAttribute;
// DocumentType values
APPKIT_EXPORT NSString *NSPlainTextDocumentType;
APPKIT_EXPORT NSString *NSRTFTextDocumentType;
APPKIT_EXPORT NSString *NSRTFDTextDocumentType;
APPKIT_EXPORT NSString *NSMacSimpleTextDocumentType;
APPKIT_EXPORT NSString *NSHTMLTextDocumentType;
APPKIT_EXPORT NSString *NSDocFormatTextDocumentType;
APPKIT_EXPORT NSString *NSWordMLTextDocumentType;
// for HTML export
APPKIT_EXPORT NSString *NSExcludedElementsDocumentAttribute;
APPKIT_EXPORT NSString *NSTextEncodingNameDocumentAttribute;
APPKIT_EXPORT NSString *NSPrefixSpacesDocumentAttribute;
// for HTML import
APPKIT_EXPORT NSString *NSBaseURLDocumentOption;
APPKIT_EXPORT NSString *NSCharacterEncodingDocumentOption;
APPKIT_EXPORT NSString *NSDefaultAttributesDocumentOption;
APPKIT_EXPORT NSString *NSDocumentTypeDocumentOption;
APPKIT_EXPORT NSString *NSTextEncodingNameDocumentOption;
APPKIT_EXPORT NSString *NSTextSizeMultiplierDocumentOption;
APPKIT_EXPORT NSString *NSTimeoutDocumentOption;
APPKIT_EXPORT NSString *NSWebPreferencesDocumentOption;
APPKIT_EXPORT NSString *NSWebResourceLoadDelegateDocumentOption;
// special attributes
APPKIT_EXPORT NSString *NSCharacterShapeAttributeName;
APPKIT_EXPORT const unsigned NSUnderlineByWordMask;
// readFrom... attributes
APPKIT_EXPORT NSString *NSCharacterEncodingDocumentOption;
APPKIT_EXPORT NSString *NSBaseURLDocumentOption;
APPKIT_EXPORT NSString *NSDefaultAttributesDocumentOption;
APPKIT_EXPORT NSString *NSDocumentTypeDocumentOption;
// initWithHTML... attributes
APPKIT_EXPORT NSString *NSTextEncodingNameDocumentOption;
APPKIT_EXPORT NSString *NSTimeoutDocumentOption;
APPKIT_EXPORT NSString *NSWebPreferencesDocumentOption;
APPKIT_EXPORT NSString *NSWebResourceLoadDelegateDocumentOption;
APPKIT_EXPORT NSString *NSTextSizeMultiplierDocumentOption;
/* Currently supported values for NSUnderlineStyleAttributeName. */
enum
enum _NSUnderlineStyle
{
GSNoUnderlineStyle = 0,
NSSingleUnderlineStyle = 1
NSUnderlineStyleNone = 0x00,
NSUnderlineStyleSingle = 0x01,
NSUnderlineStyleThick = 0x02,
NSUnderlineStyleDouble = 0x09
};
enum _NSUnderlinePattern
{
NSUnderlinePatternSolid = 0x0000,
NSUnderlinePatternDot = 0x0100,
NSUnderlinePatternDash = 0x0200,
NSUnderlinePatternDashDot = 0x0300,
NSUnderlinePatternDashDotDot = 0x0400
};
#endif
#if OS_API_VERSION(GS_API_MACOSX, MAC_OS_X_VERSION_10_3)
// Deprecated
enum
{
GSNoUnderlineStyle = 0,
NSSingleUnderlineStyle = 1,
NSUnderlineStrikethroughMask
};
#endif
@interface NSAttributedString (AppKit)
- (BOOL) containsAttachments;
- (NSDictionary*) fontAttributesInRange: (NSRange)range;
- (NSDictionary*) rulerAttributesInRange: (NSRange)range;
- (unsigned) lineBreakBeforeIndex: (unsigned)location
@ -92,15 +201,16 @@ enum
- (id) initWithRTFDFileWrapper: (NSFileWrapper*)wrapper
documentAttributes: (NSDictionary**)dict;
- (id) initWithHTML: (NSData*)data documentAttributes: (NSDictionary**)dict;
- (id) initWithHTML: (NSData*)data baseURL: (NSURL*)base
documentAttributes: (NSDictionary**)dict;
- (id) initWithHTML: (NSData*)data
baseURL: (NSURL*)base
documentAttributes: (NSDictionary**)dict;
- (NSData*) RTFFromRange: (NSRange)range
documentAttributes: (NSDictionary*)dict;
documentAttributes: (NSDictionary*)dict;
- (NSData*) RTFDFromRange: (NSRange)range
documentAttributes: (NSDictionary*)dict;
documentAttributes: (NSDictionary*)dict;
- (NSFileWrapper*) RTFDFileWrapperFromRange: (NSRange)range
documentAttributes: (NSDictionary*)dict;
documentAttributes: (NSDictionary*)dict;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
+ (NSArray *) textFileTypes;
@ -108,6 +218,43 @@ enum
+ (NSArray *) textUnfilteredFileTypes;
+ (NSArray *) textUnfilteredPasteboardTypes;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
- (NSData *) docFormatFromRange: (NSRange)range
documentAttributes: (NSDictionary *)dict;
- (id) initWithDocFormat: (NSData *)data
documentAttributes: (NSDictionary **)dict;
- (id) initWithHTML: (NSData *)data
options: (NSDictionary *)options
documentAttributes: (NSDictionary **)dict;
- (unsigned) lineBreakByHyphenatingBeforeIndex: (unsigned)location
withinRange: (NSRange)aRange;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
- (NSData *) dataFromRange: (NSRange)range
documentAttributes: (NSDictionary *)dict
error: (NSError **)error;
- (NSFileWrapper *) fileWrapperFromRange: (NSRange)range
documentAttributes: (NSDictionary *)dict
error: (NSError **)error;
- (id) initWithData: (NSData *)data
options: (NSDictionary *)options
documentAttributes: (NSDictionary **)dict
error: (NSError **)error;
- (id) initWithURL: (NSURL *)url
options: (NSDictionary *)options
documentAttributes: (NSDictionary **)dict
error: (NSError **)error;
- (NSRange) itemNumberInTextList: (NSTextList *)list
atIndex: (unsigned)location;
- (NSRange) rangeOfTextBlock: (NSTextBlock *)block
atIndex: (unsigned)location;
- (NSRange) rangeOfTextList: (NSTextList *)list
atIndex: (unsigned)location;
- (NSRange) rangeOfTextTable: (NSTextTable *)table
atIndex: (unsigned)location;
#endif
@end
@interface NSMutableAttributedString (AppKit)
@ -122,9 +269,29 @@ enum
- (void) fixParagraphStyleAttributeInRange: (NSRange)range;
- (void) fixAttachmentAttributeInRange: (NSRange)range;
- (void) updateAttachmentsFromPath: (NSString *)path;
- (BOOL) readFromURL: (NSURL *)url
options: (NSDictionary *)options
documentAttributes: (NSDictionary**)documentAttributes;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
- (BOOL) readFromData: (NSData *)data
options: (NSDictionary *)options
documentAttributes: (NSDictionary **)documentAttributes;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
- (BOOL) readFromData: (NSData *)data
options: (NSDictionary *)options
documentAttributes: (NSDictionary **)documentAttributes
error: (NSError **)error;
- (BOOL) readFromURL: (NSURL *)url
options: (NSDictionary *)options
documentAttributes: (NSDictionary **)documentAttributes
error: (NSError **)error;
- (void) setBaseWritingDirection: (NSWritingDirection)writingDirection
range: (NSRange)range;
#endif
@end
#endif

View file

@ -35,6 +35,7 @@
{
id _target;
SEL _action;
BOOL _allowsCutCopyPaste;
}
- (NSImage *)image;
@ -49,6 +50,15 @@
- (void)setEditable:(BOOL)flag;
- (BOOL)isEditable;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
- (BOOL)animates;
- (void)setAnimates:(BOOL)flag;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
- (BOOL)allowsCutCopyPaste;
- (void)setAllowsCutCopyPaste:(BOOL)flag;
#endif
@end
#endif /* _GNUstep_H_NSImageView */

View file

@ -56,18 +56,37 @@ typedef enum _NSWritingDirection {
NSWritingDirectionRightToLeft
} NSWritingDirection;
@interface NSTextTab : NSObject <NSCopying>
#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
APPKIT_EXPORT NSString *NSTabColumnTerminatorsAttributeName;
#endif
@interface NSTextTab : NSObject <NSCopying, NSCoding>
{
NSTextTabType _tabStopType;
NSDictionary *_options;
NSTextAlignment _alignment;
float _location;
}
- (id) initWithType: (NSTextTabType)type location: (float)loc;
- (float) location;
- (NSTextTabType) tabStopType;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
- (id) initWithTextAlignment: (NSTextAlignment)align
location: (float)loc
options: (NSDictionary *)options;
- (NSTextAlignment) alignment;
- (NSDictionary *) options;
#endif
@end
@interface NSParagraphStyle : NSObject <NSCopying, NSMutableCopying, NSCoding>
{
NSMutableArray *_tabStops;
NSArray *_textBlocks;
NSArray *_textLists;
float _lineSpacing;
float _paragraphSpacing;
float _headIndent;
@ -75,10 +94,15 @@ typedef enum _NSWritingDirection {
float _firstLineHeadIndent;
float _minimumLineHeight;
float _maximumLineHeight;
NSMutableArray *_tabStops;
float _paragraphSpacingBefore;
float _defaultTabInterval;
float _hyphenationFactor;
float _lineHeightMultiple;
float _tighteningFactorForTruncation;
NSTextAlignment _alignment;
NSLineBreakMode _lineBreakMode;
NSWritingDirection _baseDirection;
int _headerLevel;
}
+ (NSParagraphStyle*) defaultParagraphStyle;
@ -146,6 +170,18 @@ typedef enum _NSWritingDirection {
+ (NSWritingDirection) defaultWritingDirectionForLanguage: (NSString*) language;
- (NSWritingDirection) baseWritingDirection;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
- (float) defaultTabInterval;
- (float) lineHeightMultiple;
- (float) paragraphSpacingBefore;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
- (int) headerLevel;
- (float) hyphenationFactor;
- (NSArray *) textBlocks;
- (NSArray *) textLists;
- (float) tighteningFactorForTruncation;
#endif
@end
@ -170,6 +206,19 @@ typedef enum _NSWritingDirection {
#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
- (void) setBaseWritingDirection: (NSWritingDirection)direction;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
- (void) setDefaultTabInterval: (float)interval;
- (void) setLineHeightMultiple: (float)factor;
- (void) setParagraphSpacingBefore: (float)spacing;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
- (void) setHeaderLevel: (int)level;
- (void) setHyphenationFactor: (float)factor;
- (void) setTextBlocks: (NSArray *)blocks;
- (void) setTextLists: (NSArray *)lists;
- (void) setTighteningFactorForTruncation: (float)factor;
#endif
@end
#endif // _GNUstep_H_NSParagraphStyle

View file

@ -38,7 +38,17 @@
#include <Foundation/NSString.h>
#include <Foundation/NSAttributedString.h>
#include <Foundation/NSGeometry.h>
#include <AppKit/NSAttributedString.h>
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
typedef enum
{
NSStringDrawingUsesLineFragmentOrigin=0x01,
NSStringDrawingUsesFontLeading=0x02,
NSStringDrawingDisableScreenFontSubstitution=0x04,
NSStringDrawingUsesDeviceMetrics=0x08,
NSStringDrawingOneShot=0x10
} NSStringDrawingOptions;
#endif
@interface NSString (NSStringDrawing)
@ -46,6 +56,15 @@
- (void) drawInRect: (NSRect)rect withAttributes: (NSDictionary*)attrs;
- (NSSize) sizeWithAttributes: (NSDictionary*)attrs;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
- (NSRect) boundingRectWithSize: (NSSize)size
options: (NSStringDrawingOptions)options
attributes: (NSDictionary *)attributes;
- (void) drawWithRect: (NSRect)rect
options: (NSStringDrawingOptions)options
attributes: (NSDictionary *)attributes;
#endif
@end
@interface NSAttributedString (NSStringDrawing)
@ -54,6 +73,13 @@
- (void) drawAtPoint: (NSPoint)point;
- (void) drawInRect: (NSRect)rect;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
- (NSRect) boundingRectWithSize: (NSSize)size
options: (NSStringDrawingOptions)options;
- (void) drawWithRect: (NSRect)rect
options: (NSStringDrawingOptions)options;
#endif
@end
#else

View file

@ -35,6 +35,7 @@
#include <AppKit/NSStringDrawing.h>
#include <AppKit/AppKitDefines.h>
@class NSNotification;
@class GSLayoutManager;
/*

View file

@ -34,6 +34,7 @@
#include <Foundation/NSLock.h>
#include <Foundation/NSValue.h>
#include "AppKit/NSAttributedString.h"
#include "AppKit/NSParagraphStyle.h"
#include "AppKit/NSTextAttachment.h"
#include "AppKit/NSTextContainer.h"

View file

@ -29,6 +29,7 @@
#include <Foundation/NSException.h>
#include <Foundation/NSValue.h>
#include "AppKit/NSAttributedString.h"
#include "AppKit/NSTextStorage.h"
#include "AppKit/NSTextContainer.h"

View file

@ -28,6 +28,7 @@
#include <Foundation/NSException.h>
#include "AppKit/NSApplication.h"
#include "AppKit/NSAttributedString.h"
#include "AppKit/NSButton.h"
#include "AppKit/NSImage.h"
#include "AppKit/NSParagraphStyle.h"

View file

@ -23,6 +23,10 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <Foundation/NSDebug.h>
#include <Foundation/NSRunLoop.h>
#include "AppKit/NSAttributedString.h"
#include <AppKit/NSView.h>
#include <AppKit/NSWindow.h>
#include <AppKit/NSPanel.h>
@ -33,10 +37,6 @@
#include <AppKit/NSApplication.h>
#include <GNUstepGUI/GSTitleView.h>
#include <Foundation/NSDebug.h>
#include <Foundation/NSRunLoop.h>
#include "GNUstepGUI/GSTheme.h"
@implementation GSTitleView

View file

@ -720,6 +720,101 @@ documentAttributes: (NSDictionary **)dict
documentAttributes: dict];
}
- (id) initWithDocFormat: (NSData *)data
documentAttributes: (NSDictionary **)dict
{
// FIXME
RELEASE(self);
return nil;
}
- (id) initWithHTML: (NSData *)data
options: (NSDictionary *)options
documentAttributes: (NSDictionary **)dict
{
// FIXME
RELEASE(self);
return nil;
}
- (id) initWithData: (NSData *)data
options: (NSDictionary *)options
documentAttributes: (NSDictionary **)dict
error: (NSError **)error
{
// FIXME
RELEASE(self);
return nil;
}
- (id) initWithURL: (NSURL *)url
options: (NSDictionary *)options
documentAttributes: (NSDictionary **)dict
error: (NSError **)error
{
// FIXME
RELEASE(self);
return nil;
}
- (NSData *) docFormatFromRange: (NSRange)range
documentAttributes: (NSDictionary *)dict
{
// FIXME
return nil;
}
- (NSData *) dataFromRange: (NSRange)range
documentAttributes: (NSDictionary *)dict
error: (NSError **)error
{
// FIXME
return nil;
}
- (NSFileWrapper *) fileWrapperFromRange: (NSRange)range
documentAttributes: (NSDictionary *)dict
error: (NSError **)error
{
// FIXME
return nil;
}
- (unsigned) lineBreakByHyphenatingBeforeIndex: (unsigned)location
withinRange: (NSRange)aRange
{
// FIXME
return NSNotFound;
}
- (NSRange) itemNumberInTextList: (NSTextList *)list
atIndex: (unsigned)location
{
// FIXME
return NSMakeRange(NSNotFound, 0);
}
- (NSRange) rangeOfTextBlock: (NSTextBlock *)block
atIndex: (unsigned)location
{
// FIXME
return NSMakeRange(NSNotFound, 0);
}
- (NSRange) rangeOfTextList: (NSTextList *)list
atIndex: (unsigned)location
{
// FIXME
return NSMakeRange(NSNotFound, 0);
}
- (NSRange) rangeOfTextTable: (NSTextTable *)table
atIndex: (unsigned)location
{
// FIXME
return NSMakeRange(NSNotFound, 0);
}
@end
@implementation NSMutableAttributedString (AppKit)
@ -1081,6 +1176,17 @@ documentAttributes: (NSDictionary **)dict
- (BOOL) readFromURL: (NSURL *)url
options: (NSDictionary *)options
documentAttributes: (NSDictionary**)documentAttributes
{
return [self readFromURL: url
options: options
documentAttributes: documentAttributes
error: NULL];
}
- (BOOL) readFromURL: (NSURL *)url
options: (NSDictionary *)options
documentAttributes: (NSDictionary **)documentAttributes
error: (NSError **)error
{
NSString *extension;
NSString *type;
@ -1159,4 +1265,32 @@ documentAttributes: (NSDictionary **)dict
return NO;
}
- (BOOL) readFromData: (NSData *)data
options: (NSDictionary *)options
documentAttributes: (NSDictionary **)documentAttributes
{
return [self readFromData: data
options: options
documentAttributes: documentAttributes
error: NULL];
}
- (BOOL) readFromData: (NSData *)data
options: (NSDictionary *)options
documentAttributes: (NSDictionary **)documentAttributes
error: (NSError **)error
{
// FIXME
return NO;
}
- (void) setBaseWritingDirection: (NSWritingDirection)writingDirection
range: (NSRange)range
{
[self setAttributes: [NSDictionary dictionaryWithObject:
[NSNumber numberWithInt: writingDirection]
forKey: @"WritingDirection"]
range: range];
}
@end

View file

@ -147,6 +147,27 @@ static Class imageCellClass;
return [_cell isEditable];
}
- (BOOL) animates
{
// FIXME: Should be passed on to cell.
return NO;
}
- (void) setAnimates: (BOOL) flag
{
// FIXME: Should be passed on to cell.
}
- (BOOL) allowsCutCopyPaste
{
return _allowsCutCopyPaste;
}
- (void) setAllowsCutCopyPaste: (BOOL)flag
{
_allowsCutCopyPaste = flag;
}
@end
@implementation NSImageView (NSDraggingDestination)

View file

@ -108,6 +108,7 @@ first. Remaining cases, highest priority first:
#include "GNUstepGUI/GSLayoutManager_internal.h"
#include <Foundation/NSException.h>
#include "AppKit/NSAttributedString.h"
#include "AppKit/NSColor.h"
#include "AppKit/NSImage.h"
#include "AppKit/NSParagraphStyle.h"

View file

@ -34,6 +34,7 @@
#include <Foundation/NSString.h>
#include <Foundation/NSUserDefaults.h>
#include "AppKit/NSAttributedString.h"
#include "AppKit/NSColor.h"
#include "AppKit/NSFont.h"
#include "AppKit/NSGraphics.h"

View file

@ -35,21 +35,92 @@
@implementation NSTextTab
- (id) copyWithZone: (NSZone*)aZone
{
if (NSShouldRetainWithZone(self, aZone) == YES)
return RETAIN(self);
return NSCopyObject(self, 0, aZone);
}
- (id) initWithType: (NSTextTabType)type location: (float)loc
{
self = [super init];
_tabStopType = type;
_location = loc;
if ((self = [super init]))
{
_tabStopType = type;
_location = loc;
switch (type)
{
default:
case NSLeftTabStopType:
_alignment = NSLeftTextAlignment;
break;
case NSRightTabStopType:
_alignment = NSRightTextAlignment;
break;
case NSCenterTabStopType:
_alignment = NSCenterTextAlignment;
break;
case NSDecimalTabStopType:
_alignment = NSRightTextAlignment;
break;
}
}
return self;
}
- (id) initWithTextAlignment: (NSTextAlignment)align
location: (float)loc
options: (NSDictionary *)options
{
NSTextTabType type;
switch (align)
{
default:
case NSLeftTextAlignment:
type = NSLeftTabStopType;
break;
case NSRightTextAlignment:
if ([options objectForKey: NSTabColumnTerminatorsAttributeName] != nil)
{
type = NSDecimalTabStopType;
}
else
{
type = NSRightTabStopType;
}
break;
case NSCenterTextAlignment:
type = NSCenterTabStopType;
break;
case NSJustifiedTextAlignment:
type = NSLeftTabStopType;
break;
case NSNaturalTextAlignment:
// FIXME: Get from language user setting
type = YES ? NSLeftTabStopType : NSRightTabStopType;
break;
}
if ((self = [self initWithType: type location: loc]))
{
_alignment = align;
ASSIGN(_options, options);
}
return self;
}
- (void) dealloc;
{
RELEASE(_options);
[super dealloc];
}
- (id) copyWithZone: (NSZone*)aZone
{
NSTextTab *copy;
if (NSShouldRetainWithZone(self, aZone) == YES)
return RETAIN(self);
copy = (NSTextTab *)NSCopyObject(self, 0, aZone);
copy->_options = [_options copyWithZone: aZone];
return copy;
}
- (NSComparisonResult) compare: (id)anObject
{
float loc;
@ -97,6 +168,41 @@
{
return _tabStopType;
}
- (NSTextAlignment) alignment
{
return _alignment;
}
- (NSDictionary *) options
{
return _options;
}
- (id) initWithCoder: (NSCoder *)aCoder
{
if ([aCoder allowsKeyedCoding])
{
_location = [aCoder decodeFloatForKey: @"NSLocation"];
}
else
{
// FIXME
}
return self;
}
- (void) encodeWithCoder: (NSCoder *)aCoder
{
if ([aCoder allowsKeyedCoding])
{
[aCoder encodeFloat: _location forKey: @"NSLocation"];
}
else
{
// FIXME
}
}
@end
@ -177,25 +283,29 @@ static NSParagraphStyle *defaultStyle = nil;
NSLog(@"Argh - attempt to dealloc the default paragraph style!");
return;
}
RELEASE (_tabStops);
RELEASE(_tabStops);
RELEASE(_textBlocks);
RELEASE(_textLists);
[super dealloc];
}
- (id) init
{
self = [super init];
_alignment = NSNaturalTextAlignment;
_firstLineHeadIndent = 0.0;
_headIndent = 0.0;
_lineBreakMode = NSLineBreakByWordWrapping;
_lineSpacing = 0.0;
_maximumLineHeight = 0.0;
_minimumLineHeight = 0.0;
_paragraphSpacing = 0.0;
_tailIndent = 0.0;
_baseDirection = NSWritingDirectionNaturalDirection;
_tabStops = [[NSMutableArray allocWithZone: [self zone]]
initWithCapacity: 12];
if ((self = [super init]))
{
_alignment = NSNaturalTextAlignment;
//_firstLineHeadIndent = 0.0;
//_headIndent = 0.0;
_lineBreakMode = NSLineBreakByWordWrapping;
//_lineSpacing = 0.0;
//_maximumLineHeight = 0.0;
//_minimumLineHeight = 0.0;
//_paragraphSpacing = 0.0;
//_tailIndent = 0.0;
_baseDirection = NSWritingDirectionNaturalDirection;
_tabStops = [[NSMutableArray allocWithZone: [self zone]]
initWithCapacity: 12];
}
return self;
}
@ -289,6 +399,46 @@ static NSParagraphStyle *defaultStyle = nil;
return _baseDirection;
}
- (float) defaultTabInterval
{
return _defaultTabInterval;
}
- (float) lineHeightMultiple
{
return _lineHeightMultiple;
}
- (float) paragraphSpacingBefore
{
return _paragraphSpacingBefore;
}
- (int) headerLevel;
{
return _headerLevel;
}
- (float) hyphenationFactor;
{
return _hyphenationFactor;
}
- (NSArray *) textBlocks;
{
return _textBlocks;
}
- (NSArray *) textLists;
{
return _textLists;
}
- (float) tighteningFactorForTruncation;
{
return _tighteningFactorForTruncation;
}
- (id) copyWithZone: (NSZone*)aZone
{
if (NSShouldRetainWithZone (self, aZone) == YES)
@ -339,33 +489,34 @@ static NSParagraphStyle *defaultStyle = nil;
[aCoder decodeValueOfObjCType: @encode(unsigned) at: &count];
_tabStops = [[NSMutableArray alloc] initWithCapacity: count];
if (count > 0)
{
float locations[count];
NSTextTabType types[count];
unsigned i;
[aCoder decodeArrayOfObjCType: @encode(float)
count: count
at: locations];
[aCoder decodeArrayOfObjCType: @encode(NSTextTabType)
count: count
at: types];
for (i = 0; i < count; i++)
{
NSTextTab *tab;
tab = [NSTextTab alloc];
tab = [tab initWithType: types[i] location: locations[i]];
[_tabStops addObject: tab];
RELEASE (tab);
}
}
{
float locations[count];
NSTextTabType types[count];
unsigned i;
[aCoder decodeArrayOfObjCType: @encode(float)
count: count
at: locations];
[aCoder decodeArrayOfObjCType: @encode(NSTextTabType)
count: count
at: types];
for (i = 0; i < count; i++)
{
NSTextTab *tab;
tab = [[NSTextTab alloc] initWithType: types[i]
location: locations[i]];
[_tabStops addObject: tab];
RELEASE(tab);
}
}
if ([aCoder versionForClassName: @"NSParagraphStyle"] >= 2)
{
[aCoder decodeValueOfObjCType: @encode(int) at: &_baseDirection];
}
{
[aCoder decodeValueOfObjCType: @encode(int) at: &_baseDirection];
}
}
return self;
}
@ -396,25 +547,25 @@ static NSParagraphStyle *defaultStyle = nil;
count = [_tabStops count];
[aCoder encodeValueOfObjCType: @encode(unsigned) at: &count];
if (count > 0)
{
float locations[count];
NSTextTabType types[count];
unsigned i;
for (i = 0; i < count; i++)
{
NSTextTab *tab = [_tabStops objectAtIndex: i];
locations[i] = [tab location];
types[i] = [tab tabStopType];
}
[aCoder encodeArrayOfObjCType: @encode(float)
count: count
at: locations];
[aCoder encodeArrayOfObjCType: @encode(NSTextTabType)
count: count
at: types];
}
{
float locations[count];
NSTextTabType types[count];
unsigned i;
for (i = 0; i < count; i++)
{
NSTextTab *tab = [_tabStops objectAtIndex: i];
locations[i] = [tab location];
types[i] = [tab tabStopType];
}
[aCoder encodeArrayOfObjCType: @encode(float)
count: count
at: locations];
[aCoder encodeArrayOfObjCType: @encode(NSTextTabType)
count: count
at: types];
}
[aCoder encodeValueOfObjCType: @encode(int) at: &_baseDirection];
}
@ -438,7 +589,12 @@ static NSParagraphStyle *defaultStyle = nil;
C(_maximumLineHeight);
C(_alignment);
C(_lineBreakMode);
C(_baseDirection);
C(_paragraphSpacingBefore);
C(_defaultTabInterval);
C(_hyphenationFactor);
C(_lineHeightMultiple);
C(_tighteningFactorForTruncation);
C(_headerLevel);
#undef C
return [_tabStops isEqualToArray: other->_tabStops];
@ -530,6 +686,46 @@ static NSParagraphStyle *defaultStyle = nil;
_baseDirection = direction;
}
- (void) setDefaultTabInterval: (float)interval
{
_defaultTabInterval = interval;
}
- (void) setLineHeightMultiple: (float)factor
{
_lineHeightMultiple = factor;
}
- (void) setParagraphSpacingBefore: (float)spacing
{
_paragraphSpacingBefore = spacing;
}
- (void) setHeaderLevel: (int)level
{
_headerLevel = level;
}
- (void) setHyphenationFactor: (float)factor
{
_hyphenationFactor = factor;
}
- (void) setTextBlocks: (NSArray *)blocks
{
ASSIGN(_textBlocks, blocks);
}
- (void) setTextLists: (NSArray *)lists
{
ASSIGN(_textLists, lists);
}
- (void) setTighteningFactorForTruncation: (float)factor
{
_tighteningFactorForTruncation = factor;
}
- (void) addTabStop: (NSTextTab*)anObject
{
unsigned count = [_tabStops count];
@ -594,6 +790,12 @@ static NSParagraphStyle *defaultStyle = nil;
_paragraphSpacing = p->_paragraphSpacing;
_tailIndent = p->_tailIndent;
_baseDirection = p->_baseDirection;
_paragraphSpacingBefore = p->_paragraphSpacingBefore;
_defaultTabInterval = p->_defaultTabInterval;
_hyphenationFactor = p->_hyphenationFactor;
_lineHeightMultiple = p->_lineHeightMultiple;
_tighteningFactorForTruncation = p->_tighteningFactorForTruncation;
_headerLevel = p->_headerLevel;
}
- (id) copyWithZone: (NSZone*)aZone

View file

@ -487,6 +487,13 @@ glyphs to be drawn upside-down, so we need to tell NSFont to flip the fonts.
}
}
- (void) drawWithRect:(NSRect)rect
options:(NSStringDrawingOptions)options
{
// FIXME: This ignores options
[self drawInRect: rect];
}
- (NSSize) size
{
int ci;
@ -499,6 +506,21 @@ glyphs to be drawn upside-down, so we need to tell NSFont to flip the fonts.
return cache[ci].usedRect.size;
}
- (NSRect) boundingRectWithSize: (NSSize)size
options: (NSStringDrawingOptions)options
{
int ci;
// FIXME: This ignores options
ci = cache_lookup_attributed_string(self, 1, size, 1);
/*
An argument could be made for using NSMaxX/NSMaxY here, but that fails
horribly on right-aligned strings. For now, we handle that case in a
useful way and ignore indents.
*/
return cache[ci].usedRect;
}
@end
/*
@ -614,6 +636,14 @@ NSAttributedString to do the job.
}
}
- (void) drawWithRect: (NSRect)rect
options: (NSStringDrawingOptions)options
attributes: (NSDictionary *)attributes
{
// FIXME: This ignores options
[self drawInRect: rect withAttributes: attributes];
}
- (NSSize) sizeWithAttributes: (NSDictionary *)attrs
{
int ci;
@ -626,6 +656,22 @@ NSAttributedString to do the job.
return cache[ci].usedRect.size;
}
- (NSRect) boundingRectWithSize: (NSSize)size
options: (NSStringDrawingOptions)options
attributes: (NSDictionary *)attributes
{
int ci;
// FIXME: This ignores options
ci = cache_lookup_string(self, attributes, 1, size, 1);
/*
An argument could be made for using NSMaxX/NSMaxY here, but that fails
horribly on right-aligned strings (which may be the right thing). For now,
we handle that case in a useful way and ignore indents.
*/
return cache[ci].usedRect;
}
@end

View file

@ -37,6 +37,7 @@
#include "AppKit/NSText.h"
#include "AppKit/NSAttributedString.h"
#include "AppKit/NSPanel.h"
#include "AppKit/NSSpellChecker.h"
#include "AppKit/NSTextView.h"

View file

@ -59,6 +59,7 @@
#include <Foundation/NSUndoManager.h>
#include <Foundation/NSValue.h>
#include "AppKit/NSApplication.h"
#include "AppKit/NSAttributedString.h"
#include "AppKit/NSClipView.h"
#include "AppKit/NSColor.h"
#include "AppKit/NSColorPanel.h"

View file

@ -47,6 +47,7 @@
#include <Foundation/NSNotification.h>
#include <Foundation/NSValue.h>
#include "AppKit/NSAttributedString.h"
#include "AppKit/NSGraphics.h"
#include "AppKit/NSLayoutManager.h"
#include "AppKit/NSScrollView.h"

View file

@ -35,6 +35,7 @@
#include <Foundation/NSException.h>
#include <Foundation/NSString.h>
#include "AppKit/NSApplication.h"
#include "AppKit/NSAttributedString.h"
#include "AppKit/NSButton.h"
#include "AppKit/NSButtonCell.h"
#include "AppKit/NSDragging.h"

View file

@ -453,6 +453,62 @@ NSString *NSToolTipAttributeName = @"NSToolTipAttributeName";
NSString *NSUnderlineColorAttributeName = @"NSUnderlineColorAttributeName";
NSString *NSUnderlineStyleAttributeName = @"NSUnderlineStyleAttributeName";
NSString *NSCharacterShapeAttributeName = @"CharacterShape";
NSString *NSGlyphInfoAttributeName = @"GlyphInfo";
NSString *NSPaperSizeDocumentAttribute = @"PaperSize";
NSString *NSLeftMarginDocumentAttribute = @"LeftMargin";
NSString *NSRightMarginDocumentAttribute = @"RightMargin";
NSString *NSTopMarginDocumentAttribute = @"TopMargin";
NSString *NSBottomMarginDocumentAttribute = @"BottomMargin";
NSString *NSHyphenationFactorDocumentAttribute = @"HyphenationFactor";
NSString *NSDocumentTypeDocumentAttribute = @"DocumentType";
NSString *NSCharacterEncodingDocumentAttribute = @"CharacterEncoding";
NSString *NSViewSizeDocumentAttribute = @"ViewSize";
NSString *NSViewZoomDocumentAttribute = @"ViewZoom";
NSString *NSViewModeDocumentAttribute = @"ViewMode";
NSString *NSBackgroundColorDocumentAttribute = @"BackgroundColor";
NSString *NSCocoaVersionDocumentAttribute = @"CocoaVersion";
NSString *NSReadOnlyDocumentAttribute = @"ReadOnly";
NSString *NSConvertedDocumentAttribute = @"Converted";
NSString *NSDefaultTabIntervalDocumentAttribute = @"DefaultTabInterval";
NSString *NSTitleDocumentAttribute = @"Title";
NSString *NSCompanyDocumentAttribute = @"Company";
NSString *NSCopyrightDocumentAttribute = @"Copyright";
NSString *NSSubjectDocumentAttribute = @"Subject";
NSString *NSAuthorDocumentAttribute = @"Author";
NSString *NSKeywordsDocumentAttribute = @"Keywords";
NSString *NSCommentDocumentAttribute = @"Comment";
NSString *NSEditorDocumentAttribute = @"Editor";
NSString *NSCreationTimeDocumentAttribute = @"CreationTime";
NSString *NSModificationTimeDocumentAttribute = @"ModificationTime";
const unsigned NSUnderlineByWordMask = 0x01;
NSString *NSPlainTextDocumentType = @"PlainText";
NSString *NSRTFTextDocumentType = @"RTF";
NSString *NSRTFDTextDocumentType = @"RTFD";
NSString *NSMacSimpleTextDocumentType = @"SimpleText";
NSString *NSHTMLTextDocumentType = @"HTML";
NSString *NSDocFormatTextDocumentType = @"Doc";
NSString *NSWordMLTextDocumentType = @"WordML";
NSString *NSExcludedElementsDocumentAttribute = @"ExcludedElements";
NSString *NSTextEncodingNameDocumentAttribute = @"TextEncoding";
NSString *NSPrefixSpacesDocumentAttribute = @"PrefixSpaces";
NSString *NSBaseURLDocumentOption = @"BaseURL";
NSString *NSCharacterEncodingDocumentOption = @"CharacterEncoding";
NSString *NSDefaultAttributesDocumentOption = @"DefaultAttributes";
NSString *NSDocumentTypeDocumentOption = @"DocumentType";
NSString *NSTextEncodingNameDocumentOption = @"TextEncoding";
NSString *NSTextSizeMultiplierDocumentOption = @"TextSizeMultiplier";
NSString *NSTimeoutDocumentOption = @"Timeout";
NSString *NSWebPreferencesDocumentOption = @"WebPreferences";
NSString *NSWebResourceLoadDelegateDocumentOption = @"WebResourceLoadDelegate";
// NSTextTab
NSString *NSTabColumnTerminatorsAttributeName = @"TabColumnTerminatorsAttributeName";
// NSToolbar notifications
NSString *NSToolbarDidRemoveItemNotification = @"NSToolbarDidRemoveItemNotification";