19 #ifndef COCOA_WINDOW_CONTENT_VIEW_MM
20 #define COCOA_WINDOW_CONTENT_VIEW_MM
27 - (id)initWithFrame:(NSRect)frame {
28 self = [
super initWithFrame:frame];
31 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(layoutSubviews) name:NSViewFrameDidChangeNotification object:self];
37 [[NSNotificationCenter defaultCenter] removeObserver:self];
38 [subviewsInOrder release];
45 -(void) layoutSubviews {
46 NSRect bounds = [
self bounds];
48 NSUInteger numOfSubViews = [subviewsInOrder count];
50 if (numOfSubViews > 0) {
53 CGFloat sizesHeight[numOfSubViews];
54 CGFloat sizesWidth[numOfSubViews];
55 CGFloat exclusiveHeight = 0.0;
56 NSUInteger exclusiveChilds = 0;
59 for (i=0; i<numOfSubViews; i++) {
60 NSView* subview = [subviewsInOrder objectAtIndex:i];
65 sizesWidth[i] = neededWidth;
70 sizesHeight[i] = neededHeight;
71 exclusiveHeight += neededHeight;
77 sizesHeight[i] = -1.0;
84 CGFloat stdHeight = 0.0;
85 if (numOfSubViews > exclusiveChilds) {
86 CGFloat fillHeight = bounds.size.height-exclusiveHeight;
87 stdHeight = (fillHeight)/(numOfSubViews-exclusiveChilds);
90 CGFloat fillHeight = bounds.size.height;
91 stdHeight = (fillHeight)/(numOfSubViews);
94 CGFloat stdWidth = bounds.size.width;
98 NSRect actualFrame = bounds;
99 actualFrame.origin.x = 0.0;
100 actualFrame.origin.y += bounds.size.height;
101 for (i=0; i<numOfSubViews; i++) {
103 CGFloat usedHeight = sizesHeight[i];
104 if (usedHeight < 0.0) usedHeight = stdHeight;
105 actualFrame.origin.y -= usedHeight;
106 actualFrame.size.height = usedHeight;
108 CGFloat usedWidth = sizesWidth[i];
109 if (usedWidth < 0.0) usedWidth = stdWidth;
110 NSView* subview = [subviewsInOrder objectAtIndex:i];
111 actualFrame.size.width = usedWidth;
113 [subview setFrame:actualFrame];
120 -(void) addLayoutSubview:(NSView*)new_subview {
122 [
self addSubview:new_subview];
123 [
self layoutSubviews];
126 #pragma mark Protocoll Methods
130 NSUInteger numOfSubViews = [subviewsInOrder count];
132 NSSize size = NSMakeSize(0,0);
133 if (numOfSubViews > 0) {
135 for (i=0; i<numOfSubViews; i++) {
136 NSView* subview = [subviewsInOrder objectAtIndex:i];
139 if (subViewMinSize.width > size.width) {
140 size.width = subViewMinSize.width;
142 size.height += subViewMinSize.height;