Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using Cocoa cursors in a Carbon world



Just to post an idea that I'm investigating. I see that the actual
"original" Cocoa cursor that I was discussing is created by creating an
NSImage and copying a CGImage into it via:

//    From "Cocoa Drawing Guide: Working with Images"
static NSImage    *CreateNSImageFromCGImage( CGImageRef image )
{
    NSAutoreleasePool* localPool = NULL;
    
    localPool = [[NSAutoreleasePool alloc] init];

    NSRect            imageRect        = NSMakeRect(0.0, 0.0, 0.0, 0.0);

    // Get the image dimensions.
    imageRect.size.height = CGImageGetHeight(image);
    imageRect.size.width = CGImageGetWidth(image);

    // Create a new image to receive the Quartz image data.
    NSImage    *newImage = [[NSImage alloc] initWithSize:imageRect.size];
    [newImage lockFocus];

    // Get the Quartz context and draw.
    CGContextRef    imageContext = (CGContextRef) [[NSGraphicsContext
currentContext] graphicsPort];
    CGContextDrawImage( imageContext, *(CGRect*)&imageRect, image );
    [newImage unlockFocus];

    [localPool release];
    
    return( newImage );
}


Could this be the problem? I'm going to look into it, but if let me know if
you *know* better ;)

I'll let you know what I find out.

Thanks,
Lyndsey

On 8/28/07 9:36 PM, "Lyndsey Ferguson" <email@hidden> wrote:

> Unfortunately, he's gone and we are experiencing some issues. It seems that
> on the PowerPC (Tiger and Leopard), when the application switches the cursor
> from a Carbon cursor (via MacGetCursor and MacSetCursor) to a Cocoa cursor
> (via NSImage to NSCursor and NSCursor's -set function) one can see a flicker
> of the Carbon cursor in the vicinity of the mouse position (not where the
> hotspot is).
> 
> I thought that perhaps the issue was switching between the two types. So as
> a test, I changed the code to not switch to a Carbon cursor ever, but switch
> to another Cocoa based cursor. Flicker was gone. Yay, I thought.

-- 
Mr. Lyndsey D. Ferguson
Software Engineer
Nemetschek N.A., Inc.
http://www.nemetschek.net


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden

References: 
 >Using Cocoa cursors in a Carbon world (From: Lyndsey Ferguson <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.