/*------------------------------------------------------------------------*/ int set_format_n_property(char* pobjUID, size_t stackPointer, int valueType, int nbRow, int nbCol ) { BOOL status; char* format; if ( !isParameterStringMatrix( valueType ) ) { Scierror(999, _("Wrong type for '%s' property: String expected.\n"), "format_n"); return SET_PROPERTY_ERROR; } #if 0 if ( sciGetEntityType(pobj) != SCI_AXES ) { Scierror(999, _("'%s' property does not exist for this handle.\n"),"format_n"); return SET_PROPERTY_ERROR; } #endif format = getStringFromStack(stackPointer); status = setGraphicObjectProperty(pobjUID, __GO_FORMATN__, format, jni_string, 1); if (status == TRUE) { return SET_PROPERTY_SUCCEED; } else { Scierror(999, _("'%s' property does not exist for this handle.\n"),"format_n"); return SET_PROPERTY_ERROR; } }
/*------------------------------------------------------------------------*/ int set_tag_property(char* pobjUID, size_t stackPointer, int valueType, int nbRow, int nbCol ) { // Tag must be only one character string BOOL status = FALSE; if (valueType != sci_strings) { Scierror(999, _("Wrong type for '%s' property: A string expected.\n"), "Tag"); return SET_PROPERTY_ERROR; } if (nbCol != 1) { Scierror(999, _("Wrong size for '%s' property: A string expected.\n"), "Tag"); return SET_PROPERTY_ERROR; } status = setGraphicObjectProperty(pobjUID, __GO_TAG__, getStringFromStack(stackPointer), jni_string, 1); if (status == TRUE) { return SET_PROPERTY_SUCCEED; } else { Scierror(999, _("'%s' property does not exist for this handle.\n"), "Tag"); return SET_PROPERTY_ERROR; } }
int SetUicontrolRelief(void* _pvCtx, char* sciObjUID, size_t stackPointer, int valueType, int nbRow, int nbCol) { /* Relief can be flat, groove, raised, ridge, solid or sunken */ char* relief = NULL; BOOL status = FALSE; if (valueType != sci_strings) { /* Wrong datatype */ Scierror(999, const_cast<char*>(_("Wrong type for '%s' property: '%s', '%s', '%s', '%s', '%s' or '%s' expected.\n")), "Relief", "flat", "groove", "raised", "ridge", "solid", "sunken"); return SET_PROPERTY_ERROR; } if(nbCol != 1 || nbRow == 0) { /* Wrong string size */ Scierror(999, const_cast<char*>(_("Wrong size for '%s' property: '%s', '%s', '%s', '%s', '%s' or '%s' expected.\n")), "Relief", "flat", "groove", "raised", "ridge", "solid", "sunken"); return SET_PROPERTY_ERROR; } relief = getStringFromStack(stackPointer); if (stricmp(relief, "flat") != 0 && stricmp(relief, "groove") != 0 && stricmp(relief, "raised") != 0 && stricmp(relief, "ridge") != 0 && stricmp(relief, "solid") != 0 && stricmp(relief, "sunken") != 0) { /* Wrong string format */ Scierror(999, const_cast<char*>(_("Wrong value for '%s' property: '%s', '%s', '%s', '%s', '%s' or '%s' expected.\n")), "Relief", "flat", "groove", "raised", "ridge", "solid", "sunken"); return SET_PROPERTY_ERROR; } status = setGraphicObjectProperty(sciObjUID, __GO_UI_RELIEF__, relief, jni_string, 1); if (status == TRUE) { return SET_PROPERTY_SUCCEED; } else { Scierror(999, const_cast<char*>(_("'%s' property does not exist for this handle.\n")), "Relief"); return SET_PROPERTY_ERROR; } }
int SetUicontrolVerticalAlignment(void* _pvCtx, char* sciObjUID, size_t stackPointer, int valueType, int nbRow, int nbCol) { /* VerticalAlignment can be top, middle or bottom */ char* alignment = NULL; BOOL status = FALSE; // Vertical Alignment must be only one character string if (valueType != sci_strings) { Scierror(999, const_cast<char*>(_("Wrong type for '%s' property: '%s', '%s', or '%s' expected.\n")), "VerticalAlignment", "top", "middle", "bottom"); return SET_PROPERTY_ERROR; } if(nbCol != 1 || nbRow == 0) { Scierror(999, const_cast<char*>(_("Wrong size for '%s' property: '%s', '%s', or '%s' expected.\n")), "VerticalAlignment", "top", "middle", "bottom"); return SET_PROPERTY_ERROR; } alignment = getStringFromStack(stackPointer); if (stricmp(alignment, "top") != 0 && strcmp(alignment, "middle") != 0 && strcmp(alignment, "bottom") != 0) { /* Wrong string format */ Scierror(999, const_cast<char*>(_("Wrong value for '%s' property: '%s', '%s', or '%s' expected.\n")), "VerticalAlignment", "top", "middle", "bottom"); return SET_PROPERTY_ERROR; } status = setGraphicObjectProperty(sciObjUID, __GO_UI_VERTICALALIGNMENT__, alignment, jni_string, 1); if (status == TRUE) { return SET_PROPERTY_SUCCEED; } else { Scierror(999, const_cast<char*>(_("'%s' property does not exist for this handle.\n")), "VerticalAlignment"); return SET_PROPERTY_ERROR; } }
int SetUicontrolListboxTop(void* _pvCtx, char* sciObjUID, size_t stackPointer, int valueType, int nbRow, int nbCol) { int value = 0; int* valueTab; int valueSize = 0; int nbValues = 0; BOOL status = FALSE; if (valueType == sci_matrix) { if(nbCol > 1 || nbRow > 1) { /* Wrong value size */ Scierror(999, const_cast<char*>(_("Wrong size for '%s' property: A real expected.\n")), "ListboxTop"); return SET_PROPERTY_ERROR; } value = (int) getDoubleFromStack(stackPointer); } else if (valueType == sci_strings) // Ascendant compatibility { if(nbCol > 1 || nbRow > 1) { /* Wrong value size */ Scierror(999, const_cast<char*>(_("Wrong size for '%s' property: A real expected.\n")), "ListboxTop"); return SET_PROPERTY_ERROR; } nbValues = sscanf(getStringFromStack(stackPointer), "%d", &value); if(nbValues != 1) { /* Wrong value size */ Scierror(999, const_cast<char*>(_("Wrong value for '%s' property: A real expected.\n")), "ListboxTop"); return SET_PROPERTY_ERROR; } } else { /* Wrong datatype */ Scierror(999, const_cast<char*>(_("Wrong type for '%s' property: A real expected.\n")), "ListboxTop"); return SET_PROPERTY_ERROR; } valueSize = nbCol*nbRow; valueTab = new int[valueSize]; if (valueSize > 0) { valueTab[0] = value; } status = setGraphicObjectProperty(sciObjUID, __GO_UI_LISTBOXTOP__, valueTab, jni_int_vector, valueSize); delete[] valueTab; if (status == TRUE) { return SET_PROPERTY_SUCCEED; } else { Scierror(999, _("'%s' property does not exist for this handle.\n"), "ListboxTop"); return SET_PROPERTY_ERROR; } }
int SetUicontrolValue(char* sciObjUID, size_t stackPointer, 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; char* objectStyle = NULL; 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 = getDoubleMatrixFromStack(stackPointer); 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(getStringFromStack(stackPointer), "%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, const_cast<char*>(__GO_STYLE__), jni_string, (void**) &objectStyle); /* * For popumenus/listboxes: display a warning if the value is not an integer */ if (((strcmp(objectStyle, __GO_UI_POPUPMENU__) == 0) || (strcmp(objectStyle, __GO_UI_LISTBOX__) == 0)) && truncated) { sciprint(const_cast<char*>(_("Warning: '%s' 'Value' property should be an integer, the value will be truncated.\n")), objectStyle); } /* * For Checkboxes and Radiobuttons: display a warning if the value is neither equal to Min nor Max */ if ((strcmp(objectStyle, __GO_UI_CHECKBOX__) == 0) || (strcmp(objectStyle, __GO_UI_RADIOBUTTON__)) == 0) { getGraphicObjectProperty(sciObjUID, const_cast<char*>(__GO_UI_MIN__), jni_double, (void**) &pdblMinValue); getGraphicObjectProperty(sciObjUID, const_cast<char*>(__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")), objectStyle, "Min", "Max"); } } free(objectStyle); if ((strcmp(objectStyle, __GO_UI_POPUPMENU__) == 0) || (strcmp(objectStyle, __GO_UI_LISTBOX__) == 0)) { status = setGraphicObjectProperty(sciObjUID, const_cast<char*>(__GO_UI_VALUE__), truncatedValue, jni_double_vector, valueSize); } else { status = setGraphicObjectProperty(sciObjUID, const_cast<char*>(__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; } }