Example #1
0
//-------------------------------------------------------------------------------
//
// 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;
}
Example #2
0
bool GetKeysAction::GetBoolean()
{
	boolean bValue;
	OSErr iErr = m_pReadProcs->getBooleanProc(m_Token, &bValue);
	if(iErr)
		throw ExceptionSPErr(StringUtil::ssprintf("GetKeysAction::GetBoolean(%08x)", m_CurKey), iErr);
	return !!bValue;
}
Example #3
0
//-------------------------------------------------------------------------------
//
// 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;
}