• 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
Fwd: displaying an NSImage in custom NSView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fwd: displaying an NSImage in custom NSView


  • Subject: Fwd: displaying an NSImage in custom NSView
  • From: "Bill So" <email@hidden>
  • Date: Wed, 9 Aug 2006 09:57:34 +0800

Dear All,

I m playing around with the graphics related APIs in Cocoa.  And, I
encountered a problem to display the NSImage properly while scrolling.

This is what I've done:

1. Created an NSView subclass called CmCanvasView (hoping to build a
simple graphics app) and put it in an NSScrollView.

2. The image is larger than the scroll view's content view region. So,
scrolling is needed to look around the image.

3. in CmCanvasView's drawRect: method, I wanna display only the
portion of the image which intersects the input rect of drawRect:.

However, I can't make it work...

NSScrollView documentation has described about the "copy-on-scroll"
feature of the NSClipView.  When I scroll up one screen (press the
empty space in the vertical scroll bar), things seem to work fine...

But, when I try to scroll down one screen (press the empty space in
the vertical scroll bar), the image's got messed up.

I found that input argument of CmCanvasView's drawRect: is correct.
The newly exposed region.  When I call the NSImage's drawAtPoint: and
specify the rect (passed as input argument), Cocoa did display that
portion of the image but stretched to fit the height of the scroll
view's content view.

What did I do wrong?  Please kindly advise.

The complete source can be downloaded here:

http://www.headnix.com/files/ScrollingAutoResizeCanvas.zip

Thanks for your help.

Bill
_______________________________________________
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


  • Follow-Ups:
    • displaying an NSImage in custom NSView
      • From: "Bill So" <email@hidden>
  • Prev by Date: Re: A Question of Style
  • Next by Date: Core Data: Forcing update of NSTableView bound to an NSArrayController
  • Previous by thread: Re: testing for invisible files in a file browser
  • Next by thread: displaying an NSImage in custom NSView
  • Index(es):
    • Date
    • Thread