Re: Large over 100K pixel high ruler scroll view
Re: Large over 100K pixel high ruler scroll view
- Subject: Re: Large over 100K pixel high ruler scroll view
- From: Graham Cox <email@hidden>
- Date: Tue, 30 Aug 2011 12:29:17 +1000
On 30/08/2011, at 12:18 PM, Julie Porter wrote:
> On 8/29/11 1:17 PM, email@hidden wrote:
>>> One warning about extremely large views is that at some point you will run into floating-point rounding errors, since AppKit and CoreGraphics coords are 32-bit floats and have only 24 bits of precision. Still, that should get you to millions of pixels before the coords stop being pixel-accurate.
>> 64-bit AppKit is much better in this regard than 32-bit. If memory serves, it lets you reliably operate NSScrollViews over dimensions in the billions.
>>
> At the moment I need to support power PC (I have 5 computers.) most at least are running 10.5.8 which helps a lot.
>
> I am not to worried about the rounding. Much of this code was coded in postscript. So the graphics already are in floating point.
>
> In some ways it is too bad I can not call the cocoa classes from a postscript syntax, considering that the program already defines the data in arrays of dictionaries. I think at one time there was interactive postscript on the NEXT. Not sure if any of that still exists or not.
>
> As for the original question. I am not sure I ever got it answered? Simply where, as in what files, do I put the code that creates the super view that describes all my lines? I do have the code working that imports the data into the same array of dictionaries. The imported array comes in at 20713.
>
> Now I want to create a view that is 20713 lines high and 2600 lines wide. I am pretty sure I create or subclass NSScrollview do do this? Where do I put the code that sets this frame or clip area (which I think is the superview?) If I make a subclass of NSScrollVew called cisView, I get some basically empty files in the class, with no hints as to where things go or what to override.
>
> The "Scroll View Programming guide" has a code snippet (listing 1) Creating a scroll view programetically. This however uses an ImageView, which would require a data source that would read all the lines at once. I only want to draw or update the lines contained in the array that are visible dependent on where the scroller thumb is located.
Use Interface Builder to set up/design your interface.
Add a custom NSView, set its class to your subclass. Place it inside a standard NSScrollView. In the -awakeFromNib method of the custom NSView subclass, set the frame size to what you need. The standard NSScrollView will cope, you do not need to subclass NSScrollView (the scrollview doesn't display your content directly, it it is merely a container for another view that does display your content).
That's the essence of it. But in practice you'll probably want to have a NSDocument representing this file, in which case it is responsible for opening the file, working out the size and setting the view size as needed.
The custom NSView subclass is what is going to do the real work. In the -drawRect: method, which you're obliged to override, you are passed a "dirty rectangle". Using that rectangle, which is relative to the view's bounds, which in turn is the size of the total size you calculated from your file, you can work out what lines it is needing to redraw. Perform that calculation and request the data from the file. You'll need various lines of communication between your document and view (the document is the data model) which you can easily establish using outlets.
--Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden