2001-12-17 16:51:51 +00:00
|
|
|
|
/** <title>NSParagraphStyle</title>
|
1998-09-01 13:23:23 +00:00
|
|
|
|
|
2001-12-17 16:51:51 +00:00
|
|
|
|
<abstract>NSParagraphStyle and NSMutableParagraphStyle hold paragraph style
|
|
|
|
|
information NSTextTab holds information about a single tab stop</abstract>
|
1998-09-01 13:23:23 +00:00
|
|
|
|
|
|
|
|
|
Copyright (C) 1996 Free Software Foundation, Inc.
|
|
|
|
|
|
2001-12-17 16:51:51 +00:00
|
|
|
|
Author: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
|
|
|
|
Date March 1999
|
1998-09-01 13:23:23 +00:00
|
|
|
|
|
|
|
|
|
This file is part of the GNUstep GUI Library.
|
|
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
2007-10-29 21:16:17 +00:00
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
1998-09-01 13:23:23 +00:00
|
|
|
|
License as published by the Free Software Foundation; either
|
2008-06-10 04:01:49 +00:00
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
2007-10-29 21:16:17 +00:00
|
|
|
|
|
1998-09-01 13:23:23 +00:00
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2007-10-29 21:16:17 +00:00
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
Lesser General Public License for more details.
|
1998-09-01 13:23:23 +00:00
|
|
|
|
|
2007-10-29 21:16:17 +00:00
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
1998-09-01 13:23:23 +00:00
|
|
|
|
License along with this library; see the file COPYING.LIB.
|
2007-10-29 21:16:17 +00:00
|
|
|
|
If not, see <http://www.gnu.org/licenses/> or write to the
|
|
|
|
|
Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
|
|
|
|
Boston, MA 02110-1301, USA.
|
1998-09-01 13:23:23 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2011-03-29 21:59:57 +00:00
|
|
|
|
#import <Foundation/NSDictionary.h>
|
2011-03-04 11:33:22 +00:00
|
|
|
|
#import <Foundation/NSException.h>
|
|
|
|
|
#import "AppKit/NSParagraphStyle.h"
|
1998-09-01 13:23:23 +00:00
|
|
|
|
|
|
|
|
|
@implementation NSTextTab
|
1999-03-09 20:34:33 +00:00
|
|
|
|
|
2013-02-17 00:49:04 +00:00
|
|
|
|
- (id) initWithType: (NSTextTabType)type location: (CGFloat)loc
|
2007-06-18 21:08:54 +00:00
|
|
|
|
{
|
|
|
|
|
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
|
2013-02-17 00:49:04 +00:00
|
|
|
|
location: (CGFloat)loc
|
2007-06-18 21:08:54 +00:00
|
|
|
|
options: (NSDictionary *)options
|
|
|
|
|
{
|
2009-08-25 07:46:37 +00:00
|
|
|
|
NSTextTabType type;
|
2007-06-18 21:08:54 +00:00
|
|
|
|
|
|
|
|
|
switch (align)
|
|
|
|
|
{
|
2009-08-25 07:46:37 +00:00
|
|
|
|
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;
|
2007-06-18 21:08:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-08-25 07:46:37 +00:00
|
|
|
|
if ((self = [self initWithType: type location: loc]))
|
|
|
|
|
{
|
2007-06-18 21:08:54 +00:00
|
|
|
|
_alignment = align;
|
|
|
|
|
ASSIGN(_options, options);
|
2009-08-25 07:46:37 +00:00
|
|
|
|
}
|
|
|
|
|
return self;
|
2007-06-18 21:08:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-08-25 07:46:37 +00:00
|
|
|
|
- (void) dealloc
|
2007-06-18 21:08:54 +00:00
|
|
|
|
{
|
2009-08-25 07:46:37 +00:00
|
|
|
|
RELEASE(_options);
|
|
|
|
|
[super dealloc];
|
2007-06-18 21:08:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-09 20:34:33 +00:00
|
|
|
|
- (id) copyWithZone: (NSZone*)aZone
|
|
|
|
|
{
|
2007-06-18 21:08:54 +00:00
|
|
|
|
NSTextTab *copy;
|
|
|
|
|
|
1999-03-09 20:34:33 +00:00
|
|
|
|
if (NSShouldRetainWithZone(self, aZone) == YES)
|
2000-12-07 00:23:45 +00:00
|
|
|
|
return RETAIN(self);
|
1999-03-09 20:34:33 +00:00
|
|
|
|
|
2007-06-18 21:08:54 +00:00
|
|
|
|
copy = (NSTextTab *)NSCopyObject(self, 0, aZone);
|
|
|
|
|
copy->_options = [_options copyWithZone: aZone];
|
|
|
|
|
return copy;
|
1999-03-09 20:34:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-09 21:38:49 +00:00
|
|
|
|
- (NSComparisonResult) compare: (id)anObject
|
|
|
|
|
{
|
|
|
|
|
float loc;
|
|
|
|
|
|
|
|
|
|
if (anObject == self)
|
|
|
|
|
return NSOrderedSame;
|
2011-05-25 11:19:09 +00:00
|
|
|
|
if (anObject == nil || ([anObject isKindOfClass: object_getClass(self)] == NO))
|
1999-03-09 21:38:49 +00:00
|
|
|
|
return NSOrderedAscending;
|
2000-12-12 21:14:00 +00:00
|
|
|
|
loc = ((NSTextTab*)anObject)->_location;
|
2002-11-02 23:17:23 +00:00
|
|
|
|
if (_location < loc)
|
1999-03-09 21:38:49 +00:00
|
|
|
|
return NSOrderedAscending;
|
2002-11-02 23:17:23 +00:00
|
|
|
|
else if (_location > loc)
|
1999-03-09 21:38:49 +00:00
|
|
|
|
return NSOrderedDescending;
|
|
|
|
|
else
|
|
|
|
|
return NSOrderedSame;
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-16 02:51:30 +00:00
|
|
|
|
- (NSUInteger) hash
|
1999-03-09 20:34:33 +00:00
|
|
|
|
{
|
2013-02-17 00:49:04 +00:00
|
|
|
|
NSUInteger val = (NSUInteger)_location;
|
1999-03-09 20:34:33 +00:00
|
|
|
|
|
2013-02-17 00:49:04 +00:00
|
|
|
|
val ^= (NSUInteger)_tabStopType;
|
1999-03-09 20:34:33 +00:00
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) isEqual: (id)anObject
|
|
|
|
|
{
|
|
|
|
|
if (anObject == self)
|
|
|
|
|
return YES;
|
2011-05-25 11:19:09 +00:00
|
|
|
|
if ([anObject isKindOfClass: object_getClass(self)] == NO)
|
1999-03-09 20:34:33 +00:00
|
|
|
|
return NO;
|
2000-12-12 21:14:00 +00:00
|
|
|
|
else if (((NSTextTab*)anObject)->_tabStopType != _tabStopType)
|
1999-03-09 20:34:33 +00:00
|
|
|
|
return NO;
|
2000-12-12 21:14:00 +00:00
|
|
|
|
else if (((NSTextTab*)anObject)->_location != _location)
|
1999-03-09 20:34:33 +00:00
|
|
|
|
return NO;
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-17 00:49:04 +00:00
|
|
|
|
- (CGFloat) location
|
1999-03-09 20:34:33 +00:00
|
|
|
|
{
|
2000-12-12 21:14:00 +00:00
|
|
|
|
return _location;
|
1999-03-09 20:34:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSTextTabType) tabStopType
|
|
|
|
|
{
|
2000-12-12 21:14:00 +00:00
|
|
|
|
return _tabStopType;
|
1998-09-01 13:23:23 +00:00
|
|
|
|
}
|
2007-06-18 21:08:54 +00:00
|
|
|
|
- (NSTextAlignment) alignment
|
|
|
|
|
{
|
|
|
|
|
return _alignment;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSDictionary *) options
|
|
|
|
|
{
|
|
|
|
|
return _options;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) initWithCoder: (NSCoder *)aCoder
|
|
|
|
|
{
|
|
|
|
|
if ([aCoder allowsKeyedCoding])
|
|
|
|
|
{
|
|
|
|
|
_location = [aCoder decodeFloatForKey: @"NSLocation"];
|
* Source/NSEvent.m,
* Source/NSParagraphStyle.m: Use NSInteger instead of enumerator
type name for decoding and encoding.
* Header/AppKit/NSFontPanel.h,
* Header/AppKit/NSOpenPanel.h,
* Header/AppKit/NSDataLinkPanel.h,
* Source/NSDataLinkPanel.m,
* Header/AppKit/NSForm.h,
* Source/NSForm.m,
* Header/AppKit/NSHelpPanel.h,
* Source/NSHelpPanel.m,
* Source/NSColorPanel.m: Remove unused encoding/decoding
* methods.
* Source/NSCustomImageRep.m,
* Source/NSEPSImageRep.m,
* Source/NSMovie.m,
* Source/NSRulerMarker.m,
* Source/NSColorList.m: Flag missing keyed encoding/decoding.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36377 72102866-910b-0410-8b05-ffd578937521
2013-03-17 19:53:50 +00:00
|
|
|
|
}
|
2007-06-18 21:08:54 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
* Source/NSEvent.m,
* Source/NSParagraphStyle.m: Use NSInteger instead of enumerator
type name for decoding and encoding.
* Header/AppKit/NSFontPanel.h,
* Header/AppKit/NSOpenPanel.h,
* Header/AppKit/NSDataLinkPanel.h,
* Source/NSDataLinkPanel.m,
* Header/AppKit/NSForm.h,
* Source/NSForm.m,
* Header/AppKit/NSHelpPanel.h,
* Source/NSHelpPanel.m,
* Source/NSColorPanel.m: Remove unused encoding/decoding
* methods.
* Source/NSCustomImageRep.m,
* Source/NSEPSImageRep.m,
* Source/NSMovie.m,
* Source/NSRulerMarker.m,
* Source/NSColorList.m: Flag missing keyed encoding/decoding.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36377 72102866-910b-0410-8b05-ffd578937521
2013-03-17 19:53:50 +00:00
|
|
|
|
// FIXME
|
2007-06-18 21:08:54 +00:00
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) encodeWithCoder: (NSCoder *)aCoder
|
|
|
|
|
{
|
|
|
|
|
if ([aCoder allowsKeyedCoding])
|
|
|
|
|
{
|
|
|
|
|
[aCoder encodeFloat: _location forKey: @"NSLocation"];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
* Source/NSEvent.m,
* Source/NSParagraphStyle.m: Use NSInteger instead of enumerator
type name for decoding and encoding.
* Header/AppKit/NSFontPanel.h,
* Header/AppKit/NSOpenPanel.h,
* Header/AppKit/NSDataLinkPanel.h,
* Source/NSDataLinkPanel.m,
* Header/AppKit/NSForm.h,
* Source/NSForm.m,
* Header/AppKit/NSHelpPanel.h,
* Source/NSHelpPanel.m,
* Source/NSColorPanel.m: Remove unused encoding/decoding
* methods.
* Source/NSCustomImageRep.m,
* Source/NSEPSImageRep.m,
* Source/NSMovie.m,
* Source/NSRulerMarker.m,
* Source/NSColorList.m: Flag missing keyed encoding/decoding.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36377 72102866-910b-0410-8b05-ffd578937521
2013-03-17 19:53:50 +00:00
|
|
|
|
// FIXME
|
2007-06-18 21:08:54 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1998-09-01 13:23:23 +00:00
|
|
|
|
@end
|
|
|
|
|
|
1999-03-09 20:34:33 +00:00
|
|
|
|
|
|
|
|
|
|
1998-09-01 13:23:23 +00:00
|
|
|
|
@implementation NSParagraphStyle
|
|
|
|
|
|
1999-03-09 20:34:33 +00:00
|
|
|
|
static NSParagraphStyle *defaultStyle = nil;
|
|
|
|
|
|
|
|
|
|
+ (NSParagraphStyle*) defaultParagraphStyle
|
1998-09-01 13:23:23 +00:00
|
|
|
|
{
|
1999-03-09 20:34:33 +00:00
|
|
|
|
if (defaultStyle == nil)
|
|
|
|
|
{
|
|
|
|
|
NSParagraphStyle *style = [[self alloc] init];
|
2000-12-12 21:14:00 +00:00
|
|
|
|
defaultStyle = style;
|
1999-03-09 20:34:33 +00:00
|
|
|
|
}
|
|
|
|
|
return defaultStyle;
|
1998-09-01 13:23:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-04-26 16:51:21 +00:00
|
|
|
|
+ (void) initialize
|
|
|
|
|
{
|
|
|
|
|
if (self == [NSParagraphStyle class])
|
|
|
|
|
{
|
|
|
|
|
/* Set the class version to 2, as the writing direction is now
|
|
|
|
|
stored in the encoding */
|
2013-05-17 15:50:53 +00:00
|
|
|
|
[self setVersion: 3];
|
2003-04-26 16:51:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+ (NSWritingDirection) defaultWritingDirectionForLanguage: (NSString*) language
|
|
|
|
|
{
|
2004-05-12 14:54:08 +00:00
|
|
|
|
static NSArray *rightToLeft;
|
|
|
|
|
NSWritingDirection writingDirection;
|
|
|
|
|
NSString *langCode = nil;
|
|
|
|
|
|
|
|
|
|
/* If language is 5/6 characters long with underscore in the middle,
|
|
|
|
|
treat it as ISO language-region format. */
|
|
|
|
|
if ([language length] == 5 && [language characterAtIndex: 2] == '_')
|
|
|
|
|
langCode = [language substringToIndex: 2];
|
|
|
|
|
else if ([language length] == 6 && [language characterAtIndex: 3] == '_')
|
|
|
|
|
langCode = [language substringToIndex: 3];
|
|
|
|
|
/* Else if it's just two or three chars long, treat as ISO 639 code. */
|
|
|
|
|
else if ([language length] == 2 || [language length] == 3)
|
|
|
|
|
langCode = language;
|
|
|
|
|
|
|
|
|
|
if (!rightToLeft)
|
|
|
|
|
// Holds languages whose current scripts are written right to left.
|
|
|
|
|
rightToLeft = [[NSArray alloc] initWithObjects: @"ar", @"ara", @"arc",
|
|
|
|
|
@"chi", @"fa", @"fas", @"he", @"heb", @"iw",
|
|
|
|
|
@"ji", @"kas", @"ks", @"ku", @"kur", @"pa",
|
|
|
|
|
@"pan", @"per" @"ps", @"pus", @"sd", @"snd",
|
|
|
|
|
@"syr", @"tk", @"tmh", @"tuk", @"ug",
|
|
|
|
|
@"uig", @"ur," @"urd", @"yi", @"yid", @"zh",
|
|
|
|
|
@"zho", nil];
|
|
|
|
|
if ([rightToLeft containsObject: langCode] == YES)
|
|
|
|
|
writingDirection = NSWritingDirectionRightToLeft;
|
|
|
|
|
else // If it's not RTL, assume LTR.
|
|
|
|
|
writingDirection = NSWritingDirectionLeftToRight;
|
|
|
|
|
|
|
|
|
|
return writingDirection;
|
2003-04-26 16:51:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-09 20:34:33 +00:00
|
|
|
|
- (void) dealloc
|
1998-09-01 13:23:23 +00:00
|
|
|
|
{
|
1999-03-09 20:34:33 +00:00
|
|
|
|
if (self == defaultStyle)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Argh - attempt to dealloc the default paragraph style!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2007-06-18 21:08:54 +00:00
|
|
|
|
RELEASE(_tabStops);
|
|
|
|
|
RELEASE(_textBlocks);
|
|
|
|
|
RELEASE(_textLists);
|
1999-03-09 20:34:33 +00:00
|
|
|
|
[super dealloc];
|
1998-09-01 13:23:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-09 20:34:33 +00:00
|
|
|
|
- (id) init
|
1998-09-01 13:23:23 +00:00
|
|
|
|
{
|
2007-06-18 21:08:54 +00:00
|
|
|
|
if ((self = [super init]))
|
|
|
|
|
{
|
2024-05-13 16:47:42 +00:00
|
|
|
|
int i;
|
|
|
|
|
|
2007-06-18 21:08:54 +00:00
|
|
|
|
_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];
|
2024-05-13 16:47:42 +00:00
|
|
|
|
|
|
|
|
|
for (i = 0; i < 12; i++)
|
|
|
|
|
{
|
|
|
|
|
NSTextTab *tab;
|
|
|
|
|
|
|
|
|
|
tab = [[NSTextTab alloc] initWithType: NSLeftTabStopType
|
|
|
|
|
location: (i + 1) * 28.0];
|
|
|
|
|
[_tabStops addObject: tab];
|
|
|
|
|
RELEASE(tab);
|
|
|
|
|
}
|
2007-06-18 21:08:54 +00:00
|
|
|
|
}
|
1999-03-09 20:34:33 +00:00
|
|
|
|
return self;
|
1998-09-01 13:23:23 +00:00
|
|
|
|
}
|
1999-03-09 20:34:33 +00:00
|
|
|
|
|
2014-12-08 10:51:39 +00:00
|
|
|
|
- (NSString *)description
|
|
|
|
|
{
|
|
|
|
|
return [NSString stringWithFormat:
|
|
|
|
|
@"%@ Alignment: %ld LineSpacing: %f ParagraphSpacing: %f LineBreakMode: %ld",
|
|
|
|
|
[super description], (long)_alignment, (float)_lineSpacing,
|
|
|
|
|
(float)_paragraphSpacing, (long)_lineBreakMode];
|
|
|
|
|
}
|
|
|
|
|
|
1999-03-09 20:34:33 +00:00
|
|
|
|
/*
|
|
|
|
|
* "Leading": distance between the bottom of one line fragment and top
|
|
|
|
|
* of next (applied between lines in the same container).
|
|
|
|
|
* Can't be negative. This value is included in the line fragment
|
|
|
|
|
* heights in layout manager.
|
|
|
|
|
*/
|
2013-02-17 00:49:04 +00:00
|
|
|
|
- (CGFloat) lineSpacing
|
1998-09-01 13:23:23 +00:00
|
|
|
|
{
|
2000-12-12 21:14:00 +00:00
|
|
|
|
return _lineSpacing;
|
1998-09-01 13:23:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-09 20:34:33 +00:00
|
|
|
|
/*
|
|
|
|
|
* Distance between the bottom of this paragraph and top of next.
|
|
|
|
|
*/
|
2013-02-17 00:49:04 +00:00
|
|
|
|
- (CGFloat) paragraphSpacing
|
1999-03-09 20:34:33 +00:00
|
|
|
|
{
|
2000-12-12 21:14:00 +00:00
|
|
|
|
return _paragraphSpacing;
|
1999-03-09 20:34:33 +00:00
|
|
|
|
}
|
1998-09-01 13:23:23 +00:00
|
|
|
|
|
1999-03-09 20:34:33 +00:00
|
|
|
|
- (NSTextAlignment) alignment
|
1998-09-01 13:23:23 +00:00
|
|
|
|
{
|
2000-12-12 21:14:00 +00:00
|
|
|
|
return _alignment;
|
1998-09-01 13:23:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-09 20:34:33 +00:00
|
|
|
|
/*
|
|
|
|
|
* The following values are relative to the appropriate margin
|
|
|
|
|
* (depending on the paragraph direction)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Distance from margin to front edge of paragraph
|
|
|
|
|
*/
|
2013-02-17 00:49:04 +00:00
|
|
|
|
- (CGFloat) headIndent
|
1999-03-09 20:34:33 +00:00
|
|
|
|
{
|
2000-12-12 21:14:00 +00:00
|
|
|
|
return _headIndent;
|
1999-03-09 20:34:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Distance from margin to back edge of paragraph; if negative or 0,
|
|
|
|
|
* from other margin
|
|
|
|
|
*/
|
2013-02-17 00:49:04 +00:00
|
|
|
|
- (CGFloat) tailIndent
|
1998-09-01 13:23:23 +00:00
|
|
|
|
{
|
2000-12-12 21:14:00 +00:00
|
|
|
|
return _tailIndent;
|
1998-09-01 13:23:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-09 20:34:33 +00:00
|
|
|
|
/*
|
|
|
|
|
* Distance from margin to edge appropriate for text direction
|
|
|
|
|
*/
|
2013-02-17 00:49:04 +00:00
|
|
|
|
- (CGFloat) firstLineHeadIndent
|
1998-09-01 13:23:23 +00:00
|
|
|
|
{
|
2000-12-12 21:14:00 +00:00
|
|
|
|
return _firstLineHeadIndent;
|
1998-09-01 13:23:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-09 20:34:33 +00:00
|
|
|
|
/*
|
|
|
|
|
* Distance from margin to tab stops
|
|
|
|
|
*/
|
|
|
|
|
- (NSArray *) tabStops
|
1998-09-01 13:23:23 +00:00
|
|
|
|
{
|
2000-12-12 21:14:00 +00:00
|
|
|
|
return AUTORELEASE ([_tabStops copyWithZone: NSDefaultMallocZone ()]);
|
1998-09-01 13:23:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-09 20:34:33 +00:00
|
|
|
|
/*
|
|
|
|
|
* Line height is the distance from bottom of descenders to to
|
|
|
|
|
* of ascenders; basically the line fragment height. Does not include
|
|
|
|
|
* lineSpacing (which is added after this computation).
|
|
|
|
|
*/
|
2013-02-17 00:49:04 +00:00
|
|
|
|
- (CGFloat) minimumLineHeight
|
1998-09-01 13:23:23 +00:00
|
|
|
|
{
|
2000-12-12 21:14:00 +00:00
|
|
|
|
return _minimumLineHeight;
|
1998-09-01 13:23:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-09 20:34:33 +00:00
|
|
|
|
/*
|
|
|
|
|
* 0 implies no maximum.
|
|
|
|
|
*/
|
2013-02-17 00:49:04 +00:00
|
|
|
|
- (CGFloat) maximumLineHeight
|
1998-09-01 13:23:23 +00:00
|
|
|
|
{
|
2000-12-12 21:14:00 +00:00
|
|
|
|
return _maximumLineHeight;
|
1998-09-01 13:23:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-09 20:34:33 +00:00
|
|
|
|
- (NSLineBreakMode) lineBreakMode
|
|
|
|
|
{
|
2000-12-12 21:14:00 +00:00
|
|
|
|
return _lineBreakMode;
|
1999-03-09 20:34:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-04-26 16:51:21 +00:00
|
|
|
|
- (NSWritingDirection) baseWritingDirection
|
|
|
|
|
{
|
|
|
|
|
return _baseDirection;
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-17 00:49:04 +00:00
|
|
|
|
- (CGFloat) defaultTabInterval
|
2007-06-18 21:08:54 +00:00
|
|
|
|
{
|
|
|
|
|
return _defaultTabInterval;
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-17 00:49:04 +00:00
|
|
|
|
- (CGFloat) lineHeightMultiple
|
2007-06-18 21:08:54 +00:00
|
|
|
|
{
|
|
|
|
|
return _lineHeightMultiple;
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-17 00:49:04 +00:00
|
|
|
|
- (CGFloat) paragraphSpacingBefore
|
2007-06-18 21:08:54 +00:00
|
|
|
|
{
|
|
|
|
|
return _paragraphSpacingBefore;
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-17 00:49:04 +00:00
|
|
|
|
- (NSInteger) headerLevel
|
2007-06-18 21:08:54 +00:00
|
|
|
|
{
|
|
|
|
|
return _headerLevel;
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-25 07:46:37 +00:00
|
|
|
|
- (float) hyphenationFactor
|
2007-06-18 21:08:54 +00:00
|
|
|
|
{
|
|
|
|
|
return _hyphenationFactor;
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-25 07:46:37 +00:00
|
|
|
|
- (NSArray *) textBlocks
|
2007-06-18 21:08:54 +00:00
|
|
|
|
{
|
|
|
|
|
return _textBlocks;
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-25 07:46:37 +00:00
|
|
|
|
- (NSArray *) textLists
|
2007-06-18 21:08:54 +00:00
|
|
|
|
{
|
|
|
|
|
return _textLists;
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-25 07:46:37 +00:00
|
|
|
|
- (float) tighteningFactorForTruncation
|
2007-06-18 21:08:54 +00:00
|
|
|
|
{
|
|
|
|
|
return _tighteningFactorForTruncation;
|
|
|
|
|
}
|
|
|
|
|
|
1999-03-09 20:34:33 +00:00
|
|
|
|
- (id) copyWithZone: (NSZone*)aZone
|
|
|
|
|
{
|
2000-12-12 21:14:00 +00:00
|
|
|
|
if (NSShouldRetainWithZone (self, aZone) == YES)
|
|
|
|
|
return RETAIN (self);
|
1999-03-09 20:34:33 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NSParagraphStyle *c;
|
|
|
|
|
|
2000-12-12 21:14:00 +00:00
|
|
|
|
c = (NSParagraphStyle*)NSCopyObject (self, 0, aZone);
|
2009-01-29 22:58:13 +00:00
|
|
|
|
c->_textBlocks = [_textBlocks mutableCopyWithZone: aZone];
|
|
|
|
|
c->_textLists = [_textLists mutableCopyWithZone: aZone];
|
1999-03-09 20:34:33 +00:00
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) mutableCopyWithZone: (NSZone*)aZone
|
|
|
|
|
{
|
|
|
|
|
NSMutableParagraphStyle *c;
|
|
|
|
|
|
1999-03-09 21:38:49 +00:00
|
|
|
|
c = [[NSMutableParagraphStyle allocWithZone: aZone] init];
|
1999-03-09 20:34:33 +00:00
|
|
|
|
[c setParagraphStyle: self];
|
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) initWithCoder: (NSCoder*)aCoder
|
|
|
|
|
{
|
2006-10-15 08:34:47 +00:00
|
|
|
|
if ([aCoder allowsKeyedCoding])
|
1999-03-09 20:34:33 +00:00
|
|
|
|
{
|
2014-10-25 17:59:36 +00:00
|
|
|
|
_firstLineHeadIndent = [aCoder decodeFloatForKey: @"NSFirstLineHeadIndent"];
|
|
|
|
|
_headIndent = [aCoder decodeFloatForKey: @"NSHeadIndent"];
|
|
|
|
|
_paragraphSpacing = [aCoder decodeFloatForKey: @"NSParagraphSpacingBefore"];
|
|
|
|
|
ASSIGN(_tabStops, [aCoder decodeObjectForKey: @"NSTabStops"]);
|
|
|
|
|
ASSIGN(_textLists, [aCoder decodeObjectForKey: @"NSTextLists"]);
|
|
|
|
|
_baseDirection = [aCoder decodeIntForKey: @"NSWritingDirection"];
|
1999-03-09 20:34:33 +00:00
|
|
|
|
}
|
2006-06-04 16:31:30 +00:00
|
|
|
|
else
|
2003-04-26 16:51:21 +00:00
|
|
|
|
{
|
* Source/NSEvent.m,
* Source/NSParagraphStyle.m: Use NSInteger instead of enumerator
type name for decoding and encoding.
* Header/AppKit/NSFontPanel.h,
* Header/AppKit/NSOpenPanel.h,
* Header/AppKit/NSDataLinkPanel.h,
* Source/NSDataLinkPanel.m,
* Header/AppKit/NSForm.h,
* Source/NSForm.m,
* Header/AppKit/NSHelpPanel.h,
* Source/NSHelpPanel.m,
* Source/NSColorPanel.m: Remove unused encoding/decoding
* methods.
* Source/NSCustomImageRep.m,
* Source/NSEPSImageRep.m,
* Source/NSMovie.m,
* Source/NSRulerMarker.m,
* Source/NSColorList.m: Flag missing keyed encoding/decoding.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36377 72102866-910b-0410-8b05-ffd578937521
2013-03-17 19:53:50 +00:00
|
|
|
|
NSUInteger count;
|
2006-06-04 16:31:30 +00:00
|
|
|
|
|
* Source/NSEvent.m,
* Source/NSParagraphStyle.m: Use NSInteger instead of enumerator
type name for decoding and encoding.
* Header/AppKit/NSFontPanel.h,
* Header/AppKit/NSOpenPanel.h,
* Header/AppKit/NSDataLinkPanel.h,
* Source/NSDataLinkPanel.m,
* Header/AppKit/NSForm.h,
* Source/NSForm.m,
* Header/AppKit/NSHelpPanel.h,
* Source/NSHelpPanel.m,
* Source/NSColorPanel.m: Remove unused encoding/decoding
* methods.
* Source/NSCustomImageRep.m,
* Source/NSEPSImageRep.m,
* Source/NSMovie.m,
* Source/NSRulerMarker.m,
* Source/NSColorList.m: Flag missing keyed encoding/decoding.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36377 72102866-910b-0410-8b05-ffd578937521
2013-03-17 19:53:50 +00:00
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(NSInteger) at: &_alignment];
|
2013-02-21 17:19:00 +00:00
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(NSInteger) at: &_lineBreakMode];
|
2006-06-04 16:31:30 +00:00
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(float) at: &_firstLineHeadIndent];
|
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(float) at: &_headIndent];
|
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(float) at: &_lineSpacing];
|
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(float) at: &_maximumLineHeight];
|
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(float) at: &_minimumLineHeight];
|
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(float) at: &_paragraphSpacing];
|
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(float) at: &_tailIndent];
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Tab stops don't conform to NSCoding - so we do it the long way.
|
|
|
|
|
*/
|
* Source/NSEvent.m,
* Source/NSParagraphStyle.m: Use NSInteger instead of enumerator
type name for decoding and encoding.
* Header/AppKit/NSFontPanel.h,
* Header/AppKit/NSOpenPanel.h,
* Header/AppKit/NSDataLinkPanel.h,
* Source/NSDataLinkPanel.m,
* Header/AppKit/NSForm.h,
* Source/NSForm.m,
* Header/AppKit/NSHelpPanel.h,
* Source/NSHelpPanel.m,
* Source/NSColorPanel.m: Remove unused encoding/decoding
* methods.
* Source/NSCustomImageRep.m,
* Source/NSEPSImageRep.m,
* Source/NSMovie.m,
* Source/NSRulerMarker.m,
* Source/NSColorList.m: Flag missing keyed encoding/decoding.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36377 72102866-910b-0410-8b05-ffd578937521
2013-03-17 19:53:50 +00:00
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(NSUInteger) at: &count];
|
2006-06-04 16:31:30 +00:00
|
|
|
|
_tabStops = [[NSMutableArray alloc] initWithCapacity: count];
|
|
|
|
|
if (count > 0)
|
2007-06-18 21:08:54 +00:00
|
|
|
|
{
|
* Source/NSEvent.m,
* Source/NSParagraphStyle.m: Use NSInteger instead of enumerator
type name for decoding and encoding.
* Header/AppKit/NSFontPanel.h,
* Header/AppKit/NSOpenPanel.h,
* Header/AppKit/NSDataLinkPanel.h,
* Source/NSDataLinkPanel.m,
* Header/AppKit/NSForm.h,
* Source/NSForm.m,
* Header/AppKit/NSHelpPanel.h,
* Source/NSHelpPanel.m,
* Source/NSColorPanel.m: Remove unused encoding/decoding
* methods.
* Source/NSCustomImageRep.m,
* Source/NSEPSImageRep.m,
* Source/NSMovie.m,
* Source/NSRulerMarker.m,
* Source/NSColorList.m: Flag missing keyed encoding/decoding.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36377 72102866-910b-0410-8b05-ffd578937521
2013-03-17 19:53:50 +00:00
|
|
|
|
float locations[count];
|
|
|
|
|
NSTextTabType types[count];
|
|
|
|
|
NSUInteger i;
|
2007-06-18 21:08:54 +00:00
|
|
|
|
|
|
|
|
|
[aCoder decodeArrayOfObjCType: @encode(float)
|
|
|
|
|
count: count
|
|
|
|
|
at: locations];
|
2013-05-17 15:50:53 +00:00
|
|
|
|
if ([aCoder versionForClassName: @"NSParagraphStyle"] >= 3)
|
|
|
|
|
{
|
|
|
|
|
[aCoder decodeArrayOfObjCType: @encode(NSInteger)
|
|
|
|
|
count: count
|
|
|
|
|
at: types];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
[aCoder decodeArrayOfObjCType: @encode(int)
|
2007-06-18 21:08:54 +00:00
|
|
|
|
count: count
|
|
|
|
|
at: types];
|
2013-05-17 15:50:53 +00:00
|
|
|
|
}
|
2007-06-18 21:08:54 +00:00
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
NSTextTab *tab;
|
|
|
|
|
|
|
|
|
|
tab = [[NSTextTab alloc] initWithType: types[i]
|
|
|
|
|
location: locations[i]];
|
|
|
|
|
[_tabStops addObject: tab];
|
|
|
|
|
RELEASE(tab);
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-06-04 16:31:30 +00:00
|
|
|
|
|
|
|
|
|
if ([aCoder versionForClassName: @"NSParagraphStyle"] >= 2)
|
2007-06-18 21:08:54 +00:00
|
|
|
|
{
|
* Source/NSEvent.m,
* Source/NSParagraphStyle.m: Use NSInteger instead of enumerator
type name for decoding and encoding.
* Header/AppKit/NSFontPanel.h,
* Header/AppKit/NSOpenPanel.h,
* Header/AppKit/NSDataLinkPanel.h,
* Source/NSDataLinkPanel.m,
* Header/AppKit/NSForm.h,
* Source/NSForm.m,
* Header/AppKit/NSHelpPanel.h,
* Source/NSHelpPanel.m,
* Source/NSColorPanel.m: Remove unused encoding/decoding
* methods.
* Source/NSCustomImageRep.m,
* Source/NSEPSImageRep.m,
* Source/NSMovie.m,
* Source/NSRulerMarker.m,
* Source/NSColorList.m: Flag missing keyed encoding/decoding.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36377 72102866-910b-0410-8b05-ffd578937521
2013-03-17 19:53:50 +00:00
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(NSInteger) at: &_baseDirection];
|
2007-06-18 21:08:54 +00:00
|
|
|
|
}
|
2003-04-26 16:51:21 +00:00
|
|
|
|
}
|
2007-06-18 21:08:54 +00:00
|
|
|
|
|
1999-03-09 20:34:33 +00:00
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
|
|
|
|
{
|
2006-10-15 08:34:47 +00:00
|
|
|
|
if ([aCoder allowsKeyedCoding])
|
1999-03-09 20:34:33 +00:00
|
|
|
|
{
|
2014-10-25 17:59:36 +00:00
|
|
|
|
[aCoder encodeFloat: _firstLineHeadIndent forKey: @"NSFirstLineHeadIndent"];
|
|
|
|
|
[aCoder encodeFloat: _headIndent forKey: @"NSHeadIndent"];
|
|
|
|
|
[aCoder encodeFloat: _paragraphSpacing forKey: @"NSParagraphSpacingBefore"];
|
|
|
|
|
[aCoder encodeObject: _tabStops forKey: @"NSTabStops"];
|
|
|
|
|
[aCoder encodeObject: _textLists forKey: @"NSTextLists"];
|
|
|
|
|
[aCoder encodeInt: _baseDirection forKey: @"NSWritingDirection"];
|
2006-06-04 16:31:30 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
* Source/NSEvent.m,
* Source/NSParagraphStyle.m: Use NSInteger instead of enumerator
type name for decoding and encoding.
* Header/AppKit/NSFontPanel.h,
* Header/AppKit/NSOpenPanel.h,
* Header/AppKit/NSDataLinkPanel.h,
* Source/NSDataLinkPanel.m,
* Header/AppKit/NSForm.h,
* Source/NSForm.m,
* Header/AppKit/NSHelpPanel.h,
* Source/NSHelpPanel.m,
* Source/NSColorPanel.m: Remove unused encoding/decoding
* methods.
* Source/NSCustomImageRep.m,
* Source/NSEPSImageRep.m,
* Source/NSMovie.m,
* Source/NSRulerMarker.m,
* Source/NSColorList.m: Flag missing keyed encoding/decoding.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36377 72102866-910b-0410-8b05-ffd578937521
2013-03-17 19:53:50 +00:00
|
|
|
|
NSUInteger count;
|
2006-06-04 16:31:30 +00:00
|
|
|
|
|
* Source/NSEvent.m,
* Source/NSParagraphStyle.m: Use NSInteger instead of enumerator
type name for decoding and encoding.
* Header/AppKit/NSFontPanel.h,
* Header/AppKit/NSOpenPanel.h,
* Header/AppKit/NSDataLinkPanel.h,
* Source/NSDataLinkPanel.m,
* Header/AppKit/NSForm.h,
* Source/NSForm.m,
* Header/AppKit/NSHelpPanel.h,
* Source/NSHelpPanel.m,
* Source/NSColorPanel.m: Remove unused encoding/decoding
* methods.
* Source/NSCustomImageRep.m,
* Source/NSEPSImageRep.m,
* Source/NSMovie.m,
* Source/NSRulerMarker.m,
* Source/NSColorList.m: Flag missing keyed encoding/decoding.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36377 72102866-910b-0410-8b05-ffd578937521
2013-03-17 19:53:50 +00:00
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(NSInteger) at: &_alignment];
|
2013-02-21 17:19:00 +00:00
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(NSInteger) at: &_lineBreakMode];
|
2006-06-04 16:31:30 +00:00
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(float) at: &_firstLineHeadIndent];
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(float) at: &_headIndent];
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(float) at: &_lineSpacing];
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(float) at: &_maximumLineHeight];
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(float) at: &_minimumLineHeight];
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(float) at: &_paragraphSpacing];
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(float) at: &_tailIndent];
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Tab stops don't conform to NSCoding - so we do it the long way.
|
|
|
|
|
*/
|
|
|
|
|
count = [_tabStops count];
|
* Source/NSEvent.m,
* Source/NSParagraphStyle.m: Use NSInteger instead of enumerator
type name for decoding and encoding.
* Header/AppKit/NSFontPanel.h,
* Header/AppKit/NSOpenPanel.h,
* Header/AppKit/NSDataLinkPanel.h,
* Source/NSDataLinkPanel.m,
* Header/AppKit/NSForm.h,
* Source/NSForm.m,
* Header/AppKit/NSHelpPanel.h,
* Source/NSHelpPanel.m,
* Source/NSColorPanel.m: Remove unused encoding/decoding
* methods.
* Source/NSCustomImageRep.m,
* Source/NSEPSImageRep.m,
* Source/NSMovie.m,
* Source/NSRulerMarker.m,
* Source/NSColorList.m: Flag missing keyed encoding/decoding.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36377 72102866-910b-0410-8b05-ffd578937521
2013-03-17 19:53:50 +00:00
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(NSUInteger) at: &count];
|
2006-06-04 16:31:30 +00:00
|
|
|
|
if (count > 0)
|
2007-06-18 21:08:54 +00:00
|
|
|
|
{
|
* Source/NSEvent.m,
* Source/NSParagraphStyle.m: Use NSInteger instead of enumerator
type name for decoding and encoding.
* Header/AppKit/NSFontPanel.h,
* Header/AppKit/NSOpenPanel.h,
* Header/AppKit/NSDataLinkPanel.h,
* Source/NSDataLinkPanel.m,
* Header/AppKit/NSForm.h,
* Source/NSForm.m,
* Header/AppKit/NSHelpPanel.h,
* Source/NSHelpPanel.m,
* Source/NSColorPanel.m: Remove unused encoding/decoding
* methods.
* Source/NSCustomImageRep.m,
* Source/NSEPSImageRep.m,
* Source/NSMovie.m,
* Source/NSRulerMarker.m,
* Source/NSColorList.m: Flag missing keyed encoding/decoding.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36377 72102866-910b-0410-8b05-ffd578937521
2013-03-17 19:53:50 +00:00
|
|
|
|
float locations[count];
|
|
|
|
|
NSTextTabType types[count];
|
|
|
|
|
NSUInteger i;
|
2007-06-18 21:08:54 +00:00
|
|
|
|
|
|
|
|
|
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];
|
* Source/NSEvent.m,
* Source/NSParagraphStyle.m: Use NSInteger instead of enumerator
type name for decoding and encoding.
* Header/AppKit/NSFontPanel.h,
* Header/AppKit/NSOpenPanel.h,
* Header/AppKit/NSDataLinkPanel.h,
* Source/NSDataLinkPanel.m,
* Header/AppKit/NSForm.h,
* Source/NSForm.m,
* Header/AppKit/NSHelpPanel.h,
* Source/NSHelpPanel.m,
* Source/NSColorPanel.m: Remove unused encoding/decoding
* methods.
* Source/NSCustomImageRep.m,
* Source/NSEPSImageRep.m,
* Source/NSMovie.m,
* Source/NSRulerMarker.m,
* Source/NSColorList.m: Flag missing keyed encoding/decoding.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36377 72102866-910b-0410-8b05-ffd578937521
2013-03-17 19:53:50 +00:00
|
|
|
|
[aCoder encodeArrayOfObjCType: @encode(NSInteger)
|
2007-06-18 21:08:54 +00:00
|
|
|
|
count: count
|
|
|
|
|
at: types];
|
|
|
|
|
}
|
2006-06-04 16:31:30 +00:00
|
|
|
|
|
* Source/NSEvent.m,
* Source/NSParagraphStyle.m: Use NSInteger instead of enumerator
type name for decoding and encoding.
* Header/AppKit/NSFontPanel.h,
* Header/AppKit/NSOpenPanel.h,
* Header/AppKit/NSDataLinkPanel.h,
* Source/NSDataLinkPanel.m,
* Header/AppKit/NSForm.h,
* Source/NSForm.m,
* Header/AppKit/NSHelpPanel.h,
* Source/NSHelpPanel.m,
* Source/NSColorPanel.m: Remove unused encoding/decoding
* methods.
* Source/NSCustomImageRep.m,
* Source/NSEPSImageRep.m,
* Source/NSMovie.m,
* Source/NSRulerMarker.m,
* Source/NSColorList.m: Flag missing keyed encoding/decoding.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36377 72102866-910b-0410-8b05-ffd578937521
2013-03-17 19:53:50 +00:00
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(NSInteger) at: &_baseDirection];
|
1999-03-09 20:34:33 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
1998-09-01 13:23:23 +00:00
|
|
|
|
|
2003-02-23 23:05:43 +00:00
|
|
|
|
- (BOOL) isEqual: (id)aother
|
|
|
|
|
{
|
|
|
|
|
NSParagraphStyle *other = aother;
|
|
|
|
|
if (other == self)
|
|
|
|
|
return YES;
|
|
|
|
|
if ([other isKindOfClass: [NSParagraphStyle class]] == NO)
|
|
|
|
|
return NO;
|
|
|
|
|
|
|
|
|
|
#define C(x) if (x != other->x) return NO
|
|
|
|
|
C(_lineSpacing);
|
|
|
|
|
C(_paragraphSpacing);
|
|
|
|
|
C(_headIndent);
|
|
|
|
|
C(_tailIndent);
|
|
|
|
|
C(_firstLineHeadIndent);
|
|
|
|
|
C(_minimumLineHeight);
|
|
|
|
|
C(_maximumLineHeight);
|
|
|
|
|
C(_alignment);
|
|
|
|
|
C(_lineBreakMode);
|
2007-06-18 21:08:54 +00:00
|
|
|
|
C(_paragraphSpacingBefore);
|
|
|
|
|
C(_defaultTabInterval);
|
|
|
|
|
C(_hyphenationFactor);
|
|
|
|
|
C(_lineHeightMultiple);
|
|
|
|
|
C(_tighteningFactorForTruncation);
|
|
|
|
|
C(_headerLevel);
|
2003-02-23 23:05:43 +00:00
|
|
|
|
#undef C
|
|
|
|
|
|
|
|
|
|
return [_tabStops isEqualToArray: other->_tabStops];
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-16 02:51:30 +00:00
|
|
|
|
- (NSUInteger) hash
|
2003-02-23 23:05:43 +00:00
|
|
|
|
{
|
|
|
|
|
return _alignment + _lineBreakMode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1998-09-01 13:23:23 +00:00
|
|
|
|
@end
|
1999-03-09 20:34:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@implementation NSMutableParagraphStyle
|
|
|
|
|
|
|
|
|
|
+ (NSParagraphStyle*) defaultParagraphStyle
|
|
|
|
|
{
|
2000-12-12 21:14:00 +00:00
|
|
|
|
return AUTORELEASE ([[NSParagraphStyle defaultParagraphStyle] mutableCopy]);
|
1999-03-09 20:34:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-17 00:49:04 +00:00
|
|
|
|
- (void) setLineSpacing: (CGFloat)aFloat
|
1999-03-09 20:34:33 +00:00
|
|
|
|
{
|
2000-12-12 21:14:00 +00:00
|
|
|
|
NSAssert (aFloat >= 0.0, NSInvalidArgumentException);
|
|
|
|
|
_lineSpacing = aFloat;
|
1999-03-09 20:34:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-17 00:49:04 +00:00
|
|
|
|
- (void) setParagraphSpacing: (CGFloat)aFloat
|
1999-03-09 20:34:33 +00:00
|
|
|
|
{
|
2000-12-12 21:14:00 +00:00
|
|
|
|
NSAssert (aFloat >= 0.0, NSInvalidArgumentException);
|
|
|
|
|
_paragraphSpacing = aFloat;
|
1999-03-09 20:34:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setAlignment: (NSTextAlignment)newAlignment
|
|
|
|
|
{
|
2000-12-12 21:14:00 +00:00
|
|
|
|
_alignment = newAlignment;
|
1999-03-09 20:34:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-17 00:49:04 +00:00
|
|
|
|
- (void) setFirstLineHeadIndent: (CGFloat)aFloat
|
1999-03-09 20:34:33 +00:00
|
|
|
|
{
|
2000-12-12 21:14:00 +00:00
|
|
|
|
NSAssert (aFloat >= 0.0, NSInvalidArgumentException);
|
|
|
|
|
_firstLineHeadIndent = aFloat;
|
1999-03-09 20:34:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-17 00:49:04 +00:00
|
|
|
|
- (void) setHeadIndent: (CGFloat)aFloat
|
1999-03-09 20:34:33 +00:00
|
|
|
|
{
|
2000-12-12 21:14:00 +00:00
|
|
|
|
NSAssert (aFloat >= 0.0, NSInvalidArgumentException);
|
|
|
|
|
_headIndent = aFloat;
|
1999-03-09 20:34:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-17 00:49:04 +00:00
|
|
|
|
- (void) setTailIndent: (CGFloat)aFloat
|
1999-03-09 20:34:33 +00:00
|
|
|
|
{
|
2000-12-12 21:14:00 +00:00
|
|
|
|
_tailIndent = aFloat;
|
1999-03-09 20:34:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setLineBreakMode: (NSLineBreakMode)mode
|
|
|
|
|
{
|
2000-12-12 21:14:00 +00:00
|
|
|
|
_lineBreakMode = mode;
|
1999-03-09 20:34:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-17 00:49:04 +00:00
|
|
|
|
- (void) setMinimumLineHeight: (CGFloat)aFloat
|
1999-03-09 20:34:33 +00:00
|
|
|
|
{
|
2000-12-12 21:14:00 +00:00
|
|
|
|
NSAssert (aFloat >= 0.0, NSInvalidArgumentException);
|
|
|
|
|
_minimumLineHeight = aFloat;
|
1999-03-09 20:34:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-17 00:49:04 +00:00
|
|
|
|
- (void) setMaximumLineHeight: (CGFloat)aFloat
|
1999-03-09 20:34:33 +00:00
|
|
|
|
{
|
2000-12-12 21:14:00 +00:00
|
|
|
|
NSAssert (aFloat >= 0.0, NSInvalidArgumentException);
|
|
|
|
|
_maximumLineHeight = aFloat;
|
1999-03-09 20:34:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-04-26 16:51:21 +00:00
|
|
|
|
- (void) setBaseWritingDirection: (NSWritingDirection)direction
|
|
|
|
|
{
|
2006-11-20 16:20:15 +00:00
|
|
|
|
/*
|
|
|
|
|
* FIXME there is some confusion regarding natural writing direction.
|
|
|
|
|
*
|
|
|
|
|
* this method is documented as setting
|
|
|
|
|
* NSWritingDirectionLeftToRight or NSWritingDirectionRightToLeft
|
|
|
|
|
* based on the users language preferences.
|
|
|
|
|
* when encountering NSWritingDirectionNaturalDirection
|
|
|
|
|
*
|
|
|
|
|
* NSWritingDirectionNatural constant is documented as using the
|
|
|
|
|
* unicode bidi algorithm.
|
|
|
|
|
*
|
|
|
|
|
* no idea what the constant name or behaviour actually is.
|
|
|
|
|
*/
|
2003-04-26 16:51:21 +00:00
|
|
|
|
_baseDirection = direction;
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-17 00:49:04 +00:00
|
|
|
|
- (void) setDefaultTabInterval: (CGFloat)interval
|
2007-06-18 21:08:54 +00:00
|
|
|
|
{
|
|
|
|
|
_defaultTabInterval = interval;
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-17 00:49:04 +00:00
|
|
|
|
- (void) setLineHeightMultiple: (CGFloat)factor
|
2007-06-18 21:08:54 +00:00
|
|
|
|
{
|
|
|
|
|
_lineHeightMultiple = factor;
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-17 16:53:48 +00:00
|
|
|
|
- (void) setParagraphSpacingBefore: (CGFloat)spacing
|
2007-06-18 21:08:54 +00:00
|
|
|
|
{
|
|
|
|
|
_paragraphSpacingBefore = spacing;
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-17 00:49:04 +00:00
|
|
|
|
- (void) setHeaderLevel: (NSInteger)level
|
2007-06-18 21:08:54 +00:00
|
|
|
|
{
|
|
|
|
|
_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;
|
|
|
|
|
}
|
|
|
|
|
|
1999-03-09 21:38:49 +00:00
|
|
|
|
- (void) addTabStop: (NSTextTab*)anObject
|
1999-03-09 20:34:33 +00:00
|
|
|
|
{
|
2013-02-17 00:49:04 +00:00
|
|
|
|
NSUInteger count = [_tabStops count];
|
1999-03-09 21:38:49 +00:00
|
|
|
|
|
|
|
|
|
if (count == 0)
|
|
|
|
|
{
|
2000-12-12 21:14:00 +00:00
|
|
|
|
[_tabStops addObject: anObject];
|
1999-03-09 21:38:49 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
while (count-- > 0)
|
|
|
|
|
{
|
2013-02-17 00:49:04 +00:00
|
|
|
|
NSTextTab *tab;
|
1999-03-09 21:38:49 +00:00
|
|
|
|
|
2000-12-12 21:14:00 +00:00
|
|
|
|
tab = [_tabStops objectAtIndex: count];
|
1999-03-09 21:38:49 +00:00
|
|
|
|
if ([tab compare: anObject] != NSOrderedDescending)
|
|
|
|
|
{
|
2000-12-12 21:14:00 +00:00
|
|
|
|
[_tabStops insertObject: anObject atIndex: count + 1];
|
1999-03-09 21:38:49 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-12-12 21:14:00 +00:00
|
|
|
|
[_tabStops insertObject: anObject atIndex: 0];
|
1999-03-09 21:38:49 +00:00
|
|
|
|
}
|
1999-03-09 20:34:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-09 21:38:49 +00:00
|
|
|
|
- (void) removeTabStop: (NSTextTab*)anObject
|
1999-03-09 20:34:33 +00:00
|
|
|
|
{
|
2011-12-17 17:16:09 +00:00
|
|
|
|
NSUInteger i = [_tabStops indexOfObject: anObject];
|
1999-03-09 21:38:49 +00:00
|
|
|
|
|
|
|
|
|
if (i != NSNotFound)
|
2000-12-12 21:14:00 +00:00
|
|
|
|
[_tabStops removeObjectAtIndex: i];
|
1999-03-09 20:34:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setTabStops: (NSArray *)array
|
|
|
|
|
{
|
2000-12-12 21:14:00 +00:00
|
|
|
|
if (array != _tabStops)
|
1999-03-09 20:34:33 +00:00
|
|
|
|
{
|
2000-12-12 21:14:00 +00:00
|
|
|
|
[_tabStops removeAllObjects];
|
|
|
|
|
[_tabStops addObjectsFromArray: array];
|
|
|
|
|
[_tabStops sortUsingSelector: @selector(compare:)];
|
1999-03-09 20:34:33 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setParagraphStyle: (NSParagraphStyle*)obj
|
|
|
|
|
{
|
2013-02-17 00:49:04 +00:00
|
|
|
|
NSMutableParagraphStyle *p = (NSMutableParagraphStyle*)obj;
|
1999-03-09 20:34:33 +00:00
|
|
|
|
|
1999-03-09 21:38:49 +00:00
|
|
|
|
if (p == self)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* Can add tab stops without sorting as we know they are already sorted. */
|
2000-12-12 21:14:00 +00:00
|
|
|
|
[_tabStops removeAllObjects];
|
|
|
|
|
[_tabStops addObjectsFromArray: p->_tabStops];
|
1999-03-09 21:38:49 +00:00
|
|
|
|
|
2009-02-01 14:07:30 +00:00
|
|
|
|
if (p->_textBlocks)
|
|
|
|
|
[self setTextBlocks: p->_textBlocks];
|
|
|
|
|
if (p->_textLists)
|
|
|
|
|
[self setTextLists: p->_textLists];
|
2009-01-29 22:58:13 +00:00
|
|
|
|
|
2000-12-12 21:14:00 +00:00
|
|
|
|
_alignment = p->_alignment;
|
|
|
|
|
_firstLineHeadIndent = p->_firstLineHeadIndent;
|
|
|
|
|
_headIndent = p->_headIndent;
|
|
|
|
|
_lineBreakMode = p->_lineBreakMode;
|
|
|
|
|
_lineSpacing = p->_lineSpacing;
|
|
|
|
|
_maximumLineHeight = p->_maximumLineHeight;
|
|
|
|
|
_minimumLineHeight = p->_minimumLineHeight;
|
|
|
|
|
_paragraphSpacing = p->_paragraphSpacing;
|
|
|
|
|
_tailIndent = p->_tailIndent;
|
2003-04-26 16:51:21 +00:00
|
|
|
|
_baseDirection = p->_baseDirection;
|
2007-06-18 21:08:54 +00:00
|
|
|
|
_paragraphSpacingBefore = p->_paragraphSpacingBefore;
|
|
|
|
|
_defaultTabInterval = p->_defaultTabInterval;
|
|
|
|
|
_hyphenationFactor = p->_hyphenationFactor;
|
|
|
|
|
_lineHeightMultiple = p->_lineHeightMultiple;
|
|
|
|
|
_tighteningFactorForTruncation = p->_tighteningFactorForTruncation;
|
|
|
|
|
_headerLevel = p->_headerLevel;
|
1999-03-09 20:34:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-01-26 19:21:40 +00:00
|
|
|
|
- (id) copyWithZone: (NSZone*)aZone
|
|
|
|
|
{
|
2011-03-04 11:33:22 +00:00
|
|
|
|
NSMutableParagraphStyle *c;
|
2003-01-26 19:21:40 +00:00
|
|
|
|
|
|
|
|
|
c = (NSMutableParagraphStyle*)NSCopyObject (self, 0, aZone);
|
2011-03-04 11:33:22 +00:00
|
|
|
|
GSClassSwizzle(c, [NSParagraphStyle class]);
|
2003-01-26 19:21:40 +00:00
|
|
|
|
c->_tabStops = [_tabStops mutableCopyWithZone: aZone];
|
2009-01-29 22:58:13 +00:00
|
|
|
|
c->_textBlocks = [_textBlocks mutableCopyWithZone: aZone];
|
|
|
|
|
c->_textLists = [_textLists mutableCopyWithZone: aZone];
|
2011-03-04 11:33:22 +00:00
|
|
|
|
return c;
|
2003-01-26 19:21:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-09 20:34:33 +00:00
|
|
|
|
@end
|