Image cache tidyup

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5345 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 1999-12-01 13:49:47 +00:00
parent f2bcb34b09
commit 804630d3ae
3 changed files with 277 additions and 306 deletions

View file

@ -120,29 +120,29 @@
[self setControlView: controlView];
// do nothing if cell's frame rect is zero
if( NSIsEmptyRect(cellFrame) )
if (NSIsEmptyRect(cellFrame))
return;
[controlView lockFocus];
// draw the border if needed
switch( [self imageFrameStyle] )
{
case NSImageFrameNone:
// nada
break;
case NSImageFramePhoto:
// what does this one look like? TODO (in sync with the rest of the code)
break;
case NSImageFrameGrayBezel:
NSDrawGrayBezel(cellFrame, NSZeroRect);
break;
case NSImageFrameGroove:
NSDrawGroove(cellFrame, NSZeroRect);
break;
case NSImageFrameButton:
NSDrawButton(cellFrame, NSZeroRect);
break;
}
switch ([self imageFrameStyle])
{
case NSImageFrameNone:
// nada
break;
case NSImageFramePhoto:
// FIXME
break;
case NSImageFrameGrayBezel:
NSDrawGrayBezel(cellFrame, NSZeroRect);
break;
case NSImageFrameGroove:
NSDrawGroove(cellFrame, NSZeroRect);
break;
case NSImageFrameButton:
NSDrawButton(cellFrame, NSZeroRect);
break;
}
[self drawInteriorWithFrame: cellFrame inView: controlView];
[controlView unlockFocus];
@ -165,7 +165,7 @@ static inline float xRightInRect(NSSize innerSize, NSRect outerRect)
static inline float yTopInRect(NSSize innerSize, NSRect outerRect, BOOL flipped)
{
if( flipped )
if (flipped)
return NSMinY(outerRect);
else
return MAX(NSMaxY(outerRect) - innerSize.height, 0.0);
@ -178,7 +178,7 @@ static inline float yCenterInRect(NSSize innerSize, NSRect outerRect, BOOL flipp
static inline float yBottomInRect(NSSize innerSize, NSRect outerRect, BOOL flipped)
{
if( flipped )
if (flipped)
return MAX(NSMaxY(outerRect) - innerSize.height, 0.0);
else
return NSMinY(outerRect);
@ -207,85 +207,85 @@ static inline NSSize scaleProportionally(NSSize imageSize, NSRect canvasRect)
NSDebugLLog(@"NSImageCell", @"NSImageCell drawInteriorWithFrame called");
image = [self image];
if( !image )
if (!image)
return;
// leave room for the frame
cellFrame = [self drawingRectForBounds: cellFrame];
[controlView lockFocus];
switch( [self imageScaling] )
{
case NSScaleProportionally:
switch ([self imageScaling])
{
NSDebugLLog(@"NSImageCell", @"NSScaleProportionally");
[image setScalesWhenResized:YES];
[image setSize: scaleProportionally(_original_image_size, cellFrame)];
break;
case NSScaleProportionally:
{
NSDebugLLog(@"NSImageCell", @"NSScaleProportionally");
[image setScalesWhenResized:YES];
[image setSize: scaleProportionally(_original_image_size, cellFrame)];
break;
}
case NSScaleToFit:
{
NSDebugLLog(@"NSImageCell", @"NSScaleToFit");
[image setScalesWhenResized:YES];
[image setSize: cellFrame.size];
break;
}
case NSScaleNone:
{
NSDebugLLog(@"NSImageCell", @"NSScaleNone");
[image setScalesWhenResized:NO];
// don't let the image size overrun the space available
if (_original_image_size.width > cellFrame.size.width
|| _original_image_size.height > cellFrame.size.height)
[image setSize: cellFrame.size];
else
[image setSize: _original_image_size];
break;
}
}
case NSScaleToFit:
{
NSDebugLLog(@"NSImageCell", @"NSScaleToFit");
[image setScalesWhenResized:YES];
[image setSize: cellFrame.size];
break;
}
case NSScaleNone:
{
NSDebugLLog(@"NSImageCell", @"NSScaleNone");
[image setScalesWhenResized:NO];
// don't let the image size overrun the space available
if( _original_image_size.width > cellFrame.size.width ||
_original_image_size.height > cellFrame.size.height )
[image setSize: cellFrame.size];
else
[image setSize: _original_image_size];
break;
}
}
switch( [self imageAlignment] )
{
case NSImageAlignLeft:
position.x = xLeftInRect([image size], cellFrame);
position.y = yCenterInRect([image size], cellFrame, is_flipped);
break;
case NSImageAlignRight:
position.x = xRightInRect([image size], cellFrame);
position.y = yCenterInRect([image size], cellFrame, is_flipped);
break;
case NSImageAlignCenter:
position.x = xCenterInRect([image size], cellFrame);
position.y = yCenterInRect([image size], cellFrame, is_flipped);
break;
case NSImageAlignTop:
position.x = xCenterInRect([image size], cellFrame);
position.y = yTopInRect([image size], cellFrame, is_flipped);
break;
case NSImageAlignBottom:
position.x = xCenterInRect([image size], cellFrame);
position.y = yBottomInRect([image size], cellFrame, is_flipped);
break;
case NSImageAlignTopLeft:
position.x = xLeftInRect([image size], cellFrame);
position.y = yTopInRect([image size], cellFrame, is_flipped);
break;
case NSImageAlignTopRight:
position.x = xRightInRect([image size], cellFrame);
position.y = yTopInRect([image size], cellFrame, is_flipped);
break;
case NSImageAlignBottomLeft:
position.x = xLeftInRect([image size], cellFrame);
position.y = yBottomInRect([image size], cellFrame, is_flipped);
break;
case NSImageAlignBottomRight:
position.x = xRightInRect([image size], cellFrame);
position.y = yBottomInRect([image size], cellFrame, is_flipped);
break;
}
switch ([self imageAlignment])
{
case NSImageAlignLeft:
position.x = xLeftInRect([image size], cellFrame);
position.y = yCenterInRect([image size], cellFrame, is_flipped);
break;
case NSImageAlignRight:
position.x = xRightInRect([image size], cellFrame);
position.y = yCenterInRect([image size], cellFrame, is_flipped);
break;
case NSImageAlignCenter:
position.x = xCenterInRect([image size], cellFrame);
position.y = yCenterInRect([image size], cellFrame, is_flipped);
break;
case NSImageAlignTop:
position.x = xCenterInRect([image size], cellFrame);
position.y = yTopInRect([image size], cellFrame, is_flipped);
break;
case NSImageAlignBottom:
position.x = xCenterInRect([image size], cellFrame);
position.y = yBottomInRect([image size], cellFrame, is_flipped);
break;
case NSImageAlignTopLeft:
position.x = xLeftInRect([image size], cellFrame);
position.y = yTopInRect([image size], cellFrame, is_flipped);
break;
case NSImageAlignTopRight:
position.x = xRightInRect([image size], cellFrame);
position.y = yTopInRect([image size], cellFrame, is_flipped);
break;
case NSImageAlignBottomLeft:
position.x = xLeftInRect([image size], cellFrame);
position.y = yBottomInRect([image size], cellFrame, is_flipped);
break;
case NSImageAlignBottomRight:
position.x = xRightInRect([image size], cellFrame);
position.y = yBottomInRect([image size], cellFrame, is_flipped);
break;
}
// account for flipped views
if( is_flipped )
if (is_flipped)
position.y += [image size].height;
// draw!
@ -300,18 +300,18 @@ static inline NSSize scaleProportionally(NSSize imageSize, NSRect canvasRect)
// Get border size
switch (_frameStyle)
{
case NSImageFrameNone:
borderSize = [NSCell sizeForBorderType: NSNoBorder];
break;
case NSImageFramePhoto:
// what does this one look like? TODO (in sync with the rest of the code)
borderSize = [NSCell sizeForBorderType: NSNoBorder];
break;
case NSImageFrameGrayBezel:
case NSImageFrameGroove:
case NSImageFrameButton:
borderSize = [NSCell sizeForBorderType: NSBezelBorder];
break;
case NSImageFrameNone:
borderSize = [NSCell sizeForBorderType: NSNoBorder];
break;
case NSImageFramePhoto:
// FIXME
borderSize = [NSCell sizeForBorderType: NSNoBorder];
break;
case NSImageFrameGrayBezel:
case NSImageFrameGroove:
case NSImageFrameButton:
borderSize = [NSCell sizeForBorderType: NSBezelBorder];
break;
}
// Get Content Size