|
From: Geisschaes <gei...@us...> - 2005-02-06 19:38:23
|
Update of /cvsroot/macattrick/macattrick In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26622 Added Files: PercentageTransformer.h PercentageTransformer.m Log Message: Percentage Controller added --- NEW FILE: PercentageTransformer.h --- //---- license ---------------------------------------------------------------// // // // Macattrick: a Manager Assistant Tool for the online Game Hattrick.org // // Copyright (C) 2004 Roman Bertolami // // // // this file is part of Macattrick application // // http://sourceforge.net/macattrick // // // // Macattrick 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. // // // // Macattrick 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., 59 Temple Place - Suite 330, // // Boston, MA 02111-1307, USA. // // // // Macattrick, Copyright (C) 2004 Roman Bertolami // // Macattrick comes with ABSOLUTELY NO WARRANTY! // // // //---- eo licence ------------------------------------------------------------// #import <Cocoa/Cocoa.h> @interface PercentageTransformer : NSValueTransformer { } + (Class)transformedValueClass; + (BOOL)allowsReverseTransformation; - (id)transformedValue:(id)value; @end --- NEW FILE: PercentageTransformer.m --- //---- license ---------------------------------------------------------------// // // // Macattrick: a Manager Assistant Tool for the online Game Hattrick.org // // Copyright (C) 2004 Roman Bertolami // // // // this file is part of Macattrick application // // http://sourceforge.net/macattrick // // // // Macattrick 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. // // // // Macattrick 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., 59 Temple Place - Suite 330, // // Boston, MA 02111-1307, USA. // // // // Macattrick, Copyright (C) 2004 Roman Bertolami // // Macattrick comes with ABSOLUTELY NO WARRANTY! // // // //---- eo licence ------------------------------------------------------------// #import "PercentageTransformer.h" @implementation PercentageTransformer + (Class)transformedValueClass { return [NSNumber class]; } + (BOOL)allowsReverseTransformation { return YES; } - (id)transformedValue:(id)value { if (value == nil) return nil; double inputValue = [value doubleValue]; int result = inputValue * 100; return [NSNumber numberWithInt:result]; } -(id)reverseTransformedValue:(id)value { if (value == nil) return nil; int inputValue = [value intValue]; double result = ((double)inputValue ) / 100; return [NSNumber numberWithDouble:result]; } @end |