Example #1
0
/* control processing procedure for TextEdit
 */
short NATEctrlp(na_win *winp, Point p, short part, short mods, ControlHandle ctrl)
#ifndef THINK_C
#pragma unused (mods)
#endif
{
	short			value;
	
	if (part) {
		value = GetCtlValue(ctrl);
		switch (part) {
			case inThumb:
				part = TrackControl(ctrl, p, (ProcPtr) NULL);
				if (part && (value -= GetCtlValue(ctrl))) {
					TEHandle	hTE = teinfo->hTE;
					
					if (ctrl == teinfo->vctrl) {
						TEScroll(0, value * teinfo->lheight, hTE);
					} else if (ctrl == teinfo->hctrl) {
						TEScroll(value, 0, hTE);
					}
				}
				break;
			
			default:
				(void) TrackControl(ctrl, p,
					(ProcPtr) (ctrl == teinfo->vctrl ? vscroll : hscroll));
				break;
		}
	}
	
	return (NA_PROCESSED);
}
Example #2
0
/* track procedure for the horizontal scroll bar
 */
static pascal void hscroll(ControlHandle ctrl, short part)
{
	short		amount, value, max;
	
	if (part) {
		TEHandle hTE = (* (nate_win**) GetWRefCon((*ctrl)->contrlOwner))->hTE;
		
		value = (*hTE)->viewRect.right - (*hTE)->viewRect.left;
		switch (part) {
			case inUpButton:
				amount = -6;
				break;
			case inDownButton:
				amount = 6;
				break;
			case inPageUp:
				amount = - value;
				break;
			case inPageDown:
				amount = value;
				break;
		}
		if ((amount += (value = GetCtlValue(ctrl))) < 0) amount = 0;
		if (amount > (max = GetCtlMax(ctrl))) amount = max;
		SetCtlValue(ctrl, amount);
		TEScroll(value - amount, 0, hTE);
	}
}
Example #3
0
/* track procedure for the vertical scroll bar
 */
static pascal void vscroll(ControlHandle ctrl, short part)
{
	short		amount, value, max, lh;
	na_win		*winp;
	TEHandle	hTE;
	
	if (part == 0) return;
	winp = * (na_win**) GetWRefCon((*ctrl)->contrlOwner);
	hTE = teinfo->hTE;
	value = ((*hTE)->viewRect.bottom - (*hTE)->viewRect.top) /
		(lh = teinfo->lheight);
	switch (part) {
		case inUpButton:
			amount = -1;
			break;
		case inDownButton:
			amount = 1;
			break;
		case inPageUp:
			amount = - value;
			break;
		case inPageDown:
			amount = value;
			break;
	}
	if ((amount += (value = GetCtlValue(ctrl))) < 0) amount = 0;
	if (amount > (max = GetCtlMax(ctrl))) amount = max;
	SetCtlValue(ctrl, amount);
	TEScroll(0, (value - amount) * lh, hTE);
}
Example #4
0
/****adjusttext()************************************************************/
void adjusttext(int iforce)
/*must call this with iforce==0 before iforce==1 to get calc right*/
{
 if (Lquiet == 0)
 {
    if (iforce > 0)
    {
        if(thenoldLines+iforce >= theviewLines)  /* would be off the bottom now*/
        {/*force a scroll if line would be off bottom from earlier calculation*/

/*m*/      TEScroll(0,-(iforce*textHeight),textText); 
               /* scroll iforce number of lines */
/*m*/      SetControlValue(vtextScroll,maxValue);

        }   
        thenoldLines = thenoldLines + iforce;
    }
    else /*calculate number of lines needed for a scroll to stay on screen*/
    {
/*m*/  TECalText(textText);
      thenLines = (*textText)->nLines;  /* total lines of text */
      thendiff = thenLines - thenoldLines; 
               /*number of lines moved since last adjustment*/
      theviewLines = (textdRect.bottom - textdRect.top)/textHeight; 
                /* lines viewed in window */
      thenoldLines = thenLines;

      if (thenLines >= (theviewLines)) 
      {
/*m*/      TEScroll(0,-(thendiff*textHeight),textText); /* scroll ndiff lines */
/*m*/      SetControlValue(vtextScroll,maxValue);
      }

    }
 }
}
Example #5
0
static PyObject *TEObj_TEScroll(TEObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    short dh;
    short dv;
#ifndef TEScroll
    PyMac_PRECHECK(TEScroll);
#endif
    if (!PyArg_ParseTuple(_args, "hh",
                          &dh,
                          &dv))
        return NULL;
    TEScroll(dh,
             dv,
             _self->ob_itself);
    Py_INCREF(Py_None);
    _res = Py_None;
    return _res;
}
Example #6
0
pascal void 
DoScrollProc(ControlHandle theControl, short part)
{
	short		amount;
	TEPtr		te;
	
	if ( part != 0 ) {
		switch (gCurrWin)
		{
			case kLicenseID:				
				te = *(gControls->lw->licTxt);
				break;
			default:
				ErrorHandler(eUnknownDlgID, nil);
				break;
		}
		
		switch ( part ) {
			case kControlUpButtonPart:
			case kControlDownButtonPart:		// one line
				amount = 1;
				break;
			case kControlPageUpPart:			// one page
			case kControlPageDownPart:
				amount = (te->viewRect.bottom - te->viewRect.top) / kScrollAmount;
				break;
		}
		if ( (part == kControlDownButtonPart) || (part == kControlPageDownPart) )
			amount = -amount;
		CalcChange(theControl, &amount);
		if (amount) {
			TEScroll(0, amount * kScrollAmount, &te);
            ShowTxt();
		}
	}
}
Example #7
0
void
InLicenseContent(EventRecord* evt, WindowPtr wCurrPtr)
{
	Point 			localPt;
	Rect			r;
	ControlPartCode	part;
	short 			code, value;
	ControlHandle	scrollBar;
	ControlActionUPP	scrollActionFunctionUPP;
	GrafPtr			oldPort;
	
	GetPort(&oldPort);
	SetPort(gWPtr);
	localPt = evt->where;
	GlobalToLocal( &localPt);
	
	code = FindControl(localPt, wCurrPtr, &scrollBar);
	switch (code)
	{
		case kControlUpButtonPart:
		case kControlDownButtonPart:
		case kControlPageUpPart:
		case kControlPageDownPart:
			scrollActionFunctionUPP = NewControlActionUPP(DoScrollProc);
			value = TrackControl(scrollBar, localPt, scrollActionFunctionUPP);
 			return;
			
		case kControlIndicatorPart:
			value = GetControlValue(scrollBar);
			code = TrackControl(scrollBar, localPt, nil);
			if (code) 
			{
				value -= GetControlValue(scrollBar);
				if (value) 
				{
					TEScroll(0, value * kScrollAmount, gControls->lw->licTxt);
                    ShowTxt();
				}
			}
			return;
	}
	
	HLock((Handle)gControls->backB);
	r = (**(gControls->backB)).contrlRect;
	HUnlock((Handle)gControls->backB);
	if (PtInRect( localPt, &r))
	{
		part = TrackControl(gControls->backB, evt->where, NULL);
		if (part)
			gDone = true;  /* Decline pressed */
	}
	
	HLock((Handle)gControls->nextB);			
	r = (**(gControls->nextB)).contrlRect;
	HUnlock((Handle)gControls->nextB);
	if (PtInRect( localPt, &r))
	{
		part = TrackControl(gControls->nextB, evt->where, NULL);
		if (part)
		{
			KillControls(gWPtr);
			ShowSetupTypeWin();
			return;
		}
	}
	
	ShowTxt();
	// TO DO
	SetPort(oldPort);
}