![]() |
API 0.9.5
|
00001 /* 00002 * CPFormatter.j 00003 * Foundation 00004 * 00005 * Created by Randall Luecke 00006 * Copyright 2010, RCLConcepts, LLC. 00007 * 00008 * This library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public 00010 * License as published by the Free Software Foundation; either 00011 * version 2.1 of the License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with this library; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00021 */ 00022 00036 #import "Ref.h" 00037 @implementation CPFormatter : CPObject 00038 { 00039 id __doxygen__; 00040 } 00041 00054 - (CPString)stringForObjectValue:(id)anObject 00055 { 00056 _CPRaiseInvalidAbstractInvocation(self, _cmd); 00057 return nil; 00058 } 00059 00060 /*- (CPAttributedString)attributedStringForObjectValue:(id)anObject withDefaultAttributes:(CPDictionary)attributes 00061 { 00062 00063 }*/ 00064 00076 - (CPString)editingStringForObjectValue:(id)anObject 00077 { 00078 return [self stringForObjectValue:anObject]; 00079 } 00080 00096 - (BOOL)getObjectValue:(idRef)anObject forString:(CPString)aString errorDescription:(CPStringRef)anError 00097 { 00098 _CPRaiseInvalidAbstractInvocation(self, _cmd); 00099 return NO; 00100 } 00101 00124 - (BOOL)isPartialStringValid:(CPString)aPartialString newEditingString:(CPStringRef)aNewString errorDescription:(CPStringRef)anError 00125 { 00126 AT_DEREF(aPartialString, nil); 00127 00128 if (anError) 00129 AT_DEREF(anError, nil); 00130 00131 return YES; 00132 } 00133 00153 - (BOOL)isPartialStringValid:(CPStringRef)aPartialString proposedSelectedRange:(CPRangeRef)aProposedSelectedRange originalString:(CPString)originalString originalSelectedRange:(CPRange)originalSelectedRange errorDescription:(CPStringRef)anError 00154 { 00155 var newString = nil, 00156 valid = [self isPartialStringValid:aPartialString newEditingString:AT_REF(newString) errorDescription:anError]; 00157 00158 if (!valid) 00159 { 00160 AT_DEREF(aPartialString, newString); 00161 00162 // If a new string is passed back, the selection is always put at the end 00163 if (newString !== nil) 00164 AT_DEREF(aProposedSelectedRange, CPMakeRange(newString.length, 0)); 00165 } 00166 00167 return valid; 00168 } 00169 00170 - (id)initWithCoder:(CPCoder)aCoder 00171 { 00172 return [self init]; 00173 } 00174 00175 - (void)encodeWithCoder:(CPCoder)aCoder 00176 { 00177 } 00178 00179 @end