Switched to use the text container for size information.

Implemented [textContainerChangedGeometry].


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@7677 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
FredKiefer 2000-09-30 23:13:41 +00:00
parent 9345fc6851
commit 43d81e04cb

View file

@ -248,29 +248,13 @@ typedef enum
[[NSText class] newlineString]]]; [[NSText class] newlineString]]];
} }
- (void) setFirstTextView: (NSTextView*)aTextView
{
_firstTextView = aTextView;
}
- (void) setTextStorage: (NSTextStorage*)aTextStorage - (void) setTextStorage: (NSTextStorage*)aTextStorage
{ {
unsigned length = [aTextStorage length];
NSRange aRange = NSMakeRange(0, length);
ASSIGN(_textStorage, aTextStorage);
// force complete re - layout
RELEASE(lineLayoutInformation); RELEASE(lineLayoutInformation);
lineLayoutInformation = nil; lineLayoutInformation = nil;
[self textStorage: aTextStorage
edited: NSTextStorageEditedCharacters | NSTextStorageEditedAttributes
range: aRange
changeInLength: length
invalidatedRange: aRange];
}
- (NSTextStorage*) textStorage [super setTextStorage: aTextStorage];
{
return _textStorage;
} }
// Currently gyphIndex is the same as character index // Currently gyphIndex is the same as character index
@ -513,6 +497,18 @@ typedef enum
return _rects; return _rects;
} }
- (void) textContainerChangedGeometry: (NSTextContainer*)aContainer
{
NSRange lineRange;
RELEASE(lineLayoutInformation);
lineLayoutInformation = nil;
lineRange = [self rebuildForRange: NSMakeRange(0, [_textStorage length])
delta: 0];
[self setNeedsDisplayForLineRange: lineRange];
}
- (void)textStorage:(NSTextStorage *)aTextStorage - (void)textStorage:(NSTextStorage *)aTextStorage
edited:(unsigned int)mask edited:(unsigned int)mask
range:(NSRange)aRange range:(NSRange)aRange
@ -537,7 +533,7 @@ typedef enum
inTextContainer: nil]; inTextContainer: nil];
// clear area under text // clear area under text
[[_firstTextView backgroundColor] set]; [[[self firstTextView] backgroundColor] set];
NSRectFill(rect); NSRectFill(rect);
} }
@ -545,7 +541,7 @@ typedef enum
atPoint:(NSPoint)containerOrigin atPoint:(NSPoint)containerOrigin
{ {
NSRange newRange; NSRange newRange;
NSRange selectedRange = [_firstTextView selectedRange]; NSRange selectedRange = [[self firstTextView] selectedRange];
unsigned start = [self lineLayoutIndexForCharacterIndex: glyphRange.location]; unsigned start = [self lineLayoutIndexForCharacterIndex: glyphRange.location];
unsigned end = [self lineLayoutIndexForCharacterIndex: NSMaxRange(glyphRange)]; unsigned end = [self lineLayoutIndexForCharacterIndex: NSMaxRange(glyphRange)];
NSRange lineRange = NSMakeRange(start, end + 1 - start); NSRange lineRange = NSMakeRange(start, end + 1 - start);
@ -590,22 +586,25 @@ typedef enum
- (NSRect) frame - (NSRect) frame
{ {
return [_firstTextView frame]; if ([self firstTextView] == nil)
{
NSSize size = [[_textContainers objectAtIndex: 0] containerSize];
return NSMakeRect(0, 0, size.width, size.height);
}
return [[self firstTextView] frame];
} }
- (float) width - (float) width
{ {
return [_firstTextView frame].size.width; return [[_textContainers objectAtIndex: 0] containerSize].width;
} }
- (float) maxWidth - (float) maxWidth
{ {
NSRect aRect = [_firstTextView frame]; if ([[self firstTextView] isHorizontallyResizable])
if ([_firstTextView isHorizontallyResizable])
return HUGE; return HUGE;
else else
return aRect.size.width; return [self width];
} }
- (unsigned) lineLayoutIndexForPoint: (NSPoint)point - (unsigned) lineLayoutIndexForPoint: (NSPoint)point
@ -869,7 +868,7 @@ typedef enum
(int)NSMaxRange(redrawLineRange) - 1] lineRect]); (int)NSMaxRange(redrawLineRange) - 1] lineRect]);
displayRect.size.width = width - displayRect.origin.x; displayRect.size.width = width - displayRect.origin.x;
[_firstTextView setNeedsDisplayInRect: displayRect]; [[self firstTextView] setNeedsDisplayInRect: displayRect];
} }
@ -884,8 +883,8 @@ typedef enum
if (![lineLayoutInformation count] if (![lineLayoutInformation count]
|| (lowestY < NSMaxY(myFrame))) || (lowestY < NSMaxY(myFrame)))
{ {
[_firstTextView setNeedsDisplayInRect: NSMakeRect(0, lowestY, [[self firstTextView] setNeedsDisplayInRect: NSMakeRect(0, lowestY,
width, NSMaxY(myFrame) - lowestY)]; width, NSMaxY(myFrame) - lowestY)];
} }
} }