-
Notifications
You must be signed in to change notification settings - Fork 0
/
CPTDefinitions.h
197 lines (173 loc) · 5.76 KB
/
CPTDefinitions.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#import <Availability.h>
#import <TargetConditionals.h>
/// @file
/**
* @def CPT_SDK_SUPPORTS_WEAK
* @hideinitializer
* @brief Defined as @num{1} if the compiler and active SDK support weak references, @num{0} otherwise.
**/
/**
* @def __cpt_weak
* @hideinitializer
* @brief A custom definition for automatic reference counting (ARC) weak references that falls back to
* <code>__unsafe_unretained</code> values on older platforms.
**/
/**
* @def cpt_weak_property
* @hideinitializer
* @brief A custom definition for automatic reference counting (ARC) weak properties that falls back to
* <code>assign</code> on older platforms.
**/
// This is based on Ryan Petrich's ZWRCompatibility: https://github.com/rpetrich/ZWRCompatibility
#if TARGET_OS_IPHONE && defined(__IPHONE_5_0) && (__IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_5_0) && __clang__ && (__clang_major__ >= 3)
#define CPT_SDK_SUPPORTS_WEAK 1
#elif TARGET_OS_MAC && defined(__MAC_10_7) && (MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_7) && __clang__ && (__clang_major__ >= 3)
#define CPT_SDK_SUPPORTS_WEAK 1
#else
#define CPT_SDK_SUPPORTS_WEAK 0
#endif
#if CPT_SDK_SUPPORTS_WEAK
#define __cpt_weak
#define cpt_weak_property weak
#else
#if __clang__ && (__clang_major__ >= 3)
#define __cpt_weak __unsafe_unretained
#else
#define __cpt_weak
#endif
#define cpt_weak_property assign
#endif
// Deprecated method attribute
/**
* @def cpt_deprecated
* @hideinitializer
* @brief Marks a method declaration as deprecated.
**/
#define cpt_deprecated __attribute__( (deprecated) )
// Type safety defines
/**
* @def CPTFloat
* @hideinitializer
* @param x The number to cast.
* @brief Casts a number to @ref CGFloat.
**/
#define CPTFloat(x) ( (CGFloat)(x) )
/**
* @def CPTPointMake
* @hideinitializer
* @param x The x-coordinate of the point.
* @param y The y-coordinate of the point.
* @brief A replacement for @ref CGPointMake(), casting each parameter to @ref CGFloat.
**/
#define CPTPointMake(x, y) CGPointMake( (CGFloat)(x), (CGFloat)(y) )
/**
* @def CPTSizeMake
* @hideinitializer
* @param w The width of the size.
* @param h The height of the size.
* @brief A replacement for @ref CGSizeMake(), casting each parameter to @ref CGFloat.
**/
#define CPTSizeMake(w, h) CGSizeMake( (CGFloat)(w), (CGFloat)(h) )
/**
* @def CPTRectMake
* @hideinitializer
* @param x The x-coordinate of the rectangle.
* @param y The y-coordinate of the rectangle.
* @param w The width of the rectangle.
* @param h The height of the rectangle.
* @brief A replacement for @ref CGRectMake(), casting each parameter to @ref CGFloat.
**/
#define CPTRectMake(x, y, w, h) CGRectMake( (CGFloat)(x), (CGFloat)(y), (CGFloat)(w), (CGFloat)(h) )
/**
* @def CPTRectInset
* @hideinitializer
* @param rect The rectangle to offset.
* @param dx The x-offset.
* @param dy The y-offset.
* @brief A replacement for @ref CGRectInset(), casting each offset parameter to @ref CGFloat.
**/
#define CPTRectInset(rect, dx, dy) CGRectInset( rect, (CGFloat)(dx), (CGFloat)(dy) )
/**
* @brief Enumeration of numeric types
**/
typedef enum _CPTNumericType {
CPTNumericTypeInteger, ///< Integer
CPTNumericTypeFloat, ///< Float
CPTNumericTypeDouble ///< Double
}
CPTNumericType;
/**
* @brief Enumeration of error bar types
**/
typedef enum _CPTErrorBarType {
CPTErrorBarTypeCustom, ///< Custom error bars
CPTErrorBarTypeConstantRatio, ///< Constant ratio error bars
CPTErrorBarTypeConstantValue ///< Constant value error bars
}
CPTErrorBarType;
/**
* @brief Enumeration of axis scale types
**/
typedef enum _CPTScaleType {
CPTScaleTypeLinear, ///< Linear axis scale
CPTScaleTypeLog, ///< Logarithmic axis scale
CPTScaleTypeAngular, ///< Angular axis scale (not implemented)
CPTScaleTypeDateTime, ///< Date/time axis scale (not implemented)
CPTScaleTypeCategory ///< Category axis scale (not implemented)
}
CPTScaleType;
/**
* @brief Enumeration of axis coordinates
**/
typedef enum _CPTCoordinate {
CPTCoordinateX = 0, ///< X axis
CPTCoordinateY = 1, ///< Y axis
CPTCoordinateZ = 2 ///< Z axis
}
CPTCoordinate;
/**
* @brief RGBA color for gradients
**/
typedef struct _CPTRGBAColor {
CGFloat red; ///< The red component (0 ≤ @par{red} ≤ 1).
CGFloat green; ///< The green component (0 ≤ @par{green} ≤ 1).
CGFloat blue; ///< The blue component (0 ≤ @par{blue} ≤ 1).
CGFloat alpha; ///< The alpha component (0 ≤ @par{alpha} ≤ 1).
}
CPTRGBAColor;
/**
* @brief Enumeration of label positioning offset directions
**/
typedef enum _CPTSign {
CPTSignNone = 0, ///< No offset
CPTSignPositive = +1, ///< Positive offset
CPTSignNegative = -1 ///< Negative offset
}
CPTSign;
/**
* @brief Locations around the edge of a rectangle.
**/
typedef enum _CPTRectAnchor {
CPTRectAnchorBottomLeft, ///< The bottom left corner
CPTRectAnchorBottom, ///< The bottom center
CPTRectAnchorBottomRight, ///< The bottom right corner
CPTRectAnchorLeft, ///< The left middle
CPTRectAnchorRight, ///< The right middle
CPTRectAnchorTopLeft, ///< The top left corner
CPTRectAnchorTop, ///< The top center
CPTRectAnchorTopRight, ///< The top right
CPTRectAnchorCenter ///< The center of the rect
}
CPTRectAnchor;
/**
* @brief Label and constraint alignment constants.
**/
typedef enum _CPTAlignment {
CPTAlignmentLeft, ///< Align horizontally to the left side.
CPTAlignmentCenter, ///< Align horizontally to the center.
CPTAlignmentRight, ///< Align horizontally to the right side.
CPTAlignmentTop, ///< Align vertically to the top.
CPTAlignmentMiddle, ///< Align vertically to the middle.
CPTAlignmentBottom ///< Align vertically to the bottom.
}
CPTAlignment;