-implement CPWindow sheet notifications on delegate

-raise error when window already has a sheet, or attaching sheet to a sheet
This commit is contained in:
Darrell Walisser
2012-04-28 10:13:02 -04:00
parent 0f43cdee00
commit ce6444c30e
2 changed files with 30 additions and 0 deletions
+13
View File
@@ -933,6 +933,19 @@ CPRunContinuesResponse = -1002;
return;
}
if ([aWindow attachedSheet])
{
[CPException raise:CPInternalInconsistencyException reason:@"The target window of beginSheet: already has a sheet"];
return;
}
if ([aWindow isSheet])
{
[CPException raise:CPInternalInconsistencyException reason:@"The target window of beginSheet: cannot be a sheet"];
return;
}
[aWindow orderFront:self];
[aSheet setPlatformWindow:[aWindow platformWindow]];
[aWindow _attachSheet:aSheet modalDelegate:aModalDelegate didEndSelector:aDidEndSelector contextInfo:aContextInfo];
+17
View File
@@ -1224,6 +1224,8 @@ CPTexturedBackgroundWindowMask
[defaultCenter removeObserver:_delegate name:CPWindowDidResignMainNotification object:self];
[defaultCenter removeObserver:_delegate name:CPWindowDidMoveNotification object:self];
[defaultCenter removeObserver:_delegate name:CPWindowDidResizeNotification object:self];
[defaultCenter removeObserver:_delegate name:CPWindowWillBeginSheetNotification object:self];
[defaultCenter removeObserver:_delegate name:CPWindowDidEndSheetNotification object:self];
_delegate = aDelegate;
_delegateRespondsToWindowWillReturnUndoManagerSelector = [_delegate respondsToSelector:@selector(windowWillReturnUndoManager:)];
@@ -1269,6 +1271,20 @@ CPTexturedBackgroundWindowMask
selector:@selector(windowDidResize:)
name:CPWindowDidResizeNotification
object:self];
if ([_delegate respondsToSelector:@selector(windowWillBeginSheet:)])
[defaultCenter
addObserver:_delegate
selector:@selector(windowWillBeginSheet:)
name:CPWindowWillBeginSheetNotification
object:self];
if ([_delegate respondsToSelector:@selector(windowDidEndSheet:)])
[defaultCenter
addObserver:_delegate
selector:@selector(windowDidEndSheet:)
name:CPWindowDidEndSheetNotification
object:self];
}
/*!
@@ -2367,6 +2383,7 @@ CPTexturedBackgroundWindowMask
startFrame = CGRectMake(originx, originy, sheetFrame.size.width, 0),
endFrame = CGRectMake(originx, originy, sheetFrame.size.width, sheetFrame.size.height);
[[CPNotificationCenter defaultCenter] postNotificationName:CPWindowWillBeginSheetNotification object:self];
// if sheet is attached to a modal window, the sheet runs