#include "Face.h"
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include "ConsoleOut.h"
#pragma comment(lib,"ConsoleOut.lib")
#include "dataType.h"
/***********************界面操作函数*************************/
//打印字符串到屏幕
void OutTxt(int x, int y, char *s, int TxtColor, int BkColor)
{
MoveCursorTo(x,y);
SetTextColor(TxtColor,BkColor);
printf("%s\n",s);
}
//将字符串显示在输入框中,<space:字符间距>;<pwdChar:密码掩饰字符>
void BoxTxtOuput(int left, int top, char *buffer,int space,char pwdChar)
{
int i=0;
char c[2]={'\0'};
if(pwdChar==NULL) pwdChar='\0';
if(space<0) space=0;
++space;
while(*buffer!='\0')
{
c[0]=(pwdChar=='\0'? *buffer : pwdChar);
OutTxt(left+i,top,c);
i+=space;
buffer++;
}
}
//保存输入框中的字符,<count:字符个数累计>;<max:最大字符个数>
void BoxTxtInput(char buffer[], char kbChar,int &count,int max)
{
int &i=count;
if(kbChar>='0' && kbChar<='9' && i<max)
{
*(buffer+i)=kbChar;
i++;
}
else if('c'==kbChar || 'C'==kbChar)
{
int j=0;
while(j<i)
{
buffer[j++]='\0';
}
i=0;
}
else if('\b'==kbChar && i>0)
{
buffer[--i]='\0';
}
}
//隐去尾部的PRESS字段
void HideField(int x,int y)
{
MoveCursorTo(x, y);
SetTextColor(black, black);
}
//设置Tab键选择项
void TabSelIndex(char kbChar,int & beginIndex,int endIndex)
{
if(9==kbChar || 32==kbChar)
{
beginIndex++;
}
if(beginIndex>endIndex)
{
beginIndex=1;
}
}
//创建菜单选择按扭
void CreateBut(char *Caption,int Left, int Top, int Width, int Height,int BorderColor,int BorderBkColor,int TxtColor,int BkColor)
{
CreateSmWindow(Left,Top,Width,Height, BorderColor, BorderBkColor,TxtColor,BkColor,"",false);
OutTxt(Left+2,Top+Height/2+1,Caption,TxtColor,BkColor);
}
//创建输入框
void CreateBox(int Left, int Top, int Width, int Height,int BorderColor,int BorderBkColor,int TxtColor,int BkColor)
{
if(Width==NULL) Width=BOX_WIDTH;
if(Height==NULL) Height=BOX_HEIGHT;
CreateSmWindow(Left,Top,Width,Height, BorderColor,BorderBkColor, TxtColor,BkColor,"",false);
}
/********************界面绘制*************************/
/****************开始界面*******************/
void StartFace(){
CloseCursor();
CreateSmWindow( 0, 0, FRM_WIDTH, FRM_HEIGHT, FRM_BOR_TXT, FRM_BOR_BK, FRM_TXT, FRM_BK,FRM_TITLE,false );
OutTxt(28,2,"欢迎光临 ATM");
CreateBut(" 登 陆", 20,8,10,5);
CreateBut(" 注 册", 44,8,10,5);
OutTxt(10,20,"操作说明:Tab选择,Enter确定");
HideField();
}
void SelStartFace(int n) //Tab选择功能时(开始界面),加深边框颜色
{
if(n==1)
{
CreateBut(" 登 陆", 20,8,10,5,BUT_BOR_SEL);
CreateBut(" 注 册", 44,8,10,5);
}
else if(n==2)
{
CreateBut(" 登 陆", 20,8,10,5);
CreateBut(" 注 册", 44,8,10,5,BUT_BOR_SEL);
}
HideField();
}
/****************注册界面*****************/
void LoginFace()
{
CloseCursor();
CreateSmWindow( 0, 0, FRM_WIDTH, FRM_HEIGHT, FRM_BOR_TXT, FRM_BOR_BK, FRM_TXT, FRM_BK,FRM_TITLE,false );
OutTxt(34,2,"ATM 机-注册\n");
OutTxt(19,5, "请输入帐号和密码\n");
OutTxt(19,9,"账号:\n");
OutTxt(56,9, "限12位数字!");
CreateBox( 25, 8); //帐号输入框
OutTxt(19,12,"密码:\n");
OutTxt(56,12,"限 6位数字!\n");
CreateBox( 25, 11); //密码输入框
OutTxt(15,15,"重复密码:\n");
CreateBox( 25, 14); //密码输入框
OutTxt(22,18," L-注册 E-返回\n");
OutTxt(4,22,"提醒:防止您的账号和密码被他人窃取!\n");
HideField();
}
void SelLoginFace(int n) //Tab选择输入框时(注册界面),加深边框颜色
{
if(n==1) //选中帐号输入框
{
CreateBox( 25, 8, NULL, NULL, BUT_BOR_SEL);
CreateBox( 25, 14);
}
else if(n==2) //选中密码输入框
{
CreateBox( 25, 8);
CreateBox( 25, 11, NULL, NULL, BUT_BOR_SEL);
}
else if(n==3) //选中重复密码输入框
{
CreateBox( 25, 11);
CreateBox( 25, 14, NULL, NULL, BUT_BOR_SEL);
}
HideField();
}
/*****************登录界面******************/
void LogonFace()
{
CloseCursor();
CreateSmWindow( 0, 0, FRM_WIDTH, FRM_HEIGHT, FRM_BOR_TXT, FRM_BOR_BK, FRM_TXT, FRM_BK,FRM_TITLE,false );
OutTxt(27,2,"欢迎使用武汉市商业银行 ATM 机\n");
OutTxt(15,8,"请输入账号:\n");
CreateBox( 27, 7);
OutTxt(15,13,"请输入密码:\n");
CreateBox( 27, 12);
OutTxt(22,18,"O-账号登录 C-清除 E-返回\n");
OutTxt(4,22,"注意:防止您的账号和密码被他人窃取。\n");
HideField();
}
void SelLogonFace(int n) //Tab选择输入框时(登录功能界面),加深边框颜色
{
if(n==1) //选中帐号输入框
{
CreateBox( 27, 7, NULL, NULL, BOX_BOR_SEL);
CreateBox( 27, 12);
}
else if(n==2) //选中密码输入框
{
CreateBox( 27, 7);
CreateBox( 27, 12, NULL, NULL, BOX_BOR_SEL);
}
HideField();
}
/*****************主界面******************/
void MainFace()
{
CloseCursor();
CreateSmWindow( 0, 0, FRM_WIDTH, FRM_HEIGHT, FRM_BOR_TXT, FRM_BOR_BK, FRM_TXT, FRM_BK,FRM_TITLE,false );
OutTxt(21,3,"欢迎使用武汉市商业银行 ATM 机\n");
CreateBut(" 存 款(1)",15, 7,13,1); CreateBut(" 存款查询(2)", 41, 7,13,1);
CreateBut(" 取 款(3)",15,10,13,1); CreateBut(" 取款查询(4)", 41,10,13,1);
CreateBut(" 转 帐(5)",15,13,13,1); CreateBut(" 转帐查询(6)", 41,13,13,1);
CreateBut(" 改 密(7)",15,16,13,1); CreateBut(" 余额查询(8)", 41,16,13,1);
OutTxt(25,21,"进入(Y) 退出(E)\n");
HideField();
}
void SelMainFace(int n) //Tab选择主界面功能时,加深边框颜色
{
switch(n)
{
case 1:
CreateBut(" 存 款(1)",15, 7,13,1,BUT_BOR_SEL);
CreateBut(" 余额查询(8)", 41,16,13,1);
break;
case 2:
CreateBut(" 存 款(1)",15, 7,13,1);
CreateBut(" 存款查询(2)", 41, 7,13,1,BUT_BOR_SEL);
break;
case 3:
CreateBut(" 存款查询(2)", 41, 7,13,1);
CreateBut(" 取 款(3)",15,10,13,1,BUT_BOR_SEL);
break;
case 4:
CreateBut(" 取 款(3)",15,10,13,1);
CreateBut(" 取款查询(4)", 41,10,13,1,BUT_BOR_SEL);
break;
case 5:
CreateBut(" 取款查询(4)", 41,10,13,1);
CreateBut(" 转 帐(5)",15,13,13,1,BUT_BOR_SEL);
break;
case 6:
CreateBut(" 转 帐(5)",15,13,13,1);
CreateBut(" 转帐查询(6)", 41,13,13,1,BUT_BOR_SEL);
break;
case 7:
CreateBut(" 转帐查询(6)", 41,13,13,1);
CreateBut(" 改 密(7)",15,16,13,1,BUT_BOR_SEL);
break;
case 8:
CreateBut(" 改 密(7)",15,16,13,1);
CreateBut(" 余额查询(8)", 41,16,13,1,BUT_BOR_SEL);
break;
default:
break;
}
HideField();
}
/*****************存款界面******************/
void SavingFace()
{
CloseCursor();
CreateSmWindow( 0, 0, FRM_WIDTH, FRM_HEIGHT, FRM_BOR_TXT, FRM_BOR_BK, FRM_TXT, FRM_BK,FRM_TITLE,false );
OutTxt(23,2,"欢迎使用武汉市商业银行 ATM 机\n");
OutTxt(15,8,"请输入金额:\n");
OutTxt(57,8,"100 - 1000元整\n");
CreateBox( 27, 7);
OutTxt(22,18,"Y-确认 E-返回\n");
HideField();
}
/*****************取款界面******************/
void PopFace()
{
CloseCursor();
CreateSmWindow( 0, 0, FRM_WIDTH, FRM_HEIGHT, FRM_BOR_TXT, FRM_BOR_BK, FRM_TXT, FRM_BK,FRM_TITLE,false );
OutTxt(23,2,"欢迎使用武汉市商业银行 ATM 机\n");
OutTxt(15,8,"请输入金额:\n");
OutTxt(57,8,"100 - 1000元整\n");
CreateBox( 27, 7);
OutTxt(22,18,"O-确认 E-返回\n");
HideField();
}
/*****************转款界面******************/
void TransferFace()
{
CloseCursor();
CreateSmWindow( 0, 0, FRM_WIDTH, FRM_HEIGHT, FRM_BOR_TXT, FRM_BOR_BK, FRM_TXT, FRM_BK,FRM_TITLE,false );
OutTxt(27,2,"欢迎使用武汉市商业银行 ATM 机\n");
OutTxt(15,8,"请输入帐号:\n");
CreateBox( 27, 7);
OutTxt(57,8,"12位数字账号\n");
OutTxt(15,13,"请输入金额:\n");
CreateBox( 27, 12);
OutTxt(57,13,"100 - 5000元整\n");
OutTxt(22,18,"O-确认 C-清