/* set the controls in the TextEdit window correctly */ void NATEsetscroll(na_win *winp, Boolean moved, Rect *hrect, Rect *vrect) { short vmax, vvalue, hmax, hvalue; TEPtr te = *teinfo->hTE; ControlHandle vctrl, hctrl; vmax = te->nLines + (*(*te->hText + te->teLength - 1) == '\015' ? 1 : 0) - (te->viewRect.bottom - te->viewRect.top) / teinfo->lheight; hmax = (short) teinfo->docwidth - (te->viewRect.right - te->viewRect.left); if (vmax < 0) vmax = 0; if (hmax < 0) hmax = 0; vvalue = (te->viewRect.top - te->destRect.top) / teinfo->lheight; hvalue = te->viewRect.left - te->destRect.left; if (!(winp->flags & NATE_NOVSCROLL)) { if (teinfo->vctrl == (ControlHandle) NULL) { teinfo->vctrl = NewControl(winp->pwin, vrect, "\p", true, vvalue, 0, vmax, scrollBarProc, 0); if (winp->pwin != FrontWindow()) HiliteControl(teinfo->vctrl, 255); } else { if (vvalue < 0) vvalue = 0; if (vvalue > vmax) vvalue = vmax; SetCtlMax(vctrl = teinfo->vctrl, vmax); SetCtlValue(vctrl, vvalue); if (moved) { MoveControl(vctrl, vrect->left, vrect->top); SizeControl(vctrl, vrect->right - vrect->left, vrect->bottom - vrect->top); ShowControl(vctrl); } } } if (!(winp->flags & NATE_NOHSCROLL)) { if (teinfo->hctrl == (ControlHandle) NULL) { teinfo->hctrl = NewControl(winp->pwin, hrect, "\p", true, hvalue, 0, hmax, scrollBarProc, 0); if (winp->pwin != FrontWindow()) HiliteControl(teinfo->hctrl, 255); } else { if (hvalue < 0) hvalue = 0; if (hvalue > hmax) hvalue = hmax; SetCtlMax(hctrl = teinfo->hctrl, hmax); SetCtlValue(hctrl, hvalue); if (moved) { MoveControl(hctrl, hrect->left, hrect->top); SizeControl(hctrl, hrect->right - hrect->left, hrect->bottom - hrect->top); ShowControl(hctrl); } } } }
/* 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); } }
/* 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); }
McoStatus DisplayDialog::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 == 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[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(); } } } SetPort(oldp); return status; }
McoStatus TableDialog::readInPatches(void) { int i,count; short item; short itemtype; Handle cn1,sliderControl; Rect r; McoStatus state; int32 start_patch; //current_patch = current_patch/patch_per_strip; //current_patch *= patch_per_strip; start_patch = current_patch; count = 0; do { state = tcom->getNextPatch(current_patch,&patch_data[current_patch*3],0); if (state == MCO_SUCCESS) { playSound(EndColumnNum); } count ++; } while ((state != MCO_SUCCESS) && (count < 5)); if (state != MCO_SUCCESS) { //tcom->TurnOnStripRead(); return state; } //playSound(ClickNum); if (doc->patchtype == No_Patches) doc->patchtype = patchtype; GetDItem ( dp, Slider, &itemtype, (Handle*)&sliderControl, &r ); SetCtlValue ( (ControlHandle)sliderControl,current_patch); //ShowPatchScroll(current_patch); current_patch = next_patch[current_patch]; //current_patch++; // check for error checkError(start_patch); if (current_patch >= total_patches) { current_patch = total_patches -1; _waiting = FALSE; } ShowPatchScroll(current_patch); 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; SetSheetStripText(); //tcom->TurnOnStripRead(); return MCO_SUCCESS; }
TechkonDialog::TechkonDialog(ProfileDoc *dc,RawData *pD):InputDialog(dc,pD,1) { short iType; Handle iHandle; Handle sHandle; Rect iRect, r,pRect,tRect; UserItemUPP box3D; QDErr error; GDHandle oldGD; GWorldPtr oldGW; RGBColor c,oldbackcolor,oldforecolor; WindowPtr oldP; OSErr err; int32 i,wi,hi; double w,h; short gtsl_ids[] = GTSL_IDS; Str255 theString; PixMapHandle bigPixMap; McoStatus state; for (i=0; i<NumInputIDS; i++) ids[i] = gtsl_ids[i]; WinType = TechkonWindow; WinNum = 0; setDialog(Input_Dialog); frame_button(ids[Ok_Box]); // Added by James, 3D the box threeD_box(ids[ThreeDBox]); HideDItem(dp,ids[Redo]); GetDItem ( dp,ids[Message], &iType, (Handle*)&iHandle, &iRect ); GetIndString(theString,Message_List_ID,6); SetIText(iHandle,theString); Scramble = FALSE; if (Scramble) { voice_set = 1; } else { Disable(dp,ids[VoiceSet]); voice_set = 2; } // initialize comminications with the device state = doc->openInputDevice(0,0,0); if (state != MCO_SUCCESS) McoErrorAlert(state); // initialize the big gworld GetDItem (dp, ids[Strip_Rect], &iType, (Handle*)&iHandle, &iRect); tRect = iRect; OffsetRect(&tRect,-iRect.left,-iRect.top); error = NewGWorld( &BigGW, 32, &tRect, 0, 0, 0 ); if (error != 0) { delete this; return; } GetGWorld(&oldGW,&oldGD); SetGWorld(BigGW,nil); // GetBackColor(&oldbackcolor); GetForeColor(&oldforecolor); c.red = 65535; c.green = 65535; c.blue = 65535; RGBBackColor(&c); c.red = 0; c.green = 0; c.blue = 0; RGBForeColor(&c); bigPixMap = GetGWorldPixMap ( BigGW ); if (LockPixels ( bigPixMap )) EraseRect( &tRect ); SetGWorld(oldGW,oldGD); // RGBBackColor(&oldbackcolor); RGBForeColor(&oldforecolor); // SetPort(oldP); GetDItem (dp, ids[Patch_Rect], &iType, (Handle*)&iHandle, &pRect); num_display_patch = (iRect.bottom-iRect.top)/(pRect.bottom-pRect.top); top_patch = 0; //init the static members //current_patch = total_patches-1; //current_patch = 0; current_patch = 0; current_strip = 0; current_sheet = 0; _done = 0; _waiting = 0; SetSheetStripText(); current_top = current_patch - 2*num_display_patch/3; current_bottom = current_top + num_display_patch - 1; if (current_top < 0) { current_top = 0; current_bottom = current_top + num_display_patch - 1; } if (current_bottom >= total_patches-1) { current_bottom = total_patches - 1; current_top = current_bottom - num_display_patch + 1; } current_disp = 2*num_display_patch/3; init(); getpatchRGB(); Disable(dp,ids[Redo]); GetDItem (dp, ids[Slider], &iType, (Handle*)&iHandle, &pRect); SetCtlMin((ControlHandle)iHandle,0); SetCtlMax((ControlHandle)iHandle,total_patches-1); GetDItem(dp, ids[VoiceSet], &iType, (Handle*)&iHandle, &pRect); SetCtlValue((ControlHandle)iHandle,1); //voice_set = 1; checkFinished(); DrawWindow(); }
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; }
void RchooseDialog::setDialogState(void) { int i,m; MenuHandle menuH; short menucount; short item; short iType; Handle iHandle; Rect iRect; switch (_which) { case DT_TiffFile: if (DataFile < 0) _which = 1; break; case DT_DTP51: if (DTP51 < 0) _which = 1; break; case DT_XriteDTP41: if (DTP41 < 0) _which = 1; break; case DT_TechkonCP300: if (TechkonCP300 < 0) _which = 1; break; case DT_TechkonSP820: if (TechkonSP820 < 0) _which = 1; break; case DT_TechkonTCRCP300: if (TechkonTCRCP300 < 0) _which = 1; break; case DT_TechkonTCRSP820: if (TechkonTCRSP820 < 0) _which = 1; break; case DT_GretagHand: if (GretagHand < 0) _which = 1; break; case DT_GretagTable: if (GretagTable < 0) _which = 1; break; case DT_Xrite408: if (XR408 < 0) _which = 1; break; } switch (_which) { case (DT_DataFile): Disable(dialogptr,PatchFormat); Disable(dialogptr,DevicePort); menuH = GetMenu(Table_menu); menucount = CountMItems(menuH); for( i = menucount; i > 0; i-- ) DelMenuItem(menuH,i); _which_patch = 1; GetDItem (dialogptr, PatchFormat, &iType, &iHandle, &iRect); SetCtlValue((ControlHandle)iHandle,_which_patch); DrawControls(dialogptr); break; case (DT_DTP51): Enable(dialogptr,PatchFormat); Enable(dialogptr,DevicePort); menuH = GetMenu(Table_menu); menucount = CountMItems(menuH); for( i = menucount; i > 0; i-- ) DelMenuItem(menuH,i); m = 1; for (i=0; i<doc->patchset->filenum; i++) { if (doc->patchset->patches[i] != NULL) { if ( doc->patchset->patches[i]->patches.strips == 1) { convert[m] = i; convert2[i] = m; InsMenuItem(menuH, doc->patchset->patchames[i], m++); } } } //_which_patch = 1; GetDItem (dialogptr, PatchFormat, &iType, &iHandle, &iRect); SetCtlValue((ControlHandle)iHandle,convert2[_which_patch]); GetDItem (dialogptr, DevicePort, &iType, &iHandle, &iRect); SetCtlValue((ControlHandle)iHandle,_which_port); DrawControls(dialogptr); break; case (DT_TiffFile): Enable(dialogptr,PatchFormat); Disable(dialogptr,DevicePort); menuH = GetMenu(Table_menu); menucount = CountMItems(menuH); for( i = menucount; i > 0; i-- ) DelMenuItem(menuH,i); m = 1; for (i=0; i<doc->patchset->filenum; i++) { if (doc->patchset->patches[i] != NULL) { if (doc->patchset->patches[i]->patches.strips == 0) { convert[m] = i; convert2[i] = m; InsMenuItem(menuH, doc->patchset->patchames[i], m++); } } } //_which_patch = 1; GetDItem (dialogptr, PatchFormat, &iType, &iHandle, &iRect); SetCtlValue((ControlHandle)iHandle,convert2[_which_patch]); GetDItem (dialogptr, DevicePort, &iType, &iHandle, &iRect); SetCtlValue((ControlHandle)iHandle,_which_port); DrawControls(dialogptr); break; case (DT_TechkonCP300): case (DT_TechkonSP820): case (DT_TechkonTCRCP300): case (DT_TechkonTCRSP820): case (DT_GretagHand): case (DT_GretagTable): Enable(dialogptr,PatchFormat); Enable(dialogptr,DevicePort); menuH = GetMenu(Table_menu); menucount = CountMItems(menuH); for( i = menucount; i > 0; i-- ) DelMenuItem(menuH,i); m = 1; for (i=0; i<doc->patchset->filenum; i++) { if (doc->patchset->patches[i] != NULL) { if (doc->patchset->patches[i]->patches.strips == 0) { convert[m] = i; convert2[i] = m; InsMenuItem(menuH, doc->patchset->patchames[i], m++); } } } //_which_patch = 1; GetDItem (dialogptr, PatchFormat, &iType, &iHandle, &iRect); SetCtlValue((ControlHandle)iHandle,convert2[_which_patch]); GetDItem (dialogptr, DevicePort, &iType, &iHandle, &iRect); SetCtlValue((ControlHandle)iHandle,_which_port); DrawControls(dialogptr); break; case (DT_Xrite408): Disable(dialogptr,PatchFormat); break; } if ((!density) && (_which == DT_Xrite408)) Disable(dialogptr,1); else Enable(dialogptr,1); }
RchooseDialog::RchooseDialog(ProfileDocInf *d,int den) { short iType; Handle iHandle; Rect iRect; long id; int i; MenuHandle menuH; int which; doc = d; density = den; _which = doc->defaults->input_type; _which_patch = doc->defaults->patch_format; _which_port = doc->defaults->port; if (_which == DT_None) _which = DT_TechkonSP820; switch (_which) { case DT_TiffFile: which = DataFile; break; case DT_DTP51: which = DTP51; break; case DT_XriteDTP41: which = DTP41; break; case DT_TechkonCP300: which = TechkonCP300; break; case DT_TechkonSP820: which = TechkonSP820; break; case DT_TechkonTCRCP300: which = TechkonTCRCP300; break; case DT_TechkonTCRSP820: which = TechkonTCRSP820; break; case DT_GretagHand: which = GretagHand; break; case DT_GretagTable: which = GretagTable; break; case DT_Xrite408: which = XR408; break; } setDialog(Rchoose_Dialog); frame_button(); for (i=0; i<MAX_PATCH_NAMES; i++) { convert[i] = 0; convert2[i] = 0; } GetDItem (dialogptr, FileType, &iType, &iHandle, &iRect); SetCtlValue((ControlHandle)iHandle,which); if ((XR408 != -1) && (!density)) { menuH = GetMenu(DeviceMenuID); DisableItem(menuH,XR408); } setDialogState(); }
SpChInDialog::SpChInDialog(ProfileDoc *dc,RawData *pD):TableDialog(dc,pD) { short iType; Handle iHandle; Handle sHandle; Rect iRect, r,pRect,tRect; UserItemUPP box3D; QDErr error; GDHandle oldGD; GWorldPtr oldGW; RGBColor c,oldbackcolor,oldforecolor; WindowPtr oldP; OSErr err; int32 i,wi,hi; double w,h; short spc_ids[] = SPC_IDS; McoStatus state; int papernum; for (i=0; i<NumInputIDS; i++) ids[i] = spc_ids[i]; WinType = StripDialog; WinNum = 0; setDialog(Input_Dialog); frame_button(ids[Ok_Box]); SetSheetStripText(); // Added by James, 3D the box threeD_box(ids[ThreeDBox]); // initialize comminications with the specrolino state = doc->openInputDevice(0,0,0); if (state != MCO_SUCCESS) McoErrorAlert(state); w = patchD->patches.width; h = patchD->patches.height; if (patchD->type == CMYKPatches) papernum = 0; else if (patchD->type == RGBPatches) papernum = patchD->format.total; if (doc->tcom != 0L) ((SpectroChart*)(doc->tcom))->setUpPatches(patchD->patches.columns,patchD->patches.rows,w,h,patchD->patches.starting,patchD->patches.direction,papernum); if (doc->tcom->device_num != DT_GretagTable) { McoErrorAlert(MCO_FAILURE); } // initialize the big gworld GetDItem (dp, ids[Strip_Rect], &iType, (Handle*)&iHandle, &iRect); tRect = iRect; OffsetRect(&tRect,-iRect.left,-iRect.top); error = NewGWorld( &BigGW, 32, &tRect, 0, 0, 0 ); if (error != 0) { delete this; return; } GetGWorld(&oldGW,&oldGD); SetGWorld(BigGW,nil); // GetBackColor(&oldbackcolor); GetForeColor(&oldforecolor); c.red = 65535; c.green = 65535; c.blue = 65535; RGBBackColor(&c); c.red = 0; c.green = 0; c.blue = 0; RGBForeColor(&c); // EraseRect( &tRect ); SetGWorld(oldGW,oldGD); // RGBBackColor(&oldbackcolor); RGBForeColor(&oldforecolor); // SetPort(oldP); GetDItem (dp, ids[Patch_Rect], &iType, (Handle*)&iHandle, &pRect); num_display_patch = (iRect.bottom-iRect.top)/(pRect.bottom-pRect.top); top_patch = 0; current_top = current_patch - 2*num_display_patch/3; current_bottom = current_top + num_display_patch - 1; if (current_top < 0) { current_top = 0; current_bottom = current_top + num_display_patch - 1; } if (current_bottom >= total_patches-1) { current_bottom = total_patches - 1; current_top = current_bottom - num_display_patch + 1; } current_disp = 2*num_display_patch/3; init(); getpatchRGB(); dtype = DType_Density; Disable(dp,ids[Redo]); GetDItem (dp, ids[Slider], &iType, (Handle*)&iHandle, &pRect); SetCtlMin((ControlHandle)iHandle,0); SetCtlMax((ControlHandle)iHandle,total_patches-1); if (ids[VoiceSet] > -1) { GetDItem(dp, ids[VoiceSet], &iType, (Handle*)&iHandle, &pRect); SetCtlValue((ControlHandle)iHandle,1); } //voice_set = 1; if (ids[Lift] > -1) HideDItem(dp,ids[Lift]); checkFinished(); DrawWindow(); }
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; }
McoStatus SpChInDialog::readInPatches(void) { int i,count; short item; short itemtype; Handle cn1,sliderControl; Rect r; McoStatus state; int32 start_patch; double data[4]; SpectroChart *tcom = (SpectroChart*)(doc->tcom); //current_patch = current_patch/patch_per_strip; //current_patch *= patch_per_strip; start_patch = current_patch; if (!doc->tcom) return MCO_SUCCESS; count = 0; if ((current_patch < patchD->format.total) || (patchD->format.numLinear == 0)) doc->tcom->SetLabOutput(); else doc->tcom->SetDensityOutput(); do { state = doc->tcom->getNextPatch(current_patch,data); if (state == MCO_SUCCESS) { playSound(EndColumnNum); } count ++; } while ((state != MCO_SUCCESS) && (count < 1)); if (state != MCO_SUCCESS) { //tcom->TurnOnStripRead(); return state; } if ((current_patch < patchD->format.total) || (patchD->format.numLinear == 0)) { patch_data[current_patch*3] = data[0]; patch_data[current_patch*3+1] = data[1]; patch_data[current_patch*3+2] = data[2]; } else { i = (current_patch-patchD->format.total)/(patchD->format.numLinear-1); patch_data[current_patch*3] = data[i]; patch_data[current_patch*3+1] = 0; patch_data[current_patch*3+2] = 0; } //playSound(ClickNum); if (doc->patchtype == No_Patches) doc->patchtype = patchtype; GetDItem ( dp,ids[Slider], &itemtype, (Handle*)&sliderControl, &r ); SetCtlValue ( (ControlHandle)sliderControl,current_patch); //ShowPatchScroll(current_patch); last_patch = current_patch; current_patch = next_patch[current_patch]; //current_patch++; // check for error //checkError(start_patch); if (current_patch >= total_patches) { current_patch = total_patches -1; _waiting = FALSE; } ShowPatchScroll(current_patch); 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; SetSheetStripText(); //tcom->TurnOnStripRead(); return MCO_SUCCESS; }