Re: Setting a custom NSImageCell
Re: Setting a custom NSImageCell
- Subject: Re: Setting a custom NSImageCell
- From: Jim Turner <email@hidden>
- Date: Mon, 17 Apr 2006 12:07:38 -0500
- Thread-topic: Setting a custom NSImageCell
Wow, how embarrassing... I stared at this for a good 10 hours and never once
saw the + in front of setCellClass in the docs. Thanks, Mike! And for the
archive¹s sake, I had to move the assignment into my view¹s initialize
method as by the time awakeFromNib occurs, the cell has already been set.
Also, I got a very helpful bit of code from John Pannell for creating a
view-size image to drag:
[desiredView lockFocus];
NSBitmapImageRep *rep = [[NSBitmapImageRep alloc]
initWithFocusedViewRect:[desiredView bounds]];
[desiredView unlockFocus];
NSImage *dragImage = [[[NSImage alloc] initWithSize:[rep size]]
autorelease];
[dragImage addRepresentation:rep];
Thanks again to both of you.
Jim Turner
email@hidden
On 4/17/06 11:19 AM, "Mike Abdullah" <email@hidden> wrote:
> setCellClass: is a class method, not an instance method. You need to do
> something like:
>
> [JTImageView setCellClass: [JTImageCell class]];
>
> Mike.
>
> On 17 Apr 2006, at 15:30PM, Jim Turner wrote:
>
>> I'm confused, please help...
>>
>> I have a custom view with a subclass of NSImageView assigned to it. I load
>> images into it that I read from a database. The process works like a champ.
>> I can then drag said image from this view into Photoshop et al and diddle
>> it.
>>
>> The problem I have is in composing the drag image when the source image is
>> larger than the view. I'd like to know the size of the scaled image
>> contained in my view and build my drag image to that size (so it doesn't
>> fill the entire screen, like some of my images tend to do). NSImageCell
>> knows this value, but "/*All instance variables are private*/", according to
>> the header file.
>>
>> So I subclass NSImageCell in IB and create a method to return this value. I
>> then do this in my NSImageView subclass (which, according to the
>> documentation, seemed like the right thing to do):
>>
>> - (void) awakeFromNib
>> {
>> [self setCellClass:[JTImageCell class]];
>> }
>>
>> But what I'm getting when I compile this is that JTImageView may not respond
>> to -setCellClass. Why is this? If I inherit from NSImageView, which
>> inherits from NSControl, shouldn't I get access to -setCellClass? Or do I
>> need to implement a setCellClass in my JTImageView that does this since I'm
>> working with a custom NSImageView?
>>
>> As always, I appreciate any ideas. Thank you.
>>
>>
>> --
>> Jim Turner
>> email@hidden
>>
>> _______________________________________________
>> 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
>>
>
>
--
Jim Turner
Programmer/Analyst
The Des Moines Register
515/284-8223
email@hidden
_______________________________________________
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