//////////////////////////////////////////////////////////////////// // // FGIntesta.m // Commesse // // Created by Francesco Germinara on Mon Jul 05 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 "FGIntesta.h" @implementation FGIntesta -(id)init{ self=[super init]; //Create defaults NSFontManager *fontManager = [NSFontManager sharedFontManager]; defaultFieldNameFont=[NSFont fontWithName:@"Verdana"size:8.0]; defaultFieldNameFont=[fontManager convertFont:defaultFieldNameFont toHaveTrait:NSBoldFontMask]; defaultFieldValueFont=[NSFont fontWithName:@"Verdana"size:8.0]; clrIntestazione=[NSColor colorWithCalibratedRed:0.2 green:0.2 blue:0.8 alpha:1.0]; clrDettaglio=[NSColor colorWithCalibratedRed:0.1 green:0.2 blue:0.5 alpha:1.0]; NSMutableDictionary *attrs = [NSMutableDictionary dictionary]; [attrs setObject:defaultFieldNameFont forKey:NSFontAttributeName]; [attrs setObject:clrIntestazione forKey:NSForegroundColorAttributeName]; strASFieldNameDefault= [[NSMutableAttributedString alloc] initWithString:@" " attributes:attrs]; NSMutableDictionary *attrs2 = [NSMutableDictionary dictionary]; [attrs2 setObject:defaultFieldValueFont forKey:NSFontAttributeName]; [attrs2 setObject:clrDettaglio forKey:NSForegroundColorAttributeName]; strASFieldValueDefault= [[NSMutableAttributedString alloc] initWithString:@" " attributes:attrs2]; nCols=0; saElencoCampi=[[NSMutableArray alloc]init]; saValoreCampi=[[NSMutableArray alloc]init]; return self; } -(void)dealloc{ [strASFieldNameDefault release]; [strASFieldValueDefault release]; [saElencoCampi release]; [saValoreCampi release]; [super dealloc]; } //Add a field name -(void)addItemFieldName:(NSMutableAttributedString *) str withVisLen:(int)largVis withVisPrt:(int)largPrt{ [saElencoCampi addObject:str]; [saValoreCampi addObject:@""]; //Init to blank value nLenVis[nCols]=largVis; nLenPrt[nCols]=largPrt; nCols++; } //Add a field name using default NSAttrubutedString -(void)addItemFieldNameWithString:(NSString *) str withVisLen:(int)largVis withVisPrt:(int)largPrt{ NSMutableAttributedString *aASstr=[[NSMutableAttributedString alloc]initWithAttributedString:strASFieldNameDefault]; [[aASstr mutableString ] setString:str]; [self addItemFieldName:aASstr withVisLen:largVis withVisPrt:largPrt]; } //set a field value at index element -(void)setItemFieldValue:(NSMutableAttributedString *) str forIndex:(int)atIndex{ if(atIndex>=0 && atIndex=0 && atIndex=0 && atIndexnCols) return szCalculatedPosition; NSMutableAttributedString *tmpObj=nil; NSSize szTmp; tmpObj=[[NSMutableAttributedString alloc] init]; tmpObj=[[NSMutableAttributedString alloc] initWithAttributedString:[saElencoCampi objectAtIndex:0]]; szTmp=[tmpObj size]; szCalculatedPosition.width=nLenPrt[atIndex]; szCalculatedPosition.height=szTmp.height; [tmpObj release]; return szCalculatedPosition; } //remove all objects -(void) removeAllObjects{ [saElencoCampi removeAllObjects]; [saValoreCampi removeAllObjects]; nCols=0; } //Return Field Name at index -(NSMutableAttributedString *) fieldName:(int)atIndex{ if(atIndex>=0 && atIndex=0 && atIndex