--- /tmp/gui/Source/GSSimpleLayoutManager.m Sun Sep 23 18:09:48 2001 +++ GSSimpleLayoutManager.m Thu Nov 1 12:31:49 2001 @@ -273,7 +273,13 @@ if (![_textStorage length] || ![_lineLayoutInformation count]) { - return NSMakeRect(0, 0, 0, 12); + NSTextContainer *aTextContainer = [self textContainerForGlyphAtIndex: index + effectiveRange: lineFragmentRange]; + + NSSize inset = [[aTextContainer textView] textContainerInset]; + + + return NSMakeRect(inset.width, inset.height, 0, 12); } currentInfo = [_lineLayoutInformation @@ -292,11 +298,15 @@ unsigned start; _GNULineLayoutInfo *currentInfo; + NSTextContainer *aTextContainer = [self textContainerForGlyphAtIndex: index + effectiveRange: NULL]; + NSSize inset = [[aTextContainer textView] textContainerInset]; + if (![_textStorage length] || ![_lineLayoutInformation count]) { - return NSMakePoint(0, 0); + return NSMakePoint(inset.width, inset.height); } - + currentInfo = [_lineLayoutInformation objectAtIndex: [self lineLayoutIndexForGlyphIndex: index]]; @@ -310,7 +320,7 @@ /* NB: As per specs, we return the location relative to the glyph's line fragment rectangle */ - return NSMakePoint(x, 0); + return NSMakePoint(x, inset.height); } - (NSRect)boundingRectForGlyphRange:(NSRange)aRange @@ -319,10 +329,11 @@ _GNULineLayoutInfo *currentInfo; unsigned i1, i2; NSRect rect1; - + if (![_textStorage length] || ![_lineLayoutInformation count]) { - return NSMakeRect(0, 0, 0, 12); + NSSize inset = [[aTextContainer textView] textContainerInset]; + return NSMakeRect(inset.width, inset.height, 0, 12); } i1 = [self lineLayoutIndexForGlyphIndex: aRange.location]; @@ -361,6 +372,8 @@ { //FIXME: This currently ignores most of its arguments + NSSize inset = [[aTextContainer textView] textContainerInset]; + if (!rectCount) return _rects; @@ -387,7 +400,7 @@ width - startRect.origin.x, startRect.size.height); // second line - _rects[1] = NSMakeRect (0, endRect.origin.y, endRect.origin.x, + _rects[1] = NSMakeRect (inset.width, endRect.origin.y, endRect.origin.x - inset.width, endRect.size.height); *rectCount = 2; } @@ -400,11 +413,11 @@ width - startRect.origin.x, startRect.size.height); // intermediate lines - _rects[1] = NSMakeRect (0, NSMaxY(startRect), - width, + _rects[1] = NSMakeRect (inset.width, NSMaxY(startRect), + width - inset.width, endRect.origin.y - NSMaxY (startRect)); // last line - _rects[2] = NSMakeRect (0, endRect.origin.y, endRect.origin.x, + _rects[2] = NSMakeRect (inset.width, endRect.origin.y, endRect.origin.x - inset.width, endRect.size.height); *rectCount = 3; } @@ -502,10 +515,16 @@ NSRect rect = [self boundingRectForGlyphRange: glyphRange inTextContainer: aTextContainer]; + // We draw the background even outside the inset + rect.origin.y -= containerOrigin.y; + rect.size.width += 2 * containerOrigin.x; + rect.size.height += 2 * containerOrigin.y; + /* FIXME: Which means that the following can't be correct */ // clear area under text [[[aTextContainer textView] backgroundColor] set]; + NSRectFill(rect); } @@ -691,9 +710,14 @@ NSRect rect; float x; + NSTextContainer *aTextContainer = [self textContainerForGlyphAtIndex: index + effectiveRange: NULL]; + + NSSize inset = [[aTextContainer textView] textContainerInset]; + if (![_textStorage length] || ![_lineLayoutInformation count]) { - return NSMakeRect(0, 0, width, 12); + return NSMakeRect(inset.width, inset.height, width, 12); } currentInfo = [_lineLayoutInformation lastObject]; @@ -870,6 +894,10 @@ // for optimization detection NSMutableArray *ghostArray = nil; + NSSize inset = [[aTextContainer textView] textContainerInset]; + drawingPoint.x = inset.width; + drawingPoint.y = inset.height; + if (maxLines) { int insertionLineIndex = [self lineLayoutIndexForGlyphIndex: @@ -911,9 +939,9 @@ // If there is no text add one empty box [_lineLayoutInformation addObject: [_GNULineLayoutInfo - lineLayoutWithRange: NSMakeRange (0, 0) - rect: NSMakeRect (0, 0, width, 12) - usedRect: NSMakeRect (0, 0, 0, 12)]]; + lineLayoutWithRange: NSMakeRange (0,0) + rect: NSMakeRect (inset.width, inset.height, width, 12) + usedRect: NSMakeRect (inset.width, inset.height, 1, 12)]]; return NSMakeRange(0,1); } @@ -970,7 +998,7 @@ if (NSIsEmptyRect(remainingRect)) { - fragmentRect = NSMakeRect (0, drawingPoint.y, HUGE, HUGE); + fragmentRect = NSMakeRect (inset.width, drawingPoint.y, HUGE, HUGE); } else { @@ -1089,11 +1117,14 @@ scannerPosition += eol.length; usedLineRect.size.width += 1; // FIXME: This should use the real font size!! - if (usedLineRect.size.height == 0) + if (usedLineRect.size.height < 12) { usedLineRect.size.height = 12; } } + + // We remove the inset for our rect for our last line + usedLineRect.size.width -= inset.width; } lineGlyphRange = NSMakeRange (startingLineCharIndex, @@ -1119,7 +1150,7 @@ currentLineIndex++; startingLineCharIndex = NSMaxRange(lineGlyphRange); drawingPoint.y += usedLineRect.size.height; - drawingPoint.x = 0; + drawingPoint.x = inset.width; RELEASE(pool);