-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathSSMonthMatrix.m
68 lines (61 loc) · 2.05 KB
/
SSMonthMatrix.m
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
#import "SSMonthMatrix.h"
#import "SSUtilityCategories.h"
#import "SSYLocalize/NSString+Localize.h"
@implementation SSMonthMatrix
// Over-rides of NSMatrix methods
// The objectValue is an NSArray of NSNumbers of buttons which are pushed
//- (NSArray*)objectValue {
// NSMutableArray* pushedButtonIndexes = [[NSMutableArray alloc] init] ;
// NSEnumerator* e = [[self cells] reverseObjectEnumerator] ;
// // We go in reverse because we first want to see if lastDayOfTheMonth is active
// // because if it is, we filter out days 29, 30 and 31.
// BOOL lastDayOfMonthActive = NO ;
// NSCell* cell ;
// while ((cell = [e nextObject])) {
// if ([[cell objectValue] boolValue]) {
// int intValue = ([cell tag] + _tagOffset) ;
// if (intValue == 32) {
// lastDayOfMonthActive = YES ;
// }
// if (!lastDayOfMonthActive || (intValue <= 28) || (intValue >= 32)) {
// NSNumber* value = [NSNumber numberWithInt:intValue] ;
// [pushedButtonIndexes addObject:value] ;
// }
// }
// }
//
// NSArray* output = [[NSArray arrayWithArray:pushedButtonIndexes] arrayByReversingOrder] ;
// // Note that we also re-reverse the array to get it back in normal order
// [pushedButtonIndexes release] ;
// return output ;
//}
//- (void)setObjectValue:(NSArray*)pushedButtonIndexes {
// [super setObjectValue:pushedButtonIndexes] ;
//
// int i ;
// for (i=28; i<=31; i++) {
// NSButtonCell* cell = [self cellWithTag:(i - _tagOffset)] ;
// if (lastDayOfMonthActive) {
// [cell setState:NSOffState] ;
// [cell setEnabled:NO] ;
// }
// else {
// [cell setEnabled:YES] ;
// }
// }
//}
- (id)initWithCoder:(NSCoder*)coder {
if ((self = [super initWithCoder:coder])) {
_tagOffset = 1 ; // Since cells start with 0 but months start with 1
}
return self ;
}
- (void)awakeFromNib {
[self setToolTip:[NSString localize:@"lastDayOfTheMonth"] forCell:[self cellWithTag:(32 - _tagOffset)]] ;
NSInteger i ;
for (i=29; i<=31; i++) {
NSButtonCell* cell = [self cellWithTag:(i - _tagOffset)] ;
[self setToolTip:[NSString localize:@"warningWillRunOnLastDay"] forCell:cell] ;
}
}
@end