mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-24 04:46:01 +08:00
Created a binary of Three20 to bundle with the discussion board example
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Three20, without additions.
|
||||
#import "Three20/Three20.h"
|
||||
|
||||
// Core Additions
|
||||
#import "Three20Core/Three20Core+Additions.h"
|
||||
|
||||
// Network Additions
|
||||
// No additions for Network yet.
|
||||
//#import "Three20Network/Three20Network+Additions.h"
|
||||
|
||||
// Style Additions
|
||||
#import "Three20Style/Three20Style+Additions.h"
|
||||
|
||||
// UICommon
|
||||
#import "Three20UICommon/Three20UICommon+Additions.h"
|
||||
|
||||
// UINavigator
|
||||
#import "Three20UINavigator/Three20UINavigator+Additions.h"
|
||||
|
||||
// UI Additions
|
||||
#import "Three20UI/Three20UI+Additions.h"
|
||||
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
/*! \mainpage Three20 API Documentation
|
||||
*
|
||||
* Generated from Three20 Cut <a href="http://three20.info/roadmap/v1.0a2">v1.0a2</a>.
|
||||
*
|
||||
*/
|
||||
|
||||
// Core
|
||||
#import "Three20Core/Three20Core.h"
|
||||
|
||||
// Network
|
||||
#import "Three20Network/Three20Network.h"
|
||||
|
||||
// Style
|
||||
#import "Three20Style/Three20Style.h"
|
||||
|
||||
// UICommon
|
||||
#import "Three20UICommon/Three20UICommon.h"
|
||||
|
||||
// UINavigator
|
||||
#import "Three20UINavigator/Three20UINavigator.h"
|
||||
|
||||
// UI
|
||||
#import "Three20UI/Three20UI.h"
|
||||
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface NSArray (TTCategory)
|
||||
|
||||
/**
|
||||
* Calls performSelector on all objects that can receive the selector in the array.
|
||||
* Makes an iterable copy of the array, making it possible for the selector to modify
|
||||
* the array. Contrast this with makeObjectsPerformSelector which does not allow side effects of
|
||||
* modifying the array.
|
||||
*/
|
||||
- (void)perform:(SEL)selector;
|
||||
- (void)perform:(SEL)selector withObject:(id)p1;
|
||||
- (void)perform:(SEL)selector withObject:(id)p1 withObject:(id)p2;
|
||||
- (void)perform:(SEL)selector withObject:(id)p1 withObject:(id)p2 withObject:(id)p3;
|
||||
|
||||
/**
|
||||
* Extensions to makeObjectsPerformSelector to provide support for more than one object
|
||||
* parameter.
|
||||
*/
|
||||
- (void)makeObjectsPerformSelector:(SEL)selector withObject:(id)p1 withObject:(id)p2;
|
||||
- (void)makeObjectsPerformSelector: (SEL)selector
|
||||
withObject: (id)p1
|
||||
withObject: (id)p2
|
||||
withObject: (id)p3;
|
||||
|
||||
/**
|
||||
* @return nil or an object that matches value with isEqual:
|
||||
*/
|
||||
- (id)objectWithValue:(id)value forKey:(id)key;
|
||||
|
||||
/**
|
||||
* @return the first object with the given class.
|
||||
*/
|
||||
- (id)objectWithClass:(Class)cls;
|
||||
|
||||
/**
|
||||
* @param selector Required format: - (NSNumber*)method:(id)object;
|
||||
*/
|
||||
- (BOOL)containsObject:(id)object withSelector:(SEL)selector;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface NSData (TTCategory)
|
||||
|
||||
/**
|
||||
* Calculate the md5 hash of this data using CC_MD5.
|
||||
*
|
||||
* @return md5 hash of this data
|
||||
*/
|
||||
@property (nonatomic, readonly) NSString* md5Hash;
|
||||
|
||||
/**
|
||||
* Calculate the SHA1 hash of this data using CC_SHA1.
|
||||
*
|
||||
* @return SHA1 hash of this data
|
||||
*/
|
||||
@property (nonatomic, readonly) NSString* sha1Hash;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,86 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface NSDate (TTCategory)
|
||||
|
||||
/**
|
||||
* Returns the current date with the time set to midnight.
|
||||
*/
|
||||
+ (NSDate*)dateWithToday;
|
||||
|
||||
/**
|
||||
* Returns a copy of the date with the time set to midnight on the same day.
|
||||
*/
|
||||
- (NSDate*)dateAtMidnight;
|
||||
|
||||
/**
|
||||
* Formats the date with 'h:mm a' or the localized equivalent.
|
||||
*/
|
||||
- (NSString*)formatTime;
|
||||
|
||||
/**
|
||||
* Formats the date with 'EEEE, LLLL d, YYYY' or the localized equivalent.
|
||||
*/
|
||||
- (NSString*)formatDate;
|
||||
|
||||
/**
|
||||
* Formats the date according to how old it is.
|
||||
*
|
||||
* For dates less than a day old, the format is 'h:mm a', for less than a week old the
|
||||
* format is 'EEEE', and for anything older the format is 'M/d/yy'.
|
||||
*/
|
||||
- (NSString*)formatShortTime;
|
||||
|
||||
/**
|
||||
* Formats the date according to how old it is.
|
||||
*
|
||||
* For dates less than a day old, the format is 'h:mm a', for less than a week old the
|
||||
* format is 'EEE h:mm a', and for anything older the format is 'MMM d h:mm a'.
|
||||
*/
|
||||
- (NSString*)formatDateTime;
|
||||
|
||||
/**
|
||||
* Formats dates within 24 hours like '5 minutes ago', or calls formatDateTime if older.
|
||||
*/
|
||||
- (NSString*)formatRelativeTime;
|
||||
|
||||
/**
|
||||
* Formats dates within 1 week like '5m' or '2d', or calls formatShortTime if older.
|
||||
*/
|
||||
- (NSString*)formatShortRelativeTime;
|
||||
|
||||
/**
|
||||
* Formats the date with 'MMMM d", "Today", or "Yesterday".
|
||||
*
|
||||
* You must supply date components for today and yesterday because they are relatively expensive
|
||||
* to create, so it is best to avoid creating them every time you call this method if you
|
||||
* are going to be calling it multiple times in a loop.
|
||||
*/
|
||||
- (NSString*)formatDay:(NSDateComponents*)today yesterday:(NSDateComponents*)yesterday;
|
||||
|
||||
/**
|
||||
* Formats the date with 'MMMM".
|
||||
*/
|
||||
- (NSString*)formatMonth;
|
||||
|
||||
/**
|
||||
* Formats the date with 'yyyy".
|
||||
*/
|
||||
- (NSString*)formatYear;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface NSMutableArray (TTCategory)
|
||||
|
||||
/**
|
||||
* Adds a string on the condition that it's non-nil and non-empty.
|
||||
*/
|
||||
- (void)addNonEmptyString:(NSString*)string;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface NSMutableDictionary (TTCategory)
|
||||
|
||||
/**
|
||||
* Adds a string on the condition that it's non-nil and non-empty.
|
||||
*/
|
||||
- (void)setNonEmptyString:(NSString*)string forKey:(id)key;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface NSObject (TTAdditions)
|
||||
|
||||
/**
|
||||
* Additional performSelector signatures that support up to 7 arguments.
|
||||
*/
|
||||
- (id)performSelector:(SEL)selector withObject:(id)p1 withObject:(id)p2 withObject:(id)p3;
|
||||
- (id)performSelector:(SEL)selector withObject:(id)p1 withObject:(id)p2 withObject:(id)p3
|
||||
withObject:(id)p4;
|
||||
- (id)performSelector:(SEL)selector withObject:(id)p1 withObject:(id)p2 withObject:(id)p3
|
||||
withObject:(id)p4 withObject:(id)p5;
|
||||
- (id)performSelector:(SEL)selector withObject:(id)p1 withObject:(id)p2 withObject:(id)p3
|
||||
withObject:(id)p4 withObject:(id)p5 withObject:(id)p6;
|
||||
- (id)performSelector:(SEL)selector withObject:(id)p1 withObject:(id)p2 withObject:(id)p3
|
||||
withObject:(id)p4 withObject:(id)p5 withObject:(id)p6 withObject:(id)p7;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,107 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "Three20Core/TTCorePreprocessorMacros.h" // For __TTDEPRECATED_METHOD
|
||||
|
||||
/**
|
||||
* Doxygen does not handle categories very well, so please refer to the .m file in general
|
||||
* for the documentation that is reflected on api.three20.info.
|
||||
*/
|
||||
@interface NSString (TTAdditions)
|
||||
|
||||
/**
|
||||
* Determines if the string contains only whitespace and newlines.
|
||||
*/
|
||||
- (BOOL)isWhitespaceAndNewlines;
|
||||
|
||||
/**
|
||||
* Determines if the string is empty or contains only whitespace.
|
||||
*/
|
||||
- (BOOL)isEmptyOrWhitespace;
|
||||
|
||||
/**
|
||||
* Parses a URL query string into a dictionary.
|
||||
*
|
||||
* @deprecated Use queryContentsUsingEncoding: instead.
|
||||
*/
|
||||
- (NSDictionary*)queryDictionaryUsingEncoding:(NSStringEncoding)encoding __TTDEPRECATED_METHOD;
|
||||
|
||||
/**
|
||||
* Parses a URL query string into a dictionary where the values are arrays.
|
||||
*/
|
||||
- (NSDictionary*)queryContentsUsingEncoding:(NSStringEncoding)encoding;
|
||||
|
||||
/**
|
||||
* Parses a URL, adds query parameters to its query, and re-encodes it as a new URL.
|
||||
*/
|
||||
- (NSString*)stringByAddingQueryDictionary:(NSDictionary*)query;
|
||||
|
||||
/**
|
||||
* Returns a string with all HTML tags removed.
|
||||
*/
|
||||
- (NSString*)stringByRemovingHTMLTags;
|
||||
|
||||
/**
|
||||
* Compares two strings expressing software versions.
|
||||
*
|
||||
* The comparison is (except for the development version provisions noted below) lexicographic
|
||||
* string comparison. So as long as the strings being compared use consistent version formats,
|
||||
* a variety of schemes are supported. For example "3.02" < "3.03" and "3.0.2" < "3.0.3". If you
|
||||
* mix such schemes, like trying to compare "3.02" and "3.0.3", the result may not be what you
|
||||
* expect.
|
||||
*
|
||||
* Development versions are also supported by adding an "a" character and more version info after
|
||||
* it. For example "3.0a1" or "3.01a4". The way these are handled is as follows: if the parts
|
||||
* before the "a" are different, the parts after the "a" are ignored. If the parts before the "a"
|
||||
* are identical, the result of the comparison is the result of NUMERICALLY comparing the parts
|
||||
* after the "a". If the part after the "a" is empty, it is treated as if it were "0". If one
|
||||
* string has an "a" and the other does not (e.g. "3.0" and "3.0a1") the one without the "a"
|
||||
* is newer.
|
||||
*
|
||||
* Examples (?? means undefined):
|
||||
* "3.0" = "3.0"
|
||||
* "3.0a2" = "3.0a2"
|
||||
* "3.0" > "2.5"
|
||||
* "3.1" > "3.0"
|
||||
* "3.0a1" < "3.0"
|
||||
* "3.0a1" < "3.0a4"
|
||||
* "3.0a2" < "3.0a19" <-- numeric, not lexicographic
|
||||
* "3.0a" < "3.0a1"
|
||||
* "3.02" < "3.03"
|
||||
* "3.0.2" < "3.0.3"
|
||||
* "3.00" ?? "3.0"
|
||||
* "3.02" ?? "3.0.3"
|
||||
* "3.02" ?? "3.0.2"
|
||||
*/
|
||||
- (NSComparisonResult)versionStringCompare:(NSString *)other;
|
||||
|
||||
/**
|
||||
* Calculate the md5 hash of this string using CC_MD5.
|
||||
*
|
||||
* @return md5 hash of this string
|
||||
*/
|
||||
@property (nonatomic, readonly) NSString* md5Hash;
|
||||
|
||||
/**
|
||||
* Calculate the SHA1 hash of this string using CommonCrypto CC_SHA1.
|
||||
*
|
||||
* @return NSString with SHA1 hash of this string
|
||||
*/
|
||||
@property (nonatomic, readonly) NSString* sha1Hash;
|
||||
|
||||
@end
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Code Management
|
||||
|
||||
/**
|
||||
* Borrowed from Apple's AvailabiltyInternal.h header. There's no reason why we shouldn't be
|
||||
* able to use this macro, as it's a gcc-supported flag.
|
||||
* Here's what we based it off of.
|
||||
* __AVAILABILITY_INTERNAL_DEPRECATED __attribute__((deprecated))
|
||||
*/
|
||||
#define __TTDEPRECATED_METHOD __attribute__((deprecated))
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Flags
|
||||
|
||||
/**
|
||||
* For when the flag might be a set of bits, this will ensure that the exact set of bits in
|
||||
* the flag have been set in the value.
|
||||
*/
|
||||
#define IS_MASK_SET(value, flag) (((value) & (flag)) == (flag))
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Time
|
||||
|
||||
#define TT_MINUTE 60
|
||||
#define TT_HOUR (60 * TT_MINUTE)
|
||||
#define TT_DAY (24 * TT_HOUR)
|
||||
#define TT_5_DAYS (5 * TT_DAY)
|
||||
#define TT_WEEK (7 * TT_DAY)
|
||||
#define TT_MONTH (30.5 * TT_DAY)
|
||||
#define TT_YEAR (365 * TT_DAY)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Safe releases
|
||||
|
||||
#define TT_RELEASE_SAFELY(__POINTER) { [__POINTER release]; __POINTER = nil; }
|
||||
#define TT_INVALIDATE_TIMER(__TIMER) { [__TIMER invalidate]; __TIMER = nil; }
|
||||
|
||||
// Release a CoreFoundation object safely.
|
||||
#define TT_RELEASE_CF_SAFELY(__REF) { if (nil != (__REF)) { CFRelease(__REF); __REF = nil; } }
|
||||
@@ -0,0 +1,108 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
/**
|
||||
* Three20 Debugging tools.
|
||||
*
|
||||
* Provided in this header are a set of debugging tools. This is meant quite literally, in that
|
||||
* all of the macros below will only function when the DEBUG preprocessor macro is specified.
|
||||
*
|
||||
* TTDASSERT(<statement>);
|
||||
* If <statement> is false, the statement will be written to the log and if you are running in
|
||||
* the simulator with a debugger attached, the app will break on the assertion line.
|
||||
*
|
||||
* TTDPRINT(@"formatted log text %d", param1);
|
||||
* Print the given formatted text to the log.
|
||||
*
|
||||
* TTDPRINTMETHODNAME();
|
||||
* Print the current method name to the log.
|
||||
*
|
||||
* TTDCONDITIONLOG(<statement>, @"formatted log text %d", param1);
|
||||
* If <statement> is true, then the formatted text will be written to the log.
|
||||
*
|
||||
* TTDINFO/TTDWARNING/TTDERROR(@"formatted log text %d", param1);
|
||||
* Will only write the formatted text to the log if TTMAXLOGLEVEL is greater than the respective
|
||||
* TTD* method's log level. See below for log levels.
|
||||
*
|
||||
* The default maximum log level is TTLOGLEVEL_WARNING.
|
||||
*/
|
||||
|
||||
#define TTLOGLEVEL_INFO 5
|
||||
#define TTLOGLEVEL_WARNING 3
|
||||
#define TTLOGLEVEL_ERROR 1
|
||||
|
||||
#ifndef TTMAXLOGLEVEL
|
||||
#define TTMAXLOGLEVEL TTLOGLEVEL_WARNING
|
||||
#endif
|
||||
|
||||
// The general purpose logger. This ignores logging levels.
|
||||
#ifdef DEBUG
|
||||
#define TTDPRINT(xx, ...) NSLog(@"%s(%d): " xx, __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||
#else
|
||||
#define TTDPRINT(xx, ...) ((void)0)
|
||||
#endif // #ifdef DEBUG
|
||||
|
||||
// Prints the current method's name.
|
||||
#define TTDPRINTMETHODNAME() TTDPRINT(@"%s", __PRETTY_FUNCTION__)
|
||||
|
||||
// Debug-only assertions.
|
||||
#ifdef DEBUG
|
||||
|
||||
#import <TargetConditionals.h>
|
||||
|
||||
#if TARGET_IPHONE_SIMULATOR
|
||||
|
||||
int TTIsInDebugger();
|
||||
// We leave the __asm__ in this macro so that when a break occurs, we don't have to step out of
|
||||
// a "breakInDebugger" function.
|
||||
#define TTDASSERT(xx) { if(!(xx)) { TTDPRINT(@"TTDASSERT failed: %s", #xx); \
|
||||
if(TTIsInDebugger()) { __asm__("int $3\n" : : ); }; } \
|
||||
} ((void)0)
|
||||
#else
|
||||
#define TTDASSERT(xx) { if(!(xx)) { TTDPRINT(@"TTDASSERT failed: %s", #xx); } } ((void)0)
|
||||
#endif // #if TARGET_IPHONE_SIMULATOR
|
||||
|
||||
#else
|
||||
#define TTDASSERT(xx) ((void)0)
|
||||
#endif // #ifdef DEBUG
|
||||
|
||||
// Log-level based logging macros.
|
||||
#if TTLOGLEVEL_ERROR <= TTMAXLOGLEVEL
|
||||
#define TTDERROR(xx, ...) TTDPRINT(xx, ##__VA_ARGS__)
|
||||
#else
|
||||
#define TTDERROR(xx, ...) ((void)0)
|
||||
#endif // #if TTLOGLEVEL_ERROR <= TTMAXLOGLEVEL
|
||||
|
||||
#if TTLOGLEVEL_WARNING <= TTMAXLOGLEVEL
|
||||
#define TTDWARNING(xx, ...) TTDPRINT(xx, ##__VA_ARGS__)
|
||||
#else
|
||||
#define TTDWARNING(xx, ...) ((void)0)
|
||||
#endif // #if TTLOGLEVEL_WARNING <= TTMAXLOGLEVEL
|
||||
|
||||
#if TTLOGLEVEL_INFO <= TTMAXLOGLEVEL
|
||||
#define TTDINFO(xx, ...) TTDPRINT(xx, ##__VA_ARGS__)
|
||||
#else
|
||||
#define TTDINFO(xx, ...) ((void)0)
|
||||
#endif // #if TTLOGLEVEL_INFO <= TTMAXLOGLEVEL
|
||||
|
||||
#ifdef DEBUG
|
||||
#define TTDCONDITIONLOG(condition, xx, ...) { if ((condition)) { \
|
||||
TTDPRINT(xx, ##__VA_ARGS__); \
|
||||
} \
|
||||
} ((void)0)
|
||||
#else
|
||||
#define TTDCONDITIONLOG(condition, xx, ...) ((void)0)
|
||||
#endif // #ifdef DEBUG
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
/**
|
||||
* These flags are used primarily by TTDCONDITIONLOG.
|
||||
* Example:
|
||||
*
|
||||
* TTDCONDITIONLOG(TTDFLAG_NAVIGATOR, @"TTNavigator activated");
|
||||
*
|
||||
* This will only write to the log if the TTDFLAG_NAVIGATOR is set to non-zero.
|
||||
*/
|
||||
#define TTDFLAG_VIEWCONTROLLERS 0
|
||||
#define TTDFLAG_CONTROLLERGARBAGECOLLECTION 0
|
||||
#define TTDFLAG_NAVIGATOR 0
|
||||
#define TTDFLAG_TABLEVIEWMODIFICATIONS 0
|
||||
#define TTDFLAG_LAUNCHERVIEW 0
|
||||
#define TTDFLAG_URLREQUEST 0
|
||||
#define TTDFLAG_URLCACHE 0
|
||||
#define TTDFLAG_XMLPARSER 0
|
||||
#define TTDFLAG_ETAGS 0
|
||||
@@ -0,0 +1,47 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
/**
|
||||
* Standard entity tables for use with XML parsers.
|
||||
*
|
||||
* Supported entity tables: ISO 8859-1.
|
||||
*
|
||||
* Each table is a dictionary of entity names to NSData objects containing the character.
|
||||
*/
|
||||
@interface TTEntityTables : NSObject {
|
||||
NSDictionary* _iso88591;
|
||||
}
|
||||
|
||||
/**
|
||||
* Entity table for ISO 8859-1.
|
||||
*/
|
||||
@property (nonatomic, readonly) NSDictionary* iso88591;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface TTEntityTables (TTSingleton)
|
||||
|
||||
// Access the singleton instance: [[TTEntityTables sharedInstance] <methods>]
|
||||
+ (TTEntityTables*)sharedInstance;
|
||||
|
||||
// Release the shared instance.
|
||||
+ (void)releaseSharedInstance;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
/**
|
||||
* Creates a mutable array which does not retain references to the objects it contains.
|
||||
*
|
||||
* Typically used with arrays of delegates.
|
||||
*/
|
||||
NSMutableArray* TTCreateNonRetainingArray();
|
||||
|
||||
/**
|
||||
* Creates a mutable dictionary which does not retain references to the values it contains.
|
||||
*
|
||||
* Typically used with dictionaries of delegates.
|
||||
*/
|
||||
NSMutableDictionary* TTCreateNonRetainingDictionary();
|
||||
|
||||
/**
|
||||
* Tests if an object is an array which is not empty.
|
||||
*/
|
||||
BOOL TTIsArrayWithItems(id object);
|
||||
|
||||
/**
|
||||
* Tests if an object is a set which is not empty.
|
||||
*/
|
||||
BOOL TTIsSetWithItems(id object);
|
||||
|
||||
/**
|
||||
* Tests if an object is a string which is not empty.
|
||||
*/
|
||||
BOOL TTIsStringWithAnyText(id object);
|
||||
|
||||
/**
|
||||
* Swap the two method implementations on the given class.
|
||||
* Uses method_exchangeImplementations to accomplish this.
|
||||
*/
|
||||
void TTSwapMethods(Class cls, SEL originalSel, SEL newSel);
|
||||
@@ -0,0 +1,46 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
/**
|
||||
* Gets the current system locale chosen by the user.
|
||||
*
|
||||
* This is necessary because [NSLocale currentLocale] always returns en_US.
|
||||
*/
|
||||
NSLocale* TTCurrentLocale();
|
||||
|
||||
/**
|
||||
* @return A localized string from the Three20 bundle.
|
||||
*/
|
||||
NSString* TTLocalizedString(NSString* key, NSString* comment);
|
||||
|
||||
/**
|
||||
* @return A localized description for NSURLErrorDomain errors.
|
||||
*
|
||||
* Error codes handled:
|
||||
* - NSURLErrorTimedOut
|
||||
* - NSURLErrorNotConnectedToInternet
|
||||
* - All other NSURLErrorDomain errors fall through to "Connection Error".
|
||||
*/
|
||||
NSString* TTDescriptionForError(NSError* error);
|
||||
|
||||
/**
|
||||
* @return The given number formatted as XX,XXX,XXX.XX
|
||||
*
|
||||
* TODO(jverkoey 04/19/2010): This should likely be locale-aware.
|
||||
*/
|
||||
NSString* TTFormatInteger(NSInteger num);
|
||||
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
/**
|
||||
* @return YES if the URL begins with "bundle://"
|
||||
*/
|
||||
BOOL TTIsBundleURL(NSString* URL);
|
||||
|
||||
/**
|
||||
* @return YES if the URL begins with "documents://"
|
||||
*/
|
||||
BOOL TTIsDocumentsURL(NSString* URL);
|
||||
|
||||
/**
|
||||
* Used by TTPathForBundleResource to construct the bundle path.
|
||||
*
|
||||
* Retains the given bundle.
|
||||
*
|
||||
* @default nil (See TTGetDefaultBundle for what this means)
|
||||
*/
|
||||
void TTSetDefaultBundle(NSBundle* bundle);
|
||||
|
||||
/**
|
||||
* Retrieves the default bundle.
|
||||
*
|
||||
* If the default bundle is nil, returns [NSBundle mainBundle].
|
||||
*
|
||||
* @see TTSetDefaultBundle
|
||||
*/
|
||||
NSBundle* TTGetDefaultBundle();
|
||||
|
||||
/**
|
||||
* @return The main bundle path concatenated with the given relative path.
|
||||
*/
|
||||
NSString* TTPathForBundleResource(NSString* relativePath);
|
||||
|
||||
/**
|
||||
* @return The documents path concatenated with the given relative path.
|
||||
*/
|
||||
NSString* TTPathForDocumentsResource(NSString* relativePath);
|
||||
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
/**
|
||||
* @return a rectangle with dx and dy subtracted from the width and height, respectively.
|
||||
*
|
||||
* Example result: CGRectMake(x, y, w - dx, h - dy)
|
||||
*/
|
||||
CGRect TTRectContract(CGRect rect, CGFloat dx, CGFloat dy);
|
||||
|
||||
/**
|
||||
* @return a rectangle whose origin has been offset by dx, dy, and whose size has been
|
||||
* contracted by dx, dy.
|
||||
*
|
||||
* Example result: CGRectMake(x + dx, y + dy, w - dx, h - dy)
|
||||
*/
|
||||
CGRect TTRectShift(CGRect rect, CGFloat dx, CGFloat dy);
|
||||
|
||||
/**
|
||||
* @return a rectangle with the given insets.
|
||||
*
|
||||
* Example result: CGRectMake(x + left, y + top, w - (left + right), h - (top + bottom))
|
||||
*/
|
||||
CGRect TTRectInset(CGRect rect, UIEdgeInsets insets);
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#if __IPHONE_4_0 && __IPHONE_4_0 <= __IPHONE_OS_VERSION_MAX_ALLOWED
|
||||
@interface TTMarkupStripper : NSObject <NSXMLParserDelegate> {
|
||||
#else
|
||||
@interface TTMarkupStripper : NSObject {
|
||||
#endif
|
||||
@private
|
||||
NSMutableArray* _strings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Strips markup from the given string and returns the result.
|
||||
*/
|
||||
- (NSString*)parse:(NSString*)string;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import "Three20Core/Three20Core.h"
|
||||
|
||||
// Additions
|
||||
#import "Three20Core/NSArrayAdditions.h"
|
||||
#import "Three20Core/NSDataAdditions.h"
|
||||
#import "Three20Core/NSDateAdditions.h"
|
||||
#import "Three20Core/NSMutableArrayAdditions.h"
|
||||
#import "Three20Core/NSMutableDictionaryAdditions.h"
|
||||
#import "Three20Core/NSObjectAdditions.h"
|
||||
#import "Three20Core/NSStringAdditions.h"
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Core
|
||||
|
||||
// - Global
|
||||
#import "Three20Core/TTCorePreprocessorMacros.h"
|
||||
|
||||
#import "Three20Core/TTGlobalCore.h"
|
||||
#import "Three20Core/TTGlobalCoreLocale.h"
|
||||
#import "Three20Core/TTGlobalCorePaths.h"
|
||||
#import "Three20Core/TTGlobalCoreRects.h"
|
||||
|
||||
// - Debug
|
||||
#import "Three20Core/TTDebug.h"
|
||||
|
||||
// - Entity Tables
|
||||
#import "Three20Core/TTEntityTables.h"
|
||||
|
||||
// - Classes
|
||||
#import "Three20Core/TTMarkupStripper.h"
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
extern NSString* const kTTNetworkErrorDomain;
|
||||
extern NSInteger const kTTNetworkErrorCodeInvalidImage;
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#define TT_DEFAULT_CACHE_INVALIDATION_AGE (60*60*24) // 1 day
|
||||
#define TT_DEFAULT_CACHE_EXPIRATION_AGE (60*60*24*7) // 1 week
|
||||
#define TT_CACHE_EXPIRATION_AGE_NEVER (1.0 / 0.0) // inf
|
||||
|
||||
/**
|
||||
* Increment the number of active network requests.
|
||||
*
|
||||
* The status bar activity indicator will be spinning while there are active requests.
|
||||
*
|
||||
* @threadsafe
|
||||
*/
|
||||
void TTNetworkRequestStarted();
|
||||
|
||||
/**
|
||||
* Decrement the number of active network requests.
|
||||
*
|
||||
* The status bar activity indicator will be spinning while there are active requests.
|
||||
*
|
||||
* @threadsafe
|
||||
*/
|
||||
void TTNetworkRequestStopped();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Images
|
||||
|
||||
#define TTIMAGE(_URL) [[TTURLCache sharedCache] imageForURL:_URL]
|
||||
@@ -0,0 +1,145 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
// Network
|
||||
#import "Three20Network/TTURLRequestCachePolicy.h"
|
||||
|
||||
/**
|
||||
* TTModel describes the state of an object that can be loaded from a remote source.
|
||||
*
|
||||
* By implementing this protocol, you can communicate to the user the state of network
|
||||
* activity in an object.
|
||||
*/
|
||||
@protocol TTModel <NSObject>
|
||||
|
||||
/**
|
||||
* An array of objects that conform to the TTModelDelegate protocol.
|
||||
*/
|
||||
- (NSMutableArray*)delegates;
|
||||
|
||||
/**
|
||||
* Indicates that the data has been loaded.
|
||||
*
|
||||
* Default implementation returns YES.
|
||||
*/
|
||||
- (BOOL)isLoaded;
|
||||
|
||||
/**
|
||||
* Indicates that the data is in the process of loading.
|
||||
*
|
||||
* Default implementation returns NO.
|
||||
*/
|
||||
- (BOOL)isLoading;
|
||||
|
||||
/**
|
||||
* Indicates that the data is in the process of loading additional data.
|
||||
*
|
||||
* Default implementation returns NO.
|
||||
*/
|
||||
- (BOOL)isLoadingMore;
|
||||
|
||||
/**
|
||||
* Indicates that the model is of date and should be reloaded as soon as possible.
|
||||
*
|
||||
* Default implementation returns NO.
|
||||
*/
|
||||
-(BOOL)isOutdated;
|
||||
|
||||
/**
|
||||
* Loads the model.
|
||||
*
|
||||
* Default implementation does nothing.
|
||||
*/
|
||||
- (void)load:(TTURLRequestCachePolicy)cachePolicy more:(BOOL)more;
|
||||
|
||||
/**
|
||||
* Cancels a load that is in progress.
|
||||
*
|
||||
* Default implementation does nothing.
|
||||
*/
|
||||
- (void)cancel;
|
||||
|
||||
/**
|
||||
* Invalidates data stored in the cache or optionally erases it.
|
||||
*
|
||||
* Default implementation does nothing.
|
||||
*/
|
||||
- (void)invalidate:(BOOL)erase;
|
||||
|
||||
@end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* A default implementation of TTModel does nothing other than appear to be loaded.
|
||||
*/
|
||||
@interface TTModel : NSObject <TTModel> {
|
||||
NSMutableArray* _delegates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies delegates that the model started to load.
|
||||
*/
|
||||
- (void)didStartLoad;
|
||||
|
||||
/**
|
||||
* Notifies delegates that the model finished loading
|
||||
*/
|
||||
- (void)didFinishLoad;
|
||||
|
||||
/**
|
||||
* Notifies delegates that the model failed to load.
|
||||
*/
|
||||
- (void)didFailLoadWithError:(NSError*)error;
|
||||
|
||||
/**
|
||||
* Notifies delegates that the model canceled its load.
|
||||
*/
|
||||
- (void)didCancelLoad;
|
||||
|
||||
/**
|
||||
* Notifies delegates that the model has begun making multiple updates.
|
||||
*/
|
||||
- (void)beginUpdates;
|
||||
|
||||
/**
|
||||
* Notifies delegates that the model has completed its updates.
|
||||
*/
|
||||
- (void)endUpdates;
|
||||
|
||||
/**
|
||||
* Notifies delegates that an object was updated.
|
||||
*/
|
||||
- (void)didUpdateObject:(id)object atIndexPath:(NSIndexPath*)indexPath;
|
||||
|
||||
/**
|
||||
* Notifies delegates that an object was inserted.
|
||||
*/
|
||||
- (void)didInsertObject:(id)object atIndexPath:(NSIndexPath*)indexPath;
|
||||
|
||||
/**
|
||||
* Notifies delegates that an object was deleted.
|
||||
*/
|
||||
- (void)didDeleteObject:(id)object atIndexPath:(NSIndexPath*)indexPath;
|
||||
|
||||
/**
|
||||
* Notifies delegates that the model changed in some fundamental way.
|
||||
*/
|
||||
- (void)didChange;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,64 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@protocol TTModel;
|
||||
|
||||
@protocol TTModelDelegate <NSObject>
|
||||
|
||||
@optional
|
||||
|
||||
- (void)modelDidStartLoad:(id<TTModel>)model;
|
||||
|
||||
- (void)modelDidFinishLoad:(id<TTModel>)model;
|
||||
|
||||
- (void)model:(id<TTModel>)model didFailLoadWithError:(NSError*)error;
|
||||
|
||||
- (void)modelDidCancelLoad:(id<TTModel>)model;
|
||||
|
||||
/**
|
||||
* Informs the delegate that the model has changed in some fundamental way.
|
||||
*
|
||||
* The change is not described specifically, so the delegate must assume that the entire
|
||||
* contents of the model may have changed, and react almost as if it was given a new model.
|
||||
*/
|
||||
- (void)modelDidChange:(id<TTModel>)model;
|
||||
|
||||
- (void)model:(id<TTModel>)model didUpdateObject:(id)object atIndexPath:(NSIndexPath*)indexPath;
|
||||
|
||||
- (void)model:(id<TTModel>)model didInsertObject:(id)object atIndexPath:(NSIndexPath*)indexPath;
|
||||
|
||||
- (void)model:(id<TTModel>)model didDeleteObject:(id)object atIndexPath:(NSIndexPath*)indexPath;
|
||||
|
||||
/**
|
||||
* Informs the delegate that the model is about to begin a multi-stage update.
|
||||
*
|
||||
* Models should use this method to condense multiple updates into a single visible update.
|
||||
* This avoids having the view update multiple times for each change. Instead, the user will
|
||||
* only see the end result of all of your changes when you call modelDidEndUpdates.
|
||||
*/
|
||||
- (void)modelDidBeginUpdates:(id<TTModel>)model;
|
||||
|
||||
/**
|
||||
* Informs the delegate that the model has completed a multi-stage update.
|
||||
*
|
||||
* The exact nature of the change is not specified, so the receiver should investigate the
|
||||
* new state of the model by examining its properties.
|
||||
*/
|
||||
- (void)modelDidEndUpdates:(id<TTModel>)model;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,239 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class TTURLRequest;
|
||||
|
||||
/**
|
||||
* A general purpose URL cache for caching data in memory and on disk.
|
||||
*
|
||||
* Etags are supported.
|
||||
*/
|
||||
@interface TTURLCache : NSObject {
|
||||
NSString* _name;
|
||||
NSString* _cachePath;
|
||||
NSMutableDictionary* _imageCache;
|
||||
NSMutableArray* _imageSortedList;
|
||||
NSUInteger _totalPixelCount;
|
||||
NSUInteger _maxPixelCount;
|
||||
NSInteger _totalLoading;
|
||||
NSTimeInterval _invalidationAge;
|
||||
BOOL _disableDiskCache;
|
||||
BOOL _disableImageCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the disk cache. Disables etag support as well.
|
||||
*/
|
||||
@property (nonatomic) BOOL disableDiskCache;
|
||||
|
||||
/**
|
||||
* Disables the in-memory cache for images.
|
||||
*/
|
||||
@property (nonatomic) BOOL disableImageCache;
|
||||
|
||||
/**
|
||||
* Gets the path to the directory of the disk cache.
|
||||
*/
|
||||
@property (nonatomic, copy) NSString* cachePath;
|
||||
|
||||
/**
|
||||
* Gets the path to the directory of the disk cache for etags.
|
||||
*/
|
||||
@property (nonatomic, readonly) NSString* etagCachePath;
|
||||
|
||||
/**
|
||||
* The maximum number of pixels to keep in memory for cached images.
|
||||
*
|
||||
* Setting this to zero will allow an unlimited number of images to be cached. The default
|
||||
* is zero.
|
||||
*/
|
||||
@property (nonatomic) NSUInteger maxPixelCount;
|
||||
|
||||
/**
|
||||
* The amount of time to set back the modification timestamp on files when invalidating them.
|
||||
*/
|
||||
@property (nonatomic) NSTimeInterval invalidationAge;
|
||||
|
||||
|
||||
/**
|
||||
* Gets a shared cache identified with a unique name.
|
||||
*/
|
||||
+ (TTURLCache*)cacheWithName:(NSString*)name;
|
||||
|
||||
/**
|
||||
* Gets the shared cache singleton used across the application.
|
||||
*/
|
||||
+ (TTURLCache*)sharedCache;
|
||||
|
||||
/**
|
||||
* Sets the shared cache singleton used across the application.
|
||||
*/
|
||||
+ (void)setSharedCache:(TTURLCache*)cache;
|
||||
|
||||
- (id)initWithName:(NSString*)name;
|
||||
|
||||
/**
|
||||
* Gets the key that would be used to cache a URL response.
|
||||
*/
|
||||
- (NSString *)keyForURL:(NSString*)URL;
|
||||
|
||||
/**
|
||||
* Gets the path in the cache where a URL may be stored.
|
||||
*/
|
||||
- (NSString*)cachePathForURL:(NSString*)URL;
|
||||
|
||||
/**
|
||||
* Gets the path in the cache where a key may be stored.
|
||||
*/
|
||||
- (NSString*)cachePathForKey:(NSString*)key;
|
||||
|
||||
/**
|
||||
* Etag cache files are stored in the following way:
|
||||
* File name: <key>
|
||||
* File data: <etag value>
|
||||
*
|
||||
* @return The etag cache path for the given key.
|
||||
*/
|
||||
- (NSString*)etagCachePathForKey:(NSString*)key;
|
||||
|
||||
/**
|
||||
* Determines if there is a cache entry for a URL.
|
||||
*/
|
||||
- (BOOL)hasDataForURL:(NSString*)URL;
|
||||
|
||||
/**
|
||||
* Determines if there is a cache entry for a key.
|
||||
*/
|
||||
- (BOOL)hasDataForKey:(NSString*)key expires:(NSTimeInterval)expirationAge;
|
||||
|
||||
/**
|
||||
* Determines if there is an image cache entry for a URL.
|
||||
*/
|
||||
- (BOOL)hasImageForURL:(NSString*)URL fromDisk:(BOOL)fromDisk;
|
||||
|
||||
/**
|
||||
* Gets the data for a URL from the cache if it exists.
|
||||
*
|
||||
* @return nil if the URL is not cached.
|
||||
*/
|
||||
- (NSData*)dataForURL:(NSString*)URL;
|
||||
|
||||
/**
|
||||
* Gets the data for a URL from the cache if it exists and is newer than a minimum timestamp.
|
||||
*
|
||||
* @return nil if hthe URL is not cached or if the cache entry is older than the minimum.
|
||||
*/
|
||||
- (NSData*)dataForURL:(NSString*)URL expires:(NSTimeInterval)expirationAge
|
||||
timestamp:(NSDate**)timestamp;
|
||||
- (NSData*)dataForKey:(NSString*)key expires:(NSTimeInterval)expirationAge
|
||||
timestamp:(NSDate**)timestamp;
|
||||
|
||||
/**
|
||||
* Gets an image from the in-memory image cache.
|
||||
*
|
||||
* @return nil if the URL is not cached.
|
||||
*/
|
||||
- (id)imageForURL:(NSString*)URL;
|
||||
- (id)imageForURL:(NSString*)URL fromDisk:(BOOL)fromDisk;
|
||||
|
||||
/**
|
||||
* Get an etag value for a given cache key.
|
||||
*/
|
||||
- (NSString*)etagForKey:(NSString*)key;
|
||||
|
||||
/**
|
||||
* Stores a data on disk.
|
||||
*/
|
||||
- (void)storeData:(NSData*)data forURL:(NSString*)URL;
|
||||
- (void)storeData:(NSData*)data forKey:(NSString*)key;
|
||||
|
||||
/**
|
||||
* Stores an image in the memory cache.
|
||||
*/
|
||||
- (void)storeImage:(UIImage*)image forURL:(NSString*)URL;
|
||||
|
||||
/**
|
||||
* Stores an etag value in the etag cache.
|
||||
*/
|
||||
- (void)storeEtag:(NSString*)etag forKey:(NSString*)key;
|
||||
|
||||
/**
|
||||
* Convenient way to create a temporary URL for some data and cache it in memory.
|
||||
*
|
||||
* @return The temporary URL
|
||||
*/
|
||||
- (NSString*)storeTemporaryImage:(UIImage*)image toDisk:(BOOL)toDisk;
|
||||
|
||||
/**
|
||||
* Convenient way to create a temporary URL for some data and cache in on disk.
|
||||
*
|
||||
* @return The temporary URL
|
||||
*/
|
||||
- (NSString*)storeTemporaryData:(NSData*)data;
|
||||
|
||||
/**
|
||||
* Convenient way to create a temporary URL for a file and move it to the disk cache.
|
||||
*
|
||||
* @return The temporary URL
|
||||
*/
|
||||
- (NSString*)storeTemporaryFile:(NSURL*)fileURL;
|
||||
|
||||
/**
|
||||
* Moves the data currently stored under one URL to another URL.
|
||||
*
|
||||
* This is handy when you are caching data at a temporary URL while the permanent URL is being
|
||||
* retrieved from a server. Once you know the permanent URL you can use this to move the data.
|
||||
*/
|
||||
- (void)moveDataForURL:(NSString*)oldURL toURL:(NSString*)newURL;
|
||||
|
||||
- (void)moveDataFromPath:(NSString*)path toURL:(NSString*)newURL;
|
||||
|
||||
- (NSString*)moveDataFromPathToTemporaryURL:(NSString*)path;
|
||||
|
||||
/**
|
||||
* Removes the data for a URL from the memory cache and optionally from the disk cache.
|
||||
*/
|
||||
- (void)removeURL:(NSString*)URL fromDisk:(BOOL)fromDisk;
|
||||
|
||||
- (void)removeKey:(NSString*)key;
|
||||
|
||||
/**
|
||||
* Erases the memory cache and optionally the disk cache.
|
||||
*/
|
||||
- (void)removeAll:(BOOL)fromDisk;
|
||||
|
||||
/**
|
||||
* Invalidates the file in the disk cache so that its modified timestamp is the current
|
||||
* time minus the default cache expiration age.
|
||||
*
|
||||
* This ensures that the next time the URL is requested from the cache it will be loaded
|
||||
* from the network if the default cache expiration age is used.
|
||||
*/
|
||||
- (void)invalidateURL:(NSString*)URL;
|
||||
|
||||
- (void)invalidateKey:(NSString*)key;
|
||||
|
||||
/**
|
||||
* Invalidates all files in the disk cache according to rules explained in `invalidateURL`.
|
||||
*/
|
||||
- (void)invalidateAll;
|
||||
|
||||
- (void)logMemoryUsage;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Network
|
||||
#import "Three20Network/TTURLResponse.h"
|
||||
|
||||
/**
|
||||
* An implementation of the TTURLResponse protocal for generic NSData objects.
|
||||
*/
|
||||
@interface TTURLDataResponse : NSObject <TTURLResponse> {
|
||||
NSData* _data;
|
||||
}
|
||||
|
||||
@property (nonatomic, readonly) NSData* data;
|
||||
|
||||
@end
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Network
|
||||
#import "Three20Network/TTURLResponse.h"
|
||||
|
||||
/**
|
||||
* An implementation of the TTURLResponse protocal for UIImage objects.
|
||||
*
|
||||
* This response expects either a UIImage or an NSData object.
|
||||
* If it receives an NSData object, it updates the image cache.
|
||||
* If the image wasn't in the cache, it stores the downloaded image in the cache.
|
||||
*/
|
||||
@interface TTURLImageResponse : NSObject <TTURLResponse> {
|
||||
UIImage* _image;
|
||||
}
|
||||
|
||||
@property (nonatomic, readonly) UIImage* image;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,251 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
// Network
|
||||
#import "Three20Network/TTURLRequestCachePolicy.h"
|
||||
|
||||
// Core
|
||||
#import "Three20Core/TTCorePreprocessorMacros.h" // For __TTDEPRECATED_METHOD
|
||||
|
||||
@protocol TTURLRequestDelegate;
|
||||
@protocol TTURLResponse;
|
||||
|
||||
/**
|
||||
* The Three20 network request object, built to work with the Three20 cache and co.
|
||||
*
|
||||
* Allows customization of the http method, body, and parameters, as well as natural response
|
||||
* processing using TTURLResponse objects.
|
||||
*/
|
||||
@interface TTURLRequest : NSObject {
|
||||
NSString* _urlPath;
|
||||
|
||||
NSString* _httpMethod;
|
||||
NSData* _httpBody;
|
||||
NSMutableDictionary* _parameters;
|
||||
NSMutableDictionary* _headers;
|
||||
|
||||
NSString* _contentType;
|
||||
NSStringEncoding _charsetForMultipart;
|
||||
|
||||
NSMutableArray* _files;
|
||||
|
||||
id<TTURLResponse> _response;
|
||||
|
||||
TTURLRequestCachePolicy _cachePolicy;
|
||||
NSTimeInterval _cacheExpirationAge;
|
||||
NSString* _cacheKey;
|
||||
|
||||
NSDate* _timestamp;
|
||||
|
||||
NSInteger _totalBytesLoaded;
|
||||
NSInteger _totalBytesExpected;
|
||||
|
||||
id _userInfo;
|
||||
|
||||
BOOL _isLoading;
|
||||
BOOL _shouldHandleCookies;
|
||||
BOOL _respondedFromCache;
|
||||
BOOL _filterPasswordLogging;
|
||||
|
||||
NSMutableArray* _delegates;
|
||||
}
|
||||
|
||||
/**
|
||||
* The URL path to be loaded by the request.
|
||||
*/
|
||||
@property (nonatomic, copy) NSString* urlPath;
|
||||
|
||||
/**
|
||||
* The URL path to be loaded by the request.
|
||||
*
|
||||
* Deprecated due to name ambiguity. Use urlPath instead.
|
||||
* Remove after May 6, 2010.
|
||||
*/
|
||||
@property (nonatomic, copy) NSString* URL __TTDEPRECATED_METHOD;
|
||||
|
||||
/**
|
||||
* The HTTP method to send with the request.
|
||||
*
|
||||
* @example @"POST"
|
||||
* @example @"GET"
|
||||
* @example @"PUT"
|
||||
* @default nil (equivalent to @"GET")
|
||||
*/
|
||||
@property (nonatomic, copy) NSString* httpMethod;
|
||||
|
||||
/**
|
||||
* An object that handles the response data and may parse and validate it.
|
||||
*
|
||||
* @see TTURLDataResponse
|
||||
* @see TTURLImageResponse
|
||||
* @see TTURLXMLResponse
|
||||
*/
|
||||
@property (nonatomic, retain) id<TTURLResponse> response;
|
||||
|
||||
/**
|
||||
* The HTTP body to send with the request.
|
||||
*
|
||||
* If provided, will always be used. Please consider this when using POST/PUT methods: if
|
||||
* httpBody is provided, then the POST/PUT data generated from the parameters property will not
|
||||
* be used.
|
||||
*/
|
||||
@property (nonatomic, retain) NSData* httpBody;
|
||||
|
||||
/**
|
||||
* The content type of the data in the request.
|
||||
*
|
||||
* If not provided and httpMethod is POST/PUT, then contentType is @"multipart/form-data".
|
||||
*/
|
||||
@property (nonatomic, copy) NSString* contentType;
|
||||
|
||||
/**
|
||||
* Parameters to use for an HTTP POST/PUT.
|
||||
*/
|
||||
@property (nonatomic, readonly) NSMutableDictionary* parameters;
|
||||
|
||||
/**
|
||||
* Custom HTTP headers.
|
||||
*/
|
||||
@property (nonatomic, readonly) NSMutableDictionary* headers;
|
||||
|
||||
/**
|
||||
* @default TTURLRequestCachePolicyDefault
|
||||
*/
|
||||
@property (nonatomic) TTURLRequestCachePolicy cachePolicy;
|
||||
|
||||
/**
|
||||
* The maximum age of cached data that can be used as a response.
|
||||
*
|
||||
* @default TT_DEFAULT_CACHE_EXPIRATION_AGE (1 week)
|
||||
*/
|
||||
@property (nonatomic) NSTimeInterval cacheExpirationAge;
|
||||
|
||||
/**
|
||||
* If no cache key is provided, a unique key is generated from the request data. If the request
|
||||
* is a POST/PUT request, then the POST/PUT parameters are also used to generate the cache key.
|
||||
*
|
||||
* By setting the cacheKey, you may override the default cache key generator with your own.
|
||||
*/
|
||||
@property (nonatomic, retain) NSString* cacheKey;
|
||||
|
||||
/**
|
||||
* A dummy object used to uniquely identify this request object once it's been sent into the fray.
|
||||
* Generally TTUserInfo objects are used here.
|
||||
*
|
||||
* @see TTUserInfo
|
||||
*/
|
||||
@property (nonatomic, retain) id userInfo;
|
||||
|
||||
@property (nonatomic, retain) NSDate* timestamp;
|
||||
|
||||
/**
|
||||
* Whether or not the request is currently active.
|
||||
*/
|
||||
@property (nonatomic) BOOL isLoading;
|
||||
|
||||
/**
|
||||
* Decide whether default cookie handling will happen for this request.
|
||||
*
|
||||
* @param YES if cookies should be sent with and set for this request;
|
||||
* otherwise NO.
|
||||
* @discussion The default is YES - in other words, cookies are sent from and
|
||||
* stored to the cookie manager by default.
|
||||
*
|
||||
* @default YES
|
||||
*/
|
||||
@property (nonatomic) BOOL shouldHandleCookies;
|
||||
|
||||
/**
|
||||
* The number of bytes loaded by this request.
|
||||
*/
|
||||
@property (nonatomic) NSInteger totalBytesLoaded;
|
||||
|
||||
/**
|
||||
* The number of expected bytes from this request.
|
||||
*/
|
||||
@property (nonatomic) NSInteger totalBytesExpected;
|
||||
|
||||
/**
|
||||
* Whether or not the request was loaded from the cache.
|
||||
*
|
||||
* This is only valid after the request has completed.
|
||||
*/
|
||||
@property (nonatomic) BOOL respondedFromCache;
|
||||
|
||||
/**
|
||||
* Whether parameters named "password" should be suppressed in log messages.
|
||||
*/
|
||||
@property (nonatomic, assign) BOOL filterPasswordLogging;
|
||||
|
||||
/**
|
||||
* Charset to use when creating multipart/form-data data.
|
||||
*
|
||||
* @default NSUTF8StringEncoding to remain backwards compatible.
|
||||
*/
|
||||
@property (nonatomic) NSStringEncoding charsetForMultipart;
|
||||
|
||||
/**
|
||||
* An array of non-retained objects that receive messages about the progress of the request.
|
||||
*/
|
||||
@property (nonatomic, readonly) NSMutableArray* delegates;
|
||||
|
||||
|
||||
+ (TTURLRequest*)request;
|
||||
|
||||
+ (TTURLRequest*)requestWithURL:(NSString*)URL delegate:(id /*<TTURLRequestDelegate>*/)delegate;
|
||||
|
||||
- (id)initWithURL:(NSString*)URL delegate:(id /*<TTURLRequestDelegate>*/)delegate;
|
||||
|
||||
- (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field;
|
||||
|
||||
/**
|
||||
* Add a file whose data will be posted.
|
||||
*/
|
||||
- (void)addFile:(NSData*)data mimeType:(NSString*)mimeType fileName:(NSString*)fileName;
|
||||
|
||||
/**
|
||||
* Attempt to send a request.
|
||||
*
|
||||
* If the request can be resolved by the cache, it will happen synchronously. Otherwise,
|
||||
* the request will respond to its delegate asynchronously.
|
||||
*
|
||||
* @return YES if the request was loaded synchronously from the cache.
|
||||
*/
|
||||
- (BOOL)send;
|
||||
|
||||
/**
|
||||
* Attempt to send a synchronous request.
|
||||
*
|
||||
* The request will happen synchronously, regardless of whether the data is being grabbed from
|
||||
* the network or from the cache.
|
||||
*
|
||||
* @return YES if the request was loaded from the cache.
|
||||
*/
|
||||
- (BOOL)sendSynchronously;
|
||||
|
||||
/**
|
||||
* Cancel the request.
|
||||
*
|
||||
* If there are multiple requests going to the same URL as this request, the others will
|
||||
* not be cancelled.
|
||||
*/
|
||||
- (void)cancel;
|
||||
|
||||
- (NSURLRequest*)createNSURLRequest;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
/**
|
||||
* Facts concerning cache policies:
|
||||
*
|
||||
* - Using NoCache will also disable Etag support.
|
||||
*/
|
||||
typedef enum {
|
||||
TTURLRequestCachePolicyNone = 0,
|
||||
TTURLRequestCachePolicyMemory = 1,
|
||||
TTURLRequestCachePolicyDisk = 2,
|
||||
TTURLRequestCachePolicyNetwork = 4,
|
||||
TTURLRequestCachePolicyNoCache = 8,
|
||||
TTURLRequestCachePolicyEtag = 16 | TTURLRequestCachePolicyDisk,
|
||||
TTURLRequestCachePolicyLocal
|
||||
= (TTURLRequestCachePolicyMemory | TTURLRequestCachePolicyDisk),
|
||||
TTURLRequestCachePolicyDefault
|
||||
= (TTURLRequestCachePolicyMemory | TTURLRequestCachePolicyDisk
|
||||
| TTURLRequestCachePolicyNetwork),
|
||||
} TTURLRequestCachePolicy;
|
||||
@@ -0,0 +1,62 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class TTURLRequest;
|
||||
|
||||
@protocol TTURLRequestDelegate <NSObject>
|
||||
@optional
|
||||
|
||||
/**
|
||||
* The request has begun loading.
|
||||
*
|
||||
* This method will not be called if the data is loaded immediately from the cache.
|
||||
* @see requestDidFinishLoad:
|
||||
*/
|
||||
- (void)requestDidStartLoad:(TTURLRequest*)request;
|
||||
|
||||
/**
|
||||
* The request has loaded some more data.
|
||||
*
|
||||
* Check the totalBytesLoaded and totalBytesExpected properties for details.
|
||||
*/
|
||||
- (void)requestDidUploadData:(TTURLRequest*)request;
|
||||
|
||||
/**
|
||||
* The request has loaded data and been processed into a response.
|
||||
*
|
||||
* If the request is served from the cache, this is the only delegate method that will be called.
|
||||
*/
|
||||
- (void)requestDidFinishLoad:(TTURLRequest*)request;
|
||||
|
||||
/**
|
||||
* Allows delegate to handle any authentication challenges.
|
||||
*/
|
||||
- (void)request:(TTURLRequest*)request
|
||||
didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge*)challenge;
|
||||
|
||||
/**
|
||||
* The request failed to load.
|
||||
*/
|
||||
- (void)request:(TTURLRequest*)request didFailLoadWithError:(NSError*)error;
|
||||
|
||||
/**
|
||||
* The request was canceled.
|
||||
*/
|
||||
- (void)requestDidCancelLoad:(TTURLRequest*)request;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Network
|
||||
#import "Three20Network/TTModel.h"
|
||||
#import "Three20Network/TTURLRequestDelegate.h"
|
||||
|
||||
/**
|
||||
* An implementation of TTModel which is built to work with TTURLRequests.
|
||||
*
|
||||
* If you use a TTURLRequestModel as the delegate of your TTURLRequests, it will automatically
|
||||
* manage many of the TTModel properties based on the state of your requests.
|
||||
*/
|
||||
@interface TTURLRequestModel : TTModel <TTURLRequestDelegate> {
|
||||
TTURLRequest* _loadingRequest;
|
||||
|
||||
NSDate* _loadedTime;
|
||||
NSString* _cacheKey;
|
||||
|
||||
BOOL _isLoadingMore;
|
||||
BOOL _hasNoMore;
|
||||
}
|
||||
|
||||
/**
|
||||
* Valid upon completion of the URL request. Represents the timestamp of the completed request.
|
||||
*/
|
||||
@property (nonatomic, retain) NSDate* loadedTime;
|
||||
|
||||
/**
|
||||
* Valid upon completion of the URL request. Represents the request's cache key.
|
||||
*/
|
||||
@property (nonatomic, copy) NSString* cacheKey;
|
||||
|
||||
/**
|
||||
* Not used internally, but intended for book-keeping purposes when making requests.
|
||||
*/
|
||||
@property (nonatomic) BOOL hasNoMore;
|
||||
|
||||
/**
|
||||
* Resets the model to its original state before any data was loaded.
|
||||
*/
|
||||
- (void)reset;
|
||||
|
||||
@end
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class TTURLRequest;
|
||||
|
||||
@interface TTURLRequestQueue : NSObject {
|
||||
@private
|
||||
NSMutableDictionary* _loaders;
|
||||
|
||||
NSMutableArray* _loaderQueue;
|
||||
NSTimer* _loaderQueueTimer;
|
||||
|
||||
NSInteger _totalLoading;
|
||||
|
||||
NSUInteger _maxContentLength;
|
||||
NSString* _userAgent;
|
||||
|
||||
CGFloat _imageCompressionQuality;
|
||||
|
||||
BOOL _suspended;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the flag that determines if new load requests are allowed to reach the network.
|
||||
*
|
||||
* Because network requests tend to slow down performance, this property can be used to
|
||||
* temporarily delay them. All requests made while suspended are queued, and when
|
||||
* suspended becomes false again they are executed.
|
||||
*/
|
||||
@property (nonatomic) BOOL suspended;
|
||||
|
||||
/**
|
||||
* The maximum size of a download that is allowed.
|
||||
*
|
||||
* If a response reports a content length greater than the max, the download will be
|
||||
* cancelled. This is helpful for preventing excessive memory usage. Setting this to
|
||||
* zero will allow all downloads regardless of size.
|
||||
*
|
||||
* @default 150000 bytes
|
||||
*/
|
||||
@property (nonatomic) NSUInteger maxContentLength;
|
||||
|
||||
/**
|
||||
* The user-agent string that is sent with all HTTP requests.
|
||||
* If set to 'nil', User-Agent set by NSURLRequest will be used,
|
||||
* which looks like: 'APP_NAME/N.N CFNetwork/NNN Darwin/NN.N.NNN'.
|
||||
*
|
||||
* @default nil
|
||||
*/
|
||||
@property (nonatomic, copy) NSString* userAgent;
|
||||
|
||||
/**
|
||||
* The compression quality used for encoding images sent with HTTP posts.
|
||||
*
|
||||
* @default 0.75
|
||||
*/
|
||||
@property (nonatomic) CGFloat imageCompressionQuality;
|
||||
|
||||
/**
|
||||
* Get the shared cache singleton used across the application.
|
||||
*/
|
||||
+ (TTURLRequestQueue*)mainQueue;
|
||||
|
||||
/**
|
||||
* Set the shared cache singleton used across the application.
|
||||
*/
|
||||
+ (void)setMainQueue:(TTURLRequestQueue*)queue;
|
||||
|
||||
/**
|
||||
* Load a request from the cache or the network if it is not in the cache.
|
||||
*
|
||||
* @return YES if the request was loaded synchronously from the cache.
|
||||
*/
|
||||
- (BOOL)sendRequest:(TTURLRequest*)request;
|
||||
|
||||
/**
|
||||
* Synchronously load a request from the cache or the network if it is not in the cache.
|
||||
*
|
||||
* @return YES if the request was loaded from the cache.
|
||||
*/
|
||||
- (BOOL)sendSynchronousRequest:(TTURLRequest*)request;
|
||||
|
||||
/**
|
||||
* Cancel a request that is in progress.
|
||||
*/
|
||||
- (void)cancelRequest:(TTURLRequest*)request;
|
||||
|
||||
/**
|
||||
* Cancel all active or pending requests whose delegate or response is an object.
|
||||
*
|
||||
* This is useful for when an object is about to be destroyed and you want to remove pointers
|
||||
* to it from active requests to prevent crashes when those pointers are later referenced.
|
||||
*/
|
||||
- (void)cancelRequestsWithDelegate:(id)delegate;
|
||||
|
||||
/**
|
||||
* Cancel all active or pending requests.
|
||||
*/
|
||||
- (void)cancelAllRequests;
|
||||
|
||||
/**
|
||||
* Create a Cocoa URL request from a Three20 URL request.
|
||||
*/
|
||||
- (NSURLRequest*)createNSURLRequest:(TTURLRequest*)request URL:(NSURL*)URL;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,48 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class TTURLRequest;
|
||||
|
||||
/**
|
||||
* A response protocol for TTURLRequest. This protocol is used upon the successful retrieval of
|
||||
* data from a TTURLRequest. The processResponse method is used to process the data, whether it
|
||||
* be an image or an XML string.
|
||||
*
|
||||
* @see TTURLDataResponse
|
||||
* @see TTURLImageResponse
|
||||
*/
|
||||
@protocol TTURLResponse <NSObject>
|
||||
@required
|
||||
|
||||
/**
|
||||
* Processes the data from a successful request and determines if it is valid.
|
||||
*
|
||||
* If the data is not valid, return an error. The data will not be cached if there is an error.
|
||||
*
|
||||
* @param request The request this response is bound to.
|
||||
* @param response The response object, useful for getting the status code.
|
||||
* @param data The data received from the TTURLRequest.
|
||||
* @return NSError if there was an error parsing the data. nil otherwise.
|
||||
*
|
||||
* @required
|
||||
*/
|
||||
- (NSError*)request:(TTURLRequest*)request processResponse:(NSHTTPURLResponse*)response
|
||||
data:(id)data;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
/**
|
||||
* A helper class for storing user info to help identify a request.
|
||||
*
|
||||
* This class lets you store both a strong reference and a weak reference for the duration of
|
||||
* the request. The weak reference is special because TTURLRequestQueue will examine it when
|
||||
* you call cancelRequestsWithDelegate to see if the weak object is the delegate in question.
|
||||
* For this reason, this object is a safe way to store an object that may be destroyed before
|
||||
* the request completes if you call cancelRequestsWithDelegate in the object's destructor.
|
||||
*/
|
||||
@interface TTUserInfo : NSObject {
|
||||
NSString* _topic;
|
||||
id _strongRef;
|
||||
id _weakRef;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) NSString* topic;
|
||||
@property (nonatomic, retain) id strongRef;
|
||||
@property (nonatomic, assign) id weakRef;
|
||||
|
||||
+ (id)topic:(NSString*)topic strongRef:(id)strongRef weakRef:(id)weakRef;
|
||||
+ (id)topic:(NSString*)topic;
|
||||
+ (id)weakRef:(id)weakRef;
|
||||
|
||||
- (id)initWithTopic:(NSString*)topic strongRef:(id)strongRef weakRef:(id)weakRef;
|
||||
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import "Three20Core/Three20Core.h"
|
||||
|
||||
// Network
|
||||
|
||||
// - Global
|
||||
#import "Three20Network/TTGlobalNetwork.h"
|
||||
#import "Three20Network/TTURLRequestCachePolicy.h"
|
||||
#import "Three20Network/TTErrorCodes.h"
|
||||
|
||||
// - Models
|
||||
#import "Three20Network/TTModel.h"
|
||||
#import "Three20Network/TTModelDelegate.h"
|
||||
#import "Three20Network/TTURLRequestModel.h"
|
||||
|
||||
// - Requests
|
||||
#import "Three20Network/TTURLRequest.h"
|
||||
#import "Three20Network/TTURLRequestDelegate.h"
|
||||
|
||||
// - Responses
|
||||
#import "Three20Network/TTURLResponse.h"
|
||||
#import "Three20Network/TTURLDataResponse.h"
|
||||
#import "Three20Network/TTURLImageResponse.h"
|
||||
// TODO (jverkoey April 27, 2010: Add back support for XML.
|
||||
//#import "Three20Network/TTURLXMLResponse.h"
|
||||
|
||||
// - Classes
|
||||
#import "Three20Network/TTUserInfo.h"
|
||||
#import "Three20Network/TTURLRequestQueue.h"
|
||||
#import "Three20Network/TTURLCache.h"
|
||||
@@ -0,0 +1,133 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
// Network
|
||||
#import "Three20Network/TTURLRequestCachePolicy.h"
|
||||
|
||||
// Core
|
||||
#import "Three20Core/TTCorePreprocessorMacros.h" // For __TTDEPRECATED_METHOD
|
||||
|
||||
@class TTURLRequestQueue;
|
||||
@class TTURLRequest;
|
||||
|
||||
/**
|
||||
* The loader manages a set of TTURLRequests and makes the necessary callbacks for each.
|
||||
* It implements the NSURLConnectionDelegate protocol and calls the required operations on the
|
||||
* queue as the protocol methods are invoked.
|
||||
*
|
||||
* NSURLErrorCannotFindHost errors are retried at least twice before completely giving up.
|
||||
*
|
||||
* The loader collects identical GET TTURLRequests into a single object. This logic is handled in
|
||||
* TTURLRequestQueue's sendRequest.
|
||||
* For all other TTURLRequest types, they will each have their own loader.
|
||||
*/
|
||||
@interface TTRequestLoader : NSObject {
|
||||
NSString* _urlPath;
|
||||
|
||||
TTURLRequestQueue* _queue;
|
||||
|
||||
NSString* _cacheKey;
|
||||
TTURLRequestCachePolicy _cachePolicy;
|
||||
NSTimeInterval _cacheExpirationAge;
|
||||
|
||||
NSMutableArray* _requests;
|
||||
NSURLConnection* _connection;
|
||||
|
||||
NSHTTPURLResponse* _response;
|
||||
NSMutableData* _responseData;
|
||||
|
||||
/**
|
||||
* When load requests fail we'll attempt the request again, as many as 2 times by default.
|
||||
*/
|
||||
int _retriesLeft;
|
||||
}
|
||||
|
||||
/**
|
||||
* The list of TTURLRequests currently attached to this loader.
|
||||
*/
|
||||
@property (nonatomic, readonly) NSArray* requests;
|
||||
|
||||
/**
|
||||
* The common urlPath shared by every request.
|
||||
*/
|
||||
@property (nonatomic, readonly) NSString* urlPath;
|
||||
|
||||
/**
|
||||
* The common cacheKey shared by every request.
|
||||
*/
|
||||
@property (nonatomic, readonly) NSString* cacheKey;
|
||||
|
||||
/**
|
||||
* The common cache policy shared by every request.
|
||||
*/
|
||||
@property (nonatomic, readonly) TTURLRequestCachePolicy cachePolicy;
|
||||
|
||||
/**
|
||||
* The common cache expiration age shared by ever request.
|
||||
*/
|
||||
@property (nonatomic, readonly) NSTimeInterval cacheExpirationAge;
|
||||
|
||||
/**
|
||||
* Whether or not any of the requests in this loader are loading.
|
||||
*/
|
||||
@property (nonatomic, readonly) BOOL isLoading;
|
||||
|
||||
/**
|
||||
* Deprecated due to name ambiguity. Use urlPath instead.
|
||||
* Remove after May 6, 2010.
|
||||
*/
|
||||
@property (nonatomic, readonly) NSString* URL __TTDEPRECATED_METHOD;
|
||||
|
||||
|
||||
- (id)initForRequest:(TTURLRequest*)request queue:(TTURLRequestQueue*)queue;
|
||||
|
||||
/**
|
||||
* Duplication is possible due to the use of an NSArray for the request list.
|
||||
*/
|
||||
- (void)addRequest:(TTURLRequest*)request;
|
||||
- (void)removeRequest:(TTURLRequest*)request;
|
||||
|
||||
/**
|
||||
* If the loader isn't already active, create the NSURLRequest from the first TTURLRequest added
|
||||
* to this loader and fire it off.
|
||||
*/
|
||||
- (void)load:(NSURL*)URL;
|
||||
|
||||
/**
|
||||
* As with load:, will create the NSURLRequest from the first TTURLRequest added to the loader.
|
||||
* Unlike load:, this method will not return until the request has been fully completed.
|
||||
*
|
||||
* This is useful for threads that need to block while waiting for resources from the net.
|
||||
*/
|
||||
- (void)loadSynchronously:(NSURL*)URL;
|
||||
|
||||
/**
|
||||
* Cancel only the given request.
|
||||
*
|
||||
* @return NO If there are no requests left.
|
||||
* YES If there are any requests left.
|
||||
*/
|
||||
- (BOOL)cancel:(TTURLRequest*)request;
|
||||
|
||||
- (NSError*)processResponse:(NSHTTPURLResponse*)response data:(id)data;
|
||||
- (void)dispatchError:(NSError*)error;
|
||||
- (void)dispatchLoaded:(NSDate*)timestamp;
|
||||
- (void)dispatchAuthenticationChallenge:(NSURLAuthenticationChallenge*)challenge;
|
||||
- (void)cancel;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import "Three20Network/TTURLRequestQueue.h"
|
||||
|
||||
@class TTRequestLoader;
|
||||
|
||||
/**
|
||||
* The internal interface for the TTRequestLoaders to interact with the TTURLRequestQueue.
|
||||
*/
|
||||
@interface TTURLRequestQueue (TTRequestLoader)
|
||||
|
||||
- (void) loader: (TTRequestLoader*)loader
|
||||
didReceiveAuthenticationChallenge: (NSURLAuthenticationChallenge*)challenge;
|
||||
|
||||
- (void) loader: (TTRequestLoader*)loader
|
||||
didLoadResponse: (NSHTTPURLResponse*)response
|
||||
data: (id)data;
|
||||
|
||||
- (void) loader:(TTRequestLoader*)loader
|
||||
didLoadUnmodifiedResponse:(NSHTTPURLResponse*)response;
|
||||
|
||||
- (void)loader:(TTRequestLoader*)loader didFailLoadWithError:(NSError*)error;
|
||||
- (void)loaderDidCancel:(TTRequestLoader*)loader wasLoading:(BOOL)wasLoading;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyle.h"
|
||||
|
||||
@interface TTBevelBorderStyle : TTStyle {
|
||||
UIColor* _highlight;
|
||||
UIColor* _shadow;
|
||||
CGFloat _width;
|
||||
NSInteger _lightSource;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) UIColor* highlight;
|
||||
@property (nonatomic, retain) UIColor* shadow;
|
||||
@property (nonatomic) CGFloat width;
|
||||
@property (nonatomic) NSInteger lightSource;
|
||||
|
||||
+ (TTBevelBorderStyle*)styleWithColor:(UIColor*)color width:(CGFloat)width next:(TTStyle*)next;
|
||||
|
||||
+ (TTBevelBorderStyle*)styleWithHighlight:(UIColor*)highlight shadow:(UIColor*)shadow
|
||||
width:(CGFloat)width lightSource:(NSInteger)lightSource next:(TTStyle*)next;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyle.h"
|
||||
|
||||
@interface TTBlendStyle : TTStyle {
|
||||
CGBlendMode _blendMode;
|
||||
}
|
||||
|
||||
@property (nonatomic) CGBlendMode blendMode;
|
||||
|
||||
+ (TTBlendStyle*)styleWithBlend:(CGBlendMode)blendMode next:(TTStyle*)next;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyle.h"
|
||||
#import "Three20Style/TTPosition.h"
|
||||
|
||||
@interface TTBoxStyle : TTStyle {
|
||||
UIEdgeInsets _margin;
|
||||
UIEdgeInsets _padding;
|
||||
CGSize _minSize;
|
||||
TTPosition _position;
|
||||
}
|
||||
|
||||
@property (nonatomic) UIEdgeInsets margin;
|
||||
@property (nonatomic) UIEdgeInsets padding;
|
||||
@property (nonatomic) CGSize minSize;
|
||||
@property (nonatomic) TTPosition position;
|
||||
|
||||
+ (TTBoxStyle*)styleWithMargin:(UIEdgeInsets)margin next:(TTStyle*)next;
|
||||
+ (TTBoxStyle*)styleWithPadding:(UIEdgeInsets)padding next:(TTStyle*)next;
|
||||
+ (TTBoxStyle*)styleWithFloats:(TTPosition)position next:(TTStyle*)next;
|
||||
+ (TTBoxStyle*)styleWithMargin:(UIEdgeInsets)margin padding:(UIEdgeInsets)padding
|
||||
next:(TTStyle*)next;
|
||||
+ (TTBoxStyle*)styleWithMargin:(UIEdgeInsets)margin padding:(UIEdgeInsets)padding
|
||||
minSize:(CGSize)minSize position:(TTPosition)position next:(TTStyle*)next;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyle.h"
|
||||
|
||||
@interface TTContentStyle : TTStyle
|
||||
|
||||
+ (TTContentStyle*)styleWithNext:(TTStyle*)next;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import "Three20Style/TTDefaultStyleSheet.h"
|
||||
|
||||
@interface TTDefaultStyleSheet (TTDragRefreshHeader)
|
||||
|
||||
@property (nonatomic, readonly) UIFont* tableRefreshHeaderLastUpdatedFont;
|
||||
@property (nonatomic, readonly) UIFont* tableRefreshHeaderStatusFont;
|
||||
@property (nonatomic, readonly) UIColor* tableRefreshHeaderBackgroundColor;
|
||||
@property (nonatomic, readonly) UIColor* tableRefreshHeaderTextColor;
|
||||
@property (nonatomic, readonly) UIColor* tableRefreshHeaderTextShadowColor;
|
||||
@property (nonatomic, readonly) CGSize tableRefreshHeaderTextShadowOffset;
|
||||
@property (nonatomic, readonly) UIImage* tableRefreshHeaderArrowImage;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,97 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyleSheet.h"
|
||||
|
||||
@class TTShape;
|
||||
|
||||
@interface TTDefaultStyleSheet : TTStyleSheet
|
||||
|
||||
// Common styles
|
||||
@property (nonatomic, readonly) UIColor* textColor;
|
||||
@property (nonatomic, readonly) UIColor* highlightedTextColor;
|
||||
@property (nonatomic, readonly) UIFont* font;
|
||||
@property (nonatomic, readonly) UIColor* backgroundColor;
|
||||
@property (nonatomic, readonly) UIColor* navigationBarTintColor;
|
||||
@property (nonatomic, readonly) UIColor* toolbarTintColor;
|
||||
@property (nonatomic, readonly) UIColor* searchBarTintColor;
|
||||
|
||||
// Tables
|
||||
@property (nonatomic, readonly) UIColor* tablePlainBackgroundColor;
|
||||
@property (nonatomic, readonly) UIColor* tableGroupedBackgroundColor;
|
||||
@property (nonatomic, readonly) UIColor* searchTableBackgroundColor;
|
||||
@property (nonatomic, readonly) UIColor* searchTableSeparatorColor;
|
||||
|
||||
// Table Headers
|
||||
@property (nonatomic, readonly) UIColor* tableHeaderTextColor;
|
||||
@property (nonatomic, readonly) UIColor* tableHeaderShadowColor;
|
||||
@property (nonatomic, readonly) CGSize tableHeaderShadowOffset;
|
||||
@property (nonatomic, readonly) UIColor* tableHeaderTintColor;
|
||||
|
||||
// Photo Captions
|
||||
@property (nonatomic, readonly) UIColor* photoCaptionTextColor;
|
||||
@property (nonatomic, readonly) UIColor* photoCaptionTextShadowColor;
|
||||
@property (nonatomic, readonly) CGSize photoCaptionTextShadowOffset;
|
||||
|
||||
@property (nonatomic, readonly) UIColor* timestampTextColor;
|
||||
@property (nonatomic, readonly) UIColor* linkTextColor;
|
||||
@property (nonatomic, readonly) UIColor* moreLinkTextColor;
|
||||
|
||||
@property (nonatomic, readonly) UIColor* screenBackgroundColor;
|
||||
|
||||
@property (nonatomic, readonly) UIColor* tableActivityTextColor;
|
||||
@property (nonatomic, readonly) UIColor* tableErrorTextColor;
|
||||
@property (nonatomic, readonly) UIColor* tableSubTextColor;
|
||||
@property (nonatomic, readonly) UIColor* tableTitleTextColor;
|
||||
|
||||
@property (nonatomic, readonly) UIColor* tabTintColor;
|
||||
@property (nonatomic, readonly) UIColor* tabBarTintColor;
|
||||
|
||||
@property (nonatomic, readonly) UIColor* messageFieldTextColor;
|
||||
@property (nonatomic, readonly) UIColor* messageFieldSeparatorColor;
|
||||
|
||||
@property (nonatomic, readonly) UIColor* thumbnailBackgroundColor;
|
||||
|
||||
@property (nonatomic, readonly) UIColor* postButtonColor;
|
||||
|
||||
@property (nonatomic, readonly) UIFont* buttonFont;
|
||||
@property (nonatomic, readonly) UIFont* tableFont;
|
||||
@property (nonatomic, readonly) UIFont* tableSmallFont;
|
||||
@property (nonatomic, readonly) UIFont* tableTitleFont;
|
||||
@property (nonatomic, readonly) UIFont* tableTimestampFont;
|
||||
@property (nonatomic, readonly) UIFont* tableButtonFont;
|
||||
@property (nonatomic, readonly) UIFont* tableSummaryFont;
|
||||
@property (nonatomic, readonly) UIFont* tableHeaderPlainFont;
|
||||
@property (nonatomic, readonly) UIFont* tableHeaderGroupedFont;
|
||||
@property (nonatomic, readonly) CGFloat tableBannerViewHeight;
|
||||
@property (nonatomic, readonly) UIFont* photoCaptionFont;
|
||||
@property (nonatomic, readonly) UIFont* messageFont;
|
||||
@property (nonatomic, readonly) UIFont* errorTitleFont;
|
||||
@property (nonatomic, readonly) UIFont* errorSubtitleFont;
|
||||
@property (nonatomic, readonly) UIFont* activityLabelFont;
|
||||
@property (nonatomic, readonly) UIFont* activityBannerFont;
|
||||
|
||||
@property (nonatomic, readonly) UITableViewCellSelectionStyle tableSelectionStyle;
|
||||
|
||||
- (TTStyle*)selectionFillStyle:(TTStyle*)next;
|
||||
|
||||
- (TTStyle*)toolbarButtonForState:(UIControlState)state shape:(TTShape*)shape
|
||||
tintColor:(UIColor*)tintColor font:(UIFont*)font;
|
||||
|
||||
- (TTStyle*)pageDotWithColor:(UIColor*)color;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTLayout.h"
|
||||
|
||||
@interface TTFlowLayout : TTLayout {
|
||||
CGFloat _padding;
|
||||
CGFloat _spacing;
|
||||
}
|
||||
|
||||
@property (nonatomic) CGFloat padding;
|
||||
@property (nonatomic) CGFloat spacing;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyle.h"
|
||||
|
||||
@interface TTFourBorderStyle : TTStyle {
|
||||
UIColor* _top;
|
||||
UIColor* _right;
|
||||
UIColor* _bottom;
|
||||
UIColor* _left;
|
||||
CGFloat _width;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) UIColor* top;
|
||||
@property (nonatomic, retain) UIColor* right;
|
||||
@property (nonatomic, retain) UIColor* bottom;
|
||||
@property (nonatomic, retain) UIColor* left;
|
||||
@property (nonatomic) CGFloat width;
|
||||
|
||||
+ (TTFourBorderStyle*)styleWithTop:(UIColor*)top right:(UIColor*)right bottom:(UIColor*)bottom
|
||||
left:(UIColor*)left width:(CGFloat)width next:(TTStyle*)next;
|
||||
+ (TTFourBorderStyle*)styleWithTop:(UIColor*)top width:(CGFloat)width next:(TTStyle*)next;
|
||||
+ (TTFourBorderStyle*)styleWithRight:(UIColor*)right width:(CGFloat)width next:(TTStyle*)next;
|
||||
+ (TTFourBorderStyle*)styleWithBottom:(UIColor*)bottom width:(CGFloat)width next:(TTStyle*)next;
|
||||
+ (TTFourBorderStyle*)styleWithLeft:(UIColor*)left width:(CGFloat)width next:(TTStyle*)next;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,53 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
/**
|
||||
* A constant denoting that a corner should be rounded.
|
||||
* @const -1
|
||||
*/
|
||||
extern const CGFloat ttkRounded;
|
||||
|
||||
/**
|
||||
* Deprecated macros for common constants.
|
||||
*/
|
||||
#define TT_ROUNDED ttkRounded
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Color helpers
|
||||
|
||||
#define RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1]
|
||||
#define RGBACOLOR(r,g,b,a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 \
|
||||
alpha:(a)]
|
||||
|
||||
#define HSVCOLOR(h,s,v) [UIColor colorWithHue:(h) saturation:(s) value:(v) alpha:1]
|
||||
#define HSVACOLOR(h,s,v,a) [UIColor colorWithHue:(h) saturation:(s) value:(v) alpha:(a)]
|
||||
|
||||
#define RGBA(r,g,b,a) (r)/255.0, (g)/255.0, (b)/255.0, (a)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Style helpers
|
||||
|
||||
#define TTSTYLE(_SELECTOR) [[TTStyleSheet globalStyleSheet] styleWithSelector:@#_SELECTOR]
|
||||
|
||||
#define TTSTYLESTATE(_SELECTOR, _STATE) [[TTStyleSheet globalStyleSheet] \
|
||||
styleWithSelector:@#_SELECTOR forState:_STATE]
|
||||
|
||||
#define TTSTYLESHEET ((id)[TTStyleSheet globalStyleSheet])
|
||||
|
||||
#define TTSTYLEVAR(_VARNAME) [TTSTYLESHEET _VARNAME]
|
||||
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTLayout.h"
|
||||
|
||||
@interface TTGridLayout : TTLayout {
|
||||
NSInteger _columnCount;
|
||||
CGFloat _padding;
|
||||
CGFloat _spacing;
|
||||
}
|
||||
|
||||
@property (nonatomic) NSInteger columnCount;
|
||||
@property (nonatomic) CGFloat padding;
|
||||
@property (nonatomic) CGFloat spacing;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyle.h"
|
||||
|
||||
@interface TTHighlightBorderStyle : TTStyle {
|
||||
UIColor* _color;
|
||||
UIColor* _highlightColor;
|
||||
CGFloat _width;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) UIColor* color;
|
||||
@property (nonatomic, retain) UIColor* highlightColor;
|
||||
@property (nonatomic) CGFloat width;
|
||||
|
||||
+ (TTHighlightBorderStyle*)styleWithColor:(UIColor*)color highlightColor:(UIColor*)highlightColor
|
||||
width:(CGFloat)width next:(TTStyle*)next;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyle.h"
|
||||
|
||||
@interface TTImageStyle : TTStyle {
|
||||
NSString* _imageURL;
|
||||
UIImage* _image;
|
||||
UIImage* _defaultImage;
|
||||
|
||||
CGSize _size;
|
||||
|
||||
UIViewContentMode _contentMode;
|
||||
}
|
||||
|
||||
@property (nonatomic, copy) NSString* imageURL;
|
||||
@property (nonatomic, retain) UIImage* image;
|
||||
@property (nonatomic, retain) UIImage* defaultImage;
|
||||
@property (nonatomic) CGSize size;
|
||||
|
||||
@property (nonatomic) UIViewContentMode contentMode;
|
||||
|
||||
+ (TTImageStyle*)styleWithImageURL:(NSString*)imageURL next:(TTStyle*)next;
|
||||
+ (TTImageStyle*)styleWithImageURL:(NSString*)imageURL defaultImage:(UIImage*)defaultImage
|
||||
next:(TTStyle*)next;
|
||||
+ (TTImageStyle*)styleWithImageURL:(NSString*)imageURL defaultImage:(UIImage*)defaultImage
|
||||
contentMode:(UIViewContentMode)contentMode
|
||||
size:(CGSize)size next:(TTStyle*)next;
|
||||
+ (TTImageStyle*)styleWithImage:(UIImage*)image next:(TTStyle*)next;
|
||||
+ (TTImageStyle*)styleWithImage:(UIImage*)image defaultImage:(UIImage*)defaultImage
|
||||
next:(TTStyle*)next;
|
||||
+ (TTImageStyle*)styleWithImage:(UIImage*)image defaultImage:(UIImage*)defaultImage
|
||||
contentMode:(UIViewContentMode)contentMode
|
||||
size:(CGSize)size next:(TTStyle*)next;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTShadowStyle.h"
|
||||
|
||||
@interface TTInnerShadowStyle : TTShadowStyle
|
||||
@end
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyle.h"
|
||||
|
||||
@interface TTInsetStyle : TTStyle {
|
||||
UIEdgeInsets _inset;
|
||||
}
|
||||
|
||||
@property (nonatomic) UIEdgeInsets inset;
|
||||
|
||||
+ (TTInsetStyle*)styleWithInset:(UIEdgeInsets)inset next:(TTStyle*)next;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface TTLayout : NSObject
|
||||
|
||||
- (CGSize)layoutSubviews:(NSArray*)subviews forView:(UIView*)view;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyle.h"
|
||||
|
||||
@interface TTLinearGradientBorderStyle : TTStyle {
|
||||
UIColor* _color1;
|
||||
UIColor* _color2;
|
||||
CGFloat _location1;
|
||||
CGFloat _location2;
|
||||
CGFloat _width;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) UIColor* color1;
|
||||
@property (nonatomic, retain) UIColor* color2;
|
||||
@property (nonatomic) CGFloat location1;
|
||||
@property (nonatomic) CGFloat location2;
|
||||
@property (nonatomic) CGFloat width;
|
||||
|
||||
+ (TTLinearGradientBorderStyle*)styleWithColor1:(UIColor*)color1 color2:(UIColor*)color2
|
||||
width:(CGFloat)width next:(TTStyle*)next;
|
||||
+ (TTLinearGradientBorderStyle*)styleWithColor1:(UIColor*)color1 location1:(CGFloat)location1
|
||||
color2:(UIColor*)color2 location2:(CGFloat)location2
|
||||
width:(CGFloat)width next:(TTStyle*)next;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyle.h"
|
||||
|
||||
@interface TTLinearGradientFillStyle : TTStyle {
|
||||
UIColor* _color1;
|
||||
UIColor* _color2;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) UIColor* color1;
|
||||
@property (nonatomic, retain) UIColor* color2;
|
||||
|
||||
+ (TTLinearGradientFillStyle*)styleWithColor1:(UIColor*)color1 color2:(UIColor*)color2
|
||||
next:(TTStyle*)next;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyle.h"
|
||||
|
||||
@interface TTMaskStyle : TTStyle {
|
||||
UIImage* _mask;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) UIImage* mask;
|
||||
|
||||
+ (TTMaskStyle*)styleWithMask:(UIImage*)mask next:(TTStyle*)next;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyle.h"
|
||||
|
||||
@class TTStyleContext;
|
||||
|
||||
@interface TTPartStyle : TTStyle {
|
||||
NSString* _name;
|
||||
TTStyle* _style;
|
||||
}
|
||||
|
||||
@property (nonatomic, copy) NSString* name;
|
||||
@property (nonatomic, retain) TTStyle* style;
|
||||
|
||||
+ (TTPartStyle*)styleWithName:(NSString*)name style:(TTStyle*)style next:(TTStyle*)next;
|
||||
|
||||
- (void)drawPart:(TTStyleContext*)context;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
typedef enum {
|
||||
TTPositionStatic,
|
||||
TTPositionAbsolute,
|
||||
TTPositionFloatLeft,
|
||||
TTPositionFloatRight,
|
||||
} TTPosition;
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTShape.h"
|
||||
|
||||
@interface TTRectangleShape : TTShape
|
||||
|
||||
+ (TTRectangleShape*)shape;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyle.h"
|
||||
|
||||
@interface TTReflectiveFillStyle : TTStyle {
|
||||
UIColor* _color;
|
||||
BOOL _withBottomHighlight;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) UIColor* color;
|
||||
@property (nonatomic, assign) BOOL withBottomHighlight;
|
||||
|
||||
+ (TTReflectiveFillStyle*)styleWithColor:(UIColor*)color next:(TTStyle*)next;
|
||||
+ (TTReflectiveFillStyle*)styleWithColor:(UIColor*)color
|
||||
withBottomHighlight:(BOOL)withBottomHighlight next:(TTStyle*)next;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTShape.h"
|
||||
|
||||
@interface TTRoundedLeftArrowShape : TTShape {
|
||||
CGFloat _radius;
|
||||
}
|
||||
|
||||
@property (nonatomic) CGFloat radius;
|
||||
|
||||
+ (TTRoundedLeftArrowShape*)shapeWithRadius:(CGFloat)radius;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTShape.h"
|
||||
|
||||
@interface TTRoundedRectangleShape : TTShape {
|
||||
CGFloat _topLeftRadius;
|
||||
CGFloat _topRightRadius;
|
||||
CGFloat _bottomRightRadius;
|
||||
CGFloat _bottomLeftRadius;
|
||||
}
|
||||
|
||||
@property (nonatomic) CGFloat topLeftRadius;
|
||||
@property (nonatomic) CGFloat topRightRadius;
|
||||
@property (nonatomic) CGFloat bottomRightRadius;
|
||||
@property (nonatomic) CGFloat bottomLeftRadius;
|
||||
|
||||
+ (TTRoundedRectangleShape*)shapeWithRadius:(CGFloat)radius;
|
||||
|
||||
+ (TTRoundedRectangleShape*)shapeWithTopLeft:(CGFloat)topLeft topRight:(CGFloat)topRight
|
||||
bottomRight:(CGFloat)bottomRight bottomLeft:(CGFloat)bottomLeft;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTShape.h"
|
||||
|
||||
@interface TTRoundedRightArrowShape : TTShape {
|
||||
CGFloat _radius;
|
||||
}
|
||||
|
||||
@property (nonatomic) CGFloat radius;
|
||||
|
||||
+ (TTRoundedRightArrowShape*)shapeWithRadius:(CGFloat)radius;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyle.h"
|
||||
|
||||
@interface TTShadowStyle : TTStyle {
|
||||
UIColor* _color;
|
||||
CGFloat _blur;
|
||||
CGSize _offset;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) UIColor* color;
|
||||
@property (nonatomic) CGFloat blur;
|
||||
@property (nonatomic) CGSize offset;
|
||||
|
||||
+ (TTShadowStyle*)styleWithColor:(UIColor*)color blur:(CGFloat)blur offset:(CGSize)offset
|
||||
next:(TTStyle*)next;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface TTShape : NSObject
|
||||
|
||||
- (void)openPath:(CGRect)rect;
|
||||
- (void)closePath:(CGRect)rect;
|
||||
|
||||
- (void)addTopEdgeToPath:(CGRect)rect lightSource:(NSInteger)lightSource;
|
||||
- (void)addRightEdgeToPath:(CGRect)rect lightSource:(NSInteger)lightSource;
|
||||
- (void)addBottomEdgeToPath:(CGRect)rect lightSource:(NSInteger)lightSource;
|
||||
- (void)addLeftEdgeToPath:(CGRect)rect lightSource:(NSInteger)lightSource;
|
||||
|
||||
/**
|
||||
* Opens the path, adds all edges, and closes the path.
|
||||
*/
|
||||
- (void)addToPath:(CGRect)rect;
|
||||
|
||||
- (void)addInverseToPath:(CGRect)rect;
|
||||
|
||||
- (UIEdgeInsets)insetsForSize:(CGSize)size;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyle.h"
|
||||
|
||||
@class TTShape;
|
||||
|
||||
/**
|
||||
* Causes all layers going forward to use a particular shape.
|
||||
*/
|
||||
@interface TTShapeStyle : TTStyle {
|
||||
TTShape* _shape;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) TTShape* shape;
|
||||
|
||||
+ (TTShapeStyle*)styleWithShape:(TTShape*)shape next:(TTStyle*)next;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyle.h"
|
||||
|
||||
@interface TTSolidBorderStyle : TTStyle {
|
||||
UIColor* _color;
|
||||
CGFloat _width;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) UIColor* color;
|
||||
@property (nonatomic) CGFloat width;
|
||||
|
||||
+ (TTSolidBorderStyle*)styleWithColor:(UIColor*)color width:(CGFloat)width next:(TTStyle*)next;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyle.h"
|
||||
|
||||
@interface TTSolidFillStyle : TTStyle {
|
||||
UIColor* _color;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) UIColor* color;
|
||||
|
||||
+ (TTSolidFillStyle*)styleWithColor:(UIColor*)color next:(TTStyle*)next;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTShape.h"
|
||||
|
||||
@interface TTSpeechBubbleShape : TTShape {
|
||||
CGFloat _radius;
|
||||
CGFloat _pointLocation;
|
||||
CGFloat _pointAngle;
|
||||
CGSize _pointSize;
|
||||
}
|
||||
|
||||
@property (nonatomic) CGFloat radius;
|
||||
@property (nonatomic) CGFloat pointLocation;
|
||||
@property (nonatomic) CGFloat pointAngle;
|
||||
@property (nonatomic) CGSize pointSize;
|
||||
|
||||
+ (TTSpeechBubbleShape*)shapeWithRadius:(CGFloat)radius pointLocation:(CGFloat)pointLocation
|
||||
pointAngle:(CGFloat)pointAngle pointSize:(CGSize)pointSize;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class TTStyleContext;
|
||||
|
||||
@interface TTStyle : NSObject {
|
||||
TTStyle* _next;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) TTStyle* next;
|
||||
|
||||
- (id)initWithNext:(TTStyle*)next;
|
||||
|
||||
- (TTStyle*)next:(TTStyle*)next;
|
||||
|
||||
- (void)draw:(TTStyleContext*)context;
|
||||
|
||||
- (UIEdgeInsets)addToInsets:(UIEdgeInsets)insets forSize:(CGSize)size;
|
||||
- (CGSize)addToSize:(CGSize)size context:(TTStyleContext*)context;
|
||||
|
||||
- (void)addStyle:(TTStyle*)style;
|
||||
|
||||
- (id)firstStyleOfClass:(Class)cls;
|
||||
- (id)styleForPart:(NSString*)name;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class TTShape;
|
||||
@protocol TTStyleDelegate;
|
||||
|
||||
@interface TTStyleContext : NSObject {
|
||||
CGRect _frame;
|
||||
CGRect _contentFrame;
|
||||
|
||||
TTShape* _shape;
|
||||
|
||||
UIFont* _font;
|
||||
|
||||
BOOL _didDrawContent;
|
||||
|
||||
id<TTStyleDelegate> _delegate;
|
||||
}
|
||||
|
||||
@property (nonatomic) CGRect frame;
|
||||
@property (nonatomic) CGRect contentFrame;
|
||||
@property (nonatomic, retain) TTShape* shape;
|
||||
@property (nonatomic, retain) UIFont* font;
|
||||
@property (nonatomic) BOOL didDrawContent;
|
||||
|
||||
@property (nonatomic, assign) id<TTStyleDelegate> delegate;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class TTStyle;
|
||||
@class TTStyleContext;
|
||||
|
||||
@protocol TTStyleDelegate <NSObject>
|
||||
@optional
|
||||
|
||||
- (NSString*)textForLayerWithStyle:(TTStyle*)style;
|
||||
|
||||
- (UIImage*)imageForLayerWithStyle:(TTStyle*)style;
|
||||
|
||||
- (void)drawLayer:(TTStyleContext*)context withStyle:(TTStyle*)style;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class TTStyle;
|
||||
|
||||
@interface TTStyleSheet : NSObject {
|
||||
NSMutableDictionary* _styles;
|
||||
}
|
||||
|
||||
+ (TTStyleSheet*)globalStyleSheet;
|
||||
+ (void)setGlobalStyleSheet:(TTStyleSheet*)styleSheet;
|
||||
|
||||
- (TTStyle*)styleWithSelector:(NSString*)selector;
|
||||
- (TTStyle*)styleWithSelector:(NSString*)selector forState:(UIControlState)state;
|
||||
|
||||
- (void)freeMemory;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyledElement.h"
|
||||
|
||||
@interface TTStyledBlock : TTStyledElement
|
||||
@end
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyledInline.h"
|
||||
|
||||
@interface TTStyledBoldNode : TTStyledInline
|
||||
@end
|
||||
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyledFrame.h"
|
||||
#import "Three20Style/TTStyleDelegate.h"
|
||||
|
||||
@interface TTStyledBoxFrame : TTStyledFrame <TTStyleDelegate> {
|
||||
TTStyledBoxFrame* _parentFrame;
|
||||
TTStyledFrame* _firstChildFrame;
|
||||
TTStyle* _style;
|
||||
}
|
||||
|
||||
@property (nonatomic, assign) TTStyledBoxFrame* parentFrame;
|
||||
@property (nonatomic, retain) TTStyledFrame* firstChildFrame;
|
||||
|
||||
/**
|
||||
* The style used to render the frame;
|
||||
*/
|
||||
@property (nonatomic, retain) TTStyle* style;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyledInlineBlock.h"
|
||||
|
||||
@interface TTStyledButtonNode : TTStyledInlineBlock {
|
||||
NSString* _URL;
|
||||
BOOL _highlighted;
|
||||
}
|
||||
|
||||
@property (nonatomic) BOOL highlighted;
|
||||
@property (nonatomic, retain) NSString* URL;
|
||||
|
||||
- (id)initWithURL:(NSString*)URL;
|
||||
- (id)initWithURL:(NSString*)URL next:(TTStyledNode*)nextSibling;
|
||||
|
||||
// Designated initializer
|
||||
- (id)initWithText:(NSString*)text URL:(NSString*)URL next:(TTStyledNode*)nextSibling;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyledNode.h"
|
||||
|
||||
@interface TTStyledElement : TTStyledNode {
|
||||
TTStyledNode* _firstChild;
|
||||
TTStyledNode* _lastChild;
|
||||
NSString* _className;
|
||||
}
|
||||
|
||||
@property (nonatomic, readonly) TTStyledNode* firstChild;
|
||||
@property (nonatomic, readonly) TTStyledNode* lastChild;
|
||||
@property (nonatomic, retain) NSString* className;
|
||||
|
||||
- (id)initWithText:(NSString*)text;
|
||||
|
||||
// Designated initializer
|
||||
- (id)initWithText:(NSString*)text next:(TTStyledNode*)nextSibling;
|
||||
|
||||
- (void)addChild:(TTStyledNode*)child;
|
||||
- (void)addText:(NSString*)text;
|
||||
- (void)replaceChild:(TTStyledNode*)oldChild withChild:(TTStyledNode*)newChild;
|
||||
|
||||
- (TTStyledNode*)getElementByClassName:(NSString*)className;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class TTStyledElement;
|
||||
@class TTStyledFrame;
|
||||
@class TTStyledBoxFrame;
|
||||
|
||||
@interface TTStyledFrame : NSObject {
|
||||
TTStyledElement* _element;
|
||||
TTStyledFrame* _nextFrame;
|
||||
CGRect _bounds;
|
||||
}
|
||||
|
||||
/**
|
||||
* The element that contains the frame.
|
||||
*/
|
||||
@property (nonatomic, readonly) TTStyledElement* element;
|
||||
|
||||
/**
|
||||
* The next in the linked list of frames.
|
||||
*/
|
||||
@property (nonatomic, retain) TTStyledFrame* nextFrame;
|
||||
|
||||
/**
|
||||
* The bounds of the content that is displayed by this frame.
|
||||
*/
|
||||
@property (nonatomic) CGRect bounds;
|
||||
|
||||
@property (nonatomic) CGFloat x;
|
||||
@property (nonatomic) CGFloat y;
|
||||
@property (nonatomic) CGFloat width;
|
||||
@property (nonatomic) CGFloat height;
|
||||
|
||||
- (UIFont*)font;
|
||||
|
||||
- (id)initWithElement:(TTStyledElement*)element;
|
||||
|
||||
/**
|
||||
* Draws the frame.
|
||||
*/
|
||||
- (void)drawInRect:(CGRect)rect;
|
||||
|
||||
- (TTStyledBoxFrame*)hitTest:(CGPoint)point;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyledFrame.h"
|
||||
#import "Three20Style/TTStyleDelegate.h"
|
||||
|
||||
@class TTStyledImageNode;
|
||||
|
||||
@interface TTStyledImageFrame : TTStyledFrame <TTStyleDelegate> {
|
||||
TTStyledImageNode* _imageNode;
|
||||
TTStyle* _style;
|
||||
}
|
||||
|
||||
/**
|
||||
* The node represented by the frame.
|
||||
*/
|
||||
@property (nonatomic, readonly) TTStyledImageNode* imageNode;
|
||||
|
||||
/**
|
||||
* The style used to render the frame;
|
||||
*/
|
||||
@property (nonatomic, retain) TTStyle* style;
|
||||
|
||||
- (id)initWithElement:(TTStyledElement*)element node:(TTStyledImageNode*)node;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyledElement.h"
|
||||
|
||||
@interface TTStyledImageNode : TTStyledElement {
|
||||
NSString* _URL;
|
||||
UIImage* _image;
|
||||
UIImage* _defaultImage;
|
||||
CGFloat _width;
|
||||
CGFloat _height;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) NSString* URL;
|
||||
@property (nonatomic, retain) UIImage* image;
|
||||
@property (nonatomic, retain) UIImage* defaultImage;
|
||||
@property (nonatomic) CGFloat width;
|
||||
@property (nonatomic) CGFloat height;
|
||||
|
||||
- (id)initWithURL:(NSString*)URL;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyledElement.h"
|
||||
|
||||
@interface TTStyledInline : TTStyledElement
|
||||
@end
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyledElement.h"
|
||||
|
||||
@interface TTStyledInlineBlock : TTStyledElement
|
||||
@end
|
||||
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyledBoxFrame.h"
|
||||
|
||||
@interface TTStyledInlineFrame : TTStyledBoxFrame {
|
||||
TTStyledInlineFrame* _inlinePreviousFrame;
|
||||
TTStyledInlineFrame* _inlineNextFrame;
|
||||
}
|
||||
|
||||
@property (nonatomic, readonly) TTStyledInlineFrame* inlineParentFrame;
|
||||
@property (nonatomic, assign) TTStyledInlineFrame* inlinePreviousFrame;
|
||||
@property (nonatomic, assign) TTStyledInlineFrame* inlineNextFrame;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyledInline.h"
|
||||
|
||||
@interface TTStyledItalicNode : TTStyledInline
|
||||
@end
|
||||
@@ -0,0 +1,67 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class TTStyle;
|
||||
@class TTStyledNode;
|
||||
@class TTStyledElement;
|
||||
@class TTStyledFrame;
|
||||
@class TTStyledBoxFrame;
|
||||
@class TTStyledInlineFrame;
|
||||
|
||||
@interface TTStyledLayout : NSObject {
|
||||
CGFloat _x;
|
||||
CGFloat _width;
|
||||
CGFloat _height;
|
||||
CGFloat _lineWidth;
|
||||
CGFloat _lineHeight;
|
||||
CGFloat _minX;
|
||||
CGFloat _floatLeftWidth;
|
||||
CGFloat _floatRightWidth;
|
||||
CGFloat _floatHeight;
|
||||
|
||||
TTStyledFrame* _rootFrame;
|
||||
TTStyledFrame* _lineFirstFrame;
|
||||
TTStyledInlineFrame* _inlineFrame;
|
||||
TTStyledBoxFrame* _topFrame;
|
||||
TTStyledFrame* _lastFrame;
|
||||
|
||||
UIFont* _font;
|
||||
UIFont* _boldFont;
|
||||
UIFont* _italicFont;
|
||||
|
||||
TTStyle* _linkStyle;
|
||||
TTStyledNode* _rootNode;
|
||||
TTStyledNode* _lastNode;
|
||||
|
||||
NSMutableArray* _invalidImages;
|
||||
}
|
||||
|
||||
@property (nonatomic) CGFloat width;
|
||||
@property (nonatomic) CGFloat height;
|
||||
@property (nonatomic, retain) UIFont* font;
|
||||
@property (nonatomic, readonly) TTStyledFrame* rootFrame;
|
||||
@property (nonatomic, retain) NSMutableArray* invalidImages;
|
||||
|
||||
- (id)initWithRootNode:(TTStyledNode*)rootNode;
|
||||
- (id)initWithX:(CGFloat)x width:(CGFloat)width height:(CGFloat)height;
|
||||
|
||||
- (void)layout:(TTStyledNode*)node;
|
||||
- (void)layout:(TTStyledNode*)node container:(TTStyledElement*)element;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyledBlock.h"
|
||||
|
||||
@interface TTStyledLineBreakNode : TTStyledBlock
|
||||
@end
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyledInline.h"
|
||||
|
||||
@interface TTStyledLinkNode : TTStyledInline {
|
||||
NSString* _URL;
|
||||
BOOL _highlighted;
|
||||
}
|
||||
|
||||
@property (nonatomic) BOOL highlighted;
|
||||
@property (nonatomic, retain) NSString* URL;
|
||||
|
||||
- (id)initWithURL:(NSString*)URL;
|
||||
- (id)initWithURL:(NSString*)URL next:(TTStyledNode*)nextSibling;
|
||||
|
||||
// Designated initializer
|
||||
- (id)initWithText:(NSString*)text URL:(NSString*)URL next:(TTStyledNode*)nextSibling;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface TTStyledNode : NSObject {
|
||||
TTStyledNode* _nextSibling;
|
||||
TTStyledNode* _parentNode;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) TTStyledNode* nextSibling;
|
||||
@property (nonatomic, assign) TTStyledNode* parentNode;
|
||||
@property (nonatomic, readonly) NSString* outerText;
|
||||
@property (nonatomic, readonly) NSString* outerHTML;
|
||||
|
||||
// Designated initializer
|
||||
- (id)initWithNextSibling:(TTStyledNode*)nextSibling;
|
||||
|
||||
- (id)ancestorOrSelfWithClass:(Class)cls;
|
||||
|
||||
- (void) performDefaultAction;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,140 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
// Network
|
||||
#import "Three20Network/TTURLRequestDelegate.h"
|
||||
|
||||
@protocol TTStyledTextDelegate;
|
||||
@class TTStyledNode;
|
||||
@class TTStyledFrame;
|
||||
@class TTStyledBoxFrame;
|
||||
|
||||
@interface TTStyledText : NSObject <TTURLRequestDelegate> {
|
||||
TTStyledNode* _rootNode;
|
||||
TTStyledFrame* _rootFrame;
|
||||
UIFont* _font;
|
||||
CGFloat _width;
|
||||
CGFloat _height;
|
||||
NSMutableArray* _invalidImages;
|
||||
NSMutableArray* _imageRequests;
|
||||
|
||||
id<TTStyledTextDelegate> _delegate;
|
||||
}
|
||||
|
||||
@property (nonatomic, assign) id<TTStyledTextDelegate> delegate;
|
||||
|
||||
/**
|
||||
* The first in the sequence of nodes that contain the styled text.
|
||||
*/
|
||||
@property (nonatomic, retain) TTStyledNode* rootNode;
|
||||
|
||||
/**
|
||||
* The first in the sequence of frames of text calculated by the layout.
|
||||
*/
|
||||
@property (nonatomic, readonly) TTStyledFrame* rootFrame;
|
||||
|
||||
/**
|
||||
* The font that will be used to measure and draw all text.
|
||||
*/
|
||||
@property (nonatomic, retain) UIFont* font;
|
||||
|
||||
/**
|
||||
* The width that the text should be constrained to fit within.
|
||||
*/
|
||||
@property (nonatomic) CGFloat width;
|
||||
|
||||
/**
|
||||
* The height of the text.
|
||||
*
|
||||
* The height is automatically calculated based on the width and the size of word-wrapped text.
|
||||
*/
|
||||
@property (nonatomic, readonly) CGFloat height;
|
||||
|
||||
/**
|
||||
* Indicates if the text needs layout to recalculate its size.
|
||||
*/
|
||||
@property (nonatomic, readonly) BOOL needsLayout;
|
||||
|
||||
/**
|
||||
* Images that require loading
|
||||
*/
|
||||
@property (nonatomic, readonly) NSMutableArray* invalidImages;
|
||||
|
||||
/**
|
||||
* Constructs styled text with XHTML tags turned into style nodes.
|
||||
*
|
||||
* Only the following XHTML tags are supported: b, i, img, a. The source must
|
||||
* be a well-formed XHTML fragment. You do not need to enclose the source in an tag --
|
||||
* it can be any string with XHTML tags throughout.
|
||||
*/
|
||||
+ (TTStyledText*)textFromXHTML:(NSString*)source;
|
||||
+ (TTStyledText*)textFromXHTML:(NSString*)source lineBreaks:(BOOL)lineBreaks URLs:(BOOL)URLs;
|
||||
|
||||
/**
|
||||
* Constructs styled text with all URLs transformed into links.
|
||||
*
|
||||
* Only URLs are parsed, not HTML markup. URLs are turned into links.
|
||||
*/
|
||||
+ (TTStyledText*)textWithURLs:(NSString*)source;
|
||||
+ (TTStyledText*)textWithURLs:(NSString*)source lineBreaks:(BOOL)lineBreaks;
|
||||
|
||||
- (id)initWithNode:(TTStyledNode*)rootNode;
|
||||
|
||||
- (void)layoutFrames;
|
||||
|
||||
- (void)layoutIfNeeded;
|
||||
|
||||
/**
|
||||
* Called to indicate that the layout needs to be re-calculated.
|
||||
*/
|
||||
- (void)setNeedsLayout;
|
||||
|
||||
/**
|
||||
* Draws the text at a point.
|
||||
*/
|
||||
- (void)drawAtPoint:(CGPoint)point;
|
||||
|
||||
/**
|
||||
* Draws the text at a point with optional highlighting.
|
||||
*
|
||||
* If highlighted is YES, text colors will be ignored and all text will be drawn in the same color.
|
||||
*/
|
||||
- (void)drawAtPoint:(CGPoint)point highlighted:(BOOL)highlighted;
|
||||
|
||||
/**
|
||||
* Determines which frame is intersected by a point.
|
||||
*/
|
||||
- (TTStyledBoxFrame*)hitTest:(CGPoint)point;
|
||||
|
||||
/**
|
||||
* Finds the frame that represents the node.
|
||||
*
|
||||
* If multiple frames represent a node, such as an inline frame with line breaks, the
|
||||
* first frame in the sequence will be returned.
|
||||
*/
|
||||
- (TTStyledFrame*)getFrameForNode:(TTStyledNode*)node;
|
||||
|
||||
- (void)addChild:(TTStyledNode*)child;
|
||||
|
||||
- (void)addText:(NSString*)text;
|
||||
|
||||
- (void)insertChild:(TTStyledNode*)child atIndex:(NSInteger)index;
|
||||
|
||||
- (TTStyledNode*)getElementByClassName:(NSString*)className;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class TTStyledText;
|
||||
|
||||
@protocol TTStyledTextDelegate <NSObject>
|
||||
@optional
|
||||
|
||||
- (void)styledTextNeedsDisplay:(TTStyledText*)text;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyledFrame.h"
|
||||
|
||||
@class TTStyledTextNode;
|
||||
|
||||
@interface TTStyledTextFrame : TTStyledFrame {
|
||||
TTStyledTextNode* _node;
|
||||
NSString* _text;
|
||||
UIFont* _font;
|
||||
}
|
||||
|
||||
/**
|
||||
* The node represented by the frame.
|
||||
*/
|
||||
@property (nonatomic, readonly) TTStyledTextNode* node;
|
||||
|
||||
/**
|
||||
* The text that is displayed by this frame.
|
||||
*/
|
||||
@property (nonatomic, readonly) NSString* text;
|
||||
|
||||
/**
|
||||
* The font that is used to measure and display the text of this frame.
|
||||
*/
|
||||
@property (nonatomic, retain) UIFont* font;
|
||||
|
||||
- (id)initWithText:(NSString*)text element:(TTStyledElement*)element node:(TTStyledTextNode*)node;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyledNode.h"
|
||||
|
||||
@interface TTStyledTextNode : TTStyledNode {
|
||||
NSString* _text;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) NSString* text;
|
||||
|
||||
- (id)initWithText:(NSString*)text;
|
||||
|
||||
// Designated initializer
|
||||
- (id)initWithText:(NSString*)text next:(TTStyledNode*)nextSibling;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,48 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class TTStyledNode;
|
||||
@class TTStyledElement;
|
||||
|
||||
#if __IPHONE_4_0 && __IPHONE_4_0 <= __IPHONE_OS_VERSION_MAX_ALLOWED
|
||||
@interface TTStyledTextParser : NSObject <NSXMLParserDelegate> {
|
||||
#else
|
||||
@interface TTStyledTextParser : NSObject {
|
||||
#endif
|
||||
TTStyledNode* _rootNode;
|
||||
TTStyledElement* _topElement;
|
||||
TTStyledNode* _lastNode;
|
||||
|
||||
NSError* _parserError;
|
||||
|
||||
NSMutableString* _chars;
|
||||
NSMutableArray* _stack;
|
||||
|
||||
BOOL _parseLineBreaks;
|
||||
BOOL _parseURLs;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) TTStyledNode* rootNode;
|
||||
@property (nonatomic) BOOL parseLineBreaks;
|
||||
@property (nonatomic) BOOL parseURLs;
|
||||
|
||||
- (void)parseXHTML:(NSString*)html;
|
||||
- (void)parseText:(NSString*)string;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,70 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTStyle.h"
|
||||
|
||||
@interface TTTextStyle : TTStyle {
|
||||
UIFont* _font;
|
||||
UIColor* _color;
|
||||
|
||||
UIColor* _shadowColor;
|
||||
CGSize _shadowOffset;
|
||||
|
||||
CGFloat _minimumFontSize;
|
||||
NSInteger _numberOfLines;
|
||||
|
||||
UITextAlignment _textAlignment;
|
||||
UIControlContentVerticalAlignment _verticalAlignment;
|
||||
|
||||
UILineBreakMode _lineBreakMode;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) UIFont* font;
|
||||
@property (nonatomic, retain) UIColor* color;
|
||||
|
||||
@property (nonatomic, retain) UIColor* shadowColor;
|
||||
@property (nonatomic) CGSize shadowOffset;
|
||||
|
||||
@property (nonatomic) CGFloat minimumFontSize;
|
||||
@property (nonatomic) NSInteger numberOfLines;
|
||||
|
||||
@property (nonatomic) UITextAlignment textAlignment;
|
||||
@property (nonatomic) UIControlContentVerticalAlignment verticalAlignment;
|
||||
|
||||
@property (nonatomic) UILineBreakMode lineBreakMode;
|
||||
|
||||
+ (TTTextStyle*)styleWithFont:(UIFont*)font next:(TTStyle*)next;
|
||||
+ (TTTextStyle*)styleWithColor:(UIColor*)color next:(TTStyle*)next;
|
||||
+ (TTTextStyle*)styleWithFont:(UIFont*)font color:(UIColor*)color next:(TTStyle*)next;
|
||||
+ (TTTextStyle*)styleWithFont:(UIFont*)font color:(UIColor*)color
|
||||
textAlignment:(UITextAlignment)textAlignment next:(TTStyle*)next;
|
||||
+ (TTTextStyle*)styleWithFont:(UIFont*)font color:(UIColor*)color
|
||||
shadowColor:(UIColor*)shadowColor shadowOffset:(CGSize)shadowOffset
|
||||
next:(TTStyle*)next;
|
||||
+ (TTTextStyle*)styleWithFont:(UIFont*)font color:(UIColor*)color
|
||||
minimumFontSize:(CGFloat)minimumFontSize
|
||||
shadowColor:(UIColor*)shadowColor shadowOffset:(CGSize)shadowOffset
|
||||
next:(TTStyle*)next;
|
||||
+ (TTTextStyle*)styleWithFont:(UIFont*)font color:(UIColor*)color
|
||||
minimumFontSize:(CGFloat)minimumFontSize
|
||||
shadowColor:(UIColor*)shadowColor shadowOffset:(CGSize)shadowOffset
|
||||
textAlignment:(UITextAlignment)textAlignment
|
||||
verticalAlignment:(UIControlContentVerticalAlignment)verticalAlignment
|
||||
lineBreakMode:(UILineBreakMode)lineBreakMode numberOfLines:(NSInteger)numberOfLines
|
||||
next:(TTStyle*)next;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/Three20Style.h"
|
||||
|
||||
// Additions
|
||||
#import "Three20Style/UIColorAdditions.h"
|
||||
#import "Three20Style/UIFontAdditions.h"
|
||||
#import "Three20Style/UIImageAdditions.h"
|
||||
@@ -0,0 +1,89 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Core
|
||||
#import "Three20Core/Three20Core.h"
|
||||
|
||||
// Network
|
||||
#import "Three20Network/Three20Network.h"
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTGlobalStyle.h"
|
||||
#import "Three20Style/TTPosition.h"
|
||||
|
||||
#import "Three20Style/TTDefaultStyleSheet.h"
|
||||
#import "Three20Style/TTDefaultStyleSheet+DragRefreshHeader.h"
|
||||
#import "Three20Style/TTLayout.h"
|
||||
#import "Three20Style/TTFlowLayout.h"
|
||||
#import "Three20Style/TTGridLayout.h"
|
||||
|
||||
// Shapes
|
||||
#import "Three20Style/TTShape.h"
|
||||
#import "Three20Style/TTRectangleShape.h"
|
||||
#import "Three20Style/TTRoundedRectangleShape.h"
|
||||
#import "Three20Style/TTRoundedRightArrowShape.h"
|
||||
#import "Three20Style/TTRoundedLeftArrowShape.h"
|
||||
#import "Three20Style/TTSpeechBubbleShape.h"
|
||||
|
||||
// Styles
|
||||
#import "Three20Style/TTStyle.h"
|
||||
#import "Three20Style/TTStyleDelegate.h"
|
||||
#import "Three20Style/TTStyleContext.h"
|
||||
#import "Three20Style/TTContentStyle.h"
|
||||
#import "Three20Style/TTPartStyle.h"
|
||||
#import "Three20Style/TTShapeStyle.h"
|
||||
#import "Three20Style/TTInsetStyle.h"
|
||||
#import "Three20Style/TTBoxStyle.h"
|
||||
#import "Three20Style/TTTextStyle.h"
|
||||
#import "Three20Style/TTImageStyle.h"
|
||||
#import "Three20Style/TTMaskStyle.h"
|
||||
#import "Three20Style/TTBlendStyle.h"
|
||||
#import "Three20Style/TTSolidFillStyle.h"
|
||||
#import "Three20Style/TTLinearGradientFillStyle.h"
|
||||
#import "Three20Style/TTReflectiveFillStyle.h"
|
||||
#import "Three20Style/TTShadowStyle.h"
|
||||
#import "Three20Style/TTInnerShadowStyle.h"
|
||||
#import "Three20Style/TTSolidBorderStyle.h"
|
||||
#import "Three20Style/TTHighlightBorderStyle.h"
|
||||
#import "Three20Style/TTFourBorderStyle.h"
|
||||
#import "Three20Style/TTBevelBorderStyle.h"
|
||||
#import "Three20Style/TTLinearGradientBorderStyle.h"
|
||||
|
||||
#import "Three20Style/TTStyledText.h"
|
||||
#import "Three20Style/TTStyledTextDelegate.h"
|
||||
|
||||
// Styled nodes
|
||||
#import "Three20Style/TTStyledNode.h"
|
||||
#import "Three20Style/TTStyledTextNode.h"
|
||||
#import "Three20Style/TTStyledElement.h"
|
||||
#import "Three20Style/TTStyledBlock.h"
|
||||
#import "Three20Style/TTStyledInline.h"
|
||||
#import "Three20Style/TTStyledInlineBlock.h"
|
||||
#import "Three20Style/TTStyledBoldNode.h"
|
||||
#import "Three20Style/TTStyledItalicNode.h"
|
||||
#import "Three20Style/TTStyledLinkNode.h"
|
||||
#import "Three20Style/TTStyledButtonNode.h"
|
||||
#import "Three20Style/TTStyledImageNode.h"
|
||||
#import "Three20Style/TTStyledLineBreakNode.h"
|
||||
|
||||
// Styled frames
|
||||
#import "Three20Style/TTStyledFrame.h"
|
||||
#import "Three20Style/TTStyledBoxFrame.h"
|
||||
#import "Three20Style/TTStyledInlineFrame.h"
|
||||
#import "Three20Style/TTStyledTextFrame.h"
|
||||
#import "Three20Style/TTStyledImageFrame.h"
|
||||
|
||||
#import "Three20Style/TTStyledTextParser.h"
|
||||
@@ -0,0 +1,62 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface UIColor (TTCategory)
|
||||
|
||||
/**
|
||||
* Accepted ranges:
|
||||
* hue: 0.0 - 360.0
|
||||
* saturation: 0.0 - 1.0
|
||||
* value: 0.0 - 1.0
|
||||
* alpha: 0.0 - 1.0
|
||||
*/
|
||||
+ (UIColor*)colorWithHue:(CGFloat)h saturation:(CGFloat)s value:(CGFloat)v alpha:(CGFloat)a;
|
||||
|
||||
/**
|
||||
* Accepted ranges:
|
||||
* hue: 0.0 - 1.0
|
||||
* saturation: 0.0 - 1.0
|
||||
* value: 0.0 - 1.0
|
||||
*/
|
||||
- (UIColor*)multiplyHue:(CGFloat)hd saturation:(CGFloat)sd value:(CGFloat)vd;
|
||||
|
||||
- (UIColor*)addHue:(CGFloat)hd saturation:(CGFloat)sd value:(CGFloat)vd;
|
||||
|
||||
/**
|
||||
* Returns a new UIColor with the given alpha.
|
||||
*/
|
||||
- (UIColor*)copyWithAlpha:(CGFloat)newAlpha;
|
||||
|
||||
/**
|
||||
* Uses multiplyHue:saturation:value:alpha: to create a lighter version of the color.
|
||||
*/
|
||||
- (UIColor*)highlight;
|
||||
|
||||
/**
|
||||
* Uses multiplyHue:saturation:value:alpha: to create a darker version of the color.
|
||||
*/
|
||||
- (UIColor*)shadow;
|
||||
|
||||
- (CGFloat)hue;
|
||||
|
||||
- (CGFloat)saturation;
|
||||
|
||||
- (CGFloat)value;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface UIFont (TTCategory)
|
||||
|
||||
/**
|
||||
* Gets the height of a line of text with this font.
|
||||
*
|
||||
* Why this isn't part of UIFont is beyond me. This is the height you would expect to get
|
||||
* by calling sizeWithFont.
|
||||
*
|
||||
* App Store-safe method declaration.
|
||||
* Hurrah for broken static code analysis.
|
||||
*/
|
||||
- (CGFloat)ttLineHeight;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface UIImage (TTCategory)
|
||||
|
||||
/*
|
||||
* Resizes an image. Optionally rotates the image based on imageOrientation.
|
||||
*/
|
||||
- (UIImage*)transformWidth:(CGFloat)width height:(CGFloat)height rotate:(BOOL)rotate;
|
||||
|
||||
/**
|
||||
* Returns a CGRect positioned within rect given the contentMode.
|
||||
*/
|
||||
- (CGRect)convertRect:(CGRect)rect withContentMode:(UIViewContentMode)contentMode;
|
||||
|
||||
/**
|
||||
* Draws the image using content mode rules.
|
||||
*/
|
||||
- (void)drawInRect:(CGRect)rect contentMode:(UIViewContentMode)contentMode;
|
||||
|
||||
/**
|
||||
* Draws the image as a rounded rectangle.
|
||||
*/
|
||||
- (void)drawInRect:(CGRect)rect radius:(CGFloat)radius;
|
||||
- (void)drawInRect:(CGRect)rect radius:(CGFloat)radius contentMode:(UIViewContentMode)contentMode;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// Copyright 2009-2010 Facebook
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Style
|
||||
#import "Three20Style/TTGlobalStyle.h" // For TT_ROUNDED
|
||||
|
||||
extern const CGFloat kArrowPointWidth;
|
||||
extern const CGFloat kArrowRadius;
|
||||
|
||||
#define RD(_RADIUS) (_RADIUS == TT_ROUNDED ? round(fh/2) : _RADIUS)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user