Example #1
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;
}
Example #2
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;
}
Example #3
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;
}
Example #4
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;
}