00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 @import <Foundation/CPCountedSet.j>
00024 @import <Foundation/CPNotificationCenter.j>
00025 @import <Foundation/CPUndoManager.j>
00026
00027 @import "CGGeometry.j"
00028 @import "CPAnimation.j"
00029 @import "CPResponder.j"
00030 @import "CPScreen.j"
00031 @import "CPPlatformWindow.j"
00032
00033 #include "../Platform/Platform.h"
00034 #include "../Platform/DOM/CPDOMDisplayServer.h"
00035
00036 #include "../CoreGraphics/CGGeometry.h"
00037
00038
00039
00040
00041
00042
00043
00044 CPBorderlessWindowMask = 0;
00045
00046
00047
00048
00049
00050 CPTitledWindowMask = 1 << 0;
00051
00052
00053
00054
00055
00056 CPClosableWindowMask = 1 << 1;
00057
00058
00059
00060
00061
00062 CPMiniaturizableWindowMask = 1 << 2;
00063
00064
00065
00066
00067
00068 CPResizableWindowMask = 1 << 3;
00069
00070
00071
00072
00073
00074 CPTexturedBackgroundWindowMask = 1 << 8;
00075
00076
00077
00078
00079 CPBorderlessBridgeWindowMask = 1 << 20;
00080
00081
00082
00083
00084 CPHUDBackgroundWindowMask = 1 << 21;
00085
00086 CPWindowNotSizable = 0;
00087 CPWindowMinXMargin = 1;
00088 CPWindowWidthSizable = 2;
00089 CPWindowMaxXMargin = 4;
00090 CPWindowMinYMargin = 8;
00091 CPWindowHeightSizable = 16;
00092 CPWindowMaxYMargin = 32;
00093
00094 CPBackgroundWindowLevel = -1;
00095
00096
00097
00098
00099
00100 CPNormalWindowLevel = 0;
00101
00102
00103
00104
00105
00106 CPFloatingWindowLevel = 3;
00107
00108
00109
00110
00111
00112 CPSubmenuWindowLevel = 3;
00113
00114
00115
00116
00117
00118 CPTornOffMenuWindowLevel = 3;
00119
00120
00121
00122
00123
00124 CPMainMenuWindowLevel = 24;
00125
00126
00127
00128
00129
00130 CPStatusWindowLevel = 25;
00131
00132
00133
00134
00135
00136 CPModalPanelWindowLevel = 8;
00137
00138
00139
00140
00141
00142 CPPopUpMenuWindowLevel = 101;
00143
00144
00145
00146
00147
00148 CPDraggingWindowLevel = 500;
00149
00150
00151
00152
00153
00154 CPScreenSaverWindowLevel = 1000;
00155
00156
00157
00158
00159
00160
00161 CPWindowOut = 0;
00162
00163
00164
00165
00166
00167 CPWindowAbove = 1;
00168
00169
00170
00171
00172
00173 CPWindowBelow = 2;
00174
00175 CPWindowWillCloseNotification = @"CPWindowWillCloseNotification";
00176 CPWindowDidBecomeMainNotification = @"CPWindowDidBecomeMainNotification";
00177 CPWindowDidResignMainNotification = @"CPWindowDidResignMainNotification";
00178 CPWindowDidBecomeKeyNotification = @"CPWindowDidBecomeKeyNotification";
00179 CPWindowDidResignKeyNotification = @"CPWindowDidResignKeyNotification";
00180 CPWindowDidResizeNotification = @"CPWindowDidResizeNotification";
00181 CPWindowDidMoveNotification = @"CPWindowDidMoveNotification";
00182 CPWindowWillBeginSheetNotification = @"CPWindowWillBeginSheetNotification";
00183 CPWindowDidEndSheetNotification = @"CPWindowDidEndSheetNotification";
00184 CPWindowDidMiniaturizeNotification = @"CPWindowDidMiniaturizeNotification";
00185 CPWindowWillMiniaturizeNotification = @"CPWindowWillMiniaturizeNotification";
00186 CPWindowDidDeminiaturizeNotification = @"CPWindowDidDeminiaturizeNotification";
00187
00188 CPWindowShadowStyleStandard = 0;
00189 CPWindowShadowStyleMenu = 1;
00190 CPWindowShadowStylePanel = 2;
00191
00192 var SHADOW_MARGIN_LEFT = 20.0,
00193 SHADOW_MARGIN_RIGHT = 19.0,
00194 SHADOW_MARGIN_TOP = 10.0,
00195 SHADOW_MARGIN_BOTTOM = 10.0,
00196 SHADOW_DISTANCE = 5.0,
00197
00198 _CPWindowShadowColor = nil;
00199
00200 var CPWindowSaveImage = nil,
00201 CPWindowSavingImage = nil;
00202
00249 @implementation CPWindow : CPResponder
00250 {
00251 CPPlatformWindow _platformWindow;
00252
00253 int _windowNumber;
00254 unsigned _styleMask;
00255 CGRect _frame;
00256 int _level;
00257 BOOL _isVisible;
00258 BOOL _isMiniaturized;
00259 BOOL _isAnimating;
00260 BOOL _hasShadow;
00261 BOOL _isMovableByWindowBackground;
00262 unsigned _shadowStyle;
00263 BOOL _showsResizeIndicator;
00264
00265 BOOL _isDocumentEdited;
00266 BOOL _isDocumentSaving;
00267
00268 CPImageView _shadowView;
00269
00270 CPView _windowView;
00271 CPView _contentView;
00272 CPView _toolbarView;
00273
00274 CPArray _mouseEnteredStack;
00275 CPView _leftMouseDownView;
00276 CPView _rightMouseDownView;
00277
00278 CPToolbar _toolbar;
00279 CPResponder _firstResponder;
00280 CPResponder _initialFirstResponder;
00281 id _delegate;
00282
00283 CPString _title;
00284
00285 BOOL _acceptsMouseMovedEvents;
00286 BOOL _ignoresMouseEvents;
00287
00288 CPWindowController _windowController;
00289
00290 CGSize _minSize;
00291 CGSize _maxSize;
00292
00293 CPUndoManager _undoManager;
00294 CPURL _representedURL;
00295
00296 CPSet _registeredDraggedTypes;
00297 CPArray _registeredDraggedTypesArray;
00298 CPCountedSet _inclusiveRegisteredDraggedTypes;
00299
00300 CPButton _defaultButton;
00301 BOOL _defaultButtonEnabled;
00302
00303 BOOL _autorecalculatesKeyViewLoop;
00304 BOOL _keyViewLoopIsDirty;
00305
00306 BOOL _sharesChromeWithPlatformWindow;
00307
00308
00309 #if PLATFORM(DOM)
00310 DOMElement _DOMElement;
00311 #endif
00312
00313 unsigned _autoresizingMask;
00314
00315 BOOL _delegateRespondsToWindowWillReturnUndoManagerSelector;
00316
00317 BOOL _isFullPlatformWindow;
00318 _CPWindowFullPlatformWindowSession _fullPlatformWindowSession;
00319
00320 CPDictionary _sheetContext;
00321 CPWindow _parentView;
00322 BOOL _isSheet;
00323 }
00324
00325
00326
00327
00328
00329 + (void)initialize
00330 {
00331 if (self != [CPWindow class])
00332 return;
00333
00334 var bundle = [CPBundle bundleForClass:[CPWindow class]];
00335
00336 CPWindowSavingImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPProgressIndicator/CPProgressIndicatorSpinningStyleRegular.gif"] size:CGSizeMake(16.0, 16.0)]
00337 }
00338
00339 - (id)init
00340 {
00341 return [self initWithContentRect:_CGRectMakeZero() styleMask:CPTitledWindowMask];
00342 }
00343
00359 - (id)initWithContentRect:(CGRect)aContentRect styleMask:(unsigned int)aStyleMask
00360 {
00361 self = [super init];
00362
00363 if (self)
00364 {
00365 var windowViewClass = [[self class] _windowViewClassForStyleMask:aStyleMask];
00366
00367 _frame = [windowViewClass frameRectForContentRect:aContentRect];
00368
00369 [self _setSharesChromeWithPlatformWindow:![CPPlatform isBrowser]];
00370
00371 if ([CPPlatform isBrowser])
00372 [self setPlatformWindow:[CPPlatformWindow primaryPlatformWindow]];
00373 else
00374 {
00375 [self setPlatformWindow:[[CPPlatformWindow alloc] initWithContentRect:_frame]];
00376 [self platformWindow]._only = self;
00377 }
00378
00379 _isFullPlatformWindow = NO;
00380 _registeredDraggedTypes = [CPSet set];
00381 _registeredDraggedTypesArray = [];
00382 _isSheet = NO;
00383
00384
00385 _windowNumber = [CPApp._windows count];
00386 CPApp._windows[_windowNumber] = self;
00387
00388 _styleMask = aStyleMask;
00389
00390 [self setLevel:CPNormalWindowLevel];
00391
00392 _minSize = CGSizeMake(0.0, 0.0);
00393 _maxSize = CGSizeMake(1000000.0, 1000000.0);
00394
00395
00396 _windowView = [[windowViewClass alloc] initWithFrame:CGRectMake(0.0, 0.0, CGRectGetWidth(_frame), CGRectGetHeight(_frame)) styleMask:aStyleMask];
00397
00398 [_windowView _setWindow:self];
00399 [_windowView setNextResponder:self];
00400
00401 [self setMovableByWindowBackground:aStyleMask & CPHUDBackgroundWindowMask];
00402
00403
00404 [self setContentView:[[CPView alloc] initWithFrame:CGRectMakeZero()]];
00405
00406 _firstResponder = self;
00407
00408 #if PLATFORM(DOM)
00409 _DOMElement = document.createElement("div");
00410
00411 _DOMElement.style.position = "absolute";
00412 _DOMElement.style.visibility = "visible";
00413 _DOMElement.style.zIndex = 0;
00414
00415 if (![self _sharesChromeWithPlatformWindow])
00416 {
00417 CPDOMDisplayServerSetStyleLeftTop(_DOMElement, NULL, _CGRectGetMinX(_frame), _CGRectGetMinY(_frame));
00418 }
00419
00420 CPDOMDisplayServerSetStyleSize(_DOMElement, 1, 1);
00421 CPDOMDisplayServerAppendChild(_DOMElement, _windowView._DOMElement);
00422 #endif
00423
00424 [self setNextResponder:CPApp];
00425
00426 [self setHasShadow:aStyleMask !== CPBorderlessWindowMask];
00427
00428 if (aStyleMask & CPBorderlessBridgeWindowMask)
00429 [self setFullPlatformWindow:YES];
00430
00431 _defaultButtonEnabled = YES;
00432 _keyViewLoopIsDirty = YES;
00433
00434 [self setShowsResizeIndicator:_styleMask & CPResizableWindowMask];
00435 }
00436
00437 return self;
00438 }
00439
00440 - (CPPlatformWindow)platformWindow
00441 {
00442 return _platformWindow;
00443 }
00444
00445 - (void)setPlatformWindow:(CPPlatformWindow)aPlatformWindow
00446 {
00447
00448 _platformWindow = aPlatformWindow;
00449 }
00450
00454 + (Class)_windowViewClassForStyleMask:(unsigned)aStyleMask
00455 {
00456 if (aStyleMask & CPHUDBackgroundWindowMask)
00457 return _CPHUDWindowView;
00458
00459 else if (aStyleMask === CPBorderlessWindowMask)
00460 return _CPBorderlessWindowView;
00461
00462 else if (aStyleMask & CPDocModalWindowMask)
00463 return _CPDocModalWindowView;
00464
00465 return _CPStandardWindowView;
00466 }
00467
00468 + (Class)_windowViewClassForFullPlatformWindowStyleMask:(unsigned)aStyleMask
00469 {
00470 return _CPBorderlessBridgeWindowView;
00471 }
00472
00473 - (void)awakeFromCib
00474 {
00475 if (_initialFirstResponder)
00476 [self makeFirstResponder:_initialFirstResponder];
00477
00478 _keyViewLoopIsDirty = ![self _hasKeyViewLoop];
00479 }
00480
00481 - (void)_setWindowView:(CPView)aWindowView
00482 {
00483 if (_windowView === aWindowView)
00484 return;
00485
00486 var oldWindowView = _windowView;
00487
00488 _windowView = aWindowView;
00489
00490 if (oldWindowView)
00491 {
00492 [oldWindowView _setWindow:nil];
00493 [oldWindowView noteToolbarChanged];
00494
00495 #if PLATFORM(DOM)
00496 CPDOMDisplayServerRemoveChild(_DOMElement, oldWindowView._DOMElement);
00497 #endif
00498 }
00499
00500 if (_windowView)
00501 {
00502 #if PLATFORM(DOM)
00503 CPDOMDisplayServerAppendChild(_DOMElement, _windowView._DOMElement);
00504 #endif
00505
00506 var contentRect = [_contentView convertRect:[_contentView bounds] toView:nil];
00507
00508 contentRect.origin = [self convertBaseToGlobal:contentRect.origin];
00509
00510 [_windowView _setWindow:self];
00511 [_windowView setNextResponder:self];
00512 [_windowView addSubview:_contentView];
00513 [_windowView setTitle:_title];
00514 [_windowView noteToolbarChanged];
00515 [_windowView setShowsResizeIndicator:[self showsResizeIndicator]];
00516
00517 [self setFrame:[self frameRectForContentRect:contentRect]];
00518 }
00519 }
00520
00521 - (void)setFullPlatformWindow:(BOOL)shouldBeFullPlatformWindow
00522 {
00523 if (![_platformWindow supportsFullPlatformWindows])
00524 return;
00525
00526 shouldBeFullPlatformWindow = !!shouldBeFullPlatformWindow;
00527
00528 if (_isFullPlatformWindow === shouldBeFullPlatformWindow)
00529 return;
00530
00531 _isFullPlatformWindow = shouldBeFullPlatformWindow;
00532
00533 if (_isFullPlatformWindow)
00534 {
00535 _fullPlatformWindowSession = _CPWindowFullPlatformWindowSessionMake(_windowView, [self contentRectForFrameRect:[self frame]], [self hasShadow], [self level]);
00536
00537 var fullPlatformWindowViewClass = [[self class] _windowViewClassForFullPlatformWindowStyleMask:_styleMask],
00538 windowView = [[fullPlatformWindowViewClass alloc] initWithFrame:CGRectMakeZero() styleMask:_styleMask];
00539
00540 [self _setWindowView:windowView];
00541
00542 [self setLevel:CPBackgroundWindowLevel];
00543 [self setHasShadow:NO];
00544 [self setAutoresizingMask:CPWindowWidthSizable | CPWindowHeightSizable];
00545 [self setFrame:[_platformWindow visibleFrame]];
00546 }
00547 else
00548 {
00549 var windowView = _fullPlatformWindowSession.windowView;
00550
00551 [self _setWindowView:windowView];
00552
00553 [self setLevel:_fullPlatformWindowSession.level];
00554 [self setHasShadow:_fullPlatformWindowSession.hasShadow];
00555 [self setAutoresizingMask:CPWindowNotSizable];
00556
00557 [self setFrame:[windowView frameRectForContentRect:_fullPlatformWindowSession.contentRect]];
00558 }
00559 }
00560
00561 - (BOOL)isFullPlatformWindow
00562 {
00563 return _isFullPlatformWindow;
00564 }
00565
00569 - (unsigned)styleMask
00570 {
00571 return _styleMask;
00572 }
00573
00580 + (CGRect)frameRectForContentRect:(CGRect)aContentRect styleMask:(unsigned)aStyleMask
00581 {
00582 return [[[self class] _windowViewClassForStyleMask:aStyleMask] frameRectForContentRect:aContentRect];
00583 }
00584
00589 - (CGRect)contentRectForFrameRect:(CGRect)aFrame
00590 {
00591 return [_windowView contentRectForFrameRect:aFrame];
00592 }
00593
00599 - (CGRect)frameRectForContentRect:(CGRect)aContentRect
00600 {
00601 return [_windowView frameRectForContentRect:aContentRect];
00602 }
00603
00607 - (CGRect)frame
00608 {
00609 return _CGRectMakeCopy(_frame);
00610 }
00611
00619 - (void)_setClippedFrame:(CGRect)aFrame display:(BOOL)shouldDisplay animate:(BOOL)shouldAnimate
00620 {
00621 aFrame.size.width = MIN(MAX(aFrame.size.width, _minSize.width), _maxSize.width)
00622 aFrame.size.height = MIN(MAX(aFrame.size.height, _minSize.height), _maxSize.height);
00623 [self setFrame:aFrame display:shouldDisplay animate:shouldAnimate];
00624 }
00625
00626 - (void)setFrame:(CGRect)aFrame display:(BOOL)shouldDisplay animate:(BOOL)shouldAnimate
00627 {
00628 aFrame = _CGRectMakeCopy(aFrame);
00629
00630 var value = aFrame.origin.x,
00631 delta = value - FLOOR(value);
00632
00633 if (delta)
00634 aFrame.origin.x = value > 0.879 ? CEIL(value) : FLOOR(value);
00635
00636 value = aFrame.origin.y;
00637 delta = value - FLOOR(value);
00638
00639 if (delta)
00640 aFrame.origin.y = value > 0.879 ? CEIL(value) : FLOOR(value);
00641
00642 value = aFrame.size.width;
00643 delta = value - FLOOR(value);
00644
00645 if (delta)
00646 aFrame.size.width = value > 0.15 ? CEIL(value) : FLOOR(value);
00647
00648 value = aFrame.size.height;
00649 delta = value - FLOOR(value);
00650
00651 if (delta)
00652 aFrame.size.height = value > 0.15 ? CEIL(value) : FLOOR(value);
00653
00654 if (shouldAnimate)
00655 {
00656 var animation = [[_CPWindowFrameAnimation alloc] initWithWindow:self targetFrame:aFrame];
00657
00658 [animation startAnimation];
00659 }
00660 else
00661 {
00662 var origin = _frame.origin,
00663 newOrigin = aFrame.origin;
00664
00665 if (!_CGPointEqualToPoint(origin, newOrigin))
00666 {
00667 origin.x = newOrigin.x;
00668 origin.y = newOrigin.y;
00669
00670 #if PLATFORM(DOM)
00671 if (![self _sharesChromeWithPlatformWindow])
00672 {
00673 CPDOMDisplayServerSetStyleLeftTop(_DOMElement, NULL, origin.x, origin.y);
00674 }
00675 #endif
00676
00677 [[CPNotificationCenter defaultCenter] postNotificationName:CPWindowDidMoveNotification object:self];
00678 }
00679
00680 var size = _frame.size,
00681 newSize = aFrame.size;
00682
00683 if (!_CGSizeEqualToSize(size, newSize))
00684 {
00685 size.width = newSize.width;
00686 size.height = newSize.height;
00687
00688 [_windowView setFrameSize:size];
00689
00690 if (_hasShadow)
00691 [_shadowView setFrameSize:_CGSizeMake(SHADOW_MARGIN_LEFT + size.width + SHADOW_MARGIN_RIGHT, SHADOW_MARGIN_BOTTOM + size.height + SHADOW_MARGIN_TOP + SHADOW_DISTANCE)];
00692
00693 if (!_isAnimating)
00694 [[CPNotificationCenter defaultCenter] postNotificationName:CPWindowDidResizeNotification object:self];
00695 }
00696
00697 if ([self _sharesChromeWithPlatformWindow])
00698 [_platformWindow setContentRect:_frame];
00699 }
00700 }
00701
00702 - (void)setFrame:(CGRect)aFrame display:(BOOL)shouldDisplay
00703 {
00704 [self _setClippedFrame:aFrame display:shouldDisplay animate:NO];
00705 }
00706
00710 - (void)setFrame:(CGRect)aFrame
00711 {
00712 [self _setClippedFrame:aFrame display:YES animate:NO];
00713 }
00714
00719 - (void)setFrameOrigin:(CGPoint)anOrigin
00720 {
00721 [self _setClippedFrame:_CGRectMake(anOrigin.x, anOrigin.y, _CGRectGetWidth(_frame), _CGRectGetHeight(_frame)) display:YES animate:NO];
00722 }
00723
00728 - (void)setFrameSize:(CGSize)aSize
00729 {
00730 [self _setClippedFrame:_CGRectMake(_CGRectGetMinX(_frame), _CGRectGetMinY(_frame), aSize.width, aSize.height) display:YES animate:NO];
00731 }
00732
00737 - (void)orderFront:(id)aSender
00738 {
00739 [_platformWindow orderFront:self];
00740 [_platformWindow order:CPWindowAbove window:self relativeTo:nil];
00741 }
00742
00743
00744
00745
00746
00747
00748 - (void)orderBack:(id)aSender
00749 {
00750
00751 }
00752
00757 - (void)orderOut:(id)aSender
00758 {
00759 if ([self _sharesChromeWithPlatformWindow])
00760 [_platformWindow orderOut:self];
00761
00762 if ([_delegate respondsToSelector:@selector(windowWillClose:)])
00763 [_delegate windowWillClose:self];
00764
00765 [_platformWindow order:CPWindowOut window:self relativeTo:nil];
00766
00767 [self _updateMainAndKeyWindows];
00768 }
00769
00775 - (void)orderWindow:(CPWindowOrderingMode)aPlace relativeTo:(int)otherWindowNumber
00776 {
00777 [_platformWindow order:aPlace window:self relativeTo:CPApp._windows[otherWindowNumber]];
00778 }
00779
00784 - (void)setLevel:(int)aLevel
00785 {
00786 if (aLevel === _level)
00787 return;
00788
00789 [_platformWindow moveWindow:self fromLevel:_level toLevel:aLevel];
00790
00791 _level = aLevel;
00792
00793 if ([self _sharesChromeWithPlatformWindow])
00794 [_platformWindow setLevel:aLevel];
00795 }
00796
00800 - (int)level
00801 {
00802 return _level;
00803 }
00804
00808 - (BOOL)isVisible
00809 {
00810 return _isVisible;
00811 }
00812
00816 - (BOOL)showsResizeIndicator
00817 {
00818 return _showsResizeIndicator;
00819 }
00820
00825 - (void)setShowsResizeIndicator:(BOOL)shouldShowResizeIndicator
00826 {
00827 shouldShowResizeIndicator = !!shouldShowResizeIndicator;
00828
00829 if (_showsResizeIndicator === shouldShowResizeIndicator)
00830 return;
00831
00832 _showsResizeIndicator = shouldShowResizeIndicator;
00833 [_windowView setShowsResizeIndicator:[self showsResizeIndicator]];
00834 }
00835
00839 - (CGSize)resizeIndicatorOffset
00840 {
00841 return [_windowView resizeIndicatorOffset];
00842 }
00843
00848 - (void)setResizeIndicatorOffset:(CGSize)anOffset
00849 {
00850 [_windowView setResizeIndicatorOffset:anOffset];
00851 }
00852
00858 - (void)setContentView:(CPView)aView
00859 {
00860 if (_contentView)
00861 [_contentView removeFromSuperview];
00862
00863 var bounds = CGRectMake(0.0, 0.0, CGRectGetWidth(_frame), CGRectGetHeight(_frame));
00864
00865 _contentView = aView;
00866 [_contentView setFrame:[self contentRectForFrameRect:bounds]];
00867
00868 [_contentView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
00869 [_windowView addSubview:_contentView];
00870 }
00871
00875 - (CPView)contentView
00876 {
00877 return _contentView;
00878 }
00879
00884 - (void)setBackgroundColor:(CPColor)aColor
00885 {
00886 [_windowView setBackgroundColor:aColor];
00887 }
00888
00892 - (CPColor)backgroundColor
00893 {
00894 return [_windowView backgroundColor];
00895 }
00896
00902 - (void)setMinSize:(CGSize)aSize
00903 {
00904 if (CGSizeEqualToSize(_minSize, aSize))
00905 return;
00906
00907 _minSize = CGSizeCreateCopy(aSize);
00908
00909 var size = CGSizeMakeCopy([self frame].size),
00910 needsFrameChange = NO;
00911
00912 if (size.width < _minSize.width)
00913 {
00914 size.width = _minSize.width;
00915 needsFrameChange = YES;
00916 }
00917
00918 if (size.height < _minSize.height)
00919 {
00920 size.height = _minSize.height;
00921 needsFrameChange = YES;
00922 }
00923
00924 if (needsFrameChange)
00925 [self setFrameSize:size];
00926 }
00927
00931 - (CGSize)minSize
00932 {
00933 return _minSize;
00934 }
00935
00942 - (void)setMaxSize:(CGSize)aSize
00943 {
00944 if (CGSizeEqualToSize(_maxSize, aSize))
00945 return;
00946
00947 _maxSize = CGSizeCreateCopy(aSize);
00948
00949 var size = CGSizeMakeCopy([self frame].size),
00950 needsFrameChange = NO;
00951
00952 if (size.width > _maxSize.width)
00953 {
00954 size.width = _maxSize.width;
00955 needsFrameChange = YES;
00956 }
00957
00958 if (size.height > _maxSize.height)
00959 {
00960 size.height = _maxSize.height;
00961 needsFrameChange = YES;
00962 }
00963
00964 if (needsFrameChange)
00965 [self setFrameSize:size];
00966 }
00967
00971 - (CGSize)maxSize
00972 {
00973 return _maxSize;
00974 }
00975
00979 - (BOOL)hasShadow
00980 {
00981 return _hasShadow;
00982 }
00983
00984 - (void)_updateShadow
00985 {
00986 if ([self _sharesChromeWithPlatformWindow])
00987 {
00988 if (_shadowView)
00989 {
00990 #if PLATFORM(DOM)
00991 CPDOMDisplayServerRemoveChild(_DOMElement, _shadowView._DOMElement);
00992 #endif
00993 _shadowView = nil;
00994 }
00995
00996 [_platformWindow setHasShadow:_hasShadow];
00997
00998 return;
00999 }
01000
01001 if (_hasShadow && !_shadowView)
01002 {
01003 var bounds = [_windowView bounds];
01004
01005 _shadowView = [[CPView alloc] initWithFrame:CGRectMake(-SHADOW_MARGIN_LEFT, -SHADOW_MARGIN_TOP + SHADOW_DISTANCE,
01006 SHADOW_MARGIN_LEFT + CGRectGetWidth(bounds) + SHADOW_MARGIN_RIGHT, SHADOW_MARGIN_TOP + CGRectGetHeight(bounds) + SHADOW_MARGIN_BOTTOM)];
01007
01008 if (!_CPWindowShadowColor)
01009 {
01010 var bundle = [CPBundle bundleForClass:[CPWindow class]];
01011
01012 _CPWindowShadowColor = [CPColor colorWithPatternImage:[[CPNinePartImage alloc] initWithImageSlices:
01013 [
01014 [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/CPWindowShadow0.png"] size:CGSizeMake(20.0, 19.0)],
01015 [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/CPWindowShadow1.png"] size:CGSizeMake(1.0, 19.0)],
01016 [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/CPWindowShadow2.png"] size:CGSizeMake(19.0, 19.0)],
01017
01018 [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/CPWindowShadow3.png"] size:CGSizeMake(20.0, 1.0)],
01019 [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/CPWindowShadow4.png"] size:CGSizeMake(1.0, 1.0)],
01020 [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/CPWindowShadow5.png"] size:CGSizeMake(19.0, 1.0)],
01021
01022 [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/CPWindowShadow6.png"] size:CGSizeMake(20.0, 18.0)],
01023 [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/CPWindowShadow7.png"] size:CGSizeMake(1.0, 18.0)],
01024 [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/CPWindowShadow8.png"] size:CGSizeMake(19.0, 18.0)]
01025 ]]];
01026 }
01027
01028 [_shadowView setBackgroundColor:_CPWindowShadowColor];
01029 [_shadowView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
01030
01031 #if PLATFORM(DOM)
01032 CPDOMDisplayServerInsertBefore(_DOMElement, _shadowView._DOMElement, _windowView._DOMElement);
01033 #endif
01034 }
01035 else if (!_hasShadow && _shadowView)
01036 {
01037 #if PLATFORM(DOM)
01038 CPDOMDisplayServerRemoveChild(_DOMElement, _shadowView._DOMElement);
01039 #endif
01040 _shadowView = nil;
01041 }
01042 }
01043
01048 - (void)setHasShadow:(BOOL)shouldHaveShadow
01049 {
01050 if (_hasShadow === shouldHaveShadow)
01051 return;
01052
01053 _hasShadow = shouldHaveShadow;
01054
01055 [self _updateShadow];
01056 }
01057
01058 - (void)setShadowStyle:(unsigned)aStyle
01059 {
01060 _shadowStyle = aStyle;
01061
01062 [[self platformWindow] setShadowStyle:_shadowStyle];
01063 }
01064
01069 - (void)setDelegate:(id)aDelegate
01070 {
01071 var defaultCenter = [CPNotificationCenter defaultCenter];
01072
01073 [defaultCenter removeObserver:_delegate name:CPWindowDidResignKeyNotification object:self];
01074 [defaultCenter removeObserver:_delegate name:CPWindowDidBecomeKeyNotification object:self];
01075 [defaultCenter removeObserver:_delegate name:CPWindowDidBecomeMainNotification object:self];
01076 [defaultCenter removeObserver:_delegate name:CPWindowDidResignMainNotification object:self];
01077 [defaultCenter removeObserver:_delegate name:CPWindowDidMoveNotification object:self];
01078 [defaultCenter removeObserver:_delegate name:CPWindowDidResizeNotification object:self];
01079
01080 _delegate = aDelegate;
01081 _delegateRespondsToWindowWillReturnUndoManagerSelector = [_delegate respondsToSelector:@selector(windowWillReturnUndoManager:)];
01082
01083 if ([_delegate respondsToSelector:@selector(windowDidResignKey:)])
01084 [defaultCenter
01085 addObserver:_delegate
01086 selector:@selector(windowDidResignKey:)
01087 name:CPWindowDidResignKeyNotification
01088 object:self];
01089
01090 if ([_delegate respondsToSelector:@selector(windowDidBecomeKey:)])
01091 [defaultCenter
01092 addObserver:_delegate
01093 selector:@selector(windowDidBecomeKey:)
01094 name:CPWindowDidBecomeKeyNotification
01095 object:self];
01096
01097 if ([_delegate respondsToSelector:@selector(windowDidBecomeMain:)])
01098 [defaultCenter
01099 addObserver:_delegate
01100 selector:@selector(windowDidBecomeMain:)
01101 name:CPWindowDidBecomeMainNotification
01102 object:self];
01103
01104 if ([_delegate respondsToSelector:@selector(windowDidResignMain:)])
01105 [defaultCenter
01106 addObserver:_delegate
01107 selector:@selector(windowDidResignMain:)
01108 name:CPWindowDidResignMainNotification
01109 object:self];
01110
01111 if ([_delegate respondsToSelector:@selector(windowDidMove:)])
01112 [defaultCenter
01113 addObserver:_delegate
01114 selector:@selector(windowDidMove:)
01115 name:CPWindowDidMoveNotification
01116 object:self];
01117
01118 if ([_delegate respondsToSelector:@selector(windowDidResize:)])
01119 [defaultCenter
01120 addObserver:_delegate
01121 selector:@selector(windowDidResize:)
01122 name:CPWindowDidResizeNotification
01123 object:self];
01124 }
01125
01129 - (id)delegate
01130 {
01131 return _delegate;
01132 }
01133
01138 - (void)setWindowController:(CPWindowController)aWindowController
01139 {
01140 _windowController = aWindowController;
01141 }
01142
01146 - (CPWindowController)windowController
01147 {
01148 return _windowController;
01149 }
01150
01151 - (void)doCommandBySelector:(SEL)aSelector
01152 {
01153 if ([_delegate respondsToSelector:aSelector])
01154 [_delegate performSelector:aSelector];
01155 else
01156 [super doCommandBySelector:aSelector];
01157 }
01158
01159 - (BOOL)acceptsFirstResponder
01160 {
01161 return YES;
01162 }
01163
01171 - (BOOL)makeFirstResponder:(CPResponder)aResponder
01172 {
01173 if (_firstResponder == aResponder)
01174 return YES;
01175
01176 if(![_firstResponder resignFirstResponder])
01177 return NO;
01178
01179 if(!aResponder || ![aResponder acceptsFirstResponder] || ![aResponder becomeFirstResponder])
01180 {
01181 _firstResponder = self;
01182
01183 return NO;
01184 }
01185
01186 _firstResponder = aResponder;
01187
01188 return YES;
01189 }
01190
01194 - (CPResponder)firstResponder
01195 {
01196 return _firstResponder;
01197 }
01198
01199 - (BOOL)acceptsMouseMovedEvents
01200 {
01201 return _acceptsMouseMovedEvents;
01202 }
01203
01204 - (void)setAcceptsMouseMovedEvents:(BOOL)shouldAcceptMouseMovedEvents
01205 {
01206 _acceptsMouseMovedEvents = shouldAcceptMouseMovedEvents;
01207 }
01208
01209 - (BOOL)ignoresMouseEvents
01210 {
01211 return _ignoresMouseEvents;
01212 }
01213
01214 - (void)setIgnoresMouseEvents:(BOOL)shouldIgnoreMouseEvents
01215 {
01216 _ignoresMouseEvents = shouldIgnoreMouseEvents;
01217 }
01218
01219
01220
01224 - (CPString)title
01225 {
01226 return _title;
01227 }
01228
01232 - (void)setTitle:(CPString)aTitle
01233 {
01234 _title = aTitle;
01235
01236 [_windowView setTitle:aTitle];
01237
01238 [self _synchronizeMenuBarTitleWithWindowTitle];
01239 }
01240
01244 - (void)setTitleWithRepresentedFilename:(CPString)aFilePath
01245 {
01246 [self setRepresentedFilename:aFilePath];
01247 [self setTitle:[aFilePath lastPathComponent]];
01248 }
01249
01253 - (void)setRepresentedFilename:(CPString)aFilePath
01254 {
01255
01256 [self setRepresentedURL:aFilePath];
01257 }
01258
01262 - (CPString)representedFilename
01263 {
01264 return _representedURL;
01265 }
01266
01270 - (void)setRepresentedURL:(CPURL)aURL
01271 {
01272 _representedURL = aURL;
01273 }
01274
01278 - (CPURL)representedURL
01279 {
01280 return _representedURL;
01281 }
01282
01283 - (CPScreen)screen
01284 {
01285 return [[CPScreen alloc] init];
01286 }
01287
01288
01289
01294 - (void)setMovableByWindowBackground:(BOOL)shouldBeMovableByWindowBackground
01295 {
01296 _isMovableByWindowBackground = shouldBeMovableByWindowBackground;
01297 }
01298
01302 - (BOOL)isMovableByWindowBackground
01303 {
01304 return _isMovableByWindowBackground;
01305 }
01306
01310 - (void)center
01311 {
01312 var size = [self frame].size,
01313 containerSize = [CPPlatform isBrowser] ? [_platformWindow contentBounds].size : [[self screen] visibleFrame].size;
01314
01315 [self setFrameOrigin:CGPointMake((containerSize.width - size.width) / 2.0, (containerSize.height - size.height) / 2.0)];
01316 }
01317
01322 - (void)sendEvent:(CPEvent)anEvent
01323 {
01324 var type = [anEvent type],
01325 point = [anEvent locationInWindow];
01326
01327 switch (type)
01328 {
01329 case CPKeyUp: return [[self firstResponder] keyUp:anEvent];
01330 case CPKeyDown: return [[self firstResponder] keyDown:anEvent];
01331
01332 case CPScrollWheel: return [[_windowView hitTest:point] scrollWheel:anEvent];
01333
01334 case CPLeftMouseUp: if (!_leftMouseDownView)
01335 return [[_windowView hitTest:point] mouseUp:anEvent];
01336
01337 [_leftMouseDownView mouseUp:anEvent]
01338
01339 _leftMouseDownView = nil;
01340
01341 return;
01342 case CPLeftMouseDown: _leftMouseDownView = [_windowView hitTest:point];
01343
01344 if (_leftMouseDownView != _firstResponder && [_leftMouseDownView acceptsFirstResponder])
01345 [self makeFirstResponder:_leftMouseDownView];
01346
01347 [CPApp activateIgnoringOtherApps:YES];
01348
01349 var theWindow = [anEvent window];
01350
01351 if ([theWindow isKeyWindow] || [theWindow becomesKeyOnlyIfNeeded] && ![_leftMouseDownView needsPanelToBecomeKey])
01352 return [_leftMouseDownView mouseDown:anEvent];
01353 else
01354 {
01355
01356 [self makeKeyAndOrderFront:self];
01357
01358 if ([_leftMouseDownView acceptsFirstMouse:anEvent])
01359 return [_leftMouseDownView mouseDown:anEvent]
01360 }
01361 break;
01362 case CPLeftMouseDragged: if (!_leftMouseDownView)
01363 return [[_windowView hitTest:point] mouseDragged:anEvent];
01364
01365 return [_leftMouseDownView mouseDragged:anEvent];
01366
01367 case CPRightMouseUp: return [_rightMouseDownView mouseUp:anEvent];
01368 case CPRightMouseDown: _rightMouseDownView = [_windowView hitTest:point];
01369 return [_rightMouseDownView mouseDown:anEvent];
01370 case CPRightMouseDragged: return [_rightMouseDownView mouseDragged:anEvent];
01371
01372 case CPMouseMoved: if (!_acceptsMouseMovedEvents)
01373 return;
01374
01375 if (!_mouseEnteredStack)
01376 _mouseEnteredStack = [];
01377
01378 var hitTestView = [_windowView hitTest:point];
01379
01380 if ([_mouseEnteredStack count] && [_mouseEnteredStack lastObject] === hitTestView)
01381 return [hitTestView mouseMoved:anEvent];
01382
01383 var view = hitTestView,
01384 mouseEnteredStack = [];
01385
01386 while (view)
01387 {
01388 mouseEnteredStack.unshift(view);
01389
01390 view = [view superview];
01391 }
01392
01393 var deviation = MIN(_mouseEnteredStack.length, mouseEnteredStack.length);
01394
01395 while (deviation--)
01396 if (_mouseEnteredStack[deviation] === mouseEnteredStack[deviation])
01397 break;
01398
01399 var index = deviation + 1,
01400 count = _mouseEnteredStack.length;
01401
01402 if (index < count)
01403 {
01404 var event = [CPEvent mouseEventWithType:CPMouseExited location:point modifierFlags:[anEvent modifierFlags] timestamp:[anEvent timestamp] windowNumber:_windowNumber context:nil eventNumber:-1 clickCount:1 pressure:0];
01405
01406 for (; index < count; ++index)
01407 [_mouseEnteredStack[index] mouseExited:event];
01408 }
01409
01410 index = deviation + 1;
01411 count = mouseEnteredStack.length;
01412
01413 if (index < count)
01414 {
01415 var event = [CPEvent mouseEventWithType:CPMouseEntered location:point modifierFlags:[anEvent modifierFlags] timestamp:[anEvent timestamp] windowNumber:_windowNumber context:nil eventNumber:-1 clickCount:1 pressure:0];
01416
01417 for (; index < count; ++index)
01418 [mouseEnteredStack[index] mouseEntered:event];
01419 }
01420
01421 _mouseEnteredStack = mouseEnteredStack;
01422
01423 [hitTestView mouseMoved:anEvent];
01424 }
01425 }
01426
01430 - (int)windowNumber
01431 {
01432 return _windowNumber;
01433 }
01434
01439 - (void)becomeKeyWindow
01440 {
01441 CPApp._keyWindow = self;
01442
01443 if (_firstResponder !== self && [_firstResponder respondsToSelector:@selector(becomeKeyWindow)])
01444 [_firstResponder becomeKeyWindow];
01445
01446 [[CPNotificationCenter defaultCenter]
01447 postNotificationName:CPWindowDidBecomeKeyNotification
01448 object:self];
01449 }
01450
01455 - (BOOL)canBecomeKeyWindow
01456 {
01457 return YES;
01458 }
01459
01463 - (BOOL)isKeyWindow
01464 {
01465 return [CPApp keyWindow] == self;
01466 }
01467
01472 - (void)makeKeyAndOrderFront:(id)aSender
01473 {
01474 [self orderFront:self];
01475
01476 [self makeKeyWindow];
01477 [self makeMainWindow];
01478 }
01479
01483 - (void)makeKeyWindow
01484 {
01485 if ([CPApp keyWindow] === self || ![self canBecomeKeyWindow])
01486 return;
01487
01488 [[CPApp keyWindow] resignKeyWindow];
01489 [self becomeKeyWindow];
01490 }
01491
01495 - (void)resignKeyWindow
01496 {
01497 if (_firstResponder != self && [_firstResponder respondsToSelector:@selector(resignKeyWindow)])
01498 [_firstResponder resignKeyWindow];
01499
01500 if (CPApp._keyWindow === self)
01501 CPApp._keyWindow = nil;
01502
01503 [[CPNotificationCenter defaultCenter]
01504 postNotificationName:CPWindowDidResignKeyNotification
01505 object:self];
01506 }
01507
01518 - (void)dragImage:(CPImage)anImage at:(CGPoint)imageLocation offset:(CGSize)mouseOffset event:(CPEvent)anEvent pasteboard:(CPPasteboard)aPasteboard source:(id)aSourceObject slideBack:(BOOL)slideBack
01519 {
01520 [[CPDragServer sharedDragServer] dragImage:anImage fromWindow:self at:[self convertBaseToGlobal:imageLocation] offset:mouseOffset event:anEvent pasteboard:aPasteboard source:aSourceObject slideBack:slideBack];
01521 }
01522
01523 - (void)_noteRegisteredDraggedTypes:(CPSet)pasteboardTypes
01524 {
01525 if (!pasteboardTypes)
01526 return;
01527
01528 if (!_inclusiveRegisteredDraggedTypes)
01529 _inclusiveRegisteredDraggedTypes = [CPCountedSet set];
01530
01531 [_inclusiveRegisteredDraggedTypes unionSet:pasteboardTypes];
01532 }
01533
01534 - (void)_noteUnregisteredDraggedTypes:(CPSet)pasteboardTypes
01535 {
01536 if (!pasteboardTypes)
01537 return;
01538
01539 [_inclusiveRegisteredDraggedTypes minusSet:pasteboardTypes]
01540
01541 if ([_inclusiveRegisteredDraggedTypes count] === 0)
01542 _inclusiveRegisteredDraggedTypes = nil;
01543 }
01544
01555 - (void)dragView:(CPView)aView at:(CGPoint)viewLocation offset:(CGSize)mouseOffset event:(CPEvent)anEvent pasteboard:(CPPasteboard)aPasteboard source:(id)aSourceObject slideBack:(BOOL)slideBack
01556 {
01557 [[CPDragServer sharedDragServer] dragView:aView fromWindow:self at:[self convertBaseToGlobal:viewLocation] offset:mouseOffset event:anEvent pasteboard:aPasteboard source:aSourceObject slideBack:slideBack];
01558 }
01559
01564 - (void)registerForDraggedTypes:(CPArray)pasteboardTypes
01565 {
01566 if (!pasteboardTypes)
01567 return;
01568
01569 [self _noteUnregisteredDraggedTypes:_registeredDraggedTypes];
01570 [_registeredDraggedTypes addObjectsFromArray:pasteboardTypes]
01571 [self _noteRegisteredDraggedTypes:_registeredDraggedTypes];
01572
01573 _registeredDraggedTypesArray = nil;
01574 }
01575
01580 - (CPArray)registeredDraggedTypes
01581 {
01582 if (!_registeredDraggedTypesArray)
01583 _registeredDraggedTypesArray = [_registeredDraggedTypes allObjects]
01584
01585 return _registeredDraggedTypesArray;
01586 }
01587
01591 - (void)unregisterDraggedTypes
01592 {
01593 [self _noteUnregisteredDraggedTypes:_registeredDraggedTypes];
01594
01595 _registeredDraggedTypes = [CPSet set];
01596 _registeredDraggedTypesArray = [];
01597 }
01598
01599
01600
01605 - (void)setDocumentEdited:(BOOL)isDocumentEdited
01606 {
01607 if (_isDocumentEdited == isDocumentEdited)
01608 return;
01609
01610 _isDocumentEdited = isDocumentEdited;
01611
01612 [CPMenu _setMenuBarIconImageAlphaValue:_isDocumentEdited ? 0.5 : 1.0];
01613
01614 [_windowView setDocumentEdited:isDocumentEdited];
01615 }
01616
01620 - (BOOL)isDocumentEdited
01621 {
01622 return _isDocumentEdited;
01623 }
01624
01625 - (void)setDocumentSaving:(BOOL)isDocumentSaving
01626 {
01627 if (_isDocumentSaving == isDocumentSaving)
01628 return;
01629
01630 _isDocumentSaving = isDocumentSaving;
01631
01632 [self _synchronizeSaveMenuWithDocumentSaving];
01633
01634 [_windowView windowDidChangeDocumentSaving];
01635 }
01636
01637 - (BOOL)isDocumentSaving
01638 {
01639 return _isDocumentSaving;
01640 }
01641
01642
01643 - (void)_synchronizeSaveMenuWithDocumentSaving
01644 {
01645 if (![self isMainWindow])
01646 return;
01647
01648 var mainMenu = [CPApp mainMenu],
01649 index = [mainMenu indexOfItemWithTitle:_isDocumentSaving ? @"Save" : @"Saving..."];
01650
01651 if (index == CPNotFound)
01652 return;
01653
01654 var item = [mainMenu itemAtIndex:index];
01655
01656 if (_isDocumentSaving)
01657 {
01658 CPWindowSaveImage = [item image];
01659
01660 [item setTitle:@"Saving..."];
01661 [item setImage:CPWindowSavingImage];
01662 [item setEnabled:NO];
01663 }
01664 else
01665 {
01666 [item setTitle:@"Save"];
01667 [item setImage:CPWindowSaveImage];
01668 [item setEnabled:YES];
01669 }
01670 }
01671
01672
01673
01678 - (void)performMiniaturize:(id)aSender
01679 {
01680
01681 [self miniaturize:aSender];
01682 }
01683
01688 - (void)miniaturize:(id)sender
01689 {
01690 [[CPNotificationCenter defaultCenter] postNotificationName:CPWindowWillMiniaturizeNotification object:self];
01691
01692 [[self platformWindow] miniaturize:sender];
01693
01694 [self _updateMainAndKeyWindows];
01695
01696 [[CPNotificationCenter defaultCenter] postNotificationName:CPWindowDidMiniaturizeNotification object:self];
01697
01698 _isMiniaturized = YES;
01699 }
01700
01704 - (void)deminiaturize:(id)sender
01705 {
01706 [[self platformWindow] deminiaturize:sender];
01707
01708 [[CPNotificationCenter defaultCenter] postNotificationName:CPWindowDidDeminiaturizeNotification object:self];
01709
01710 _isMiniaturized = NO;
01711 }
01712
01716 - (void)isMiniaturized
01717 {
01718 return _isMiniaturized;
01719 }
01720
01721
01722
01727 - (void)performClose:(id)aSender
01728 {
01729 if (!(_styleMask & CPClosableWindowMask))
01730 return;
01731
01732 if ([self isFullBridge])
01733 {
01734 var event = [CPApp currentEvent];
01735
01736 if ([event type] === CPKeyDown && [event characters] === "w" && ([event modifierFlags] & CPPlatformActionKeyMask))
01737 {
01738 [[self platformWindow] _propagateCurrentDOMEvent:YES];
01739 return;
01740 }
01741 }
01742
01743
01744 if ([_delegate respondsToSelector:@selector(windowShouldClose:)])
01745 {
01746 if (![_delegate windowShouldClose:self])
01747 return;
01748 }
01749
01750
01751 else if ([self respondsToSelector:@selector(windowShouldClose:)] && ![self windowShouldClose:self])
01752 return;
01753
01754 var documents = [_windowController documents];
01755 if ([documents count])
01756 {
01757 var index = [documents indexOfObject:[_windowController document]];
01758
01759 [documents[index] shouldCloseWindowController:_windowController
01760 delegate:self
01761 shouldCloseSelector:@selector(_windowControllerContainingDocument:shouldClose:contextInfo:)
01762 contextInfo:{documents:[documents copy], visited:0, index:index}];
01763 }
01764 else
01765 [self close];
01766 }
01767
01768 - (void)_windowControllerContainingDocument:(CPDocument)document shouldClose:(BOOL)shouldClose contextInfo:(Object)context
01769 {
01770 if (shouldClose)
01771 {
01772 var windowController = [self windowController],
01773 documents = context.documents,
01774 count = [documents count],
01775 visited = ++context.visited,
01776 index = ++context.index % count;
01777
01778 [document removeWindowController:windowController];
01779
01780 if (visited < count)
01781 {
01782 [windowController setDocument:documents[index]];
01783
01784 [documents[index] shouldCloseWindowController:_windowController
01785 delegate:self
01786 shouldCloseSelector:@selector(_windowControllerContainingDocument:shouldClose:contextInfo:)
01787 contextInfo:context];
01788 }
01789 else
01790 [self close];
01791 }
01792 }
01793
01798 - (void)close
01799 {
01800 [[CPNotificationCenter defaultCenter] postNotificationName:CPWindowWillCloseNotification object:self];
01801
01802 [self orderOut:nil];
01803 }
01804
01805
01809 - (BOOL)isMainWindow
01810 {
01811 return [CPApp mainWindow] == self;
01812 }
01813
01817 - (BOOL)canBecomeMainWindow
01818 {
01819
01820 if ([self isVisible])
01821 return YES;
01822
01823 return NO;
01824 }
01825
01829 - (void)makeMainWindow
01830 {
01831 if ([CPApp mainWindow] === self || ![self canBecomeMainWindow])
01832 return;
01833
01834 [[CPApp mainWindow] resignMainWindow];
01835 [self becomeMainWindow];
01836 }
01837
01841 - (void)becomeMainWindow
01842 {
01843 CPApp._mainWindow = self;
01844
01845 [self _synchronizeMenuBarTitleWithWindowTitle];
01846 [self _synchronizeSaveMenuWithDocumentSaving];
01847
01848 [[CPNotificationCenter defaultCenter]
01849 postNotificationName:CPWindowDidBecomeMainNotification
01850 object:self];
01851 }
01852
01856 - (void)resignMainWindow
01857 {
01858 [[CPNotificationCenter defaultCenter]
01859 postNotificationName:CPWindowDidResignMainNotification
01860 object:self];
01861
01862 if (CPApp._mainWindow === self)
01863 CPApp._mainWindow = nil;
01864 }
01865
01866 - (void)_updateMainAndKeyWindows
01867 {
01868 var allWindows = [CPApp orderedWindows],
01869 windowCount = [allWindows count];
01870
01871 if ([self isKeyWindow])
01872 {
01873 var keyWindow = [CPApp keyWindow];
01874 [self resignKeyWindow];
01875
01876 if (keyWindow && keyWindow !== self && [keyWindow canBecomeKeyWindow])
01877 [keyWindow makeKeyWindow];
01878 else
01879 {
01880 var menuWindow = [CPApp mainMenu]._menuWindow;
01881 for (var i = 0; i < windowCount; i++)
01882 {
01883 var currentWindow = allWindows[i];
01884 if (currentWindow === self || currentWindow === menuWindow)
01885 continue;
01886
01887 if ([currentWindow isVisible] && [currentWindow canBecomeKeyWindow])
01888 {
01889 [currentWindow makeKeyWindow];
01890 break;
01891 }
01892 }
01893
01894 if (![CPApp keyWindow])
01895 [menuWindow makeKeyWindow];
01896 }
01897 }
01898
01899 if ([self isMainWindow])
01900 {
01901 var mainWindow = [CPApp mainWindow];
01902 [self resignMainWindow];
01903
01904 if (mainWindow && mainWindow !== self && [mainWindow canBecomeMainWindow])
01905 [mainWindow makeMainWindow];
01906 else
01907 {
01908 var menuWindow = [CPApp mainMenu]._menuWindow;
01909 for (var i = 0; i < windowCount; i++)
01910 {
01911 var currentWindow = allWindows[i];
01912 if (currentWindow === self || currentWindow === menuWindow)
01913 continue;
01914
01915 if ([currentWindow isVisible] && [currentWindow canBecomeMainWindow])
01916 {
01917 [currentWindow makeMainWindow];
01918 break;
01919 }
01920 }
01921 }
01922 }
01923 }
01924
01925
01929 - (CPToolbar)toolbar
01930 {
01931 return _toolbar;
01932 }
01933
01938 - (void)setToolbar:(CPToolbar)aToolbar
01939 {
01940 if (_toolbar === aToolbar)
01941 return;
01942
01943
01944 [[aToolbar _window] setToolbar:nil];
01945
01946
01947 [_toolbar _setWindow:nil];
01948
01949 _toolbar = aToolbar;
01950
01951
01952 [_toolbar _setWindow:self];
01953
01954 [self _noteToolbarChanged];
01955 }
01956
01957 - (void)toggleToolbarShown:(id)aSender
01958 {
01959 var toolbar = [self toolbar];
01960
01961 [toolbar setVisible:![toolbar isVisible]];
01962 }
01963
01964 - (void)_noteToolbarChanged
01965 {
01966 var frame = CGRectMakeCopy([self frame]),
01967 newFrame;
01968
01969 [_windowView noteToolbarChanged];
01970
01971 if (_isFullPlatformWindow)
01972 newFrame = [_platformWindow visibleFrame];
01973 else
01974 {
01975 newFrame = CGRectMakeCopy([self frame]);
01976
01977 newFrame.origin = frame.origin;
01978 }
01979
01980 [self setFrame:newFrame];
01981
01982
01983
01984
01985
01986
01987 }
01988
01989 - (void)_setFrame:(CGRect)aFrame delegate:(id)delegate duration:(int)duration curve:(CPAnimationCurve)curve
01990 {
01991 var animation = [[_CPWindowFrameAnimation alloc] initWithWindow:self targetFrame:aFrame];
01992 [animation setDelegate:delegate];
01993 [animation setAnimationCurve:curve];
01994 [animation setDuration:duration];
01995 [animation startAnimation];
01996 }
01997
01998
01999 - (void)_setAttachedSheetFrameOrigin
02000 {
02001
02002 var attachedSheet = [self attachedSheet];
02003 var contentRect = [[self contentView] frame],
02004 sheetFrame = CGRectMakeCopy([attachedSheet frame]);
02005
02006 sheetFrame.origin.y = CGRectGetMinY(_frame) + CGRectGetMinY(contentRect);
02007 sheetFrame.origin.x = CGRectGetMinX(_frame) + FLOOR((CGRectGetWidth(_frame) - CGRectGetWidth(sheetFrame)) / 2.0);
02008
02009 [attachedSheet setFrame:sheetFrame display:YES animate:NO];
02010 }
02011
02012
02013 - (void)_attachSheet:(CPWindow)aSheet modalDelegate:(id)aModalDelegate didEndSelector:(SEL)aDidEndSelector contextInfo:(id)aContextInfo
02014 {
02015 var sheetFrame = [aSheet frame];
02016
02017 _sheetContext = {"sheet":aSheet, "modalDelegate":aModalDelegate, "endSelector":aDidEndSelector, "contextInfo":aContextInfo, "frame":CGRectMakeCopy(sheetFrame), "returnCode":-1, "opened": NO};
02018
02019 [self _attachSheetWindow:aSheet];
02020 }
02021
02022
02023 - (void)_attachSheetWindow:(CPWindow)aSheet
02024 {
02025 var sheetFrame = [aSheet frame],
02026 frame = [self frame],
02027 sheetContent = [aSheet contentView];
02028
02029 [self _setUpMasksForView:sheetContent];
02030
02031 aSheet._isSheet = YES;
02032 aSheet._parentView = self;
02033
02034 var originx = frame.origin.x + FLOOR((frame.size.width - sheetFrame.size.width)/2),
02035 originy = frame.origin.y + [[self contentView] frame].origin.y,
02036 startFrame = CGRectMake(originx, originy, sheetFrame.size.width, 0),
02037 endFrame = CGRectMake(originx, originy, sheetFrame.size.width, sheetFrame.size.height);
02038
02039 [[CPNotificationCenter defaultCenter] postNotificationName:CPWindowWillBeginSheetNotification object:self];
02040 [CPApp runModalForWindow:aSheet];
02041
02042 [aSheet orderFront:self];
02043 [aSheet setFrame:startFrame display:YES animate:NO];
02044 _sheetContext["opened"] = YES;
02045
02046 [aSheet _setFrame:endFrame delegate:self duration:0.2 curve:CPAnimationEaseOut];
02047
02048
02049 [aSheet becomeKeyWindow];
02050 }
02051
02052
02053 - (void)_detachSheetWindow
02054 {
02055 var sheet = [self attachedSheet],
02056 startFrame = [sheet frame],
02057 endFrame = CGRectMakeCopy(startFrame);
02058
02059 endFrame.size.height = 0;
02060
02061 _sheetContext["frame"] = startFrame;
02062
02063 var sheetContent = [sheet contentView];
02064 [self _setUpMasksForView:sheetContent];
02065
02066 _sheetContext["opened"] = NO;
02067 [sheet _setFrame:endFrame delegate:self duration:0.2 curve:CPAnimationEaseIn];
02068 }
02069
02070
02071 - (void)animationDidEnd:(id)anim
02072 {
02073 var sheet = _sheetContext["sheet"];
02074 if (anim._window != sheet)
02075 return;
02076
02077 var sheetContent = [sheet contentView];
02078
02079 if (_sheetContext["opened"] === YES)
02080 {
02081 [self _restoreMasksForView:sheetContent];
02082 return;
02083 }
02084
02085 [CPApp stopModal];
02086 [[CPNotificationCenter defaultCenter] postNotificationName:CPWindowDidEndSheetNotification object:self];
02087
02088 [sheet orderOut:self];
02089
02090 var lastFrame = _sheetContext["frame"];
02091 [sheet setFrame:lastFrame];
02092
02093 [self _restoreMasksForView:sheetContent];
02094
02095 var delegate = _sheetContext["modalDelegate"],
02096 endSelector = _sheetContext["endSelector"];
02097
02098 if (delegate != nil && endSelector != nil)
02099 objj_msgSend(delegate, endSelector, sheet, _sheetContext["returnCode"], _sheetContext["contextInfo"]);
02100
02101 _sheetContext = nil;
02102 sheet._parentView = nil;
02103 }
02104
02105 - (void)_setUpMasksForView:(CPView)aView
02106 {
02107 var views = [aView subviews];
02108
02109 [views addObject:aView];
02110
02111 for (var i = 0, count = [views count]; i < count; i++)
02112 {
02113 var view = [views objectAtIndex:i],
02114 mask = [view autoresizingMask],
02115 maskToAdd = (mask & CPViewMinYMargin) ? 128 : CPViewMinYMargin;
02116
02117 [view setAutoresizingMask:(mask | maskToAdd)];
02118 }
02119 }
02120
02121 - (void)_restoreMasksForView:(CPView)aView
02122 {
02123 var views = [aView subviews];
02124
02125 [views addObject:aView];
02126
02127 for (var i = 0, count = [views count]; i < count; i++)
02128 {
02129 var view = [views objectAtIndex:i],
02130 mask = [view autoresizingMask],
02131 maskToRemove = (mask & 128) ? 128 : CPViewMinYMargin;
02132
02133 [view setAutoresizingMask:(mask & (~ maskToRemove))];
02134 }
02135 }
02136
02140 - (CPWindow)attachedSheet
02141 {
02142 if (_sheetContext === nil)
02143 return nil;
02144
02145 return _sheetContext["sheet"];
02146 }
02147
02151 - (BOOL)isSheet
02152 {
02153 return _isSheet;
02154 }
02155
02156
02157
02158
02159
02160
02161 - (BOOL)becomesKeyOnlyIfNeeded
02162 {
02163 return NO;
02164 }
02165
02170 - (BOOL)worksWhenModal
02171 {
02172 return NO;
02173 }
02174
02175 - (void)performKeyEquivalent:(CPEvent)anEvent
02176 {
02177
02178
02179 return [[self contentView] performKeyEquivalent:anEvent];
02180 }
02181
02182 - (void)keyDown:(CPEvent)anEvent
02183 {
02184
02185
02186 if (![anEvent _couldBeKeyEquivalent] || ![self performKeyEquivalent:anEvent])
02187 [self interpretKeyEvents:[anEvent]];
02188 }
02189
02190 - (void)insertNewline:(id)sender
02191 {
02192 if (_defaultButton && _defaultButtonEnabled)
02193 [_defaultButton performClick:nil];
02194 }
02195
02196 - (void)insertTab:(id)sender
02197 {
02198 [self selectNextKeyView:nil];
02199 }
02200
02201 - (void)_dirtyKeyViewLoop
02202 {
02203 if (_autorecalculatesKeyViewLoop)
02204 _keyViewLoopIsDirty = YES;
02205 }
02206
02207 - (BOOL)_hasKeyViewLoop
02208 {
02209 var subviews = [];
02210
02211 [self _appendSubviewsOf:_contentView toArray:subviews];
02212
02213 for (var i = 0, count = [subviews count]; i<count; i++)
02214 {
02215 if (subviews[i]._nextKeyView)
02216 return YES;
02217 }
02218
02219 return NO;
02220 }
02221
02222 - (void)recalculateKeyViewLoop
02223 {
02224 var subviews = [];
02225
02226 [self _appendSubviewsOf:_contentView toArray:subviews];
02227
02228 var keyViewOrder = [subviews sortedArrayUsingFunction:keyViewComparator context:_contentView],
02229 count = [keyViewOrder count];
02230
02231 for (var i=0; i<count; i++)
02232 [keyViewOrder[i] setNextKeyView:keyViewOrder[(i+1)%count]];
02233
02234 _keyViewLoopIsDirty = NO;
02235 }
02236
02237 - (void)_appendSubviewsOf:(CPView)aView toArray:(CPArray)anArray
02238 {
02239 var subviews = [aView subviews],
02240 count = [subviews count];
02241
02242 while (count--)
02243 [self _appendSubviewsOf:subviews[count] toArray:anArray];
02244
02245 [anArray addObject:aView];
02246 }
02247
02248 - (void)setAutorecalculatesKeyViewLoop:(BOOL)shouldRecalculate
02249 {
02250 if (_autorecalculatesKeyViewLoop === shouldRecalculate)
02251 return;
02252
02253 _autorecalculatesKeyViewLoop = shouldRecalculate;
02254
02255 if (_keyViewLoopIsDirty)
02256 [self recalculateKeyViewLoop];
02257 else if (_autorecalculatesKeyViewLoop)
02258 [self _dirtyKeyViewLoop];
02259 }
02260
02261 - (BOOL)autorecalculatesKeyViewLoop
02262 {
02263 return _autorecalculatesKeyViewLoop;
02264 }
02265
02266 - (void)selectNextKeyView:(id)sender
02267 {
02268 if ([_firstResponder isKindOfClass:[CPView class]])
02269 [self selectKeyViewFollowingView:_firstResponder];
02270 }
02271
02272 - (void)selectPreviousKeyView:(id)sender
02273 {
02274 if ([_firstResponder isKindOfClass:[CPView class]])
02275 [self selectKeyViewPrecedingView:_firstResponder];
02276 }
02277
02278 - (void)selectKeyViewFollowingView:(CPView)aView
02279 {
02280 if (_keyViewLoopIsDirty)
02281 [self recalculateKeyViewLoop];
02282
02283 [self makeFirstResponder:[aView nextValidKeyView]];
02284 }
02285
02286 - (void)selectKeyViewPrecedingView:(CPView)aView
02287 {
02288 if (_keyViewLoopIsDirty)
02289 [self recalculateKeyViewLoop];
02290
02291 [self makeFirstResponder:[aView previousValidKeyView]];
02292 }
02293
02294 - (void)setDefaultButtonCell:(CPButton)aButton
02295 {
02296 [self setDefaultButton:aButton];
02297 }
02298
02299 - (CPButton)defaultButtonCell
02300 {
02301 return [self defaultButton];
02302 }
02303
02304 - (void)setDefaultButton:(CPButton)aButton
02305 {
02306 [_defaultButton setDefaultButton:NO];
02307
02308 _defaultButton = aButton;
02309
02310 [_defaultButton setDefaultButton:YES];
02311 }
02312
02313 - (CPButton)defaultButton
02314 {
02315 return _defaultButton;
02316 }
02317
02318 - (void)enableKeyEquivalentForDefaultButton
02319 {
02320 _defaultButtonEnabled = YES;
02321 }
02322
02323 - (void)enableKeyEquivalentForDefaultButtonCell
02324 {
02325 [self enableKeyEquivalentForDefaultButton];
02326 }
02327
02328 - (void)disableKeyEquivalentForDefaultButton
02329 {
02330 _defaultButtonEnabled = NO;
02331 }
02332
02333 - (void)disableKeyEquivalentForDefaultButtonCell
02334 {
02335 [self disableKeyEquivalentForDefaultButton];
02336 }
02337
02338 @end
02339
02340 var keyViewComparator = function(a, b, context)
02341 {
02342 var viewBounds = [a convertRect:[a bounds] toView:nil],
02343 otherBounds = [b convertRect:[b bounds] toView:nil];
02344
02345 if (CGRectGetMinY(viewBounds) < CGRectGetMinY(otherBounds))
02346 return -1;
02347 else if (CGRectGetMinY(viewBounds) == CGRectGetMinY(otherBounds) && CGRectGetMinX(viewBounds) < CGRectGetMinX(otherBounds))
02348 return -1;
02349 else if (CGRectGetMinX(viewBounds) == CGRectGetMinX(otherBounds) && CGRectGetMinX(viewBounds) == CGRectGetMinX(otherBounds))
02350 return 0;
02351 else
02352 return 1;
02353 }
02354
02355 @implementation CPWindow (MenuBar)
02356
02357 - (void)_synchronizeMenuBarTitleWithWindowTitle
02358 {
02359
02360 if (![_windowController document] || ![self isMainWindow])
02361 return;
02362
02363 [CPMenu setMenuBarTitle:_title];
02364 }
02365
02366 @end
02367
02368 @implementation CPWindow (BridgeSupport)
02369
02370
02371
02372
02373 - (void)resizeWithOldPlatformWindowSize:(CGSize)aSize
02374 {
02375 if ([self isFullPlatformWindow])
02376 return [self setFrame:[_platformWindow visibleFrame]];
02377
02378 if (_autoresizingMask == CPWindowNotSizable)
02379 return;
02380
02381 var frame = [_platformWindow contentBounds],
02382 newFrame = CGRectMakeCopy(_frame),
02383 dX = (CGRectGetWidth(frame) - aSize.width) /
02384 (((_autoresizingMask & CPWindowMinXMargin) ? 1 : 0) + (_autoresizingMask & CPWindowWidthSizable ? 1 : 0) + (_autoresizingMask & CPWindowMaxXMargin ? 1 : 0)),
02385 dY = (CGRectGetHeight(frame) - aSize.height) /
02386 ((_autoresizingMask & CPWindowMinYMargin ? 1 : 0) + (_autoresizingMask & CPWindowHeightSizable ? 1 : 0) + (_autoresizingMask & CPWindowMaxYMargin ? 1 : 0));
02387
02388 if (_autoresizingMask & CPWindowMinXMargin)
02389 newFrame.origin.x += dX;
02390 if (_autoresizingMask & CPWindowWidthSizable)
02391 newFrame.size.width += dX;
02392
02393 if (_autoresizingMask & CPWindowMinYMargin)
02394 newFrame.origin.y += dY;
02395 if (_autoresizingMask & CPWindowHeightSizable)
02396 newFrame.size.height += dY;
02397
02398 [self setFrame:newFrame];
02399 }
02400
02401
02402
02403
02404 - (void)setAutoresizingMask:(unsigned)anAutoresizingMask
02405 {
02406 _autoresizingMask = anAutoresizingMask;
02407 }
02408
02409
02410
02411
02412 - (unsigned)autoresizingMask
02413 {
02414 return _autoresizingMask;
02415 }
02416
02417 - (CGPoint)convertBaseToGlobal:(CGPoint)aPoint
02418 {
02419 return [CPPlatform isBrowser] ? [self convertBaseToPlatformWindow:aPoint] : [self convertBaseToScreen:aPoint];
02420 }
02421
02422 - (CGPoint)convertGlobalToBase:(CGPoint)aPoint
02423 {
02424 return [CPPlatform isBrowser] ? [self convertPlatformWindowToBase:aPoint] : [self convertScreenToBase:aPoint];
02425 }
02426
02427 - (CGPoint)convertBaseToPlatformWindow:(CGPoint)aPoint
02428 {
02429 if ([self _sharesChromeWithPlatformWindow])
02430 return aPoint;
02431
02432 var origin = [self frame].origin;
02433
02434 return _CGPointMake(aPoint.x + origin.x, aPoint.y + origin.y);
02435 }
02436
02437 - (CGPoint)convertPlatformWindowToBase:(CGPoint)aPoint
02438 {
02439 if ([self _sharesChromeWithPlatformWindow])
02440 return aPoint;
02441
02442 var origin = [self frame].origin;
02443
02444 return _CGPointMake(aPoint.x - origin.x, aPoint.y - origin.y);
02445 }
02446
02447 - (CGPoint)convertScreenToBase:(CGPoint)aPoint
02448 {
02449 return [self convertPlatformWindowToBase:[_platformWindow convertScreenToBase:aPoint]];
02450 }
02451
02452 - (CGPoint)convertBaseToScreen:(CGPoint)aPoint
02453 {
02454 return [_platformWindow convertBaseToScreen:[self convertBaseToPlatformWindow:aPoint]];
02455 }
02456
02457 - (void)_setSharesChromeWithPlatformWindow:(BOOL)shouldShareFrameWithPlatformWindow
02458 {
02459
02460 if (shouldShareFrameWithPlatformWindow && [CPPlatform isBrowser])
02461 return;
02462
02463 _sharesChromeWithPlatformWindow = shouldShareFrameWithPlatformWindow;
02464
02465 [self _updateShadow];
02466 }
02467
02468 - (BOOL)_sharesChromeWithPlatformWindow
02469 {
02470 return _sharesChromeWithPlatformWindow;
02471 }
02472
02473
02477 - (CPUndoManager)undoManager
02478 {
02479
02480 if (_undoManager)
02481 return _undoManager;
02482
02483
02484 var documentUndoManager = [[_windowController document] undoManager];
02485
02486 if (documentUndoManager)
02487 return documentUndoManager;
02488
02489
02490 if (_delegateRespondsToWindowWillReturnUndoManagerSelector)
02491 return [_delegate windowWillReturnUndoManager:self];
02492
02493
02494 if (!_undoManager)
02495 _undoManager = [[CPUndoManager alloc] init];
02496
02497 return _undoManager;
02498 }
02499
02504 - (void)undo:(id)aSender
02505 {
02506 [[self undoManager] undo];
02507 }
02508
02513 - (void)redo:(id)aSender
02514 {
02515 [[self undoManager] redo];
02516 }
02517
02518 - (BOOL)containsPoint:(CGPoint)aPoint
02519 {
02520 return CGRectContainsPoint(_frame, aPoint);
02521 }
02522
02523 @end
02524
02525 @implementation CPWindow (Deprecated)
02526
02527 - (void)setFullBridge:(BOOL)shouldBeFullBridge
02528 {
02529 [self setFullPlatformWindow:shouldBeFullBridge];
02530 }
02531
02532 - (BOOL)isFullBridge
02533 {
02534 return [self isFullPlatformWindow];
02535 }
02536
02537
02538
02539
02540 - (CGPoint)convertBaseToBridge:(CGPoint)aPoint
02541 {
02542 return [self convertBaseToPlatformWindow:aPoint];
02543 }
02544
02545
02546
02547
02548 - (CGPoint)convertBridgeToBase:(CGPoint)aPoint
02549 {
02550 return [self convertPlatformWindowToBase:aPoint];
02551 }
02552
02553 @end
02554
02555 var interpolate = function(fromValue, toValue, progress)
02556 {
02557 return fromValue + (toValue - fromValue) * progress;
02558 }
02559
02560
02561 @implementation _CPWindowFrameAnimation : CPAnimation
02562 {
02563 CPWindow _window;
02564
02565 CGRect _startFrame;
02566 CGRect _targetFrame;
02567 }
02568
02569 - (id)initWithWindow:(CPWindow)aWindow targetFrame:(CGRect)aTargetFrame
02570 {
02571 self = [super initWithDuration:0.2 animationCurve:CPAnimationLinear];
02572
02573 if (self)
02574 {
02575 _window = aWindow;
02576
02577 _targetFrame = CGRectMakeCopy(aTargetFrame);
02578 _startFrame = CGRectMakeCopy([_window frame]);
02579 }
02580
02581 return self;
02582 }
02583
02584 - (void)startAnimation
02585 {
02586 [super startAnimation];
02587
02588 _window._isAnimating = YES;
02589 }
02590
02591 - (void)setCurrentProgress:(float)aProgress
02592 {
02593 [super setCurrentProgress:aProgress];
02594
02595 var value = [self currentValue];
02596
02597 if (value == 1.0)
02598 _window._isAnimating = NO;
02599
02600 var newFrame = CGRectMake(interpolate(CGRectGetMinX(_startFrame), CGRectGetMinX(_targetFrame), value),
02601 interpolate(CGRectGetMinY(_startFrame), CGRectGetMinY(_targetFrame), value),
02602 interpolate(CGRectGetWidth(_startFrame), CGRectGetWidth(_targetFrame), value),
02603 interpolate(CGRectGetHeight(_startFrame), CGRectGetHeight(_targetFrame), value));
02604
02605 [_window setFrame:newFrame display:YES animate:NO];
02606 }
02607
02608 @end
02609
02610 function _CPWindowFullPlatformWindowSessionMake(aWindowView, aContentRect, hasShadow, aLevel)
02611 {
02612 return { windowView:aWindowView, contentRect:aContentRect, hasShadow:hasShadow, level:aLevel };
02613 }
02614
02615 CPStandardWindowShadowStyle = 0;
02616 CPMenuWindowShadowStyle = 1;
02617 CPPanelWindowShadowStyle = 2;
02618 CPCustomWindowShadowStyle = 3;
02619
02620
02621 @import "_CPWindowView.j"
02622 @import "_CPStandardWindowView.j"
02623 @import "_CPDocModalWindowView.j"
02624 @import "_CPHUDWindowView.j"
02625 @import "_CPBorderlessWindowView.j"
02626 @import "_CPBorderlessBridgeWindowView.j"
02627 @import "CPDragServer.j"
02628 @import "CPView.j"