mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-16 07:31:28 +00:00
-allow any window to become a sheet
This commit is contained in:
@@ -2395,7 +2395,7 @@ CPTexturedBackgroundWindowMask
|
||||
- (void)_endSheet
|
||||
{
|
||||
CPLog("%@ %@", [self class], _cmd);
|
||||
|
||||
|
||||
var sheet = _sheetContext["sheet"],
|
||||
delegate = _sheetContext["modalDelegate"],
|
||||
endSelector = _sheetContext["endSelector"];
|
||||
@@ -2445,6 +2445,8 @@ CPTexturedBackgroundWindowMask
|
||||
|
||||
[sheet orderOut:self];
|
||||
|
||||
[sheet._windowView _enableSheet:NO];
|
||||
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPWindowDidEndSheetNotification object:self];
|
||||
|
||||
if (_nextSheetContext)
|
||||
|
||||
@@ -54,4 +54,9 @@ var _CPStandardWindowViewBodyBackgroundColor = nil;
|
||||
return aContentRect;
|
||||
}
|
||||
|
||||
- (void)_enableSheet:(BOOL)enable
|
||||
{
|
||||
// do nothing, already a sheet
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -208,8 +208,40 @@ var HUD_TITLEBAR_HEIGHT = 26.0;
|
||||
[_titleField setFrame:CGRectMake(20.0, 3.0, width - 40.0, CGRectGetHeight([_titleField frame]))];
|
||||
|
||||
var maxY = [self toolbarMaxY];
|
||||
if ([_titleField isHidden])
|
||||
maxY -= ([self toolbarOffset]).height;
|
||||
|
||||
[[theWindow contentView] setFrameOrigin:CGPointMake(0.0, maxY, width, CGRectGetHeight(bounds) - maxY)];
|
||||
//[[theWindow contentView] setFrameOrigin:CGPointMake(0.0, maxY, width, CGRectGetHeight(bounds) - maxY)];
|
||||
|
||||
var contentRect = CGRectMake(0.0, maxY, width, CGRectGetHeight(bounds) - maxY);
|
||||
|
||||
[[theWindow contentView] setFrame:contentRect];
|
||||
}
|
||||
|
||||
- (void)_enableSheet:(BOOL)enable
|
||||
{
|
||||
[super _enableSheet:enable];
|
||||
|
||||
// convert window to "sheet mode" and back again
|
||||
[_closeButton setHidden:enable];
|
||||
[_titleField setHidden:enable];
|
||||
|
||||
// resize the window
|
||||
var window = [self window],
|
||||
frame = [window frame];
|
||||
|
||||
var dy = ([self toolbarOffset]).height;
|
||||
if (enable)
|
||||
dy = -dy;
|
||||
|
||||
var newHeight = CGRectGetMaxY(frame) + dy;
|
||||
var newWidth = CGRectGetMaxX(frame);
|
||||
frame.size.height += dy;
|
||||
|
||||
[self setFrameSize:CGSizeMake(newWidth, newHeight)];
|
||||
[self tile];
|
||||
[window setFrame:frame display:NO animate:NO];
|
||||
[window setMovableByWindowBackground:!enable];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -147,8 +147,11 @@ var STANDARD_GRADIENT_HEIGHT = 41.0,
|
||||
return _CPStandardWindowViewTitleBackgroundColor;
|
||||
}
|
||||
|
||||
|
||||
+ (CGRect)contentRectForFrameRect:(CGRect)aFrameRect
|
||||
{
|
||||
CPLog("%@ %@: static", [self class], _cmd);
|
||||
|
||||
var contentRect = CGRectMakeCopy(aFrameRect),
|
||||
titleBarHeight = [self titleBarHeight] + 1.0;
|
||||
|
||||
@@ -160,6 +163,8 @@ var STANDARD_GRADIENT_HEIGHT = 41.0,
|
||||
|
||||
+ (CGRect)frameRectForContentRect:(CGRect)aContentRect
|
||||
{
|
||||
CPLog("%@ %@: static", [self class], _cmd);
|
||||
|
||||
var frameRect = CGRectMakeCopy(aContentRect),
|
||||
titleBarHeight = [self titleBarHeight] + 1.0;
|
||||
|
||||
@@ -181,7 +186,7 @@ var STANDARD_GRADIENT_HEIGHT = 41.0,
|
||||
|
||||
if ([theToolbar isVisible])
|
||||
{
|
||||
toolbarHeight = CGRectGetHeight([[theToolbar _toolbarView] frame]);
|
||||
var toolbarHeight = CGRectGetHeight([[theToolbar _toolbarView] frame]);
|
||||
|
||||
contentRect.origin.y += toolbarHeight;
|
||||
contentRect.size.height -= toolbarHeight;
|
||||
@@ -330,11 +335,13 @@ var STANDARD_GRADIENT_HEIGHT = 41.0,
|
||||
|
||||
[_headView setFrameSize:CGSizeMake(width, [self toolbarMaxY])];
|
||||
[_dividerView setFrame:CGRectMake(0.0, CGRectGetMaxY([_headView frame]), width, 1.0)];
|
||||
|
||||
var dividerMaxY = CGRectGetMaxY([_dividerView frame]);
|
||||
|
||||
|
||||
var dividerMaxY = 0;
|
||||
if (![_dividerView isHidden])
|
||||
dividerMaxY = CGRectGetMaxY([_dividerView frame]);
|
||||
|
||||
[_bodyView setFrame:CGRectMake(0.0, dividerMaxY, width, CGRectGetHeight(bounds) - dividerMaxY)];
|
||||
|
||||
|
||||
var leftOffset = 8;
|
||||
|
||||
if (_closeButton)
|
||||
@@ -344,7 +351,9 @@ var STANDARD_GRADIENT_HEIGHT = 41.0,
|
||||
|
||||
[_titleField setFrame:CGRectMake(leftOffset, 5.0, width - leftOffset * 2.0, CGRectGetHeight([_titleField frame]))];
|
||||
|
||||
[[theWindow contentView] setFrameOrigin:CGPointMake(0.0, CGRectGetMaxY([_dividerView frame]))];
|
||||
var contentRect = CGRectMake(0.0, dividerMaxY, width, CGRectGetHeight([_bodyView frame]));
|
||||
|
||||
[[theWindow contentView] setFrame:contentRect];
|
||||
}
|
||||
/*
|
||||
- (void)setAnimatingToolbar:(BOOL)isAnimatingToolbar
|
||||
@@ -401,10 +410,39 @@ var STANDARD_GRADIENT_HEIGHT = 41.0,
|
||||
|
||||
- (void)mouseDown:(CPEvent)anEvent
|
||||
{
|
||||
if (CGRectContainsPoint([_headView frame], [self convertPoint:[anEvent locationInWindow] fromView:nil]))
|
||||
return [self trackMoveWithEvent:anEvent];
|
||||
if (![_headView isHidden])
|
||||
if (CGRectContainsPoint([_headView frame], [self convertPoint:[anEvent locationInWindow] fromView:nil]))
|
||||
return [self trackMoveWithEvent:anEvent];
|
||||
|
||||
[super mouseDown:anEvent];
|
||||
}
|
||||
|
||||
- (void)_enableSheet:(BOOL)enable
|
||||
{
|
||||
[super _enableSheet:enable];
|
||||
|
||||
// convert window to "sheet mode" and back again
|
||||
[_headView setHidden:enable];
|
||||
[_dividerView setHidden:enable];
|
||||
[_closeButton setHidden:enable];
|
||||
[_minimizeButton setHidden:enable];
|
||||
[_titleField setHidden:enable];
|
||||
|
||||
// resize the window
|
||||
var window = [self window],
|
||||
frame = [window frame];
|
||||
|
||||
var dy = CGRectGetHeight([_headView frame]) + CGRectGetHeight([_dividerView frame]);
|
||||
if (enable)
|
||||
dy = -dy;
|
||||
|
||||
var newHeight = CGRectGetMaxY(frame) + dy;
|
||||
var newWidth = CGRectGetMaxX(frame);
|
||||
frame.size.height += dy;
|
||||
|
||||
[self setFrameSize:CGSizeMake(newWidth, newHeight)];
|
||||
[self tile];
|
||||
[window setFrame:frame display:NO animate:NO];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -41,6 +41,8 @@ var _CPWindowViewResizeIndicatorImage = nil;
|
||||
CGPoint _mouseDraggedPoint;
|
||||
|
||||
CGRect _cachedScreenFrame;
|
||||
|
||||
CPView _sheetShadowView;
|
||||
}
|
||||
|
||||
+ (void)initialize
|
||||
@@ -380,4 +382,21 @@ var _CPWindowViewResizeIndicatorImage = nil;
|
||||
[self addSubview:_resizeIndicator];
|
||||
}
|
||||
|
||||
- (void)_enableSheet:(BOOL)enable
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
var bundle = [CPBundle bundleForClass:[CPWindow class]];
|
||||
_sheetShadowView = [[CPView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([self bounds]), 8)];
|
||||
[_sheetShadowView setAutoresizingMask:CPViewWidthSizable];
|
||||
[_sheetShadowView setBackgroundColor:[CPColor colorWithPatternImage:[[CPImage alloc]
|
||||
initWithContentsOfFile:[bundle pathForResource:@"CPWindow/CPWindowAttachedSheetShadow.png"] size:CGSizeMake(9,8)]]];
|
||||
[self addSubview:_sheetShadowView];
|
||||
}
|
||||
else
|
||||
{
|
||||
[_sheetShadowView removeFromSuperview];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user