-
Notifications
You must be signed in to change notification settings - Fork 17
/
OSPane.m
96 lines (70 loc) · 2.02 KB
/
OSPane.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
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
#import "OSPane.h"
#import "missioncontrol/OSPaneThumbnail.h"
#import "missioncontrol/OSThumbnailView.h"
#import "missioncontrol/OSThumbnailPlaceholder.h"
@implementation OSPane
@synthesize name = _name;
@synthesize thumbnail = _thumbnail;
-(id)initWithName:(NSString*)name thumbnail:(UIImage*)thumbnail{
CGRect frame = [[UIScreen mainScreen] bounds];
if(![self isPortrait]){
float widthPlaceholder = frame.size.width;
frame.size.width = frame.size.height;
frame.size.height = widthPlaceholder;
}
if(![super initWithFrame:frame]){
return nil;
}
self.name = name;
self.thumbnail = thumbnail;
self.layer.masksToBounds = false;
self.layer.shadowOffset = CGSizeMake(0, 0);
self.layer.shadowRadius = 10;
self.layer.shadowOpacity = 0.5;
self.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.bounds].CGPath;
return self;
}
- (void)missionControlWillActivate{}
- (void)missionControlWillDeactivate{}
- (void)missionControlDidDeactivate{}
- (void)paneIndexWillChange{}
- (void)paneIndexDidChange{}
- (void)setName:(NSString*)name{
[_name release];
_name = name;
[_name retain];
bool found = false;
for(OSPaneThumbnail *thumbnail in [[[OSThumbnailView sharedInstance] wrapperView] subviews]){
if([thumbnail isKindOfClass:[OSThumbnailPlaceholder class]])
continue;
if(thumbnail.pane == self){
thumbnail.label.text = self.name;
found = true;
}
}
if(!found){
for(OSPaneThumbnail *thumbnail in [[OSThumbnailView sharedInstance] subviews]){
if(![thumbnail isKindOfClass:[OSPaneThumbnail class]])
continue;
if(thumbnail.pane == self){
thumbnail.label.text = self.name;
found = true;
}
}
}
}
-(BOOL)showsDock{
return false;
}
-(BOOL)isPortrait{
if([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait || [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortraitUpsideDown){
return true;
}
return false;
}
- (void)dealloc{
[self.name release];
[self.thumbnail release];
[super dealloc];
}
@end