-
Notifications
You must be signed in to change notification settings - Fork 598
Expand file tree
/
Copy pathCPTDefinitions.h
More file actions
286 lines (242 loc) · 8 KB
/
CPTDefinitions.h
File metadata and controls
286 lines (242 loc) · 8 KB
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
#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_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_property weak
#else
#define cpt_weak_property unsafe_unretained
#endif
// Deprecated method attribute
/**
* @def cpt_deprecated
* @hideinitializer
* @brief Marks a method declaration as deprecated.
**/
#define cpt_deprecated __attribute__((deprecated))
// Unused parameter attribute (DEBUG only)
/**
* @def cpt_unused
* @hideinitializer
* @brief Marks a parameter value as unused only in RELEASE builds.
**/
#ifdef DEBUG
#define cpt_unused
#else
#define cpt_unused __unused
#endif
// Swift wrappers
/**
* @def cpt_swift_enum
* @hideinitializer
* @brief Marks a type definition to be imported into Swift as an enumeration.
**/
#define cpt_swift_enum __attribute__((swift_wrapper(enum)))
/**
* @def cpt_swift_struct
* @hideinitializer
* @brief Marks a type definition to be imported into Swift as a structure.
**/
#define cpt_swift_struct __attribute__((swift_wrapper(struct)))
// 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))
/**
* @def CPTNAN
* @hideinitializer
* @brief The not-a-number constant (@NAN), cast to @ref CGFloat.
**/
#define CPTNAN ((CGFloat)NAN)
/**
* @brief Enumeration of numeric types
**/
typedef NS_ENUM (NSInteger, CPTNumericType) {
CPTNumericTypeInteger, ///< Integer
CPTNumericTypeFloat, ///< Float
CPTNumericTypeDouble ///< Double
};
/**
* @brief Enumeration of error bar types
**/
typedef NS_ENUM (NSInteger, CPTErrorBarType) {
CPTErrorBarTypeCustom, ///< Custom error bars
CPTErrorBarTypeConstantRatio, ///< Constant ratio error bars
CPTErrorBarTypeConstantValue ///< Constant value error bars
};
/**
* @brief Enumeration of axis scale types
**/
typedef NS_ENUM (NSInteger, 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
CPTScaleTypeLogModulus ///< Log-modulus axis scale
};
/**
* @brief Enumeration of axis coordinates
**/
typedef NS_ENUM (NSInteger, CPTCoordinate) {
CPTCoordinateX = 0, ///< X axis
CPTCoordinateY = 1, ///< Y axis
CPTCoordinateZ = 2, ///< Z axis
CPTCoordinateNone = NSIntegerMax ///< Invalid coordinate value
};
/**
* @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 NS_CLOSED_ENUM(NSInteger, CPTSign) {
CPTSignNone = 0, ///< No offset
CPTSignPositive = +1, ///< Positive offset
CPTSignNegative = -1 ///< Negative offset
};
/**
* @brief Locations around the edge of a rectangle.
**/
typedef NS_ENUM (NSInteger, 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
};
/**
* @brief Label and constraint alignment constants.
**/
typedef NS_ENUM (NSInteger, 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.
};
/**
* @brief Edge inset distances for stretchable images.
**/
typedef struct _CPTEdgeInsets {
CGFloat top; ///< The top inset.
CGFloat left; ///< The left inset.
CGFloat bottom; ///< The bottom inset.
CGFloat right; ///< The right inset.
}
CPTEdgeInsets;
extern const CPTEdgeInsets CPTEdgeInsetsZero; ///< Defines a set of stretchable image edge insets where all of the values are zero (@num{0}).
extern const NSStringDrawingOptions CPTStringDrawingOptions; ///< String drawing options used when measuring and drawing text.
/**
* @brief An array of numbers.
**/
typedef NSArray<NSNumber *> CPTNumberArray;
/**
* @brief A mutable array of numbers.
**/
typedef NSMutableArray<NSNumber *> CPTMutableNumberArray;
/**
* @brief A set of numbers.
**/
typedef NSSet<NSNumber *> CPTNumberSet;
/**
* @brief A mutable set of numbers.
**/
typedef NSMutableSet<NSNumber *> CPTMutableNumberSet;
/**
* @brief An array of strings.
**/
typedef NSArray<NSString *> CPTStringArray;
/**
* @brief A mutable array of strings.
**/
typedef NSMutableArray<NSString *> CPTMutableStringArray;
/**
* @brief An array of values.
**/
typedef NSArray<NSValue *> CPTValueArray;
/**
* @brief A mutable array of values.
**/
typedef NSMutableArray<NSValue *> CPTMutableValueArray;
/**
* @brief An array of strings.
**/
typedef NSDictionary<NSString *, id> CPTDictionary;
/**
* @brief A mutable array of strings.
**/
typedef NSMutableDictionary<NSString *, id> CPTMutableDictionary;
/**
* @brief Render a Quick Look image into the given context.
**/
typedef void (^CPTQuickLookImageBlock)(__nonnull CGContextRef context, CGFloat scale, CGRect bounds);