mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-03 17:00:42 +00:00
Removed [initImageCell:], [dealloc], [cellSizeForBounds:] and
[copyWithZone:], which where only super calls. In [drawWithFrame:inView:] lockFocus only around drawing code and check for invalid window. In [drawInteriorWithFrame:inView:] lockFocus only around drawing code, check for invalid window, use NSCompositeSourceOver instead of NSCompositeCopy and show first responder state. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@10687 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
614c80bae2
commit
e6320bce97
1 changed files with 16 additions and 37 deletions
|
@ -56,19 +56,6 @@
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initImageCell: (NSImage *)anImage
|
|
||||||
{
|
|
||||||
NSDebugLLog(@"NSImageCell", @"NSImageCell -initImageCell");
|
|
||||||
[super initImageCell: anImage];
|
|
||||||
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) dealloc
|
|
||||||
{
|
|
||||||
[super dealloc];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) setImage:(NSImage *)anImage
|
- (void) setImage:(NSImage *)anImage
|
||||||
{
|
{
|
||||||
[super setImage:anImage];
|
[super setImage:anImage];
|
||||||
|
@ -109,6 +96,8 @@
|
||||||
|
|
||||||
- (void) setImageFrameStyle: (NSImageFrameStyle)aFrameStyle
|
- (void) setImageFrameStyle: (NSImageFrameStyle)aFrameStyle
|
||||||
{
|
{
|
||||||
|
// We could set _cell.is_bordered and _cell.is_bezeled here to reflect
|
||||||
|
// the border type, but this wont be used.
|
||||||
_frameStyle = aFrameStyle;
|
_frameStyle = aFrameStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,10 +109,9 @@
|
||||||
NSDebugLLog(@"NSImageCell", @"NSImageCell -drawWithFrame");
|
NSDebugLLog(@"NSImageCell", @"NSImageCell -drawWithFrame");
|
||||||
|
|
||||||
// do nothing if cell's frame rect is zero
|
// do nothing if cell's frame rect is zero
|
||||||
if (NSIsEmptyRect(cellFrame))
|
if (NSIsEmptyRect(cellFrame) || ![controlView window])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
[controlView lockFocus];
|
|
||||||
// draw the border if needed
|
// draw the border if needed
|
||||||
switch (_frameStyle)
|
switch (_frameStyle)
|
||||||
{
|
{
|
||||||
|
@ -134,18 +122,23 @@
|
||||||
// FIXME
|
// FIXME
|
||||||
break;
|
break;
|
||||||
case NSImageFrameGrayBezel:
|
case NSImageFrameGrayBezel:
|
||||||
|
[controlView lockFocus];
|
||||||
NSDrawGrayBezel(cellFrame, NSZeroRect);
|
NSDrawGrayBezel(cellFrame, NSZeroRect);
|
||||||
|
[controlView unlockFocus];
|
||||||
break;
|
break;
|
||||||
case NSImageFrameGroove:
|
case NSImageFrameGroove:
|
||||||
|
[controlView lockFocus];
|
||||||
NSDrawGroove(cellFrame, NSZeroRect);
|
NSDrawGroove(cellFrame, NSZeroRect);
|
||||||
|
[controlView unlockFocus];
|
||||||
break;
|
break;
|
||||||
case NSImageFrameButton:
|
case NSImageFrameButton:
|
||||||
|
[controlView lockFocus];
|
||||||
NSDrawButton(cellFrame, NSZeroRect);
|
NSDrawButton(cellFrame, NSZeroRect);
|
||||||
|
[controlView unlockFocus];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
[self drawInteriorWithFrame: cellFrame inView: controlView];
|
[self drawInteriorWithFrame: cellFrame inView: controlView];
|
||||||
[controlView unlockFocus];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline float
|
static inline float
|
||||||
|
@ -213,12 +206,11 @@ scaleProportionally(NSSize imageSize, NSRect canvasRect)
|
||||||
|
|
||||||
NSDebugLLog(@"NSImageCell", @"NSImageCell drawInteriorWithFrame called");
|
NSDebugLLog(@"NSImageCell", @"NSImageCell drawInteriorWithFrame called");
|
||||||
|
|
||||||
if (!_cell_image)
|
if (![controlView window] || !_cell_image)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// leave room for the frame
|
// leave room for the frame
|
||||||
cellFrame = [self drawingRectForBounds: cellFrame];
|
cellFrame = [self drawingRectForBounds: cellFrame];
|
||||||
[controlView lockFocus];
|
|
||||||
|
|
||||||
switch (_imageScaling)
|
switch (_imageScaling)
|
||||||
{
|
{
|
||||||
|
@ -298,7 +290,12 @@ scaleProportionally(NSSize imageSize, NSRect canvasRect)
|
||||||
position.y += imageSize.height;
|
position.y += imageSize.height;
|
||||||
|
|
||||||
// draw!
|
// draw!
|
||||||
[_cell_image compositeToPoint: position operation: NSCompositeCopy];
|
[controlView lockFocus];
|
||||||
|
[_cell_image compositeToPoint: position operation: NSCompositeSourceOver];
|
||||||
|
|
||||||
|
if (_cell.shows_first_responder)
|
||||||
|
NSDottedFrameRect(cellFrame);
|
||||||
|
|
||||||
[controlView unlockFocus];
|
[controlView unlockFocus];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,12 +330,6 @@ scaleProportionally(NSSize imageSize, NSRect canvasRect)
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSSize) cellSizeForBounds: (NSRect)aRect
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
return NSZeroSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSRect) drawingRectForBounds: (NSRect)theRect
|
- (NSRect) drawingRectForBounds: (NSRect)theRect
|
||||||
{
|
{
|
||||||
NSSize borderSize;
|
NSSize borderSize;
|
||||||
|
@ -363,18 +354,6 @@ scaleProportionally(NSSize imageSize, NSRect canvasRect)
|
||||||
return NSInsetRect (theRect, borderSize.width, borderSize.height);
|
return NSInsetRect (theRect, borderSize.width, borderSize.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) copyWithZone: (NSZone *)zone
|
|
||||||
{
|
|
||||||
NSImageCell *c = [super copyWithZone: zone];
|
|
||||||
|
|
||||||
//c->_imageAlignment = _imageAlignment;
|
|
||||||
//c->_frameStyle = _frameStyle;
|
|
||||||
//c->_imageScaling = _imageScaling;
|
|
||||||
//c->_original_image_size = _original_image_size;
|
|
||||||
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// NSCoding protocol
|
// NSCoding protocol
|
||||||
//
|
//
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue