コード例 #1
0
ファイル: EditBin.c プロジェクト: byxob/calendar
void EDIT_SetBinMode(EDIT_Handle hEdit, U32 Value, U32 Min, U32 Max) {
  EDIT_Obj* pObj;
  int MaxLen;
  WM_LOCK();
  pObj = EDIT_H2P(hEdit);
  pObj->pfAddKeyEx    = _AddKeyBin;
  pObj->pfUpdateBufer = _UpdateBuffer;
  pObj->CurrentValue = Value;
  pObj->CursorPos = 0;
  MaxLen = pObj->MaxLen;
  if (MaxLen <= 0 ) {
    MaxLen = _GetNumDigits(Max);
  }
  if (MaxLen > 32) {
    MaxLen = 32;
  }
  if (MaxLen != pObj->MaxLen) {
    EDIT_SetMaxLen(hEdit, MaxLen);
  }
  pObj->Min = Min;
  pObj->Max = Max;
  pObj->EditMode = GUI_EDIT_MODE_OVERWRITE;
  _UpdateBuffer(pObj);
  WM_UNLOCK();
}
コード例 #2
0
static void AddKeyHex(EDIT_Obj* pObj, EDIT_Handle hObj, int Key) {
  if (pObj) {
    switch (Key) {
      #if EDIT_HEX_DIGITONLY
      case GUI_KEY_UP:
        {
          int Nibble = (_GetCurrentNibble(pObj) + 1) & 15;
          _EditHex(Nibble, pObj, hObj);
        }
        break;
      case GUI_KEY_DOWN:
        {
          int Nibble = (_GetCurrentNibble(pObj) + 1) & 15;
          _EditHex(Nibble, pObj, hObj);
        }
        break;
      #else
      case GUI_KEY_UP:
        _AddPosition(pObj, hObj, 1);
        break;
      case GUI_KEY_DOWN:
        _AddPosition(pObj, hObj, -1);
        break;
      #endif
      case GUI_KEY_RIGHT:
        if (pObj->CursorPos < (pObj->MaxLen - 1))
          pObj->CursorPos++;
        break;
      case GUI_KEY_LEFT:
        if (pObj->CursorPos > 0)
          pObj->CursorPos--;
        break;
      default:
        {
          int Nibble = _HexChar2Int(Key);
          if (Nibble >= 0) {
            _EditHex(Nibble, pObj, hObj);
            if (pObj->CursorPos < (pObj->MaxLen - 1))
              pObj->CursorPos++;
          }
        }
        break;
    }
  }
  _UpdateBuffer(pObj);
}
コード例 #3
0
ファイル: EDITHex.c プロジェクト: Liu1992/GasSub_LPC1788
/*********************************************************************
*
*       _AddKeyHex
*/
static void _AddKeyHex(EDIT_Handle hObj, int Key) {
  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) {
      #if EDIT_HEX_DIGITONLY
      case GUI_KEY_UP:
        {
          int Nibble = (_GetCurrentNibble(pObj) + 1) & 15;
          _EditHex(Nibble, pObj, hObj);
        }
        break;
      case GUI_KEY_DOWN:
        {
          int Nibble = (_GetCurrentNibble(pObj) + 1) & 15;
          _EditHex(Nibble, pObj, hObj);
        }
        break;
      #else
      case GUI_KEY_UP:
        _AddPosition(pObj, hObj, 1);
        break;
      case GUI_KEY_DOWN:
        _AddPosition(pObj, hObj, -1);
        break;
      #endif
      case GUI_KEY_RIGHT:
        EDIT__SetCursorPos(pObj, pObj->CursorPos + 1);
        break;
      case GUI_KEY_LEFT:
        EDIT__SetCursorPos(pObj, pObj->CursorPos - 1);
        break;
      default:
        {
          int Nibble = _HexChar2Int(Key);
          if (Nibble >= 0) {
            _EditHex(Nibble, pObj, hObj);
            EDIT__SetCursorPos(pObj, pObj->CursorPos + 1);
          }
        }
        break;
    }
  }
  _UpdateBuffer(hObj);
}
コード例 #4
0
ファイル: EditBin.c プロジェクト: byxob/calendar
static void _AddKeyBin(EDIT_Obj* pObj, EDIT_Handle hObj, int Key) {
  if (pObj) {
    switch (Key) {
      case GUI_KEY_UP:
        {
          int Bit = _GetCurrentBit(pObj) + 1;
          if (Bit > 1)
            Bit = 0;
          _EditBin(Bit, pObj, hObj);
        }
        break;
      case GUI_KEY_DOWN:
        {
          int Bit = _GetCurrentBit(pObj) - 1;
          if (Bit < 0)
            Bit = 1;
          _EditBin(Bit, pObj, hObj);
        }
        break;
      case GUI_KEY_RIGHT:
        if (pObj->CursorPos < (pObj->MaxLen - 1))
          pObj->CursorPos++;
        break;
      case GUI_KEY_LEFT:
        if (pObj->CursorPos > 0)
          pObj->CursorPos--;
        break;
      default:
        {
          int Bit = _BinChar2Int(Key);
          if (Bit >= 0) {
            _EditBin(Bit, pObj, hObj);
            if (pObj->CursorPos < (pObj->MaxLen - 1))
              pObj->CursorPos++;
          }
        }
        break;
    }
  }
  _UpdateBuffer(pObj);
}
コード例 #5
0
void EDIT_SetDecMode(EDIT_Handle hEdit, I32 Value, I32 Min, I32 Max, int Shift, U8 Flags) {
  EDIT_Obj* pObj;
  WM_LOCK();
  if (hEdit) {
    pObj = EDIT_H2P(hEdit);
    pObj->pfAddKeyEx    = _AddKeyDec;
    pObj->pfUpdateBufer = _UpdateBuffer;
    pObj->CurrentValue  = Value;
    pObj->CursorPos     = 0;
    pObj->Min           = Min;
    pObj->Max           = Max;
    pObj->NumDecs       = Shift;
    pObj->Flags         = Flags;
    pObj->EditMode      = GUI_EDIT_MODE_OVERWRITE;
    _UpdateBuffer(pObj);
    if (_GetCurrentChar(pObj) == '.') {
      pObj->CursorPos++;
    }
  }
  WM_UNLOCK();
}
コード例 #6
0
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);
}
コード例 #7
0
ファイル: EDITDec.c プロジェクト: ChunHungLiu/ubuntu230os
/*********************************************************************
*
*       _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);
}