API  0.9.7
 All Classes Files Functions Variables Macros Groups Pages
CPFormatter.j
Go to the documentation of this file.
1 /*
2  * CPFormatter.j
3  * Foundation
4  *
5  * Created by Randall Luecke
6  * Copyright 2010, RCLConcepts, LLC.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
35 @implementation CPFormatter : CPObject
36 {
37  id __doxygen__;
38 }
39 
52 - (CPString)stringForObjectValue:(id)anObject
53 {
54  _CPRaiseInvalidAbstractInvocation(self, _cmd);
55  return nil;
56 }
57 
58 /*- (CPAttributedString)attributedStringForObjectValue:(id)anObject withDefaultAttributes:(CPDictionary)attributes
59 {
60 
61 }*/
62 
74 - (CPString)editingStringForObjectValue:(id)anObject
75 {
76  return [self stringForObjectValue:anObject];
77 }
78 
94 - (BOOL)getObjectValue:(idRef)anObject forString:(CPString)aString errorDescription:(CPStringRef)anError
95 {
96  _CPRaiseInvalidAbstractInvocation(self, _cmd);
97  return NO;
98 }
99 
122 - (BOOL)isPartialStringValid:(CPString)aPartialString newEditingString:(CPStringRef)aNewString errorDescription:(CPStringRef)anError
123 {
124  @deref(aPartialString) = nil;
125 
126  if (anError)
127  @deref(anError) = nil;
128 
129  return YES;
130 }
131 
151 - (BOOL)isPartialStringValid:(CPStringRef)aPartialStringRef proposedSelectedRange:(CPRangeRef)aProposedSelectedRangeRef originalString:(CPString)originalString originalSelectedRange:(CPRange)originalSelectedRange errorDescription:(CPStringRef)anError
152 {
153  var newString = nil,
154  valid = [self isPartialStringValid:aPartialStringRef newEditingString:@ref(newString) errorDescription:anError];
155 
156  if (!valid)
157  {
158  @deref(aPartialStringRef) = newString;
159 
160  // If a new string is passed back, the selection is always put at the end
161  if (newString !== nil)
162  @deref(aProposedSelectedRangeRef) = CPMakeRange(newString.length, 0);
163  }
164 
165  return valid;
166 }
167 
168 - (id)initWithCoder:(CPCoder)aCoder
169 {
170  return [self init];
171 }
172 
173 - (void)encodeWithCoder:(CPCoder)aCoder
174 {
175 }
176 
177 @end