⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cashterminal.c

📁 ucgu最新版本 4.14
💻 C
📖 第 1 页 / 共 3 页
字号:
*       _CreateFrame
*/
static WM_HWIN _CreateFrame(WM_CALLBACK* cb) {
  int x = 0;
  int y = 0;
  x = FRAME_BORDER + MAIN_BORDER;
  y = FRAME_BORDER + MAIN_TITLE_HEIGHT;
  _hLastFrame = WM_CreateWindowAsChild(x, y, FRAME_WIDTH, FRAME_HEIGHT, WM_HBKWIN, WM_CF_SHOW, cb, 0);
  return _hLastFrame;
}

/*********************************************************************
*
*       _DeleteFrame
*/
static void _DeleteFrame(void) {
  WM_DeleteWindow(_hLastFrame);
  _hLastFrame = 0;
}

/*********************************************************************
*
*       _CreateButton
*/
static WM_HWIN _CreateButton(WM_HWIN hParent, const char* pText, int Id, int x, int y, int w, int h, unsigned TextId) {
  WM_HWIN hButton;
  hButton = BUTTON_CreateEx(x, y, w, h, hParent, WM_CF_SHOW, 0, Id);
  if (TextId) {
    pText = _GetLang(TextId);
  }
  BUTTON_SetText      (hButton,    pText);
  BUTTON_SetFont      (hButton,    FRAME_BUTTON_FONT);
  BUTTON_SetBkColor   (hButton, 0, FRAME_BUTTON_BKCOLOR0);
  BUTTON_SetBkColor   (hButton, 1, FRAME_BUTTON_BKCOLOR1);
  BUTTON_SetBkColor   (hButton, 2, FRAME_BUTTON_BKCOLOR2);
  BUTTON_SetTextColor (hButton, 0, FRAME_BUTTON_COLOR0);
  BUTTON_SetTextColor (hButton, 1, FRAME_BUTTON_COLOR1);
  BUTTON_SetTextColor (hButton, 2, FRAME_BUTTON_COLOR0);
  WIDGET_SetEffect    (hButton,    FRAME_BUTTON_EFFECT);
  BUTTON_SetFocussable(hButton,    0);
  return hButton;
}

/*********************************************************************
*
*       Static code, logo functions
*
**********************************************************************
*/
/*********************************************************************
*
*       _DrawLogoBox
*/
static void _DrawLogoBox(int Index, const GUI_BITMAP GUI_UNI_PTR* pBitmap) {
  int x, y, w, h;
  x  = (FRAME_WIDTH - (5 * LOGO_FRAME_SIZE_X) - (4 * LOGO_FRAME_DIST_X)) >> 1;
  y  = FRAME_HEIGHT - LOGO_FRAME_OFFSET_Y - LOGO_FRAME_SIZE_Y;
  w  = LOGO_FRAME_SIZE_X;
  h  = LOGO_FRAME_SIZE_Y;
  x += Index * (w + LOGO_FRAME_DIST_X);
  GUI_SetBkColor(LOGO_FRAME_BKCOLOR);
  GUI_ClearRect(x, y, x + w - 1, y + h - 1);
  _DrawDownRect(LOGO_FRAME_EFFECT, x, y, x + w - 1, y + h - 1);
  x += (w - pBitmap->XSize) >> 1;
  y += (h - pBitmap->YSize) >> 1;
  GUI_DrawBitmap(pBitmap, x, y);
  GUI_SetBkColor(FRAME_BKCOLOR);
  GUI_SetColor(FRAME_TEXTCOLOR);
  GUI_SetFont(FRAME_FONT);
}

/*********************************************************************
*
*       Static code, NumPad
*
**********************************************************************
*/
/*********************************************************************
*
*       _cbNumPad
*/
static void _cbNumPad(WM_MESSAGE* pMsg) {
  WM_HWIN hWin = pMsg->hWin;
  switch (pMsg->MsgId) {
  case WM_CREATE:
    WM_SetFocus(hWin);
    _PIN_Value  = 0;
    _PIN_Digits = 0;
    break;
  case WM_PAINT: {
    GUI_RECT r;
    WM_GetClientRect(&r);
    GUI_SetBkColor(NUMPAD_BKCOLOR);
    GUI_Clear();
    _DrawUpRectEx(NUMPAD_EFFECT, &r);
  } break;
  case WM_NOTIFY_PARENT:
    if (pMsg->Data.v == WM_NOTIFICATION_RELEASED) {
      int Id = WM_GetId(pMsg->hWinSrc);
      switch (Id) {
      case NUMPAD_ID_0:
      case NUMPAD_ID_1:
      case NUMPAD_ID_2:
      case NUMPAD_ID_3:
      case NUMPAD_ID_4:
      case NUMPAD_ID_5:
      case NUMPAD_ID_6:
      case NUMPAD_ID_7:
      case NUMPAD_ID_8:
      case NUMPAD_ID_9:
        _PIN_Value = (_PIN_Value * 10) + (Id - NUMPAD_ID_0);
        if (_PIN_Digits < 4) {
          _PIN_Digits++;
          WM_SendMessageNoPara(WM_GetParent(hWin), MSG_PIN_CHANGED);
        }
        break;
      case NUMPAD_ID_A:   /* Cancel   */
        WM_SendMessageNoPara(WM_GetParent(hWin), MSG_PIN_CANCEL);
        break;
      case NUMPAD_ID_B:   /* Correct  */
        _PIN_Value /= 10;
        if (_PIN_Digits) {
          _PIN_Digits--;
        }
        WM_SendMessageNoPara(WM_GetParent(hWin), MSG_PIN_CHANGED);
        break;
      case NUMPAD_ID_D:   /* Confirm  */
        if (_PIN_Digits == 4) {
          WM_SendMessageNoPara(WM_GetParent(hWin), MSG_PIN_OK);
        } else {
          WM_SendMessageNoPara(WM_GetParent(hWin), MSG_PIN_ERROR);
        }
        break;
      }
    }
    break;
  default:
    WM_DefaultProc(pMsg);
  }
}

/*********************************************************************
*
*       _CreateNumPadButton
*/
static WM_HWIN _CreateNumPadButton(WM_HWIN hParent, const char* pText, int Id,
                             int x, int y, int w, int h,
                             GUI_COLOR Color, GUI_COLOR PressedColor, int Enable, unsigned TextId)
{
  WM_HWIN hButton;
  hButton = BUTTON_CreateEx(x, y, w, h, hParent, WM_CF_SHOW, 0, Id);
  if (Enable) {
    if (TextId) {
      pText = _GetLang(TextId);
    }
    BUTTON_SetText(hButton, pText);
  } else {
    WM_DisableWindow(hButton);
  }
  BUTTON_SetFont      (hButton,    NUMPAD_BUTTON_FONT);
  BUTTON_SetBkColor   (hButton, 0, NUMPAD_BUTTON_BKCOLOR0);
  BUTTON_SetBkColor   (hButton, 1, NUMPAD_BUTTON_BKCOLOR1);
  BUTTON_SetBkColor   (hButton, 2, NUMPAD_BUTTON_BKCOLOR2);
  BUTTON_SetTextColor (hButton, 0, Color);
  BUTTON_SetTextColor (hButton, 1, PressedColor);
  BUTTON_SetTextColor (hButton, 2, Color);
  BUTTON_SetFocussable(hButton, 0);
  WIDGET_SetEffect    (hButton, NUMPAD_BUTTON_EFFECT);
  return hButton;
}

