Ejemplo n.º 1
0
/*------------------------------------------------------------------------*/
int getMatteBorder(void* _pvCtx, int _iVar, int* _piParent, int _iPos, int _iObjUID)
{
    SciErr sciErr;
    int* piAddrList = NULL;
    char* pstFieldList[] = {"MatteBorder", "top", "left", "bottom", "right", "color"};
    double* pdblPosition = NULL;
    char* pstColor = NULL;
    int iListSize = 6;

    getGraphicObjectProperty(_iObjUID, __GO_POSITION__, jni_double_vector, (void **)&pdblPosition);
    getGraphicObjectProperty(_iObjUID, __GO_UI_FRAME_BORDER_COLOR__, jni_string, (void **)&pstColor);

    if (_piParent)
    {
        sciErr = createTListInList(_pvCtx, _iVar, _piParent, _iPos, iListSize, &piAddrList);
    }
    else
    {
        sciErr = createTList(_pvCtx, _iVar, iListSize, &piAddrList);
    }

    sciErr = createMatrixOfStringInList(_pvCtx, _iVar, piAddrList, 1, 1, iListSize, pstFieldList);
    if (sciErr.iErr)
    {
        return -1;
    }

    sciErr = createMatrixOfDoubleInList(_pvCtx, _iVar, piAddrList, 2, 1, 1, &pdblPosition[0]);
    if (sciErr.iErr)
    {
        return -1;
    }

    sciErr = createMatrixOfDoubleInList(_pvCtx, _iVar, piAddrList, 3, 1, 1, &pdblPosition[1]);
    if (sciErr.iErr)
    {
        return -1;
    }

    sciErr = createMatrixOfDoubleInList(_pvCtx, _iVar, piAddrList, 4, 1, 1, &pdblPosition[2]);
    if (sciErr.iErr)
    {
        return -1;
    }

    sciErr = createMatrixOfDoubleInList(_pvCtx, _iVar, piAddrList, 5, 1, 1, &pdblPosition[3]);
    if (sciErr.iErr)
    {
        return -1;
    }

    sciErr = createMatrixOfStringInList(_pvCtx, _iVar, piAddrList, 6, 1, 1, &pstColor);
    if (sciErr.iErr)
    {
        return -1;
    }

    return 0;
}
Ejemplo n.º 2
0
/*--------------------------------------------------------------------------*/
int createXMLObjectAtPosInList(int *list, int stackPos, int type, int pos, int id, void *pvApiCtx)
{
    const char **fields = NULL;
    int *mlistaddr = NULL;
    SciErr err;

    err = createMListInList(pvApiCtx, stackPos, list, pos, 2, &mlistaddr);
    if (err.iErr)
    {
        printError(&err, 0);
        return 0;
    }

    switch (type)
    {
        case XMLDOCUMENT:
            fields = _XMLDoc;
            break;
        case XMLELEMENT:
            fields = _XMLElem;
            break;
        case XMLATTRIBUTE:
            fields = _XMLAttr;
            break;
        case XMLNAMESPACE:
            fields = _XMLNs;
            break;
        case XMLLIST:
            fields = _XMLList;
            break;
        case XMLNOTHANDLED:
            fields = _XMLNotHandled;
            break;
        case XMLSET:
            fields = _XMLSet;
            break;
        case XMLVALID:
            fields = _XMLValid;
            break;
        default:
            Scierror(999, _("Unknown tag.\n"));
            return 0;
    }

    err = createMatrixOfStringInList(pvApiCtx, stackPos, mlistaddr, 1, 1, 2, fields);
    if (err.iErr)
    {
        printError(&err, 0);
        return 0;
    }

    err = createMatrixOfInteger32InList(pvApiCtx, stackPos, mlistaddr, 2, 1, 1, &id);
    if (err.iErr)
    {
        printError(&err, 0);
        return 0;
    }

    return 1;
}
Ejemplo n.º 3
0
//--------------------------------------------------------------------------------------------------------
int createScilabFannErrorStructFromCFannErrorStruct(struct fann_error* ann, FILE * log_file, unsigned int StackPos)
{
  int * pi_extra_addr = NULL;
  SciErr _sciErr;

  //The struct field names
  static char * fieldnames[] = {"fannerrorlist", "file"};

  _sciErr = createMList(pvApiCtx, StackPos, 2, &pi_extra_addr);
  if (_sciErr.iErr)
    {
      printError(&_sciErr, 0);
      return -1;
    }

  _sciErr = createMatrixOfStringInList(pvApiCtx, StackPos, pi_extra_addr, 1, 2, 1, fieldnames);
  if (_sciErr.iErr)
    {
      printError(&_sciErr, 0);
      return -1;
    }

  _sciErr = createPointerInList(pvApiCtx, StackPos, pi_extra_addr, 2, log_file);
  if (_sciErr.iErr)
    {
      printError(&_sciErr, 0);
      return -1;
    }

  return 0;
}
Ejemplo n.º 4
0
//--------------------------------------------------------------------------------------------------------
int createScilabFannTrainDataStructFromCFannTrainDataStruct(struct fann_train_data* ann_data, unsigned int StackPos)
{
  int * pi_extra_addr = NULL;
  SciErr _sciErr;

  //The struct field names
  static char * fieldnames[] = {"fanntraindatalist", "fann_train_data"};

  _sciErr = createMList(pvApiCtx, StackPos, 2, &pi_extra_addr);
  if (_sciErr.iErr)
    {
      printError(&_sciErr, -1);
      return 0;
    }

  _sciErr = createMatrixOfStringInList(pvApiCtx, StackPos, pi_extra_addr, 1, 2, 1, fieldnames);
  if (_sciErr.iErr)
    {
      printError(&_sciErr, -1);
      return 0;
    }

  _sciErr = createPointerInList(pvApiCtx, StackPos, pi_extra_addr, 2, ann_data);
  if (_sciErr.iErr)
    {
      printError(&_sciErr, -1);
      return 0;
    }

  return 0;
}
Ejemplo n.º 5
0
/*------------------------------------------------------------------------*/
int getNoBorder(void* _pvCtx, int _iVar, int* _piParent, int _iPos, int _iObjUID)
{
    SciErr sciErr;
    int* piAddrList = NULL;
    char* pstFieldList[] = {"NoBorder"};
    if (_piParent)
    {
        sciErr = createTListInList(_pvCtx, _iVar, _piParent, _iPos, 1, &piAddrList);
    }
    else
    {
        sciErr = createTList(_pvCtx, _iVar, 1, &piAddrList);
    }

    if (sciErr.iErr)
    {
        return -1;
    }

    sciErr = createMatrixOfStringInList(_pvCtx, _iVar, piAddrList, 1, 1, 1, pstFieldList);
    if (sciErr.iErr)
    {
        return -1;
    }

    return 0;
}
Ejemplo n.º 6
0
/*------------------------------------------------------------------------*/
int getEmptyBorder(void* _pvCtx, int _iVar, int* _piParent, int _iPos, int _iObjUID)
{
    SciErr sciErr;
    int* piAddrList = NULL;
    char* pstFieldList[] = {"EmptyBorder", "top", "left", "bottom", "right"};
    double* pdblPosition = NULL;
    int iListSize = 5;

    getGraphicObjectProperty(_iObjUID, __GO_POSITION__, jni_double_vector, (void **)&pdblPosition);

    if (pdblPosition == NULL)
    {
        iListSize = 1;
    }

    if (_piParent)
    {
        sciErr = createTListInList(_pvCtx, _iVar, _piParent, _iPos, iListSize, &piAddrList);
    }
    else
    {
        sciErr = createTList(_pvCtx, _iVar, iListSize, &piAddrList);
    }

    sciErr = createMatrixOfStringInList(_pvCtx, _iVar, piAddrList, 1, 1, iListSize, pstFieldList);
    if (sciErr.iErr)
    {
        return -1;
    }

    if (iListSize > 1)
    {
        sciErr = createMatrixOfDoubleInList(_pvCtx, _iVar, piAddrList, 2, 1, 1, &pdblPosition[0]);
        if (sciErr.iErr)
        {
            return -1;
        }

        sciErr = createMatrixOfDoubleInList(_pvCtx, _iVar, piAddrList, 3, 1, 1, &pdblPosition[1]);
        if (sciErr.iErr)
        {
            return -1;
        }

        sciErr = createMatrixOfDoubleInList(_pvCtx, _iVar, piAddrList, 4, 1, 1, &pdblPosition[2]);
        if (sciErr.iErr)
        {
            return -1;
        }

        sciErr = createMatrixOfDoubleInList(_pvCtx, _iVar, piAddrList, 5, 1, 1, &pdblPosition[3]);
        if (sciErr.iErr)
        {
            return -1;
        }
    }

    return 0;
}
Ejemplo n.º 7
0
void ScilabObjects::createEnvironmentObjectAtPos(int type, int pos, int id, const int envId, void * pvApiCtx)
{
    const char ** fields = 0;
    int * mlistaddr = 0;
    SciErr err;

    if (envId < 0)
    {
        throw ScilabAbstractEnvironmentException("Invalid environment");
    }

    switch (type)
    {
        case EXTERNAL_OBJECT:
            fields = static_cast<const char **>(_EOBJ);
            break;
        case EXTERNAL_CLASS:
            fields = static_cast<const char **>(_ECLASS);
            break;
        case EXTERNAL_VOID:
            fields = static_cast<const char **>(_EVOID);
            break;
        default :
            fields = static_cast<const char **>(_EOBJ);
            break;
    }

    err = createMList(pvApiCtx, pos, FIELDS_LENGTH, &mlistaddr);
    if (err.iErr)
    {
        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Cannot allocate memory"));
    }

    err = createMatrixOfStringInList(pvApiCtx, pos, mlistaddr, 1, 1, FIELDS_LENGTH, fields);
    if (err.iErr)
    {
        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Cannot allocate memory"));
    }

    err = createMatrixOfInteger32InList(pvApiCtx, pos, mlistaddr, EXTERNAL_ENV_ID_POSITION, 1, 1, &envId);
    if (err.iErr)
    {
        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Cannot allocate memory"));
    }

    err = createMatrixOfInteger32InList(pvApiCtx, pos, mlistaddr, EXTERNAL_OBJ_ID_POSITION, 1, 1, &id);
    if (err.iErr)
    {
        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Cannot allocate memory"));
    }
}
Ejemplo n.º 8
0
/*------------------------------------------------------------------------*/
int getCompoundBorder(void* _pvCtx, int _iVar, int* _piParent, int _iPos, int _iObjUID)
{
    SciErr sciErr;
    int* piAddrList = NULL;
    char* pstFieldList[] = {"CompoundBorder", "outer", "inner"};
    int iChildBorderOut = 0;
    int* piChildBorderOut = &iChildBorderOut;
    int iChildBorderIn = 0;
    int* piChildBorderIn = &iChildBorderIn;
    int iListSize = 3;

    getGraphicObjectProperty(_iObjUID, __GO_UI_FRAME_BORDER_OUT_BORDER__, jni_int, (void **)&piChildBorderOut);
    getGraphicObjectProperty(_iObjUID, __GO_UI_FRAME_BORDER_IN_BORDER__, jni_int, (void **)&piChildBorderIn);

    if (piChildBorderOut == NULL || piChildBorderIn == NULL)
    {
        iListSize = 1;
    }

    if (_piParent)
    {
        sciErr = createTListInList(_pvCtx, _iVar, _piParent, _iPos, iListSize, &piAddrList);
    }
    else
    {
        sciErr = createTList(_pvCtx, _iVar, iListSize, &piAddrList);
    }

    sciErr = createMatrixOfStringInList(_pvCtx, _iVar, piAddrList, 1, 1, iListSize, pstFieldList);
    if (sciErr.iErr)
    {
        return -1;
    }

    if (iListSize > 1)
    {
        //get child information and fill current list
        if (getBorder(_pvCtx, _iVar, piAddrList, 2, iChildBorderOut))
        {
            return -1;
        }

        if (getBorder(_pvCtx, _iVar, piAddrList, 3, iChildBorderIn))
        {
            return -1;
        }
    }

    return 0;
}
Ejemplo n.º 9
0
int * H5DataConverter::getHypermatrix(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims)
{
    static const char * hypermat[3] = {"hm", "dims", "entries"};

    int * list = 0;
    SciErr err = createMList(pvApiCtx, position, 3, &list);
    if (err.iErr)
    {
        throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
    }

    err = createMatrixOfStringInList(pvApiCtx, position, list, 1, 1, 3, hypermat);
    if (err.iErr)
    {
        throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
    }

    if (sizeof(int) == sizeof(hsize_t))
    {
        err = createMatrixOfInteger32InList(pvApiCtx, position, list, 2, 1, ndims, (int *)dims);
        if (err.iErr)
        {
            throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
        }
    }
    else
    {
        int * _dims = 0;
        err = allocMatrixOfInteger32InList(pvApiCtx, position, list, 2, 1, ndims, &_dims);
        if (err.iErr)
        {
            throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
        }
        for (int i = 0; i < ndims; i++)
        {
            _dims[i] = (int)dims[i];
        }
    }

    return list;
}
Ejemplo n.º 10
0
int CreateCellVariable(int iVar, matvar_t *matVariable, int * parent, int item_position)
{
  static const char *fieldNames[] = {"ce", "dims","entries"};
  int nbFields = 3;
  int K = 0;
  int prodDims = 0;
  int valueIndex = 0, type;
  int * cell_addr = NULL;
  int * cell_entry_addr = NULL;
  matvar_t ** allData = NULL;
  SciErr _SciErr;

  /* Returned mlist initialization */
  if (parent==NULL)
    {
      _SciErr = createMList(pvApiCtx, iVar, nbFields, &cell_addr); MATIO_ERROR;
    }
  else
    {
      _SciErr = createMListInList(pvApiCtx, iVar, parent, item_position, nbFields, &cell_addr); MATIO_ERROR;
    }
 
  /* FIRST LIST ENTRY: fieldnames */
  _SciErr = createMatrixOfStringInList(pvApiCtx, iVar, cell_addr, 1, 1, nbFields, (char **)fieldNames); MATIO_ERROR;
  
  /* SECOND LIST ENTRY: Dimensions (int32 type) */
  if(matVariable->rank==2) /* Two dimensions */
    {
      _SciErr = createMatrixOfInteger32InList(pvApiCtx, iVar, cell_addr, 2, 1, matVariable->rank, matVariable->dims); MATIO_ERROR;
    }
  else /* 3 or more dimensions -> Scilab HyperMatrix */
    {
      type = I_INT32;
      CreateHyperMatrixVariable(iVar, MATRIX_OF_VARIABLE_SIZE_INTEGER_DATATYPE, 
				&type, &matVariable->rank, matVariable->dims, matVariable->data,
				NULL, cell_addr, 2);
    }

  /* ALL OTHER ENTRIES: Fields data */
  prodDims = 1;
  for (K=0; K<matVariable->rank; K++)
    {
      prodDims *= matVariable->dims[K];
    }

  allData = (matvar_t**) (matVariable->data);

  if (prodDims == 1) /* Scalar cell */
    {
      /* Create list entry in the stack */
      if (!CreateMatlabVariable(iVar, allData[0], cell_addr, 3)) /* Could not Create Variable */
	{
	  sciprint("Do not know how to read a variable of class %d.\n", allData[0]->class_type);
	}
    }
  else
    {
      _SciErr = createListInList(pvApiCtx, iVar, cell_addr, 3, prodDims, &cell_entry_addr); MATIO_ERROR;

      for (valueIndex = 0; valueIndex < prodDims; valueIndex++)
        {
          /* Create list entry in the stack */
          if (!CreateMatlabVariable(iVar, allData[valueIndex], cell_entry_addr, valueIndex+1)) /* Could not Create Variable */
            {
              sciprint("Do not know how to read a variable of class %d.\n", allData[valueIndex]->class_type);
            }
        }
    }
  
  return TRUE;
}
Ejemplo n.º 11
0
int CreateCharVariable(void *pvApiCtx, int iVar, matvar_t *matVariable, int * parent, int item_position)
{
    int nbRow = 0, nbCol = 0;
    char **charData = NULL;
    int K = 0, L = 0;
    SciErr sciErr;

    if (matVariable->rank == 2) /* 2-D array */
    {
        nbRow = (int)matVariable->dims[0];
        nbCol = nbRow == 0 ? 0 : 1; /* In Scilab empty string has size 0x0 */

        if (nbRow != 0)
        {
            charData =  (char**) MALLOC(sizeof(char*) * nbRow);
            if (charData == NULL)
            {
                Scierror(999, _("%s: No more memory.\n"), "CreateCharVariable");
                return FALSE;
            }
        }

        for (K = 0; K < nbRow; K++)
        {
            charData[K] =  (char*) MALLOC(sizeof(char*) * (matVariable->dims[1] + 1));
            if (charData[K] == NULL)
            {
                Scierror(999, _("%s: No more memory.\n"), "CreateCharVariable");
                return FALSE;
            }
        }

        /* Fill items: data in Matlab file is stored columnwise */
        for (K = 0; K < (int)matVariable->dims[0]; K++) /* Loop over items */
        {
            for (L = 0; L < (int)matVariable->dims[1]; L++) /* Loop over chars */
            {
                charData[K][L] = ((char *)matVariable->data)[L * matVariable->dims[0] + K];
            }
            charData[K][L] = '\0';
        }

        if (nbRow * nbCol != 0)
        {
            if (parent == NULL)
            {
                sciErr = createMatrixOfString(pvApiCtx, iVar, nbRow, nbCol, charData);
                if (sciErr.iErr)
                {
                    printError(&sciErr, 0);
                    return 0;
                }
            }
            else
            {
                sciErr = createMatrixOfStringInList(pvApiCtx, iVar, parent, item_position, nbRow, nbCol, charData);
                if (sciErr.iErr)
                {
                    printError(&sciErr, 0);
                    return 0;
                }
            }
        }
        else /* Empty character string */
        {
            if (parent == NULL)
            {
                createSingleString(pvApiCtx, iVar, "\0");
            }
            else
            {
                char ** tmp_char = (char **)MALLOC(sizeof(char *));
                tmp_char[0] = os_strdup("\0");
                sciErr = createMatrixOfStringInList(pvApiCtx, iVar, parent, item_position, 1, 1, tmp_char);
                if (sciErr.iErr)
                {
                    printError(&sciErr, 0);
                    return 0;
                }
                freeArrayOfString(tmp_char, 1);
            }
        }

        freeArrayOfString(charData, nbRow * nbCol);
    }
    else /* Multi-dimension array -> Scilab HyperMatrix */
    {
        Scierror(999, _("%s: N-D arrays of chars not implemented.\n"), "CreateCharVariable");
        return FALSE;
    }

    return TRUE;
}
Ejemplo n.º 12
0
int CreateStructVariable(void *pvApiCtx, int iVar, matvar_t *matVariable, int * parent, int item_position)
{
    char **fieldNames = NULL;
    int nbFields = 0;
    int fieldIndex = 0;
    int K = 0;
    int prodDims = 0;
    int valueIndex = 0;
    matvar_t *fieldMatVar = NULL;
    matvar_t ** allData = NULL;
    int * cell_addr = NULL;
    int * cell_entry_addr = NULL;
    int type;
    SciErr sciErr;
    int *piDims = NULL;
    int i = 0;

    /* Fields of the struct */
    nbFields = 2; /* "st" "dims" */
    nbFields += Mat_VarGetNumberOfFields(matVariable);

    fieldNames = (char**) MALLOC(sizeof(char*) * nbFields);
    if (fieldNames == NULL)
    {
        Scierror(999, _("%s: No more memory.\n"), "CreateStructVariable");
        return FALSE;
    }

    fieldNames[0] = strdup("st");
    if (fieldNames[0] == NULL)
    {
        Scierror(999, _("%s: No more memory.\n"), "CreateStructVariable");
        return FALSE;
    }
    fieldNames[1] = strdup("dims");
    if (fieldNames[1] == NULL)
    {
        Scierror(999, _("%s: No more memory.\n"), "CreateStructVariable");
        return FALSE;
    }

    for (fieldIndex = 1; fieldIndex < nbFields - 1; fieldIndex++)
    {
        fieldMatVar = Mat_VarGetStructField(matVariable, &fieldIndex, MAT_BY_INDEX, 0);
        fieldNames[fieldIndex + 1] = strdup(fieldMatVar->name);
        if (fieldNames[fieldIndex + 1] == NULL)
        {
            Scierror(999, _("%s: No more memory.\n"), "CreateStructVariable");
            return FALSE;
        }
    }

    /* Returned mlist initialization */
    if (parent == NULL)
    {
        sciErr = createMList(pvApiCtx, iVar, nbFields, &cell_addr);
        if (sciErr.iErr)
        {
            printError(&sciErr, 0);
            return 0;
        }
    }
    else
    {
        sciErr = createMListInList(pvApiCtx, iVar, parent, item_position, nbFields, &cell_addr);
        if (sciErr.iErr)
        {
            printError(&sciErr, 0);
            return 0;
        }
    }

    /* FIRST LIST ENTRY: fieldnames */
    sciErr = createMatrixOfStringInList(pvApiCtx, iVar, cell_addr, 1, 1, nbFields, fieldNames);
    if (sciErr.iErr)
    {
        printError(&sciErr, 0);
        return 0;
    }

    /* SECOND LIST ENTRY: Dimensions (int32 type) */
    if (nbFields == 2) /* Empty struct must have size 0x0 in Scilab */
    {
        matVariable->dims[0] = 0;
        matVariable->dims[1] = 0;
    }

    piDims = (int *) MALLOC(matVariable->rank * sizeof(int));
    for (i = 0 ; i < matVariable->rank ; ++i)
    {
        piDims[i] = (int)matVariable->dims[i];
    }

    if (matVariable->rank == 2) /* Two dimensions */
    {
        sciErr = createMatrixOfInteger32InList(pvApiCtx, iVar, cell_addr, 2, 1, matVariable->rank, piDims);
        if (sciErr.iErr)
        {
            printError(&sciErr, 0);
            return 0;
        }
    }
    else /* 3 or more dimensions -> Scilab HyperMatrix */
    {
        type = I_INT32;
        CreateHyperMatrixVariable(pvApiCtx, iVar, MATRIX_OF_VARIABLE_SIZE_INTEGER_DATATYPE,
                                  &type, &matVariable->rank, piDims, (double*)matVariable->data,
                                  NULL, cell_addr, 2);
    }

    FREE(piDims);

    /* ALL OTHER ENTRIES: Fields data */
    prodDims = 1;
    for (K = 0; K < matVariable->rank; K++)
    {
        prodDims *= (int)matVariable->dims[K];
    }

    allData = (matvar_t**) (matVariable->data);

    if (prodDims == 1) /* Scalar struct */
    {
        for (fieldIndex = 0; fieldIndex < nbFields - 2; fieldIndex++)
        {
            /* Create list entry in the stack */
            if (!CreateMatlabVariable(pvApiCtx, iVar, allData[fieldIndex], cell_addr, fieldIndex + 3)) /* Could not Create Variable */
            {
                if (allData[fieldIndex]->class_type != 0) /* class is 0 for not initialized fields */
                {
                    sciprint("Do not know how to read a variable of class %d.\n", allData[fieldIndex]->class_type);
                }
            }
        }
    }
    else
    {
        for (fieldIndex = 0; fieldIndex < nbFields - 2; fieldIndex++)
        {
            sciErr = createListInList(pvApiCtx, iVar, cell_addr, fieldIndex + 3, prodDims, &cell_entry_addr);
            if (sciErr.iErr)
            {
                printError(&sciErr, 0);
                return 0;
            }

            for (valueIndex = 0; valueIndex < prodDims; valueIndex++)
            {
                /* Create list entry in the stack */
                if (!CreateMatlabVariable(pvApiCtx, iVar, allData[(fieldIndex) + (nbFields - 2)*valueIndex], cell_entry_addr, valueIndex + 1)) /* Could not Create Variable */
                {
                    if (allData[(fieldIndex) + (nbFields - 2)*valueIndex]->class_type != 0) /* class is 0 for not initialized fields */
                    {
                        sciprint("Do not know how to read a variable of class %d.\n", allData[(fieldIndex) + (nbFields - 2)*valueIndex]->class_type);
                    }
                }
            }
        }
    }

    freeArrayOfString(fieldNames, nbFields);

    return TRUE;
}
Ejemplo n.º 13
0
/*------------------------------------------------------------------------*/
int getTitledBorder(void* _pvCtx, int _iVar, int* _piParent, int _iPos, int _iObjUID)
{
    SciErr sciErr;
    int* piAddrList = NULL;
    char* pstFieldList1[] = {"TitledBorder", "border", "title", "justification", "position", "font", "color"};
    char* pstFieldList2[] = {"TitledBorder", "title"};
    char** pstFieldList = pstFieldList1;
    char* pstJustification[] = {"leading" , "left" , "center" , "right" , "trailing"};
    char* pstPosition[] = {"top" , "above_top" , "below_top" , "bottom" , "above_bottom", "below_bottom"};
    int iChildBorder = 0;
    int* piChildBorder = &iChildBorder;
    char* pstTitle = NULL;
    int iJustification = 0;
    int* piJustification = &iJustification;
    char* pstFontName = NULL;
    char* pstFontAngle = NULL;
    int iFontSize = 0;
    int* piFontSize = &iFontSize;
    double dblFontSize = 0;
    char* pstFontWeight = NULL;
    int iPosition = 0;
    int* piPosition = &iPosition;
    char* pstColor = NULL;
    int iListSize = 7;

    getGraphicObjectProperty(_iObjUID, __GO_UI_FRAME_BORDER_TITLE__, jni_int, (void **)&piChildBorder);
    getGraphicObjectProperty(_iObjUID, __GO_TITLE__, jni_string, (void **)&pstTitle);
    getGraphicObjectProperty(_iObjUID, __GO_UI_FRAME_BORDER_JUSTIFICATION__, jni_int, (void **)&piJustification);
    getGraphicObjectProperty(_iObjUID, __GO_UI_FONTNAME__, jni_string, (void **)&pstFontName);
    getGraphicObjectProperty(_iObjUID, __GO_UI_FONTANGLE__, jni_string, (void **)&pstFontAngle);
    getGraphicObjectProperty(_iObjUID, __GO_UI_FONTSIZE__, jni_int, (void **)&piFontSize);
    getGraphicObjectProperty(_iObjUID, __GO_UI_FONTWEIGHT__, jni_string, (void **)&pstFontWeight);
    getGraphicObjectProperty(_iObjUID, __GO_UI_FRAME_BORDER_POSITION__, jni_int, (void **)&piPosition);
    getGraphicObjectProperty(_iObjUID, __GO_UI_FRAME_BORDER_COLOR__, jni_string, (void **)&pstColor);

    //2 3 5 6 7
    if (pstColor == NULL)
    {
        iListSize = 6;
    }

    if (pstFontName == NULL || pstFontAngle == NULL || piFontSize == NULL || pstFontWeight == NULL)
    {
        iListSize = 5;
    }

    if (piJustification == NULL)
    {
        iListSize = 3;
    }

    if (pstTitle == NULL)
    {
        iListSize = 2;
    }

    if (piChildBorder == NULL)
    {
        iListSize = 2;
        pstFieldList = pstFieldList2;
    }


    dblFontSize = (double)iFontSize;

    if (_piParent)
    {
        sciErr = createTListInList(_pvCtx, _iVar, _piParent, _iPos, iListSize, &piAddrList);
    }
    else
    {
        sciErr = createTList(_pvCtx, _iVar, iListSize, &piAddrList);
    }

    sciErr = createMatrixOfStringInList(_pvCtx, _iVar, piAddrList, 1, 1, iListSize, pstFieldList);
    if (sciErr.iErr)
    {
        return -1;
    }

    if (piChildBorder)
    {
        //get child information and fill current list
        if (getBorder(_pvCtx, _iVar, piAddrList, 2, iChildBorder))
        {
            return -1;
        }
    }

    if (pstTitle)
    {
        //pos 2 or 3
        sciErr = createMatrixOfStringInList(_pvCtx, _iVar, piAddrList, piChildBorder == NULL ? 2 : 3, 1, 1, &pstTitle);
        if (sciErr.iErr)
        {
            return -1;
        }
    }

    if (iListSize > 3)
    {
        sciErr = createMatrixOfStringInList(_pvCtx, _iVar, piAddrList, 4, 1, 1, &pstJustification[iJustification]);
        if (sciErr.iErr)
        {
            return -1;
        }

        sciErr = createMatrixOfStringInList(_pvCtx, _iVar, piAddrList, 5, 1, 1, &pstPosition[iPosition]);
        if (sciErr.iErr)
        {
            return -1;
        }
    }

    if (iListSize > 5)
    {
        //create a Font Border
        int* piFont = NULL;
        char* pstFontBorder[] = {"BorderFont", "name", "size", "angle", "weight"};

        sciErr = createTListInList(_pvCtx, _iVar, piAddrList, 6, 5, &piFont);
        if (sciErr.iErr)
        {
            return -1;
        }

        sciErr = createMatrixOfStringInList(_pvCtx, _iVar, piFont, 1, 1, 5, pstFontBorder);
        if (sciErr.iErr)
        {
            return -1;
        }

        sciErr = createMatrixOfStringInList(_pvCtx, _iVar, piFont, 2, 1, 1, &pstFontName);
        if (sciErr.iErr)
        {
            return -1;
        }

        sciErr = createMatrixOfDoubleInList(_pvCtx, _iVar, piFont, 3, 1, 1, &dblFontSize);
        if (sciErr.iErr)
        {
            return -1;
        }

        sciErr = createMatrixOfStringInList(_pvCtx, _iVar, piFont, 4, 1, 1, &pstFontAngle);
        if (sciErr.iErr)
        {
            return -1;
        }

        sciErr = createMatrixOfStringInList(_pvCtx, _iVar, piFont, 5, 1, 1, &pstFontWeight);
        if (sciErr.iErr)
        {
            return -1;
        }
    }

    if (iListSize > 6)
    {
        sciErr = createMatrixOfStringInList(_pvCtx, _iVar, piAddrList, 7, 1, 1, &pstColor);
        if (sciErr.iErr)
        {
            return -1;
        }
    }

    return 0;
}
Ejemplo n.º 14
0
/*------------------------------------------------------------------------*/
int getEtchedBorder(void* _pvCtx, int _iVar, int* _piParent, int _iPos, int _iObjUID)
{
    SciErr sciErr;
    int* piAddrList = NULL;
    char* pstFieldList1[] = {"EtchedBorder", "type", "hl", "shadow"};
    char* pstFieldList2[] = {"EtchedBorder", "hl", "shadow"};
    char** pstFieldList = pstFieldList1;
    int iType = 0;
    int* piType = &iType;
    char* pstType[] = {"raised", "lowered"};
    char* pstHlOutColor = NULL;
    char* pstShadowOutColor = NULL;
    int iListSize = 4;

    getGraphicObjectProperty(_iObjUID, __GO_UI_FRAME_BORDER_TYPE__, jni_int, (void **)&piType);
    getGraphicObjectProperty(_iObjUID, __GO_UI_FRAME_BORDER_HIGHLIGHT_OUT__, jni_string, (void **)&pstHlOutColor);
    getGraphicObjectProperty(_iObjUID, __GO_UI_FRAME_BORDER_SHADOW_OUT__, jni_string, (void **)&pstShadowOutColor);

    if (piType == NULL)
    {
        if (pstHlOutColor == NULL || pstShadowOutColor == NULL)
        {
            iListSize = 1;
        }
        else
        {
            iListSize = 3;
            pstFieldList = pstFieldList2;
        }
    }
    else
    {
        if (pstHlOutColor == NULL || pstShadowOutColor == NULL)
        {
            iListSize = 2;
        }
        else
        {
            iListSize = 4;
        }
    }

    if (_piParent)
    {
        sciErr = createTListInList(_pvCtx, _iVar, _piParent, _iPos, iListSize, &piAddrList);
    }
    else
    {
        sciErr = createTList(_pvCtx, _iVar, iListSize, &piAddrList);
    }

    if (sciErr.iErr)
    {
        return -1;
    }

    sciErr = createMatrixOfStringInList(_pvCtx, _iVar, piAddrList, 1, 1, iListSize, pstFieldList);
    if (sciErr.iErr)
    {
        return -1;
    }

    if (iListSize == 2 || iListSize == 4)
    {
        sciErr = createMatrixOfStringInList(_pvCtx, _iVar, piAddrList, 2, 1, 1, &pstType[iType]);
        if (sciErr.iErr)
        {
            return -1;
        }
    }

    if (iListSize == 3 || iListSize == 4)
    {
        sciErr = createMatrixOfStringInList(_pvCtx, _iVar, piAddrList, iListSize - 1, 1, 1, &pstHlOutColor);
        if (sciErr.iErr)
        {
            return -1;
        }

        sciErr = createMatrixOfStringInList(_pvCtx, _iVar, piAddrList, iListSize, 1, 1, &pstShadowOutColor);
        if (sciErr.iErr)
        {
            return -1;
        }
    }
    return 0;
}
Ejemplo n.º 15
0
/*------------------------------------------------------------------------*/
int getCommonBevelBorder(void* _pvCtx, int _iVar, int* _piParent, int _iPos, int _iObjUID, int _iBevel)
{
    SciErr sciErr;
    int* piAddrList = NULL;
    char* pstFieldList1[] = {"BevelBorder", "type", "hlouter", "hlinner", "shadowouter", "shadowinner"};
    char* pstFieldList2[] = {"BevelBorder", "type", "hlouter", "shadowouter"};
    char** pstFieldList = pstFieldList1;
    char* pstSoftFieldList1[] = {"SoftBevelBorder", "type", "hlouter", "hlinner", "shadowouter", "shadowinner"};
    char* pstSoftFieldList2[] = {"SoftBevelBorder", "type", "hlouter", "shadowouter"};
    char** pstSoftFieldList = pstSoftFieldList1;
    int iType = 0;
    int* piType = &iType;
    char* pstType[] = {"raised", "lowered"};
    char* pstHlOutColor = NULL;
    char* pstHlInColor = NULL;
    char* pstShadowOutColor = NULL;
    char* pstShadowInColor = NULL;
    int iListSize = 6;

    getGraphicObjectProperty(_iObjUID, __GO_UI_FRAME_BORDER_TYPE__, jni_int, (void **)&piType);
    if (piType == NULL)
    {
        Scierror(999, _("'%s' property does not exist for this handle.\n"), "border");
        return -1;
    }

    getGraphicObjectProperty(_iObjUID, __GO_UI_FRAME_BORDER_HIGHLIGHT_OUT__, jni_string, (void **)&pstHlOutColor);
    getGraphicObjectProperty(_iObjUID, __GO_UI_FRAME_BORDER_HIGHLIGHT_IN__, jni_string, (void **)&pstHlInColor);
    getGraphicObjectProperty(_iObjUID, __GO_UI_FRAME_BORDER_SHADOW_OUT__, jni_string, (void **)&pstShadowOutColor);
    getGraphicObjectProperty(_iObjUID, __GO_UI_FRAME_BORDER_SHADOW_IN__, jni_string, (void **)&pstShadowInColor);

    if (pstHlInColor == NULL || pstShadowInColor == NULL)
    {
        iListSize = 4;
        pstFieldList = pstFieldList2;
        pstSoftFieldList = pstSoftFieldList2;
    }

    if (pstHlOutColor == NULL || pstShadowOutColor == NULL)
    {
        iListSize = 2;
        pstFieldList = pstFieldList2;
        pstSoftFieldList = pstSoftFieldList2;
    }

    if (_piParent)
    {
        sciErr = createTListInList(_pvCtx, _iVar, _piParent, _iPos, iListSize, &piAddrList);
    }
    else
    {
        sciErr = createTList(_pvCtx, _iVar, iListSize, &piAddrList);
    }
    if (sciErr.iErr)
    {
        return -1;
    }

    if (_iBevel == 1)
    {
        sciErr = createMatrixOfStringInList(_pvCtx, _iVar, piAddrList, 1, 1, iListSize, pstFieldList);
    }
    else
    {
        sciErr = createMatrixOfStringInList(_pvCtx, _iVar, piAddrList, 1, 1, iListSize, pstSoftFieldList);
    }

    if (sciErr.iErr)
    {
        return -1;
    }

    sciErr = createMatrixOfStringInList(_pvCtx, _iVar, piAddrList, 2, 1, 1, &pstType[iType]);
    if (sciErr.iErr)
    {
        return -1;
    }

    if (iListSize == 4)
    {
        sciErr = createMatrixOfStringInList(_pvCtx, _iVar, piAddrList, 3, 1, 1, &pstHlOutColor);
        if (sciErr.iErr)
        {
            return -1;
        }

        sciErr = createMatrixOfStringInList(_pvCtx, _iVar, piAddrList, 4, 1, 1, &pstShadowOutColor);
        if (sciErr.iErr)
        {
            return -1;
        }
    }
    else if (iListSize == 6)
    {
        sciErr = createMatrixOfStringInList(_pvCtx, _iVar, piAddrList, 3, 1, 1, &pstHlOutColor);
        if (sciErr.iErr)
        {
            return -1;
        }

        sciErr = createMatrixOfStringInList(_pvCtx, _iVar, piAddrList, 4, 1, 1, &pstHlInColor);
        if (sciErr.iErr)
        {
            return -1;
        }

        sciErr = createMatrixOfStringInList(_pvCtx, _iVar, piAddrList, 5, 1, 1, &pstShadowOutColor);
        if (sciErr.iErr)
        {
            return -1;
        }

        sciErr = createMatrixOfStringInList(_pvCtx, _iVar, piAddrList, 6, 1, 1, &pstShadowInColor);
        if (sciErr.iErr)
        {
            return -1;
        }
    }

    return 0;
}
Ejemplo n.º 16
0
/*------------------------------------------------------------------------*/
int getLineBorder(void* _pvCtx, int _iVar, int* _piParent, int _iPos, int _iObjUID)
{
    SciErr sciErr;
    int* piAddrList = NULL;
    char* pstFieldList[] = {"LineBorder", "color", "thickness", "rounded"};
    char* pstColor = NULL;
    int iThickness = 0;
    double dblThickness = 0;
    int* piThickness = &iThickness;
    int iRounded = 0;
    int* piRounded = &iRounded;
    int iListSize = 4;

    getGraphicObjectProperty(_iObjUID, __GO_UI_FRAME_BORDER_COLOR__, jni_string, (void **)&pstColor);
    if (pstColor == NULL)
    {
        Scierror(999, _("'%s' property does not exist for this handle.\n"), "border");
        return -1;
    }

    getGraphicObjectProperty(_iObjUID, __GO_LINE_THICKNESS__, jni_int, (void **)&piThickness);
    getGraphicObjectProperty(_iObjUID, __GO_UI_FRAME_BORDER_ROUNDED__, jni_bool, (void **)&piRounded);

    if (piRounded == NULL)
    {
        iListSize = 3;
    }

    if (piThickness == NULL)
    {
        iListSize = 2;
    }

    if (_piParent)
    {
        sciErr = createTListInList(_pvCtx, _iVar, _piParent, _iPos, iListSize, &piAddrList);
    }
    else
    {
        sciErr = createTList(_pvCtx, _iVar, iListSize, &piAddrList);
    }

    if (sciErr.iErr)
    {
        return -1;
    }

    sciErr = createMatrixOfStringInList(_pvCtx, _iVar, piAddrList, 1, 1, iListSize, pstFieldList);
    if (sciErr.iErr)
    {
        return -1;
    }

    sciErr = createMatrixOfStringInList(_pvCtx, _iVar, piAddrList, 2, 1, 1, &pstColor);
    if (sciErr.iErr)
    {
        return -1;
    }

    if (iListSize > 2)
    {
        dblThickness = (double)iThickness;
        sciErr = createMatrixOfDoubleInList(_pvCtx, _iVar, piAddrList, 3, 1, 1, &dblThickness);
        if (sciErr.iErr)
        {
            return -1;
        }
    }

    if (iListSize > 3)
    {
        sciErr = createMatrixOfBooleanInList(_pvCtx, _iVar, piAddrList, 4, 1, 1, &iRounded);
        if (sciErr.iErr)
        {
            return -1;
        }
    }

    return 0;
}