From SDK sample; utility interface for parameter gathering that allows snippets to prompt
for a data type value(for example PMString, int32). The normal behavour
of this interface will be to pop a dialog and request a value to
be entered by the user. This allows code snippets to acquire parameter
values when they run.
The code below shows how to declare and use the interface to get the
value of a PMString:
<pre>
Utils<ISnipRunParameterUtils> parameterUtils;
PMString swatchName = parameterUtils->GetPMString("Swatch name", "Black");
if (parameterUtils->WasDialogCancelled()) {
The user cancelled and you should too, don't prompt for any more parameters, }
| virtual void ISnipRunParameterUtils::EnableDialog | ( | const bool16 | enable | ) | |
| pure virtual |
For the use of the SnippetRunner framework, please avoid. Controls the display of parameter dialogs(enabled by default). If ISnipRunParameterUtils::IsDailogEnabled is kFalse, no parameter dialogs will be displayed. In that case, ISnipRunParameterUtils calls will return the default value passed into the call.
You should not need to call this method but if you do please save the state of the flag before you change it and restore it after you are done, thank you.
- Parameters
| enable | IN kTrue to prompt the user for parameter values, kFalse otherwise. |
Implemented in SnipRunParameterUtils.
| virtual void ISnipRunParameterUtils::EnableTranslation | ( | const bool16 | enable | ) | |
| pure virtual |
For the use of the SnippetRunner framework, please avoid. Controls whether or not PMString's passed into parameter prompt calls are translatable. By default PMString's must be translatable.
You should not need to call this method but if you do please save the state of the flag before you change it and restore it after you are done, thank you.
Code snippets don't have to call this method. By default the strings used in snippets are not translatable and the SnippetRunner framework will make sure this API expects untranslatable strings to be passed.
If ISnipRunParameterUtils::IsTranslationEnabled is kFalse, PMString's passed into ISnipRunParameterUtils will be marked as untranslatable by calling PMString::SetTranslatable(kFalse).
- Parameters
| enable | IN kTrue to pass translatable strings, kFalse otherwise. |
Implemented in SnipRunParameterUtils.
| virtual int32 ISnipRunParameterUtils::GetChoice | ( | const PMString & | prompt, | | | const K2Vector< PMString > & | choices, | | | const int32 | defaultChoiceIndex = 0 | | ) | | const |
| pure virtual |
Return the index of a selected choice from a list of choices described
by a vector of PMString's.
The code below requests a choice between "DoThis" and "DoThat" to be made.
K2Vector<PMString> choices;
choices.push_back(PMString("DoThis"));
choices.push_back(PMString("DoThat"));
enum {kDoThis, kDoThat};
int32 choice = parameterUtils->GetChoice("What do you want to do.", choices);
if (parameterUtils->WasDialogCancelled() == kFalse) {
switch (choice)
{
case kDoThis:
case kDoThat:
}
}
- Parameters
| prompt | IN describing what the choice represents |
| choices | IN vector of strings representing the choices available |
| defaultChoiceIndex | IN (default 0) |
- Returns
- the index of the selected choice
Implemented in SnipRunParameterUtils.
| virtual int32 ISnipRunParameterUtils::GetInt32 | ( | const PMString & | prompt, | | | const int32 | defaultValue = 0, | | | const int32 | lowerLimit = 0, | | | const int32 | upperLimit = 0 | | ) | | const |
| pure virtual |
Return an int32 value.
The code below requests an int32 that represents a page number with a default value
of 1 and no range checking.
int32 pageNumber = parameterUtils->GetInt32("Page number", 1);
The code below checks the page number entered is in the range 1 to 9999:
int32 pageNumber = parameterUtils->GetInt32("Number of pages", 1, 1, 9999);
- Parameters
| prompt | IN describing what the int32 represents |
| defaultValue | IN (default 0) |
| lowerLimit | IN (default 0, if both lowerLimit and upperlimit are 0 range checking is switched off) |
| upperLimit | IN (default 0) |
- Returns
- an int32 value
Implemented in SnipRunParameterUtils.
| virtual PMReal ISnipRunParameterUtils::GetPMReal | ( | const PMString & | prompt, | | | const PMReal & | defaultValue = 0, | | | const PMReal & | lowerLimit = 0, | | | const PMReal & | upperLimit = 0 | | ) | | const |
| pure virtual |
Return a PMReal value.
The code below requests a PMReal that represents stroke weight with a default value of 1.0
and no range checking.
PMReal strokeWeight = parameterUtils->GetPMReal("Stroke weight", 1);
The code below checks the stroke weight entered is in the range 1 to 1000:
int32 pageNumber = parameterUtils->GetInt32("Number of pages", 1, 1, 1000);
- Parameters
| prompt | IN describing what the PMReal represents |
| defaultValue | IN (default 0) |
| lowerLimit | IN (default 0, if both lowerLimit and upperlimit are 0 range checking is switched off) |
| upperLimit | IN (default 0) |
- Returns
- a PMReal value
Implemented in SnipRunParameterUtils.