mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-25 06:30:55 +00:00
* Source/NSPrinter.m:
* Source/NSPrintOperation.m:
* Source/NSPageLayout.m:
* Source/NSPrintInfo.m:
* Headers/AppKit/NSPrintInfo.h: Migrate printing code to CGFloat
or double.
* Source/NSTextView.m: Rewrite -adjustPageHeightNew🔝bottom:limit:
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@34288 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
30826f63ee
commit
aefc51b5bb
7 changed files with 81 additions and 56 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,4 +1,14 @@
|
|||
2011-11-17 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
2011-12-14 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
|
||||
* Source/NSPrinter.m:
|
||||
* Source/NSPrintOperation.m:
|
||||
* Source/NSPageLayout.m:
|
||||
* Source/NSPrintInfo.m:
|
||||
* Headers/AppKit/NSPrintInfo.h: Migrate printing code to CGFloat
|
||||
or double.
|
||||
* Source/NSTextView.m: Rewrite -adjustPageHeightNew:top:bottom:limit:
|
||||
|
||||
2011-12-14 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
|
||||
* Source/NSImageCell.m: if drawing on a view use -centerScanRect:
|
||||
to pixel align the drawing rect.
|
||||
|
|
|
@ -76,20 +76,20 @@ typedef enum _NSPrintingPaginationMode {
|
|||
// Managing the Printing Rectangle
|
||||
//
|
||||
+ (NSSize)sizeForPaperName:(NSString *)name;
|
||||
- (float)bottomMargin;
|
||||
- (float)leftMargin;
|
||||
- (CGFloat)bottomMargin;
|
||||
- (CGFloat)leftMargin;
|
||||
- (NSPrintingOrientation)orientation;
|
||||
- (NSString *)paperName;
|
||||
- (NSSize)paperSize;
|
||||
- (float)rightMargin;
|
||||
- (void)setBottomMargin:(float)value;
|
||||
- (void)setLeftMargin:(float)value;
|
||||
- (CGFloat)rightMargin;
|
||||
- (void)setBottomMargin:(CGFloat)value;
|
||||
- (void)setLeftMargin:(CGFloat)value;
|
||||
- (void)setOrientation:(NSPrintingOrientation)mode;
|
||||
- (void)setPaperName:(NSString *)name;
|
||||
- (void)setPaperSize:(NSSize)size;
|
||||
- (void)setRightMargin:(float)value;
|
||||
- (void)setTopMargin:(float)value;
|
||||
- (float)topMargin;
|
||||
- (void)setRightMargin:(CGFloat)value;
|
||||
- (void)setTopMargin:(CGFloat)value;
|
||||
- (CGFloat)topMargin;
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
|
||||
- (NSRect)imageablePageBounds;
|
||||
#endif
|
||||
|
|
|
@ -825,7 +825,7 @@ enum {
|
|||
if (scaleNumber == nil)
|
||||
{
|
||||
NSLog(@"NSPrintScalingFactor was nil in NSPrintInfo");
|
||||
scaleNumber = [NSNumber numberWithFloat: 100.0];
|
||||
scaleNumber = [NSNumber numberWithDouble: 100.0];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -875,16 +875,16 @@ enum {
|
|||
customPaper = [customPapers objectForKey: paperName];
|
||||
|
||||
number = [customPaper objectForKey: @"TopMargin"];
|
||||
[_printInfo setTopMargin: [number floatValue]];
|
||||
[_printInfo setTopMargin: [number doubleValue]];
|
||||
|
||||
number = [customPaper objectForKey: @"BottomMargin"];
|
||||
[_printInfo setBottomMargin: [number floatValue]];
|
||||
[_printInfo setBottomMargin: [number doubleValue]];
|
||||
|
||||
number = [customPaper objectForKey: @"LeftMargin"];
|
||||
[_printInfo setLeftMargin: [number floatValue]];
|
||||
[_printInfo setLeftMargin: [number doubleValue]];
|
||||
|
||||
number = [customPaper objectForKey: @"RightMargin"];
|
||||
[_printInfo setRightMargin: [number floatValue]];
|
||||
[_printInfo setRightMargin: [number doubleValue]];
|
||||
|
||||
size = [[customPaper objectForKey: @"PaperSize"] sizeValue];
|
||||
[_printInfo setPaperSize: size];
|
||||
|
|
|
@ -214,14 +214,14 @@ static NSPrintInfo *sharedPrintInfo = nil;
|
|||
//
|
||||
// Managing the Printing Rectangle
|
||||
//
|
||||
- (float) bottomMargin
|
||||
- (CGFloat) bottomMargin
|
||||
{
|
||||
return [(NSNumber *)[_info objectForKey: NSPrintBottomMargin] floatValue];
|
||||
return [(NSNumber *)[_info objectForKey: NSPrintBottomMargin] doubleValue];
|
||||
}
|
||||
|
||||
- (float) leftMargin
|
||||
- (CGFloat) leftMargin
|
||||
{
|
||||
return [(NSNumber *)[_info objectForKey: NSPrintLeftMargin] floatValue];
|
||||
return [(NSNumber *)[_info objectForKey: NSPrintLeftMargin] doubleValue];
|
||||
}
|
||||
|
||||
- (NSPrintingOrientation) orientation
|
||||
|
@ -245,20 +245,20 @@ static NSPrintInfo *sharedPrintInfo = nil;
|
|||
return [val sizeValue];
|
||||
}
|
||||
|
||||
- (float) rightMargin
|
||||
- (CGFloat) rightMargin
|
||||
{
|
||||
return [(NSNumber *)[_info objectForKey: NSPrintRightMargin] floatValue];
|
||||
return [(NSNumber *)[_info objectForKey: NSPrintRightMargin] doubleValue];
|
||||
}
|
||||
|
||||
- (void) setBottomMargin: (float)value
|
||||
- (void) setBottomMargin: (CGFloat)value
|
||||
{
|
||||
[_info setObject: [NSNumber numberWithFloat: value]
|
||||
[_info setObject: [NSNumber numberWithDouble: value]
|
||||
forKey: NSPrintBottomMargin];
|
||||
}
|
||||
|
||||
- (void) setLeftMargin: (float)value
|
||||
- (void) setLeftMargin: (CGFloat)value
|
||||
{
|
||||
[_info setObject: [NSNumber numberWithFloat: value]
|
||||
[_info setObject: [NSNumber numberWithDouble: value]
|
||||
forKey: NSPrintLeftMargin];
|
||||
}
|
||||
|
||||
|
@ -274,7 +274,7 @@ static NSPrintInfo *sharedPrintInfo = nil;
|
|||
if ((mode == NSPortraitOrientation && size.width > size.height)
|
||||
|| (mode == NSLandscapeOrientation && size.width < size.height))
|
||||
{
|
||||
float tmp = size.width;
|
||||
CGFloat tmp = size.width;
|
||||
size.width = size.height;
|
||||
size.height = tmp;
|
||||
[_info setObject: [NSValue valueWithSize: size]
|
||||
|
@ -307,21 +307,21 @@ static NSPrintInfo *sharedPrintInfo = nil;
|
|||
forKey: NSPrintOrientation];
|
||||
}
|
||||
|
||||
- (void) setRightMargin: (float)value
|
||||
- (void) setRightMargin: (CGFloat)value
|
||||
{
|
||||
[_info setObject:[NSNumber numberWithFloat:value]
|
||||
[_info setObject:[NSNumber numberWithDouble:value]
|
||||
forKey:NSPrintRightMargin];
|
||||
}
|
||||
|
||||
- (void) setTopMargin: (float)value
|
||||
- (void) setTopMargin: (CGFloat)value
|
||||
{
|
||||
[_info setObject:[NSNumber numberWithFloat:value]
|
||||
[_info setObject:[NSNumber numberWithDouble:value]
|
||||
forKey:NSPrintTopMargin];
|
||||
}
|
||||
|
||||
- (float) topMargin
|
||||
- (CGFloat) topMargin
|
||||
{
|
||||
return [(NSNumber *)[_info objectForKey:NSPrintTopMargin] floatValue];
|
||||
return [(NSNumber *)[_info objectForKey:NSPrintTopMargin] doubleValue];
|
||||
}
|
||||
|
||||
- (NSRect) imageablePageBounds
|
||||
|
@ -341,7 +341,7 @@ static NSPrintInfo *sharedPrintInfo = nil;
|
|||
|| (NSLandscapeOrientation == mode
|
||||
&& pageBounds.size.width < pageBounds.size.height))
|
||||
{
|
||||
float tmp;
|
||||
CGFloat tmp;
|
||||
|
||||
tmp = pageBounds.origin.x;
|
||||
pageBounds.origin.x = pageBounds.origin.y;
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
#import "GSGuiPrivate.h"
|
||||
|
||||
#define NSNUMBER(a) [NSNumber numberWithInt: (a)]
|
||||
#define NSFNUMBER(a) [NSNumber numberWithFloat: (a)]
|
||||
#define NSFNUMBER(a) [NSNumber numberWithDouble: (a)]
|
||||
|
||||
/*
|
||||
* When a view gets printed it may need to be split up into segments, if the
|
||||
|
@ -760,7 +760,6 @@ scaleRect(NSRect rect, double scale)
|
|||
NSNumber *value;
|
||||
|
||||
dict = [_print_info dictionary];
|
||||
|
||||
info->paperSize = [_print_info paperSize];
|
||||
info->orient = [_print_info orientation];
|
||||
value = [dict objectForKey: NSPrintScalingFactor];
|
||||
|
@ -838,7 +837,7 @@ scaleRect(NSRect rect, double scale)
|
|||
*/
|
||||
if (((int)(info->nup / 2) & 0x1) == 1)
|
||||
{
|
||||
float tmp;
|
||||
CGFloat tmp;
|
||||
if (info->orient == NSLandscapeOrientation)
|
||||
info->nupScale =
|
||||
info->paperSize.width/(2*info->paperSize.height);
|
||||
|
@ -855,7 +854,7 @@ scaleRect(NSRect rect, double scale)
|
|||
}
|
||||
else if (info->nup > 1)
|
||||
{
|
||||
info->nupScale = 2.0 / (float)info->nup;
|
||||
info->nupScale = 2.0 / (CGFloat)info->nup;
|
||||
}
|
||||
|
||||
if ([[dict objectForKey: NSPrintPageDirection] isEqual: @"Columns"])
|
||||
|
@ -1119,7 +1118,7 @@ scaleRect(NSRect rect, double scale)
|
|||
{
|
||||
int currentPage;
|
||||
int numberOnSheet;
|
||||
float xoffset, yoffset, scale;
|
||||
CGFloat xoffset, yoffset, scale;
|
||||
NSPoint location;
|
||||
NSPrintOperation *printOp = [NSPrintOperation currentOperation];
|
||||
NSGraphicsContext *ctxt = [printOp context];
|
||||
|
|
|
@ -516,7 +516,7 @@ static NSMutableDictionary* printerCache;
|
|||
{
|
||||
NSString *result;
|
||||
NSScanner *bits;
|
||||
float x1, y1, x2, y2;
|
||||
double x1, y1, x2, y2;
|
||||
|
||||
result = [self stringForKey: key
|
||||
inTable: table];
|
||||
|
@ -525,10 +525,10 @@ static NSMutableDictionary* printerCache;
|
|||
return NSZeroRect;
|
||||
|
||||
bits = [NSScanner scannerWithString: result];
|
||||
if ([bits scanFloat: &x1] &&
|
||||
[bits scanFloat: &y1] &&
|
||||
[bits scanFloat: &x2] &&
|
||||
[bits scanFloat: &y2])
|
||||
if ([bits scanDouble: &x1] &&
|
||||
[bits scanDouble: &y1] &&
|
||||
[bits scanDouble: &x2] &&
|
||||
[bits scanDouble: &y2])
|
||||
{
|
||||
return NSMakeRect(x1, y1, x2-x1, y2-y1);
|
||||
}
|
||||
|
@ -540,7 +540,7 @@ static NSMutableDictionary* printerCache;
|
|||
{
|
||||
NSString *result;
|
||||
NSScanner *bits;
|
||||
float x, y;
|
||||
double x, y;
|
||||
|
||||
result = [self stringForKey: key
|
||||
inTable: table];
|
||||
|
@ -549,8 +549,8 @@ static NSMutableDictionary* printerCache;
|
|||
return NSZeroSize;
|
||||
|
||||
bits = [NSScanner scannerWithString: result];
|
||||
if ([bits scanFloat: &x] &&
|
||||
[bits scanFloat: &y])
|
||||
if ([bits scanDouble: &x] &&
|
||||
[bits scanDouble: &y])
|
||||
{
|
||||
return NSMakeSize(x,y);
|
||||
}
|
||||
|
|
|
@ -4218,12 +4218,12 @@ 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
|
||||
- (void) adjustPageHeightNew: (CGFloat*)newBottom
|
||||
top: (CGFloat)oldTop
|
||||
bottom: (CGFloat)oldBottom
|
||||
limit: (CGFloat)bottomLimit
|
||||
{
|
||||
// FIXME: This assumes we are printing a vertical column
|
||||
BOOL needsToMoveBottom = NO;
|
||||
|
||||
NSRect proposedPage = NSMakeRect([self bounds].origin.x,
|
||||
oldTop,
|
||||
|
@ -4233,6 +4233,8 @@ Figure out how the additional layout stuff is supposed to work.
|
|||
NSRange pageGlyphRange = [_layoutManager glyphRangeForBoundingRect: proposedPage
|
||||
inTextContainer: _textContainer];
|
||||
|
||||
CGFloat actualTextBottom = oldBottom; // the maximum Y value of text less than oldBottom
|
||||
|
||||
NSInteger i;
|
||||
for (i = NSMaxRange(pageGlyphRange) - 1; i >= (NSInteger)pageGlyphRange.location; )
|
||||
{
|
||||
|
@ -4240,20 +4242,34 @@ Figure out how the additional layout stuff is supposed to work.
|
|||
NSRect lineFragRect = [_layoutManager lineFragmentRectForGlyphAtIndex: i
|
||||
effectiveRange: &lineFragGlyphRange];
|
||||
|
||||
if (NSContainsRect(proposedPage, lineFragRect))
|
||||
if (NSMaxY(lineFragRect) <= NSMaxY(proposedPage))
|
||||
{
|
||||
*newBottom = NSMaxY(lineFragRect);
|
||||
return;
|
||||
actualTextBottom = NSMaxY(lineFragRect);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We encountered a visible glyph fragment which extents below
|
||||
// the bottom of the page
|
||||
needsToMoveBottom = YES;
|
||||
}
|
||||
|
||||
i = lineFragGlyphRange.location - 1;
|
||||
}
|
||||
|
||||
NSLog(@"Error -[NSTextView adjustPageHeightNew:top:bottom:limit:] failed to find a line fragment completely inside the page");
|
||||
*newBottom = oldBottom;
|
||||
if (needsToMoveBottom)
|
||||
{
|
||||
*newBottom = actualTextBottom;
|
||||
}
|
||||
else
|
||||
{
|
||||
*newBottom = oldBottom;
|
||||
}
|
||||
|
||||
// FIXME: Do we need a special case so text attachments aren't split in half?
|
||||
}
|
||||
|
||||
- (float)heightAdjustLimit
|
||||
- (CGFloat)heightAdjustLimit
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue