Printing, cString fixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@14407 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fedor 2002-09-06 19:31:00 +00:00
parent 6b3b2819df
commit 7fea2291bb
7 changed files with 60 additions and 15 deletions

View file

@ -1,3 +1,17 @@
2002-09-06 Adam Fedor <fedor@gnu.org>
* Headers/gnustep/gui/NSPrintInfo.h: Add print option.
* Source/NSPrintOperation.m ([-_printPaginateWithInfo:knowsRange:):
Use it.
(-_rectForPage:info:xpage:ypage:): Correct xpage/ypage calc.
(-_adjustPagesFirst:last:info:): Likewise.
* Source/NSStringDrawing.m (setupSpecialRun): Set base.
* Source/NSSound.m (-getDataFromFileAtPath:): Use
fileSystemRepresentation.
* Source/NSView.m (-beginPage:label:bBox:fonts:): Use
lossyCString.
2002-09-06 Fred Kiefer <FredKiefer@gmx.de>
* Headers/gnustep/gui/NSColorPanel.h

View file

@ -162,6 +162,13 @@ APPKIT_EXPORT NSString *NSPrintTopMargin;
APPKIT_EXPORT NSString *NSPrintVerticalPagination;
APPKIT_EXPORT NSString *NSPrintVerticallyCentered;
//
// Additional (GNUstep) keys
//
/** Set to <code>Rows</code> to print row by row, set to <code>Columns</code>
to print column by column */
APPKIT_EXPORT NSString *NSPrintPageDirection;
//
// Print Job Disposition Values
//

View file

@ -68,6 +68,7 @@ typedef struct _page_info_t {
int nup; /* Number up pages to print on a sheet */
double lastWidth, lastHeight;
NSPrintingOrientation orient;
int pageDirection; /* NSPrintPageDirection */
} page_info_t;
@interface NSPrintOperation (Private)
@ -771,6 +772,11 @@ scaleRect(NSRect rect, double scale)
{
info->nupScale = 2.0 / (float)info->nup;
}
if ([[dict objectForKey: NSPrintPageDirection] isEqual: @"Columns"])
info->pageDirection = 1;
else
info->pageDirection = 0;
}
/* Our personnel method to calculate the print rect for the specified page.
@ -778,12 +784,24 @@ scaleRect(NSRect rect, double scale)
page. The returned pageRect is in the view's coordinate system
*/
- (NSRect) _rectForPage: (int)page info: (page_info_t *)info
xpage: (int *)xptr
ypage: (int *)yptr
{
int xpage, ypage;
NSRect pageRect;
xpage = (page - 1) % info->xpages;
if (info->pageDirection == 1)
{
xpage = (page - 1) / info->ypages;
ypage = (page - 1) % info->ypages;
}
else
{
xpage = (page - 1) % info->xpages;
ypage = (page - 1) / info->xpages;
}
*xptr = xpage;
*yptr = ypage;
if (xpage == 0)
info->lastWidth = 0;
if (ypage == 0)
@ -803,7 +821,7 @@ scaleRect(NSRect rect, double scale)
last: (int)last
info: (page_info_t *)info
{
int i;
int i, xpage, ypage;
double hlimit, wlimit;
NSRect pageRect;
hlimit = [_view heightAdjustLimit];
@ -811,7 +829,7 @@ scaleRect(NSRect rect, double scale)
for (i = first; i <= last; i++)
{
float newVal, limitVal;
pageRect = [self _rectForPage: i info: info];
pageRect = [self _rectForPage: i info: info xpage: &xpage ypage: &ypage];
limitVal = NSMaxY(pageRect) - hlimit * NSHeight(pageRect);
[_view adjustPageHeightNew: &newVal
top: NSMinY(pageRect)
@ -826,7 +844,9 @@ scaleRect(NSRect rect, double scale)
limit: limitVal];
if (newVal < NSMaxX(pageRect))
pageRect.size.width = MAX(newVal, limitVal) - NSMinX(pageRect);
if (info->pageDirection == 0 || ypage == info->ypages - 1)
info->lastWidth = NSMaxX(pageRect)*(info->pageScale*info->printScale);
if (info->pageDirection == 1 || xpage == info->xpages - 1)
info->lastHeight = NSMaxY(pageRect)*(info->pageScale*info->printScale);
}
return pageRect;

View file

@ -235,7 +235,8 @@ afCloseFile(file); \
return NO; \
}
if ((file = afOpenFile([path cString], "r", NULL)) == AF_NULL_FILEHANDLE)
if ((file = afOpenFile([path fileSystemRepresentation], "r", NULL))
== AF_NULL_FILEHANDLE)
{
return NO;
}

View file

@ -287,6 +287,7 @@ setupSpecialRun(GSTextRun *run, unsigned length, unichar *chars, unsigned pos,
run->baseline = [run->cell cellBaselineOffset].y;
run->height = run->glyphs[0].adv.height;
run->width = run->glyphs[0].adv.width;
run->base = 0;
// Unset the normale fields
run->font = nil;
run->bg = nil;

View file

@ -2847,13 +2847,13 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
if (aString == nil)
aString = [[NSNumber numberWithInt: ordinalNum] description];
DPSPrintf(ctxt, "%%%%Page: %s %d\n", [aString cString], ordinalNum);
DPSPrintf(ctxt, "%%%%Page: %s %d\n", [aString lossyCString], ordinalNum);
if (NSIsEmptyRect(pageRect) == NO)
DPSPrintf(ctxt, "%%%%PageBoundingBox: %d %d %d %d\n",
(int)NSMinX(pageRect), (int)NSMinY(pageRect),
(int)NSMaxX(pageRect), (int)NSMaxY(pageRect));
if (fontNames)
DPSPrintf(ctxt, "%%%%PageFonts: %s\n", [fontNames cString]);
DPSPrintf(ctxt, "%%%%PageFonts: %s\n", [fontNames lossyCString]);
DPSPrintf(ctxt, "%%%%BeginPageSetup\n");
}
@ -2882,13 +2882,13 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
DPSPrintf(ctxt, "%%!PS-Adobe-3.0 EPSF-3.0\n");
else
DPSPrintf(ctxt, "%%!PS-Adobe-3.0\n");
DPSPrintf(ctxt, "%%%%Title: %s\n", [aTitle cString]);
DPSPrintf(ctxt, "%%%%Creator: %s\n", [anApplication cString]);
DPSPrintf(ctxt, "%%%%Title: %s\n", [aTitle lossyCString]);
DPSPrintf(ctxt, "%%%%Creator: %s\n", [anApplication lossyCString]);
DPSPrintf(ctxt, "%%%%CreationDate: %s\n",
[[dateCreated description] cString]);
DPSPrintf(ctxt, "%%%%For: %s\n", [user cString]);
[[dateCreated description] lossyCString]);
DPSPrintf(ctxt, "%%%%For: %s\n", [user lossyCString]);
if (fontNames)
DPSPrintf(ctxt, "%%%%DocumentFonts: %s\n", [fontNames cString]);
DPSPrintf(ctxt, "%%%%DocumentFonts: %s\n", [fontNames lossyCString]);
else
DPSPrintf(ctxt, "%%%%DocumentFonts: (atend)\n");

View file

@ -279,6 +279,8 @@ NSString *NSPrintHorizontalPagination = @"PrintHorizontalPagination";
NSString *NSPrintVerticalPagination = @"PrintVerticalPagination";
NSString *NSPrintVerticallyCentered = @"PrintVerticallyCentered";
NSString *NSPrintPageDirection = @"NSPrintPageDirection";
// Print Job Disposition Values
NSString *NSPrintCancelJob = @"PrintCancelJob";
NSString *NSPrintFaxJob = @"PrintFaxJob";