Re: Using selectedMenuItemColor
Re: Using selectedMenuItemColor
- Subject: Re: Using selectedMenuItemColor
- From: Eric Gorr <email@hidden>
- Date: Sun, 10 Apr 2011 22:32:29 -0400
On Apr 10, 2011, at 10:09 PM, Graham Cox wrote:
>
> On 11/04/2011, at 11:33 AM, Eric Gorr wrote:
>
>> Hummm...I can't seem to get it to do much. If I alter the code to:
>
>
> Have you tried using NSAffineTransform to offset the coordinate system to where you want to draw? You probably don't need or want to mess with your view coordinates or frame, you just need to move the coordinate system around within the view using the CTM.
>
> e.g. if you want to highlight the rect <hr> (typed into mail, untested):
>
> NSRect hr = NSMakeRect( 100, 100, 200, 120 );
>
> [NSGraphicsContext saveGraphicsState];
>
> NSAffineTransform* tfm = [NSAffineTransform transform];
> [tfm translateXBy:hr.origin.x yBy:hr.origin.y];
> [tfm concat];
>
> hr.origin = NSZeroPoint;
>
> NSRectFill( hr );
>
> [NSGraphicsContext restoreGraphicsState];
>
> So you offset to the rect origin, then draw at 0,0.
Thanks Graham.
I changed the code to:
for ( x = 0; x < 10; x++ )
{
blockFrame.origin.x = ( x * xOffset ) + NSMinX( secondThird );
blockFrame.origin.y = ( x * yOffset );
[NSGraphicsContext saveGraphicsState];
NSAffineTransform* tfm = [NSAffineTransform transform];
[tfm translateXBy:blockFrame.origin.x yBy:blockFrame.origin.y];
[tfm concat];
blockFrame.origin = NSZeroPoint;
NSRectFill( blockFrame );
[NSGraphicsContext restoreGraphicsState];
}
However, it had no effect.
I'll keep playing with this until a solution is found - if there is one.
Oh, I did figure out that, after calling setBoundsOrigin, to have the rectangle filled with something other then black, one needs to call [[NSColor selectedMenuItemColor] set] again. But, I still couldn't get it to do what I wanted it to do.
Seems to be an interesting problem. Perhaps the only solution is the NSImage route...
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden