git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5399 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 1999-12-07 06:40:21 +00:00
parent b768de6402
commit f16e1bb031

View file

@ -41,7 +41,9 @@
+ (void) initialize + (void) initialize
{ {
if (self == [NSImageCell class]) if (self == [NSImageCell class])
[self setVersion: 1]; {
[self setVersion: 1];
}
} }
// //
@ -67,7 +69,7 @@
[super dealloc]; [super dealloc];
} }
- (void)setImage:(NSImage *)anImage - (void) setImage:(NSImage *)anImage
{ {
[super setImage:anImage]; [super setImage:anImage];
_original_image_size = [anImage size]; _original_image_size = [anImage size];
@ -76,23 +78,23 @@
// //
// Aligning and scaling the image // Aligning and scaling the image
// //
- (NSImageAlignment)imageAlignment - (NSImageAlignment) imageAlignment
{ {
return _imageAlignment; return _imageAlignment;
} }
- (void)setImageAlignment: (NSImageAlignment)anAlignment - (void) setImageAlignment: (NSImageAlignment)anAlignment
{ {
NSDebugLLog(@"NSImageCell", @"NSImageCell -setImageAlignment"); NSDebugLLog(@"NSImageCell", @"NSImageCell -setImageAlignment");
_imageAlignment = anAlignment; _imageAlignment = anAlignment;
} }
- (NSImageScaling)imageScaling - (NSImageScaling) imageScaling
{ {
return _imageScaling; return _imageScaling;
} }
- (void)setImageScaling: (NSImageScaling)scaling - (void) setImageScaling: (NSImageScaling)scaling
{ {
_imageScaling = scaling; _imageScaling = scaling;
} }
@ -100,12 +102,12 @@
// //
// Choosing the frame // Choosing the frame
// //
- (NSImageFrameStyle)imageFrameStyle - (NSImageFrameStyle) imageFrameStyle
{ {
return _frameStyle; return _frameStyle;
} }
- (void)setImageFrameStyle: (NSImageFrameStyle)aFrameStyle - (void) setImageFrameStyle: (NSImageFrameStyle)aFrameStyle
{ {
_frameStyle = aFrameStyle; _frameStyle = aFrameStyle;
} }
@ -148,22 +150,26 @@
[controlView unlockFocus]; [controlView unlockFocus];
} }
static inline float xLeftInRect(NSSize innerSize, NSRect outerRect) static inline float
xLeftInRect(NSSize innerSize, NSRect outerRect)
{ {
return NSMinX(outerRect); return NSMinX(outerRect);
} }
static inline float xCenterInRect(NSSize innerSize, NSRect outerRect) static inline float
xCenterInRect(NSSize innerSize, NSRect outerRect)
{ {
return MAX(NSMidX(outerRect) - (innerSize.width/2.0), 0.0); return MAX(NSMidX(outerRect) - (innerSize.width/2.0), 0.0);
} }
static inline float xRightInRect(NSSize innerSize, NSRect outerRect) static inline float
xRightInRect(NSSize innerSize, NSRect outerRect)
{ {
return MAX(NSMaxX(outerRect) - innerSize.width, 0.0); return MAX(NSMaxX(outerRect) - innerSize.width, 0.0);
} }
static inline float yTopInRect(NSSize innerSize, NSRect outerRect, BOOL flipped) static inline float
yTopInRect(NSSize innerSize, NSRect outerRect, BOOL flipped)
{ {
if (flipped) if (flipped)
return NSMinY(outerRect); return NSMinY(outerRect);
@ -171,12 +177,14 @@ static inline float yTopInRect(NSSize innerSize, NSRect outerRect, BOOL flipped)
return MAX(NSMaxY(outerRect) - innerSize.height, 0.0); return MAX(NSMaxY(outerRect) - innerSize.height, 0.0);
} }
static inline float yCenterInRect(NSSize innerSize, NSRect outerRect, BOOL flipped) static inline float
yCenterInRect(NSSize innerSize, NSRect outerRect, BOOL flipped)
{ {
return MAX(NSMidY(outerRect) - innerSize.height/2.0, 0.0); return MAX(NSMidY(outerRect) - innerSize.height/2.0, 0.0);
} }
static inline float yBottomInRect(NSSize innerSize, NSRect outerRect, BOOL flipped) rtatic inline float
yBottomInRect(NSSize innerSize, NSRect outerRect, BOOL flipped)
{ {
if (flipped) if (flipped)
return MAX(NSMaxY(outerRect) - innerSize.height, 0.0); return MAX(NSMaxY(outerRect) - innerSize.height, 0.0);
@ -184,13 +192,14 @@ static inline float yBottomInRect(NSSize innerSize, NSRect outerRect, BOOL flipp
return NSMinY(outerRect); return NSMinY(outerRect);
} }
static inline NSSize scaleProportionally(NSSize imageSize, NSRect canvasRect) static inline NSSize
scaleProportionally(NSSize imageSize, NSRect canvasRect)
{ {
float ratio; float ratio;
// get the smaller ratio and scale the image size by it // get the smaller ratio and scale the image size by it
ratio = MIN(NSWidth(canvasRect) / imageSize.width, ratio = MIN(NSWidth(canvasRect) / imageSize.width,
NSHeight(canvasRect) / imageSize.height); NSHeight(canvasRect) / imageSize.height);
imageSize.width *= ratio; imageSize.width *= ratio;
imageSize.height *= ratio; imageSize.height *= ratio;
@ -200,9 +209,9 @@ static inline NSSize scaleProportionally(NSSize imageSize, NSRect canvasRect)
- (void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView *)controlView - (void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView *)controlView
{ {
NSImage *image; NSImage *image;
NSPoint position; NSPoint position;
BOOL is_flipped = [controlView isFlipped]; BOOL is_flipped = [controlView isFlipped];
NSDebugLLog(@"NSImageCell", @"NSImageCell drawInteriorWithFrame called"); NSDebugLLog(@"NSImageCell", @"NSImageCell drawInteriorWithFrame called");