bool GetKeysAction::GetNextKey(DescriptorTypeID &type) { if(m_pDescParams == NULL) return false; int32 flags = 0; return !!m_pReadProcs->getKeyProc(m_Token, &m_CurKey, &type, &flags); }
//------------------------------------------------------------------------------- // // ReadScriptParameters // // See if we were called by the Photoshop scripting system and return the value // in displayDialog if the user wants to see our dialog. // //------------------------------------------------------------------------------- OSErr ReadScriptParameters(Boolean* displayDialog) { OSErr err = noErr; PIReadDescriptor token = NULL; DescriptorKeyID key = 0; DescriptorTypeID type = 0; int32 flags = 0; DescriptorKeyIDArray array = { keyPSGamma, keyPSInvert, 0 }; double gamma; Boolean invert; if (displayDialog != NULL) *displayDialog = gData->queryForParameters; else return errMissingParameter; if (!*displayDialog) { PIDescriptorParameters* descParams = gFilterRecord->descriptorParameters; if (descParams == NULL) return err; ReadDescriptorProcs* readProcs = gFilterRecord->descriptorParameters->readDescriptorProcs; if (readProcs == NULL) return err; if (descParams->descriptor != NULL) { token = readProcs->openReadDescriptorProc(descParams->descriptor, array); if (token != NULL) { while(readProcs->getKeyProc(token, &key, &type, &flags) && !err) { switch (key) { case keyPSGamma: err = readProcs->getFloatProc(token, &gamma); if (!err) gParams->gamma = gamma; break; case keyPSInvert: err = readProcs->getBooleanProc(token, &invert); if (!err) gParams->invert = invert != FALSE; break; default: err = readErr; break; } } err = readProcs->closeReadDescriptorProc(token); gFilterRecord->handleProcs->disposeProc(descParams->descriptor); descParams->descriptor = NULL; } *displayDialog = descParams->playInfo == plugInDialogDisplay; } } return err; }
//------------------------------------------------------------------------------- // // ReadScriptParamsOnRead // // Checks the parameters against scripting-returned parameters, if any, and // updates the globals to match ones provided by the scripting system. // // Inputs: // void Pointer to global structure. // // Outputs: // returns TRUE If you should pop your dialog. // returns FALSE If you should not pop your dialog. // // gResult Will return any fatal error. // //------------------------------------------------------------------------------- Boolean ReadScriptParamsOnRead (void) { DescriptorKeyID key = 0; DescriptorTypeID type = 0; DescriptorKeyIDArray array = { NULLID }; int32 flags = 0; OSErr stickyError = noErr; Boolean returnValue = true; PIDescriptorParameters * descParams = gFormatRecord->descriptorParameters; if (descParams == NULL) { return returnValue; } ReadDescriptorProcs * readProcs = descParams->readDescriptorProcs; if (readProcs == NULL) { return returnValue; } if (descParams->descriptor == NULL) { return returnValue; } PIReadDescriptor token = readProcs->openReadDescriptorProc(descParams->descriptor, array); if (token == NULL) { return returnValue; } while (readProcs->getKeyProc(token, &key, &type, &flags)) { switch (key) { case keyMyFoo: // readProcs->getBooleanProc(token, &gData->fooValueForRead); break; // check keys here } } stickyError = readProcs->closeReadDescriptorProc(token); // closes & disposes. // Dispose the parameter block descriptor: sPSHandle->Dispose(descParams->descriptor); descParams->descriptor = NULL; if (stickyError) { if (stickyError == errMissingParameter) {// missedParamErr == -1715 ; } /* (descriptorKeyIDArray != NULL) missing parameter somewhere. Walk IDarray to find which one. */ else { *gResult = stickyError; } } returnValue = descParams->playInfo == plugInDialogDisplay; // return TRUE if want to show our Dialog return returnValue; }
//------------------------------------------------------------------------------- // // ReadScriptParamsOnWrite // // Checks the parameters against scripting-returned parameters, if any, and // updates the globals to match ones provided by the scripting system. // // Inputs: // void Pointer to global structure. // // Outputs: // returns TRUE If you should pop your dialog. // returns FALSE If you should not pop your dialog. // // gResult Will return any fatal error. // //------------------------------------------------------------------------------- Boolean ReadScriptParamsOnWrite (void) { DescriptorKeyID key = 0; DescriptorTypeID type = 0; DescriptorKeyIDArray array = { NULLID }; int32 flags = 0; OSErr stickyError = noErr; Boolean returnValue = true; PIDescriptorParameters * descParams = gFormatRecord->descriptorParameters; if (descParams == NULL) { return returnValue; } ReadDescriptorProcs * readProcs = gFormatRecord->descriptorParameters->readDescriptorProcs; if (readProcs == NULL) { return returnValue; } if (descParams->descriptor == NULL) { return returnValue; } PIReadDescriptor token = readProcs->openReadDescriptorProc(descParams->descriptor, array); if (token == NULL) { return returnValue; } while (readProcs->getKeyProc(token, &key, &type, &flags)) { switch (key) { case keyMyBar: // readProcs->getBooleanProc(token, &gData->barValueForWrite); break; } } stickyError = readProcs->closeReadDescriptorProc(token); // closes & disposes. // Dispose the parameter block descriptor: sPSHandle->Dispose(descParams->descriptor); descParams->descriptor = NULL; returnValue = descParams->playInfo == plugInDialogDisplay; // return TRUE if want to show our Dialog return returnValue; }
//------------------------------------------------------------------------------- // // ReadScriptParameters // // See if we were called by the Photoshop scripting system and return the value // in displayDialog if the user wants to see our dialog. // //------------------------------------------------------------------------------- OSErr ReadScriptParameters(Boolean* displayDialog) { OSErr err = noErr; PIReadDescriptor token = NULL; DescriptorKeyID key = 0; DescriptorTypeID type = 0; DescriptorUnitID units; int32 flags = 0; double percent; DescriptorEnumID disposition; Boolean ignoreSelection; DescriptorKeyIDArray array = { keyAmount, keyDisposition, 0 }; if (displayDialog != NULL) *displayDialog = gData->queryForParameters; else return errMissingParameter; PIDescriptorParameters* descParams = gFilterRecord->descriptorParameters; if (descParams == NULL) return err; ReadDescriptorProcs* readProcs = gFilterRecord->descriptorParameters->readDescriptorProcs; if (readProcs == NULL) return err; if (descParams->descriptor != NULL) { token = readProcs->openReadDescriptorProc(descParams->descriptor, array); if (token != NULL) { while(readProcs->getKeyProc(token, &key, &type, &flags) && !err) { switch (key) { case keyAmount: err = readProcs->getUnitFloatProc(token, &units, &percent); if (!err) gParams->percent = (int16)percent; break; case keyDisposition: err = readProcs->getEnumeratedProc(token, &disposition); if (!err) { gParams->disposition = ScriptToDialog(disposition); CopyColor(gData->color, gData->colorArray[gParams->disposition]); } break; case keyIgnoreSelection: err = readProcs->getBooleanProc(token, &ignoreSelection); if (!err) gParams->ignoreSelection = ignoreSelection; break; default: err = readErr; break; } } err = readProcs->closeReadDescriptorProc(token); gFilterRecord->handleProcs->disposeProc(descParams->descriptor); descParams->descriptor = NULL; } *displayDialog = descParams->playInfo == plugInDialogDisplay; } return err; }