/* main.m Copyright (C) 1999 Free Software Foundation, Inc. Author: Laurent Julliard Date: Nov 2001 This file is part of GNUstep. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include #include #include #include #include #include #include #include #include "GormPrivate.h" /* ----------------------------------------------------------- * Some additions to the NSNumberFormatter Class specific to Gorm * -----------------------------------------------------------*/ NSArray *predefinedNumberFormats; int defaultNumberFormatIndex = 0; @implementation NSNumberFormatter (GormAdditions) + (void) initialize { predefinedNumberFormats = [NSArray arrayWithObjects: [NSArray arrayWithObjects: @"$#,##0.00;0.00;-$#,##0.00",@"9999.99",@"-9999.99",nil], [NSArray arrayWithObjects: @"$#,##0.00;0.00;[Red]($#,##0.00)",@"9999.99",@"-9999.99",nil], [NSArray arrayWithObjects: @"0.00;0.00;-0.00",@"9999.99",@"-9999.99",nil], [NSArray arrayWithObjects: @"0;0;-0",@"100",@"-100",nil], [NSArray arrayWithObjects: @"00000;00000;-00000",@"100",@"-100",nil], [NSArray arrayWithObjects: @"0%;0%;-0%",@"100",@"-100",nil], [NSArray arrayWithObjects: @"0.00%;0.00%;-0.00%",@"99.99",@"-99.99",nil], nil]; } + (int) formatCount { return [predefinedNumberFormats count]; } + (NSString *) formatAtIndex: (int)i { return [[predefinedNumberFormats objectAtIndex:i] objectAtIndex:0]; } + (NSString *) positiveFormatAtIndex: (int)i { NSString *fmt =[[predefinedNumberFormats objectAtIndex:i] objectAtIndex:0]; return [ [fmt componentsSeparatedByString:@";"] objectAtIndex:0]; } + (NSString *) zeroFormatAtIndex: (int)i { NSString *fmt =[[predefinedNumberFormats objectAtIndex:i] objectAtIndex:0]; return [ [fmt componentsSeparatedByString:@";"] objectAtIndex:1]; } + (NSString *) negativeFormatAtIndex: (int)i { NSString *fmt =[[predefinedNumberFormats objectAtIndex:i] objectAtIndex:0]; return [ [fmt componentsSeparatedByString:@";"] objectAtIndex:2]; } + (NSDecimalNumber *) positiveValueAtIndex: (int)i { return [NSDecimalNumber decimalNumberWithString: [[predefinedNumberFormats objectAtIndex:i] objectAtIndex:1] ]; } + (NSDecimalNumber *) negativeValueAtIndex: (int)i { return [NSDecimalNumber decimalNumberWithString: [[predefinedNumberFormats objectAtIndex:i] objectAtIndex:2] ]; } + (int) indexOfFormat: (NSString *) format { int i; NSString *fmt; int count = [predefinedNumberFormats count]; for (i=0;i