Ejemplo n.º 1
0
OSErr WriteScriptParams (GPtr globals)
{
	PIWriteDescriptor	token = NULL;	// token to write our parameters to
	OSErr				err = noErr; // we'll return any error with this
			
	if (DescriptorAvailable(NULL))
	{ // Descriptor suite is available.  Open a token:
	
		// PIUtilities has a routine that will create a descriptor to write
		// parameters to:
		token = OpenWriter();
		
		if (token)
		{ // was able to create the token, write our keys:
			
			// Write scripting keys and values here.
			// See PIActions.h and PIUtilities.h for
			// routines and macros for scripting functions.

			// PIUtilities has a routine that will close the token, collapse
			// it, and store it in the struct that the host will then grab
			// and store for recording and/or subsequent scripting.  It tells
			// the host that the dialog is optional.  You can override this
			// by setting recordInfo to whatever you need.  It then
			// deallocates token and sets it to NULL:
			err = CloseWriter(&token);
			
		} // wasn't able to create token
	
	} // descriptor suite unavailable
	
	return err;
	
} // end WriteScriptParams
OSErr WriteScriptParams (GPtr globals)
{
	PIWriteDescriptor	token = NULL;	// token to write our parameters to
	OSErr				err = noErr; // we'll return any error with this
			
	if (DescriptorAvailable(NULL))
	{ // Descriptor suite is available.  Open a token:
	
		// PIUtilities has a routine that will create a descriptor to write
		// parameters to:
		token = OpenWriter();
		
		if (token)
		{ // was able to create the token, write our keys:
			PIPutInt(token, keyHorizontal, gPointH);
			PIPutInt(token, keyVertical, gPointV);
			PIPutInt(token, keyXFactor, gXFactor);
			PIPutBool(token, keyGaussianBlurData, gGaussianBlurData);

			// PIUtilities has a routine that will close the token, collapse
			// it, and store it in the struct that the host will then grab
			// and store for recording and/or subsequent scripting.  It tells
			// the host that the dialog is optional.  You can override this
			// by setting recordInfo to whatever you need.  It then
			// deallocates token and sets it to NULL:
			err = CloseWriter(&token);
			
		} // wasn't able to create token
	
	} // descriptor suite unavailable
	
	return err;
	
} // end WriteScriptParams
Ejemplo n.º 3
0
OSErr WriteScriptParams (GPtr globals)
{
	PIWriteDescriptor			token = NULL;
	double						percent = gPercent;
	OSErr						gotErr = noErr;
			
	if (DescriptorAvailable(NULL))
	{ /* recording.  Do our thing. */
		token = OpenWriter();
		if (token)
		{
			PIPutEnum(token,
					  keyMyArea,
					  typeMySelect,
					  EnumToKey(gWhatArea, typeMySelect));
			if (gWhatArea == iSelectRandom)
				PIPutUnitFloat(token, keyMyAmount, unitPercent, &percent);
			PIPutEnum(token,
					  keyMyChannels,
					  typeMyComposite,
					  EnumToKey(gWhatChannels, typeMyComposite));
			PIPutEnum(token,
					  keyMyCreate,
					  typeMyCreate,
					  EnumToKey(gCreate, typeMyCreate));
			gotErr = CloseWriter(&token); /* closes and sets to dialog optional */
		/* done.  Now pass handle on to Photoshop */
		}
	}
	return gotErr;
}
Ejemplo n.º 4
0
Boolean ReadScriptParams (GPtr globals)
{
	PIReadDescriptor			token = NULL;
	DescriptorKeyID				key = NULLID;
	DescriptorTypeID			type = NULLID;
	double						percent = 0;
	const double				minValue = kPercentMin, maxValue = kPercentMax;
	DescriptorUnitID			percentUnitPass = unitPercent;
	OSType						x = typeNull;
	DescriptorKeyIDArray		array = { keyMyShape, keyMyChannels, keyMyCreate, NULLID };
	int32						flags = 0;
	OSErr						stickyError = noErr;
	Boolean						returnValue = true;
	
	if (DescriptorAvailable(NULL))
	{ /* playing back.  Do our thing. */
		token = OpenReader(array);
		if (token)
		{
			while (PIGetKey(token, &key, &type, &flags))
			{
				switch (key)
				{
					case keyMyArea:
						PIGetEnum(token, &x);
						gWhatArea = KeyToEnum(x, typeMySelect);
						break;
					case keyMyAmount: // optional
						PIGetPinUnitFloat(token, &minValue, &maxValue, &percentUnitPass, &percent);
						gPercent = (short)percent;
						break;
					case keyMyChannels:
						PIGetEnum(token, &x);
						gWhatChannels = KeyToEnum(x, typeMyComposite);
						break;
					case keyMyCreate:
						PIGetEnum(token, &x);
						gCreate = KeyToEnum(x, typeMyCreate);
						break;
				}
			}

			stickyError = CloseReader(&token); // closes & disposes.
				
			if (stickyError)
			{
				if (stickyError == errMissingParameter) // missedParamErr == -1715
					;
					/* (descriptorKeyIDArray != NULL)
					   missing parameter somewhere.  Walk IDarray to find which one. */
				else
					gResult = stickyError;
			}
		}		
		returnValue = PlayDialog();
		/* return TRUE if want to show our Dialog */
	}
	return returnValue;
}
Ejemplo n.º 5
0
Boolean ReadScriptParams (GPtr globals)
{
	PIReadDescriptor	token = NULL;	// token we'll use to read descriptor
	DescriptorKeyID		key = NULLID;	// the next key
	DescriptorTypeID	type = NULLID;	// the type of the key we read
	int32				flags = 0;		// any flags for the key
	
	// Populate this array if we're expecting any keys,
	// must be NULLID terminated:
	DescriptorKeyIDArray array = { NULLID };
	
	// While we're reading keys, errors will stick around and be reported
	// when we close the token:
	OSErr				err = noErr;
	
	// Assume we want to pop our dialog unless explicitly told not to:
	Boolean				returnValue = true;
	
	if (DescriptorAvailable(NULL))
	{ // descriptor suite is available, go ahead and open descriptor:
	
		// PIUtilities routine to open descriptor handed to us by host:
		token = OpenReader(array);
		
		if (token)
		{ // token was valid, so read keys from it:
			
			while (PIGetKey(token, &key, &type, &flags))
			{ // got a valid key.  Figure out where to put it:
			
				switch (key)
				{ // match a key to its expected type:case keyAmount:
					case 0:
						break;

					default:
						break;
					// Read scripting keys and values here.
					// See PIActions.h and PIUtilities.h for
					// routines and macros for scripting functions.
				
				} // key
				
			} // PIGetKey

			// PIUtilities routine that automatically deallocates,
			// closes, and sets token to NULL:
			err = CloseReader(&token);
				
			if (err)
			{ // an error did occur while we were reading keys:
			
				if (err == errMissingParameter) // missedParamErr == -1715
				{ // missing parameter somewhere.  Walk IDarray to find which one.
				}
				else
				{ // serious error.  Return it as a global result:
					gResult = err;
				}
					
			} // stickyError
						
		} // didn't have a valid token
		
		// Whether we had a valid token or not, we were given information
		// as to whether to pop our dialog or not.  PIUtilities has a routine
		// to check that and return TRUE if we should pop it, FALSE if not:	
		returnValue = PlayDialog();
	
	} // descriptor suite unavailable
	
	return returnValue;
	
} // end ReadScriptParams
OSErr ReadScriptParams (GPtr globals)
{
	PIReadDescriptor	token = NULL;	// token we'll use to read descriptor
	DescriptorKeyID		key = NULLID;	// the next key
	DescriptorTypeID	type = NULLID;	// the type of the key we read
	int32				flags = 0;		// any flags for the key
	
	// Populate this array if we're expecting any keys,
	// must be NULLID terminated:
	DescriptorKeyIDArray	array = { keyHorizontal, keyVertical, keyXFactor, keyGaussianBlurData, NULLID };
	
	// While we're reading keys, errors will stick around and be reported
	// when we close the token:
	OSErr				err = noErr;
	
	// Assume we want to pop our dialog unless explicitly told not to:
	Boolean				returnValue = gQueryForParameters;
	
	if (DescriptorAvailable(NULL))
	{ // descriptor suite is available, go ahead and open descriptor:
	
		// PIUtilities routine to open descriptor handed to us by host:
		token = OpenReader(array);
		
		if (token)
		{ // token was valid, so read keys from it:
			while (PIGetKey(token, &key, &type, &flags))
			{ // got a valid key.  Figure out where to put it:
			
				switch (key)
				{ // match a key to its expected type:case keyAmount:
					case keyHorizontal:
						int32 h;
						err = PIGetInt(token, &h);
						gPointH = (short)h;
						break;
					case keyVertical:
						int32 v;
						err = PIGetInt(token, &v);
						gPointV = (short)v;
						break;
					case keyXFactor:
						err = PIGetInt(token, &gXFactor);
						break;
					case keyGaussianBlurData:
						err = PIGetBool(token, &gGaussianBlurData);
						break;
					// ignore all other cases and classes
				} // key
				
			} // PIGetKey

			// PIUtilities routine that automatically deallocates,
			// closes, and sets token to NULL:
			err = CloseReader(&token);
				
			if (err)
			{ // an error did occur while we were reading keys:
			
				if (err == errMissingParameter) // missedParamErr == -1715
				{ // missing parameter somewhere.  Walk IDarray to find which one.
				}
				else
				{ // serious error.  Return it as a global result:
					gResult = err;
				}
					
			} // stickyError
						
		} // didn't have a valid token
		
		// Whether we had a valid token or not, we were given information
		// as to whether to pop our dialog or not.  PIUtilities has a routine
		// to check that and return TRUE if we should pop it, FALSE if not:	
		returnValue = PlayDialog();
	
	} // descriptor suite unavailable
	
	gQueryForParameters = returnValue;
	
	return err;
	
} // end ReadScriptParams