home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Carousel
/
CAROUSEL.cdr
/
mactosh
/
lang
/
skel_azt.sha
/
myscroll.c
< prev
next >
Wrap
C/C++ Source or Header
|
1986-07-08
|
2KB
|
67 lines
/*
* myscroll.c -- called by TrackControl for mouse click in page or
* arrow parts of a scrollbar
* NOTE: the global rectangle r must be the visible
* region of the window, as noted in checkscroll() and
* scroll().
*/
#include <quickdraw.h>
#include <control.h>
#include <textedit.h>
pascal void
myscroll(mc, pc)
ControlHandle mc; /* "my" control (which control) */
int pc; /* which part code is clicked this time
* (the global, part, tells which part code was
* clicked originally)
*/
{
short amount;
short atom;
long dlr; /* to ignore result from Delay */
extern TEHandle hTE;
extern short part; /* control part */
extern Rect r;
short start;
extern int swi; /* scroll window index */
Boolean up;
extern Boolean vertical; /* indicates which scroll bar */
up = pc == inUpButton || pc == inPageUp;
start = GetCtlValue(mc);
if ((up && start > GetCtlMin(mc)) ||
(!up && start < GetCtlMax(mc)) && part == pc) {
if (!hTE || swi != 1)
atom = 1;
else {
atom = (*hTE)->lineHeight;
if (!vertical)
atom >>= 1;
};
amount = up ? -1 : 1;
if (pc == inPageUp || pc == inPageDown) {
atom *= amount;
if (vertical)
amount *= r.bottom - r.top;
else
amount *= r.right - r.left;
amount -= atom;
}
else /* in XXButton */
amount *= atom;
if (up && (start + amount) < GetCtlMin(mc))
amount = GetCtlMin(mc) - start;
if (!up && (start + amount) > GetCtlMax(mc))
amount = GetCtlMax(mc) - start;
if (amount != 0) {
SetCtlValue(mc, start + amount);
scroll();
Delay(8L, &dlr); /* de-bounce mouse button */
};
};
} /* end of myscroll */