Пример #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);
}
Пример #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);
	}
}
Пример #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);
}
Пример #4
0
int16	RchooseDialog::hit(void)
{	
	short		item;	
	short		iType;
	Handle		iHandle;
	Rect 		iRect;	
	int 		which;


	BringToFront(dialogptr);
	ShowWindow(dialogptr);

	do{
		ModalDialog(NULL, &item);
		switch(item){
			case FileType:
				GetDItem (dialogptr, FileType, &iType, &iHandle, &iRect);
				which = GetCtlValue((ControlHandle)iHandle);
				convertToDefault(which);
				setDialogState();
				break;
			case PatchFormat:
				GetDItem (dialogptr, PatchFormat, &iType, &iHandle, &iRect);
				which = GetCtlValue((ControlHandle)iHandle);
				_which_patch = convert[which];
				break;
			case DevicePort:
				GetDItem (dialogptr, DevicePort, &iType, &iHandle, &iRect);
				_which_port = GetCtlValue((ControlHandle)iHandle);
				 break;
	    	case 3:
	    	break;
	    	
	    	case 1:
	    	_Savesettings();
			break;	    	
	    }	
	 } while( item != 1 && item != 3);	
	
	if (item == 3) item = 0;
	return item;	    	
}
Пример #5
0
McoStatus TechkonDialog::DoEvents(short item, Point clickPoint, WindowCode *wc, int32 *numwc, void **data, Boolean &changed)
{
UserItemUPP myfilter;
Str255		theString;
short		itemtype;
Handle		cn1,sliderControl;
Rect		r;
short		part;
Point		mpoint;
int32		next_patch;
McoStatus	status;
WindowPtr	oldp;
int32		temp;
double 		m=1;

	GetPort(&oldp);
	SetPort(dp);

	Changed = FALSE;
	*numwc = 0;
	status = MCO_SUCCESS;

	if (isPressed(0x38)) m = 10;

	if (item != -1) {
		if ((item == TIMER_ITEM ) && (doc->tcom)) // a timer event has occured
			{   
			_last_tick_time2 = TickCount();
			if (_waiting)
				{
				if (!doc->tcom->IsBufferEmpty())	// has a strip been read in
					{
					changed = TRUE; 
					// check to see if a strip has been read in 
					if (doc->tcom->IsDataPresent()) 
						{
						doc->needsSave = TRUE;
						GetDItem ( dp,ids[Message], &itemtype, (Handle*)&cn1, &r );
						GetIndString(theString,Message_List_ID,4);
						SetIText(cn1,theString);
						readInPatches();
						Changed = TRUE;
						next_patch = findNextPatch();
						if (next_patch == -1)
							{
							GetDItem ( dp,ids[Message], &itemtype, (Handle*)&cn1, &r );
							GetIndString(theString,Message_List_ID,5);
							SetIText(cn1,theString);
							_done == TRUE;
							_waiting = FALSE;
							Disable(dp,ids[Redo]);
							Disable(dp,ids[Start]);
							Disable(dp,ids[Cancel]);
							Enable(dp,ids[Save_as]);	
							Enable(dp,OK);			
							}
						else
							{
							GetDItem ( dp,ids[Message], &itemtype, (Handle*)&cn1, &r );
							GetIndString(theString,Message_List_ID,7);
							SetIText(cn1,theString);
							}
						}
					}
				checkFinished();
				}
			}
		else if (item == ids[Slider])   // the slider has been adjusted
			{
			GetMouse(&mpoint);
			do {
				current_patch = GetSlider(mpoint,ids[Slider]);
				ShowPatchScroll(current_patch);
				SetSheetStripText();
				current_sheet = current_patch/(patch_per_strip*strip_per_sheet);
				current_strip = (current_patch - current_sheet*(patch_per_strip*strip_per_sheet))/patch_per_strip;	
				GetMouse(&mpoint);
				} while ( StillDown ( ) );
			checkError((current_patch/patch_per_strip)*patch_per_strip);
			//_waiting = 0;
			Enable(dp,ids[Redo]);
			SetSheetStripText();
			}
		else if (item == ids[Start]) // start or stop reading
			{
			status = MCO_SUCCESS;
			if (_first) 
				{
				
				status = doc->tcom->Calibrate();
				playSound(EndColumnNum);
				if (status != MCO_SUCCESS) 
					{
					McoMessAlert(MCO_FAIL_CALIB,0L);
					status = MCO_SUCCESS;
					goto bail;
					}
				}
			if (status == MCO_SUCCESS)
				{
				_waiting = 1;	
				current_patch = findNextPatch();  // reset the display, current patch, sheet, strip, and text
				ShowPatch(current_patch); // display the window
				current_sheet = current_patch/(patch_per_strip*strip_per_sheet);
				current_strip = (current_patch - current_sheet*(patch_per_strip*strip_per_sheet))/patch_per_strip;
				Disable(dp,ids[Start]);	 
				GetDItem ( dp,ids[Message], &itemtype, (Handle*)&cn1, &r );
				GetIndString(theString,Message_List_ID,7);
				SetIText(cn1,theString);
				SetSheetStripText();		
				_first = 0;
				}
			status = MCO_SUCCESS;
			}
		else if (item == ids[Save_as])
			{
			StorePatches();
			doc->patchtype = patchtype;
			doc->handle_save_datafile(patchD);
			ShowPatch(current_patch);
			}
		else if (item == ids[VoiceSet]) 
			{
			GetDItem(dp, ids[VoiceSet], &itemtype, (Handle*)&cn1, &r );
			voice_set = GetCtlValue((ControlHandle)cn1);
			}
		else if (item == ids[Strip_Rect])
			{
			GlobalToLocal(&clickPoint);
			temp = whichPatch(clickPoint);
			if (temp != -1)
				{
				current_patch = temp;
				current_disp = current_patch-current_top;
				GetDItem ( dp, ids[Slider], &itemtype, (Handle*)&sliderControl, &r );
				SetCtlValue ( (ControlHandle)sliderControl,current_patch);
				ShowPatch(current_patch);
				SetSheetStripText();
				}
			}
		else if (item == ids[Redo]) // Reread a strip
			{
			_waiting = 1;		   // reset the display, current patch, sheet, strip, and text
			Disable(dp,ids[Redo]);
			Disable(dp,ids[Start]);	 
			GetDItem ( dp,ids[Message], &itemtype, (Handle*)&cn1, &r );
			GetIndString(theString,Message_List_ID,7);
			SetIText(cn1,theString);
			}
		else if (item == OK)
			{
			StorePatches();
			doc->copyWaiting(patchD);
			doc->patchtype = patchtype;
			//doc->needsSave = TRUE;
			*numwc = 1;
			wc[0].code = WE_Close_Window;
			wc[0].wintype = WinType;
			wc[0].winnum = WinNum;
			wc[0].doc = doc;
			}
		else if (item == Cancel)
			{
			*numwc = 1;
			wc[0].code = WE_Close_Window;
			wc[0].wintype = WinType;
			wc[0].winnum = WinNum;
			wc[0].doc = doc;
			}
		}
bail:		
		
	SetPort(oldp);
	changed = Changed;
	return status;	    	
}
Пример #6
0
McoStatus SpChInDialog::DoEvents(short item, Point clickPoint, WindowCode *wc, int32 *numwc, void **data, Boolean &changed)
{
UserItemUPP myfilter;
Str255		theString;
short		itemtype;
Handle		cn1,sliderControl;
Rect		r;
short		part;
Point		mpoint;
int32		next_patch;
McoStatus	status;
WindowPtr	oldp;
int32		temp;
double 		m=1;
SpectroChart *tcom = (SpectroChart*)(doc->tcom);


	GetPort(&oldp);
	SetPort(dp);

	Changed = FALSE;
	*numwc = 0;
	status = MCO_SUCCESS;

	if (isPressed(0x38)) m = 10;

	if (item != -1) {
		if (item == TIMER_ITEM ) // a timer event has occured
			{   
			_last_tick_time2 = TickCount();
			if (_waiting)
				{
				doc->needsSave = TRUE;
			//	GetDItem ( dp,Message, &itemtype, (Handle*)&cn1, &r );
			//	GetIndString(theString,Message_List_ID,4);
			//	SetIText(cn1,theString);
				readInPatches();
				Changed = TRUE;
				next_patch = findNextPatch();
				if (next_patch == -1)
					{
				//	GetDItem ( dp,Message, &itemtype, (Handle*)&cn1, &r );
				//	GetIndString(theString,Message_List_ID,5);
				//	SetIText(cn1,theString);
					_done == TRUE;
					if (current_patch == total_patches) _waiting = FALSE;
					Disable(dp,ids[Redo]);
					//Disable(dp,ReadNext);
					if (NotAlreadFinished) Disable(dp,Cancel);
					Enable(dp,ids[Save_as]);	
					Enable(dp,OK);			
					}
				else
					{

				//	GetDItem ( dp,Message, &itemtype, (Handle*)&cn1, &r );
				//	GetIndString(theString,Message_List_ID,2);
				//	SetIText(cn1,theString);
					}
				if (!_waiting)
					{
					GetDItem ( dp,ids[Start], &itemtype, (Handle*)&cn1, &r );
					GetIndString(theString,Button_Labels,1);
					SetCTitle((ControlHandle)cn1,theString);
					}
				checkFinished();
				}
			}
		else if (item == ids[Slider])   // the slider has been adjusted
			{
			GetMouse(&mpoint);
			do {
				current_patch = GetSlider(mpoint,ids[Slider]);
				ShowPatchScroll(current_patch);
				SetSheetStripText();
				current_sheet = current_patch/(patch_per_strip*strip_per_sheet);
				current_strip = (current_patch - current_sheet*(patch_per_strip*strip_per_sheet))/patch_per_strip;	
				GetMouse(&mpoint);
				} while ( StillDown ( ) );
			checkError((current_patch/patch_per_strip)*patch_per_strip);
			//_waiting = 0;
			Enable(dp,ids[Redo]);
			SetSheetStripText();
			}
		else if (item == ids[Start]) // start or stop reading
			{
			if (_waiting) 
				{
				_waiting = 0;
				GetDItem ( dp,ids[Start], &itemtype, (Handle*)&cn1, &r );
				GetIndString(theString,Button_Labels,1);
				SetCTitle((ControlHandle)cn1,theString);
				current_patch = last_patch;
				ShowPatchScroll(current_patch);
				SetSheetStripText();
				current_sheet = current_patch/(patch_per_strip*strip_per_sheet);
				current_strip = (current_patch - current_sheet*(patch_per_strip*strip_per_sheet))/patch_per_strip;
				}
			else 
				{
				if (DoStart() == MCO_SUCCESS)
					{
					GetDItem ( dp,ids[Start], &itemtype, (Handle*)&cn1, &r );
					GetIndString(theString,Button_Labels,2);
					SetCTitle((ControlHandle)cn1,theString);
					}
				}
			}
		else if (item == ids[Position_Up])
			{
			if (!_waiting)
				{
				tcom->moveDistance(0,m*0.5);
				}
			}
		else if (item == ids[Position_Down])
			{
			if (!_waiting)
				{	
				tcom->moveDistance(0,-0.5*m);
				}
			}
		else if (item == ids[Position_Left])
			{
			if (!_waiting)
				{
				tcom->moveDistance(-0.5*m,0);
				}
			}
		else if (item == ids[Position_Right])
			{
			if (!_waiting)
				{
				tcom->moveDistance(0.5*m,0);
				}
			}		
		else if (item == ids[Save_as])
			{
			StorePatches();
			doc->patchtype = patchtype;
			doc->handle_save_datafile(patchD);
			ShowPatch(current_patch);
			}
		else if (item == ids[VoiceSet]) 
			{
			GetDItem(dp, ids[VoiceSet], &itemtype, (Handle*)&cn1, &r );
			voice_set = GetCtlValue((ControlHandle)cn1);
			}
		else if (item == ids[Strip_Rect])
			{
			GlobalToLocal(&clickPoint);
			temp = whichPatch(clickPoint);
			if (temp != -1)
				{
				current_patch = temp;
				current_disp = current_patch-current_top;
				GetDItem ( dp, ids[Slider], &itemtype, (Handle*)&sliderControl, &r );
				SetCtlValue ( (ControlHandle)sliderControl,current_patch);
				ShowPatch(current_patch);
				SetSheetStripText();
				}
			}
		else if (item == OK)
			{
			StorePatches();
			doc->copyWaiting(patchD);
			doc->patchtype = patchtype;
			//doc->needsSave = TRUE;
			*numwc = 1;
			wc[0].code = WE_Close_Window;
			wc[0].wintype = WinType;
			wc[0].winnum = WinNum;
			wc[0].doc = doc;
			}
		else if (item == Cancel)
			{
			*numwc = 1;
			wc[0].code = WE_Close_Window;
			wc[0].wintype = WinType;
			wc[0].winnum = WinNum;
			wc[0].doc = doc;
			doc->patchtype = oldpatchtype;
			}
		}
	SetPort(oldp);
	changed = Changed;
	return status;	    	
}