Add support for minimization.

This commit is contained in:
Ross Boucher
2009-10-10 12:20:02 -04:00
committed by Francisco Ryan Tolmasky I
parent 2900163644
commit 2338ca2fa2
9 changed files with 123 additions and 23 deletions
+64 -13
View File
@@ -178,6 +178,9 @@ CPWindowDidResignMainNotification = @"CPWindowDidResignMainNotification";
CPWindowDidMoveNotification = @"CPWindowDidMoveNotification";
CPWindowWillBeginSheetNotification = @"CPWindowWillBeginSheetNotification";
CPWindowDidEndSheetNotification = @"CPWindowDidEndSheetNotification";
CPWindowDidMiniaturizeNotification = @"CPWindowDidMiniaturizeNotification";
CPWindowWillMiniaturizeNotification = @"CPWindowWillMiniaturizeNotification";
CPWindowDidDeminiaturizeNotification = @"CPWindowDidDeminiaturizeNotification";
CPWindowShadowStyleStandard = 0;
CPWindowShadowStyleMenu = 1;
@@ -249,6 +252,7 @@ var CPWindowSaveImage = nil,
CGRect _frame;
int _level;
BOOL _isVisible;
BOOL _isMiniaturized;
BOOL _isAnimating;
BOOL _hasShadow;
BOOL _isMovableByWindowBackground;
@@ -441,10 +445,10 @@ CPTexturedBackgroundWindowMask
{
if (aStyleMask & CPHUDBackgroundWindowMask)
return _CPHUDWindowView;
else if (aStyleMask === CPBorderlessWindowMask)
return _CPBorderlessWindowView;
else if (aStyleMask & CPDocModalWindowMask)
return _CPDocModalWindowView;
@@ -964,17 +968,17 @@ CPTexturedBackgroundWindowMask
if (!_CPWindowShadowColor)
{
var bundle = [CPBundle bundleForClass:[CPWindow class]];
_CPWindowShadowColor = [CPColor colorWithPatternImage:[[CPNinePartImage alloc] initWithImageSlices:
[
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/CPWindowShadow0.png"] size:CGSizeMake(20.0, 19.0)],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/CPWindowShadow1.png"] size:CGSizeMake(1.0, 19.0)],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/CPWindowShadow2.png"] size:CGSizeMake(19.0, 19.0)],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/CPWindowShadow3.png"] size:CGSizeMake(20.0, 1.0)],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/CPWindowShadow4.png"] size:CGSizeMake(1.0, 1.0)],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/CPWindowShadow5.png"] size:CGSizeMake(19.0, 1.0)],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/CPWindowShadow6.png"] size:CGSizeMake(20.0, 18.0)],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/CPWindowShadow7.png"] size:CGSizeMake(1.0, 18.0)],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/CPWindowShadow8.png"] size:CGSizeMake(19.0, 18.0)]
@@ -1249,33 +1253,33 @@ CPTexturedBackgroundWindowMask
case CPLeftMouseUp: if (!_leftMouseDownView)
return [[_windowView hitTest:point] mouseUp:anEvent];
[_leftMouseDownView mouseUp:anEvent]
_leftMouseDownView = nil;
return;
case CPLeftMouseDown: _leftMouseDownView = [_windowView hitTest:point];
if (_leftMouseDownView != _firstResponder && [_leftMouseDownView acceptsFirstResponder])
[self makeFirstResponder:_leftMouseDownView];
var theWindow = [anEvent window];
if ([theWindow isKeyWindow] || [theWindow becomesKeyOnlyIfNeeded])
return [_leftMouseDownView mouseDown:anEvent];
else
{
// FIXME: delayed ordering?
[self makeKeyAndOrderFront:self];
if ([_leftMouseDownView acceptsFirstMouse:anEvent])
return [_leftMouseDownView mouseDown:anEvent]
}
break;
case CPLeftMouseDragged: if (!_leftMouseDownView)
return [[_windowView hitTest:point] mouseDragged:anEvent];
return [_leftMouseDownView mouseDragged:anEvent];
case CPRightMouseUp: return [_rightMouseDownView mouseUp:anEvent];
@@ -1574,6 +1578,53 @@ CPTexturedBackgroundWindowMask
}
}
// Minimizing Windows
/*!
Simulates the user minimizing the window, then minimizes the window.
@param aSender the object making this request
*/
- (void)performMiniaturize:(id)aSender
{
//FIXME show stuff
[self miniaturize:aSender];
}
/*!
Minimizes the window. Posts a \c CPWindowWillMiniaturizeNotification to the
notification center before minimizing the window.
*/
- (void)miniaturize:(id)sender
{
[[CPNotificationCenter defaultCenter] postNotificationName:CPWindowWillMiniaturizeNotification object:self];
[[self platformWindow] miniaturize:sender];
[[CPNotificationCenter defaultCenter] postNotificationName:CPWindowDidMiniaturizeNotification object:self];
_isMiniaturized = YES;
}
/*!
Restores a mimized window to it's original size.
*/
- (void)deminiaturize:(id)sender
{
[[self platformWindow] deminiaturize:sender];
[[CPNotificationCenter defaultCenter] postNotificationName:CPWindowDidDeminiaturizeNotification object:self];
_isMiniaturized = NO;
}
/*!
Returns YES if the window is minimized.
*/
- (void)isMiniaturized
{
return _isMiniaturized;
}
// Closing Windows
/*!
@@ -1806,7 +1857,7 @@ CPTexturedBackgroundWindowMask
var sheetContent = [sheet contentView];
[self _setUpMasksForView:sheetContent];
_sheetContext["opened"] = NO;
[sheet _setFrame:endFrame delegate:self duration:0.2 curve:CPAnimationEaseIn];
}
+43 -10
View File
@@ -98,7 +98,9 @@ var _CPStandardWindowViewBodyBackgroundColor = nil,
_CPStandardWindowViewDividerBackgroundColor = nil,
_CPStandardWindowViewTitleBackgroundColor = nil,
_CPStandardWindowViewCloseButtonImage = nil,
_CPStandardWindowViewCloseButtonHighlightedImage = nil;
_CPStandardWindowViewCloseButtonHighlightedImage = nil,
_CPStandardWindowViewMinimizeButtonImage = nil,
_CPStandardWindowViewMinimizeButtonHighlightedImage = nil;
var STANDARD_GRADIENT_HEIGHT = 41.0;
STANDARD_TITLEBAR_HEIGHT = 25.0;
@@ -112,6 +114,7 @@ var STANDARD_GRADIENT_HEIGHT = 41.0;
CPTextField _titleField;
CPButton _closeButton;
CPButton _minimizeButton;
}
+ (CPColor)bodyBackgroundColor
@@ -230,7 +233,7 @@ var STANDARD_GRADIENT_HEIGHT = 41.0;
[_bodyView setHitTests:NO];
[self addSubview:_bodyView];
[self setResizeIndicatorOffset:CGSizeMake(2.0, 2.0)];
_titleField = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
@@ -256,24 +259,44 @@ var STANDARD_GRADIENT_HEIGHT = 41.0;
if (!_CPStandardWindowViewCloseButtonImage)
{
var bundle = [CPBundle bundleForClass:[CPWindow class]];
_CPStandardWindowViewCloseButtonImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/Standard/CPWindowStandardCloseButton.png"] size:CGSizeMake(16.0, 16.0)];
_CPStandardWindowViewCloseButtonHighlightedImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/Standard/CPWindowStandardCloseButtonHighlighted.png"] size:CGSizeMake(16.0, 16.0)];
}
_closeButton = [[CPButton alloc] initWithFrame:CGRectMake(8.0, 7.0, 16.0, 16.0)];
[_closeButton setBordered:NO];
[_closeButton setImage:_CPStandardWindowViewCloseButtonImage];
[_closeButton setAlternateImage:_CPStandardWindowViewCloseButtonHighlightedImage];
[self addSubview:_closeButton];
}
if (_styleMask & CPMiniaturizableWindowMask && ![CPPlatform isBrowser])
{
if (!_CPStandardWindowViewMinimizeButtonImage)
{
var bundle = [CPBundle bundleForClass:[CPWindow class]];
_CPStandardWindowViewMinimizeButtonImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/Standard/CPWindowStandardMinimizeButton.png"] size:CGSizeMake(16.0, 16.0)];
_CPStandardWindowViewMinimizeButtonHighlightedImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/Standard/CPWindowStandardMinimizeButtonHighlighted.png"] size:CGSizeMake(16.0, 16.0)];
}
_minimizeButton = [[CPButton alloc] initWithFrame:CGRectMake(27.0, 7.0, 16.0, 16.0)];
[_minimizeButton setBordered:NO];
[_minimizeButton setImage:_CPStandardWindowViewMinimizeButtonImage];
[_minimizeButton setAlternateImage:_CPStandardWindowViewMinimizeButtonHighlightedImage];
[self addSubview:_minimizeButton];
}
[self tile];
}
return self;
}
@@ -281,6 +304,9 @@ var STANDARD_GRADIENT_HEIGHT = 41.0;
{
[_closeButton setTarget:[self window]];
[_closeButton setAction:@selector(performClose:)];
[_minimizeButton setTarget:[self window]];
[_minimizeButton setAction:@selector(performMiniaturize:)];
}
- (CGSize)toolbarOffset
@@ -303,7 +329,14 @@ var STANDARD_GRADIENT_HEIGHT = 41.0;
[_bodyView setFrame:CGRectMake(0.0, dividerMaxY, width, CGRectGetHeight(bounds) - dividerMaxY)];
[_titleField setFrame:CGRectMake(10.0, 3.0, width - 20.0, CGRectGetHeight([_titleField frame]))];
var leftOffset = 8;
if (_closeButton)
leftOffset += 19.0;
if (_minimizeButton)
leftOffset += 19.0;
[_titleField setFrame:CGRectMake(leftOffset, 5.0, width - leftOffset*2.0, CGRectGetHeight([_titleField frame]))];
[[theWindow contentView] setFrameOrigin:CGPointMake(0.0, CGRectGetMaxY([_dividerView frame]))];
}
+16
View File
@@ -149,6 +149,22 @@ var PrimaryPlatformWindow = NULL;
#endif
}
- (void)deminiaturize:(id)sender
{
#if PLATFORM(DOM)
if (_DOMWindow && typeof _DOMWindow["cpDeminiaturize"] === "function")
_DOMWindow.cpDeminiaturize();
#endif
}
- (void)miniaturize:(id)sender
{
#if PLATFORM(DOM)
if (_DOMWindow && typeof _DOMWindow["cpMiniaturize"] === "function")
_DOMWindow.cpMiniaturize();
#endif
}
- (void)setLevel:(CPInteger)aLevel
{
_level = aLevel;
Binary file not shown.

After

Width:  |  Height:  |  Size: 720 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 716 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 713 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 722 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 661 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 683 B