text: //
  //  iCarousel.h
  //
  //  Version 1.7 beta
  //
  //  Created by Nick Lockwood on 01/04/2011.
  //  Copyright 2010 Charcoal Design
  //
  //  Distributed under the permissive zlib License
  //  Get the latest version from either of these locations:
  //
  //  http://charcoaldesign.co.uk/source/cocoa#icarousel
  //  https://github.com/nicklockwood/iCarousel
  //
  //  This software is provided 'as-is', without any express or implied
  //  warranty.  In no event will the authors be held liable for any damages
  //  arising from the use of this software.
  //
  //  Permission is granted to anyone to use this software for any purpose,
  //  including commercial applications, and to alter it and redistribute it
  //  freely, subject to the following restrictions:
  //
  //  1. The origin of this software must not be misrepresented; you must not
  //  claim that you wrote the original software. If you use this software
  //  in a product, an acknowledgment in the product documentation would be
  //  appreciated but is not required.
  //
  //  2. Altered source versions must be plainly marked as such, and must not be
  //  misrepresented as being the original software.
  //
  //  3. This notice may not be removed or altered from any source distribution.
  //
  
  //
  //  ARC Helper
  //
  //  Version 2.0
  //
  //  Created by Nick Lockwood on 05/01/2012.
  //  Copyright 2012 Charcoal Design
  //
  //  Distributed under the permissive zlib license
  //  Get the latest version from here:
  //
  //  https://gist.github.com/1563325
  //
  
  #ifndef ah_retain
  #if __has_feature(objc_arc)
  #define ah_retain self
  #define ah_dealloc self
  #define release self
  #define autorelease self
  #else
  #define ah_retain retain
  #define ah_dealloc dealloc
  #define __bridge
  #endif
  #endif
  
  //  Weak reference support
  
  #import <Availability.h>
  #if (defined __IPHONE_OS_VERSION_MIN_REQUIRED && \
  __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_5_0) || \
  (defined __MAC_OS_X_VERSION_MIN_REQUIRED && \
  __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_7)
  #undef weak
  #define weak unsafe_unretained
  #undef __weak
  #define __weak __unsafe_unretained
  #endif
  
  //  ARC Helper ends
  
  
  #import <QuartzCore/QuartzCore.h>
  
  #ifdef USING_CHAMELEON
  #define ICAROUSEL_IOS
  #elif defined __IPHONE_OS_VERSION_MAX_ALLOWED
  #define ICAROUSEL_IOS
  typedef CGRect NSRect;
  typedef CGSize NSSize;
  #else
  #define ICAROUSEL_MACOS
  #endif
  
  
  #ifdef ICAROUSEL_IOS
  #import <UIKit/UIKit.h>
  #else
  #import <Cocoa/Cocoa.h>
  typedef NSView UIView;
  #endif
  
  
  typedef enum
  {
      iCarouselTypeLinear = 0,
      iCarouselTypeRotary,
      iCarouselTypeInvertedRotary,
      iCarouselTypeCylinder,
      iCarouselTypeInvertedCylinder,
      iCarouselTypeWheel,
      iCarouselTypeInvertedWheel,
      iCarouselTypeCoverFlow,
      iCarouselTypeCoverFlow2,
      iCarouselTypeTimeMachine,
      iCarouselTypeInvertedTimeMachine,
      iCarouselTypeCustom
  }
  iCarouselType;
  
  
  typedef enum
  {
      iCarouselTranformOptionCount = 0,
      iCarouselTranformOptionArc,
  	iCarouselTranformOptionAngle,
      iCarouselTranformOptionRadius,
      iCarouselTranformOptionTilt,
      iCarouselTranformOptionSpacing
  }
  iCarouselTranformOption;
  
  
  @protocol iCarouselDataSource, iCarouselDelegate;
  
  @interface iCarousel : UIView
  
  //required for 32-bit Macs
  #ifdef __i386__
  {
  	@private
  	
      id<iCarouselDelegate> __weak _delegate;
      id<iCarouselDataSource> __weak _dataSource;
      iCarouselType _type;
      CGFloat _perspective;
      NSInteger _numberOfItems;
      NSInteger _numberOfPlaceholders;
  	NSInteger _numberOfPlaceholdersToShow;
      NSInteger _numberOfVisibleItems;
      UIView *_contentView;
      NSDictionary *_itemViews;
      NSMutableSet *_itemViewPool;
      NSMutableSet *_placeholderViewPool;
      NSInteger _previousItemIndex;
      CGFloat _itemWidth;
      CGFloat _scrollOffset;
      CGFloat _offsetMultiplier;
      CGFloat _startVelocity;
      id __unsafe_unretained _timer;
      BOOL _decelerating;
      BOOL _scrollEnabled;
      CGFloat _decelerationRate;
      BOOL _bounces;
      CGSize _contentOffset;
      CGSize _viewpointOffset;
      CGFloat _startOffset;
      CGFloat _endOffset;
      NSTimeInterval _scrollDuration;
      NSTimeInterval _startTime;
      BOOL _scrolling;
      CGFloat _previousTranslation;
  	BOOL _centerItemWhenSelected;
  	BOOL _shouldWrap;
  	BOOL _dragging;
      BOOL _didDrag;
      CGFloat _scrollSpeed;
      CGFloat _bounceDistance;
      NSTimeInterval _toggleTime;
      CGFloat _toggle;
      BOOL _stopAtItemBoundary;
      BOOL _scrollToItemBoundary;
      BOOL _useDisplayLink;
  	BOOL _vertical;
      BOOL _ignorePerpendicularSwipes;
      NSInteger _animationDisableCount;
  }
  #endif
  
  @property (nonatomic, weak) IBOutlet id<iCarouselDataSource> dataSource;
  @property (nonatomic, weak) IBOutlet id<iCarouselDelegate> delegate;
  @property (nonatomic, assign) iCarouselType type;
  @property (nonatomic, assign) CGFloat perspective;
  @property (nonatomic, assign) CGFloat decelerationRate;
  @property (nonatomic, assign) CGFloat scrollSpeed;
  @property (nonatomic, assign) CGFloat bounceDistance;
  @property (nonatomic, assign) BOOL scrollEnabled;
  @property (nonatomic, assign) BOOL bounces;
  @property (nonatomic, assign) CGFloat scrollOffset;
  @property (nonatomic, readonly) CGFloat offsetMultiplier;
  @property (nonatomic, assign) CGSize contentOffset;
  @property (nonatomic, assign) CGSize viewpointOffset;
  @property (nonatomic, readonly) NSInteger numberOfItems;
  @property (nonatomic, readonly) NSInteger numberOfPlaceholders;
  @property (nonatomic, assign) NSInteger currentItemIndex;
  @property (nonatomic, strong, readonly) UIView *currentItemView;
  @property (nonatomic, strong, readonly) NSArray *indexesForVisibleItems;
  @property (nonatomic, readonly) NSInteger numberOfVisibleItems;
  @property (nonatomic, strong, readonly) NSArray *visibleItemViews;
  @property (nonatomic, readonly) CGFloat itemWidth;
  @property (nonatomic, strong, readonly) UIView *contentView;
  @property (nonatomic, readonly) CGFloat toggle;
  @property (nonatomic, assign) BOOL stopAtItemBoundary;
  @property (nonatomic, assign) BOOL scrollToItemBoundary;
  @property (nonatomic, assign) BOOL useDisplayLink;
  @property (nonatomic, assign, getter = isVertical) BOOL vertical;
  @property (nonatomic, assign) BOOL ignorePerpendicularSwipes;
  @property (nonatomic, assign) BOOL centerItemWhenSelected;
  
  - (void)scrollByOffset:(CGFloat)offset duration:(NSTimeInterval)duration;
  - (void)scrollToOffset:(CGFloat)offset duration:(NSTimeInterval)duration;
  - (void)scrollByNumberOfItems:(NSInteger)itemCount duration:(NSTimeInterval)duration;
  - (void)scrollToItemAtIndex:(NSInteger)index duration:(NSTimeInterval)duration;
  - (void)scrollToItemAtIndex:(NSInteger)index animated:(BOOL)animated;
  - (void)removeItemAtIndex:(NSInteger)index animated:(BOOL)animated;
  - (void)insertItemAtIndex:(NSInteger)index animated:(BOOL)animated;
  - (void)reloadItemAtIndex:(NSInteger)index animated:(BOOL)animated;
  - (UIView *)itemViewAtIndex:(NSInteger)index;
  - (NSInteger)indexOfItemView:(UIView *)view;
  - (NSInteger)indexOfItemViewOrSubview:(UIView *)view;
  - (CGFloat)offsetForItemAtIndex:(NSInteger)index;
  - (void)reloadData;
  
  @end
  
  
  @protocol iCarouselDataSource <NSObject>
  
  - (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel;
  - (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view;
  
  @optional
  
  - (NSUInteger)numberOfPlaceholdersInCarousel:(iCarousel *)carousel;
  - (UIView *)carousel:(iCarousel *)carousel placeholderViewAtIndex:(NSUInteger)index reusingView:(UIView *)view;
  - (NSUInteger)numberOfVisibleItemsInCarousel:(iCarousel *)carousel;
  
  @end
  
  
  @protocol iCarouselDelegate <NSObject>
  @optional
  
  - (void)carouselWillBeginScrollingAnimation:(iCarousel *)carousel;
  - (void)carouselDidEndScrollingAnimation:(iCarousel *)carousel;
  - (void)carouselDidScroll:(iCarousel *)carousel;
  - (void)carouselCurrentItemIndexUpdated:(iCarousel *)carousel;
  - (void)carouselWillBeginDragging:(iCarousel *)carousel;
  - (void)carouselDidEndDragging:(iCarousel *)carousel willDecelerate:(BOOL)decelerate;
  - (void)carouselWillBeginDecelerating:(iCarousel *)carousel;
  - (void)carouselDidEndDecelerating:(iCarousel *)carousel;
  - (CGFloat)carouselItemWidth:(iCarousel *)carousel;
  - (CGFloat)carouselOffsetMultiplier:(iCarousel *)carousel;
  - (BOOL)carouselShouldWrap:(iCarousel *)carousel;
  - (CGFloat)carousel:(iCarousel *)carousel itemAlphaForOffset:(CGFloat)offset;
  - (CATransform3D)carousel:(iCarousel *)carousel itemTransformForOffset:(CGFloat)offset baseTransform:(CATransform3D)transform;
  - (CGFloat)carousel:(iCarousel *)carousel valueForTransformOption:(iCarouselTranformOption)option withDefault:(CGFloat)value;
  - (BOOL)carousel:(iCarousel *)carousel shouldSelectItemAtIndex:(NSInteger)index;
  - (void)carousel:(iCarousel *)carousel didSelectItemAtIndex:(NSInteger)index;
  
  @end