forked from rickardp/iqwidgets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIQGanttView.h
139 lines (117 loc) · 4.86 KB
/
IQGanttView.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
//
// IQGanttView.h
// IQWidgets for iOS
//
// Copyright 2010 EvolvIQ
// 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>
#import "IQScrollView.h"
@protocol IQGanttHeaderDelegate;
@protocol IQGanttRowDelegate;
@protocol IQCalendarDataSource;
@class IQGanttView;
typedef UIView* (^IQGanttBlockViewCreationCallback)(IQGanttView* gantt, UIView* rowView, id item, CGRect frame);
typedef NSInteger (^IQGanttRowHeightCallback)(IQGanttView* gantt, UIView* rowView, id<IQCalendarDataSource> rowData);
typedef struct _IQGanttViewTimeWindow {
NSTimeInterval windowStart, windowEnd;
NSTimeInterval viewStart, viewSize;
} IQGanttViewTimeWindow;
@interface IQGanttView : IQScrollView {
@private
NSInteger defaultRowHeight;
NSMutableArray* rows;
NSMutableArray* rowViews;
IQGanttViewTimeWindow scaleWindow;
NSCalendarUnit displayCalendarUnits;
IQGanttBlockViewCreationCallback createBlock;
IQGanttRowHeightCallback rowHeight;
NSCalendar* calendar;
}
@property (nonatomic) IQGanttViewTimeWindow scaleWindow;
@property (nonatomic) NSCalendarUnit displayCalendarUnits;
@property (nonatomic) NSInteger defaultRowHeight;
@property (nonatomic, retain) NSCalendar* calendar;
- (void)removeAllRows;
- (void)addRow:(id<IQCalendarDataSource>)row;
// Overridable methods. Subclass IQGanttView and override the below methods
// to achieve further customization of the user interface.
- (UIView*) cornerViewWithFrame:(CGRect)frame; // default implementation returns nil
- (UIView<IQGanttHeaderDelegate>*) timeHeaderViewWithFrame:(CGRect)frame; // default implementation returns a IQGanttHeaderView
- (UIView*) rowHeaderViewWithFrame:(CGRect)frame; // default implementation returns nil
- (UIView<IQGanttRowDelegate>*) viewForRow:(id<IQCalendarDataSource>)row withFrame:(CGRect)frame; // default implementation returns a IQGanttRowView
@end
// This category uses blocks for defining a call-back interface. This
// option performs better with large data sets and allows for more
// customization than the simple interface.
@interface IQGanttView (CallbackInterface)
- (void) setBlockCreationCallback:(IQGanttBlockViewCreationCallback)callback;
- (void) setRowHeightCallback:(IQGanttRowHeightCallback)callback;
@end
@protocol IQGanttHeaderDelegate
@optional
- (void)ganttView:(IQGanttView*)view didScaleWindow:(IQGanttViewTimeWindow)win;
- (void)ganttView:(IQGanttView*)view didMoveWindow:(IQGanttViewTimeWindow)win;
- (void)ganttView:(IQGanttView*)view shouldDisplayCalendarUnits:(NSCalendarUnit) displayCalendarUnits;
- (void)ganttView:(IQGanttView*)view didChangeCalendar:(NSCalendar*)calendar;
@end
@protocol IQGanttRowDelegate
@optional
- (void)ganttView:(IQGanttView*)view didChangeDataSource:(id<IQCalendarDataSource>)dataSource;
- (void)ganttView:(IQGanttView*)view didChangeCalendar:(NSCalendar*)calendar;
- (void)ganttView:(IQGanttView*)view didScaleWindow:(IQGanttViewTimeWindow)win;
- (void)ganttView:(IQGanttView*)view didMoveWindow:(IQGanttViewTimeWindow)win;
@end
@interface IQGanttHeaderView : UIView <IQGanttHeaderDelegate> {
@private
IQGanttViewTimeWindow scaleWindow;
CGFloat offset;
UIColor* tintColor;
CGGradientRef grad;
CGColorRef border;
NSCalendarUnit displayCalendarUnits;
NSMutableArray* floatingLabels;
char weekdayLetters[8];
NSCalendar* cal;
NSDateFormatter* monthNameFormatter;
}
@property (nonatomic, retain) UIColor* tintColor;
@property (nonatomic, readonly) NSDateFormatter* monthNameFormatter;
@end
typedef struct _IQGridDash {
CGFloat a,b;
} IQGridDash;
static IQGridDash IQMakeGridDash(CGFloat a, CGFloat b) {
IQGridDash ret;
ret.a = a;
ret.b = b;
return ret;
}
@interface IQGanttRowView : UIView <IQGanttRowDelegate> {
@private
NSCalendar* cal;
IQGanttViewTimeWindow scaleWindow;
NSCalendarUnit primaryLineUnits;
NSCalendarUnit secondaryLineUnits;
NSCalendarUnit tertaryLineUnits;
}
@property (nonatomic, retain) id<IQCalendarDataSource> dataSource;
@property (nonatomic, retain) UIColor* primaryGridColor;
@property (nonatomic, retain) UIColor* secondaryGridColor;
@property (nonatomic, retain) UIColor* tertaryGridColor;
@property (nonatomic) IQGridDash primaryGridDash;
@property (nonatomic) IQGridDash secondaryGridDash;
@property (nonatomic) IQGridDash tertaryGridDash;
// Overridable. Called to create and manage the subviews.
- (void) layoutItems:(IQGanttView*)gantt;
@end