diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index 59c0c3501..32509b2d3 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -1510,6 +1510,8 @@ CPTexturedBackgroundWindowMask _isDocumentEdited = isDocumentEdited; [CPMenu _setMenuBarIconImageAlphaValue:_isDocumentEdited ? 0.5 : 1.0]; + + [_windowView setDocumentEdited:isDocumentEdited]; } /*! diff --git a/AppKit/CPWindow/_CPStandardWindowView.j b/AppKit/CPWindow/_CPStandardWindowView.j index 5b100a2cc..8ea33a72e 100644 --- a/AppKit/CPWindow/_CPStandardWindowView.j +++ b/AppKit/CPWindow/_CPStandardWindowView.j @@ -94,13 +94,15 @@ var _CPTexturedWindowHeadGradientColor = nil, @end -var _CPStandardWindowViewBodyBackgroundColor = nil, - _CPStandardWindowViewDividerBackgroundColor = nil, - _CPStandardWindowViewTitleBackgroundColor = nil, - _CPStandardWindowViewCloseButtonImage = nil, - _CPStandardWindowViewCloseButtonHighlightedImage = nil, - _CPStandardWindowViewMinimizeButtonImage = nil, - _CPStandardWindowViewMinimizeButtonHighlightedImage = nil; +var _CPStandardWindowViewBodyBackgroundColor = nil, + _CPStandardWindowViewDividerBackgroundColor = nil, + _CPStandardWindowViewTitleBackgroundColor = nil, + _CPStandardWindowViewCloseButtonImage = nil, + _CPStandardWindowViewCloseButtonHighlightedImage = nil, + _CPStandardWindowViewCloseButtonUnsavedImage = nil, + _CPStandardWindowViewCloseButtonUnsavedHighlightedImage = nil, + _CPStandardWindowViewMinimizeButtonImage = nil, + _CPStandardWindowViewMinimizeButtonHighlightedImage = nil; var STANDARD_GRADIENT_HEIGHT = 41.0; STANDARD_TITLEBAR_HEIGHT = 25.0; @@ -115,6 +117,8 @@ var STANDARD_GRADIENT_HEIGHT = 41.0; CPTextField _titleField; CPButton _closeButton; CPButton _minimizeButton; + + BOOL _isDocumentEdited; } + (CPColor)bodyBackgroundColor @@ -262,14 +266,14 @@ var STANDARD_GRADIENT_HEIGHT = 41.0; _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)]; + _CPStandardWindowViewCloseButtonUnsavedImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/Standard/CPWindowStandardCloseButtonUnsaved.png"] size:CGSizeMake(16.0, 16.0)]; + _CPStandardWindowViewCloseButtonUnsavedHighlightedImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/Standard/CPWindowStandardCloseButtonUnsavedHighlighted.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 _updateCloseButton]; [self addSubview:_closeButton]; } @@ -367,6 +371,27 @@ var STANDARD_GRADIENT_HEIGHT = 41.0; } } */ + +- (void)_updateCloseButton +{ + if (_isDocumentEdited) + { + [_closeButton setImage:_CPStandardWindowViewCloseButtonUnsavedImage]; + [_closeButton setAlternateImage:_CPStandardWindowViewCloseButtonUnsavedHighlightedImage]; + } + else + { + [_closeButton setImage:_CPStandardWindowViewCloseButtonImage]; + [_closeButton setAlternateImage:_CPStandardWindowViewCloseButtonHighlightedImage]; + } +} + +- (void)setDocumentEdited:(BOOL)isEdited +{ + _isDocumentEdited = isEdited; + [self _updateCloseButton]; +} + - (void)setTitle:(CPString)aTitle { [_titleField setStringValue:aTitle]; diff --git a/AppKit/CPWindow/_CPWindowView.j b/AppKit/CPWindow/_CPWindowView.j index 5231016f6..0f878fd9a 100644 --- a/AppKit/CPWindow/_CPWindowView.j +++ b/AppKit/CPWindow/_CPWindowView.j @@ -88,6 +88,10 @@ var _CPWindowViewResizeIndicatorImage = nil; return self; } +- (void)setDocumentEdited:(BOOL)isEdited +{ +} + - (void)setTitle:(CPString)aTitle { } diff --git a/AppKit/CPWindowController.j b/AppKit/CPWindowController.j index 5909e2d63..aaaf14291 100644 --- a/AppKit/CPWindowController.j +++ b/AppKit/CPWindowController.j @@ -399,6 +399,27 @@ */ - (void)setDocumentEdited:(BOOL)isEdited { + // we ignore this. in a multi-doc world, we base this flag on the logical OR + // of all the open documents edited state. so this is just a hint to re-check that state. + //[[self window] setDocumentEdited:isEdited]; + [self _synchronizeDocumentEditedState]; +} + +- (void)_synchronizeDocumentEditedState +{ + var docs = [self documents], + count = [docs count], + isEdited = NO; + + while (count--) + { + if ([docs[count] isDocumentEdited]) + { + isEdited = YES; + break; + } + } + [[self window] setDocumentEdited:isEdited]; }