API  0.9.6
 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 
36 #import "Ref.h"
37 @implementation CPFormatter : CPObject
38 {
39  id __doxygen__;
40 }
41 
54 - (CPString)stringForObjectValue:(id)anObject
55 {
56  _CPRaiseInvalidAbstractInvocation(self, _cmd);
57  return nil;
58 }
59 
60 /*- (CPAttributedString)attributedStringForObjectValue:(id)anObject withDefaultAttributes:(CPDictionary)attributes
61 {
62 
63 }*/
64 
76 - (CPString)editingStringForObjectValue:(id)anObject
77 {
78  return [self stringForObjectValue:anObject];
79 }
80 
96 - (BOOL)getObjectValue:(idRef)anObject forString:(CPString)aString errorDescription:(CPStringRef)anError
97 {
98  _CPRaiseInvalidAbstractInvocation(self, _cmd);
99  return NO;
100 }
101 
124 - (BOOL)isPartialStringValid:(CPString)aPartialString newEditingString:(CPStringRef)aNewString errorDescription:(CPStringRef)anError
125 {
126  AT_DEREF(aPartialString, nil);
127 
128  if (anError)
129  AT_DEREF(anError, nil);
130 
131  return YES;
132 }
133 
153 - (BOOL)isPartialStringValid:(CPStringRef)aPartialString proposedSelectedRange:(CPRangeRef)aProposedSelectedRange originalString:(CPString)originalString originalSelectedRange:(CPRange)originalSelectedRange errorDescription:(CPStringRef)anError
154 {
155  var newString = nil,
156  valid = [self isPartialStringValid:aPartialString newEditingString:AT_REF(newString) errorDescription:anError];
157 
158  if (!valid)
159  {
160  AT_DEREF(aPartialString, newString);
161 
162  // If a new string is passed back, the selection is always put at the end
163  if (newString !== nil)
164  AT_DEREF(aProposedSelectedRange, CPMakeRange(newString.length, 0));
165  }
166 
167  return valid;
168 }
169 
170 - (id)initWithCoder:(CPCoder)aCoder
171 {
172  return [self init];
173 }
174 
175 - (void)encodeWithCoder:(CPCoder)aCoder
176 {
177 }
178 
179 @end