Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- // Doesn't work for versions before CS3
- static SPErr GetCurrentTool()
- {
- SPErr err = 0;
- PIActionReference toolPropRef = 0;
- PIActionDescriptor inputDesc = 0;
- if ((err = sPSActionReference->Make(&toolPropRef)))
- {
- debugOutError("sPSActionReference->Make() returned %d", err);
- return err;
- }
- if ((err = sPSActionReference->PutProperty(toolPropRef, 'Prpr', 'Tool')))
- {
- debugOutError("sPSActionReference->PutProperty() returned %d", err);
- goto end;
- }
- if ((err = sPSActionReference->PutEnumerated(toolPropRef, 'capp', 'Ordn', 'Trgt')))
- {
- debugOutError("sPSActionReference->PutEnumerated() returned %d", err);
- goto end;
- }
- if ((err = sPSActionControl->Get(&inputDesc, toolPropRef)))
- {
- debugOutError("sPSActionControl->Get() returned %d %s", err, PIUIDToChar(err));
- goto end;
- }
- unsigned int descCount = 0;
- if ((err = sPSActionDescriptor->GetCount(inputDesc, &descCount)))
- {
- debugOutError("sPSActionDescriptor->GetCount() returned %d", err);
- goto end;
- }
- for (unsigned int c = 0; c < descCount; ++c)
- {
- // get the key for this item
- DescriptorKeyID thisKeyID;
- if ((err = sPSActionDescriptor->GetKey(inputDesc, c, &thisKeyID)))
- {
- debugOutError("sPSActionDescriptor->GetKey() returned %d", err);
- goto end;
- }
- // get the type for this key
- DescriptorTypeID typeID;
- if ((err = sPSActionDescriptor->GetType(inputDesc, thisKeyID, &typeID)))
- {
- debugOutError("sPSActionDescriptor->GetType() returned %d", err);
- goto end;
- }
- // we're looking for the enum
- if (typeID != typeEnumerated)
- continue;
- DescriptorEnumTypeID type;
- DescriptorEnumID value;
- sPSActionDescriptor->GetEnumerated(inputDesc, thisKeyID, &type, &value);
- //debugOut("type: %d %s, value: %d %s", type, PIUIDToChar(type), value, PIUIDToChar(value));
- char classStr[255] = { 0 };
- if ((err = sPSActionControl->TypeIDToStringID(type, classStr, 255)))
- {
- debugOutError("sPSActionControl->TypeIDToStringID() returned %d", err);
- goto end;
- }
- setPSTool(classStr);
- }
- end:
- if (inputDesc)
- sPSActionDescriptor->Free(inputDesc);
- if (toolPropRef)
- sPSActionReference->Free(toolPropRef);
- return err;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement