Re: NSImageView only for images?
Re: NSImageView only for images?
- Subject: Re: NSImageView only for images?
- From: "M. Uli Kusterer" <email@hidden>
- Date: Sat, 12 Feb 2005 15:18:30 +0100
At 14:10 Uhr +0100 12.02.2005, Joe Maffia wrote:
I'm using NSImageView for drag images on my app, is it possible to
use also for drag files?
It's only intended as an image container. If you want the same
border around an area for, e.g. a file, you need to create your own
custom view that looks this way.
Don't bother trying to use Carbon's HIThemeDrawGenericWell() to draw
the inset area, though. Right now this will give you a border, but
won't fill its inside with the right color. And as there seems to be
no pre-defined NSColor for an image well's fill, it's impossible to
draw the content color yourself in a future-safe way.
What seems to work, however, is to create your own NSControl subclass
and set its view to one that does whatever you want (e.g. my
UKFinderIconCell class that is part of UKDistributedView -
NSButtonCell seems to insist on erasing its background, so won't
work). Use the following drawRect method:
-(void) drawRect: (NSRect)dirtyArea
{
NSImageCell* borderCell = [[[NSImageCell alloc] initImageCell:
[[[NSImage alloc] initWithSize: NSMakeSize(2,2)] autorelease]]
autorelease];
[borderCell setImageFrameStyle: NSImageFrameGrayBezel];
[borderCell drawWithFrame: [self bounds] inView: self];
[self drawCellInside: [self cell]];
}
This will abuse an NSImageCell with an empty image to draw the inset
well, and then call NSControl to draw the actual cell.
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden