Re: Scrolling
Re: Scrolling
- Subject: Re: Scrolling
- From: Dietrich Epp <email@hidden>
- Date: Wed, 12 Mar 2003 15:51:36 -0800
On Wednesday, Mar 12, 2003, at 08:27 US/Pacific, Glenn L. Austin wrote:
on 3/12/2003 1:29 AM, Peter Karlsson at email@hidden wrote:
Dear list!
I am developing an music app (not a game) in Cocoa that needs
scrolling.
Maybe some of you think that Cocoa is the list for me but I think
this list
is the best to ask because scrolling is pretty common in games. So my
queston is:
I need to scroll rectangles from right to left, these rectangles is
made of
small pictures, size is different for each rectangle but to make it
easy
lets say 250 pixel wide and 32 pixel height.
What is the best way to scroll lots of these rectangles at the same
time
from right to left?
Use Carbon so that you can use ScrollRect. ;-)
Seriously though, CG, Quartz and Cocoa don't have native support for
scrolling an arbitrary rectangle. This means that you'll have to do
the
work yourself by using a progressive origin each time you draw, and
make
sure that you erase the area that you just scrolled out of (right edge
for
scrolling to the left, left edge for scrolling to the right, and so
forth)
if your image is smaller than the area. Of course, given that X has
double-buffered windows, simply erase the area, draw the image in the
new
location, then tell the window server to flush that area to the screen.
Wrong! Curious -- do you actually use Cocoa?
In Cocoa it's dead easy... just put your view inside an NSClipView or
an NSScrollView. I'd use NSScrollView because it's nicer. It gives
you scroll bars if you want or no scroll bars if you don't, and you can
do slick things like...
[myView scrollRectToVisible:NSRect (...)];
where myView is the view inside the NSScrollView. You can create this
in IB by grouping your custom view in a NSScrollView (in one of the
menus)
Look for scrolling methods in the NSView documentation:
file:///System/Library/Frameworks/AppKit.framework/Versions/C/
Resources/English.lproj/Documentation/Reference/ObjC_classic/Classes/
NSView.html
_______________________________________________
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.