diff options
Diffstat (limited to 'libs/FontLabel/ZAttributedString.h')
-rwxr-xr-x | libs/FontLabel/ZAttributedString.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/libs/FontLabel/ZAttributedString.h b/libs/FontLabel/ZAttributedString.h new file mode 100755 index 0000000..e194c81 --- /dev/null +++ b/libs/FontLabel/ZAttributedString.h | |||
@@ -0,0 +1,77 @@ | |||
1 | // | ||
2 | // ZAttributedString.h | ||
3 | // FontLabel | ||
4 | // | ||
5 | // Created by Kevin Ballard on 9/22/09. | ||
6 | // Copyright 2009 Zynga Game Networks. All rights reserved. | ||
7 | // | ||
8 | |||
9 | #import <Foundation/Foundation.h> | ||
10 | |||
11 | #if NS_BLOCKS_AVAILABLE | ||
12 | #define Z_BLOCKS 1 | ||
13 | #else | ||
14 | // set this to 1 if you are using PLBlocks | ||
15 | #define Z_BLOCKS 0 | ||
16 | #endif | ||
17 | |||
18 | #if Z_BLOCKS | ||
19 | enum { | ||
20 | ZAttributedStringEnumerationReverse = (1UL << 1), | ||
21 | ZAttributedStringEnumerationLongestEffectiveRangeNotRequired = (1UL << 20) | ||
22 | }; | ||
23 | typedef NSUInteger ZAttributedStringEnumerationOptions; | ||
24 | #endif | ||
25 | |||
26 | @interface ZAttributedString : NSObject <NSCoding, NSCopying, NSMutableCopying> { | ||
27 | NSMutableString *_buffer; | ||
28 | NSMutableArray *_attributes; | ||
29 | } | ||
30 | @property (nonatomic, readonly) NSUInteger length; | ||
31 | @property (nonatomic, readonly) NSString *string; | ||
32 | - (id)initWithAttributedString:(ZAttributedString *)attr; | ||
33 | - (id)initWithString:(NSString *)str; | ||
34 | - (id)initWithString:(NSString *)str attributes:(NSDictionary *)attributes; | ||
35 | - (id)attribute:(NSString *)attributeName atIndex:(NSUInteger)index effectiveRange:(NSRangePointer)aRange; | ||
36 | - (id)attribute:(NSString *)attributeName atIndex:(NSUInteger)index longestEffectiveRange:(NSRangePointer)aRange inRange:(NSRange)rangeLimit; | ||
37 | - (ZAttributedString *)attributedSubstringFromRange:(NSRange)aRange; | ||
38 | - (NSDictionary *)attributesAtIndex:(NSUInteger)index effectiveRange:(NSRangePointer)aRange; | ||
39 | - (NSDictionary *)attributesAtIndex:(NSUInteger)index longestEffectiveRange:(NSRangePointer)aRange inRange:(NSRange)rangeLimit; | ||
40 | #if Z_BLOCKS | ||
41 | - (void)enumerateAttribute:(NSString *)attrName inRange:(NSRange)enumerationRange options:(ZAttributedStringEnumerationOptions)opts | ||
42 | usingBlock:(void (^)(id value, NSRange range, BOOL *stop))block; | ||
43 | - (void)enumerateAttributesInRange:(NSRange)enumerationRange options:(ZAttributedStringEnumerationOptions)opts | ||
44 | usingBlock:(void (^)(NSDictionary *attrs, NSRange range, BOOL *stop))block; | ||
45 | #endif | ||
46 | - (BOOL)isEqualToAttributedString:(ZAttributedString *)otherString; | ||
47 | @end | ||
48 | |||
49 | @interface ZMutableAttributedString : ZAttributedString { | ||
50 | } | ||
51 | - (void)addAttribute:(NSString *)name value:(id)value range:(NSRange)range; | ||
52 | - (void)addAttributes:(NSDictionary *)attributes range:(NSRange)range; | ||
53 | - (void)appendAttributedString:(ZAttributedString *)str; | ||
54 | - (void)deleteCharactersInRange:(NSRange)range; | ||
55 | - (void)insertAttributedString:(ZAttributedString *)str atIndex:(NSUInteger)idx; | ||
56 | - (void)removeAttribute:(NSString *)name range:(NSRange)range; | ||
57 | - (void)replaceCharactersInRange:(NSRange)range withAttributedString:(ZAttributedString *)str; | ||
58 | - (void)replaceCharactersInRange:(NSRange)range withString:(NSString *)str; | ||
59 | - (void)setAttributedString:(ZAttributedString *)str; | ||
60 | - (void)setAttributes:(NSDictionary *)attributes range:(NSRange)range; | ||
61 | @end | ||
62 | |||
63 | extern NSString * const ZFontAttributeName; | ||
64 | extern NSString * const ZForegroundColorAttributeName; | ||
65 | extern NSString * const ZBackgroundColorAttributeName; | ||
66 | extern NSString * const ZUnderlineStyleAttributeName; | ||
67 | |||
68 | enum { | ||
69 | ZUnderlineStyleNone = 0x00, | ||
70 | ZUnderlineStyleSingle = 0x01 | ||
71 | }; | ||
72 | #define ZUnderlineStyleMask 0x00FF | ||
73 | |||
74 | enum { | ||
75 | ZUnderlinePatternSolid = 0x0000 | ||
76 | }; | ||
77 | #define ZUnderlinePatternMask 0xFF00 | ||