/*********************************************************************
*
*       _CreateNumPad
*/
static WM_HWIN _CreateNumPad(WM_HWIN hParent, int x, int y) {
  int w, h, bx, by, bw, bh, dx, dy;
  /* Position and size */
  bx = NUMPAD_BORDER;
  by = NUMPAD_BORDER;
  bw = NUMPAD_BUTTON_WIDTH;
  bh = NUMPAD_BUTTON_HEIGHT;
  dx = NUMPAD_BUTTON_DIST_X;
  dy = NUMPAD_BUTTON_DIST_Y;
  w  = (bx * 2) + (bw * 11/2) + (dx * 5);
  h  = (by * 2) + (bh * 4)    + (dy * 3);
  x -= (w >> 1);
  y -= (h >> 1);
  /* Create NumPad window */
  _hNumPad = WM_CreateWindowAsChild(x, y, w, h, hParent, WM_CF_SHOW, _cbNumPad, 0);
  /* Create buttons for NumPad */
  _CreateNumPadButton(_hNumPad, "1", NUMPAD_ID_1, bx + 0*(bw+dx),   by + 0*(bh+dy), bw,     bh, NUMPAD_BUTTON_COLOR0,  NUMPAD_BUTTON_COLOR1,  1, 0);
  _CreateNumPadButton(_hNumPad, "2", NUMPAD_ID_2, bx + 1*(bw+dx),   by + 0*(bh+dy), bw,     bh, NUMPAD_BUTTON_COLOR0,  NUMPAD_BUTTON_COLOR1,  1, 0);
  _CreateNumPadButton(_hNumPad, "3", NUMPAD_ID_3, bx + 2*(bw+dx),   by + 0*(bh+dy), bw,     bh, NUMPAD_BUTTON_COLOR0,  NUMPAD_BUTTON_COLOR1,  1, 0);
  _CreateNumPadButton(_hNumPad, "4", NUMPAD_ID_4, bx + 0*(bw+dx),   by + 1*(bh+dy), bw,     bh, NUMPAD_BUTTON_COLOR0,  NUMPAD_BUTTON_COLOR1,  1, 0);
  _CreateNumPadButton(_hNumPad, "5", NUMPAD_ID_5, bx + 1*(bw+dx),   by + 1*(bh+dy), bw,     bh, NUMPAD_BUTTON_COLOR0,  NUMPAD_BUTTON_COLOR1,  1, 0);
  _CreateNumPadButton(_hNumPad, "6", NUMPAD_ID_6, bx + 2*(bw+dx),   by + 1*(bh+dy), bw,     bh, NUMPAD_BUTTON_COLOR0,  NUMPAD_BUTTON_COLOR1,  1, 0);
  _CreateNumPadButton(_hNumPad, "7", NUMPAD_ID_7, bx + 0*(bw+dx),   by + 2*(bh+dy), bw,     bh, NUMPAD_BUTTON_COLOR0,  NUMPAD_BUTTON_COLOR1,  1, 0);
  _CreateNumPadButton(_hNumPad, "8", NUMPAD_ID_8, bx + 1*(bw+dx),   by + 2*(bh+dy), bw,     bh, NUMPAD_BUTTON_COLOR0,  NUMPAD_BUTTON_COLOR1,  1, 0);
  _CreateNumPadButton(_hNumPad, "9", NUMPAD_ID_9, bx + 2*(bw+dx),   by + 2*(bh+dy), bw,     bh, NUMPAD_BUTTON_COLOR0,  NUMPAD_BUTTON_COLOR1,  1, 0);
  _CreateNumPadButton(_hNumPad, "*", NUMPAD_ID_X, bx + 0*(bw+dx),   by + 3*(bh+dy), bw,     bh, NUMPAD_BUTTON_COLOR0,  NUMPAD_BUTTON_COLOR1,  0, 0) ;
  _CreateNumPadButton(_hNumPad, "0", NUMPAD_ID_0, bx + 1*(bw+dx),   by + 3*(bh+dy), bw,     bh, NUMPAD_BUTTON_COLOR0,  NUMPAD_BUTTON_COLOR1,  1, 0);
  _CreateNumPadButton(_hNumPad, "#", NUMPAD_ID_Y, bx + 2*(bw+dx),   by + 3*(bh+dy), bw,     bh, NUMPAD_BUTTON_COLOR0,  NUMPAD_BUTTON_COLOR1,  0, 0);
  _CreateNumPadButton(_hNumPad, "",  NUMPAD_ID_A, bx + 3*bw + 5*dx, by + 0*(bh+dy), bw*5/2, bh, NUMPAD_BUTTON_RED0,    NUMPAD_BUTTON_RED1,    1, TEXT_ID_ABBRUCH);
  _CreateNumPadButton(_hNumPad, "",  NUMPAD_ID_B, bx + 3*bw + 5*dx, by + 1*(bh+dy), bw*5/2, bh, NUMPAD_BUTTON_YELLOW0, NUMPAD_BUTTON_YELLOW1, 1, TEXT_ID_KORREKTUR);
  _CreateNumPadButton(_hNumPad, "",  NUMPAD_ID_C, bx + 3*bw + 5*dx, by + 2*(bh+dy), bw*5/2, bh, NUMPAD_BUTTON_COLOR0,  NUMPAD_BUTTON_COLOR1,  0, 0);
  _CreateNumPadButton(_hNumPad, "",  NUMPAD_ID_D, bx + 3*bw + 5*dx, by + 3*(bh+dy), bw*5/2, bh, NUMPAD_BUTTON_GREEN0,  NUMPAD_BUTTON_GREEN1,  1, TEXT_ID_BESTAETIGEN);
  return _hNumPad;
}

/*********************************************************************
*
*       _DeleteNumPad
*/
static void _DeleteNumPad(void) {
  WM_DeleteWindow(_hNumPad);
}

