Exemplo n.º 1
0
/* Draw the representation of a cell that have the focus, for cells that
   are not in the edit mode
   -> lin, col : the cell
   -> set: 1 to put the draw of the focus
           0 to remove the draw
*/
void iupMatrixDrawFocus(Ihandle* ih, int lin, int col, int set)
{
  int x1, y1, x2, y2, dx, dy, oldbgc;

  if(iupAttribGetInt(ih, "HIDEFOCUS"))
    return;

  if(!iupMatrixAuxGetCellDim(ih, lin, col, &x1, &y1, &dx, &dy))
    return;

  ih->data->redraw = 1;

  if(set)          /* put the draw of the focus */
    oldbgc = iMatrixDrawSetFgColor(ih, lin+1, col+1, iupMatrixMarkCellGet(ih, lin, col));
  else                /* remove the draw of the focus */
    oldbgc = iMatrixDrawSetBgColor(ih, lin+1, col+1, IMAT_ELEM_COLOR, iupMatrixMarkCellGet(ih, lin, col));

  x2 = x1 + dx - 1;
  y2 = y1 + dy - 1;

  CdRect(x1, x2, y1, y2);
  CdRect(x1+1, x2-1, y1+1, y2-1);
  
  CdRestoreBgColor();
}
Exemplo n.º 2
0
static void iMatrixMarkCellSet(Ihandle* ih, int lin, int col, int mark, IFniii markedit_cb, IFnii mark_cb)
{
  /* called only when MARKMODE=CELL */
  if (mark == -1)
    mark = !iupMatrixMarkCellGet(ih, lin, col, mark_cb);

  if (ih->data->callback_mode)
  {
    if (markedit_cb && !ih->data->inside_markedit_cb)
    {
      ih->data->inside_markedit_cb = 1;
      markedit_cb(ih, lin, col, mark);
      ih->data->inside_markedit_cb = 0;
    }
    else
    {
      if (mark)
        iupAttribSetId2(ih, "MARK", lin, col, "1");
      else
        iupAttribSetId2(ih, "MARK", lin, col, NULL);
    }
  }
  else
  {
    if (mark)
      ih->data->cells[lin][col].flags |= IMAT_IS_MARKED;
    else
      ih->data->cells[lin][col].flags &= ~IMAT_IS_MARKED;
  }
}
Exemplo n.º 3
0
static void iMatrixMarkCellSet(Ihandle* ih, int lin, int col, int mark, IFniii markedit_cb, IFnii mark_cb, char* str)
{
  /* called only when MARKMODE=CELL */
  if (mark == -1)
    mark = !iupMatrixMarkCellGet(ih, lin, col, mark_cb, str);

  if (ih->data->callback_mode)
  {
    if (markedit_cb)
      markedit_cb(ih, lin, col, mark);
    else
    {
      sprintf(str, "MARK%d:%d", lin, col);
      if (mark)
        iupAttribSetStr(ih, str, "1");
      else
        iupAttribSetStr(ih, str, NULL);
    }
  }
  else
  {
    if (mark)
      ih->data->cells[lin][col].flags |= IUPMAT_MARK;
    else
      ih->data->cells[lin][col].flags &= ~IUPMAT_MARK;
  }
}
Exemplo n.º 4
0
/* Redraw a block of cells of the matrix. Handle marked cells, change
   automatically the background color of them.
   - lin1, col1 : cell coordinates that mark the left top corner of the area to be redrawn
   - lin2, col2 : cell coordinates that mark the right bottom corner of the area to be redrawn */
