• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSCell, Matrix, coordinate system
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Prev by Date: Re: Handling a mouse event
  • Next by Date: Re: Saving a NSMutableArray into a plain ASCII file
  • Previous by thread: Re: Saving a NSMutableArray into a plain ASCII file
  • Next by thread: Re: NSCell, Matrix, coordinate system
  • Index(es):
    • Date
    • Thread