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

displaying an NSImage in customer NSView


  • Subject: displaying an NSImage in customer NSView
  • From: "Bill So" <email@hidden>
  • Date: Wed, 9 Aug 2006 02:08:00 +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


  • Prev by Date: The format of NSHTMLPboardType
  • Next by Date: Re: Temporal XCode 2.4 problem in ADC
  • Previous by thread: The format of NSHTMLPboardType
  • Next by thread: sorting problems with custom compare
  • Index(es):
    • Date
    • Thread