void iupMatrixDrawCells(Ihandle* ih, int lin1, int col1, int lin2, int col2)
{
  int x1, y1, x2, y2, old_x2, old_y1, old_y2;
  int alignment, lin, col, active, first_col, first_lin;
  long framecolor, emptyarea_color = -1;
  IFnii mark_cb;
  IFnii dropcheck_cb;
  IFniiiiiiC draw_cb;

  x2 = ih->data->w-1;
  y2 = ih->data->h-1;

  old_x2 = x2;
  old_y1 = 0;
  old_y2 = y2;

  if (ih->data->lines.num <= 1 ||
      ih->data->columns.num <= 1)
    return;

  if (ih->data->columns.num_noscroll>1 && col1==1 && col2==ih->data->columns.num_noscroll-1)
  {
    first_col = 0;
    x1 = 0;
  }
  else
  {
    if (col1 > ih->data->columns.last ||
        col2 < ih->data->columns.first)
      return;

    if (col1 < ih->data->columns.first)
      col1 = ih->data->columns.first;
    if (col2 > ih->data->columns.last)
      col2 = ih->data->columns.last;

    first_col = ih->data->columns.first;
    x1 = 0;
    for (col = 0; col< ih->data->columns.num_noscroll; col++)
      x1 += ih->data->columns.dt[col].size;
  }

  if (ih->data->lines.num_noscroll>1 && lin1==1 && lin2==ih->data->lines.num_noscroll-1)
  {
    first_lin = 0;
    y1 = 0;
  }
  else
  {
    if (lin1 > ih->data->lines.last ||
        lin2 < ih->data->lines.first)
      return;

    if (lin1 < ih->data->lines.first)
      lin1 = ih->data->lines.first;
    if (lin2 > ih->data->lines.last)
      lin2 = ih->data->lines.last;

    first_lin = ih->data->lines.first;
    y1 = 0;
    for (lin = 0; lin< ih->data->lines.num_noscroll; lin++)
      y1 += ih->data->lines.dt[lin].size;
  }

  iupMATRIX_CLIPAREA(ih, x1, x2, y1, y2);
  cdCanvasClip(ih->data->cd_canvas, CD_CLIPOFF);  /* wait for background */

  /* Find the initial position of the first column */
  if (first_col==ih->data->columns.first)
    x1 -= ih->data->columns.first_offset;
  for(col = first_col; col < col1; col++)
    x1 += ih->data->columns.dt[col].size;

  /* Find the initial position of the first line */
  if (first_lin == ih->data->lines.first)
    y1 -= ih->data->lines.first_offset;
  for(lin = first_lin; lin < lin1; lin++)
    y1 += ih->data->lines.dt[lin].size;

  /* Find the final position of the last column */
  x2 = x1;
  for( ; col <= col2; col++)
    x2 += ih->data->columns.dt[col].size;

  /* Find the final position of the last line */
  y2 = y1;
  for( ; lin <= lin2; lin++)
    y2 += ih->data->lines.dt[lin].size;

  if ((col2 == ih->data->columns.num-1) && (old_x2 > x2))
  {
    emptyarea_color = cdIupConvertColor(ih->data->bgcolor_parent);
    cdCanvasForeground(ih->data->cd_canvas, emptyarea_color);

    /* 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. */
    iupMATRIX_BOX(ih, x2, old_x2, old_y1, old_y2);
  }

  if ((lin2 == ih->data->lines.num-1) && (old_y2 > y2))
  {
    if (emptyarea_color == -1)
      emptyarea_color = cdIupConvertColor(ih->data->bgcolor_parent);
    cdCanvasForeground(ih->data->cd_canvas, emptyarea_color);

    /* If it was drawn until the last line visible and remains space below it,
       then delete this area with the the background color. */
    iupMATRIX_BOX(ih, 0, old_x2, y2, old_y2);
  }

  /* after the background */
  cdCanvasClip(ih->data->cd_canvas, CD_CLIPAREA);

  /***** Draw the cell values and frame */
  old_y1 = y1;
  framecolor = cdIupConvertColor(iupAttribGetStr(ih, "FRAMECOLOR"));
  active = iupdrvIsActive(ih);

  mark_cb = (IFnii)IupGetCallback(ih, "MARK_CB");
  dropcheck_cb = (IFnii)IupGetCallback(ih, "DROPCHECK_CB");
  draw_cb = (IFniiiiiiC)IupGetCallback(ih, "DRAW_CB");

  for(col = col1; col <= col2; col++)  /* For all the columns in the region */
  {
    if (ih->data->columns.dt[col].size == 0)
      continue;

    alignment = iMatrixDrawGetColAlignment(ih, col);

    x2 = x1 + ih->data->columns.dt[col].size;

    for(lin = lin1; lin <= lin2; lin++)     /* For all lines in the region */
    {
      int drop = 0;
      int marked = 0;

      if (ih->data->lines.dt[lin].size == 0)
        continue;

      y2 = y1 + ih->data->lines.dt[lin].size;

      /* If the cell is marked, then draw it with attenuation color */
      marked = iupMatrixMarkCellGet(ih, lin, col, mark_cb);

      iMatrixDrawBackground(ih, x1, x2, y1, y2, marked, active, lin, col);

      iMatrixDrawFrameRectCell(ih, lin, col, x1, x2, y1, y2, framecolor);

      if (dropcheck_cb)
      {
        int ret = dropcheck_cb(ih, lin, col);
        if (ret == IUP_DEFAULT)
        {
          drop = IMAT_DROPBOX_W+IMAT_PADDING_W/2;
          iMatrixDrawDropFeedback(ih, x2, y1, y2, active, framecolor);
        }
        else if (ret == IUP_CONTINUE)
        {
          drop = IMAT_TOGGLE_SIZE + IMAT_PADDING_W;
          iMatrixDrawToggle(ih, x2, y1, y2, lin, col, marked, active);
        }
      }
        
      /* draw the cell contents */
      iMatrixDrawCellValue(ih, x1, x2-drop, y1, y2, alignment, marked, active, lin, col, draw_cb, framecolor);

      y1 = y2;
    }

    x1 = x2;
    y1 = old_y1;  /* must reset also y */
  }

  cdCanvasClip(ih->data->cd_canvas, CD_CLIPOFF);
}
Exemplo n.º 5
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;
  }
}
Exemplo n.º 6
0
char* iupMatrixGetMarkedAttrib(Ihandle* ih)
{
  int lin, col, size;
  IFnii mark_cb;
  char* p, *value = NULL;
  int exist_mark = 0;           /* Show if there is someone marked */

  if (ih->data->mark_mode == IMAT_MARK_NO)
    return NULL;

  mark_cb = (IFnii)IupGetCallback(ih, "MARK_CB");

  if (ih->data->mark_mode == IMAT_MARK_CELL)
  {
    size = (ih->data->lines.num-1) * (ih->data->columns.num-1) + 1;
    value = iupStrGetMemory(size);
    p = value;

    for(lin = 1; lin < ih->data->lines.num; lin++)
    {
      for(col = 1; col < ih->data->columns.num; col++)
      {
         if (iupMatrixMarkCellGet(ih, lin, col, mark_cb))
         {
           exist_mark = 1;
           *p++ = '1';
         }
         else
           *p++ = '0';
      }
    }
    *p = 0;
  }
  else
  {
    int marked_lines = 0, marked_cols = 0;

    if (ih->data->mark_mode == IMAT_MARK_LINCOL) /* must find which format to return */
    {
      /* look for a marked column */
      for(col = 1; col < ih->data->columns.num; col++)
      {
        if (ih->data->columns.dt[col].flags & IMAT_IS_MARKED)
        {
          marked_cols = 1; /* at least one column is marked */
          break;
        }
      }

      if (!marked_cols)
        marked_lines = 1;
    }
    else if (ih->data->mark_mode == IMAT_MARK_LIN)
      marked_lines = 1;
    else if (ih->data->mark_mode == IMAT_MARK_COL)
      marked_cols = 1;

    if (marked_lines)
    {
      size = 1 + (ih->data->lines.num-1) + 1;
      value = iupStrGetMemory(size);
      p = value;

      *p++ = 'L';

      for(lin = 1; lin < ih->data->lines.num; lin++)
      {
        if (ih->data->lines.dt[lin].flags & IMAT_IS_MARKED)
        {
          exist_mark = 1;
          *p++ = '1';
        }
        else
         *p++ = '0';
      }
      *p = 0;
    }
    else if (marked_cols)
    {
      size = 1 + (ih->data->columns.num-1) + 1;
      value = iupStrGetMemory(size);
      p = value;

      *p++ = 'C';

      for(col = 1; col < ih->data->columns.num; col++)
      {
        if (ih->data->columns.dt[col].flags & IMAT_IS_MARKED)
        {
          exist_mark = 1;
          *p++ = '1';
        }
        else
         *p++ = '0';
      }
      *p = 0;
    }
  }

  return exist_mark? value: NULL;
}
Exemplo n.º 7
0
/* Redraw a block of cells of the matrix. Handle marked cells, change
   automatically the background color of them.
   - lin1, col1 : cell coordinates that mark the left top corner of the area to be redrawn
   - lin2, col2 : cell coordinates that mark the right bottom corner of the area to be redrawn */
