Re: Dynamically Resize NSView Subclass to NSScrollView
Re: Dynamically Resize NSView Subclass to NSScrollView
- Subject: Re: Dynamically Resize NSView Subclass to NSScrollView
- From: "Ujwal S. Sathyam" <email@hidden>
- Date: Sun, 25 Jan 2004 15:06:07 -0800
You can set/reset the size of the canvasView with setFrameSize. When the window is resized to something smaller, and views are resized, notifications like NSViewFrameDidChangeNotification are sent out. Your view can listen for those notifications, and resize itself to the minimum size if needed. If the minimum size is smaller than the contentView of the scrollView, the scrollbars should automatically appear.
Ujwal
On 2004-01-25 11:34:39 -0800 Mijobe <email@hidden> wrote:
Thank you for your reply. That part I've got working. Where I'm running
into trouble is implementing a minimum size for the drawing canvas. For
instance if I enlarge the window, draw graphics, then shrink the window I
want the contained canvas to maintain a size large enough to contain all of
the drawn graphics that should then cause the NSScrollView to display
scrollbars allowing the user to scroll the entire size of the canvas. This
needs to be done dynamically because I want the user to be able to simply and
quickly resize their drawing surface.
-
email@hidden
<xinjen/>
On Jan 24, 2004, at 9:01 PM, Ujwal S. Sathyam wrote:
That's pretty much the function of the scrollview. You will have to set:
[scrollView setDocumentView: canvasView];
[canvasView setAutoresizingMask: NSViewWidthSizable|NSViewHeightSizable];
either in your nib or in code.
That should do it.
Ujwal
I am developing a drawing application that allows users to draw arbitrary
shapes onto a canvas, very similar to Apple's Sketch example application.
I would like the size of the canvas to follow the size of its containing
NSScrollView as long as it is large enough to display the contents of the
canvas. If the NSScrollView is shrunk below the amount of space needed to
display the graphics then I would like the canvas to stop resizing
allowing the scrollbars to appear. To clarify here are a few example
scenarios of how I would like it to work:
- The user requires more canvas surface for their graphics and so they
resize the window to fit the additional content. As the window is
enlarged the NSScrollView is enlarge and the NSView follows in suit by
enlarging its drawing surface.
- The user has drawn all of the graphics for a particular canvas and
doesn't want the window taking up all of their desktop space but wants to
work with particular sections of the canvas so they shrink the window
smaller than the space required by the canvas to display all the graphics.
Once the size becomes too small to display all of the graphics the NSView
stops resizing and the NSScrollView then displays its scrollbars allowing
the user to scroll over the canvas.
_______________________________________________
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.
--
Ujwal S. Sathyam
email@hidden
_______________________________________________
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.