int GetUicontrolStyle(void* _pvCtx, char *sciObjUID) { int iStyle = -1; int *piStyle = &iStyle; getGraphicObjectProperty(sciObjUID, __GO_STYLE__, jni_int, (void **) &piStyle); if (piStyle != NULL) { return sciReturnString(_pvCtx, IntToStyle(iStyle)); } else { Scierror(999, const_cast<char*>(_("No '%s' property for this object.\n")), "Style"); return FALSE; } }
int SetUicontrolMax(void* _pvCtx, int iObjUID, void* _pvData, int valueType, int nbRow, int nbCol) { double maxValue = 0.0; BOOL status = FALSE; double value = 0; double* pdblValue = &value; double minValue = 0.0; double* pdblMinValue = &minValue; int objectStyle = -1; int *piObjectStyle = &objectStyle; int type = -1; int* piType = &type; // Check type getGraphicObjectProperty(iObjUID, __GO_TYPE__, jni_int, (void**) &piType); if (type != __GO_UICONTROL__) { Scierror(999, const_cast<char*>(_("'%s' property does not exist for this handle.\n")), "Max"); return SET_PROPERTY_ERROR; } if (valueType != sci_matrix) { /* Wrong datatype */ Scierror(999, const_cast<char*>(_("Wrong type for '%s' property: A real expected.\n")), "Max"); return SET_PROPERTY_ERROR; } if (nbCol != 1 || nbRow != 1) { /* Wrong value size */ Scierror(999, const_cast<char*>(_("Wrong size for '%s' property: A real expected.\n")), "Max"); return SET_PROPERTY_ERROR; } /* Store the value in Scilab */ maxValue = ((double*)_pvData)[0]; /* * For Checkboxes and Radiobuttons: display a warning if the value is neither equal to Min nor Max */ getGraphicObjectProperty(iObjUID, __GO_STYLE__, jni_int, (void**) &piObjectStyle); if (objectStyle == __GO_UI_CHECKBOX__ || objectStyle == __GO_UI_RADIOBUTTON__) { getGraphicObjectProperty(iObjUID, __GO_UI_MIN__, jni_double, (void**) &pdblMinValue); getGraphicObjectProperty(iObjUID, __GO_UI_VALUE__, jni_double, (void**) &pdblValue); if ((value != minValue) && (value != maxValue)) { sciprint(const_cast<char*>(_("Warning: '%s' 'Value' property should be equal to either '%s' or '%s' property value.\n")), IntToStyle(objectStyle), "Min", "Max"); } } status = setGraphicObjectProperty(iObjUID, __GO_UI_MAX__, &maxValue, jni_double, 1); if (status == TRUE) { return SET_PROPERTY_SUCCEED; } else { Scierror(999, const_cast<char*>(_("'%s' property does not exist for this handle.\n")), "Max"); return SET_PROPERTY_ERROR; } }
int SetUicontrolValue(void* _pvCtx, char* sciObjUID, void* _pvData, int valueType, int nbRow, int nbCol) { double *value = NULL; double* truncatedValue = NULL; int valueSize = 0; int nbValues = 0; int kValue = 0; BOOL status = FALSE; BOOL truncated = FALSE; double maxValue = 0; double* pdblMaxValue = &maxValue; double minValue = 0; double* pdblMinValue = &minValue; int objectStyle = -1; int *piObjectStyle = &objectStyle; int type = -1; int *piType = &type; // Check type getGraphicObjectProperty(sciObjUID, __GO_TYPE__, jni_int, (void**) &piType); if (type != __GO_UICONTROL__) { Scierror(999, const_cast<char*>(_("'%s' property does not exist for this handle.\n")), "Value"); return SET_PROPERTY_ERROR; } if (valueType == sci_matrix) { if (nbRow > 1) { /* Wrong value size */ Scierror(999, const_cast<char*>(_("Wrong size for '%s' property: A real row vector expected.\n")), "Value"); return SET_PROPERTY_ERROR; } value = (double*)_pvData; valueSize = nbCol * nbRow; } else if (valueType == sci_strings) // Ascendant compatibility { if (nbCol > 1) { /* Wrong value size */ Scierror(999, const_cast<char*>(_("Wrong size for '%s' property: A string expected.\n")), "Value"); return SET_PROPERTY_ERROR; } value = new double[1]; valueSize = 1; nbValues = sscanf((char*)_pvData, "%lf", &value[0]); if (nbValues != 1) { /* Wrong value size */ Scierror(999, const_cast<char*>(_("Wrong value for '%s' property: A String containing a numeric value expected.\n")), "Value"); return SET_PROPERTY_ERROR; } } else { /* Wrong datatype */ Scierror(999, const_cast<char*>(_("Wrong type for '%s' property: A real row vector or a string expected.\n")), "Value"); return SET_PROPERTY_ERROR; } truncatedValue = new double[valueSize]; for (kValue = 0; kValue < valueSize; kValue++) { truncatedValue[kValue] = floor(value[kValue]); if (truncatedValue[kValue] != value[kValue]) { truncated = TRUE; } } getGraphicObjectProperty(sciObjUID, __GO_STYLE__, jni_int, (void**) &piObjectStyle); /* * For popumenus/listboxes: display a warning if the value is not an integer */ if ((objectStyle == __GO_UI_POPUPMENU__ || objectStyle == __GO_UI_LISTBOX__) && truncated) { sciprint(const_cast<char*>(_("Warning: '%s' 'Value' property should be an integer, the value will be truncated.\n")), IntToStyle(objectStyle)); } /* * For Checkboxes and Radiobuttons: display a warning if the value is neither equal to Min nor Max */ if (objectStyle == __GO_UI_CHECKBOX__ || objectStyle == __GO_UI_RADIOBUTTON__) { getGraphicObjectProperty(sciObjUID, __GO_UI_MIN__, jni_double, (void**) &pdblMinValue); getGraphicObjectProperty(sciObjUID, __GO_UI_MAX__, jni_double, (void**) &pdblMaxValue); if ((value[0] != minValue) && (value[0] != maxValue)) { sciprint(const_cast<char*>(_("Warning: '%s' 'Value' property should be equal to either '%s' or '%s' property value.\n")), IntToStyle(objectStyle), "Min", "Max"); } } if (objectStyle == __GO_UI_POPUPMENU__ || objectStyle == __GO_UI_LISTBOX__) { status = setGraphicObjectProperty(sciObjUID, __GO_UI_VALUE__, truncatedValue, jni_double_vector, valueSize); } else { status = setGraphicObjectProperty(sciObjUID, __GO_UI_VALUE__, value, jni_double_vector, valueSize); } delete[] truncatedValue; if (valueType == sci_strings) { delete[] value; } if (status == TRUE) { return SET_PROPERTY_SUCCEED; } else { Scierror(999, const_cast<char*>(_("'%s' property does not exist for this handle.\n")), "Value"); return SET_PROPERTY_ERROR; } }