FROM : Mark Trombino
DATE : Wed Jan 29 19:27:36 2003
Hello,
I'm trying to subclass NSCell and I've ran into a bit of a problem when
trying to draw the cells. Essentially, nothing gets drawn! My cells
are used with an NSMatrix subclass. I'm overriding
drawInteriorWithFrame:inView: but I get crazy frame values whenever
this method gets called. My implementation:
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView
*)controlView
{
if([[self path] length])
{
NSImage *displayImage = [self _displayImageForPath:[self path]
withSize:cellFrame.size];
if(inDragLoop)
[displayImage compositeToPoint:cellFrame.origin
operation:NSCompositeSourceOver fraction:.5];
else
[displayImage compositeToPoint:cellFrame.origin
operation:NSCompositeSourceOver];
}
NSLog(@"%@: drawInteriorWithFrame:(%d, %d)", self,
cellFrame.origin.x, cellFrame.origin.y);
}
This generates the following for a 3 x 3 matrix:
2003-01-29 10:50:17.178 DragTest[16407] <MTFileMatrixCell: 0xc2990>:
drawInteriorWithFrame:(0, 0)
2003-01-29 10:50:17.179 DragTest[16407] <MTFileMatrixCell: 0xc2a50>:
drawInteriorWithFrame:(1079279616, 0)
2003-01-29 10:50:17.179 DragTest[16407] <MTFileMatrixCell: 0x23e450>:
drawInteriorWithFrame:(1080328192, 0)
2003-01-29 10:50:17.180 DragTest[16407] <MTFileMatrixCell: 0x23e4f0>:
drawInteriorWithFrame:(0, 0)
2003-01-29 10:50:17.181 DragTest[16407] <MTFileMatrixCell: 0x23e590>:
drawInteriorWithFrame:(1079279616, 0)
2003-01-29 10:50:17.181 DragTest[16407] <MTFileMatrixCell: 0x23e660>:
drawInteriorWithFrame:(1080328192, 0)
2003-01-29 10:50:17.181 DragTest[16407] <MTFileMatrixCell: 0x23e700>:
drawInteriorWithFrame:(0, 0)
2003-01-29 10:50:17.182 DragTest[16407] <MTFileMatrixCell: 0x23e7a0>:
drawInteriorWithFrame:(1079279616, 0)
2003-01-29 10:50:17.182 DragTest[16407] <MTFileMatrixCell: 0x23e840>:
drawInteriorWithFrame:(1080328192, 0)
I guess what I'm wondering is whether or not I have to do some sort of
conversion on cellFrame before using it? Is it supposed to be in the
NSControl's coordinate system? To be clear, I'm not getting sent my
bounds, but the frame of my cell in the NSControl's coordinate system,
yes?
Can cells know their frame other than by the cellFrame parameter? I
don't see a frame instance variable in the header file for NSCell so
I'm guessing not. I imagine that cells probably shouldn't need to know
their frame...
Really, all I want is something similar to a NSButtonCell that I can
drag and drop file images to and from. Perhaps I should subclass that
rather than NSActionCell?
This is a bit daunting to me, subclassing NSCell and trying to get it
to work with NSMatrix. If anyone has any pointers or good places for
info on the subject please let me know ;-)
Thank you!
Mark Trombino
<email_removed>
DATE : Wed Jan 29 19:27:36 2003
Hello,
I'm trying to subclass NSCell and I've ran into a bit of a problem when
trying to draw the cells. Essentially, nothing gets drawn! My cells
are used with an NSMatrix subclass. I'm overriding
drawInteriorWithFrame:inView: but I get crazy frame values whenever
this method gets called. My implementation:
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView
*)controlView
{
if([[self path] length])
{
NSImage *displayImage = [self _displayImageForPath:[self path]
withSize:cellFrame.size];
if(inDragLoop)
[displayImage compositeToPoint:cellFrame.origin
operation:NSCompositeSourceOver fraction:.5];
else
[displayImage compositeToPoint:cellFrame.origin
operation:NSCompositeSourceOver];
}
NSLog(@"%@: drawInteriorWithFrame:(%d, %d)", self,
cellFrame.origin.x, cellFrame.origin.y);
}
This generates the following for a 3 x 3 matrix:
2003-01-29 10:50:17.178 DragTest[16407] <MTFileMatrixCell: 0xc2990>:
drawInteriorWithFrame:(0, 0)
2003-01-29 10:50:17.179 DragTest[16407] <MTFileMatrixCell: 0xc2a50>:
drawInteriorWithFrame:(1079279616, 0)
2003-01-29 10:50:17.179 DragTest[16407] <MTFileMatrixCell: 0x23e450>:
drawInteriorWithFrame:(1080328192, 0)
2003-01-29 10:50:17.180 DragTest[16407] <MTFileMatrixCell: 0x23e4f0>:
drawInteriorWithFrame:(0, 0)
2003-01-29 10:50:17.181 DragTest[16407] <MTFileMatrixCell: 0x23e590>:
drawInteriorWithFrame:(1079279616, 0)
2003-01-29 10:50:17.181 DragTest[16407] <MTFileMatrixCell: 0x23e660>:
drawInteriorWithFrame:(1080328192, 0)
2003-01-29 10:50:17.181 DragTest[16407] <MTFileMatrixCell: 0x23e700>:
drawInteriorWithFrame:(0, 0)
2003-01-29 10:50:17.182 DragTest[16407] <MTFileMatrixCell: 0x23e7a0>:
drawInteriorWithFrame:(1079279616, 0)
2003-01-29 10:50:17.182 DragTest[16407] <MTFileMatrixCell: 0x23e840>:
drawInteriorWithFrame:(1080328192, 0)
I guess what I'm wondering is whether or not I have to do some sort of
conversion on cellFrame before using it? Is it supposed to be in the
NSControl's coordinate system? To be clear, I'm not getting sent my
bounds, but the frame of my cell in the NSControl's coordinate system,
yes?
Can cells know their frame other than by the cellFrame parameter? I
don't see a frame instance variable in the header file for NSCell so
I'm guessing not. I imagine that cells probably shouldn't need to know
their frame...
Really, all I want is something similar to a NSButtonCell that I can
drag and drop file images to and from. Perhaps I should subclass that
rather than NSActionCell?
This is a bit daunting to me, subclassing NSCell and trying to get it
to work with NSMatrix. If anyone has any pointers or good places for
info on the subject please let me know ;-)
Thank you!
Mark Trombino
<email_removed>
| Related mails | Author | Date |
|---|---|---|
| Mark Trombino | Jan 29, 19:27 | |
| Timothy Ritchey | Jan 29, 19:51 | |
| Mark Trombino | Jan 29, 23:58 | |
| Timothy Ritchey | Jan 30, 07:43 |






Cocoa mail archive

