NSCell, Matrix, coordinate system
NSCell, Matrix, coordinate system
- Subject: NSCell, Matrix, coordinate system
- From: Todd Heberlein <email@hidden>
- Date: Tue, 28 May 2002 15:38:06 -0700
Probably a silly question, but I have not been able to find the answer.
I want a matrix of my own buttons. I created subclasses of NSMatrix and
NSButtonCell, and I overrode initWithFrame:frameRect for MyMatrix that
calls initWithFrame:mode:prototype:numberOfRows:numberOfColumns: with an
instance of my own button cell class.
I also overrode drawWithFrame:inView: for MyButtonCell, and what I
found is that controlView's Y coordinate system (which is the view I
presume I am drawing in) is flipped.
Unfortunately, when I try to composite an NSImage into the area defined
by cellFrame (i.e., where the button image is supposed to be drawn) with
compositeToPoint: operation: the image is drawn above the appropriate
button area. This seems to be because the image is drawn assuming that
the coordinate system is *not* flipped.
I have set the image's flipped value, but that did not help.
I have found that by simply adding the cellFrame.size.height to the
point's y value, the image composite to the right place. For example,
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
...
my_point = cellFrame.origin;
my_point.y += cellFrame.size.height;
[p_image compositeToPoint: my_point operation:
NSCompositeSourceOver];
...
}
But this seems like such a hack. Is there a more appropriate way to get
my image to composite correctly into my NSMatrix subclass (with its
flipped coordinate system)?
Thanks,
Todd
_______________________________________________
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.