mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
NSTextView.m: Attempt to add pagination support so lines aren't cut in half when printing
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@32566 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
5d165e7db8
commit
6af7d4f8b0
2 changed files with 46 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
2011-03-14 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
|
||||
* Source/NSTextView.m: Attempt to add pagination support
|
||||
so lines aren't cut in half when printing
|
||||
|
||||
2011-03-13 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
|
||||
* Source/NSTextView.m: Tweaks to last commit
|
||||
|
|
|
@ -4097,6 +4097,47 @@ Figure out how the additional layout stuff is supposed to work.
|
|||
}
|
||||
}
|
||||
|
||||
/**** Pagination *****/
|
||||
|
||||
- (void) adjustPageHeightNew: (float*)newBottom
|
||||
top: (float)oldTop
|
||||
bottom: (float)oldBottom
|
||||
limit: (float)bottomLimit
|
||||
{
|
||||
// FIXME: This assumes we are printing a vertical column
|
||||
|
||||
NSRect proposedPage = NSMakeRect([self bounds].origin.x,
|
||||
oldTop,
|
||||
[self bounds].size.width,
|
||||
oldBottom - oldTop);
|
||||
|
||||
NSRange pageGlyphRange = [_layoutManager glyphRangeForBoundingRect: proposedPage
|
||||
inTextContainer: _textContainer];
|
||||
|
||||
NSInteger i;
|
||||
for (i = NSMaxRange(pageGlyphRange) - 1; i >= (NSInteger)pageGlyphRange.location; )
|
||||
{
|
||||
NSRange lineFragGlyphRange = NSMakeRange(0, 0);
|
||||
NSRect lineFragRect = [_layoutManager lineFragmentRectForGlyphAtIndex: i
|
||||
effectiveRange: &lineFragGlyphRange];
|
||||
|
||||
if (NSContainsRect(proposedPage, lineFragRect))
|
||||
{
|
||||
*newBottom = NSMaxY(lineFragRect);
|
||||
return;
|
||||
}
|
||||
|
||||
i = lineFragGlyphRange.location - 1;
|
||||
}
|
||||
|
||||
NSLog(@"Error -[NSTextView adjustPageHeightNew:top:bottom:limit:] failed to find a line fragment completely inside the page");
|
||||
*newBottom = oldBottom;
|
||||
}
|
||||
|
||||
- (float)heightAdjustLimit
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue