Re: Scaled image in NSButtonCell flipped - drawInRect:
Re: Scaled image in NSButtonCell flipped - drawInRect:
- Subject: Re: Scaled image in NSButtonCell flipped - drawInRect:
- From: Ricky Sharp <email@hidden>
- Date: Tue, 3 Jan 2006 18:42:16 -0600
On Jan 3, 2006, at 5:13 PM, Richard Salvatierra wrote:
I have been searching the lists for days now and can not seem to
solve me problem.
I have an NSButtonCell subclass in order to build my own layout
within an NSMatrix and
be able to scale the buttonCells. (adding colums/rows as needed)
I override:
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)
controlView
Within, I draw an image using:
[image drawInRect: cellFrame fromRect: NSZeroRect operation:
NSCompositeSourceIn fraction: 1.0];
in order to scale the image with the scaling cellFrame
My problem is the image is flipped. Using the drawInRect, [image
setFlipped:YES] will not work.
I have dabbled with NSAffineTransform but am having trouble
effecting each cell individually.
It appears most people simply use drawAtPoint but I need drawInRect
to scale.
I also do scaling and here's what I currently do in an NSActionCell
subclass:
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)
controlView
{
...
if ([controlView isFlipped])
{
NSAffineTransform* theAffineTransform = [NSAffineTransform
transform];
[theAffineTransform scaleXBy:1.0 yBy:-1.0];
[theAffineTransform translateXBy:0.0 yBy:-
cellFrame.size.height];
[theAffineTransform concat];
}
//draw image here
}
I haven't used NSImage's setFlipped: in a while, but you should call
it like this:
[image setFlipped:[controlView isFlipped]];
That way, your cell will do the right thing in flipped and non-
flipped containers.
Also, I think in your drawInRect:, you may need to translate the y-
coords of the rect you pass in.
___________________________________________________________
Ricky A. Sharp mailto:email@hidden
Instant Interactive(tm) http://www.instantinteractive.com
_______________________________________________
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