//------------------------------------------------------------------------------- // // 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; }
void GetKeysAction::Rewind() { if(m_Token) m_pReadProcs->closeReadDescriptorProc(m_Token); m_Token = m_pReadProcs->openReadDescriptorProc(m_pDescParams->descriptor, NULL); }
//------------------------------------------------------------------------------- // // 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; }
void OpenScriptParams (GPtr globals) { DescriptorKeyID key = 0; DescriptorTypeID type = 0; int32 flags = 0; int32 depth = gOutputDepth; double rows = gLastRows, columns = gLastCols; const double minRows = kRowsMin, maxRows = kRowsMax, minColumns = kColumnsMin, maxColumns = kColumnsMax; unsigned long pixelsUnitPass = unitPixels; PIDescriptorHandle descriptor; ReadDescriptorProcs *reader; PIReadDescriptor token; // why the hell isn't this stuff in the main source base? #ifndef PIGetKey #define PIGetKey(token, key, type, flags) \ reader->getKeyProc(token, key, type, flags) #endif #ifndef PIGetPinUnitFloat #define PIGetPinUnitFloat(token, min, max, unit, value) \ reader->getPinnedUnitFloatProc(token, min, max, unit, value) #endif #ifndef PIGetInt #define PIGetInt(token, value) \ reader->getIntegerProc(token, value) #endif if (gStuff->descriptorParameters) { descriptor = gStuff->descriptorParameters->descriptor; reader = gStuff->descriptorParameters->readDescriptorProcs; token = reader->openReadDescriptorProc(descriptor, NULL); /* don't know how many we're going to be passed, so don't bother with array */ if (token) { while (PIGetKey(token, &key, &type, &flags)) { /* nothing to do here switch (key) { case keyVertical: PIGetPinUnitFloat(token, &minRows, &maxRows, &pixelsUnitPass, &rows); gLastRows = (int32)rows; break; case keyHorizontal: PIGetPinUnitFloat(token, &minColumns, &maxColumns, &pixelsUnitPass, &columns); gLastCols = (int32)columns; break; case keyDepth: PIGetInt(token, &depth); gOutputDepth = (int16)depth; break; } */ } } // HostCloseReader reader->closeReadDescriptorProc(token); PIDisposeHandle( gStuff->descriptorParameters->descriptor ); gStuff->descriptorParameters->descriptor = NULL; } /* return true if want to show our Dialog */ }
//------------------------------------------------------------------------------- // // 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; }