forked from pixmeo/osirix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CPRClusterView.m
127 lines (89 loc) · 2.92 KB
/
CPRClusterView.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*=========================================================================
Program: OsiriX
Copyright (c) OsiriX Team
All rights reserved.
Distributed under GNU - LGPL
See http://www.osirix-viewer.com/copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
=========================================================================*/
#import "CPRClusterView.h"
@interface CPRClusterView ()
- (void)_updateClusterViewFrames;
@end
@implementation CPRClusterView
@synthesize mainView = _mainView;
@synthesize topView = _topView;
@synthesize middleView = _middleView;
@synthesize bottomView = _bottomView;
- (void)dealloc
{
[_mainView release];
_mainView = nil;
[_topView release];
_topView = nil;
[_middleView release];
_middleView = nil;
[_bottomView release];
_bottomView = nil;
[super dealloc];
}
- (void)setMainView:(NSView *)mainView
{
if (mainView != _mainView) {
[_mainView release];
_mainView = [mainView retain];
[self _updateClusterViewFrames];
}
}
- (void)setTopView:(NSView *)topView
{
if (topView != _topView) {
[_topView release];
_topView = [topView retain];
[self _updateClusterViewFrames];
}
}
- (void)setMiddleView:(NSView *)middleView
{
if (middleView != _middleView) {
[_middleView release];
_middleView = [middleView retain];
[self _updateClusterViewFrames];
}
}
- (void)setBottomView:(NSView *)bottomView
{
if (bottomView != _bottomView) {
[_bottomView release];
_bottomView = [bottomView retain];
[self _updateClusterViewFrames];
}
}
- (void)setFrame:(NSRect)frameRect
{
[super setFrame:frameRect];
[self _updateClusterViewFrames];
}
- (void)_updateClusterViewFrames
{
NSDisableScreenUpdates();
CGFloat rightViewHeight;
CGFloat rightViewWidth;
CGFloat rightViewX;
rightViewHeight = NSHeight(self.bounds)/3;
rightViewHeight = floor(rightViewHeight);
rightViewWidth = MIN(rightViewHeight, NSWidth(self.bounds));
rightViewX = NSWidth(self.bounds) - rightViewWidth;
_bottomView.translatesAutoresizingMaskIntoConstraints = YES;
_middleView.translatesAutoresizingMaskIntoConstraints = YES;
_topView.translatesAutoresizingMaskIntoConstraints = YES;
_mainView.translatesAutoresizingMaskIntoConstraints = YES;
[_bottomView setFrame:NSMakeRect(rightViewX, 0, rightViewWidth, rightViewHeight)];
[_middleView setFrame:NSMakeRect(rightViewX, rightViewHeight, rightViewWidth, rightViewHeight)];
[_topView setFrame:NSMakeRect(rightViewX, rightViewHeight*2.0, rightViewWidth, NSHeight(self.bounds) - 2.0*rightViewHeight)];
[_mainView setFrame:NSMakeRect(0, 0, rightViewX, NSHeight(self.bounds))];
NSEnableScreenUpdates();
}
@end