Ejemplo n.º 1
0
static void iMatrixDrawMatrix(Ihandle* ih)
{
    iupMatrixPrepareDrawData(ih);

    /* fill the background because there will be empty cells */
    if ((ih->data->lines.num == 1) || (ih->data->columns.num == 1))
    {
        cdCanvasBackground(ih->data->cddbuffer, cdIupConvertColor(ih->data->bgcolor_parent));
        cdCanvasClear(ih->data->cddbuffer);
    }

    /* Draw the corner between line and column titles, if necessary */
    iMatrixDrawTitleCorner(ih);

    /* If there are columns, then draw their titles */
    if (ih->data->columns.num_noscroll>1)
        iupMatrixDrawColumnTitle(ih, 1, ih->data->columns.num_noscroll-1);
    iupMatrixDrawColumnTitle(ih, ih->data->columns.first, ih->data->columns.last);

    /* If there are lines, then draw their titles */
    if (ih->data->lines.num_noscroll>1)
        iupMatrixDrawLineTitle(ih, 1, ih->data->lines.num_noscroll-1);
    iupMatrixDrawLineTitle(ih, ih->data->lines.first, ih->data->lines.last);

    /* If there are ordinary cells, then draw them */
    if (ih->data->columns.num_noscroll>1)
        iupMatrixDrawCells(ih, ih->data->lines.first, 1,
                           ih->data->lines.last, ih->data->columns.num_noscroll-1);
    if (ih->data->lines.num_noscroll>1)
        iupMatrixDrawCells(ih, 1, ih->data->columns.first,
                           ih->data->lines.num_noscroll-1, ih->data->columns.last);
    iupMatrixDrawCells(ih, ih->data->lines.first, ih->data->columns.first,
                       ih->data->lines.last, ih->data->columns.last);
}
Ejemplo n.º 2
0
/* Redraw the entire matrix, may or not redraw the line and column titles
   -> modo : this constant specifics the titles will be redraw, with the
             following values:
             IMAT_DRAW_ALL -> Redraw the title columns and lines
             IMAT_DRAW_COL -> Redraw just the title columns
             IMAT_DRAW_LIN -> Redraw just the title lines
     ... always redraw the cells - the "modo" just draw the titles ...
*/
void iupMatrixDrawMatrix(Ihandle* ih, int modo)
{
  ih->data->redraw = 1;

  if((ih->data->lin.num == 0) || (ih->data->col.num == 0))
  {
    cdCanvasBackground(ih->data->cddbuffer, cdIupConvertColor(iupControlBaseGetParentBgColor(ih)));
    cdCanvasClear(ih->data->cddbuffer);
  }

  /* Draw the corner between line and column titles, if necessary */
  iupMatrixDrawTitleCorner(ih);

  /* If there are columns and must draw them, then draw the titles */
  if((ih->data->col.num != 0) &&
     (modo == IMAT_DRAW_ALL || modo == IMAT_DRAW_COL) && ih->data->lin.titlewh)
  {
    iupMatrixDrawColumnTitle(ih, ih->data->col.first, ih->data->col.last);
  }

  /* If there are lines and must draw them, then draw the titles */
  if((ih->data->lin.num != 0) &&
     (modo == IMAT_DRAW_ALL || modo == IMAT_DRAW_LIN) &&
     ih->data->col.titlewh)
  {
    iupMatrixDrawLineTitle(ih, ih->data->lin.first, ih->data->lin.last);
  }

  /* If there are cells in the matrix, then draw the cells */
  if((ih->data->lin.num != 0) && (ih->data->col.num != 0))
    iupMatrixDrawCells(ih, ih->data->lin.first, ih->data->col.first, ih->data->lin.last, ih->data->col.last);
}
Ejemplo n.º 3
0
int iupMatrixDrawSetRedrawAttrib(Ihandle* ih, const char* value)
{
    int type;

    if (value == NULL)
        type = 0;
    else if(value[0] == 'L' || value[0] == 'l')
        type = IMAT_PROCESS_LIN;
    else if(value[0] == 'C' || value[0] == 'c')
        type = IMAT_PROCESS_COL;
    else
        type = 0;

    if (type)  /* lines or columns, inluding their titles */
    {
        int min = 0, max = 0;
        value++;

        if(iupStrToIntInt(value, &min, &max, ':') != 2)
            max = min;

        if (min > max)
            return 0;

        iupMatrixPrepareDrawData(ih);

        if (ih->data->need_calcsize)
            iupMatrixAuxCalcSizes(ih);

        /* ignore empty area, draw only cells */

        iMatrixDrawTitleCorner(ih);

        if (type == IMAT_PROCESS_LIN)
        {
            iupMatrixDrawLineTitle(ih, min, max);
            if (ih->data->columns.num_noscroll>1)
                iupMatrixDrawCells(ih, min, 1, max, ih->data->columns.num_noscroll-1);
            iupMatrixDrawCells(ih, min, ih->data->columns.first, max, ih->data->columns.last);
        }
        else
        {
            iupMatrixDrawColumnTitle(ih, min, max);
            if (ih->data->lines.num_noscroll>1)
                iupMatrixDrawCells(ih, 1, min, ih->data->lines.num_noscroll-1, max);
            iupMatrixDrawCells(ih, ih->data->lines.first, min, ih->data->lines.last, max);
        }
    }
    else
    {
        /* Force CalcSize */
        iupMatrixAuxCalcSizes(ih);

        iMatrixDrawMatrix(ih);
    }

    ih->data->need_redraw = 0;
    iupMatrixDrawUpdate(ih);
    return 0;
}
Ejemplo n.º 4
0
int iupMatrixDrawSetRedrawAttrib(Ihandle* ih, const char* value)
{
  int type;

  if (value == NULL)
    type = 0;
  else if(value[0] == 'L' || value[0] == 'l')
    type = IMAT_PROCESS_LIN;
  else if(value[0] == 'C' || value[0] == 'c')
    type = IMAT_PROCESS_COL;
  else
    type = 0;

  if (type)
  {
    int min = 0, max = 0;
    value++;

    if(iupStrToIntInt(value, &min, &max, ':') != 2)
      max = min;

    if (min > max)
      return 0;

    iupMatrixPrepareDrawData(ih);

    if (ih->data->need_calcsize)
      iupMatrixAuxCalcSizes(ih);

    if (ih->data->lines.sizes[0] && ih->data->columns.sizes[0])
      iMatrixDrawTitleCorner(ih);

    if (type == IMAT_PROCESS_LIN)
    {
      iupMatrixDrawLineTitle(ih, min, max);
      iupMatrixDrawCells(ih, min, ih->data->columns.first, max, ih->data->columns.last);
    }
    else
    {
      iupMatrixDrawColumnTitle(ih, min, max);
      iupMatrixDrawCells(ih, ih->data->lines.first, min, ih->data->lines.last, max);
    }
  }
  else
  {
    iupMatrixAuxCalcSizes(ih);
    iMatrixDrawMatrix(ih);
  }

  iupMatrixDrawUpdate(ih);
  return 0;
}
Ejemplo n.º 5
0
static void iMatrixMarkItem(Ihandle* ih, int lin1, int col1, int mark, IFniii markedit_cb, IFnii mark_cb, char* str)
{
  int lin, col;

  if (ih->data->mark_full1 == IMAT_PROCESS_LIN)
  {
    if (ih->data->mark_mode == IMAT_MARK_CELL)
    {
      for (col = 1; col < ih->data->columns.num; col++)
        iMatrixMarkCellSet(ih, lin1, col, mark, markedit_cb, mark_cb, str);
    }
    else
    {
      iMatrixMarkLinSet(ih, lin1, mark);
      iupMatrixDrawLineTitle(ih, lin1, lin1);
    }

    iupMatrixDrawCells(ih, lin1, 1, lin1, ih->data->columns.num-1);
  }
  else if (ih->data->mark_full1 == IMAT_PROCESS_COL)
  {
    if (ih->data->mark_mode == IMAT_MARK_CELL)
    {
      for(lin = 1; lin < ih->data->lines.num; lin++)
        iMatrixMarkCellSet(ih, lin, col1, mark, markedit_cb, mark_cb, str);
    }
    else
    {
      iMatrixMarkColSet(ih, col1, mark);
      iupMatrixDrawColumnTitle(ih, col1, col1);
    }

    iupMatrixDrawCells(ih, 1, col1, ih->data->lines.num-1, col1);
  }
  else if (ih->data->mark_mode == IMAT_MARK_CELL)
  {
    iMatrixMarkCellSet(ih, lin1, col1, mark, markedit_cb, mark_cb, str);
    iupMatrixDrawCells(ih, lin1, col1, lin1, col1);
  }
}
Ejemplo n.º 6
0
/* Redraw a block of cells of the matrix. Handle marked cells, change
   automatically the background color of them.
   - l1, c1 : cell coordinates that mark the left top corner of the
              area to be redrawn
   - l2, c2 : cell coordinates that mark the right bottom corner of the
              area to be redrawn
*/
void iupMatrixDrawCells(Ihandle* ih, int l1, int c1, int l2, int c2)
{
  int x1, y1, x2, y2, oldx2, oldy1, oldy2;
  int yc1, yc2, xc1, xc2, i, j;
  int align;
  long framecolor;
  char str[30];
  unsigned char r,g,b;

  /* If there are no cells in the matrix, returns */
  if(ih->data->lin.num == 0 || ih->data->col.num == 0)
   return;

  /* Adjust parameters */
  if(c1 < ih->data->col.first)
    c1 = ih->data->col.first;
  if(c2 > ih->data->col.last)
    c2 = ih->data->col.last;

  if(l1 < ih->data->lin.first)
    l1 = ih->data->lin.first;
  if(l2 > ih->data->lin.last)
    l2 = ih->data->lin.last;

  if(c1 > c2 || l1 > l2)
    return;

  ih->data->redraw = 1;

  if(l1 <= l2)
    iupMatrixDrawLineTitle(ih, l1, l2);
  if(c1<=c2)
    iupMatrixDrawColumnTitle(ih, c1, c2);

  x1 = 0;
  x2 = ih->data->XmaxC;
  y1 = 0;
  y2 = ih->data->YmaxC;

  oldx2 = x2;
  oldy1 = y1;
  oldy2 = y2;

  /* Find the initial position of the first column */
  x1 += ih->data->col.titlewh;
  for(j = ih->data->col.first; j < c1; j++)
    x1 += ih->data->col.wh[j];

  /* Find the final position of the last column */
  x2 = x1;
  for( ; j < c2; j++)
    x2 += ih->data->col.wh[j];
  x2 += (c2 == ih->data->col.last ? ih->data->col.lastwh : ih->data->col.wh[c2]);

  /* Find the initial position of the first line */
  y1 += ih->data->lin.titlewh;
  for(j = ih->data->lin.first; j < l1; j++)
    y1 += ih->data->lin.wh[j];

  /* Find the final position of the last line */
  y2 = y1;
  for( ; j < l2; j++)
    y2 += ih->data->lin.wh[j];
  y2 += (l2 == ih->data->lin.last ? ih->data->lin.lastwh : ih->data->lin.wh[l2]);

  if((c2 == ih->data->col.num-1) && (oldx2 > x2))
  {
    /* If it was drawn until the last column and remains space in the right of it,
       then delete this area with the the background color.
    */
    iupMatrixDrawEmptyArea(ih, x2, oldx2, oldy1, oldy2);
  }

  if((l2 == ih->data->lin.num-1) && (oldy2 > y2))
  {
    /* If it was drawn until the last line visible and remains space below it,
       then delete this area with the the background color.
    */
    iupMatrixDrawEmptyArea(ih, 0, oldx2, y2, oldy2);
  }

  /***** Show the cell values */
  xc1 = x1;
  yc1 = y1;
  iupStrToRGB(IupGetAttribute(ih, "FRAMECOLOR"), &r, &g, &b);
  framecolor = cdEncodeColor((unsigned char) r, (unsigned char) g, (unsigned char) b);

  for(j = c1; j <= c2; j++)  /* For all the columns in the region */
  {
    if(ih->data->col.wh[j] == 0)
      continue;

    align = iMatrixDrawGetColAlignment(ih, j + 1);

    xc2 = xc1 + (j == ih->data->col.last ? ih->data->col.lastwh : ih->data->col.wh[j]);

    for(i = l1; i <= l2; i++)     /* For all lines in the region */
    {
      if(ih->data->lin.wh[i] == 0)
        continue;

      yc2 = yc1 + ih->data->lin.wh[i]-1;

      if(!(IupGetInt(ih->data->datah, "VISIBLE") && i == ih->data->lin.active && j == ih->data->col.active))
      {
        int drop = 0;
        int cor  = IMAT_ELEM_COLOR;
        char *cell_value;

        if(iMatrixDrawCallDropDownCheckCb(ih, i, j))
          drop = IMAT_BOXW;

        /* If the cell is marked, then draw it in reverse color */
        if(iupMatrixMarkCellGet(ih, i, j))
          cor = IMAT_REVERSE_COLOR;

        cell_value = iupMatrixAuxGetCellValue(ih, i, j);
        iMatrixDrawText(ih, xc1, xc1+ih->data->col.wh[j]-1-drop, yc1, yc2-1, cell_value, align, xc2, cor, i+1, j+1);

        if(drop)
          iMatrixDrawComboFeedback(ih, xc1+ih->data->col.wh[j]-1, yc1, yc2, i+1, j+1, cor);
      }

      if (ih->data->checkframecolor)
      {
        sprintf(str, "FRAMEHORIZCOLOR%d:%d", i, j);
        if (iupStrToRGB(IupGetAttribute(ih, str), &r, &g, &b))
          cdCanvasForeground(ih->data->cddbuffer, cdEncodeColor((unsigned char) r, (unsigned char) g, (unsigned char) b));
        else
          cdCanvasForeground(ih->data->cddbuffer, framecolor);
      }
      else
        cdCanvasForeground(ih->data->cddbuffer, framecolor);
    
      /* horizontal line (only for this column) */
      CdLine(xc1, yc2, xc2-1, yc2);
      
      if (ih->data->checkframecolor)
      {
        sprintf(str, "FRAMEVERTCOLOR%d:%d", i+1, j+1);
        if (iupStrToRGB(IupGetAttribute(ih, str), &r, &g, &b))
          cdCanvasForeground(ih->data->cddbuffer, cdEncodeColor((unsigned char) r, (unsigned char) g, (unsigned char) b));
        else
          cdCanvasForeground(ih->data->cddbuffer, framecolor);
      }
      else
        cdCanvasForeground(ih->data->cddbuffer, framecolor);

      /* vertical line (only for this line) */
      CdLine(xc2-1,yc1,xc2-1,yc2-1);

      yc1  = yc2+1;
    }

    xc1 = xc2;
    yc1 = y1;
  }
}
Ejemplo n.º 7
0
void iupMatrixMarkMouseItem(Ihandle* ih, int ctrl, int lin1, int col1)
{
  int mark = 1, mark_full_all, lin, col;
  IFniii markedit_cb = NULL;
  IFnii mark_cb = NULL;
  char str[100];

  iupMatrixMarkMouseReset(ih);
  iupMatrixPrepareDrawData(ih);

  if (!ih->data->mark_multiple || ih->data->mark_continuous || !ctrl)
  {
    iupMatrixMarkClearAll(ih, 1);
    iupMatrixDraw(ih, 0);
  }
  else
    mark = -1; /* toggle mark state */

  ih->data->mark_full1 = 0;
  mark_full_all = 0;

  if (lin1 == 0 && col1 == 0)
  {
    if ((ih->data->mark_mode == IMAT_MARK_CELL && ih->data->mark_multiple) ||
        ih->data->mark_mode == IMAT_MARK_COL ||
        ih->data->mark_mode == IMAT_MARK_LIN)
      mark_full_all = 1;
  }
  /* If it was pointing for a column title... */
  else if (lin1 == 0)
  {
    if ((ih->data->mark_mode == IMAT_MARK_CELL && ih->data->mark_multiple) || 
         ih->data->mark_mode & IMAT_MARK_COL)
      ih->data->mark_full1 = IMAT_PROCESS_COL;
  }
  /* If it was pointing for a line title... */
  else if (col1 == 0)
  {
    if ((ih->data->mark_mode == IMAT_MARK_CELL && ih->data->mark_multiple) || 
         ih->data->mark_mode & IMAT_MARK_LIN)
      ih->data->mark_full1 = IMAT_PROCESS_LIN;
  }

  if (ih->data->mark_mode == IMAT_MARK_CELL && ih->data->callback_mode)
  {
    markedit_cb = (IFniii)IupGetCallback(ih, "MARKEDIT_CB");
    mark_cb = (IFnii)IupGetCallback(ih, "MARK_CB");
  }

  if (mark_full_all)
  {
    if (ih->data->mark_mode == IMAT_MARK_CELL)
    {
      char str[100];
      for (col = 1; col < ih->data->columns.num; col++)
      {
        for(lin = 1; lin < ih->data->lines.num; lin++)
          iMatrixMarkCellSet(ih, lin, col, mark, markedit_cb, mark_cb, str);
      }
    }
    else if (ih->data->mark_mode == IMAT_MARK_LIN)
    {
      for(lin = 1; lin < ih->data->lines.num; lin++)
        iMatrixMarkLinSet(ih, lin, mark);

      iupMatrixDrawLineTitle(ih, 1, ih->data->lines.num-1);
    }
    else if (ih->data->mark_mode == IMAT_MARK_COL)
    {
      for (col = 1; col < ih->data->columns.num; col++)
        iMatrixMarkColSet(ih, col, mark);

      iupMatrixDrawColumnTitle(ih, 1, ih->data->columns.num-1);
    }

    iupMatrixDrawCells(ih, 1, 1, ih->data->lines.num-1, ih->data->columns.num-1);
  }
  else
    iMatrixMarkItem(ih, lin1, col1, mark, markedit_cb, mark_cb, str);

  ih->data->mark_lin1 = lin1;
  ih->data->mark_col1 = col1;
}
Ejemplo n.º 8
0
/* Make the scroll of a number of columns to the left or right side or
   lines on top or down, using the ScrollImage primitive. To the left, just
   move one column - to the right, can move more than one. On top, just
   move only one column - on down, can move more than one.
   -> dir : [IMAT_SCROLL_LEFT| IMAT_SCROLL_RIGHT | IMAT_SCROLL_UP | IMAT_SCROLL_DOWN]
   -> ref : First column/line to be redrawn when the move is to right or on down.
   -> num : Number of columns/lines to be moved,  when the move is to right or on down.
*/
void iupMatrixScroll(Ihandle* ih, int dir, int ref, int num)
{
  int x1, x2, y1, y2, xt2, yt2;
  int i;

  x1 = 0;
  x2 = ih->data->XmaxC;
  
  y1 = 0;
  y2 = ih->data->YmaxC;

  ih->data->redraw = 1;

  if(dir == IMAT_SCROLL_LEFT)
  {
    x1  = ih->data->col.titlewh;      /* skip the line title */
    x2 -= ih->data->col.wh[ih->data->col.first];
    if(x1 >= x2)
    {
     iupMatrixDrawMatrix(ih, IMAT_DRAW_COL);
     return;
    }

    cdCanvasScrollArea(ih->data->cddbuffer, x1, x2, y1, y2, ih->data->col.wh[ih->data->col.first], 0);

    iupMatrixDrawColumnTitle(ih, ih->data->col.first, ih->data->col.first);

    iupMatrixCDSetCdFrameColor(ih);
    cdCanvasLine(ih->data->cddbuffer, ih->data->XmaxC, y1, ih->data->XmaxC, y2);

    iupMatrixDrawCells(ih, ih->data->lin.first, ih->data->col.first, ih->data->lin.last, ih->data->col.first);
  }
  else if(dir == IMAT_SCROLL_UP)
  {
    y2 -= ih->data->lin.titlewh;      /* skip the column title */
    y1 += ih->data->lin.wh[ih->data->lin.first];
    if(y1 >= y2)
    {
     iupMatrixDrawMatrix(ih, IMAT_DRAW_LIN);
     return;
    }

    cdCanvasScrollArea(ih->data->cddbuffer, x1, x2, y1, y2, 0, -ih->data->lin.wh[ih->data->lin.first]);
    iupMatrixDrawLineTitle(ih, ih->data->lin.first, ih->data->lin.first);
    iupMatrixDrawCells(ih, ih->data->lin.first, ih->data->col.first, ih->data->lin.first, ih->data->col.last);
  }
  else if(dir == IMAT_SCROLL_RIGHT)
  {
    x1 = ih->data->col.titlewh;      /* skip the line title */
    for(i = 1; i <= num; i++)
      x1 += ih->data->col.wh[ih->data->col.first-i];
    if(x1 >= x2)
    {
     iupMatrixDrawMatrix(ih, IMAT_DRAW_COL);
     return;
    }

    cdCanvasScrollArea(ih->data->cddbuffer, x1, x2/*-1*/, y1, y2, ih->data->col.titlewh-x1, 0);

    xt2 = iupMatrixDrawColumnTitle(ih, ref, ih->data->col.last);

    if(xt2 < x2)          /* clear the right area that doesn't have column */
    {
      iupMatrixDrawEmptyArea(ih, xt2, x2, y1, y2);
    }
    else
    {
      iupMatrixCDSetCdFrameColor(ih);
      cdCanvasLine(ih->data->cddbuffer, x2, y1, x2, y2);
    }

    /* draw the cells */
    iupMatrixDrawCells(ih, ih->data->lin.first, ref, ih->data->lin.last, ih->data->col.last);
  }
  else if(dir == IMAT_SCROLL_DOWN)
  {
    y2 -= ih->data->lin.titlewh;      /* skip the column title */
    for(i = 1; i <= num; i++)
      y2 -= ih->data->lin.wh[ih->data->lin.first-i];
    if(y1 >= y2)
    {
     iupMatrixDrawMatrix(ih, IMAT_DRAW_LIN);
     return;
    }

    cdCanvasScrollArea(ih->data->cddbuffer, x1, x2/*-1*/, y1, y2, 0, ih->data->YmaxC-ih->data->lin.titlewh-y2);

    yt2 = iupMatrixDrawLineTitle(ih, ref, ih->data->lin.last);

    if(yt2 < y1)          /* clear the right area that doesn't have column */
    {
     iupMatrixDrawEmptyArea(ih, x1, x2, y1, yt2);
    }
    else
    {
     iupMatrixCDSetCdFrameColor(ih);
     cdCanvasLine(ih->data->cddbuffer, x1, y1, x2, y1);
    }

    /* desenha as celulas */
    iupMatrixDrawCells(ih, ref, ih->data->col.first, ih->data->lin.last, ih->data->col.last);
  }
}