Exemplo n.º 1
0
static void iMatrixExCopyGetData(ImatExData* matex_data, Iarray* data, int lin1, int col1, int lin2, int col2)
{
  int lin, col;
  int add_sep;

  for(lin = lin1; lin <= lin2; ++lin)
  {
    add_sep = 0;

    if (iupMatrixExIsLineVisible(matex_data->ih, lin))
    {
      for(col = col1; col <= col2; ++col)
      {
        if (iupMatrixExIsColumnVisible(matex_data->ih, col))
        {
          if (add_sep)
            iMatrixExArrayAddChar(data, '\t');

          iMatrixExArrayAddCell(matex_data, data, lin, col);

          add_sep = 1;
        }
      }
    }

    if (add_sep)
      iMatrixExArrayAddChar(data, '\n');
  }
}
Exemplo n.º 2
0
static void iMatrixExCopyGetDataMarkedLin(ImatExData* matex_data, Iarray* data, const char* marked, int num_lin, int num_col)
{
  int lin, col;
  int add_sep;

  for(lin = 1; lin <= num_lin; ++lin)  /* only marked lines, but maintain original structure */
  {
    add_sep = 0;

    if (iupMatrixExIsLineVisible(matex_data->ih, lin))
    {
      for(col = 1; col <= num_col; ++col)    /* all columns */
      {
        if (marked[lin-1] == '1' && iupMatrixExIsColumnVisible(matex_data->ih, col))
        {
          if (add_sep)
            iMatrixExArrayAddChar(data, '\t');

          iMatrixExArrayAddCell(matex_data, data, lin, col);
          add_sep = 1;
        }
      }
    }

    if (add_sep)
      iMatrixExArrayAddChar(data, '\n');
  }
}
Exemplo n.º 3
0
static int iMatrixExGetVisibleNumLin(Ihandle *ih, int start_lin, int data_num_lin)
{
  int lin, vis_num_lin = data_num_lin;
  for (lin=start_lin; lin < start_lin+data_num_lin; lin++)
  {
    if (!iupMatrixExIsLineVisible(ih, lin))
      vis_num_lin++;
  }
  return vis_num_lin;
}
Exemplo n.º 4
0
static void iMatrixExPasteSetData(Ihandle *ih, const char* data, int data_num_lin, int data_num_col, char sep, int start_lin, int start_col, int num_lin, int num_col, const char* busyname)
{
  ImatExData* matex_data = (ImatExData*)iupAttribGet(ih, "_IUP_MATEX_DATA");
  int lin, col, len, l, c;
  char* value = NULL;
  int value_max_size = 0, value_len;

  iupMatrixExBusyStart(matex_data, data_num_lin*data_num_col, busyname);

  lin = start_lin;
  l = 0;
  while (lin <= num_lin && l<data_num_lin)
  {
    if (iupMatrixExIsLineVisible(ih, lin))
    {
      const char* next_line = iupStrNextLine(data, &len); l++;

      col = start_col;
      c = 0;
      while (col <= num_col && c<data_num_col)
      {
        if (iupMatrixExIsColumnVisible(ih, col))
        {
          const char* next_value = iupStrNextValue(data, len, &value_len, sep);  c++;

          value = iMatrixExStrCopyValue(value, &value_max_size, data, value_len);
          iupMatrixExSetCellValue(matex_data->ih, lin, col, value);

          data = next_value;
          len -= value_len+1;

          if (!iupMatrixExBusyInc(matex_data))
          {
            if (value) 
              free(value);
            return;
          }
        }

        col++;
      }

      data = next_line;
    }

    lin++;
  }

  iupMatrixExBusyEnd(matex_data);

  if (value)
    free(value);

  iupBaseCallValueChangedCb(matex_data->ih);
}
Exemplo n.º 5
0
static void iMatrixExCopyTXT(Ihandle *ih, FILE* file, int num_lin, int num_col, int skip_lin, int skip_col)
{
  ImatExData* matex_data = (ImatExData*)iupAttribGet(ih, "_IUP_MATEX_DATA");
  int lin, col;
  int add_sep;
  char* str, sep;

  sep = *(iupAttribGetStr(ih, "TEXTSEPARATOR"));

  str = iupAttribGetStr(ih, "COPYCAPTION");
  if (str)
    fprintf(file,"%s\n",str);

  /* Here includes the title cells */
  for (lin = 0; lin <= num_lin; ++lin)
  {
    add_sep = 0;

    if (iupMatrixExIsLineVisible(ih, lin))
    {
      for (col = 0; col <= num_col; ++col)
      {
        if (iupMatrixExIsColumnVisible(ih, col))
        {
          if (add_sep)
            fprintf(file, "%c", sep);

          str = iupMatrixExGetCellValue(matex_data->ih, lin, col, 1);  /* get displayed value */
          if (str)
          {
            if (strchr(str, sep))
              fprintf(file, "\"%s\"", str);
            else
              fprintf(file, "%s", str);
          }
          else
            fprintf(file, "%s", " ");

          add_sep = 1;
        }

        if (col == 0) col += skip_col;
      }

      fprintf(file, "%s", "\n");
    }

    if (lin == 0) lin += skip_lin;
  }
}
Exemplo n.º 6
0
static void iMatrixExCopyGetDataMarkedCell(ImatExData* matex_data, Iarray* data, const char* marked, int lin1, int col1, int lin2, int col2, int num_col, int keep_struct)
{
  int lin, col;
  int add_sep;

  for(lin = lin1; lin <= lin2; ++lin)
  {
    add_sep = 0;

    if (iupMatrixExIsLineVisible(matex_data->ih, lin))
    {
      for(col = col1; col <= col2; ++col)
      {
        if (iupMatrixExIsColumnVisible(matex_data->ih, col))
        {
          int pos = (lin-1) * num_col + (col-1);  /* marked array does not include titles */
          if (marked[pos] == '1')
          {
            if (add_sep)
              iMatrixExArrayAddChar(data, '\t');
            iMatrixExArrayAddCell(matex_data, data, lin, col);
            add_sep = 1;
          }
          else if (keep_struct)
          {
            if (add_sep)
              iMatrixExArrayAddChar(data, '\t');
            iMatrixExArrayAddEmpty(data);
            add_sep = 1;
          }
        }
      }
    }

    if (add_sep)
      iMatrixExArrayAddChar(data, '\n');
  }
}
Exemplo n.º 7
0
static void iMatrixExCopyLaTeX(Ihandle *ih, FILE* file, int num_lin, int num_col, char* buffer, int skip_lin, int skip_col)
{
  ImatExData* matex_data = (ImatExData*)iupAttribGet(ih, "_IUP_MATEX_DATA");
  int lin, col;
  int add_sep;
  char* str;

  fprintf(file,"%% File automatically generated by IUP\n");

  fprintf(file,"\\begin{table}\n");
  fprintf(file,"\\begin{center}\n");
  fprintf(file,"\\begin{tabular}{");

  for (col = 0; col <= num_col; ++col)
  {
    if (iupMatrixExIsColumnVisible(ih, col))
      fprintf(file,"|r");

    if (col == 0) col += skip_col;
  }
  fprintf(file,"|} \\hline\n");

  /* Here includes the title cells */
  for (lin = 0; lin <= num_lin; ++lin)
  {
    add_sep = 0;

    if (iupMatrixExIsLineVisible(ih, lin))
    {
      int is_bold = iMatrixExIsBoldLine(ih, lin);

      for (col = 0; col <= num_col; ++col)
      {
        if (iupMatrixExIsColumnVisible(ih, col))
        {    
          if (add_sep)
            fprintf(file,"& ");

          if (is_bold)
            fprintf(file,"\\bf{");

          str = iupMatrixExGetCellValue(matex_data->ih, lin, col, 1);  /* get displayed value */
          if (str)
          {
            iMatrixExStrCopyNoSepLaTeX(buffer, str);
            fprintf(file, "%s", buffer);
          }
          else
            fprintf(file, "%s", " ");

          if (is_bold)
            fprintf(file,"}");

          add_sep = 1;
        }

        if (col == 0) col += skip_col;
      }

      fprintf(file,"\\\\ \\hline\n");
    }

    if (lin == 0) lin += skip_lin;
  }

  fprintf(file,"\\end{tabular}\n");

  str = iupAttribGetStr(ih, "COPYCAPTION");
  if (str) fprintf(file,"\\caption{%s.}\n", str);

  str = iupAttribGetStr(ih, "LATEXLABEL");
  if (str) fprintf(file,"\\label{tab:%s}\n", str);

  fprintf(file,"\\end{center}\n");
  fprintf(file,"\\end{table}\n");
}
Exemplo n.º 8
0
static void iMatrixExCopyHTML(Ihandle *ih, FILE* file, int num_lin, int num_col, char* buffer, int skip_lin, int skip_col)
{
  ImatExData* matex_data = (ImatExData*)iupAttribGet(ih, "_IUP_MATEX_DATA");
  int lin, col;
  char* str, *caption, f[512];

  int add_format = iupAttribGetInt(ih, "HTMLADDFORMAT");

  char* table = iupAttribGetStr(ih, "HTML<TABLE>");
  char* tr = iupAttribGetStr(ih, "HTML<TR>");
  char* th = iupAttribGetStr(ih, "HTML<TH>");
  char* td = iupAttribGetStr(ih, "HTML<TD>");
  caption = iupAttribGetStr(ih, "HTML<CAPTION>");
  if (!table) table = "";
  if (!tr) tr = "";
  if (!th) th = "";
  if (!td) td = "";
  if (!caption) caption = "";

  fprintf(file,"<!-- File automatically generated by IUP -->\n");
  fprintf(file,"<TABLE%s>\n", table);

  str = iupAttribGetStr(ih, "COPYCAPTION");
  if (str)
    fprintf(file,"<CAPTION%s>%s</CAPTION>\n", caption, str);

  /* Here includes the title cells */
  for (lin = 0; lin <= num_lin; ++lin)
  {
    if (iupMatrixExIsLineVisible(ih, lin))
    {
      fprintf(file,"<TR%s> ", tr);

      for (col = 0; col <= num_col; ++col)
      {
        if (iupMatrixExIsColumnVisible(ih, col))
        {           
          if (lin==0||col==0)
            fprintf(file,"<TH%s%s>", th, add_format? iMatrixExGetCellFormat(ih, lin, col, f): "");
          else
            fprintf(file,"<TD%s%s>", td, add_format? iMatrixExGetCellFormat(ih, lin, col, f): "");

          str = iupMatrixExGetCellValue(matex_data->ih, lin, col, 1);  /* get displayed value */
          if (str)
          {
            iMatrixExStrCopyNoSepHTML(buffer, str);
            fprintf(file, "%s", buffer);
          }
          else
            fprintf(file, "%s", " ");

          if (lin==0||col==0)
            fprintf(file,"</TH> ");
          else
            fprintf(file,"</TD> ");
        }

        if (col == 0) col += skip_col;
      }

      fprintf(file,"</TR>\n");
    }

    if (lin == 0) lin += skip_lin;
  }

  fprintf(file,"</TABLE>\n");
}
Exemplo n.º 9
0
static char* iMatrixGetVisibleLinAttribId(Ihandle *ih, int lin)
{
  return iupStrReturnBoolean (iupMatrixExIsLineVisible(ih, lin)); 
}