Re: Incorrect flipping when manually drawing NSCells (was: Fwd: -isFlipped not working right when drawing IconAndTextCell to NSImage)
Re: Incorrect flipping when manually drawing NSCells (was: Fwd: -isFlipped not working right when drawing IconAndTextCell to NSImage)
- Subject: Re: Incorrect flipping when manually drawing NSCells (was: Fwd: -isFlipped not working right when drawing IconAndTextCell to NSImage)
- From: Matt Neuburg <email@hidden>
- Date: Wed, 03 May 2006 09:10:02 -0700
- Thread-topic: Incorrect flipping when manually drawing NSCells (was: Fwd: -isFlipped not working right when drawing IconAndTextCell to NSImage)
On Mon, 1 May 2006 02:50:33 -0400, Scott Anguish <email@hidden> said:
>The doc knows all
>
>Bottom of this page
>
>Coordinate Systems Basics
>
>http://developer.apple.com/documentation/Cocoa/Conceptual/
>CocoaDrawingGuide/Transforms/chapter_4_section_2.html#//apple_ref/doc/
>uid/TP40003290-CH204-BCIFCIHJ
>
>and here
>
>Drawing in Flipped Coordinate Systems
>
>http://developer.apple.com/documentation/Cocoa/Conceptual/
>CocoaDrawingGuide/Transforms/chapter_4_section_5.html#//apple_ref/doc/
>uid/TP40003290-CH204-BCIBJBGC
Great docs; definitely a vast improvement. Even so (returning to the
original question), it is quite true that the combination of views that are
flipped and unflipped with drawn-things that do or don't compensate for
flippedness (e.g. the text system) can drive you mad. It took me two days of
experimentation to create the NSCells in the lower part of the NotLight
window, and in the end my solution was purely practical - I still don't
understand how it works. (I call this "programming by whacking with a
hammer", my favorite method.) I found it easiest to draw into an NSImage and
use that as the sole basis for the contents of the NSCell; you (Lawrence)
might want to do this with you custom cell too, because once you have the
NSImage, then you can draw it to the cell or to the drag image, as desired.
m.
>On Apr 29, 2006, at 6:47 PM, Lawrence Sanbourne wrote:
>
>> Hello again,
>>
>> After some more testing, I've determined that this also happens with
>> other NSCells besides IconAndTextCell. In particular, I get the same
>> behavior with a custom cell I wrote myself. (It's viewed in an
>> NSMatrix subclass.)
>>
>> So, what am I doing wrong when I try to draw NSCells to images?
>>
>> // Draw cell in cellImage.
>> BOOL highlighted = [cell isHighlighted];
>> [cell setHighlighted:NO];
>>
>> [cellImage lockFocus];
>> [cell drawWithFrame:cellDrawingFrame inView:self]; // self is the
>> NSControl containing the cell
>> [cellImage unlockFocus];
>> [cell setHighlighted:highlighted];
>>
>> Somehow, if the cell draws text, it comes out OK. But if the cell
>> draws images, they come out flipped.
>>
>> Does this help? Any ideas?
>>
>> Larry
>>
>> ---------- Forwarded message ----------
>> From: Lawrence Sanbourne <email@hidden>
>> Date: Apr 28, 2006 8:13 PM
>> Subject: -isFlipped not working right when drawing IconAndTextCell
>> to NSImage
>> To: Apple Mailing List <email@hidden>
>>
>>
>> Hello,
>>
>> I'm fairly new to Cocoa drawing, and I'm having a problem with
>> -isFlipped that I haven't been able to figure out. From a subclass of
>> NSTableView, I'm drawing one of the table's IconAndTextCell objects
>> into an NSImage to create a custom drag image:
>>
>> - (NSImage *)dragImageForRowsWithIndexes:(NSIndexSet *)dragRows
>> tableColumns:(NSArray *)tableColumns event:(NSEvent *)dragEvent
>> offset:(NSPointPointer)dragImageOffset {
>> //...
>> [dragImage lockFocus];
>> [cell drawWithFrame:cellDrawingFrame inView:self];
>> [dragImage unlockFocus];
>> //...
>> return dragImage;
>> }
>>
>> IconAndTextCell is careful to check the -isFlipped status of its
>> controlView. However, this is causing the icon in the cell to draw in
>> the wrong place. If I negate the conditional on the if([controlView
>> isFlipped]) in IconAndTextCell, the problem is fixed for drag images
>> -- but then of course all the other IconAndTextCells look weird.
>>
>> What am I doing wrong?
>>
>> Larry
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Cocoa-dev mailing list (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>
>
>
>
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden