• 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
Re: Rendering an NSControl into a NSImage? (resolved)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Rendering an NSControl into a NSImage? (resolved)


  • Subject: Re: Rendering an NSControl into a NSImage? (resolved)
  • From: "John C. Randolph" <email@hidden>
  • Date: Thu, 3 Apr 2003 12:20:08 -0800

On Wednesday, April 2, 2003, at 11:44 AM, Mark Alldritt wrote:

Hi,

Great thanks to John Randolph, Carl Norum, and Peter Mark. It was Peter
Mark's code that finally cracked the problem. The following code correctly
renders an NSControl into an NSImage. In the end, the only change from my
original code was to call [snapshot setFlipped:YES].

- (NSImage*) proxyImage
{
NSRect sourceRect = [self frame];
NSImage *snapshot = [[NSImage alloc] initWithSize:sourceRect.size];

One suggestion: test for whether self is flipped here, and then you have a general solution:

if ([self isFlipped])
[snapshot setFlipped:YES];
[snapshot lockFocus];
[self drawRect:sourceRect];
[snapshot unlockFocus];

return [snapshot autorelease];
}

For those that care, I've created a sample project that illustrates what
I've learned about how to use drag and drop to copy controls:

http://www.latenightsw.com/archives/ControlDragAndDrop.hqx

-jcr


John C. Randolph <email@hidden> (408) 974-8819
Sr. Cocoa Software Engineer,
Apple Worldwide Developer Relations
http://developer.apple.com/cocoa/index.html
_______________________________________________
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.

References: 
 >Re: Rendering an NSControl into a NSImage? (resolved) (From: Mark Alldritt <email@hidden>)

  • Prev by Date: import statement issues
  • Next by Date: Re: hasSuffix and new line characters.
  • Previous by thread: Re: Rendering an NSControl into a NSImage? (resolved)
  • Next by thread: SummaryService API?
  • Index(es):
    • Date
    • Thread