1 | /*-------------------------------------------------------------------------------------------------------*\ |
---|
2 | | Adium, Copyright (C) 2001-2005, Adam Iser (adamiser@mac.com | http://www.adiumx.com) | |
---|
3 | \---------------------------------------------------------------------------------------------------------/ |
---|
4 | | This program is free software; you can redistribute it and/or modify it under the terms of the GNU |
---|
5 | | General Public License as published by the Free Software Foundation; either version 2 of the License, |
---|
6 | | or (at your option) any later version. |
---|
7 | | |
---|
8 | | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even |
---|
9 | | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
---|
10 | | Public License for more details. |
---|
11 | | |
---|
12 | | You should have received a copy of the GNU General Public License along with this program; if not, |
---|
13 | | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
14 | \------------------------------------------------------------------------------------------------------ */ |
---|
15 | |
---|
16 | /*! |
---|
17 | * @class AIStringFormatter |
---|
18 | * @brief Formatter which restricts characters and length. |
---|
19 | * |
---|
20 | * <tt>NSFormatter</tt> subclass which formats to a specified <tt>NSCharacterSet</tt> and length. An errorMessage may be set which will be displayed after the user makes 3 invalid input attempts. |
---|
21 | */ |
---|
22 | @interface AIStringFormatter : NSFormatter { |
---|
23 | NSCharacterSet *characters; |
---|
24 | int length; |
---|
25 | BOOL caseSensitive; |
---|
26 | |
---|
27 | NSString *errorMessage; |
---|
28 | int errorCount; |
---|
29 | } |
---|
30 | |
---|
31 | /*! |
---|
32 | * @brief Create an <tt>AIStringFormatter</tt> |
---|
33 | * |
---|
34 | * Create an autoreleased <tt>AIStringFormatter</tt> |
---|
35 | * @param inCharacters An <tt>NSCharacterSet</tt> of all allowed characters |
---|
36 | * @param inLength The maximum allowed length of the formatted string |
---|
37 | * @param inCaseSensitive YES if the characters should be tested with respect for case |
---|
38 | * @param errorMessage A message to be displayed to the user after 3 invalid input attempts. If nil, no error message is displayed. |
---|
39 | * @return An <tt>AIStringFormatter</tt> object |
---|
40 | */ |
---|
41 | + (id)stringFormatterAllowingCharacters:(NSCharacterSet *)inCharacters length:(int)inLength caseSensitive:(BOOL)inCaseSensitive errorMessage:(NSString *)errorMessage; |
---|
42 | |
---|
43 | @end |
---|