Re: erasing, redrawing NSBezierPath into and NSImage problem
Re: erasing, redrawing NSBezierPath into and NSImage problem
- Subject: Re: erasing, redrawing NSBezierPath into and NSImage problem
- From: Wilhelm Phillips <email@hidden>
- Date: Tue, 6 Jul 2004 15:29:33 -0700
Thanks for taking to time to follow up on this with me. I'm a bit
confused now.
When the application first launches it draws all the labels correctly
(i.e. sized to fit the cells in labelMatrix and with a properly shaped
beziePath) using the same call to drawLabels. So, I assume that my
drawing code does works correctly.
It's only upon resizing labelMatrix that the call to drawLabels doesn't
seem to accurately reflect the correctly sized and shaped bezierPath
for the labelMatrix cells which have setImage: someLabel.
Are you saying that if 10 cells have there image set to someLabel and
then I draw into someLabel it won't update the images in the
labelMatrix - even with [labelMatrix setNeedsDisplay: YES]?
And you are also saying that I should not have my init code in the
drawLabels method? If I move my initialization to awakeFromNib, and
the call drawLabels they never get drawn.
i.e. this doesn't work:
- (void)awakeFromNib
{
someLabel = [[NSImage alloc] initWithSize:NSMakeSize(cWidth, cHeight)];
[someLabel setName:@"SomeLabel"];
[self drawLabels];
}
- (void)drawLabels
{
[someLabel lockFocus];
// draw bezierPath into someLabel
[someLabel unlockFocus];
[self fillLabelMatrix];
[labelMatrix setNeedsDisplay: YES];
}
but this does work on launch:
- (void)awakeFromNib
{
[self drawLabels];
}
- (void)drawLabels
{
someLabel = [[NSImage alloc] initWithSize:NSMakeSize(cWidth, cHeight)];
[someLabel setName:@"SomeLabel"];
[someLabel lockFocus];
// draw bezierPath into someLabel
[someLabel unlockFocus];
[labelMatrix setNeedsDisplay: YES];
}
and neither seem to work for redrawing the adjusted bezierPath into
someLabel upon labelMatrix resizing.
Will
On Jul 6, 2004, at 1:09 PM, Louis C. Sacha wrote:
>
Hello...
>
>
It looks like you are creating a new image every time drawLabels is
>
called, and you aren't doing anything with it.
>
>
Instead of creating a new image, you need to either somehow get a
>
reference to the existing images being used in the matrix and do your
>
redrawing in those images, or after you've created and drawn the
>
images you need to tell the matrix to use them instead of the old
>
images.
>
>
Hope that helps,
>
>
Louis
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.