home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!spool.mu.edu!umn.edu!csus.edu!netcom.com!friedman
- From: friedman@netcom.com (Greg Friedman)
- Subject: Re: Dialogs and Scrolling
- Message-ID: <1992Dec16.204039.26189@netcom.com>
- Organization: Netcom Online Communications Services (408-241-9760 login: guest)
- References: <1992Dec16.171910.8575@aio.jsc.nasa.gov>
- Date: Wed, 16 Dec 1992 20:40:39 GMT
- Lines: 61
-
- In article <1992Dec16.171910.8575@aio.jsc.nasa.gov> mark@cheers.jsc.nasa.gov (Mark Manning) writes:
- >
- > Question: I want to place a PICT picture onto the screen and
- > then scroll it left and right. On top of this PICT
- > are editable fields. Is this possible and if so
- > could you post a snippet on how to do this? I keep
- > crashing my system when I try to do this. :(
-
- If I understand correctly, you have a dialog on the screen and are
- attempting to scroll the contents of the dialog. I have done
- something similar in the past, though my dlog did not contain a PICT.
- I don't think a pict item should make a difference. This code assumes
- that you are scrolling in response to a hit on the upButton in a scroll
- bar. If you aren't scrolling in response to a scroll bar hit, or
- your dlog doesn't contain controls, than omit the control related code:
-
- SetCtlValue(vScrollHndl,(**vScrollHndl).contrlValue - 1);
- ShiftControls(whichWindow,((-1) * kVScrollVal));
-
- clipRect.right = clipRect.right - 15;
- clipRect.bottom = clipRect.bottom - (15);
- clipRect.top = clipRect.top + headerHeight;
- ClipRect(&clipRect);
- ScrollRect(&clipRect,0,kVScrollVal,((WindowPeek)whichWindow)->visRgn);
- SetOrigin (((GrafPtr)whichWindow)->portRect.left,
- ((GrafPtr)whichWindow)->portRect.top - kVScrollVal);
- clipRect = ((GrafPtr)whichWindow) ->portRect;
- clipRect.right = clipRect.right - 15;
- clipRect.top = clipRect.top + headerHeight;
- clipRect.bottom = clipRect.top + kVScrollVal;
- ClipRect(&clipRect);
- DrawDialog((DialogPtr)whichWindow);
- ValidRect(&((GrafPtr)whichWindow) ->portRect);
-
- I didn't scroll the entire contents of the dlog. I omitted a header,
- whose height was defined in headerHeight. Be sure to set the origin
- of the dlog. Otherwise dlog items will be drawn in the wrong places
- when the dialog is drawn. Also, be sure to validate the dlog rect
- after your call to draw dlog. In case you have controls in the window,
- you'll have to shift them yourself. Here's the function ShiftControls
- that I call from the above code.
-
- void
- ShiftControls( WindowPtr whichWindow,
- short shiftVal)
- {
- ControlHandle whichControl;
-
- /*set whichControl to the window's first control*/
- whichControl = ((WindowPeek)whichWindow)->controlList;
-
- /* now loop through all of the controls and shift them by shiftVal*/
- do{
- (**whichControl).contrlRect.top = (**whichControl).contrlRect.top + shiftVal;
- (**whichControl).contrlRect.bottom = (**whichControl).contrlRect.bottom +
- shiftVal;
- whichControl = (**whichControl).nextControl;
- } while (whichControl);
- }
-
- Hope this helps.
-