📄 manager.h
字号:
/************************************************
*本文本包含程序中的所有宏定义,函数原型,全局变量等
*************************************************/
#define CANCEL -1 /*定义cancel为-1时取消*/
/**针对鼠标的宏定义**/
#define ON 1
#define OFF 2
#define LEFT_BUTTON 1
#define RIGHT_BUTTON 2
#define BOTH_BUTTON 3
/*宏定义键盘按键*/
#define MAXBOOKNAMELEN 57 /*(书名的最大长度)其中56个用于装书名*/
#define INSERT 0x5200
#define DELETE 0x5300
#define BACK 8
#define SPACE 32
#define ESC 0x1B
#define UP 0x4800
#define DOWN 0x5000
#define HOME 0x4700
#define END 0x4f00
#define RIGHT 0x4d00
#define LEFT 0x4b00
#define PGUP 0x4900
#define PGDOWN 0x5100
#define ENTER 0x0d
#define C_F 6 /*ctrl+F*/
#define C_X 24
#define C_F4 97
#define C_S 19
#define F1 0x3b00
#define F2 0x3c00
#define F3 0x3d00
#define F4 0x3e00
#define F5 0x3f00
#define F6 0x4000
#define F7 0x4100
#define F8 0x4200
#define F9 0x4300
#define F10 0x4400
#define F11 133
#define F12 134
/**************图书信息结构体定义*******/
struct bookinfo {
int booknum; /* 书号 */
float bookprice; /* 书价 */
char haveCD[2]; /* 是否有光盘 */
char borrow_out[2]; /* 是否借出 */
char bookname[MAXBOOKNAMELEN];/* 书名 */
int data; /*注:现在暂时在头结点中将它作为用户标志位(即一般用户和超级用户)*/
};
/******图书节点结构体定义*************/
struct dnode {
struct bookinfo book;
struct dnode* last;
struct dnode* next;
};
/*****人员名称结构体定义*******/
struct borrowerinfo{
long borrowernum; /*人代号,这里面包含各种信息(8位)*/
char borrower[7]; /*姓名(3 个汉字)*/
char borrowdate[9];/*The data of borrow book*/
int booknum; /*图书代号*/
char bookname[49];/*所借的书的名称*/
int data;
};
/*******结点单元结构体定义*********/
struct personnode{
struct borrowerinfo person;
struct personnode *last;
struct personnode *next;
};
struct commonstr{
char string[80];
struct commonstr* last;
struct commonstr* next;
};
/***定义键盘扫描码数据结构***/
union keycode_type
{
int word;
char byte;
};
/*****说明:上面的结构用来存放一些数据,然后在函数CommonWin中显示,结构的头
指针中用来存放窗口的标题。
******/
/*全局变量*/
extern int have_mouse; /***鼠标是否安装(返回 0未安装, 其它为鼠标键数***/
extern int mx,my;/**鼠标光标坐标(mouse x,mouse y的缩写)***/
extern int allbooknode; /*用Length()求出的图书链表的长度*/
extern int allpersonnode;/*人员链表长度*/
extern int mainwincurx,mainwincury;/*主窗口光标相对位置*/
extern int mainwinx,mainwiny; /*主窗口光标绝对位置,最大为allbooknode*/
extern int mainwinheight;/*主显示窗口的高度*/
extern int mainwinwidth; /*主显示窗口的宽度*/
extern int mainwintopy;
extern int mainwintopx;
extern int personwinx;
extern int personwiny;/*当前光标的绝对坐标,最大为allpersonnode*/
extern int personwintopx; /*人员信息窗口的当前左端坐标*/
extern int personwintopy; /*人员信息窗口的当前顶端坐标*/
extern int personwinheight;/*人员信息窗口的高度*/
extern char* curpath; /*保存当前程序所在路径*/
/*********注意::下面是本程序中出现的所有函数的原型及一般介绍,
它们是以在相对应的文件中出现的顺序为顺序排序
的
**********/
/******************下列函数出现在文件mymouse.c中************************/
int reset_mouse(); /**初始华鼠标**/
void light_mouse(int op); /**显示鼠标 op=1显示,op=2 关闭**/
int get_mouse_status(int *x,int *y); /**获取鼠标当前状态**/
void set_mousexy(int x,int y); /**使鼠标跳到坐标 x,y**/
/***设置鼠标的活动范围( left,top,right,bottom分别为左上角和右下角坐标)**/
void set_mouse_range(int left,int top,int right,int bottom);
/******************下列函数出现在文件operate.c中************************/
/*根据查找并反回该节点或NULL*/
struct dnode* FindBookNodeFromNum(int booknum,struct dnode* bookhead);
/*根据书号找到书并把它删除*/
int DeleteBookFromNum(struct dnode* bookhead,int booknum);
/*根据书号找到书并把它删除*/
int DeleteBookFromNum(struct dnode* bookhead,int booknum);
/**本函数将根据顺序在程序中找到这个结点**/
struct dnode* FindNode(int num,struct dnode* bookhead);
/* 初始化数据结构为双向非循环链表 */
struct dnode* InitList(void);
/* 插入一个新结点(i为插入位置,x为插入的元素) */
int InsertBookNode(int i,struct bookinfo x,struct dnode* bookhead);
/*清除整个链表*/
int ClearBookList(struct dnode* bookhead);
/* 求长度 */
int Length(struct dnode* bookhead);
/* 判断表是否为空 */
int IsEmpty(struct dnode* bookhead);
/* 删除第I个结点 */
int DeleteBookNode(struct dnode* bookhead,int i);
/* 删除图书界面 */
void DeleteBookWin(struct dnode* bookhead);
/** 函数用于求出数据的插入位置*/
int InsertPlaceofBook(int num,struct dnode* bookhead);
/** 判断输入的书号是否有重复(返回1为有重复,0为无重复)*/
int IsBookSame(int num,struct dnode* bookhead);
/* 存储线性表 */
void SaveList(struct dnode* bookhead,char* filename);
/* 加载表格 */
struct dnode* LoadList(char *filename);
/*************以下函数出现在文件input.c中*************/
/****函数get_key(void)用于读取键盘按按钮****/
int get_key(void);
/**本函数专用于输入书号,返回所输入的号码**/
int InputBookNum();
/**本程序专用于输入书价,返回所输入的价格**/
float InputBookPrice();
/**input Yes or No,返回Y或者N**/
char *InputYesorNo();
/**本程序专门用于输入书名,返回书名字符串**/
char* InputBookName();
/**************以下函数出现在文件define.c中**********/
/* 函数putchinese()用于在图形格式下输出显示汉字,汉字上下两部分的颜色不一样
x,y为汉字的显示坐标,width,height为汉字字模的点阵高度,
color为汉字的颜色,add为汉字点阵的存放地址
*/
void putchinese(int x,int y,int width,int height,int color,unsigned char* add);
/***此函数也是用于图形模式下显示汉字,但显示的是单一颜色的汉字*/
/*依次:字模指针地址、点阵大小、起始坐标(x,y)、颜色*/
void drawmat(char *mat,int matsize,int x,int y,int color);
/* 串比较,如果两字符串相等就返回1,不相等返回0 */
int strcamp(char *str1,char *str2);
/* 显示登录画面 */
struct dnode* showfirst(struct dnode* bookhead);
/*****本程序专门用于输入登录密码***/
char* InputPassword();
/******************下列函数出现在文件winoperate.c中***************/
/**上翻页键**/
void keypgup(struct dnode* bookhead);
/**下翻页键**/
void keypgdown(struct dnode* bookhead);
/**对上箭头光标进行控制**/
void keyup(struct dnode* bookhead);
/**对下箭头光标进行控制**/
void keydown(struct dnode* bookhead);
/****对光标的左右键进行控制*******/
void keyright(void);
void keyleft(void);
/***本函数用于在程序主窗口中显示一行文本***/
void ShowMainWinLine(int x,int y,int line,struct dnode* bookhead);
/**用于显示一屏幕文本**/
void ShowMainWinaScreen(struct dnode* bookhead,int startline);
/**************以下函数出现在文件person.c中*********************/
/**本函数将根据顺序在程序中找到这个结点**/
struct personnode* FindBorrowerNodeOrder(int linenum,struct personnode* personhead);
/* 插入一个新结点(i为插入位置,x为插入的元素,personhead为欲插入的链表 */
int InsertPersonNode(int i,struct borrowerinfo x,struct personnode* personhead);
/***删除第I个结点**/
int DeletePersonNode(struct personnode* perosnhead,int i);
/*删除人员号码personnum所指向的节点*/
int DeletePerson(struct personnode* personhead,long personnum);
/*删除链表personhead中的personnode号节点*/
int DeletePersonFromNode(struct personnode* personhead,struct personnode* personnode);
/*清除人员链表***/
int ClearBorrowerList(struct personnode* personhead);
/* 求长度 */
int LengthofPersonList(struct personnode* personhead);
/* 判断表是否为空 */
int IsEmptyPersonList(struct personnode* personhead);
/**本函数将根据书号在程序中找到这个结点**/
struct personnode* FindBorrowerNode(long personnum,struct personnode* personhead);
/***本函数专用于输入借阅号****/
long InputBorrowerNum();
/**输入借书人的姓名***/
char* InputBorrowerName();
/*** 函数用于求出数据的插入位置*/
int InsertPlaceofBorrower(long num,struct personnode* personhead);
/**获取当前的日期**/
char* getnowdate(void);
/*得到当前日期:中文的年月日*/
char* getdates(void);
/***返回借书超过的日期**/
int beyondday(char *olddate,struct dnode* bookhead);
/***人员信息输入窗口**/
int InputPersonNode(struct personnode* personhead);
/*求出一个人的总借书数量*/
int BorrowBookCount(long personnum,struct personnode* personhead,struct dnode* bookhead);
/***借书窗口***/
void BorrowBookWin(long personnum,struct personnode* personhead,struct dnode* bookhead);
/****还书窗口***/
void ReturnBookWin(struct personnode* personhead,struct dnode* bookhead);
/*输出指定成员的借书信息*/
void PrintBorrowerNode(long personnum,struct personnode* personhead,struct dnode* bookhead);
/*根据借书者的号码查找借书者在链表中的位置,如果找到返回一个大于0的数,否则返回0*/
int FindBorrower(long personnum,struct personnode* personhead);
/*根据书号找到借阅者的号码*/
struct personnode* FindBorrowerFromBookNum(int booknum,struct personnode* personhead);
/*启动借书功能后,开始执行此函数*/
int StartBorrowBook(struct personnode* personhead,struct dnode* bookhead);
/* 在屏幕上显示一条提示信息:依次为两个坐标和要显示的信息 */
int MessageBox(int col,int row,char *info);
/***对人员窗口上箭头光标进行控制**/
void keypersonup(struct personnode* personhead,struct dnode* bookhead);
/**对下箭头光标进行控制**/
void keypersondown(struct personnode* personhead,struct dnode* bookhead);
/****对光标的左右键进行控制*******/
void keypersonright(void);
void keypersonleft(void);
/***上下翻页键****/
void keypersonpgup(struct personnode* personhead,struct dnode* bookhead);
void keypersonpgdown(struct personnode* personhead,struct dnode* bookhead);
/****人员信息窗口(主窗口)*****/
void borrowerinfoWin(struct personnode* personhead,struct dnode* bookhead);
/***本函数用于在人员信息窗口中显示一行文本*****/
int ShowPersonWinaLine(int x,int y,int line,struct personnode* personhead,
struct dnode* bookhead,struct personnode* curnode);
/**用于显示一屏幕文字***/
int ShowPersonWinaScreen(struct personnode* personhead,struct dnode* bookhead,
int startline);
/****删除人员窗口****/
int DeletePersonWin(struct personnode* personhead,struct dnode* bookhead);
/***初始化人员信息节点*****/
struct personnode* InitPersonList(void);
/* 存储人员信息线性表 */
int SavePersonList(struct personnode* personhead,char* filename);
/* 加载人员信息线性表 */
struct personnode* LoadPersonList(char *filename);
/***************以下函数出现在文件common.c中**************/
/* 将gettext()函数取得的内容重新显示到屏幕上*/
void myputtext(int left,int top,int right,int button,char* block);
/* 插入一个新结点 */
int InsertCommonNode(int i,char* x,struct commonstr* head);
/* 定义数据结构为双向非循环链表 */
struct commonstr* InitCommonList(void);
/*清除整个链表*/
int ClearCommonList(struct commonstr* head);
/* 求长度 */
int LengthCommonList(struct commonstr* head);
/***查找节点并返回此节点***/
struct commonstr* FindCommonNode(int linenum,struct commonstr* head);
/*显示一行*/
void ShowCommonWinaLine(int x,int y,int linenum,struct commonstr* head);
/*显示一屏*/
void ShowCommonWinaScreen(struct commonstr* head,int startline,int textline);
/**上下左右键**/
int keycommonwinup(int* winy,int* wintopy,int* winheight,struct commonstr* head);
int keycommonwindown(int* winy,int* wintopy,int* winheight,struct commonstr* head);
int keycommonwinleft(int* winx,int* wintopx,int* winwidth);
int keycommonwinright(int* winx,int* wintopx,int* winwidth);
/**上翻页键**/
int keycommonpgup(int* winy,int* wintopy,int* winheight,struct commonstr* head);
/**下翻页键**/
int keycommonpgdown(int* winy,int* wintopy,int*winheight,struct commonstr* head);
struct commonstr* FindPersonInfo(long personnum,struct personnode* personhead,
struct dnode* bookhead);
/*用于显示head链表中的内容,窗口标题放在head的头结点中*/
void CommonWin(struct commonstr* head);
/***根据书是否被借出来查找书<当YN为Y时,查看借出去的书,为N时查看没有被借出去的书***/
struct commonstr* SearchBookYN(struct dnode* bookhead,char YN);
/**根据是否超期查找借书的人**/
struct commonstr* SearchPersonBeyond(struct personnode* personhead,struct dnode* bookhead);
/***查找书链表中的书名中有string关键字的书的节点***/
struct commonstr* SearchBookName(struct dnode* bookhead,char* string);
/*****本程序专门用于输入查找的关键书名****/
char* InputSearchName();
/**选择查找命令后第一个出现的窗口**/
int FindWindow(struct dnode* bookhead,struct personnode* personhead);
/**帮助信息**/
struct commonstr* HelpInfo();
/******************下列函数出现在文件face.c中***************************/
void windows(struct dnode* bookhead);/******此函数用来显示程序主界面****/
/*******************下列函数出现在文件passwin.c中***********************/
/****改变借书数量****/
int ChangeBorrowCount(struct dnode* bookhead,struct personnode* personhead);
int ChangePassWin(struct dnode* head);/*用于修改密码*/
int ChangeDays(struct dnode* head); /*用于修改最长的借书时间*/
/*******scroll.c****/
/*窗口滚屏(左上角,右下角,向上或向下(0,1),背景颜色)*/
void scroll(int left,int top,int right,int bottom,int status,int bkcolor);
#include "mymouse.c"
#include "operate.c"
#include "input.c"
#include "define.c"
#include "winoprat.c"
#include "person.c"
#include "common.c"
#include "face.c"
#include "passwin.c"
#include "scroll.c"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -