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
34 @implementation MMWindow
36 - (id)initWithContentRect:(NSRect)rect
37 styleMask:(unsigned int)style
38 backing:(NSBackingStoreType)bufferingType
41 self = [super initWithContentRect:rect
45 if (!self) return nil;
47 [self setReleasedWhenClosed:NO];
49 NSRect tabSepRect = { 0, rect.size.height - 1, rect.size.width, 1 };
50 tablineSeparator = [[NSBox alloc] initWithFrame:tabSepRect];
52 [tablineSeparator setBoxType:NSBoxSeparator];
53 [tablineSeparator setHidden:YES];
54 [tablineSeparator setAutoresizingMask:NSViewWidthSizable|NSViewMinYMargin];
56 NSView *contentView = [self contentView];
57 [contentView setAutoresizesSubviews:YES];
58 [contentView addSubview:tablineSeparator];
65 // TODO: Is there any reason why we would want the following call?
66 //[tablineSeparator removeFromSuperviewWithoutNeedingDisplay];
67 [tablineSeparator release]; tablineSeparator = nil;
71 - (BOOL)hideTablineSeparator:(BOOL)hide
73 BOOL isHidden = [tablineSeparator isHidden];
74 [tablineSeparator setHidden:hide];
76 // Return YES if visibility state was toggled, NO if it was unchanged.
77 return isHidden != hide;
80 - (NSRect)contentRectForFrameRect:(NSRect)frame
82 NSRect rect = [super contentRectForFrameRect:frame];
83 if (![tablineSeparator isHidden])
89 - (NSRect)frameRectForContentRect:(NSRect)rect
91 NSRect frame = [super frameRectForContentRect:rect];
92 if (![tablineSeparator isHidden])
98 - (void)setContentMinSize:(NSSize)size
100 if (![tablineSeparator isHidden])
103 [super setContentMinSize:size];
106 - (void)setContentMaxSize:(NSSize)size
108 if (![tablineSeparator isHidden])
111 [super setContentMaxSize:size];
114 - (void)setContentSize:(NSSize)size
116 if (![tablineSeparator isHidden])
119 [super setContentSize:size];
122 - (void)performClose:(id)sender
124 id wc = [self windowController];
125 if ([wc respondsToSelector:@selector(performClose:)])
126 [wc performClose:sender];
128 [super performClose:sender];
131 - (BOOL)validateMenuItem:(NSMenuItem *)item
133 if ([item action] == @selector(vimMenuItemAction:)
134 || [item action] == @selector(performClose:))