Esempio n. 1
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;
}
Esempio n. 2
0
static int iMatrixEditDropDownKeyAny_CB(Ihandle* ih_list, int c)
{
    Ihandle* ih = ih_list->parent;
    IFniiiis cb = (IFniiiis)IupGetCallback(ih, "ACTION_CB");
    if (cb)
    {
        int oldc = c;
        c = cb(ih, c, ih->data->edit_lin, ih->data->edit_col, 1, "");
        if (c == IUP_IGNORE || c == IUP_CLOSE  || c == IUP_CONTINUE)
            return c;
        else if(c == IUP_DEFAULT)
            c = oldc;
    }

    switch (c)
    {
    case K_CR:
        if (iupMatrixEditConfirm(ih) == IUP_DEFAULT)
        {
            if (iupMatrixAuxCallLeaveCellCb(ih) != IUP_IGNORE)
            {
                iupMATRIX_ScrollKeyCr(ih);
                iupMatrixAuxCallEnterCellCb(ih);
            }
            iupMatrixDrawUpdate(ih);
            return IUP_IGNORE;
        }
        break;
    case K_ESC:
        iupMatrixEditAbort(ih);
        return IUP_IGNORE;
    }

    return IUP_CONTINUE;
}
Esempio n. 3
0
static int iMatrixEditDropDownKeyAny_CB(Ihandle* ih, int c)
{
  Ihandle* ih_matrix = ih->parent;
  IFniiiis cb = (IFniiiis)IupGetCallback(ih_matrix, "ACTION_CB");
  if (cb)
  {
    int oldc = c;
    c = cb(ih_matrix, c, ih_matrix->data->lines.focus_cell, ih_matrix->data->columns.focus_cell, 1, "");
    if (c == IUP_IGNORE || c == IUP_CLOSE  || c == IUP_CONTINUE)
      return c;
    else if(c == IUP_DEFAULT)
      c = oldc;
  }

  switch (c)
  {
    case K_CR:
      if (iupMatrixEditHide(ih_matrix) == IUP_DEFAULT)
      {
        if (iupMatrixAuxCallLeaveCellCb(ih_matrix) != IUP_IGNORE)
        {
          iupMATRIX_ScrollKeyCr(ih_matrix);
          iupMatrixAuxCallEnterCellCb(ih_matrix);
        }
        iupMatrixDrawUpdate(ih_matrix);
        return IUP_IGNORE;
      }
      break;
    case K_ESC:
      iMatrixEditCancel(ih_matrix, 1, 0, 0); /* set focus + NO update + NO ignore */
      return IUP_IGNORE;
  }

  return IUP_CONTINUE;
}
Esempio n. 4
0
int iupMatrixScroll_CB(Ihandle* ih, int action, float posx, float posy)
{
  if (!iupMatrixIsValid(ih, 0))
    return IUP_DEFAULT;

  switch(action)
  {
    case IUP_SBUP      : iupMATRIX_ScrollUp(ih);       break;
    case IUP_SBDN      : iupMATRIX_ScrollDown(ih);     break;
    case IUP_SBPGUP    : iupMATRIX_ScrollPgUp(ih);     break;
    case IUP_SBPGDN    : iupMATRIX_ScrollPgDown(ih);   break;
    case IUP_SBRIGHT   : iupMATRIX_ScrollRight(ih);    break;
    case IUP_SBLEFT    : iupMATRIX_ScrollLeft(ih);     break;
    case IUP_SBPGRIGHT : iupMATRIX_ScrollPgRight(ih);  break;
    case IUP_SBPGLEFT  : iupMATRIX_ScrollPgLeft(ih);   break;
    case IUP_SBPOSV    : iupMATRIX_ScrollPosVer(ih,posy); break;
    case IUP_SBPOSH    : iupMATRIX_ScrollPosHor(ih,posx); break;
    case IUP_SBDRAGV   : iupMATRIX_ScrollPosVer(ih,posy); break;
    case IUP_SBDRAGH   : iupMATRIX_ScrollPosHor(ih,posx); break;
  }

  iupMatrixDrawUpdate(ih);

  return IUP_DEFAULT;
}
Esempio n. 5
0
void iupMatrixDraw(Ihandle* ih, int update)
{
  if (ih->data->need_calcsize)
    iupMatrixAuxCalcSizes(ih);

  iMatrixDrawMatrix(ih);

  if (update)
    iupMatrixDrawUpdate(ih);
}
Esempio n. 6
0
static int iMatrixSetEditModeAttrib(Ihandle* ih, const char* value)
{
  if (iupStrBoolean(value))
    iupMatrixEditShow(ih);
  else
  {
    iupMatrixEditHide(ih);
    iupMatrixDrawUpdate(ih);
  }
  return 1;
}
Esempio n. 7
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;
}
Esempio n. 8
0
static int iMatrixRedraw_CB(Ihandle* ih)
{
  if (!ih->data->cddbuffer)
    return IUP_DEFAULT;

  if (ih->data->callback_mode ||  /* in callback mode the values are not changed by attributes, so we can NOT wait for a REDRAW */
      ih->data->need_redraw ||  /* if some of the attributes that do not automatically redraw were set */
      ih->data->need_calcsize)   /* if something changed the matrix size */
    iupMatrixDraw(ih, 0);

  iupMatrixDrawUpdate(ih);

  return IUP_DEFAULT;
}
Esempio n. 9
0
void iupMatrixDraw(Ihandle* ih, int update)
{
  cdCanvasActivate(ih->data->cd_canvas);

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

  iMatrixDrawMatrix(ih);

  ih->data->need_redraw = 0;

  if (update)
    iupMatrixDrawUpdate(ih);
}
Esempio n. 10
0
static int iMatrixRedraw_CB(Ihandle* ih)
{
  if (!ih->data->cddbuffer)
    return IUP_DEFAULT;

  if (!ih->data->first_redraw)
  {
    ih->data->first_redraw = 1;
    iupMatrixDraw(ih, 0);
  }

  iupMatrixDrawUpdate(ih);

  return IUP_DEFAULT;
}
Esempio n. 11
0
static int iMatrixMenuItemAction_CB(Ihandle* ih_item)
{
    Ihandle* ih_menu = ih_item->parent;
    Ihandle* ih = (Ihandle*)iupAttribGet(ih_menu, "_IUP_MATRIX");
    char* title = IupGetAttribute(ih_item, "TITLE");
    IFniinsii cb = (IFniinsii)IupGetCallback(ih, "DROPSELECT_CB");
    if(cb)
    {
        int i = IupGetChildPos(ih_menu, ih_item) + 1;
        cb(ih, ih->data->edit_lin, ih->data->edit_col, ih_menu, title, i, 1);
    }

    IupStoreAttribute(ih_menu, "VALUE", title);

    iMatrixEditCallEditionCbUpdateValue(ih, 0, 1);  /* always update, similar to iupMatrixEditConfirm */
    iupMatrixDrawUpdate(ih);

    return IUP_DEFAULT;
}
Esempio n. 12
0
static int iMatrixMenuItemAction(Ihandle* ih)
{
  Ihandle* ih_menu = ih->parent;
  Ihandle* ih_matrix = (Ihandle*)iupAttribGet(ih_menu, "_IUP_MATRIX");
  char* t = IupGetAttribute(ih, "TITLE"); 
  IFniinsii cb = (IFniinsii)IupGetCallback(ih_matrix, "DROPSELECT_CB");
  if(cb)
  {
    int i = IupGetChildPos(ih_menu, ih) + 1;
    cb(ih_matrix, ih_matrix->data->lines.focus_cell, ih_matrix->data->columns.focus_cell, ih_menu, t, i, 1);
  }

  IupStoreAttribute(ih_menu, "VALUE", t);

  iMatrixEditCallEditionCb(ih_matrix, 0, 1);  /* always update */
  iupMatrixDrawUpdate(ih_matrix);

  return IUP_DEFAULT;
}
Esempio n. 13
0
static int iMatrixEditDropDownAction_CB(Ihandle* ih_list, char* t, int i, int v)
{
    Ihandle* ih = ih_list->parent;
    IFniinsii cb = (IFniinsii)IupGetCallback(ih, "DROPSELECT_CB");
    if(cb)
    {
        int ret = cb(ih, ih->data->edit_lin, ih->data->edit_col, ih_list, t, i, v);

        /* If the user returns IUP_CONTINUE in a dropselect_cb
        the value is accepted and the matrix leaves edition mode. */
        if (ret == IUP_CONTINUE)
        {
            if (iupMatrixEditConfirm(ih) == IUP_DEFAULT)
                iupMatrixDrawUpdate(ih);
        }
    }

    return IUP_DEFAULT;
}
Esempio n. 14
0
static int iMatrixEditDropDownAction_CB(Ihandle* ih, char* t, int i, int v)
{
  Ihandle* ih_matrix = ih->parent;
  IFniinsii cb = (IFniinsii)IupGetCallback(ih_matrix, "DROPSELECT_CB");
  if(cb)
  {
    int ret = cb(ih_matrix, ih_matrix->data->lines.focus_cell, ih_matrix->data->columns.focus_cell, ih, t, i, v);

    /* If the user returns IUP_CONTINUE in a dropselect_cb 
    the value is accepted and the matrix leaves edition mode. */
    if (ret == IUP_CONTINUE)
    {
      iupMatrixEditHide(ih_matrix);
      iupMatrixDrawUpdate(ih_matrix);
    }
  }

  return IUP_DEFAULT;
}
Esempio n. 15
0
static int iMatrixSetFocusCellAttrib(Ihandle* ih, const char* value)
{
  int lin = 0, col = 0;
  if (iupStrToIntInt(value, &lin, &col, ':') == 2)
  {
    if (!iupMatrixCheckCellPos(ih, lin, col))
      return 0;

    if (lin <= 0 || col <= 0) /* title can NOT have the focus */
      return 0;
    if (lin >= ih->data->lines.num || col >= ih->data->columns.num)
      return 0;

    iupMatrixFocusSet(ih, lin, col);

    if (ih->data->cddbuffer)
      iupMatrixDrawUpdate(ih);
  }

  return 0;
}
Esempio n. 16
0
static int iMatrixEditFinish(Ihandle* ih, int setfocus, int update, int accept_ignore)
{
    if (ih->data->editing)
    {
        int ret;

        /* Avoid calling EDITION_CB twice. Usually because a killfocus. */
        if (iupAttribGet(ih, "_IUPMAT_CALL_EDITION"))
            return IUP_DEFAULT;

        iupAttribSet(ih, "_IUPMAT_CALL_EDITION", "1");
        ret = iMatrixEditCallEditionCbUpdateValue(ih, 0, update);
        iupAttribSet(ih, "_IUPMAT_CALL_EDITION", NULL);

        if (ret == IUP_IGNORE && accept_ignore)
            return IUP_IGNORE;

        ih->data->editing = 0;

        iupAttribSet(ih, "_IUPMAT_IGNOREFOCUS", "1");

        IupSetAttribute(ih->data->datah, "VISIBLE", "NO");
        IupSetAttribute(ih->data->datah, "ACTIVE",  "NO");

        if (setfocus)
        {
            IupSetFocus(ih);
            ih->data->has_focus = 1; /* set this so even if getfocus_cb is not called the focus is drawn */
        }

        iupAttribSet(ih, "_IUPMAT_IGNOREFOCUS", NULL);

#ifdef SunOS
        /* Usually when the edit control is hidden the matrix is automatically repainted by the system, except in SunOS. */
        iupMatrixDrawUpdate(ih);
#endif
    }

    return IUP_DEFAULT;
}
Esempio n. 17
0
static int iMatrixFocus_CB(Ihandle* ih, int focus)
{
  int rc = IUP_DEFAULT;

  if (!iupMatrixIsValid(ih, 1))
    return IUP_DEFAULT;

  if (IupGetGlobal("MOTIFVERSION"))
  {
    if (iupAttribGet(ih, "_IUPMAT_DROPDOWN") ||  /* from iMatrixEditDropDown_CB, in Motif */
        iupAttribGet(ih, "_IUPMAT_DOUBLECLICK"))  /* from iMatrixMouseLeftPress, in Motif */
      return IUP_DEFAULT;
  }

  ih->data->has_focus = focus;
  iupMatrixDrawUpdate(ih);

  if (focus)
    iupMatrixAuxCallEnterCellCb(ih);
  else
    iupMatrixAuxCallLeaveCellCb(ih);

  return rc;
}
Esempio n. 18
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;
}
Esempio n. 19
0
static int iMatrixEditTextKeyAny_CB(Ihandle* ih, int c)
{
  Ihandle* ih_matrix = ih->parent;
  IFniiiis cb = (IFniiiis) IupGetCallback(ih_matrix, "ACTION_CB");
  if (cb && !iup_isprint(c)) /* only for other keys that are not characters */
  {
    int oldc = c;
    c = cb(ih_matrix, c, ih_matrix->data->lines.focus_cell, ih_matrix->data->columns.focus_cell, 1, IupGetAttribute(ih, "VALUE"));
    if(c == IUP_IGNORE || c == IUP_CLOSE || c == IUP_CONTINUE)
      return c;
    else if(c == IUP_DEFAULT)
      c = oldc;
  }

  switch (c)
  {
    case K_cUP:
    case K_cDOWN:
    case K_cLEFT:
    case K_cRIGHT:     
      if (iupMatrixEditHide(ih_matrix) == IUP_DEFAULT)
      {
        iupMatrixProcessKeyPress(ih_matrix, c);  
        return IUP_IGNORE;
      }
      break;
    case K_UP:
      if (IupGetInt(ih, "CARET") == 1)
      {
        /* if at the first line of the text */
        if (iupMatrixEditHide(ih_matrix) == IUP_DEFAULT)
        {
          iupMatrixProcessKeyPress(ih_matrix, c);  
          return IUP_IGNORE;
        }
      }
      break;
    case K_DOWN:
      { 
        char* value = IupGetAttribute(ih, "VALUE");
        if (value)
        {
          /* if at the last line of the text */
          if (iupStrLineCount(value) == IupGetInt(ih, "CARET"))
          {
            if (iupMatrixEditHide(ih_matrix) == IUP_DEFAULT)
            {
              iupMatrixProcessKeyPress(ih_matrix, c);  
              return IUP_IGNORE;
            }
          }
        }
      }
      break;
    case K_LEFT:
      if (IupGetInt(ih, "CARETPOS") == 0)
      {
        /* if at the first character */
        if (iupMatrixEditHide(ih_matrix) == IUP_DEFAULT)
        {
          iupMatrixProcessKeyPress(ih_matrix, c);  
          return IUP_IGNORE;
        }
      }
      break;
    case K_RIGHT:
      { 
        char* value = IupGetAttribute(ih, "VALUE");
        if (value)
        {
          /* if at the last character */
          if ((int)strlen(value) == IupGetInt(ih, "CARETPOS"))
          {
            if (iupMatrixEditHide(ih_matrix) == IUP_DEFAULT)
            {
              iupMatrixProcessKeyPress(ih_matrix, c);  
              return IUP_IGNORE;
            }
          }
        }
      }
      break;
    case K_ESC:
      iMatrixEditCancel(ih_matrix, 1, 0, 0); /* set focus + NO update + NO ignore */
      return IUP_IGNORE;  /* always ignore to avoid the defaultesc behavior from here */
    case K_CR:
      if (iupMatrixEditHide(ih_matrix) == IUP_DEFAULT)
      {
        if (iupStrEqualNoCase(IupGetGlobal("DRIVER"), "Win32") && IupGetInt(ih, "MULTILINE"))
        {
          /* work around for Windows when using Multiline */
          iupAttribSetStr(ih_matrix, "_IUPMAT_IGNORE_SHOW", "1");
        }

        if (iupMatrixAuxCallLeaveCellCb(ih_matrix) != IUP_IGNORE)
        {
          iupMATRIX_ScrollKeyCr(ih_matrix);
          iupMatrixAuxCallEnterCellCb(ih_matrix);
        }
        iupMatrixDrawUpdate(ih_matrix);
      }
      return IUP_IGNORE;  /* always ignore to avoid the defaultenter behavior from here */
  }

  return IUP_CONTINUE;
}
Esempio n. 20
0
static int iMatrixEditTextKeyAny_CB(Ihandle* ih_text, int c)
{
    Ihandle* ih = ih_text->parent;
    IFniiiis cb = (IFniiiis) IupGetCallback(ih, "ACTION_CB");
    if (cb && !iup_isprint(c)) /* only for keys that are NOT ASCii characters */
    {
        int oldc = c;
        c = cb(ih, c, ih->data->edit_lin, ih->data->edit_col, 1, IupGetAttribute(ih_text, "VALUE"));
        if(c == IUP_IGNORE || c == IUP_CLOSE || c == IUP_CONTINUE)
            return c;
        else if(c == IUP_DEFAULT)
            c = oldc;
    }

    switch (c)
    {
    case K_cUP:
    case K_cDOWN:
    case K_cLEFT:
    case K_cRIGHT:
        if (iupMatrixEditConfirm(ih) == IUP_DEFAULT)
        {
            iupMatrixProcessKeyPress(ih, c);
            return IUP_IGNORE;
        }
        break;
    case K_UP:
        if (!IupGetInt(ih_text, "MULTILINE") || IupGetInt(ih_text, "CARET") == 1)  /* if Multiline CARET will be "L,C" */
        {
            /* if at the first line of the text */
            if (iupMatrixEditConfirm(ih) == IUP_DEFAULT)
            {
                iupMatrixProcessKeyPress(ih, c);
                return IUP_IGNORE;
            }
        }
        break;
    case K_DOWN:
    {
        /* if at the last line of the text */
        if (!IupGetInt(ih_text, "MULTILINE") || IupGetInt(ih_text, "LINECOUNT") == IupGetInt(ih_text, "CARET"))  /* if Multiline CARET will be "L,C" */
        {
            if (iupMatrixEditConfirm(ih) == IUP_DEFAULT)
            {
                iupMatrixProcessKeyPress(ih, c);
                return IUP_IGNORE;
            }
        }
    }
    break;
    case K_LEFT:
        if (IupGetInt(ih_text, "CARETPOS") == 0)
        {
            /* if at the first character */
            if (iupMatrixEditConfirm(ih) == IUP_DEFAULT)
            {
                iupMatrixProcessKeyPress(ih, c);
                return IUP_IGNORE;
            }
        }
        break;
    case K_RIGHT:
    {
        /* if at the last character */
        if (IupGetInt(ih_text, "COUNT") == IupGetInt(ih_text, "CARETPOS"))
        {
            if (iupMatrixEditConfirm(ih) == IUP_DEFAULT)
            {
                iupMatrixProcessKeyPress(ih, c);
                return IUP_IGNORE;
            }
        }
    }
    break;
    case K_ESC:
        iupMatrixEditAbort(ih);
        return IUP_IGNORE;  /* always ignore to avoid the defaultesc behavior from here */
    case K_CR:
        if (iupMatrixEditConfirm(ih) == IUP_DEFAULT)
        {
            if (iupStrEqualNoCase(IupGetGlobal("DRIVER"), "Win32") && IupGetInt(ih_text, "MULTILINE"))
            {
                /* work around for Windows when using Multiline */
                iupAttribSet(ih, "_IUPMAT_IGNORE_SHOW", "1");
            }

            if (iupMatrixAuxCallLeaveCellCb(ih) != IUP_IGNORE)
            {
                iupMATRIX_ScrollKeyCr(ih);
                iupMatrixAuxCallEnterCellCb(ih);
            }
            iupMatrixDrawUpdate(ih);
        }
        return IUP_IGNORE;  /* always ignore to avoid the defaultenter behavior from here */
    }

    return IUP_CONTINUE;
}