//////////////////////////////////////////////////////////////////// // // FGBsePrint.m // Commesse // // Created by Francesco Germinara on Wed Jun 30 2004. // // Copyright (c) 2004 SofTech di F.Germinara - www.germinara.it. All rights reserved. // // For information please contact me at info@germinara.it //////////////////////////////////////////////////////////////////// // History: // // Description: // //////////////////////////////////////////////////////////////////// #import "FGBsePrint.h" #import "FGBseData.h" #import "fgMainApp.h" @implementation FGBsePrint -(id)init{ self=[super init]; return self; } //set default value -(void) setDefault{ NSFontManager *fontManager = [NSFontManager sharedFontManager]; //Default Font sets fntTitolo=[NSFont fontWithName:@"Verdana"size:12.0]; fntIntestazione=[NSFont fontWithName:@"Verdana"size:10.0]; fntIntestazione=[fontManager convertFont:fntIntestazione toHaveTrait:NSBoldFontMask]; fntDettaglio=[NSFont fontWithName:@"Verdana"size:10.0]; fntNote=[NSFont fontWithName:@"Verdana"size:8]; clrTitolo=[NSColor colorWithCalibratedRed:0.0 green:0.0 blue:0.8 alpha:1.0]; clrTitolo2=[NSColor colorWithCalibratedRed:0.0 green:0.2 blue:0.6 alpha:1.0]; clrIntestazione=[NSColor colorWithCalibratedRed:0.25 green:0.25 blue:0.8 alpha:1.0]; clrDettaglio=[NSColor colorWithCalibratedRed:0.5 green:0.15 blue:0.5 alpha:1.0]; clrNote=[NSColor colorWithCalibratedRed:0.8 green:0.25 blue:0.1 alpha:1.0]; NSMutableDictionary *attrs = [NSMutableDictionary dictionary]; [attrs setObject:fntTitolo forKey:NSFontAttributeName]; [attrs setObject:clrTitolo forKey:NSForegroundColorAttributeName]; strAsTitolo1= [[NSMutableAttributedString alloc] initWithString:@" " attributes:attrs]; NSMutableDictionary *attrs2 = [NSMutableDictionary dictionary]; [attrs2 setObject:fntTitolo forKey:NSFontAttributeName]; [attrs2 setObject:clrTitolo2 forKey:NSForegroundColorAttributeName]; strAsTitolo2= [[NSMutableAttributedString alloc] initWithString:@" " attributes:attrs2]; NSMutableDictionary *attrs3 = [NSMutableDictionary dictionary]; [attrs3 setObject:fntNote forKey:NSFontAttributeName]; [attrs3 setObject:clrNote forKey:NSForegroundColorAttributeName]; strAsNote= [[NSMutableAttributedString alloc] initWithString:@" " attributes:attrs3]; NSMutableDictionary *attrs4 = [NSMutableDictionary dictionary]; [attrs4 setObject:fntIntestazione forKey:NSFontAttributeName]; [attrs4 setObject:clrIntestazione forKey:NSForegroundColorAttributeName]; strAsTmpIntesta= [[NSMutableAttributedString alloc] initWithString:@" " attributes:attrs4]; NSMutableDictionary *attrs5 = [NSMutableDictionary dictionary]; [attrs5 setObject:fntDettaglio forKey:NSFontAttributeName]; [attrs5 setObject:clrDettaglio forKey:NSForegroundColorAttributeName]; strAsTmpDettaglio= [[NSMutableAttributedString alloc] initWithString:@" " attributes:attrs5]; //Data di Stampa FGBseData *dataStampa=[[FGBseData alloc]init]; //Data Elaborazione strData=[NSString stringWithFormat:@"Data: %@",[dataStampa DataD]]; [dataStampa release]; imgLogoCliente=[NSImage imageNamed:@"LOG FERRERO "]; imgLogoSoftech=[NSImage imageNamed:@"bitsoftech"]; //Calcolo posizione righe NSSize attrStringSize; attrStringSize=[strAsTitolo1 size]; nPosLineaIntestazione1=attrStringSize.height; attrStringSize=[strAsTmpIntesta size]; nPosLineaIntestazione2=attrStringSize.height; attrStringSize=[strAsNote size]; nPosLineaNote=attrStringSize.height * 1.5; nMaxPage=0; nCurrentPage=0; nRowPerPage=25; } -(void)Free{ if(strAsTitolo1 != nil) [strAsTitolo1 release]; if(strAsTitolo2!= nil) [strAsTitolo2 release]; if(strAsTmpIntesta != nil) [strAsTmpIntesta release]; if(strAsTmpDettaglio != nil) [strAsTmpDettaglio release]; if(strAsNote != nil) [strAsNote release]; [self setHidden:TRUE]; strAsTitolo1=nil; strAsTitolo2=nil; strAsTmpIntesta=nil; strAsTmpDettaglio=nil; strAsNote=nil; } -(BOOL)knowsPageRange:(NSRangePointer)aRange{ NSLog(@"FGBsePrint:knowsPageRange"); [self setDefault]; int nMaxRow=[printDataSource count]; nMaxPage=(int)(nMaxRow/nRowPerPage); //Calcolo Numero di righe x pagine int nRigheVedove=nMaxRow -(nMaxPage*nRowPerPage); if(nRigheVedove>0) nMaxPage++; aRange->length=nMaxPage; aRange->location=1; return YES; } - (void)beginDocument{ NSLog(@"FGBsePrint:beginDocument"); [super beginDocument]; } -(void)beginPageInRect:(NSRect)aRect atPlacement:(NSPoint)location{ NSLog(@"FGBsePrint:beginPageInRect"); [super beginPageInRect:aRect atPlacement:location]; } //Scrivo Titolo e Note - (void)drawPageBorderWithSize:(NSSize)borderSize{ NSLog(@"FGBsePrint:drawPageBorderWithSize"); [super drawPageBorderWithSize:borderSize]; } - (void)drawSheetBorderWithSize:(NSSize)borderSize{ NSLog(@"FGBsePrint:drawSheetBorderWithSize"); [super drawSheetBorderWithSize:borderSize]; } //Disegno Intestazione e Piè Pagina -(void) drawIntestazionePiePagina{ NSRect drwRect; //Traccio la linea delle note drwRect=NSMakeRect(nLeftMargin,nBottomMargin-5,rcAreaStampa.size.width,1); [[NSColor blueColor] set]; //Imposto il colore [NSBezierPath fillRect:drwRect]; //Traccio la linea della intestazione NSRect drwRectIntesta; drwRectIntesta=NSMakeRect(nLeftMargin,rcPagina.size.height-nTopMargin+3,rcAreaStampa.size.width,1); [[NSColor blueColor]set]; //Imposto il colore [NSBezierPath fillRect:drwRectIntesta]; //Traccio la linea della intestazione tabulato NSRect drwRectHeader; int nHeight=[tabHeader getSizePosition:0].height+4; drwRectHeader=NSMakeRect(nLeftMargin,rcPagina.size.height-nTopMargin-nHeight+3,rcAreaStampa.size.width,1); [[NSColor blueColor]set]; //Imposto il colore [NSBezierPath fillRect:drwRectHeader]; //Scrivo le colonne int nColonne=[tabHeader count]; int nIndex=0; for(nIndex=0; nIndexnMaxRow) endRow=nMaxRow; int nPrintedRow=0; for(nRow=startRow; nRow < endRow; nRow++){ [(fgMainApp*)theApp printRow:nRow]; //Chiamo Call Back per Info Record da stampare nPrintedRow++; for(nIndex=0; nIndex