1 /* vi:set ts=8 sts=4 sw=4 ft=objc:
3 * VIM - Vi IMproved by Bram Moolenaar
4 * MacVim GUI port by Bjorn Winckler
6 * Do ":help uganda" in Vim to read copying and usage conditions.
7 * Do ":help credits" in Vim to see a list of people who contributed.
8 * See README.txt for an overview of the Vim source code.
13 * A normal window with a (possibly hidden) tabline separator at the top of the
16 * The main point of this class is for the window controller to be able to call
17 * contentRectForFrameRect: without having to worry about whether the separator
20 * This is a bit of a hack, it would be nicer to be able to leave the content
21 * view alone, but as it is the tabline separator is a subview of the content
22 * view. Since we want to pretend that the content view does not contain the
23 * separator this leads to some dangerous situations. For instance, calling
24 * [window setContentMinSize:size] when the separator is visible results in
25 * size != [window contentMinSize], since the latter is one pixel higher than
35 @implementation MMWindow
37 - (id)initWithContentRect:(NSRect)rect
38 styleMask:(unsigned int)style
39 backing:(NSBackingStoreType)bufferingType
42 self = [super initWithContentRect:rect
46 if (!self) return nil;
48 NSRect tabSepRect = { 0, rect.size.height - 1, rect.size.width, 1 };
49 tablineSeparator = [[NSBox alloc] initWithFrame:tabSepRect];
51 [tablineSeparator setBoxType:NSBoxSeparator];
52 [tablineSeparator setHidden:YES];
53 [tablineSeparator setAutoresizingMask:NSViewWidthSizable|NSViewMinYMargin];
55 NSView *contentView = [self contentView];
56 [contentView setAutoresizesSubviews:YES];
57 [contentView addSubview:tablineSeparator];
64 [tablineSeparator removeFromSuperviewWithoutNeedingDisplay];
65 [tablineSeparator release]; tablineSeparator = nil;
69 - (BOOL)hideTablineSeparator:(BOOL)hide
71 BOOL isHidden = [tablineSeparator isHidden];
72 [tablineSeparator setHidden:hide];
74 // Return YES if visibility state was toggled, NO if it was unchanged.
75 return isHidden != hide;
78 - (NSRect)contentRectForFrameRect:(NSRect)frame
80 NSRect rect = [super contentRectForFrameRect:frame];
81 if (![tablineSeparator isHidden])
87 - (NSRect)frameRectForContentRect:(NSRect)rect
89 NSRect frame = [super frameRectForContentRect:rect];
90 if (![tablineSeparator isHidden])
96 - (void)setContentMinSize:(NSSize)size
98 if (![tablineSeparator isHidden])
101 [super setContentMinSize:size];
104 - (void)setContentMaxSize:(NSSize)size
106 if (![tablineSeparator isHidden])
109 [super setContentMaxSize:size];
112 - (void)setContentSize:(NSSize)size
114 if (![tablineSeparator isHidden])
117 [super setContentSize:size];
120 - (void)performClose:(id)sender
122 id wc = [self windowController];
123 if ([wc respondsToSelector:@selector(performClose:)])
124 [wc performClose:sender];
126 [super performClose:sender];