void iupMatrixDrawCells(Ihandle* ih, int lin1, int col1, int lin2, int col2)
{
  int x1, y1, x2, y2, old_x2, old_y1, old_y2;
  int alignment, lin, col, active;
  long framecolor, emptyarea_color = -1;
  char str[100];
  IFnii mark_cb;
  IFnii dropcheck_cb;
  IFniiiiiiC draw_cb;

  x1 = 0;
  x2 = ih->data->w-1;
  y1 = 0;
  y2 = ih->data->h-1;

  old_x2 = x2;
  old_y1 = y1;
  old_y2 = y2;

  if (col1 > ih->data->columns.last ||
      col2 < ih->data->columns.first ||
      lin1 > ih->data->lines.last ||
      lin2 < ih->data->lines.first)
    return;

  if (col1 < ih->data->columns.first)
    col1 = ih->data->columns.first;
  if (col2 > ih->data->columns.last)
    col2 = ih->data->columns.last;
  if (lin1 < ih->data->lines.first)
    lin1 = ih->data->lines.first;
  if (lin2 > ih->data->lines.last)
    lin2 = ih->data->lines.last;

  /* Find the initial position of the first column */
  x1 += ih->data->columns.sizes[0];
  for(col = ih->data->columns.first; col < col1; col++)
    x1 += ih->data->columns.sizes[col];

  /* Find the final position of the last column */
  x2 = x1;
  for( ; col <= col2; col++)
    x2 += ih->data->columns.sizes[col];

  /* Find the initial position of the first line */
  y1 += ih->data->lines.sizes[0];
  for(lin = ih->data->lines.first; lin < lin1; lin++)
    y1 += ih->data->lines.sizes[lin];

  /* Find the final position of the last line */
  y2 = y1;
  for( ; lin <= lin2; lin++)
    y2 += ih->data->lines.sizes[lin];

  if ((col2 == ih->data->columns.num-1) && (old_x2 > x2))
  {
    emptyarea_color = cdIupConvertColor(ih->data->bgcolor_parent);
    cdCanvasForeground(ih->data->cddbuffer, emptyarea_color);

    /* 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. */
    IUPMAT_BOX(ih, x2, old_x2, old_y1, old_y2);
  }

  if ((lin2 == ih->data->lines.num-1) && (old_y2 > y2))
  {
    if (emptyarea_color == -1)
      emptyarea_color = cdIupConvertColor(ih->data->bgcolor_parent);
    cdCanvasForeground(ih->data->cddbuffer, emptyarea_color);

    /* If it was drawn until the last line visible and remains space below it,
       then delete this area with the the background color. */
    IUPMAT_BOX(ih, 0, old_x2, y2, old_y2);
  }

  /***** Draw the cell values and frame */
  old_y1 = y1;
  framecolor = cdIupConvertColor(iupAttribGetStr(ih, "FRAMECOLOR"));
  active = iupdrvIsActive(ih);

  mark_cb = (IFnii)IupGetCallback(ih, "MARK_CB");
  dropcheck_cb = (IFnii)IupGetCallback(ih, "DROPCHECK_CB");
  draw_cb = (IFniiiiiiC)IupGetCallback(ih, "DRAW_CB");

  for(col = col1; col <= col2; col++)  /* For all the columns in the region */
  {
    if (ih->data->columns.sizes[col] == 0)
      continue;

    alignment = iMatrixDrawGetColAlignment(ih, col, str);

    x2 = x1 + ih->data->columns.sizes[col];

    for(lin = lin1; lin <= lin2; lin++)     /* For all lines in the region */
    {
      if (ih->data->lines.sizes[lin] == 0)
        continue;

      y2 = y1 + ih->data->lines.sizes[lin];

      if (col==1 && ih->data->columns.sizes[0] == 0)
      {
        /* If does not have titles then draw the left line of the cell frame */
        iMatrixDrawFrameVertLineCell(ih, lin, col, x1, y1, y2-1-1, framecolor, str);
      }

      if (lin==1 && ih->data->lines.sizes[0] == 0)
      {
        /* If does not have titles then draw the top line of the cell frame */
        iMatrixDrawFrameHorizLineCell(ih, lin, col, x1, x2-1-1, y1, framecolor, str);
      }

      /* draw the cell contents */
      {
        int drop = 0;
        int marked = 0;

        if (dropcheck_cb && dropcheck_cb(ih, lin, col) == IUP_DEFAULT)
          drop = IMAT_COMBOBOX_W;

        /* If the cell is marked, then draw it with attenuation color */
        marked = iupMatrixMarkCellGet(ih, lin, col, mark_cb, str);

        iMatrixDrawBackground(ih, x1, x2, y1, y2, marked, active, lin, col);
        
        iMatrixDrawCellValue(ih, x1, x2-drop, y1, y2, alignment, marked, active, lin, col, draw_cb);

        if (drop)
          iMatrixDrawComboFeedback(ih, x2, y1, y2, lin, col, marked, active, framecolor);
      }

      /* bottom line */
      iMatrixDrawFrameHorizLineCell(ih, lin, col, x1, x2-1, y2-1, framecolor, str);
      
      /* rigth line */
      iMatrixDrawFrameVertLineCell(ih, lin, col, x2-1, y1, y2-1, framecolor, str);

      y1 = y2;
    }

    x1 = x2;
    y1 = old_y1;  /* must reset also y */
  }
}
Exemplo n.º 8
0
int iupMatrixProcessKeyPress(Ihandle* ih, int c)
{
  /* This function is also called from inside the keyboard callbacks 
     of the Text and Dropdown list when in edition mode */

  int ret = IUP_IGNORE; /* default for processed keys */

  /* Hide (off) the marked cells if the key is not tab/del */
  if (c != K_TAB && c != K_sTAB && c != K_DEL && c != K_sDEL)
    iupMatrixMarkClearAll(ih, 1);

  /* If the focus is not visible, a scroll is done for that the focus to be visible */
  if (!iupMatrixAuxIsCellFullVisible(ih, ih->data->lines.focus_cell, ih->data->columns.focus_cell))
    iupMatrixScrollToVisible(ih, ih->data->lines.focus_cell, ih->data->columns.focus_cell);

  switch (c)
  {
    case K_CR+2000:   /* used by the iMatrixEditTextKeyAny_CB and iMatrixEditDropDownKeyAny_CB */
      if (iupMatrixAuxCallLeaveCellCb(ih) == IUP_IGNORE)
        break;
      iupMatrixScrollKeyCr(ih);
      iupMatrixAuxCallEnterCellCb(ih);
      break;

    case K_cHOME:
    case K_sHOME:
    case K_HOME:
      if(iupMatrixAuxCallLeaveCellCb(ih) == IUP_IGNORE)
        break;
      iupMatrixScrollKeyHome(ih);
      ih->data->homekeycount++;
      iupMatrixAuxCallEnterCellCb(ih);
      break;

    case K_cEND:
    case K_sEND:
    case K_END:
      if(iupMatrixAuxCallLeaveCellCb(ih) == IUP_IGNORE)
        break;
      iupMatrixScrollKeyEnd(ih);
      ih->data->endkeycount++;
      iupMatrixAuxCallEnterCellCb(ih);
      break;

    case K_sTAB:
    case K_TAB:
      return IUP_CONTINUE;  /* do not redraw */

    case K_cLEFT:
    case K_sLEFT:
    case K_LEFT:
      if (iupMatrixAuxCallLeaveCellCb(ih) == IUP_IGNORE)
        break;
      iupMatrixScrollKeyLeft(ih);
      iupMatrixAuxCallEnterCellCb(ih);
      break;

    case K_cRIGHT:
    case K_sRIGHT:
    case K_RIGHT:
      if(iupMatrixAuxCallLeaveCellCb(ih) == IUP_IGNORE)
        break;
      iupMatrixScrollKeyRight(ih);
      iupMatrixAuxCallEnterCellCb(ih);
      break;

    case K_cUP:
    case K_sUP:
    case K_UP:
      if(iupMatrixAuxCallLeaveCellCb(ih) == IUP_IGNORE)
        break;
      iupMatrixScrollKeyUp(ih);
      iupMatrixAuxCallEnterCellCb(ih);
      break ;

    case K_cDOWN:
    case K_sDOWN:
    case K_DOWN:
      if(iupMatrixAuxCallLeaveCellCb(ih) == IUP_IGNORE)
        break;
      iupMatrixScrollKeyDown(ih);
      iupMatrixAuxCallEnterCellCb(ih);
      break;

    case K_sPGUP:
    case K_PGUP:
      if(iupMatrixAuxCallLeaveCellCb(ih) == IUP_IGNORE)
        break;
      iupMatrixScrollKeyPgUp(ih);
      iupMatrixAuxCallEnterCellCb(ih);
      break;

    case K_sPGDN:
    case K_PGDN:
      if(iupMatrixAuxCallLeaveCellCb(ih) == IUP_IGNORE)
        break;
      iupMatrixScrollKeyPgDown(ih);
      iupMatrixAuxCallEnterCellCb(ih);
      break;

    case K_SP:
    case K_CR:
    case K_sCR:
      if (iupMatrixEditShow(ih))
        return IUP_IGNORE; /* do not redraw */
      break;

    case K_sDEL:
    case K_DEL:
      {
        int lin, col;
        char str[100];
        IFnii mark_cb = (IFnii)IupGetCallback(ih, "MARK_CB");

        iupMatrixPrepareDrawData(ih);

        for(lin = 1; lin < ih->data->lines.num; lin++)
        {
          for(col = 1; col < ih->data->columns.num; col++)
          {
            if (iupMatrixMarkCellGet(ih, lin, col, mark_cb, str))
            {
              if (iupMatrixAuxCallEditionCbLinCol(ih, lin, col, 1) != IUP_IGNORE)
              {
                IFniis value_edit_cb;

                iupMatrixCellSetValue(ih, lin, col, NULL);

                value_edit_cb = (IFniis)IupGetCallback(ih, "VALUE_EDIT_CB");
                if (value_edit_cb)
                  value_edit_cb(ih, lin, col, NULL);

                iupMatrixDrawCells(ih, lin, col, lin, col);
              }
            }
          }
        }
        break;
      }
    default:
      /* if a valid character is pressed enter edition mode */
      if (iup_isprint(c))
      {
        if (iupMatrixEditShow(ih))
        {
          if (ih->data->datah == ih->data->texth)
          {
            char value[2] = {0,0};
            value[0] = (char)c;
            IupStoreAttribute(ih->data->datah, "VALUE", value);
            IupSetAttribute(ih->data->datah, "CARET", "2");
          }
          return IUP_IGNORE; /* do not redraw */
        }
      }
      ret = IUP_DEFAULT; /* unprocessed keys */
      break;
  }

  iupMatrixDrawUpdate(ih);  
  return ret;
}