Prefixed all NSParagraphStyle and NSTextTab ivars with underscores

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@8313 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
nico 2000-12-12 21:14:00 +00:00
parent fb798c08f7
commit a0711aeb96
3 changed files with 123 additions and 124 deletions

View file

@ -1,3 +1,9 @@
Tue Dec 12 23:50:04 2000 Nicola Pero <n.pero@mi.flashnet.it>
* Headers/gnustep/gui/NSParagraphStyle.h: Prefixed all ivars with
underscores.
* Source/NSParagraphStyle.m: Updated for ivar name change.
Tue Dec 12 21:07:56 2000 Nicola Pero <n.pero@mi.flashnet.it> Tue Dec 12 21:07:56 2000 Nicola Pero <n.pero@mi.flashnet.it>
* Source/NSMenuItemCell.m ([-drawInteriorWithFrame:inView:]), * Source/NSMenuItemCell.m ([-drawInteriorWithFrame:inView:]),

View file

@ -49,26 +49,26 @@ typedef enum _NSLineBreakMode { /* What to do with long lines */
@interface NSTextTab : NSObject <NSCopying> @interface NSTextTab : NSObject <NSCopying>
{ {
NSTextTabType tabStopType; NSTextTabType _tabStopType;
float location; float _location;
} }
- (id) initWithType: (NSTextTabType)type location: (float)loc; - (id) initWithType: (NSTextTabType)type location: (float)loc;
- (float) location; - (float) location;
- (NSTextTabType) tabStopType; - (NSTextTabType) tabStopType;
@end @end
@interface NSParagraphStyle : NSObject <NSCopying, NSMutableCopying, NSCoding> @interface NSParagraphStyle : NSObject <NSCopying, NSMutableCopying, NSCoding>
{ {
float lineSpacing; float _lineSpacing;
float paragraphSpacing; float _paragraphSpacing;
float headIndent; float _headIndent;
float tailIndent; float _tailIndent;
float firstLineHeadIndent; float _firstLineHeadIndent;
float minimumLineHeight; float _minimumLineHeight;
float maximumLineHeight; float _maximumLineHeight;
NSMutableArray *tabStops; NSMutableArray *_tabStops;
NSTextAlignment alignment; NSTextAlignment _alignment;
NSLineBreakMode lineBreakMode; NSLineBreakMode _lineBreakMode;
} }
+ (NSParagraphStyle*) defaultParagraphStyle; + (NSParagraphStyle*) defaultParagraphStyle;

View file

@ -44,8 +44,8 @@
- (id) initWithType: (NSTextTabType)type location: (float)loc - (id) initWithType: (NSTextTabType)type location: (float)loc
{ {
self = [super init]; self = [super init];
tabStopType = type; _tabStopType = type;
location = loc; _location = loc;
return self; return self;
} }
@ -57,10 +57,10 @@
return NSOrderedSame; return NSOrderedSame;
if (anObject == nil || ([anObject isKindOfClass: self->isa] == NO)) if (anObject == nil || ([anObject isKindOfClass: self->isa] == NO))
return NSOrderedAscending; return NSOrderedAscending;
loc = ((NSTextTab*)anObject)->location; loc = ((NSTextTab*)anObject)->_location;
if (loc < location) if (loc < _location)
return NSOrderedAscending; return NSOrderedAscending;
else if (loc > location) else if (loc > _location)
return NSOrderedDescending; return NSOrderedDescending;
else else
return NSOrderedSame; return NSOrderedSame;
@ -68,9 +68,9 @@
- (unsigned) hash - (unsigned) hash
{ {
unsigned val = (unsigned)location; unsigned val = (unsigned)_location;
val ^= (unsigned)tabStopType; val ^= (unsigned)_tabStopType;
return val; return val;
} }
@ -80,21 +80,21 @@
return YES; return YES;
if ([anObject isKindOfClass: self->isa] == NO) if ([anObject isKindOfClass: self->isa] == NO)
return NO; return NO;
else if (((NSTextTab*)anObject)->tabStopType != tabStopType) else if (((NSTextTab*)anObject)->_tabStopType != _tabStopType)
return NO; return NO;
else if (((NSTextTab*)anObject)->location != location) else if (((NSTextTab*)anObject)->_location != _location)
return NO; return NO;
return YES; return YES;
} }
- (float) location - (float) location
{ {
return location; return _location;
} }
- (NSTextTabType) tabStopType - (NSTextTabType) tabStopType
{ {
return tabStopType; return _tabStopType;
} }
@end @end
@ -115,20 +115,13 @@ static NSParagraphStyle *defaultStyle = nil;
{ {
NSTextTab *tab; NSTextTab *tab;
/* FIXME: (i * 1) ? */
tab = [[NSTextTab alloc] initWithType: NSLeftTabStopType tab = [[NSTextTab alloc] initWithType: NSLeftTabStopType
location: (i*1)*28.0]; location: (i * 1) * 28.0];
[style->tabStops addObject: tab]; [style->_tabStops addObject: tab];
RELEASE(tab); RELEASE(tab);
} }
defaultStyle = style;
/*
* If another thread was doing this at the same time, it may have
* assigned it's own defaultStyle - if so we use that and discard ours.
*/
if (defaultStyle != nil)
RELEASE(style);
else
defaultStyle = style;
} }
return defaultStyle; return defaultStyle;
} }
@ -140,25 +133,24 @@ static NSParagraphStyle *defaultStyle = nil;
NSLog(@"Argh - attempt to dealloc the default paragraph style!"); NSLog(@"Argh - attempt to dealloc the default paragraph style!");
return; return;
} }
RELEASE(tabStops); RELEASE (_tabStops);
[super dealloc]; [super dealloc];
} }
- (id) init - (id) init
{ {
self = [super init]; self = [super init];
alignment = NSNaturalTextAlignment; _alignment = NSNaturalTextAlignment;
firstLineHeadIndent = 0.0; _firstLineHeadIndent = 0.0;
headIndent = 0.0; _headIndent = 0.0;
lineBreakMode = NSLineBreakByWordWrapping; _lineBreakMode = NSLineBreakByWordWrapping;
lineSpacing = 0.0; _lineSpacing = 0.0;
maximumLineHeight = 0.0; _maximumLineHeight = 0.0;
minimumLineHeight = 0.0; _minimumLineHeight = 0.0;
paragraphSpacing = 0.0; _paragraphSpacing = 0.0;
tailIndent = 0.0; _tailIndent = 0.0;
// FIXME: I find it surprising that this is mutable, this propably was done to _tabStops = [[NSMutableArray allocWithZone: [self zone]]
// reuse it for NSMutableParagraphStyle. Still I think it is wrong. initWithCapacity: 12];
tabStops = [[NSMutableArray allocWithZone: [self zone]] initWithCapacity: 12];
return self; return self;
} }
@ -170,7 +162,7 @@ static NSParagraphStyle *defaultStyle = nil;
*/ */
- (float) lineSpacing - (float) lineSpacing
{ {
return lineSpacing; return _lineSpacing;
} }
/* /*
@ -178,12 +170,12 @@ static NSParagraphStyle *defaultStyle = nil;
*/ */
- (float) paragraphSpacing - (float) paragraphSpacing
{ {
return paragraphSpacing; return _paragraphSpacing;
} }
- (NSTextAlignment) alignment - (NSTextAlignment) alignment
{ {
return alignment; return _alignment;
} }
/* /*
@ -196,7 +188,7 @@ static NSParagraphStyle *defaultStyle = nil;
*/ */
- (float) headIndent - (float) headIndent
{ {
return headIndent; return _headIndent;
} }
/* /*
@ -205,7 +197,7 @@ static NSParagraphStyle *defaultStyle = nil;
*/ */
- (float) tailIndent - (float) tailIndent
{ {
return tailIndent; return _tailIndent;
} }
/* /*
@ -213,7 +205,7 @@ static NSParagraphStyle *defaultStyle = nil;
*/ */
- (float) firstLineHeadIndent - (float) firstLineHeadIndent
{ {
return firstLineHeadIndent; return _firstLineHeadIndent;
} }
/* /*
@ -221,7 +213,7 @@ static NSParagraphStyle *defaultStyle = nil;
*/ */
- (NSArray *) tabStops - (NSArray *) tabStops
{ {
return AUTORELEASE([tabStops copyWithZone: NSDefaultMallocZone()]); return AUTORELEASE ([_tabStops copyWithZone: NSDefaultMallocZone ()]);
} }
/* /*
@ -231,7 +223,7 @@ static NSParagraphStyle *defaultStyle = nil;
*/ */
- (float) minimumLineHeight - (float) minimumLineHeight
{ {
return minimumLineHeight; return _minimumLineHeight;
} }
/* /*
@ -239,24 +231,24 @@ static NSParagraphStyle *defaultStyle = nil;
*/ */
- (float) maximumLineHeight - (float) maximumLineHeight
{ {
return maximumLineHeight; return _maximumLineHeight;
} }
- (NSLineBreakMode) lineBreakMode - (NSLineBreakMode) lineBreakMode
{ {
return lineBreakMode; return _lineBreakMode;
} }
- (id) copyWithZone: (NSZone*)aZone - (id) copyWithZone: (NSZone*)aZone
{ {
if (NSShouldRetainWithZone(self, aZone) == YES) if (NSShouldRetainWithZone (self, aZone) == YES)
return RETAIN(self); return RETAIN (self);
else else
{ {
NSParagraphStyle *c; NSParagraphStyle *c;
c = (NSParagraphStyle*)NSCopyObject(self, 0, aZone); c = (NSParagraphStyle*)NSCopyObject (self, 0, aZone);
c->tabStops = [tabStops mutableCopyWithZone: aZone]; c->_tabStops = [_tabStops mutableCopyWithZone: aZone];
return c; return c;
} }
} }
@ -274,21 +266,22 @@ static NSParagraphStyle *defaultStyle = nil;
{ {
unsigned count; unsigned count;
[aCoder decodeValueOfObjCType: @encode(NSTextAlignment) at: &alignment]; [aCoder decodeValueOfObjCType: @encode(NSTextAlignment) at: &_alignment];
[aCoder decodeValueOfObjCType: @encode(NSLineBreakMode) at: &lineBreakMode]; [aCoder decodeValueOfObjCType: @encode(NSLineBreakMode)
[aCoder decodeValueOfObjCType: @encode(float) at: &firstLineHeadIndent]; at: &_lineBreakMode];
[aCoder decodeValueOfObjCType: @encode(float) at: &headIndent]; [aCoder decodeValueOfObjCType: @encode(float) at: &_firstLineHeadIndent];
[aCoder decodeValueOfObjCType: @encode(float) at: &lineSpacing]; [aCoder decodeValueOfObjCType: @encode(float) at: &_headIndent];
[aCoder decodeValueOfObjCType: @encode(float) at: &maximumLineHeight]; [aCoder decodeValueOfObjCType: @encode(float) at: &_lineSpacing];
[aCoder decodeValueOfObjCType: @encode(float) at: &minimumLineHeight]; [aCoder decodeValueOfObjCType: @encode(float) at: &_maximumLineHeight];
[aCoder decodeValueOfObjCType: @encode(float) at: &paragraphSpacing]; [aCoder decodeValueOfObjCType: @encode(float) at: &_minimumLineHeight];
[aCoder decodeValueOfObjCType: @encode(float) at: &tailIndent]; [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. * Tab stops don't conform to NSCoding - so we do it the long way.
*/ */
[aCoder decodeValueOfObjCType: @encode(unsigned) at: &count]; [aCoder decodeValueOfObjCType: @encode(unsigned) at: &count];
tabStops = [[NSMutableArray alloc] initWithCapacity: count]; _tabStops = [[NSMutableArray alloc] initWithCapacity: count];
if (count > 0) if (count > 0)
{ {
float locations[count]; float locations[count];
@ -307,8 +300,8 @@ static NSParagraphStyle *defaultStyle = nil;
tab = [NSTextTab alloc]; tab = [NSTextTab alloc];
tab = [tab initWithType: types[i] location: locations[i]]; tab = [tab initWithType: types[i] location: locations[i]];
[tabStops addObject: tab]; [_tabStops addObject: tab];
RELEASE(tab); RELEASE (tab);
} }
} }
@ -319,20 +312,21 @@ static NSParagraphStyle *defaultStyle = nil;
{ {
unsigned count; unsigned count;
[aCoder encodeValueOfObjCType: @encode(NSTextAlignment) at: &alignment]; [aCoder encodeValueOfObjCType: @encode(NSTextAlignment) at: &_alignment];
[aCoder encodeValueOfObjCType: @encode(NSLineBreakMode) at: &lineBreakMode]; [aCoder encodeValueOfObjCType: @encode(NSLineBreakMode)
[aCoder encodeValueOfObjCType: @encode(float) at: &firstLineHeadIndent]; at: &_lineBreakMode];
[aCoder encodeValueOfObjCType: @encode(float) at: &headIndent]; [aCoder encodeValueOfObjCType: @encode(float) at: &_firstLineHeadIndent];
[aCoder encodeValueOfObjCType: @encode(float) at: &lineSpacing]; [aCoder encodeValueOfObjCType: @encode(float) at: &_headIndent];
[aCoder encodeValueOfObjCType: @encode(float) at: &maximumLineHeight]; [aCoder encodeValueOfObjCType: @encode(float) at: &_lineSpacing];
[aCoder encodeValueOfObjCType: @encode(float) at: &minimumLineHeight]; [aCoder encodeValueOfObjCType: @encode(float) at: &_maximumLineHeight];
[aCoder encodeValueOfObjCType: @encode(float) at: &paragraphSpacing]; [aCoder encodeValueOfObjCType: @encode(float) at: &_minimumLineHeight];
[aCoder encodeValueOfObjCType: @encode(float) at: &tailIndent]; [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. * Tab stops don't conform to NSCoding - so we do it the long way.
*/ */
count = [tabStops count]; count = [_tabStops count];
[aCoder encodeValueOfObjCType: @encode(unsigned) at: &count]; [aCoder encodeValueOfObjCType: @encode(unsigned) at: &count];
if (count > 0) if (count > 0)
{ {
@ -342,7 +336,7 @@ static NSParagraphStyle *defaultStyle = nil;
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
NSTextTab *tab = [tabStops objectAtIndex: i]; NSTextTab *tab = [_tabStops objectAtIndex: i];
locations[count] = [tab location]; locations[count] = [tab location];
types[count] = [tab tabStopType]; types[count] = [tab tabStopType];
@ -364,67 +358,67 @@ static NSParagraphStyle *defaultStyle = nil;
+ (NSParagraphStyle*) defaultParagraphStyle + (NSParagraphStyle*) defaultParagraphStyle
{ {
return AUTORELEASE([[NSParagraphStyle defaultParagraphStyle] mutableCopy]); return AUTORELEASE ([[NSParagraphStyle defaultParagraphStyle] mutableCopy]);
} }
- (void) setLineSpacing: (float)aFloat - (void) setLineSpacing: (float)aFloat
{ {
NSAssert(aFloat >= 0.0, NSInvalidArgumentException); NSAssert (aFloat >= 0.0, NSInvalidArgumentException);
lineSpacing = aFloat; _lineSpacing = aFloat;
} }
- (void) setParagraphSpacing: (float)aFloat - (void) setParagraphSpacing: (float)aFloat
{ {
NSAssert(aFloat >= 0.0, NSInvalidArgumentException); NSAssert (aFloat >= 0.0, NSInvalidArgumentException);
paragraphSpacing = aFloat; _paragraphSpacing = aFloat;
} }
- (void) setAlignment: (NSTextAlignment)newAlignment - (void) setAlignment: (NSTextAlignment)newAlignment
{ {
alignment = newAlignment; _alignment = newAlignment;
} }
- (void) setFirstLineHeadIndent: (float)aFloat - (void) setFirstLineHeadIndent: (float)aFloat
{ {
NSAssert(aFloat >= 0.0, NSInvalidArgumentException); NSAssert (aFloat >= 0.0, NSInvalidArgumentException);
firstLineHeadIndent = aFloat; _firstLineHeadIndent = aFloat;
} }
- (void) setHeadIndent: (float)aFloat - (void) setHeadIndent: (float)aFloat
{ {
NSAssert(aFloat >= 0.0, NSInvalidArgumentException); NSAssert (aFloat >= 0.0, NSInvalidArgumentException);
headIndent = aFloat; _headIndent = aFloat;
} }
- (void) setTailIndent: (float)aFloat - (void) setTailIndent: (float)aFloat
{ {
tailIndent = aFloat; _tailIndent = aFloat;
} }
- (void) setLineBreakMode: (NSLineBreakMode)mode - (void) setLineBreakMode: (NSLineBreakMode)mode
{ {
lineBreakMode = mode; _lineBreakMode = mode;
} }
- (void) setMinimumLineHeight: (float)aFloat - (void) setMinimumLineHeight: (float)aFloat
{ {
NSAssert(aFloat >= 0.0, NSInvalidArgumentException); NSAssert (aFloat >= 0.0, NSInvalidArgumentException);
minimumLineHeight = aFloat; _minimumLineHeight = aFloat;
} }
- (void) setMaximumLineHeight: (float)aFloat - (void) setMaximumLineHeight: (float)aFloat
{ {
NSAssert(aFloat >= 0.0, NSInvalidArgumentException); NSAssert (aFloat >= 0.0, NSInvalidArgumentException);
maximumLineHeight = aFloat; _maximumLineHeight = aFloat;
} }
- (void) addTabStop: (NSTextTab*)anObject - (void) addTabStop: (NSTextTab*)anObject
{ {
unsigned count = [tabStops count]; unsigned count = [_tabStops count];
if (count == 0) if (count == 0)
{ {
[tabStops addObject: anObject]; [_tabStops addObject: anObject];
} }
else else
{ {
@ -432,32 +426,32 @@ static NSParagraphStyle *defaultStyle = nil;
{ {
NSTextTab *tab; NSTextTab *tab;
tab = [tabStops objectAtIndex: count]; tab = [_tabStops objectAtIndex: count];
if ([tab compare: anObject] != NSOrderedDescending) if ([tab compare: anObject] != NSOrderedDescending)
{ {
[tabStops insertObject: anObject atIndex: count+1]; [_tabStops insertObject: anObject atIndex: count + 1];
return; return;
} }
} }
[tabStops insertObject: anObject atIndex: 0]; [_tabStops insertObject: anObject atIndex: 0];
} }
} }
- (void) removeTabStop: (NSTextTab*)anObject - (void) removeTabStop: (NSTextTab*)anObject
{ {
unsigned i = [tabStops indexOfObject: anObject]; unsigned i = [_tabStops indexOfObject: anObject];
if (i != NSNotFound) if (i != NSNotFound)
[tabStops removeObjectAtIndex: i]; [_tabStops removeObjectAtIndex: i];
} }
- (void) setTabStops: (NSArray *)array - (void) setTabStops: (NSArray *)array
{ {
if (array != tabStops) if (array != _tabStops)
{ {
[tabStops removeAllObjects]; [_tabStops removeAllObjects];
[tabStops addObjectsFromArray: array]; [_tabStops addObjectsFromArray: array];
[tabStops sortUsingSelector: @selector(compare:)]; [_tabStops sortUsingSelector: @selector(compare:)];
} }
} }
@ -469,19 +463,18 @@ static NSParagraphStyle *defaultStyle = nil;
return; return;
/* Can add tab stops without sorting as we know they are already sorted. */ /* Can add tab stops without sorting as we know they are already sorted. */
[tabStops removeAllObjects]; [_tabStops removeAllObjects];
[tabStops addObjectsFromArray: p->tabStops]; [_tabStops addObjectsFromArray: p->_tabStops];
alignment = p->alignment; _alignment = p->_alignment;
firstLineHeadIndent = p->firstLineHeadIndent; _firstLineHeadIndent = p->_firstLineHeadIndent;
headIndent = p->headIndent; _headIndent = p->_headIndent;
lineBreakMode = p->lineBreakMode; _lineBreakMode = p->_lineBreakMode;
lineSpacing = p->lineSpacing; _lineSpacing = p->_lineSpacing;
maximumLineHeight = p->maximumLineHeight; _maximumLineHeight = p->_maximumLineHeight;
minimumLineHeight = p->minimumLineHeight; _minimumLineHeight = p->_minimumLineHeight;
paragraphSpacing = p->paragraphSpacing; _paragraphSpacing = p->_paragraphSpacing;
tailIndent = p->tailIndent; _tailIndent = p->_tailIndent;
} }
@end @end