Contents

TwGetParam (function)

int TwGetParam(TwBar *bar, const char *varName, const char *paramName, TwParamValueType paramValueType, unsigned int outValueMaxCount, const void *outValues)

Description

This function returns the current value of a bar or variable parameter. Parameters define the behavior of bars and vars and may have been set or modified by functions TwDefine, TwAddVar* or TwSetParam.

Parameters

bar

Bar identifier. If the requested parameter is global (not linked to a particular bar), NULL may be used as identifier.

varName

varName is the name of the parameter’s variable (ie., the unique name used to create the variable).

If the parameter is directly related to a bar (and not specific to a var), varName should be NULL.

paramName

Name of the parameter. This is one of the key words listed in the bar parameters page if the parameter is directly related to a bar, or listed in the var parameters page if the parameter is related to a variable.

paramValueType

Type of the data to be stored in outValues. Should be one of the constants defined by TwParamValueType: TW_PARAM_INT32, TW_PARAM_FLOAT, TW_PARAM_DOUBLE or TW_PARAM_CSTRING.

outValueMaxCount

Each parameter may have one or more values (eg., a position parameter has two values x and y). outValueMaxCount is the maximum number of output values that the function can write in the outValues buffer.

If the parameter value is of type string, outValueMaxCount is the maximum number of characters allocated for the outValues buffer. In this case and if the parameter have more than one value, they are all written in the outValues string and separated by spaces.

outValues

Pointer to the buffer that will be filled with the requested parameter values. The buffer must be large enough to contain at least outValueMaxCount values of type specified by paramValueType.

Examples

// get the current position of a bar
int pos[2];
TwGetParam(bar, NULL, "position", TW_PARAM_INT32, 2, pos);
 
// check if a group is opened or closed
int opened;
TwGetParam(bar, "groupname", "opened", TW_PARAM_INT32, 1, &opened); 
 
// get a variable min value
double vmin;
TwGetParam(bar, "varname", "min", TW_PARAM_DOUBLE, 1, &vmin); 
 
// get the name of the group including a variable
char group[128]; // 128 chars max
TwGetParam(bar, "varname", "group", TW_PARAM_CSTRING, 128, group); 
 
// get the global iconmargin
int margin[2];
TwGetParam(NULL, NULL, "iconmargin", TW_PARAM_INT32, 2, margin);

Return value

See also

TwSetParam, TwDefine, bar parameters, var parameters