diff --git a/AppKit/CPApplication.j b/AppKit/CPApplication.j index 41d8d6dee..7958fc45f 100644 --- a/AppKit/CPApplication.j +++ b/AppKit/CPApplication.j @@ -325,7 +325,9 @@ CPRunContinuesResponse = -1002; applicationVersion = [options objectForKey:@"ApplicationVersion"] || [mainInfo objectForKey:@"CPBundleShortVersionString"], copyright = [options objectForKey:@"Copyright"] || [mainInfo objectForKey:@"CPHumanReadableCopyright"]; - var aboutPanelController = [[CPWindowController alloc] initWithWindowCibName:@"AboutPanel"], + var aboutPanelPath = [[CPBundle bundleForClass:[CPWindowController class]] pathForResource:@"AboutPanel.cib"], + aboutPanelController = [CPWindowController alloc], + aboutPanelController = [aboutPanelController initWithWindowCibPath:aboutPanelPath owner:aboutPanelController], aboutPanel = [aboutPanelController window], contentView = [aboutPanel contentView], imageView = [contentView viewWithTag:1], diff --git a/AppKit/CPImageView.j b/AppKit/CPImageView.j index 7d365f71f..ab9722cae 100644 --- a/AppKit/CPImageView.j +++ b/AppKit/CPImageView.j @@ -35,6 +35,16 @@ CPScaleProportionally = 0; CPScaleToFit = 1; CPScaleNone = 2; +CPImageAlignCenter = 0; +CPImageAlignTop = 1; +CPImageAlignTopLeft = 2; +CPImageAlignTopRight = 3; +CPImageAlignLeft = 4; +CPImageAlignBottom = 5; +CPImageAlignBottomLeft = 6; +CPImageAlignBottomRight = 7; +CPImageAlignRight = 8; + var CPImageViewShadowBackgroundColor = nil; var LEFT_SHADOW_INSET = 3.0, @@ -52,14 +62,15 @@ var LEFT_SHADOW_INSET = 3.0, */ @implementation CPImageView : CPControl { - DOMElement _DOMImageElement; + DOMElement _DOMImageElement; - BOOL _hasShadow; - CPView _shadowView; + BOOL _hasShadow; + CPView _shadowView; - BOOL _isEditable; + BOOL _isEditable; - CGRect _imageRect; + CGRect _imageRect; + CPImageAlignment _imageAlignment; } - (id)initWithFrame:(CGRect)aFrame @@ -191,6 +202,30 @@ var LEFT_SHADOW_INSET = 3.0, [self hideOrDisplayContents]; } +/*! + Sets the type of image alignment that should be used to + render the image. + @param anImageAlignment the type of scaling to use +*/ +- (void)setImageAlignment:(CPImageAlignment)anImageAlignment +{ + if (_imageAlignment == anImageAlignment) + return; + + _imageAlignment = anImageAlignment; + + if (![self image]) + return; + + [self setNeedsLayout]; + [self setNeedsDisplay:YES]; +} + +- (unsigned)imageAlignment +{ + return _imageAlignment; +} + /*! Sets the type of image scaling that should be used to render the image. @@ -318,8 +353,49 @@ var LEFT_SHADOW_INSET = 3.0, #endif } - var x = (boundsWidth - width) / 2.0, - y = (boundsHeight - height) / 2.0; + var x, y; + + switch (_imageAlignment) + { + case CPImageAlignLeft: + case CPImageAlignTopLeft: + case CPImageAlignBottomLeft: + x = 0.0; + break; + + case CPImageAlignRight: + case CPImageAlignTopRight: + case CPImageAlignBottomRight: + x = boundsWidth - width; + break; + + case CPImageAlignCenter: + case CPImageAlignTop: + case CPImageAlignBottom: + x = (boundsWidth - width) / 2.0; + break; + } + + switch (_imageAlignment) + { + case CPImageAlignTop: + case CPImageAlignTopLeft: + case CPImageAlignTopRight: + y = 0.0; + break; + + case CPImageAlignBottom: + case CPImageAlignBottomLeft: + case CPImageAlignBottomRight: + y = boundsHeight - height; + break; + + case CPImageAlignLeft: + case CPImageAlignRight: + case CPImageAlignCenter: + y = (boundsHeight - height) / 2.0; + break; + } #if PLATFORM(DOM) CPDOMDisplayServerSetStyleLeftTop(_DOMImageElement, NULL, x, y); @@ -380,10 +456,11 @@ var LEFT_SHADOW_INSET = 3.0, @end -var CPImageViewImageKey = @"CPImageViewImageKey", - CPImageViewImageScalingKey = @"CPImageViewImageScalingKey", - CPImageViewHasShadowKey = @"CPImageViewHasShadowKey", - CPImageViewIsEditableKey = @"CPImageViewIsEditableKey"; +var CPImageViewImageKey = @"CPImageViewImageKey", + CPImageViewImageScalingKey = @"CPImageViewImageScalingKey", + CPImageViewImageAlignmentKey = @"CPImageViewImageAlignmentKey", + CPImageViewHasShadowKey = @"CPImageViewHasShadowKey", + CPImageViewIsEditableKey = @"CPImageViewIsEditableKey"; @implementation CPImageView (CPCoding) @@ -416,6 +493,7 @@ var CPImageViewImageKey = @"CPImageViewImageKey", #endif [self setHasShadow:[aCoder decodeBoolForKey:CPImageViewHasShadowKey]]; + [self setImageAlignment:[aCoder decodeIntForKey:CPImageViewImageAlignmentKey]]; if ([aCoder decodeBoolForKey:CPImageViewIsEditableKey] || NO) [self setEditable:YES]; @@ -450,6 +528,7 @@ var CPImageViewImageKey = @"CPImageViewImageKey", _subviews = actualSubviews; [aCoder encodeBool:_hasShadow forKey:CPImageViewHasShadowKey]; + [aCoder encodeInt:_imageAlignment forKey:CPImageViewImageAlignmentKey]; if (_isEditable) [aCoder encodeBool:_isEditable forKey:CPImageViewIsEditableKey]; diff --git a/AppKit/CPWindowController.j b/AppKit/CPWindowController.j index aebbc5e89..2d011af98 100644 --- a/AppKit/CPWindowController.j +++ b/AppKit/CPWindowController.j @@ -133,7 +133,7 @@ if (_window) return; - [[CPBundle bundleForClass:[_cibOwner class]] loadCibFile:[self windowCibPath] externalNameTable:[CPDictionary dictionaryWithObject:_cibOwner forKey:CPCibOwner]]; + [[CPBundle mainBundle] loadCibFile:[self windowCibPath] externalNameTable:[CPDictionary dictionaryWithObject:_cibOwner forKey:CPCibOwner]]; } /*! @@ -424,7 +424,7 @@ if (_windowCibPath) return _windowCibPath; - return [[CPBundle bundleForClass:[_cibOwner class]] pathForResource:_windowCibName + @".cib"]; + return [[CPBundle mainBundle] pathForResource:_windowCibName + @".cib"]; } // Setting and Getting Window Attributes diff --git a/Tools/nib2cib/NSImageView.j b/Tools/nib2cib/NSImageView.j index 2624c2582..9c83e4a7b 100644 --- a/Tools/nib2cib/NSImageView.j +++ b/Tools/nib2cib/NSImageView.j @@ -34,6 +34,7 @@ var cell = [aCoder decodeObjectForKey:@"NSCell"]; [self setImageScaling:[cell imageScaling]]; + [self setImageAlignment:[cell imageAlignment]]; _isEditable = [cell isEditable]; } @@ -92,7 +93,7 @@ NSImageScalingToCPImageScaling[NSImageScaleProportionallyUpOrDown] = CPScalePro @implementation NSImageCell : NSCell { BOOL _animates @accessors; - NSImageAlignment _imageAlignment @accessors; + NSImageAlignment _imageAlignment @accessors(readonly, getter=imageAlignment); NSImageScaling _imageScaling @accessors(readonly, getter=imageScaling); NSImageFrameStyle _frameStyle @accessors; }