小学期的数据结构课设,开题想做一个备忘录,奈何找不到什么参考,就和队友自己写啦,本着世界知识无产者联合起来的宗旨,分享给大家。
小学期课设多比较忙,就做的很潦草,加之本身水平就很低,就是希望大家再碰到类似的项目的时候,有所参考吧。
目前该程序还存在着包含下述的问题,因为课设验收完成了也就不想继续完善了。
(1)每天只能有一个待办事项
(2)日期是从char型转换成float型,原理上存在问题,比如7日期.22要比7.3大,float型相反(ps:当时验收完才发现这个重大错误,还好是过了)
废话不多说了,完整代码如下:
注意运行源码需要安装easyX库,GUI界面是基于easyX库做的,然后背景图片需要放在源码同一路径下,还需要提前在源码同一路径下创建一个data.txt文本文件噢
背景图片如下:
运行效果如下:
代码太长的原因主要是和队友合作,cmd部分的和最终版都在一起,没有进行整理和删改
define _CRT_SECURE_NO_WARNINGS
#include
#include
#include
#include
#include
#include
#define InitValue 522 //宏定义一个初始值防止静态变量默认0使菜单退出
int flag = InitValue; //静态变量作为功能按键
int Number_of_Things = 0; //静态变量,记录目前待办事件数量
int CNumber_of_Things = 0; //静态变量,记录某一类待办事件的数量
FILE* FilePathTemp; //保存文件所用的全局文件流指针变量
typedef struct SchedulelTreeNode { //待办事项的树的结构体定义
char Classname[10];
char Time[20];
char Location[50];
char Describe[200];
struct SchedulelTreeNode* lch;
struct SchedulelTreeNode* rch;
}SchedulelTreeNode, * SchedulelTree;
/功能实现
void ShowMenu(SchedulelTree* T); //菜单显示函数,负责循环判断flag,并把树的指针传进去,方便后续不同的功能的操作
void initial(void); //初始化函数,显示欢迎界面
void AddScheduleTree(SchedulelTree* T); //添加待办事项
void Delete(SchedulelTree* T);
void DeleteScheduleTree(SchedulelTree* T, char* Time); //删除待办事项
SchedulelTreeNode* FindParent(SchedulelTree T, SchedulelTreeNode* child); //服务于删除函数
bool Search(SchedulelTree T, char* Time, SchedulelTree f, SchedulelTree* p); //查找成功时,p指向值为Time的节点。如果查找失败,则p指向遍历的最后一个节点
void initialScheduleTree(SchedulelTree* T); //从txt文件中读取数据并创建待办事件树
int ShowScheduleTree(SchedulelTree T); //显示事件树
int ShowScheduleTree_core(SchedulelTree T); //显示事件树函数的内核
int ShowScheduleTree_Class(SchedulelTree T); //显示某个类别的所有事件
int ShowScheduleTree_Class_core(SchedulelTree T, char* Classname);
//是显示某个类别所有事件函数的内核
int SearchSchedudle(SchedulelTree T); //查询函数,用来查询某一天的待办事项
int SearchSchedudle_core(SchedulelTree T, char* Time); //查询函数内核
void AmendSchedule_Describe(SchedulelTree T); //用来修改某一待办事件的内容
int AmendSchedule_Describe_core(SchedulelTree T, char* Time);
//修改某一待办事件的内核
int SaveData(SchedulelTree T); //用于保存事件树到txt文件
int LeaveSystem(SchedulelTree T); //注意离开函数嵌套了保存数据函数,两者要配合使用
void change(const char* s); //弹出界面函数
void Window_ShowScheduleTree_updown(SchedulelTree T);
int Window_ShowScheduleTree(SchedulelTree T);
void ShowMenu(SchedulelTree* T)
{
printf("下面进入功能菜单:\n");
while (flag)
{
printf("--------------------------------功能菜单--------------------------------\n");
printf("1:添加待办事项\n");
printf("2:删除待办事项\n");
printf("3:显示一类待办事项\n");
printf("4:显示所有待办事项\n");
printf("5:查询待办事项\n");
printf("6:修改事项内容\n");
printf("0:离开系统\n");
printf("请选择您需要的功能:");
scanf("%d", &flag);
getchar();
switch (flag)
{
case 0:
break;
case 1:
{
AddScheduleTree(T);
break;
}
case 2:
{
Delete(T);
break;
}
case 3:
{
ShowScheduleTree_Class(*T);
break;
}
case 4:
{
ShowScheduleTree(*T);
break;
}
case 5:
{
SearchSchedudle(*T);
break;
}
case 6:
{
AmendSchedule_Describe(*T);
break;
}
default:
printf("\n!输入无效,请重新输入!\n\n");
}
}
}
int ShowScheduleTree(SchedulelTree T)
{
Number_of_Things = 0;
ShowScheduleTree_core(T);
if (Number_of_Things)
printf("----------------------以上是所有您需要做的 %d 件事情----------------------\n\n", Number_of_Things);
else
printf("\n-------------------------您已经完成了所有的待办事项!-------------------------\n\n");
return 0;
}
int ShowScheduleTree_core(SchedulelTree T)
{
if (T == NULL)
{
return 0;
}
ShowScheduleTree_core(T->lch);
printf("\n");
printf("事件属性: ");
printf("%s\n", T->Classname);
printf("时间: ");
printf("%s\n", T->Time);
printf("地点: ");
printf("%s\n", T->Location);
printf("详情: ");
printf("%s\n", T->Describe);
printf("\n");
Number_of_Things++;
ShowScheduleTree_core(T->rch);
}
int ShowScheduleTree_Class(SchedulelTree T)
{
char option;
char Classname[10];
printf("\n请输入您要显示待办事项的类别: A. 工作类 B. 生活类 C. 学习类\n");
while (1)
{
scanf("%c", &option);
getchar();
if (option == 'A' || option == 'a')
{
strcpy(Classname, "工作类");
break;
}
else if (option == 'B' || option == 'b')
{
strcpy(Classname, "生活类");
break;
}
else if (option == 'C' || option == 'c')
{
strcpy(Classname, "学习类");
break;
}
else
printf("选项输入错误,请重新输入:");
}
CNumber_of_Things = 0;
printf("-------------------------------------------------------------------------------------\n");
ShowScheduleTree_Class_core(T, Classname);
printf("-------------------------以上就是属于 %s 的 %d 件待办事项-------------------------\n", Classname, CNumber_of_Things);
return 0;
}
int ShowScheduleTree_Class_core(SchedulelTree T, char* Classname)
{
if (T == NULL)
{
return 0;
}
ShowScheduleTree_Class_core(T->lch, Classname);
if (!strcmp(Classname, T->Classname))
{
printf("事件属性: ");
printf("%s\n", T->Classname);
printf("时间: ");
printf("%s\n", T->Time);
printf("地点: ");
printf("%s\n", T->Location);
printf("详情: ");
printf("%s\n", T->Describe);
printf("\n");
CNumber_of_Things++;
}
ShowScheduleTree_Class_core(T->rch, Classname);
}
void initial(void)
{
printf("***************************欢迎来到备忘录系统!***************************\n");
printf("您目前需要做的事情有:\n");
}
void initialScheduleTree(SchedulelTree* T)
{
int i = 0;
FILE* FilePath; //文件指针
char data[200]; //替换所需的字符串数组
FilePath = fopen("data.txt", "r");
(*T) = (SchedulelTree)malloc(sizeof(SchedulelTreeNode)); //动态分配空间
if (FilePath == NULL)
{
printf("读取数据异常!");
exit(0);
}
while (1)
{
if (EOF == fscanf(FilePath, "%s", data))
{
*T = NULL;
break;
}
else
{
switch (i % 4)
{
case 0:
{
strcpy((*T)->Classname, data);
break;
}
case 1:
{
strcpy((*T)->Time, data);
break;
}
case 2:
{
strcpy((*T)->Location, data);
break;
}
case 3:
{
strcpy((*T)->Describe, data);
(*T)->lch = NULL; //默认初始化的事件树的左子树为空
T = &((*(T))->rch);
(*T) = (SchedulelTree)malloc(sizeof(SchedulelTreeNode)); //动态分配空间
break;
}
}
i++;
}
}
fclose(FilePath);
}
int SearchSchedudle(SchedulelTree T)
{
printf("请输入要查询的日期(如7月10日,输入7.10):");
char Time[20];
scanf("%s", &Time);
getchar();
SearchSchedudle_core(T, Time);
return 0;
}
int SearchSchedudle_core(SchedulelTree T, char* Time)
{
if (T == NULL)
{
printf("\n");
printf("当天您没有待办事项\n");
printf("\n");
return 0;
}
if (!strcmp(T->Time, Time))
{
printf("查询到了您要找的事项:\n");
printf("\n");
printf("-----------------------------------------------\n");
printf(" | 事件属性: ");
printf("%s\n", T->Classname);
printf(" | 时间: ");
printf("%s\n", T->Time);
printf(" | 地点: ");
printf("%s\n", T->Location);
printf(" | 详情: ");
printf("%s\n", T->Describe);
printf("\n");
printf("-----------------------------------------------\n");
printf("\n");
return 0;
}
if (strcmp(T->Time, Time) > 0)
{
SearchSchedudle_core(T->lch, Time);
}
if (strcmp(T->Time, Time) < 0)
{
SearchSchedudle_core(T->rch, Time);
}
}
void Delete(SchedulelTree* T)
{
char Time[20];
printf("请输入要删除的日期(如7月9日,输入7.9):");
scanf("%s", &Time);
getchar();
DeleteScheduleTree(T, Time);
}
void DeleteScheduleTree(SchedulelTree* T, char* Time)
{
if (NULL == *T)
{
printf("\n\n删除错误!\n\n");
return; //空树直接报错
}
SchedulelTreeNode* p;
SchedulelTreeNode* f = NULL;
SchedulelTreeNode* q, * s;
if (Search(*T, Time, NULL, &p)) //确实存在值为key的节点,则p指向该节点
{
if (NULL == p->lch && NULL != p->rch) //无左孩子,有右孩子
{
q = p->rch;
strcpy(p->Time, q->Time);
strcpy(p->Location, q->Location);
strcpy(p->Describe, q->Describe);
//因为两个节点之间本质的不同在于数据域的不同,而与放在哪个地址没有关系
p->rch = q->rch;
p->lch = q->lch;
free(q);
}
else if (NULL == p->rch && NULL != p->lch) //无右孩子,有左孩子
{
q = p->lch;
strcpy(p->Time, q->Time);
strcpy(p->Location, q->Location);
strcpy(p->Describe, q->Describe);
p->rch = q->rch;
p->lch = q->lch;
free(q);
}
else if (NULL != p->rch && NULL != p->lch) //既有左孩子,又有右孩子
{
q = p;
s = p->lch; //找左孩子的最右孩子
while (s->rch)
{
q = s;
s = s->rch;
}
strcpy(p->Time, s->Time);
strcpy(p->Location, s->Location);
strcpy(p->Describe, s->Describe);
if (q != p)
{
q->rch = s->lch;
}
else
{
q->lch = s->lch;
}
free(s);
}
else
{
if (*T == p) //只有一个根节点
{
free(*T);
*T = NULL;
return;
}
SchedulelTreeNode* parent = FindParent(*T, p);
if (parent->lch == p)
{
parent->lch = NULL;
}
else
{
parent->rch = NULL;
}
free(p);
}
printf("\n\n删除成功!\n\n");
}
return;
}
bool Search(SchedulelTree T, char* Time, SchedulelTree f, SchedulelTree* p) //查找成功时,p指向值为Time的节点。如果查找失败,则p指向遍历的最后一个节点
{
if (!T)
{
*p = f;
//printf("\n\n没有该日期的待办事项!\n\n");
change("没有该日期的待办事项!");
return false;
}
if (!strcmp(T->Time, Time)) //查找成功,直接返回
{
*p = T;
change("删除成功!");
return true;
}
else if (strcmp(T->Time, Time) < 0)
{
return Search(T->rch, Time, T, p);
}
return Search(T->lch, Time, T, p);
}
SchedulelTreeNode* FindParent(SchedulelTree T, SchedulelTreeNode* child)
{
if (NULL == T)
{
return NULL;
}
if (T->lch->Time == child->Time || T->rch->Time == child->Time)
{
return T;
}
if (NULL != T->rch)
{
return FindParent(T->rch, child);
}
if (NULL != T->lch)
{
return FindParent(T->lch, child);
}
}
void AddScheduleTree(SchedulelTree* T)
{
printf("\n--------------------正在进行数据写入--------------------\n\n");
char classname[10], time[20], location[50], describe[100];
char data[200];
char option;
//类别输入
printf("请选择类别:A.工作类 B.生活类 C.学习类\n");
while (1)
{
scanf("%c", &option);
getchar();
if (option == 'A' || option == 'a')
{
strcpy(classname, "工作类");
break;
}
else if (option == 'B' || option == 'b')
{
strcpy(classname, "生活类");
break;
}
else if (option == 'C' || option == 'c')
{
strcpy(classname, "学习类");
break;
}
else
printf("选项输入错误,请重新输入:");
}
//日期输入
printf("请输入时间(如6月21日请输入6.21):");
scanf("%s", &time[0]);
getchar();
//地点输入
printf("请输入地点:");
scanf("%s", &location[0]);
getchar();
//事件输入
printf("请输入事件内容:");
scanf("%s", &describe[0]);
getchar();
SchedulelTreeNode* parent = (SchedulelTreeNode*)malloc(sizeof(SchedulelTreeNode)); //表示双亲结点;
SchedulelTreeNode* head = *T;
SchedulelTreeNode* p = (SchedulelTreeNode*)malloc(sizeof(SchedulelTreeNode));
strcpy(p->Classname, classname);
strcpy(p->Time, time);
strcpy(p->Location, location);
strcpy(p->Describe, describe); //保存结点数据;
p->lch = p->rch = NULL; //左右子树置空;
//查找需要添加的父结点,这个父结点是度为0的结点;
if (*T)
{
while (head)
{
parent = head;
if ((strcmp(time, head->Time)) == -1) //若关键字小于结点的数据;
head = head->lch; //在左子树上查找;
else //若关键字大于结点的数据;
head = head->rch; //在右子树上查找;
}
//判断添加到左子树还是右子树;
if (strcmp(time, parent->Time) == -1) //小于父结点;
parent->lch = p; //添加到左子树;
else //大于父结点;
parent->rch = p; //添加到右子树;
}
else
{
*T = p;
}
printf("\n--------------------数据写入成功--------------------\n\n");
}
void AmendSchedule_Describe(SchedulelTree T)
{
int AmendFlag = 0;
char Time[20];
printf("请先输入要修改待办事件的日期以查找事件(如7月9号,请输入7.9):");
scanf("%s", &Time);
getchar();
AmendFlag = AmendSchedule_Describe_core(T, Time);
if (!AmendFlag)
{
printf("修改失败!\n");
}
}
int AmendSchedule_Describe_core(SchedulelTree T, char* Time)
{
if (T == NULL)
{
printf("\n");
printf("当天您没有待办事项\n");
printf("\n");
return 0;
}
if (!strcmp(T->Time, Time))
{
printf("查询到了您要找的事项:\n");
printf("\n");
printf("-----------------------------------------------\n");
printf(" | 事件属性: ");
printf("%s\n", T->Classname);
printf(" | 时间: ");
printf("%s\n", T->Time);
printf(" | 地点: ");
printf("%s\n", T->Location);
printf(" | 详情: ");
printf("%s\n", T->Describe);
printf("\n");
printf("-----------------------------------------------\n");
printf("\n");
printf("请选择要修改的属性: A.事件属性 B. 地点 C. 详情\n");
char data[200];
char option;
char option1;
while (1)
{
scanf("%c", &option);
getchar();
if (option == 'A' || option == 'a')
{
printf("请选择新的事件属性:A.工作类 B.生活类 C.学习类\n");
while (1)
{
scanf("%c", &option1);
getchar();
if (option1 == 'A' || option1 == 'a')
{
strcpy(data, "工作类");
strcpy(T->Classname, data);
break;
}
else if (option1 == 'B' || option1 == 'b')
{
strcpy(data, "生活类");
strcpy(T->Classname, data);
break;
}
else if (option1 == 'C' || option1 == 'c')
{
strcpy(data, "学习类");
strcpy(T->Classname, data);
break;
}
else
printf("选项输入错误,请重新输入:");
}
break;
}
else if (option == 'B' || option == 'b')
{
printf("请输入新的地点:");
scanf("%s", &data);
getchar();
strcpy(T->Location, data);
break;
}
else if (option == 'C' || option == 'c')
{
printf("请输入新的描述:");
scanf("%s", &data);
getchar();
strcpy(T->Describe, data);
break;
}
else
printf("选项输入错误,请重新输入:");
}
printf("\n修改成功!\n");
printf("-----------------------------------------------\n");
printf(" | 事件属性: ");
printf("%s\n", T->Classname);
printf(" | 时间: ");
printf("%s\n", T->Time);
printf(" | 地点: ");
printf("%s\n", T->Location);
printf(" | 详情: ");
printf("%s\n", T->Describe);
printf("\n");
printf("-----------------------------------------------\n");
return 1;
}
if (strcmp(T->Time, Time) > 0)
{
AmendSchedule_Describe_core(T->lch, Time);
}
if (strcmp(T->Time, Time) < 0)
{
AmendSchedule_Describe_core(T->rch, Time);
}
}
int SaveData(SchedulelTree T)
{
FilePathTemp = fopen("data.txt", "a");
if (T == NULL) //迭代出口
{
return 0;
}
char data[200]; //写入文件所需的字符串数组
SaveData(T->lch); //平衡二叉树,先写入左节点
//写完左节点之后再写入自身节点
strcpy(data, T->Classname); //写入类别
fprintf(FilePathTemp, "%s", data);
fprintf(FilePathTemp, "\n");
strcpy(data, T->Time); //写入时间
fprintf(FilePathTemp, "%s", data);
fprintf(FilePathTemp, "\n");
strcpy(data, T->Location); //写入地点
fprintf(FilePathTemp, "%s", data);
fprintf(FilePathTemp, "\n");
strcpy(data, T->Describe); //写入描述
fprintf(FilePathTemp, "%s", data);
fprintf(FilePathTemp, "\n");
//写完左节点和自身节点之后再写入右节点
SaveData(T->rch);
}
int LeaveSystem(SchedulelTree T)
{
remove("data.txt"); //删除之前的文件
SaveData(T); //保存在新文件
printf("\n\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^数据保存完成^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");
printf("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^成功离开系统^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");
return 0;
}
///GUI功能实现
int Window_AddScheduleTree(SchedulelTree* T);
void Window_Delete(SchedulelTree* T);
void Window_DeleteScheduleTree(SchedulelTree* T, char* Time);
int Window_ShowScheduleTreecore(SchedulelTree T);
int Window_ShowScheduleTree(SchedulelTree T);
int Window_SearchSchedudle(SchedulelTree T); //查询函数,用来查询某一天的待办事项
int Window_SearchSchedudle_core(SchedulelTree T, char* Time); //查询函数内核
void Window_AmendSchedule_Describe(SchedulelTree T); //用来修改某一待办事件的内容
int Window_AmendSchedule_Describe_core(SchedulelTree T, char* Time);
int Window_ShowScheduleTree_Class(SchedulelTree T); //显示某个类别的所有事件
int Window_ShowScheduleTree_Class_core(SchedulelTree T, char* Classname);
void change(const char* s);
int AmendFlag = 0;
void change(const char* s)
{
//获得窗口句柄
HWND hnd = GetHWnd();
//弹出窗口,提示
MessageBox(hnd, s, "提示", MB_OKCANCEL);
}
int Close_window()
{
ExMessage msg;
if (peekmessage(&msg, EM_MOUSE))
{
if (msg.message == WM_LBUTTONDOWN)
if (msg.x >= 30 && msg.x <= 30 + 200 && msg.y >= 360 && msg.y <= 360 + 50)
{
closegraph();
}
}
return 0;
}
void Text_buttoncore(int x, int y, int high, int wide, const char arr[])
{
settextcolor(BLACK); //设置字体颜色
setbkmode(TRANSPARENT); //设置字体背景
settextstyle(25, 0, "微软雅黑"); //设置字体样式、大小
setlinecolor(BLACK);
setfillcolor(RGB(255, 174, 200));//粉色
fillroundrect(x, y, x + high, y + wide, 10, 10);
int width = high / 2 - textwidth(arr) / 2;
int height = wide / 2 - textheight(arr) / 2;
outtextxy(width + x, height + y, arr);
}
void Text_button()
{
IMAGE img;
loadimage(&img, "./bk.jpg", 1200, 600);
putimage(300, 0, &img);
setlinecolor(BLACK);
setlinestyle(0, 2);
line(300, 0, 300, 600);
line(860, 0, 860, 600);
settextcolor(BLACK); //设置字体颜色
setbkmode(TRANSPARENT); //设置字体背景
settextstyle(25, 0, "微软雅黑"); //设置字体样式、大小
setfillcolor(RGB(255, 174, 200));
fillellipse(85, 10, 170, 60);
outtextxy(92.5, 20, "功能菜单\n");
Text_buttoncore(30, 80, 200, 50, "添加待办事项");
Text_buttoncore(30, 150, 200, 50, "删除待办事项");
Text_buttoncore(30, 220, 200, 50, "显示一类待办事项");
Text_buttoncore(30, 290, 200, 50, "显示所有待办事项");
Text_buttoncore(30, 360, 200, 50, "查询待办事项");
Text_buttoncore(30, 430, 200, 50, "修改事项内容");
Text_buttoncore(30, 500, 200, 50, "离开系统");
}
void Create_window(int x, int y)
{
initgraph(x, y); //界面创建
setbkcolor(WHITE); //设置背景颜色
setbkmode(TRANSPARENT);
cleardevice();
}
void Image_bk() //输出图片
{
IMAGE img; //定义变量
loadimage(&img, "./bk.jpg");
putimage(0, 0, &img);
}
// 实现文本框控件
class EasyTextBox
{
private:
int left = 0, top = 0, right = 0, bottom = 0; // 控件坐标
char* text = NULL; // 控件内容
size_t maxlen = 0; // 文本框最大内容长度
public:
void Create(int x1, int y1, int x2, int y2, int max)
{
maxlen = max;
text = new char[maxlen];
text[0] = 0;
left = x1, top = y1, right = x2, bottom = y2;
// 绘制用户界面
Show();
}
char* Text()
{
return text;
}
bool Check(int x, int y)
{
return (left <= x && x <= right && top <= y && y <= bottom);
}
// 绘制界面
void Show()
{
// 备份环境值
int oldlinecolor = getlinecolor();
int oldbkcolor = getbkcolor();
int oldfillcolor = getfillcolor();
setlinecolor(LIGHTGRAY); // 设置画线颜色
setbkcolor(0xeeeeee); // 设置背景颜色
setfillcolor(0xeeeeee); // 设置填充颜色
fillrectangle(left, top, right, bottom);
outtextxy(left + 10, top + 5, text);
// 恢复环境值
setlinecolor(oldlinecolor);
setbkcolor(oldbkcolor);
setfillcolor(oldfillcolor);
}
void OnMessage()
{
// 备份环境值
int oldlinecolor = getlinecolor();
int oldbkcolor = getbkcolor();
int oldfillcolor = getfillcolor();
setlinecolor(BLACK); // 设置画线颜色
setbkcolor(WHITE); // 设置背景颜色
setfillcolor(WHITE); // 设置填充颜色
fillrectangle(left, top, right, bottom);
outtextxy(left + 10, top + 5, text);
int width = textwidth(text); // 字符串总宽度
int counter = 0; // 光标闪烁计数器
bool binput = true; // 是否输入中
ExMessage msg;
while (binput)
{
while (binput && peekmessage(&msg, EM_MOUSE | EM_CHAR, false)) // 获取消息,但不从消息队列拿出
{
if (msg.message == WM_LBUTTONDOWN)
{
// 如果鼠标点击文本框外面,结束文本输入
if (msg.x < left || msg.x > right || msg.y < top || msg.y > bottom)
{
binput = false;
break;
}
}
else if (msg.message == WM_CHAR)
{
size_t len = strlen(text);
switch (msg.ch)
{
case '\b': // 用户按退格键,删掉一个字符
if (len > 0)
{
text[len - 1] = 0;
width = textwidth(text);
counter = 0;
clearrectangle(left + 10 + width, top + 1, right - 1, bottom - 1);
}
break;
case '\r': // 用户按回车键,结束文本输入
case '\n':
binput = false;
break;
default: // 用户按其它键,接受文本输入
if (len < maxlen - 1)
{
text[len++] = msg.ch;
text[len] = 0;
clearrectangle(left + 10 + width + 1, top + 3, left + 10 + width + 1, bottom - 3); // 清除画的光标
width = textwidth(text); // 重新计算文本框宽度
counter = 0;
outtextxy(left + 10, top + 5, text); // 输出新的字符串
}
}
}
peekmessage(NULL, EM_MOUSE | EM_CHAR); // 从消息队列抛弃刚刚处理过的一个消息
}
// 绘制光标(光标闪烁周期为 20ms * 32)
counter = (counter + 1) % 32;
if (counter < 16)
line(left + 10 + width + 1, top + 3, left + 10 + width + 1, bottom - 3); // 画光标
else
clearrectangle(left + 10 + width + 1, top + 3, left + 10 + width + 1, bottom - 3); // 擦光标
// 延时 20ms
Sleep(20);
}
clearrectangle(left + 10 + width + 1, top + 3, left + 10 + width + 1, bottom - 3); // 擦光标
// 恢复环境值
setlinecolor(oldlinecolor);
setbkcolor(oldbkcolor);
setfillcolor(oldfillcolor);
Show();
}
};
// 定义控件
EasyTextBox Add_txtClass;
EasyTextBox Add_txtTime;
EasyTextBox Add_txtPlace;
EasyTextBox Add_txtDescribe;
EasyTextBox Delete_txtTime;
EasyTextBox Search_txtTime;
EasyTextBox Amend_txtTime;
EasyTextBox Amend_txtPlace;
EasyTextBox Amend_txtDescribe;
#define Arrow_x 330 //宏定义一下上下移动箭头的坐标
#define Arrow_y 300
int Y_Dis = 30;
//上下移动箭头
void Draw_up_arrows(int x, int y)//下箭头的起点坐标为x,y
{
POINT pts1[] = { {340,300},{390,300},{365,330} };
POINT pts2[] = { {340,280},{390,280},{365,250} };
setfillcolor(RGB(255, 174, 200));
setpolyfillmode(0);
fillpolygon(pts1, 3);
fillpolygon(pts2, 3);
}
//实现可上下移动的显示
void Window_ShowScheduleTree_updown(SchedulelTree T)
{
Y_Dis = 30;
Draw_up_arrows(Arrow_x, Arrow_y);
Text_buttoncore(1000, 10, 130, 30, "下一步");
Window_ShowScheduleTree(T);
ExMessage msg;
int a = 1; //判断写入循环
while (a)
{
msg = getmessage(EM_MOUSE); // 获取消息输入
if (msg.message == WM_LBUTTONDOWN)
{
// 向上移动
if (msg.x >= 340 && msg.x <= 390 && msg.y >= 300 && msg.y <= 330)
{
Y_Dis = Y_Dis - 30;
BeginBatchDraw();
cleardevice();
Text_button();
Draw_up_arrows(Arrow_x, Arrow_y);
Text_buttoncore(1000, 10, 130, 30, "下一步");
Window_ShowScheduleTree(T);
EndBatchDraw();
}
// 向下移动
else if (msg.x >= 340 && msg.x <= 390 && msg.y >= 250 && msg.y <= 280)
{
Y_Dis = Y_Dis + 30;
BeginBatchDraw();
cleardevice();
Text_button();
Draw_up_arrows(Arrow_x, Arrow_y);
Text_buttoncore(1000, 10, 130, 30, "下一步");
Window_ShowScheduleTree(T);
EndBatchDraw();
}
else if (msg.x <= 320 || msg.x >= 850)
{
BeginBatchDraw();
cleardevice();
Text_button();
EndBatchDraw();
return;
}
}
}
}
//显示功能主函数
int Window_ShowScheduleTree(SchedulelTree T)
{
Window_ShowScheduleTreecore(T);
if (Number_of_Things)
outtextxy(400, Y_Dis, "--------以上是所有您需要做的事情-----------\n");
else
outtextxy(400, Y_Dis, "----------您已经完成了所有的待办事项!-----------\n");
Y_Dis = Y_Dis - 120 * Number_of_Things;
Number_of_Things = 0;
return 0;
}
//显示功能核心
int Window_ShowScheduleTreecore(SchedulelTree T)
{
if (T == NULL)
{
return 0;
}
Window_ShowScheduleTreecore(T->lch);
outtextxy(500, Y_Dis, "事件属性: ");
outtextxy(600, Y_Dis, T->Classname);
Y_Dis = Y_Dis + 30;
outtextxy(500, Y_Dis, "时间: ");
outtextxy(600, Y_Dis, T->Time);
Y_Dis = Y_Dis + 30;
outtextxy(500, Y_Dis, "地点: ");
outtextxy(600, Y_Dis, T->Location);
Y_Dis = Y_Dis + 30;
outtextxy(500, Y_Dis, "详情: ");
outtextxy(600, Y_Dis, T->Describe);
Y_Dis = Y_Dis + 30;
Number_of_Things++;
Window_ShowScheduleTreecore(T->rch);
}
// 添加功能主函数
int Window_AddSchduleTree(SchedulelTree* T)
{
Window_ShowScheduleTree_updown(*T);
Window_ShowScheduleTree(*T);
Text_buttoncore(1000, 250, 160, 40, "确定");
Text_buttoncore(1200, 250, 160, 40, "返回");
settextcolor(BLACK); //设置字体颜色
setbkmode(TRANSPARENT); //设置字体背景
settextstyle(25, 0, "微软雅黑"); //设置字体样式、大小
outtextxy(980, 55, "项目属性:");
Add_txtClass.Create(1070, 50, 1350, 80, 30); // 创建项目类型文本框控件
outtextxy(1000, 105, "时 间:");
Add_txtTime.Create(1070, 100, 1350, 130, 30); // 创建时间文本框控件
outtextxy(1000, 155, "地 点:");
Add_txtPlace.Create(1070, 150, 1350, 180, 30); // 创建地点文本框控件
outtextxy(1000, 205, "详 情:");
Add_txtDescribe.Create(1070, 200, 1350, 230, 30); // 创建详情文本框控件
ExMessage msg;
int a = 1;
while (a)
{
msg = getmessage(EM_MOUSE); // 获取消息输入
if (msg.message == WM_LBUTTONDOWN)
{
// 判断控件
if (Add_txtClass.Check(msg.x, msg.y)) Add_txtClass.OnMessage();
//判断控件
if (Add_txtTime.Check(msg.x, msg.y)) Add_txtTime.OnMessage();
//判断控件
if (Add_txtPlace.Check(msg.x, msg.y)) Add_txtPlace.OnMessage();
// 判断控件
if (Add_txtDescribe.Check(msg.x, msg.y)) Add_txtDescribe.OnMessage();
// 退出循环
if (msg.x >= 1000 && msg.x <= 1160 && msg.y >= 250 && msg.y <= 290)
{
a = 0;
}
if (msg.x >= 1200 && msg.x <= 1360 && msg.y >= 250 && msg.y <= 290)
{
BeginBatchDraw();
cleardevice();
Text_button();
EndBatchDraw();
return 0;
}
}
}
BeginBatchDraw();
cleardevice();
Text_button();
EndBatchDraw();
change("添加成功");
SchedulelTreeNode* parent = (SchedulelTreeNode*)malloc(sizeof(SchedulelTreeNode)); //表示双亲结点;
SchedulelTreeNode* head = *T;
SchedulelTreeNode* p = (SchedulelTreeNode*)malloc(sizeof(SchedulelTreeNode));
strcpy(p->Classname, Add_txtClass.Text());
strcpy(p->Time, Add_txtTime.Text());
strcpy(p->Location, Add_txtPlace.Text());
strcpy(p->Describe, Add_txtDescribe.Text()); //保存结点数据;
p->lch = p->rch = NULL; //左右子树置空;
//查找需要添加的父结点,这个父结点是度为0的结点;
while (head)
{
parent = head;
if ((strcmp(p->Time, head->Time)) == -1) //若关键字小于结点的数据;
head = head->lch; //在左子树上查找;
else //若关键字大于结点的数据;
head = head->rch; //在右子树上查找;
}
//判断添加到左子树还是右子树;
if (strcmp(p->Time, parent->Time) == -1) //小于父结点;
parent->lch = p; //添加到左子树;
else //大于父结点;
parent->rch = p; //添加到右子树;
return 0;
}
//删除功能主函数
void Window_Delete(SchedulelTree* T)
{
Window_ShowScheduleTree_updown(*T);
Window_ShowScheduleTree(*T);
Text_buttoncore(1000, 250, 160, 40, "确定");
Text_buttoncore(1200, 250, 160, 40, "返回");
settextcolor(BLACK); //设置字体颜色
setbkmode(TRANSPARENT); //设置字体背景
settextstyle(25, 0, "微软雅黑"); //设置字体样式、大小
outtextxy(1000, 165, "请输入要删除的日期(如7月9日,输入7.9):");
Delete_txtTime.Create(1000, 200, 1350, 230, 30); // 创建时间文本框控件
ExMessage msg;
int a = 1; //判断写入循环
while (a)
{
msg = getmessage(EM_MOUSE); // 获取消息输入
if (msg.message == WM_LBUTTONDOWN)
{
// 判断控件
if (Delete_txtTime.Check(msg.x, msg.y)) Delete_txtTime.OnMessage();
// 退出循环
if (msg.x >= 1000 && msg.x <= 1160 && msg.y >= 250 && msg.y <= 290)
{
a = 0;
}
if (msg.x >= 1200 && msg.x <= 1360 && msg.y >= 250 && msg.y <= 290)
{
BeginBatchDraw();
cleardevice();
Text_button();
EndBatchDraw();
return;
}
}
}
Window_DeleteScheduleTree(T, Delete_txtTime.Text());
BeginBatchDraw();
cleardevice();
Text_button();
EndBatchDraw();
}
//删除功能核心
void Window_DeleteScheduleTree(SchedulelTree* T, char* Time)
{
if (NULL == *T)
{
printf("\n\n删除错误!\n\n");
return; //空树直接报错
}
SchedulelTreeNode* p;
SchedulelTreeNode* f = NULL;
SchedulelTreeNode* q, * s;
if (Search(*T, Time, NULL, &p)) //确实存在值为key的节点,则p指向该节点
{
if (NULL == p->lch && NULL != p->rch) //无左孩子,有右孩子
{
q = p->rch;
strcpy(p->Classname, q->Classname);
strcpy(p->Time, q->Time);
strcpy(p->Location, q->Location);
strcpy(p->Describe, q->Describe);
//因为两个节点之间本质的不同在于数据域的不同,而与放在哪个地址没有关系
p->rch = q->rch;
p->lch = q->lch;
free(q);
}
else if (NULL == p->rch && NULL != p->lch) //无右孩子,有左孩子
{
q = p->lch;
strcpy(p->Classname, q->Classname);
strcpy(p->Time, q->Time);
strcpy(p->Location, q->Location);
strcpy(p->Describe, q->Describe);
p->rch = q->rch;
p->lch = q->lch;
free(q);
}
else if (NULL != p->rch && NULL != p->lch) //既有左孩子,又有右孩子
{
q = p;
s = p->lch; //找左孩子的最右孩子
while (s->rch)
{
q = s;
s = s->rch;
}
strcpy(p->Classname, q->Classname);
strcpy(p->Time, s->Time);
strcpy(p->Location, s->Location);
strcpy(p->Describe, s->Describe);
if (q != p)
{
q->rch = s->lch;
}
else
{
q->lch = s->lch;
}
free(s);
}
else
{
if (*T == p) //只有一个根节点
{
free(*T);
*T = NULL;
return;
}
SchedulelTreeNode* parent = FindParent(*T, p);
if (parent->lch == p)
{
parent->lch = NULL;
}
else
{
parent->rch = NULL;
}
free(p);
}
}
return;
}
//查找功能主函数
int Search_flag = 1;
int Window_SearchSchedudle(SchedulelTree T)
{
Window_ShowScheduleTree_updown(T);
Window_ShowScheduleTree(T);
Text_buttoncore(950, 250, 160, 40, "确定");
Text_buttoncore(1200, 250, 160, 40, "返回");
settextcolor(BLACK); //设置字体颜色
setbkmode(TRANSPARENT); //设置字体背景
settextstyle(25, 0, "微软雅黑"); //设置字体样式、大小
outtextxy(1000, 165, "请输入要查询的日期(如7月10日,输入7.10):");
Search_txtTime.Create(1000, 200, 1350, 230, 30); // 创建时间文本框控件
ExMessage msg;
int a = 1; //判断写入循环
while (a)
{
msg = getmessage(EM_MOUSE); // 获取消息输入
if (msg.message == WM_LBUTTONDOWN)
{
// 判断控件
if (Search_txtTime.Check(msg.x, msg.y)) Search_txtTime.OnMessage();
// 退出循环
if (msg.x >= 950 && msg.x <= 1110 && msg.y >= 250 && msg.y <= 290)
{
a = 0;
BeginBatchDraw();
cleardevice();
Text_button();
EndBatchDraw();
}
if (msg.x >= 1200 && msg.x <= 1360 && msg.y >= 250 && msg.y <= 290)
{
BeginBatchDraw();
cleardevice();
Text_button();
EndBatchDraw();
return 0;
}
}
}
Window_SearchSchedudle_core(T, Search_txtTime.Text());
while (Search_flag)
{
msg = getmessage(EM_MOUSE); // 获取消息输入
if (msg.message == WM_LBUTTONDOWN)
if (msg.x >= 500 && msg.x <= 700 && msg.y >= 280 && msg.y <= 330)
{
BeginBatchDraw();
cleardevice();
Text_button();
EndBatchDraw();
return 0;
}
}
return 0;
}
//查找功能核心
int Window_SearchSchedudle_core(SchedulelTree T, char* Time)
{
if (T == NULL)
{
change("当天您没有待办事项");
BeginBatchDraw();
cleardevice();
Text_button();
EndBatchDraw();
Search_flag = 0;
return 0;
}
if (!strcmp(T->Time, Time))
{
change("查询到了您要找的事项:");
Text_buttoncore(500, 280, 160, 40, "确定");
int Y_dis = 120;
outtextxy(500, Y_dis, "您当日的待办事项: ");
Y_dis = Y_dis + 30;
outtextxy(500, Y_dis, "事件属性: ");
outtextxy(600, Y_dis, T->Classname);
Y_dis = Y_dis + 30;
outtextxy(500, Y_dis, "时间: ");
outtextxy(600, Y_dis, T->Time);
Y_dis = Y_dis + 30;
outtextxy(500, Y_dis, "地点: ");
outtextxy(600, Y_dis, T->Location);
Y_dis = Y_dis + 30;
outtextxy(500, Y_dis, "详情: ");
outtextxy(600, Y_dis, T->Describe);
Search_flag = 1;
return 1;
}
if (strcmp(T->Time, Time) > 0)
{
Window_SearchSchedudle_core(T->lch, Time);
}
if (strcmp(T->Time, Time) < 0)
{
Window_SearchSchedudle_core(T->rch, Time);
}
}
//修改功能主函数
void Window_AmendSchedule_Describe(SchedulelTree T)
{
Window_ShowScheduleTree_updown(T);
Window_ShowScheduleTree(T);
AmendFlag = 0;
Text_buttoncore(1000, 250, 160, 40, "确定");
Text_buttoncore(1200, 250, 160, 40, "返回");
settextcolor(BLACK); //设置字体颜色
setbkmode(TRANSPARENT); //设置字体背景
settextstyle(25, 0, "微软雅黑"); //设置字体样式、大小
outtextxy(875, 165, "请输入要修改待办事件的日期以查找事件(如7月9号,请输入7.9):");
Amend_txtTime.Create(1000, 200, 1350, 230, 30); // 创建时间文本框控件
ExMessage msg;
int a = 1; //判断写入循环
while (a)
{
msg = getmessage(EM_MOUSE); // 获取消息输入
if (msg.message == WM_LBUTTONDOWN)
{
// 判断控件
if (Amend_txtTime.Check(msg.x, msg.y)) Amend_txtTime.OnMessage();
// 退出循环
if (msg.x >= 1000 && msg.x <= 1160 && msg.y >= 250 && msg.y <= 290)
{
a = 0;
}
if (msg.x >= 1200 && msg.x <= 1360 && msg.y >= 250 && msg.y <= 290)
{
BeginBatchDraw();
cleardevice();
Text_button();
EndBatchDraw();
return;
}
}
}
Window_AmendSchedule_Describe_core(T, Amend_txtTime.Text());
//printf("%d", AmendFlag);
if (AmendFlag == 0)
{
change("当天无待办事项!");
BeginBatchDraw();
cleardevice();
Text_button();
EndBatchDraw();
return;
}
else if (AmendFlag == 2)
{
Text_buttoncore(500, 510, 160, 40, "返回");
while (1)
{
msg = getmessage(EM_MOUSE); // 获取消息输入
if (msg.message == WM_LBUTTONDOWN)
if (msg.x >= 500 && msg.x <= 660 && msg.y >= 510 && msg.y <= 550)
{
BeginBatchDraw();
cleardevice();
Text_button();
EndBatchDraw();
return;
}
}
}
}
//修改功能核心
int Window_AmendSchedule_Describe_core(SchedulelTree T, char* Time)
{
if (T == NULL)
{
return 0;
}
if (!strcmp(T->Time, Time))
{
BeginBatchDraw();
cleardevice();
Text_button();
EndBatchDraw();
change("查询到了您要找的事项:");
outtextxy(500, 30, "您当日的待办事项: ");
outtextxy(500, 60, "事件属性: ");
outtextxy(600, 60, T->Classname);
outtextxy(500, 90, "时间: ");
outtextxy(600, 90, T->Time);
outtextxy(500, 120, "地点: ");
outtextxy(600, 120, T->Location);
outtextxy(500, 150, "详情: ");
outtextxy(600, 150, T->Describe);
outtextxy(400, 210, "请选择要修改的属性:A.事件属性 B. 地点 C. 详情");
Text_buttoncore(450, 240, 100, 25, "A.事件属性");
Text_buttoncore(570, 240, 100, 25, " B. 地点 ");
Text_buttoncore(690, 240, 100, 25, "C. 详情");
ExMessage msg;
while (1)
{
msg = getmessage(EM_MOUSE); // 获取消息输入
if (msg.message == WM_LBUTTONDOWN)
{
if (msg.x >= 450 && msg.x <= 550 && msg.y >= 240 && msg.y <= 265)
{
outtextxy(400, 270, "请选择新的事件属性:A.工作类 B.生活类 C.学习类");
Text_buttoncore(450, 300, 100, 25, "A.工作类");
Text_buttoncore(570, 300, 100, 25, " B. 生活类 ");
Text_buttoncore(690, 300, 100, 25, "C. 学习类");
ExMessage msg_1;
while (1)
{
msg_1 = getmessage(EM_MOUSE);
if (msg_1.message == WM_LBUTTONDOWN)
{
if (msg_1.x >= 450 && msg_1.x <= 550 && msg_1.y >= 300 && msg_1.y <= 325)
{
strcpy(T->Classname, "工作类");
break;
}
else if (msg_1.x >= 570 && msg_1.x <= 670 && msg_1.y >= 300 && msg_1.y <= 325)
{
strcpy(T->Classname, "生活类");
break;
}
else if (msg_1.x >= 690 && msg_1.x <= 790 && msg_1.y >= 300 && msg_1.y <= 325)
{
strcpy(T->Classname, "学习类");
break;
}
}
}
break;
}
else if (msg.x >= 570 && msg.x <= 670 && msg.y >= 240 && msg.y <= 265)
{
outtextxy(400, 280, "请输入新的地点:");
Amend_txtPlace.Create(560, 275, 800, 305, 30); // 创建修改地点文本框控件
Text_buttoncore(500, 320, 100, 25, "确定");
ExMessage msg_2;
int a = 1;
while (a)
{
msg_2 = getmessage(EM_MOUSE); // 获取消息输入
if (msg_2.message == WM_LBUTTONDOWN)
{
// 判断控件
if (Amend_txtPlace.Check(msg_2.x, msg_2.y)) Amend_txtPlace.OnMessage();
// 退出循环
if (msg_2.x >= 500 && msg_2.x <= 600 && msg_2.y >= 320 && msg_2.y <= 335)
{
a = 0;
}
}
}
strcpy(T->Location, Amend_txtPlace.Text());
break;
}
else if (msg.x >= 690 && msg.x <= 790 && msg.y >= 240 && msg.y <= 265)
{
outtextxy(400, 280, "请输入新的事件:");
Amend_txtDescribe.Create(560, 275, 800, 305, 30); // 创建修改事件文本框控件
Text_buttoncore(500, 320, 100, 25, "确定");
ExMessage msg_3;
int a = 1;
while (a)
{
msg_3 = getmessage(EM_MOUSE); // 获取消息输入
if (msg_3.message == WM_LBUTTONDOWN)
{
// 判断控件
if (Amend_txtDescribe.Check(msg_3.x, msg_3.y)) Amend_txtDescribe.OnMessage();
// 退出循环
if (msg_3.x >= 500 && msg_3.x <= 600 && msg_3.y >= 320 && msg_3.y <= 335)
{
a = 0;
}
}
}
strcpy(T->Describe, Amend_txtDescribe.Text());
break;
}
}
}
change("修改成功!");
outtextxy(500, 360, "您当日的待办事项: ");
outtextxy(500, 390, "事件属性: ");
outtextxy(600, 390, T->Classname);
outtextxy(500, 420, "时间: ");
outtextxy(600, 420, T->Time);
outtextxy(500, 450, "地点: ");
outtextxy(600, 450, T->Location);
outtextxy(500, 480, "详情: ");
outtextxy(600, 480, T->Describe);
AmendFlag = 2;
return 2;
}
if (strcmp(T->Time, Time) > 0)
{
Window_AmendSchedule_Describe_core(T->lch, Time);
}
if (strcmp(T->Time, Time) < 0)
{
Window_AmendSchedule_Describe_core(T->rch, Time);
}
}
//类别显示主函数
int Y_Dis1 = 30;
int Window_ShowScheduleTree_Class(SchedulelTree T)
{
BeginBatchDraw();
char Classname[10];
Text_buttoncore(1100, 250, 160, 40, "返回");
settextcolor(BLACK); //设置字体颜色
setbkmode(TRANSPARENT); //设置字体背景
settextstyle(25, 0, "微软雅黑"); //设置字体样式、大小
outtextxy(900, 165, "请选择您要显示待办事项的类别:A.工作类 B.生活类 C.学习类");
Text_buttoncore(1000, 200, 100, 25, "A.工作类");
Text_buttoncore(1120, 200, 100, 25, " B. 生活类 ");
Text_buttoncore(1240, 200, 100, 25, "C. 学习类");
EndBatchDraw();
ExMessage msg;
while (1)
{
msg = getmessage(EM_MOUSE); // 获取消息输入
if (msg.message == WM_LBUTTONDOWN)
{
if (msg.x >= 1000 && msg.x <= 1100 && msg.y >= 200 && msg.y <= 225)
{
strcpy(Classname, "工作类");
break;
}
else if (msg.x >= 1120 && msg.x <= 1220 && msg.y >= 200 && msg.y <= 225)
{
strcpy(Classname, "生活类");
break;
}
else if (msg.x >= 1240 && msg.x <= 1340 && msg.y >= 200 && msg.y <= 225)
{
strcpy(Classname, "学习类");
break;
}
else if (msg.x >= 1100 && msg.x <= 1270 && msg.y >= 250 && msg.y <= 290)
{
BeginBatchDraw();
cleardevice();
Text_button();
EndBatchDraw();
return 0;
}
}
}
Y_Dis1 = 30;
Window_ShowScheduleTree_Class_core(T, Classname);
outtextxy(500, Y_Dis1, "全部该类事件显示完毕 ");
Draw_up_arrows(Arrow_x, Arrow_y);
int temp = 30;
while (1)
{
msg = getmessage(EM_MOUSE); // 获取消息输入
if (msg.message == WM_LBUTTONDOWN)
{
if (msg.x >= 1100 && msg.x <= 1260 && msg.y >= 250 && msg.y <= 290)
{
BeginBatchDraw();
cleardevice();
Text_button();
EndBatchDraw();
return 0;
}
if (msg.x >= 340 && msg.x <= 390 && msg.y >= 300 && msg.y <= 330)
{
temp = temp + 20;
Y_Dis1 = temp;
BeginBatchDraw();
cleardevice();
Text_button();
Text_buttoncore(1000, 200, 100, 25, "A.工作类");
Text_buttoncore(1120, 200, 100, 25, " B. 生活类 ");
Text_buttoncore(1240, 200, 100, 25, "C. 学习类");
outtextxy(900, 165, "请选择您要显示待办事项的类别:A.工作类 B.生活类 C.学习类");
Text_buttoncore(1100, 250, 160, 40, "返回");
Draw_up_arrows(Arrow_x, Arrow_y);
Window_ShowScheduleTree_Class_core(T, Classname);
outtextxy(500, Y_Dis1, "全部该类事件显示完毕 ");
EndBatchDraw();
}
if (msg.x >= 340 && msg.x <= 390 && msg.y >= 250 && msg.y <= 280)
{
temp = temp - 20;
Y_Dis1 = temp;
BeginBatchDraw();
cleardevice();
Text_button();
Text_buttoncore(1000, 200, 100, 25, "A.工作类");
Text_buttoncore(1120, 200, 100, 25, " B. 生活类 ");
Text_buttoncore(1240, 200, 100, 25, "C. 学习类");
outtextxy(900, 165, "请选择您要显示待办事项的类别:A.工作类 B.生活类 C.学习类");
Text_buttoncore(1100, 250, 160, 40, "返回");
Draw_up_arrows(Arrow_x, Arrow_y);
Window_ShowScheduleTree_Class_core(T, Classname);
outtextxy(500, Y_Dis1, "全部该类事件显示完毕 ");
EndBatchDraw();
}
}
}
return 0;
}
//类别显示功能核心
int Window_ShowScheduleTree_Class_core(SchedulelTree T, char* Classname)
{
if (T == NULL)
{
return 0;
}
Window_ShowScheduleTree_Class_core(T->lch, Classname);
if (!strcmp(Classname, T->Classname))
{
outtextxy(400, Y_Dis1, "事件属性: ");
outtextxy(500, Y_Dis1, T->Classname);
Y_Dis1 = Y_Dis1 + 30;
outtextxy(400, Y_Dis1, "时间: ");
outtextxy(500, Y_Dis1, T->Time);
Y_Dis1 = Y_Dis1 + 30;
outtextxy(400, Y_Dis1, "地点: ");
outtextxy(500, Y_Dis1, T->Location);
Y_Dis1 = Y_Dis1 + 30;
outtextxy(400, Y_Dis1, "详情: ");
outtextxy(500, Y_Dis1, T->Describe);
Y_Dis1 = Y_Dis1 + 30;
}
Window_ShowScheduleTree_Class_core(T->rch, Classname);
}
//功能菜单
void Get_Mousemessage(SchedulelTreeNode* T)
{
ExMessage msg;
while (1)
{
if (peekmessage(&msg, EM_MOUSE))
{
if (msg.message == WM_LBUTTONDOWN)
{
if (msg.x >= 30 && msg.x <= 30 + 200 && msg.y >= 60 && msg.y <= 60 + 50)
{
BeginBatchDraw();
cleardevice();
Text_button();
EndBatchDraw();
Window_AddSchduleTree(&T);
}
else if (msg.x >= 30 && msg.x <= 30 + 200 && msg.y >= 130 && msg.y <= 130 + 50)
{
BeginBatchDraw();
cleardevice();
Text_button();
EndBatchDraw();
Window_Delete(&T);
}
else if (msg.x >= 30 && msg.x <= 30 + 200 && msg.y >= 200 && msg.y <= 200 + 50)
{
BeginBatchDraw();
cleardevice();
Text_button();
EndBatchDraw();
Window_ShowScheduleTree_Class(T);
}
else if (msg.x >= 30 && msg.x <= 30 + 200 && msg.y >= 270 && msg.y <= 270 + 50)
{
BeginBatchDraw();
cleardevice();
Text_button();
EndBatchDraw();
Window_ShowScheduleTree_updown(T);
}
else if (msg.x >= 30 && msg.x <= 30 + 200 && msg.y >= 340 && msg.y <= 340 + 50)
{
BeginBatchDraw();
cleardevice();
Text_button();
EndBatchDraw();
Window_SearchSchedudle(T);
}
else if (msg.x >= 30 && msg.x <= 30 + 200 && msg.y >= 410 && msg.y <= 410 + 50)
{
BeginBatchDraw();
cleardevice();
Text_button();
EndBatchDraw();
Window_AmendSchedule_Describe(T);
}
else if (msg.x >= 30 && msg.x <= 30 + 200 && msg.y >= 480 && msg.y <= 480 + 50)
{
remove("data.txt"); //删除之前的文件
SaveData(T);
closegraph(); //关闭窗口
}
}
}
}
}
int main()
{
SchedulelTree T;
//initial();
initialScheduleTree(&T);
Create_window(1500, 600);
Text_button();
//ShowScheduleTree(T);
//ShowMenu(T);
//LeaveSystem(T);
Get_Mousemessage(T);
getchar();
}