/*********************************************************************
*
*       Static code, background callback
*
**********************************************************************
*/
/*********************************************************************
*
*       _cbBkWindow
*/
static void _cbBkWindow(WM_MESSAGE* pMsg) {
  switch (pMsg->MsgId) {
  case WM_KEY:
    if (((WM_KEY_INFO *)pMsg->Data.p)->Key == GUI_KEY_ESCAPE) {
      _Break = 1;
    }
    break;
  case WM_PAINT: {
    int x, y, w, h;
    GUI_SetBkColor(MAIN_BKCOLOR);
    GUI_SetColor(MAIN_TEXTCOLOR);
    GUI_SetFont(MAIN_FONT);
    GUI_Clear();
    x = MAIN_LOGO_OFFSET_X + MAIN_BORDER;
    y = MAIN_LOGO_OFFSET_Y + ((MAIN_TITLE_HEIGHT - MAIN_LOGO_BITMAP->YSize) >> 1);
    GUI_DrawBitmap(MAIN_LOGO_BITMAP, x, y);
    x = MAIN_BORDER;
    y = MAIN_TITLE_HEIGHT;
    w = 640 - (MAIN_BORDER * 2);
    h = 480 - (MAIN_BORDER + MAIN_TITLE_HEIGHT);
    _DrawDownRect(FRAME_EFFECT, x, y, x + w - 1, y + h - 1);
  } break;
  default:
    WM_DefaultProc(pMsg);
  }
}

/*********************************************************************
*
*       Static code, frame callbacks
*
**********************************************************************
*/
/*********************************************************************
*
*       _cbThanks
*/
static void _cbThanks(WM_MESSAGE* pMsg) {
  WM_HWIN hWin = pMsg->hWin;
  switch (pMsg->MsgId) {
  case WM_CREATE:
    WM_SetFocus(hWin);
    break;
  case WM_PAINT:
    _PaintFrame();
    GUI_DispStringHCenterAt(_GetLang(TEXT_ID_VIELEN_DANK), FRAME_WIDTH >> 1, 65);
    GUI_DrawBitmap(&bmSeggerLogoLarge, (FRAME_WIDTH - bmSeggerLogoLarge.XSize) >> 1, 150);
    break;
  case WM_TOUCH:
    if (((GUI_PID_STATE *)pMsg->Data.p)->Pressed == 1) {
      _Break = 1;
    }
    break;
  default:
    WM_DefaultProc(pMsg);
  }
}

/*********************************************************************
*
*       _cbRemoveMoney
*/
static void _cbRemoveMoney(WM_MESSAGE* pMsg) {
  WM_HWIN hWin = pMsg->hWin;
  switch (pMsg->MsgId) {
  case WM_CREATE:
    WM_SetFocus(hWin);
    break;
  case WM_PAINT:
    _PaintFrame();
    GUI_DispStringHCenterAt(_GetLang(TEXT_ID_GELD_ENTNEHMEN), FRAME_WIDTH >> 1, 125);
    break;
  case WM_TOUCH:
    if (((GUI_PID_STATE *)pMsg->Data.p)->Pressed == 1) {
      _DeleteFrame();
      _CreateFrame(&_cbThanks);
    }
    break;
  default:
    WM_DefaultProc(pMsg);
  }
}

/*********************************************************************
*
*       _cbRemoveCard
*/
static void _cbRemoveCard(WM_MESSAGE* pMsg) {
  WM_HWIN hWin = pMsg->hWin;
  switch (pMsg->MsgId) {
  case WM_CREATE:
    WM_SetFocus(hWin);
    break;
  case WM_PAINT:
    _PaintFrame();
    GUI_DispStringHCenterAt(_GetLang(TEXT_ID_KARTE_ENTNEHMEN), FRAME_WIDTH >> 1, 125);
    break;
  case WM_TOUCH:
    if (((GUI_PID_STATE *)pMsg->Data.p)->Pressed == 1) {
      _DeleteFrame();
      _CreateFrame(&_cbRemoveMoney);
    }
    break;
  default:
    WM_DefaultProc(pMsg);
  }
}

/*********************************************************************
*
*       _cbWait
*/
static void _cbWait(WM_MESSAGE* pMsg) {
  WM_HWIN hWin = pMsg->hWin;
  switch (pMsg->MsgId) {
  case WM_CREATE:
    WM_SetFocus(hWin);
    break;
  case WM_PAINT:
    _PaintFrame();
    GUI_DispStringHCenterAt(_GetLang(TEXT_ID_BITTE_GEDULD), FRAME_WIDTH >> 1, 125);
    break;
  case WM_TOUCH:
    if (((GUI_PID_STATE *)pMsg->Data.p)->Pressed == 1) {
      _DeleteFrame();
      _CreateFrame(&_cbRemoveCard);
    }
    break;
  default:
    WM_DefaultProc(pMsg);
  }
}

/*********************************************************************
*
*       _cbEnterAmount
*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -