• 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: NSImageView scrolling
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSImageView scrolling


  • Subject: Re: NSImageView scrolling
  • From: Marco Binder <email@hidden>
  • Date: Sat, 28 Sep 2002 17:58:04 +0200

Hello,

just in case your question was meant in a somewhat different way:

you got your NSImage (lets say "myImage") and put that into the NSImageView ([myImageView setImage:myImage]), right. Now I assume, you want the image view to adjust to the native size of the image. You do that by [myImageView setFrameSize:[myImage size]]; In order to have the NSScrollView (myScrollView) to reflect the change, you have to call display on it: [[myImageView scrollView] setNeedsDisplay:YES]; If it still doesnt work, you probably havent added the NSImageView as the scroll views document view. Do that like [myScrollView setDocumentView:myImageView]; all the rest, activating scrollbars just as needed, will be done automaticvally by your scroll view.

Just if you want to totally hide the scrollbars if the image is smaller than your scroll view, you have to do what Jeremy told you. Note: as far a I can remember, the default for a NSScrollView however is HAVING the scrollbars!

Second note: I would recommend not to hide the scrollbars, since resizing of your window would then require checking the image dimensions again and stuff. I think its convenient enought to have the scroll view activate and deactivate the scrollbars automatically.

MArco


Am Samstag, 28.09.02 um 13:04 Uhr schrieb Jeremy Dronfield:

Hello list,

I need to have an NSScrollView with an NSImageView inside it, which I know how to do already. What I don't know is how to get the imageView to expand automatically to show the entire NSImage it displays. When the NSImageView grows larger than the scroll view, scrollbars should appear.

Is this possible? How would I go about doing it?

It's not clear what you want: do you want the whole view to expand to display the whole image, or simply to bring up scrollbars when the image is too large? I'll assume the latter. The default implementation of NSScrollView has no scrollbars. This makes sense, because you only want them if the image is too large. What you need to do is check the image size when it loads, and give the scroll view scrollbars accordingly, something like this:

NSSize selfSize = [myImageView frame].size;
NSSize sViewSize = [myScrollView frame].size;

BOOL hFlag = selfSize.width > sViewSize.width;
BOOL vFlag = selfSize.height > sViewSize.height;

[scrollView setHasHorizontalScroller:hFlag];
[scrollView setHasVerticalScroller:vFlag];

Also, you need to read the documentation on NSImage, NSScrollView, NSView, NSImageView etc and related Programming Topics.
-Jeremy

--
|\ /| E-Mail: email@hidden WWW: www.marco-binder.de
| \/ | Telefon: 07531 / 94 19 94 Fax: 07531 / 94 19 92
| |ARCO Snail-Mail: Banater Str. 3 - 78467 Konstanz
BINDER _____________________________________________________
_______________________________________________
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.

  • Follow-Ups:
    • Re: NSImageView scrolling
      • From: Jeremy Dronfield <email@hidden>
    • Re: NSImageView scrolling
      • From: Marco Binder <email@hidden>
References: 
 >Re: NSImageView scrolling (From: Jeremy Dronfield <email@hidden>)

  • Prev by Date: Drag operations and AppKit views
  • Next by Date: RE: Licences 101 - Copy Protection for Newbies
  • Previous by thread: Re: NSImageView scrolling
  • Next by thread: Re: NSImageView scrolling
  • Index(es):
    • Date
    • Thread