static void _AddKeyDec(EDIT_Obj* pObj, EDIT_Handle hObj, int Key) {
  char c;
  if (pObj) {
    switch (Key) {
      case '+':
        if (pObj->CursorPos == 0) {
          _MakePositive(pObj, hObj);
          _IncrementCursor(pObj);
        }
        break;
      case '-':
        if (pObj->CursorPos == 0) {
          _MakeNegative(pObj, hObj);
          _IncrementCursor(pObj);
        }
        break;
      #if EDIT_DEC_DIGITONLY
        case GUI_KEY_UP:
          c = _GetCurrentChar(pObj);
          if ((c == '-') || (c == '+')) {
            _SwapSign(pObj, hObj);
          } else {
            int Digit = GetCurrentDigit(pObj) + 1;
            if (Digit > 9)
              Digit = 0;
            _EditDec(Digit, pObj, hObj);
          }
          break;
        case GUI_KEY_DOWN:
          c = _GetCurrentChar(pObj);
          if ((c == '-') || (c == '+')) {
            _SwapSign(pObj, hObj);
          } else {
            int Digit = GetCurrentDigit(pObj) - 1;
            if (Digit < 0)
              Digit = 9;
            _EditDec(Digit, pObj, hObj);
          }
          break;
      #else
        case GUI_KEY_UP:
          c = _GetCurrentChar(pObj);
          if ((c == '-') || (c == '+')) {
            _SwapSign(pObj, hObj);
          } else {
            _AddPosition(pObj, hObj, 1);
          }
          break;
        case GUI_KEY_DOWN:
          c = _GetCurrentChar(pObj);
          if ((c == '-') || (c == '+')) {
            _SwapSign(pObj, hObj);
          } else {
            _AddPosition(pObj, hObj, -1);
          }
          break;
      #endif
      case GUI_KEY_RIGHT:
        _IncrementCursor(pObj);
        break;
      case GUI_KEY_LEFT:
        if (pObj->CursorPos > 0)
          pObj->CursorPos--;
        if (_GetCurrentChar(pObj) == '.') {
          if (pObj->CursorPos > 0) {
            pObj->CursorPos--;
          } else {
            pObj->CursorPos++;
          }
        }
        break;
      default:
        {
          char c = _GetCurrentChar(pObj);
          if ((c != '-') && (c != '+')) {
            int Digit = _DecChar2Int(Key);
            if (Digit >= 0) {
              _EditDec(Digit, pObj, hObj);
              _IncrementCursor(pObj);
            }
          }
        }
        break;
    }
  }
  _UpdateBuffer(pObj);
}
示例#2
0
/*********************************************************************
*
*       _AddKeyDec
*/
static void _AddKeyDec(EDIT_Handle hObj, int Key) {
  char c;
  EDIT_Obj * pObj;
  pObj = EDIT_H2P(hObj); /* The GUI needs not to be locked here. This function is called only from EDIT_AddKey which has already locked the GUI */
  if (pObj) {
    switch (Key) {
      case '+':
        if (pObj->CursorPos == 0) {
          _MakePositive(pObj, hObj);
          _IncrementCursor(pObj);
        }
        break;
      case '-':
        if (pObj->CursorPos == 0) {
          _MakeNegative(pObj, hObj);
          _IncrementCursor(pObj);
        }
        break;
      #if EDIT_DEC_DIGITONLY
        case GUI_KEY_UP:
          c = EDIT__GetCurrentChar(pObj);
          if ((c == '-') || (c == '+')) {
            _SwapSign(pObj, hObj);
          } else {
            int Digit = GetCurrentDigit(pObj) + 1;
            if (Digit > 9)
              Digit = 0;
            _EditDec(Digit, pObj, hObj);
          }
          break;
        case GUI_KEY_DOWN:
          c = EDIT__GetCurrentChar(pObj);
          if ((c == '-') || (c == '+')) {
            _SwapSign(pObj, hObj);
          } else {
            int Digit = GetCurrentDigit(pObj) - 1;
            if (Digit < 0)
              Digit = 9;
            _EditDec(Digit, pObj, hObj);
          }
          break;
      #else
        case GUI_KEY_UP:
          c = EDIT__GetCurrentChar(pObj);
          if ((c == '-') || (c == '+')) {
            _SwapSign(pObj, hObj);
          } else {
            _AddPosition(pObj, hObj, 1);
          }
          break;
        case GUI_KEY_DOWN:
          c = EDIT__GetCurrentChar(pObj);
          if ((c == '-') || (c == '+')) {
            _SwapSign(pObj, hObj);
          } else {
            _AddPosition(pObj, hObj, -1);
          }
          break;
      #endif
      case GUI_KEY_RIGHT:
        _IncrementCursor(pObj);
        break;
      case GUI_KEY_LEFT:
        EDIT__SetCursorPos(pObj, pObj->CursorPos - 1);
        if (EDIT__GetCurrentChar(pObj) == '.') {
          if (pObj->CursorPos > 0) {
            EDIT__SetCursorPos(pObj, pObj->CursorPos - 1);
          } else {
            EDIT__SetCursorPos(pObj, pObj->CursorPos + 1);
          }
        }
        break;
      default:
        {
          char c = EDIT__GetCurrentChar(pObj);
          if ((c != '-') && (c != '+')) {
            int Digit = _DecChar2Int(Key);
            if (Digit >= 0) {
              _EditDec(Digit, pObj, hObj);
              _IncrementCursor(pObj);
            }
          }
        }
        break;
    }
  }
  _UpdateBuffer(hObj);
}